[CoordinatedGraphics] Use modern for-loops
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Oct 2014 01:18:32 +0000 (01:18 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Oct 2014 01:18:32 +0000 (01:18 +0000)
https://bugs.webkit.org/show_bug.cgi?id=138168

Patch by Hunseop Jeong <hs85.jeong@samsung.com> on 2014-10-29
Reviewed by Andreas Kling.

No new tests as there is no change in functionality.

Source/WebCore:

* platform/graphics/texmap/coordinated/CompositingCoordinator.cpp: Use a modern for loop.
(WebCore::CompositingCoordinator::renderNextFrame):
(WebCore::CompositingCoordinator::paintToSurface):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp: Use a modern for loop.
(WebCore::CoordinatedGraphicsLayer::setShouldUpdateVisibleRect):
(WebCore::CoordinatedGraphicsLayer::flushCompositingState):
(WebCore::CoordinatedGraphicsLayer::syncChildren):
(WebCore::CoordinatedGraphicsLayer::syncPendingStateChangesIncludingSubLayers):
(WebCore::CoordinatedGraphicsLayer::findFirstDescendantWithContentsRecursively):
(WebCore::CoordinatedGraphicsLayer::updateContentBuffersIncludingSubLayers):
* platform/graphics/texmap/coordinated/CoordinatedImageBacking.cpp: Use a modern for loop.
(WebCore::CoordinatedImageBacking::updateVisibilityIfNeeded):

Source/WebKit2:

* UIProcess/CoordinatedGraphics/CoordinatedBackingStore.cpp: Use a modern for loop.
(WebCore::CoordinatedBackingStore::texture):
(WebCore::CoordinatedBackingStore::paintTilesToTextureMapper):
* UIProcess/CoordinatedGraphics/CoordinatedDrawingAreaProxy.cpp: Use a modern for loop.
(WebKit::CoordinatedDrawingAreaProxy::incorporateUpdate):
* UIProcess/CoordinatedGraphics/CoordinatedGraphicsScene.cpp: Use a modern for loop.
(WebCore::CoordinatedGraphicsScene::setLayerChildrenIfNeeded):
(WebCore::CoordinatedGraphicsScene::createLayers): changed the name of argument to be equal with deleteLayer().
(WebCore::CoordinatedGraphicsScene::deleteLayers):
(WebCore::CoordinatedGraphicsScene::createTilesIfNeeded):
(WebCore::CoordinatedGraphicsScene::removeTilesIfNeeded):
(WebCore::CoordinatedGraphicsScene::updateTilesIfNeeded):
(WebCore::CoordinatedGraphicsScene::syncUpdateAtlases):
(WebCore::CoordinatedGraphicsScene::syncImageBackings):
(WebCore::CoordinatedGraphicsScene::commitSceneState):
* WebProcess/WebPage/CoordinatedGraphics/CoordinatedDrawingArea.cpp: Use a modern for loop.
(WebKit::shouldPaintBoundsRect):
(WebKit::CoordinatedDrawingArea::display):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@175361 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.cpp
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedImageBacking.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedBackingStore.cpp
Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedDrawingAreaProxy.cpp
Source/WebKit2/UIProcess/CoordinatedGraphics/CoordinatedGraphicsScene.cpp
Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedDrawingArea.cpp

index 50104b6..d975e35 100644 (file)
@@ -1,3 +1,25 @@
+2014-10-29  Hunseop Jeong  <hs85.jeong@samsung.com>
+
+        [CoordinatedGraphics] Use modern for-loops
+        https://bugs.webkit.org/show_bug.cgi?id=138168
+
+        Reviewed by Andreas Kling.
+
+        No new tests as there is no change in functionality.
+
+        * platform/graphics/texmap/coordinated/CompositingCoordinator.cpp: Use a modern for loop.
+        (WebCore::CompositingCoordinator::renderNextFrame):
+        (WebCore::CompositingCoordinator::paintToSurface):
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp: Use a modern for loop.
+        (WebCore::CoordinatedGraphicsLayer::setShouldUpdateVisibleRect):
+        (WebCore::CoordinatedGraphicsLayer::flushCompositingState):
+        (WebCore::CoordinatedGraphicsLayer::syncChildren):
+        (WebCore::CoordinatedGraphicsLayer::syncPendingStateChangesIncludingSubLayers):
+        (WebCore::CoordinatedGraphicsLayer::findFirstDescendantWithContentsRecursively):
+        (WebCore::CoordinatedGraphicsLayer::updateContentBuffersIncludingSubLayers):
+        * platform/graphics/texmap/coordinated/CoordinatedImageBacking.cpp: Use a modern for loop.
+        (WebCore::CoordinatedImageBacking::updateVisibilityIfNeeded):
+
 2014-10-29  Chris Dumez  <cdumez@apple.com>
 
         Final-ize more of TextFieldInputType's virtual functions
index f0910be..0da429b 100644 (file)
@@ -356,8 +356,8 @@ void CompositingCoordinator::commitScrollOffset(uint32_t layerID, const WebCore:
 
 void CompositingCoordinator::renderNextFrame()
 {
-    for (unsigned i = 0; i < m_updateAtlases.size(); ++i)
-        m_updateAtlases[i]->didSwapBuffers();
+    for (auto& atlas : m_updateAtlases)
+        atlas->didSwapBuffers();
 }
 
 void CompositingCoordinator::purgeBackingStores()
@@ -373,8 +373,8 @@ void CompositingCoordinator::purgeBackingStores()
 
 bool CompositingCoordinator::paintToSurface(const IntSize& size, CoordinatedSurface::Flags flags, uint32_t& atlasID, IntPoint& offset, CoordinatedSurface::Client* client)
 {
-    for (unsigned i = 0; i < m_updateAtlases.size(); ++i) {
-        UpdateAtlas* atlas = m_updateAtlases[i].get();
+    for (auto& updateAtlas : m_updateAtlases) {
+        UpdateAtlas* atlas = updateAtlas.get();
         if (atlas->supportsAlpha() == (flags & CoordinatedSurface::SupportsAlpha)) {
             // This will be false if there is no available buffer space.
             if (atlas->paintOnAvailableBuffer(size, atlasID, offset, client))
index 37b76c5..04c908b 100644 (file)
@@ -91,8 +91,8 @@ void CoordinatedGraphicsLayer::didChangeImageBacking()
 void CoordinatedGraphicsLayer::setShouldUpdateVisibleRect()
 {
     m_shouldUpdateVisibleRect = true;
-    for (size_t i = 0; i < children().size(); ++i)
-        toCoordinatedGraphicsLayer(children()[i])->setShouldUpdateVisibleRect();
+    for (auto& child : children())
+        toCoordinatedGraphicsLayer(child)->setShouldUpdateVisibleRect();
     if (replicaLayer())
         toCoordinatedGraphicsLayer(replicaLayer())->setShouldUpdateVisibleRect();
 }
@@ -598,8 +598,8 @@ void CoordinatedGraphicsLayer::flushCompositingState(const FloatRect& rect)
 
     flushCompositingStateForThisLayerOnly();
 
-    for (size_t i = 0; i < children().size(); ++i)
-        children()[i]->flushCompositingState(rect);
+    for (auto& child : children())
+        child->flushCompositingState(rect);
 }
 
 CoordinatedGraphicsLayer* toCoordinatedGraphicsLayer(GraphicsLayer* layer)
@@ -614,8 +614,8 @@ void CoordinatedGraphicsLayer::syncChildren()
     m_shouldSyncChildren = false;
     m_layerState.childrenChanged = true;
     m_layerState.children.clear();
-    for (size_t i = 0; i < children().size(); ++i)
-        m_layerState.children.append(toCoordinatedLayerID(children()[i]));
+    for (auto& child : children())
+        m_layerState.children.append(toCoordinatedLayerID(child));
 }
 
 void CoordinatedGraphicsLayer::syncFilters()
@@ -802,8 +802,8 @@ void CoordinatedGraphicsLayer::syncPendingStateChangesIncludingSubLayers()
     if (maskLayer())
         toCoordinatedGraphicsLayer(maskLayer())->syncPendingStateChangesIncludingSubLayers();
 
-    for (size_t i = 0; i < children().size(); ++i)
-        toCoordinatedGraphicsLayer(children()[i])->syncPendingStateChangesIncludingSubLayers();
+    for (auto& child : children())
+        toCoordinatedGraphicsLayer(child)->syncPendingStateChangesIncludingSubLayers();
 }
 
 void CoordinatedGraphicsLayer::resetLayerState()
@@ -842,8 +842,8 @@ CoordinatedGraphicsLayer* CoordinatedGraphicsLayer::findFirstDescendantWithConte
     if (shouldHaveBackingStore())
         return this;
 
-    for (size_t i = 0; i < children().size(); ++i) {
-        CoordinatedGraphicsLayer* layer = toCoordinatedGraphicsLayer(children()[i])->findFirstDescendantWithContentsRecursively();
+    for (auto& child : children()) {
+        CoordinatedGraphicsLayer* layer = toCoordinatedGraphicsLayer(child)->findFirstDescendantWithContentsRecursively();
         if (layer)
             return layer;
     }
@@ -1003,8 +1003,8 @@ void CoordinatedGraphicsLayer::updateContentBuffersIncludingSubLayers()
 
     updateContentBuffers();
 
-    for (size_t i = 0; i < children().size(); ++i)
-        toCoordinatedGraphicsLayer(children()[i])->updateContentBuffersIncludingSubLayers();
+    for (auto& child : children())
+        toCoordinatedGraphicsLayer(child)->updateContentBuffersIncludingSubLayers();
 }
 
 void CoordinatedGraphicsLayer::updateContentBuffers()
index 50f4eee..80c4eed 100644 (file)
@@ -151,8 +151,8 @@ void CoordinatedImageBacking::updateVisibilityIfNeeded(bool& changedToVisible)
     bool previousIsVisible = m_isVisible;
 
     m_isVisible = false;
-    for (size_t i = 0; i < m_hosts.size(); ++i) {
-        if (m_hosts[i]->imageBackingVisible()) {
+    for (auto& host : m_hosts) {
+        if (host->imageBackingVisible()) {
             m_isVisible = true;
             break;
         }
index 8dd8308..b90a646 100644 (file)
@@ -1,3 +1,31 @@
+2014-10-29  Hunseop Jeong  <hs85.jeong@samsung.com>
+
+        [CoordinatedGraphics] Use modern for-loops
+        https://bugs.webkit.org/show_bug.cgi?id=138168
+
+        Reviewed by Andreas Kling.
+
+        No new tests as there is no change in functionality.
+
+        * UIProcess/CoordinatedGraphics/CoordinatedBackingStore.cpp: Use a modern for loop.
+        (WebCore::CoordinatedBackingStore::texture):
+        (WebCore::CoordinatedBackingStore::paintTilesToTextureMapper):
+        * UIProcess/CoordinatedGraphics/CoordinatedDrawingAreaProxy.cpp: Use a modern for loop.
+        (WebKit::CoordinatedDrawingAreaProxy::incorporateUpdate):
+        * UIProcess/CoordinatedGraphics/CoordinatedGraphicsScene.cpp: Use a modern for loop.
+        (WebCore::CoordinatedGraphicsScene::setLayerChildrenIfNeeded):
+        (WebCore::CoordinatedGraphicsScene::createLayers): changed the name of argument to be equal with deleteLayer(). 
+        (WebCore::CoordinatedGraphicsScene::deleteLayers):
+        (WebCore::CoordinatedGraphicsScene::createTilesIfNeeded):
+        (WebCore::CoordinatedGraphicsScene::removeTilesIfNeeded):
+        (WebCore::CoordinatedGraphicsScene::updateTilesIfNeeded):
+        (WebCore::CoordinatedGraphicsScene::syncUpdateAtlases):
+        (WebCore::CoordinatedGraphicsScene::syncImageBackings):
+        (WebCore::CoordinatedGraphicsScene::commitSceneState):
+        * WebProcess/WebPage/CoordinatedGraphics/CoordinatedDrawingArea.cpp: Use a modern for loop.
+        (WebKit::shouldPaintBoundsRect):
+        (WebKit::CoordinatedDrawingArea::display):
+
 2014-10-29  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
 
         Unreviewed, EFL build fix since r175349.
index e23a8cc..105cce0 100644 (file)
@@ -91,9 +91,8 @@ void CoordinatedBackingStore::updateTile(uint32_t id, const IntRect& sourceRect,
 
 PassRefPtr<BitmapTexture> CoordinatedBackingStore::texture() const
 {
-    CoordinatedBackingStoreTileMap::const_iterator end = m_tiles.end();
-    for (CoordinatedBackingStoreTileMap::const_iterator it = m_tiles.begin(); it != end; ++it) {
-        RefPtr<BitmapTexture> texture = it->value.texture();
+    for (auto& tile : m_tiles.values()) {
+        RefPtr<BitmapTexture> texture = tile.texture();
         if (texture)
             return texture;
     }
@@ -108,8 +107,8 @@ void CoordinatedBackingStore::setSize(const FloatSize& size)
 
 void CoordinatedBackingStore::paintTilesToTextureMapper(Vector<TextureMapperTile*>& tiles, TextureMapper* textureMapper, const TransformationMatrix& transform, float opacity, const FloatRect& rect)
 {
-    for (size_t i = 0; i < tiles.size(); ++i)
-        tiles[i]->paint(textureMapper, transform, opacity, calculateExposedTileEdges(rect, tiles[i]->rect()));
+    for (auto& tile : tiles)
+        tile->paint(textureMapper, transform, opacity, calculateExposedTileEdges(rect, tile->rect()));
 }
 
 TransformationMatrix CoordinatedBackingStore::adjustedTransformForRect(const FloatRect& targetRect)
index c48806f..4b5d648 100644 (file)
@@ -253,8 +253,8 @@ void CoordinatedDrawingAreaProxy::incorporateUpdate(const UpdateInfo& updateInfo
     if (shouldScroll && !m_webPageProxy.canScrollView())
         m_webPageProxy.setViewNeedsDisplay(IntRect(IntPoint(), m_webPageProxy.viewSize()));
     else {
-        for (size_t i = 0; i < updateInfo.updateRects.size(); ++i)
-            m_webPageProxy.setViewNeedsDisplay(updateInfo.updateRects[i]);
+        for (auto& updateRect : updateInfo.updateRects)
+            m_webPageProxy.setViewNeedsDisplay(updateRect);
     }
 
     if (shouldScroll)
index 8a64366..a582d83 100644 (file)
@@ -215,10 +215,9 @@ void CoordinatedGraphicsScene::setLayerChildrenIfNeeded(TextureMapperLayer* laye
 
     Vector<TextureMapperLayer*> children;
 
-    for (size_t i = 0; i < state.children.size(); ++i) {
-        CoordinatedLayerID childID = state.children[i];
-        TextureMapperLayer* child = layerByID(childID);
-        children.append(child);
+    for (auto& child : state.children) {
+        TextureMapperLayer* childLayer = layerByID(child);
+        children.append(childLayer);
     }
     layer->setChildren(children);
 }
@@ -322,10 +321,10 @@ TextureMapperLayer* CoordinatedGraphicsScene::getLayerByIDIfExists(CoordinatedLa
     return (id != InvalidCoordinatedLayerID) ? layerByID(id) : 0;
 }
 
-void CoordinatedGraphicsScene::createLayers(const Vector<CoordinatedLayerID>& ids)
+void CoordinatedGraphicsScene::createLayers(const Vector<CoordinatedLayerID>& layerIDs)
 {
-    for (size_t index = 0; index < ids.size(); ++index)
-        createLayer(ids[index]);
+    for (auto& layerID : layerIDs)
+        createLayer(layerID);
 }
 
 void CoordinatedGraphicsScene::createLayer(CoordinatedLayerID id)
@@ -338,8 +337,8 @@ void CoordinatedGraphicsScene::createLayer(CoordinatedLayerID id)
 
 void CoordinatedGraphicsScene::deleteLayers(const Vector<CoordinatedLayerID>& layerIDs)
 {
-    for (size_t index = 0; index < layerIDs.size(); ++index)
-        deleteLayer(layerIDs[index]);
+    for (auto& layerID : layerIDs)
+        deleteLayer(layerID);
 }
 
 void CoordinatedGraphicsScene::deleteLayer(CoordinatedLayerID layerID)
@@ -412,8 +411,8 @@ void CoordinatedGraphicsScene::createTilesIfNeeded(TextureMapperLayer* layer, co
     RefPtr<CoordinatedBackingStore> backingStore = m_backingStores.get(layer);
     ASSERT(backingStore);
 
-    for (size_t i = 0; i < state.tilesToCreate.size(); ++i)
-        backingStore->createTile(state.tilesToCreate[i].tileID, state.tilesToCreate[i].scale);
+    for (auto& tile : state.tilesToCreate)
+        backingStore->createTile(tile.tileID, tile.scale);
 }
 
 void CoordinatedGraphicsScene::removeTilesIfNeeded(TextureMapperLayer* layer, const CoordinatedGraphicsLayerState& state)
@@ -425,8 +424,8 @@ void CoordinatedGraphicsScene::removeTilesIfNeeded(TextureMapperLayer* layer, co
     if (!backingStore)
         return;
 
-    for (size_t i = 0; i < state.tilesToRemove.size(); ++i)
-        backingStore->removeTile(state.tilesToRemove[i]);
+    for (auto& tile : state.tilesToRemove)
+        backingStore->removeTile(tile);
 
     m_backingStoresWithPendingBuffers.add(backingStore);
 }
@@ -439,25 +438,24 @@ void CoordinatedGraphicsScene::updateTilesIfNeeded(TextureMapperLayer* layer, co
     RefPtr<CoordinatedBackingStore> backingStore = m_backingStores.get(layer);
     ASSERT(backingStore);
 
-    for (size_t i = 0; i < state.tilesToUpdate.size(); ++i) {
-        const TileUpdateInfo& tileInfo = state.tilesToUpdate[i];
-        const SurfaceUpdateInfo& surfaceUpdateInfo = tileInfo.updateInfo;
+    for (auto& tile : state.tilesToUpdate) {
+        const SurfaceUpdateInfo& surfaceUpdateInfo = tile.updateInfo;
 
         SurfaceMap::iterator surfaceIt = m_surfaces.find(surfaceUpdateInfo.atlasID);
         ASSERT(surfaceIt != m_surfaces.end());
 
-        backingStore->updateTile(tileInfo.tileID, surfaceUpdateInfo.updateRect, tileInfo.tileRect, surfaceIt->value, surfaceUpdateInfo.surfaceOffset);
+        backingStore->updateTile(tile.tileID, surfaceUpdateInfo.updateRect, tile.tileRect, surfaceIt->value, surfaceUpdateInfo.surfaceOffset);
         m_backingStoresWithPendingBuffers.add(backingStore);
     }
 }
 
 void CoordinatedGraphicsScene::syncUpdateAtlases(const CoordinatedGraphicsState& state)
 {
-    for (size_t i = 0; i < state.updateAtlasesToCreate.size(); ++i)
-        createUpdateAtlas(state.updateAtlasesToCreate[i].first, state.updateAtlasesToCreate[i].second);
+    for (auto& atlas : state.updateAtlasesToCreate)
+        createUpdateAtlas(atlas.first, atlas.second);
 
-    for (size_t i = 0; i < state.updateAtlasesToRemove.size(); ++i)
-        removeUpdateAtlas(state.updateAtlasesToRemove[i]);
+    for (auto& atlas : state.updateAtlasesToRemove)
+        removeUpdateAtlas(atlas);
 }
 
 void CoordinatedGraphicsScene::createUpdateAtlas(uint32_t atlasID, PassRefPtr<CoordinatedSurface> surface)
@@ -474,17 +472,17 @@ void CoordinatedGraphicsScene::removeUpdateAtlas(uint32_t atlasID)
 
 void CoordinatedGraphicsScene::syncImageBackings(const CoordinatedGraphicsState& state)
 {
-    for (size_t i = 0; i < state.imagesToRemove.size(); ++i)
-        removeImageBacking(state.imagesToRemove[i]);
+    for (auto& image : state.imagesToRemove)
+        removeImageBacking(image);
 
-    for (size_t i = 0; i < state.imagesToCreate.size(); ++i)
-        createImageBacking(state.imagesToCreate[i]);
+    for (auto& image : state.imagesToCreate)
+        createImageBacking(image);
 
-    for (size_t i = 0; i < state.imagesToUpdate.size(); ++i)
-        updateImageBacking(state.imagesToUpdate[i].first, state.imagesToUpdate[i].second);
+    for (auto& image : state.imagesToUpdate)
+        updateImageBacking(image.first, image.second);
 
-    for (size_t i = 0; i < state.imagesToClear.size(); ++i)
-        clearImageBackingContents(state.imagesToClear[i]);
+    for (auto& image : state.imagesToClear)
+        clearImageBackingContents(image);
 }
 
 void CoordinatedGraphicsScene::createImageBacking(CoordinatedImageBackingID imageID)
@@ -571,8 +569,8 @@ void CoordinatedGraphicsScene::commitSceneState(const CoordinatedGraphicsState&
     syncImageBackings(state);
     syncUpdateAtlases(state);
 
-    for (size_t i = 0; i < state.layersToUpdate.size(); ++i)
-        setLayerState(state.layersToUpdate[i].first, state.layersToUpdate[i].second);
+    for (auto& layer : state.layersToUpdate)
+        setLayerState(layer.first, layer.second);
 
     commitPendingBackingStoreOperations();
     removeReleasedImageBackingsIfNeeded();
index a8accdb..52857db 100644 (file)
@@ -532,8 +532,8 @@ static bool shouldPaintBoundsRect(const IntRect& bounds, const Vector<IntRect>&
     // is too large, then we will do individual rect painting instead.
     unsigned boundsArea = bounds.width() * bounds.height();
     unsigned rectsArea = 0;
-    for (size_t i = 0; i < rects.size(); ++i)
-        rectsArea += rects[i].width() * rects[i].height();
+    for (auto& rect : rects)
+        rectsArea += rect.width() * rect.height();
 
     double wastedSpace = 1 - (static_cast<double>(rectsArea) / boundsArea);
 
@@ -590,9 +590,9 @@ void CoordinatedDrawingArea::display(UpdateInfo& updateInfo)
 
     graphicsContext->translate(-bounds.x(), -bounds.y());
 
-    for (size_t i = 0; i < rects.size(); ++i) {
-        m_webPage.drawRect(*graphicsContext, rects[i]);
-        updateInfo.updateRects.append(rects[i]);
+    for (auto& rect : rects) {
+        m_webPage.drawRect(*graphicsContext, rect);
+        updateInfo.updateRects.append(rect);
     }
 
     // Layout can trigger more calls to setNeedsDisplay and we don't want to process them