[chromium] Remove unneeded content vs. layer space distinction in tiled layers
authorenne@google.com <enne@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Jan 2012 23:07:32 +0000 (23:07 +0000)
committerenne@google.com <enne@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Jan 2012 23:07:32 +0000 (23:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=75498

Reviewed by James Robinson.

Long ago, before scrollbars became their own layers, tiled layers had
a distinction between content space (what's mostly called layer space
elsewhere) and layer space (the transformed content space). It seemed
like this transform could get reused for supporting RTL pages, but as
that's not the case, it should be eradicated.

Tiled layers now deal with everything in "layer space", which is a 2d
rectangle starting at (0, 0) in the top left of the layer and
extending to contentBounds() in the bottom right.

As no code actually set the tiler position, this change should be a
no-op.

Test: LayoutTests/compositing/

* platform/graphics/chromium/TiledLayerChromium.cpp:
(WebCore::UpdatableTile::isDirty):
(WebCore::UpdatableTile::clearDirty):
(WebCore::TiledLayerChromium::updateCompositorResources):
(WebCore::TiledLayerChromium::createTile):
(WebCore::TiledLayerChromium::invalidateRect):
(WebCore::TiledLayerChromium::protectTileTextures):
(WebCore::TiledLayerChromium::prepareToUpdateTiles):
(WebCore::TiledLayerChromium::prepareToUpdate):
(WebCore::TiledLayerChromium::prepareToUpdateIdle):
(WebCore::TiledLayerChromium::needsIdlePaint):
(WebCore::TiledLayerChromium::idlePaintRect):
* platform/graphics/chromium/TiledLayerChromium.h:
* platform/graphics/chromium/cc/CCLayerTilingData.cpp:
(WebCore::CCLayerTilingData::operator=):
(WebCore::CCLayerTilingData::layerRectToTileIndices):
(WebCore::CCLayerTilingData::tileRect):
* platform/graphics/chromium/cc/CCLayerTilingData.h:
* platform/graphics/chromium/cc/CCTiledLayerImpl.cpp:
(WebCore::CCTiledLayerImpl::appendQuads):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/TiledLayerChromium.h
Source/WebCore/platform/graphics/chromium/cc/CCLayerTilingData.cpp
Source/WebCore/platform/graphics/chromium/cc/CCLayerTilingData.h
Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.cpp

index 8f46212..bc5cc8c 100644 (file)
@@ -1,3 +1,46 @@
+2012-01-03  Adrienne Walker  <enne@google.com>
+
+        [chromium] Remove unneeded content vs. layer space distinction in tiled layers
+        https://bugs.webkit.org/show_bug.cgi?id=75498
+
+        Reviewed by James Robinson.
+
+        Long ago, before scrollbars became their own layers, tiled layers had
+        a distinction between content space (what's mostly called layer space
+        elsewhere) and layer space (the transformed content space). It seemed
+        like this transform could get reused for supporting RTL pages, but as
+        that's not the case, it should be eradicated.
+
+        Tiled layers now deal with everything in "layer space", which is a 2d
+        rectangle starting at (0, 0) in the top left of the layer and
+        extending to contentBounds() in the bottom right.
+
+        As no code actually set the tiler position, this change should be a
+        no-op.
+
+        Test: LayoutTests/compositing/
+
+        * platform/graphics/chromium/TiledLayerChromium.cpp:
+        (WebCore::UpdatableTile::isDirty):
+        (WebCore::UpdatableTile::clearDirty):
+        (WebCore::TiledLayerChromium::updateCompositorResources):
+        (WebCore::TiledLayerChromium::createTile):
+        (WebCore::TiledLayerChromium::invalidateRect):
+        (WebCore::TiledLayerChromium::protectTileTextures):
+        (WebCore::TiledLayerChromium::prepareToUpdateTiles):
+        (WebCore::TiledLayerChromium::prepareToUpdate):
+        (WebCore::TiledLayerChromium::prepareToUpdateIdle):
+        (WebCore::TiledLayerChromium::needsIdlePaint):
+        (WebCore::TiledLayerChromium::idlePaintRect):
+        * platform/graphics/chromium/TiledLayerChromium.h:
+        * platform/graphics/chromium/cc/CCLayerTilingData.cpp:
+        (WebCore::CCLayerTilingData::operator=):
+        (WebCore::CCLayerTilingData::layerRectToTileIndices):
+        (WebCore::CCLayerTilingData::tileRect):
+        * platform/graphics/chromium/cc/CCLayerTilingData.h:
+        * platform/graphics/chromium/cc/CCTiledLayerImpl.cpp:
+        (WebCore::CCTiledLayerImpl::appendQuads):
+
 2011-12-22  Joseph Pecoraro  <pecoraro@apple.com>
 
         Implement Date and Time Input Value Sanitization
index a22d60d..b08ca9a 100644 (file)
@@ -58,12 +58,10 @@ public:
     LayerTextureUpdater::Texture* texture() { return m_texture.get(); }
     ManagedTexture* managedTexture() { return m_texture->texture(); }
 
-    bool isDirty() const { return !m_dirtyLayerRect.isEmpty(); }
-    void clearDirty() { m_dirtyLayerRect = IntRect(); }
+    bool isDirty() const { return !m_dirtyRect.isEmpty(); }
+    void clearDirty() { m_dirtyRect = IntRect(); }
 
-    // Layer-space dirty rectangle that needs to be repainted.
-    IntRect m_dirtyLayerRect;
-    // Content-space rectangle that needs to be updated.
+    IntRect m_dirtyRect;
     IntRect m_updateRect;
 private:
     OwnPtr<LayerTextureUpdater::Texture> m_texture;
@@ -214,7 +212,7 @@ void TiledLayerChromium::updateCompositorResources(GraphicsContext3D*, CCTexture
                 continue;
 
             ASSERT(tile->managedTexture()->isReserved());
-            const IntPoint anchor = m_tiler->tileContentRect(tile).location();
+            const IntPoint anchor = m_tiler->tileRect(tile).location();
 
             // Calculate tile-space rectangle to upload into.
             IntRect destRect(IntPoint(sourceRect.x() - anchor.x(), sourceRect.y() - anchor.y()), sourceRect.size());
@@ -238,7 +236,7 @@ void TiledLayerChromium::updateCompositorResources(GraphicsContext3D*, CCTexture
         }
     }
 
-    m_updateRect = FloatRect(m_tiler->contentRectToLayerRect(m_paintRect));
+    m_updateRect = FloatRect(m_paintRect);
 }
 
 void TiledLayerChromium::setTilingOption(TilingOption tilingOption)
@@ -290,7 +288,7 @@ UpdatableTile* TiledLayerChromium::createTile(int i, int j)
 {
     RefPtr<UpdatableTile> tile = adoptRef(new UpdatableTile(textureUpdater()->createTexture(textureManager())));
     m_tiler->addTile(tile, i, j);
-    tile->m_dirtyLayerRect = m_tiler->tileLayerRect(tile.get());
+    tile->m_dirtyRect = m_tiler->tileRect(tile.get());
 
     return tile.get();
 }
@@ -316,25 +314,21 @@ void TiledLayerChromium::setIsNonCompositedContent(bool isNonCompositedContent)
     setBorderTexelOption(borderTexelOption);
 }
 
-void TiledLayerChromium::invalidateRect(const IntRect& contentRect)
+void TiledLayerChromium::invalidateRect(const IntRect& layerRect)
 {
-    if (m_tiler->isEmpty() || contentRect.isEmpty() || m_skipsDraw)
+    if (m_tiler->isEmpty() || layerRect.isEmpty() || m_skipsDraw)
         return;
 
-    // Dirty rects are always in layer space, as the layer could be repositioned
-    // after invalidation.
-    const IntRect layerRect = m_tiler->contentRectToLayerRect(contentRect);
-
     int left, top, right, bottom;
-    m_tiler->contentRectToTileIndices(contentRect, left, top, right, bottom);
+    m_tiler->layerRectToTileIndices(layerRect, left, top, right, bottom);
     for (int j = top; j <= bottom; ++j) {
         for (int i = left; i <= right; ++i) {
             UpdatableTile* tile = tileAt(i, j);
             if (!tile)
                 continue;
-            IntRect bound = m_tiler->tileLayerRect(tile);
+            IntRect bound = m_tiler->tileRect(tile);
             bound.intersect(layerRect);
-            tile->m_dirtyLayerRect.unite(bound);
+            tile->m_dirtyRect.unite(bound);
         }
     }
 }
@@ -344,13 +338,13 @@ void TiledLayerChromium::protectVisibleTileTextures()
     protectTileTextures(IntRect(IntPoint::zero(), contentBounds()));
 }
 
-void TiledLayerChromium::protectTileTextures(const IntRect& contentRect)
+void TiledLayerChromium::protectTileTextures(const IntRect& layerRect)
 {
-    if (m_tiler->isEmpty() || contentRect.isEmpty())
+    if (m_tiler->isEmpty() || layerRect.isEmpty())
         return;
 
     int left, top, right, bottom;
-    m_tiler->contentRectToTileIndices(contentRect, left, top, right, bottom);
+    m_tiler->layerRectToTileIndices(layerRect, left, top, right, bottom);
 
     for (int j = top; j <= bottom; ++j) {
         for (int i = left; i <= right; ++i) {
@@ -381,7 +375,7 @@ void TiledLayerChromium::prepareToUpdateTiles(bool idle, int left, int top, int
                 tile = createTile(i, j);
 
             if (!tile->managedTexture()->isValid(m_tiler->tileSize(), m_textureFormat))
-                tile->m_dirtyLayerRect = m_tiler->tileLayerRect(tile);
+                tile->m_dirtyRect = m_tiler->tileRect(tile);
 
             if (!tile->managedTexture()->reserve(m_tiler->tileSize(), m_textureFormat)) {
                 m_skipsIdlePaint = true;
@@ -392,11 +386,11 @@ void TiledLayerChromium::prepareToUpdateTiles(bool idle, int left, int top, int
                 return;
             }
 
-            dirtyLayerRect.unite(tile->m_dirtyLayerRect);
+            dirtyLayerRect.unite(tile->m_dirtyRect);
         }
     }
 
-    m_paintRect = m_tiler->layerRectToContentRect(dirtyLayerRect);
+    m_paintRect = dirtyLayerRect;
     if (dirtyLayerRect.isEmpty())
         return;
 
@@ -423,9 +417,8 @@ void TiledLayerChromium::prepareToUpdateTiles(bool idle, int left, int top, int
             if (!tile->isDirty())
                 continue;
 
-            // Calculate content-space rectangle to copy from.
-            IntRect sourceRect = m_tiler->tileContentRect(tile);
-            sourceRect.intersect(m_tiler->layerRectToContentRect(tile->m_dirtyLayerRect));
+            IntRect sourceRect = m_tiler->tileRect(tile);
+            sourceRect.intersect(tile->m_dirtyRect);
             // Paint rect not guaranteed to line up on tile boundaries, so
             // make sure that sourceRect doesn't extend outside of it.
             sourceRect.intersect(m_paintRect);
@@ -444,7 +437,7 @@ void TiledLayerChromium::prepareToUpdateTiles(bool idle, int left, int top, int
 }
 
 
-void TiledLayerChromium::prepareToUpdate(const IntRect& contentRect)
+void TiledLayerChromium::prepareToUpdate(const IntRect& layerRect)
 {
     m_skipsDraw = false;
     m_skipsIdlePaint = false;
@@ -453,16 +446,16 @@ void TiledLayerChromium::prepareToUpdate(const IntRect& contentRect)
 
     updateBounds();
 
-    if (contentRect.isEmpty() || !m_tiler->numTiles())
+    if (layerRect.isEmpty() || !m_tiler->numTiles())
         return;
 
     int left, top, right, bottom;
-    m_tiler->contentRectToTileIndices(contentRect, left, top, right, bottom);
+    m_tiler->layerRectToTileIndices(layerRect, left, top, right, bottom);
 
     prepareToUpdateTiles(false, left, top, right, bottom);
 }
 
-void TiledLayerChromium::prepareToUpdateIdle(const IntRect& contentRect)
+void TiledLayerChromium::prepareToUpdateIdle(const IntRect& layerRect)
 {
     // Abort if we have already prepared a paint or run out of memory.
     if (m_skipsIdlePaint || !m_paintRect.isEmpty())
@@ -477,14 +470,14 @@ void TiledLayerChromium::prepareToUpdateIdle(const IntRect& contentRect)
 
     // Protect any textures in the pre-paint area so we don't end up just
     // reclaiming them below.
-    IntRect idlePaintContentRect = idlePaintRect(contentRect);
-    protectTileTextures(idlePaintContentRect);
+    IntRect idlePaintLayerRect = idlePaintRect(layerRect);
+    protectTileTextures(idlePaintLayerRect);
 
     // Expand outwards until we find a dirty row or column to update.
     int left, top, right, bottom;
-    m_tiler->contentRectToTileIndices(contentRect, left, top, right, bottom);
+    m_tiler->layerRectToTileIndices(layerRect, left, top, right, bottom);
     int prepaintLeft, prepaintTop, prepaintRight, prepaintBottom;
-    m_tiler->contentRectToTileIndices(idlePaintContentRect, prepaintLeft, prepaintTop, prepaintRight, prepaintBottom);
+    m_tiler->layerRectToTileIndices(idlePaintLayerRect, prepaintLeft, prepaintTop, prepaintRight, prepaintBottom);
     while (!m_skipsIdlePaint && (left > prepaintLeft || top > prepaintTop || right < prepaintRight || bottom < prepaintBottom)) {
         if (bottom < prepaintBottom) {
             ++bottom;
@@ -513,15 +506,15 @@ void TiledLayerChromium::prepareToUpdateIdle(const IntRect& contentRect)
     }
 }
 
-bool TiledLayerChromium::needsIdlePaint(const IntRect& contentRect)
+bool TiledLayerChromium::needsIdlePaint(const IntRect& layerRect)
 {
     if (m_skipsIdlePaint)
         return false;
 
-    IntRect idlePaintContentRect = idlePaintRect(contentRect);
+    IntRect idlePaintLayerRect = idlePaintRect(layerRect);
 
     int left, top, right, bottom;
-    m_tiler->contentRectToTileIndices(idlePaintContentRect, left, top, right, bottom);
+    m_tiler->layerRectToTileIndices(idlePaintLayerRect, left, top, right, bottom);
     for (int j = top; j <= bottom; ++j) {
         for (int i = left; i <= right; ++i) {
             if (m_requestedUpdateTilesRect.contains(IntPoint(i, j)))
@@ -534,9 +527,9 @@ bool TiledLayerChromium::needsIdlePaint(const IntRect& contentRect)
     return false;
 }
 
-IntRect TiledLayerChromium::idlePaintRect(const IntRect& visibleContentRect)
+IntRect TiledLayerChromium::idlePaintRect(const IntRect& visibleLayerRect)
 {
-    IntRect prepaintRect = visibleContentRect;
+    IntRect prepaintRect = visibleLayerRect;
     // FIXME: This can be made a lot larger if we can:
     // - reserve memory at a lower priority than for visible content
     // - only reserve idle paint tiles up to a memory reclaim threshold and
index f82018d..f0ab057 100644 (file)
@@ -59,7 +59,7 @@ public:
 
     // Reserves all existing and valid tile textures to protect them from being
     // recycled by the texture manager.
-    void protectTileTextures(const IntRect& contentRect);
+    void protectTileTextures(const IntRect& layerRect);
 
 protected:
     explicit TiledLayerChromium(CCLayerDelegate*);
@@ -77,16 +77,16 @@ protected:
     virtual LayerTextureUpdater* textureUpdater() const = 0;
 
     // Set invalidations to be potentially repainted during update().
-    void invalidateRect(const IntRect& contentRect);
+    void invalidateRect(const IntRect& layerRect);
 
-    // Prepare data needed to update textures that intersect with contentRect.
-    void prepareToUpdate(const IntRect& contentRect);
+    // Prepare data needed to update textures that intersect with layerRect.
+    void prepareToUpdate(const IntRect& layerRect);
 
     // Same as above, but this will try to paint additional surrounding content if idle.
-    void prepareToUpdateIdle(const IntRect& contentRect);
+    void prepareToUpdateIdle(const IntRect& layerRect);
 
     // After preparing an update, returns true if more pre-painting is needed.
-    bool needsIdlePaint(const IntRect& contentRect);
+    bool needsIdlePaint(const IntRect& layerRect);
 
     virtual void protectVisibleTileTextures();
 
@@ -101,7 +101,7 @@ private:
     void setTilingOption(TilingOption);
 
     void prepareToUpdateTiles(bool idle, int left, int top, int right, int bottom);
-    IntRect idlePaintRect(const IntRect& visibleContentRect);
+    IntRect idlePaintRect(const IntRect& visibleLayerRect);
 
     UpdatableTile* tileAt(int, int) const;
     UpdatableTile* createTile(int, int);
index 0cff00c..8b8622b 100644 (file)
@@ -69,7 +69,6 @@ void CCLayerTilingData::setBorderTexelOption(BorderTexelOption borderTexelOption
 const CCLayerTilingData& CCLayerTilingData::operator=(const CCLayerTilingData& tiler)
 {
     m_tileSize = tiler.m_tileSize;
-    m_layerPosition = tiler.m_layerPosition;
     m_tilingData = tiler.m_tilingData;
 
     return *this;
@@ -100,52 +99,20 @@ void CCLayerTilingData::reset()
     m_tilingData.setTotalSize(0, 0);
 }
 
-void CCLayerTilingData::contentRectToTileIndices(const IntRect& contentRect, int& left, int& top, int& right, int& bottom) const
+void CCLayerTilingData::layerRectToTileIndices(const IntRect& layerRect, int& left, int& top, int& right, int& bottom) const
 {
-    const IntRect layerRect = contentRectToLayerRect(contentRect);
-
     left = m_tilingData.tileXIndexFromSrcCoord(layerRect.x());
     top = m_tilingData.tileYIndexFromSrcCoord(layerRect.y());
     right = m_tilingData.tileXIndexFromSrcCoord(layerRect.maxX() - 1);
     bottom = m_tilingData.tileYIndexFromSrcCoord(layerRect.maxY() - 1);
 }
 
-IntRect CCLayerTilingData::contentRectToLayerRect(const IntRect& contentRect) const
-{
-    IntPoint pos(contentRect.x() - m_layerPosition.x(), contentRect.y() - m_layerPosition.y());
-    IntRect layerRect(pos, contentRect.size());
-
-    // Clip to the position.
-    if (pos.x() < 0 || pos.y() < 0)
-        layerRect = IntRect(IntPoint(0, 0), IntSize(contentRect.width() + pos.x(), contentRect.height() + pos.y()));
-    return layerRect;
-}
-
-IntRect CCLayerTilingData::layerRectToContentRect(const IntRect& layerRect) const
-{
-    IntRect contentRect = layerRect;
-    contentRect.move(m_layerPosition.x(), m_layerPosition.y());
-    return contentRect;
-}
-
-IntRect CCLayerTilingData::tileContentRect(const Tile* tile) const
-{
-    IntRect contentRect = tileLayerRect(tile);
-    contentRect.move(m_layerPosition.x(), m_layerPosition.y());
-    return contentRect;
-}
-
-IntRect CCLayerTilingData::tileLayerRect(const Tile* tile) const
+IntRect CCLayerTilingData::tileRect(const Tile* tile) const
 {
     const int index = m_tilingData.tileIndex(tile->i(), tile->j());
-    IntRect layerRect = m_tilingData.tileBoundsWithBorder(index);
-    layerRect.setSize(m_tileSize);
-    return layerRect;
-}
-
-void CCLayerTilingData::setLayerPosition(const IntPoint& layerPosition)
-{
-    m_layerPosition = layerPosition;
+    IntRect tileRect = m_tilingData.tileBoundsWithBorder(index);
+    tileRect.setSize(m_tileSize);
+    return tileRect;
 }
 
 void CCLayerTilingData::setBounds(const IntSize& size)
index 92fd106..46ae881 100644 (file)
@@ -50,9 +50,6 @@ public:
     IntRect tileBounds(int i, int j) const { return m_tilingData.tileBounds(m_tilingData.tileIndex(i, j)); }
     IntPoint textureOffset(int xIndex, int yIndex) const { return m_tilingData.textureOffset(xIndex, yIndex); }
 
-    // Set position of this tiled layer in content space.
-    void setLayerPosition(const IntPoint&);
-
     // Change the tile size. This may invalidate all the existing tiles.
     void setTileSize(const IntSize&);
     const IntSize& tileSize() const { return m_tileSize; }
@@ -100,11 +97,8 @@ public:
     void setBounds(const IntSize&);
     IntSize bounds() const;
 
-    void contentRectToTileIndices(const IntRect& contentRect, int &left, int &top, int &right, int &bottom) const;
-    IntRect contentRectToLayerRect(const IntRect& contentRect) const;
-    IntRect layerRectToContentRect(const IntRect& layerRect) const;
-    IntRect tileContentRect(const Tile*) const;
-    IntRect tileLayerRect(const Tile*) const;
+    void layerRectToTileIndices(const IntRect&, int &left, int &top, int &right, int &bottom) const;
+    IntRect tileRect(const Tile*) const;
 
     void reset();
 
@@ -113,7 +107,6 @@ protected:
 
     TileMap m_tiles;
     IntSize m_tileSize;
-    IntPoint m_layerPosition;
     TilingData m_tilingData;
 };
 
index 4906654..6ccb407 100644 (file)
@@ -116,14 +116,13 @@ TransformationMatrix CCTiledLayerImpl::quadTransform() const
 
 void CCTiledLayerImpl::appendQuads(CCQuadList& quadList, const CCSharedQuadState* sharedQuadState)
 {
-    const IntRect& contentRect = visibleLayerRect();
+    const IntRect& layerRect = visibleLayerRect();
 
-    if (m_skipsDraw || !m_tiler || m_tiler->isEmpty() || contentRect.isEmpty())
+    if (m_skipsDraw || !m_tiler || m_tiler->isEmpty() || layerRect.isEmpty())
         return;
 
     int left, top, right, bottom;
-    m_tiler->contentRectToTileIndices(contentRect, left, top, right, bottom);
-    IntRect layerRect = m_tiler->contentRectToLayerRect(contentRect);
+    m_tiler->layerRectToTileIndices(layerRect, left, top, right, bottom);
     for (int j = top; j <= bottom; ++j) {
         for (int i = left; i <= right; ++i) {
             DrawableTile* tile = tileAt(i, j);