Title: [196803] trunk/Source
Revision
196803
Author
[email protected]
Date
2016-02-18 23:27:28 -0800 (Thu, 18 Feb 2016)

Log Message

[GTK] Limit the number of tiles according to the visible area
https://bugs.webkit.org/show_bug.cgi?id=126122

Reviewed by Carlos Garcia Campos.

Source/WebCore:

TextureMapperTiledBackingStore creates tiles for whole layer bounds, which
means it creates the huge amount of textures if there is an excessively big
layer.  Not only it wastes the memory and the CPU time, it even can crash GPU
drivers.

This patch modifies TextureMapperTiledBackingStore to take into account the
visible area with a coverage multiplier when creating tiles.

* platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:
(WebCore::GraphicsLayerTextureMapper::GraphicsLayerTextureMapper):
Set a flag to recalculate the visible area of the layer when there are
geometric changes.
(WebCore::GraphicsLayerTextureMapper::setContentsToImage):
(WebCore::GraphicsLayerTextureMapper::flushCompositingStateForThisLayerOnly):
(WebCore::GraphicsLayerTextureMapper::updateBackingStoreIncludingSubLayers):
(WebCore::GraphicsLayerTextureMapper::updateBackingStoreIfNeeded):
(WebCore::GraphicsLayerTextureMapper::markVisibleRectAsDirty):
(WebCore::GraphicsLayerTextureMapper::selfOrAncestorHasActiveTransformAnimation):
(WebCore::GraphicsLayerTextureMapper::computeTransformedVisibleRect):
Compute the inverse transform matrix to map a global visible are to
the local visible area.
(WebCore::clampToContentsRectIfRectIsInfinite):
(WebCore::GraphicsLayerTextureMapper::transformedVisibleRect):
* platform/graphics/texmap/TextureMapperTiledBackingStore.cpp:
(WebCore::TextureMapperTiledBackingStore::paintToTextureMapper):
In HiDPI, the directly composited image is uploaded to the unscaled
texture to reduce memory usages. So we should apply device scale
factor to render it correctly.
(WebCore::TextureMapperTiledBackingStore::createOrDestroyTilesIfNeeded):
Create tiles which covered by visible rect with a coverage multiplier.

Source/WebKit2:

* WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp:
(WebKit::LayerTreeHostGtk::initialize): Because we creates
nonCompositingLayer with a size of current view, we should not apply
the currently visible rect when creating / deleting tiles.
(WebKit::LayerTreeHostGtk::flushPendingLayerChanges): Passes the current
visible rect to the GraphicsLayers.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (196802 => 196803)


--- trunk/Source/WebCore/ChangeLog	2016-02-19 07:22:36 UTC (rev 196802)
+++ trunk/Source/WebCore/ChangeLog	2016-02-19 07:27:28 UTC (rev 196803)
@@ -1,3 +1,41 @@
+2016-02-18  Gwang Yoon Hwang  <[email protected]>
+
+        [GTK] Limit the number of tiles according to the visible area
+        https://bugs.webkit.org/show_bug.cgi?id=126122
+
+        Reviewed by Carlos Garcia Campos.
+
+        TextureMapperTiledBackingStore creates tiles for whole layer bounds, which
+        means it creates the huge amount of textures if there is an excessively big
+        layer.  Not only it wastes the memory and the CPU time, it even can crash GPU
+        drivers.
+
+        This patch modifies TextureMapperTiledBackingStore to take into account the
+        visible area with a coverage multiplier when creating tiles.
+
+        * platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:
+        (WebCore::GraphicsLayerTextureMapper::GraphicsLayerTextureMapper):
+        Set a flag to recalculate the visible area of the layer when there are
+        geometric changes.
+        (WebCore::GraphicsLayerTextureMapper::setContentsToImage):
+        (WebCore::GraphicsLayerTextureMapper::flushCompositingStateForThisLayerOnly):
+        (WebCore::GraphicsLayerTextureMapper::updateBackingStoreIncludingSubLayers):
+        (WebCore::GraphicsLayerTextureMapper::updateBackingStoreIfNeeded):
+        (WebCore::GraphicsLayerTextureMapper::markVisibleRectAsDirty):
+        (WebCore::GraphicsLayerTextureMapper::selfOrAncestorHasActiveTransformAnimation):
+        (WebCore::GraphicsLayerTextureMapper::computeTransformedVisibleRect):
+        Compute the inverse transform matrix to map a global visible are to
+        the local visible area.
+        (WebCore::clampToContentsRectIfRectIsInfinite):
+        (WebCore::GraphicsLayerTextureMapper::transformedVisibleRect):
+        * platform/graphics/texmap/TextureMapperTiledBackingStore.cpp:
+        (WebCore::TextureMapperTiledBackingStore::paintToTextureMapper):
+        In HiDPI, the directly composited image is uploaded to the unscaled
+        texture to reduce memory usages. So we should apply device scale
+        factor to render it correctly.
+        (WebCore::TextureMapperTiledBackingStore::createOrDestroyTilesIfNeeded):
+        Create tiles which covered by visible rect with a coverage multiplier.
+
 2016-02-18  Brent Fulgham  <[email protected]>
 
         Extend HashCountedSet with a method to efficiently set the count of an entry

Modified: trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp (196802 => 196803)


--- trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp	2016-02-19 07:22:36 UTC (rev 196802)
+++ trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp	2016-02-19 07:27:28 UTC (rev 196803)
@@ -48,6 +48,8 @@
     , m_contentsLayer(0)
     , m_animationStartTime(0)
     , m_isScrollable(false)
+    , m_isNonCompositingLayer(false)
+    , m_isVisibleRectDirty(true)
 {
 }
 
@@ -167,6 +169,7 @@
         return;
     GraphicsLayer::setPosition(value);
     notifyChange(PositionChange);
+    markVisibleRectAsDirty();
 }
 
 void GraphicsLayerTextureMapper::setAnchorPoint(const FloatPoint3D& value)
@@ -175,6 +178,7 @@
         return;
     GraphicsLayer::setAnchorPoint(value);
     notifyChange(AnchorPointChange);
+    markVisibleRectAsDirty();
 }
 
 void GraphicsLayerTextureMapper::setSize(const FloatSize& value)
@@ -186,6 +190,7 @@
     if (maskLayer())
         maskLayer()->setSize(value);
     notifyChange(SizeChange);
+    markVisibleRectAsDirty();
 }
 
 void GraphicsLayerTextureMapper::setTransform(const TransformationMatrix& value)
@@ -195,6 +200,7 @@
 
     GraphicsLayer::setTransform(value);
     notifyChange(TransformChange);
+    markVisibleRectAsDirty();
 }
 
 void GraphicsLayerTextureMapper::setChildrenTransform(const TransformationMatrix& value)
@@ -203,6 +209,7 @@
         return;
     GraphicsLayer::setChildrenTransform(value);
     notifyChange(ChildrenTransformChange);
+    markVisibleRectAsDirty();
 }
 
 void GraphicsLayerTextureMapper::setPreserves3D(bool value)
@@ -211,6 +218,7 @@
         return;
     GraphicsLayer::setPreserves3D(value);
     notifyChange(Preserves3DChange);
+    markVisibleRectAsDirty();
 }
 
 void GraphicsLayerTextureMapper::setMasksToBounds(bool value)
@@ -219,6 +227,7 @@
         return;
     GraphicsLayer::setMasksToBounds(value);
     notifyChange(MasksToBoundsChange);
+    markVisibleRectAsDirty();
 }
 
 void GraphicsLayerTextureMapper::setDrawsContent(bool value)
@@ -301,6 +310,7 @@
             m_compositedImage = TextureMapperTiledBackingStore::create();
         m_compositedImage->setContentsToImage(image);
         m_compositedImage->updateContentsScale(pageScaleFactor() * deviceScaleFactor());
+        m_compositedImage->updateContentsSize(image->size());
     } else {
         m_compositedNativeImagePtr = nullptr;
         m_compositedImage = nullptr;
@@ -369,6 +379,8 @@
     prepareBackingStoreIfNeeded();
     commitLayerChanges();
     m_layer.syncAnimations();
+    if (!m_isNonCompositingLayer)
+        computeTransformedVisibleRect();
 }
 
 void GraphicsLayerTextureMapper::prepareBackingStoreIfNeeded()
@@ -512,22 +524,22 @@
         child->flushCompositingState(rect, viewportIsStable);
 }
 
-void GraphicsLayerTextureMapper::updateBackingStoreIncludingSubLayers()
+void GraphicsLayerTextureMapper::updateBackingStoreIncludingSubLayers(const FloatRect& visibleContentRect)
 {
     if (!m_layer.textureMapper())
         return;
 
-    updateBackingStoreIfNeeded();
+    updateBackingStoreIfNeeded(visibleContentRect);
 
     if (maskLayer())
-        downcast<GraphicsLayerTextureMapper>(*maskLayer()).updateBackingStoreIfNeeded();
+        downcast<GraphicsLayerTextureMapper>(*maskLayer()).updateBackingStoreIfNeeded(visibleContentRect);
     if (replicaLayer())
-        downcast<GraphicsLayerTextureMapper>(*replicaLayer()).updateBackingStoreIfNeeded();
+        downcast<GraphicsLayerTextureMapper>(*replicaLayer()).updateBackingStoreIfNeeded(visibleContentRect);
     for (auto* child : children())
-        downcast<GraphicsLayerTextureMapper>(*child).updateBackingStoreIncludingSubLayers();
+        downcast<GraphicsLayerTextureMapper>(*child).updateBackingStoreIncludingSubLayers(visibleContentRect);
 }
 
-void GraphicsLayerTextureMapper::updateBackingStoreIfNeeded()
+void GraphicsLayerTextureMapper::updateBackingStoreIfNeeded(const FloatRect& visibleContentRect)
 {
     TextureMapper* textureMapper = m_layer.textureMapper();
     if (!textureMapper)
@@ -547,9 +559,10 @@
 
     TextureMapperTiledBackingStore* backingStore = static_cast<TextureMapperTiledBackingStore*>(m_backingStore.get());
     backingStore->updateContentsScale(pageScaleFactor() * deviceScaleFactor());
+    backingStore->updateContentsSize(m_size);
 
     dirtyRect.scale(pageScaleFactor() * deviceScaleFactor());
-    backingStore->updateContents(*textureMapper, this, m_size, dirtyRect, BitmapTexture::UpdateCanModifyOriginalImageData);
+    backingStore->updateContents(*textureMapper, this, transformedVisibleRect(visibleContentRect), dirtyRect, BitmapTexture::UpdateCanModifyOriginalImageData);
 
     m_needsDisplay = false;
     m_needsDisplayRect = IntRect();
@@ -626,5 +639,81 @@
     notifyChange(RepaintCountChange);
 }
 
+void GraphicsLayerTextureMapper::markVisibleRectAsDirty()
+{
+    m_isVisibleRectDirty = true;
+
+    if (maskLayer())
+        downcast<GraphicsLayerTextureMapper>(*maskLayer()).markVisibleRectAsDirty();
+    if (replicaLayer())
+        downcast<GraphicsLayerTextureMapper>(*replicaLayer()).markVisibleRectAsDirty();
+    for (auto* child : children())
+        downcast<GraphicsLayerTextureMapper>(*child).markVisibleRectAsDirty();
 }
+
+bool GraphicsLayerTextureMapper::selfOrAncestorHasActiveTransformAnimation() const
+{
+    if (m_animations.hasActiveAnimationsOfType(AnimatedPropertyTransform))
+        return true;
+
+    if (!parent())
+        return false;
+
+    return downcast<GraphicsLayerTextureMapper>(*parent()).selfOrAncestorHasActiveTransformAnimation();
+}
+
+void GraphicsLayerTextureMapper::computeTransformedVisibleRect()
+{
+    if (!m_isVisibleRectDirty && !selfOrAncestorHasActiveTransformAnimation())
+        return;
+
+    m_isVisibleRectDirty = false;
+    TransformationMatrix currentTransform = transform();
+    if (selfOrAncestorHasActiveTransformAnimation())
+        client().getCurrentTransform(this, currentTransform);
+    m_layerTransform.setLocalTransform(currentTransform);
+
+    m_layerTransform.setAnchorPoint(m_anchorPoint);
+    m_layerTransform.setPosition(m_position);
+    m_layerTransform.setSize(m_size);
+
+    m_layerTransform.setFlattening(!preserves3D());
+    m_layerTransform.setChildrenTransform(childrenTransform());
+    m_layerTransform.combineTransforms(parent() ? downcast<GraphicsLayerTextureMapper>(*parent()).m_layerTransform.combinedForChildren() : TransformationMatrix());
+
+    m_cachedInverseTransform = m_layerTransform.combined().inverse().valueOr(TransformationMatrix());
+}
+
+static void clampToContentsRectIfRectIsInfinite(FloatRect& rect, const FloatSize& contentsSize)
+{
+    if (rect.width() >= LayoutUnit::nearlyMax() || rect.width() <= LayoutUnit::nearlyMin()) {
+        rect.setX(0);
+        rect.setWidth(contentsSize.width());
+    }
+
+    if (rect.height() >= LayoutUnit::nearlyMax() || rect.height() <= LayoutUnit::nearlyMin()) {
+        rect.setY(0);
+        rect.setHeight(contentsSize.height());
+    }
+}
+
+FloatRect GraphicsLayerTextureMapper::transformedVisibleRect(const FloatRect& visibleContentRect)
+{
+    if (m_isNonCompositingLayer)
+        return FloatRect(FloatPoint::zero(), m_size);
+
+    // Non-invertible layers are not visible.
+    if (!m_layerTransform.combined().isInvertible())
+        return IntRect();
+
+    // Return a projection of the visible rect (surface coordinates) onto the layer's plane (layer coordinates).
+    // The resulting quad might be squewed and the visible rect is the bounding box of this quad,
+    // so it might spread further than the real visible area (and then even more amplified by the cover rect multiplier).
+    ASSERT(m_cachedInverseTransform == m_layerTransform.combined().inverse().valueOr(TransformationMatrix()));
+    FloatRect rect = m_cachedInverseTransform.clampedBoundsOfProjectedQuad(FloatQuad(visibleContentRect));
+    clampToContentsRectIfRectIsInfinite(rect, size());
+    return rect;
+}
+
+}
 #endif

Modified: trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h (196802 => 196803)


--- trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h	2016-02-19 07:22:36 UTC (rev 196802)
+++ trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h	2016-02-19 07:27:28 UTC (rev 196803)
@@ -86,7 +86,7 @@
     virtual void flushCompositingState(const FloatRect&, bool) override;
     virtual void flushCompositingStateForThisLayerOnly(bool) override;
 
-    void updateBackingStoreIncludingSubLayers();
+    void updateBackingStoreIncludingSubLayers(const FloatRect&);
 
     TextureMapperLayer& layer() { return m_layer; }
 
@@ -102,6 +102,7 @@
     void setRepaintCount(int);
 
     void setAnimations(const TextureMapperAnimations&);
+    void setAsNonCompositingLayer() { m_isNonCompositingLayer = true; }
 
 private:
     // GraphicsLayer
@@ -113,10 +114,15 @@
 
     void commitLayerChanges();
     void updateDebugBorderAndRepaintCount();
-    void updateBackingStoreIfNeeded();
+    void updateBackingStoreIfNeeded(const FloatRect&);
     void prepareBackingStoreIfNeeded();
     bool shouldHaveBackingStore() const;
 
+    bool selfOrAncestorHasActiveTransformAnimation() const;
+    void computeTransformedVisibleRect();
+    void markVisibleRectAsDirty();
+    FloatRect transformedVisibleRect(const FloatRect&);
+
     // This set of flags help us defer which properties of the layer have been
     // modified by the compositor, so we can know what to look for in the next flush.
     enum ChangeMask {
@@ -182,6 +188,11 @@
 
     IntSize m_committedScrollOffset;
     bool m_isScrollable;
+
+    bool m_isNonCompositingLayer;
+    bool m_isVisibleRectDirty;
+    GraphicsLayerTransform m_layerTransform;
+    TransformationMatrix m_cachedInverseTransform;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.cpp (196802 => 196803)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.cpp	2016-02-19 07:22:36 UTC (rev 196802)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.cpp	2016-02-19 07:27:28 UTC (rev 196803)
@@ -35,7 +35,7 @@
     if (!m_image)
         return;
 
-    updateContents(textureMapper, m_image.get(), m_image->size(), enclosingIntRect(m_image->rect()), BitmapTexture::UpdateCannotModifyOriginalImageData);
+    updateContents(textureMapper, m_image.get(), m_image->rect(), enclosingIntRect(m_image->rect()), BitmapTexture::UpdateCannotModifyOriginalImageData);
 
     if (m_image->imageObserver())
         m_image->imageObserver()->didDraw(m_image.get());
@@ -44,15 +44,23 @@
 
 TransformationMatrix TextureMapperTiledBackingStore::adjustedTransformForRect(const FloatRect& targetRect)
 {
-    return TransformationMatrix::rectToRect(rect(), targetRect);
+    FloatRect scaledContentsRect(FloatPoint::zero(), m_contentsSize);
+    scaledContentsRect.scale(m_contentsScale);
+    return TransformationMatrix::rectToRect(scaledContentsRect, targetRect);
 }
 
 void TextureMapperTiledBackingStore::paintToTextureMapper(TextureMapper& textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity)
 {
+    FloatRect scaledTargetRect(targetRect);
+    if (m_image)
+        scaledTargetRect.scale(m_contentsScale);
+
     updateContentsFromImageIfNeeded(textureMapper);
-    TransformationMatrix adjustedTransform = transform * adjustedTransformForRect(targetRect);
+    TransformationMatrix adjustedTransform = transform * adjustedTransformForRect(scaledTargetRect);
+    FloatRect scaledContentsRect(FloatPoint::zero(), m_contentsSize);
+    scaledContentsRect.scale(m_contentsScale);
     for (auto& tile : m_tiles)
-        tile.paint(textureMapper, adjustedTransform, opacity, calculateExposedTileEdges(rect(), tile.rect()));
+        tile.paint(textureMapper, adjustedTransform, opacity, calculateExposedTileEdges(scaledContentsRect, tile.rect()));
 }
 
 void TextureMapperTiledBackingStore::drawBorder(TextureMapper& textureMapper, const Color& borderColor, float borderWidth, const FloatRect& targetRect, const TransformationMatrix& transform)
@@ -78,29 +86,50 @@
     m_contentsScale = scale;
 }
 
-void TextureMapperTiledBackingStore::createOrDestroyTilesIfNeeded(const FloatSize& size, const IntSize& tileSize, bool hasAlpha)
+void TextureMapperTiledBackingStore::updateContentsSize(const FloatSize& size)
 {
-    if (size == m_size && !m_isScaleDirty)
+    if (m_contentsSize == size)
         return;
 
-    m_size = size;
+    m_isSizeDirty = true;
+    m_contentsSize = size;
+}
+
+void TextureMapperTiledBackingStore::createOrDestroyTilesIfNeeded(const FloatRect& visibleRect, const IntSize& tileSize, bool hasAlpha)
+{
+    if (visibleRect == m_visibleRect && !m_isScaleDirty && !m_isSizeDirty)
+        return;
+
+    m_visibleRect = visibleRect;
     m_isScaleDirty = false;
+    m_isSizeDirty = false;
 
-    FloatSize scaledSize(m_size);
-    if (!m_image)
-        scaledSize.scale(m_contentsScale);
+    FloatRect scaledContentsRect(FloatRect(FloatPoint::zero(), m_contentsSize));
+    FloatRect scaledVisibleRect(m_visibleRect);
 
+    static const float coverRectMultiplier = 1.2;
+    FloatPoint delta(scaledVisibleRect.center());
+    delta.scale(1 - coverRectMultiplier, 1 - coverRectMultiplier);
+
+    scaledVisibleRect.scale(coverRectMultiplier);
+    scaledVisibleRect.moveBy(delta);
+    if (!m_image) {
+        scaledContentsRect.scale(m_contentsScale);
+        scaledVisibleRect.scale(m_contentsScale);
+    }
+
     Vector<FloatRect> tileRectsToAdd;
     Vector<int> tileIndicesToRemove;
     static const size_t TileEraseThreshold = 6;
 
     // This method recycles tiles. We check which tiles we need to add, which to remove, and use as many
     // removable tiles as replacement for new tiles when possible.
-    for (float y = 0; y < scaledSize.height(); y += tileSize.height()) {
-        for (float x = 0; x < scaledSize.width(); x += tileSize.width()) {
+    for (float y = 0; y < scaledContentsRect.height(); y += tileSize.height()) {
+        for (float x = 0; x < scaledContentsRect.width(); x += tileSize.width()) {
             FloatRect tileRect(x, y, tileSize.width(), tileSize.height());
-            tileRect.intersect(rect());
-            tileRectsToAdd.append(tileRect);
+            tileRect.intersect(scaledContentsRect);
+            if (tileRect.intersects(scaledVisibleRect))
+                tileRectsToAdd.append(tileRect);
         }
     }
 
@@ -150,16 +179,16 @@
     }
 }
 
-void TextureMapperTiledBackingStore::updateContents(TextureMapper& textureMapper, Image* image, const FloatSize& totalSize, const IntRect& dirtyRect, BitmapTexture::UpdateContentsFlag updateContentsFlag)
+void TextureMapperTiledBackingStore::updateContents(TextureMapper& textureMapper, Image* image, const FloatRect& visibleRect, const IntRect& dirtyRect, BitmapTexture::UpdateContentsFlag updateContentsFlag)
 {
-    createOrDestroyTilesIfNeeded(totalSize, textureMapper.maxTextureSize(), !image->currentFrameKnownToBeOpaque());
+    createOrDestroyTilesIfNeeded(visibleRect, textureMapper.maxTextureSize(), !image->currentFrameKnownToBeOpaque());
     for (auto& tile : m_tiles)
         tile.updateContents(textureMapper, image, dirtyRect, updateContentsFlag);
 }
 
-void TextureMapperTiledBackingStore::updateContents(TextureMapper& textureMapper, GraphicsLayer* sourceLayer, const FloatSize& totalSize, const IntRect& dirtyRect, BitmapTexture::UpdateContentsFlag updateContentsFlag)
+void TextureMapperTiledBackingStore::updateContents(TextureMapper& textureMapper, GraphicsLayer* sourceLayer, const FloatRect& visibleRect, const IntRect& dirtyRect, BitmapTexture::UpdateContentsFlag updateContentsFlag)
 {
-    createOrDestroyTilesIfNeeded(totalSize, textureMapper.maxTextureSize(), true);
+    createOrDestroyTilesIfNeeded(visibleRect, textureMapper.maxTextureSize(), true);
     for (auto& tile : m_tiles)
         tile.updateContents(textureMapper, sourceLayer, dirtyRect, updateContentsFlag, m_contentsScale);
 }

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.h (196802 => 196803)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.h	2016-02-19 07:22:36 UTC (rev 196802)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.h	2016-02-19 07:27:28 UTC (rev 196803)
@@ -43,29 +43,28 @@
     virtual void drawRepaintCounter(TextureMapper&, int repaintCount, const Color&, const FloatRect&, const TransformationMatrix&) override;
 
     void updateContentsScale(float);
-    void updateContents(TextureMapper&, Image*, const FloatSize&, const IntRect&, BitmapTexture::UpdateContentsFlag);
-    void updateContents(TextureMapper&, GraphicsLayer*, const FloatSize&, const IntRect&, BitmapTexture::UpdateContentsFlag);
+    void updateContentsSize(const FloatSize&);
 
+    void updateContents(TextureMapper&, Image*, const FloatRect& visibleRect, const IntRect& dirtyRect, BitmapTexture::UpdateContentsFlag);
+    void updateContents(TextureMapper&, GraphicsLayer*, const FloatRect& visibleRect, const IntRect& dirtyRect, BitmapTexture::UpdateContentsFlag);
+
     void setContentsToImage(Image* image) { m_image = image; }
 
 private:
     TextureMapperTiledBackingStore() { }
 
-    void createOrDestroyTilesIfNeeded(const FloatSize& backingStoreSize, const IntSize& tileSize, bool hasAlpha);
+    void createOrDestroyTilesIfNeeded(const FloatRect& visibleRect, const IntSize& tileSize, bool hasAlpha);
     void updateContentsFromImageIfNeeded(TextureMapper&);
     TransformationMatrix adjustedTransformForRect(const FloatRect&);
-    inline FloatRect rect() const
-    {
-        FloatRect rect(FloatPoint::zero(), m_size);
-        rect.scale(m_contentsScale);
-        return rect;
-    }
 
     Vector<TextureMapperTile> m_tiles;
-    FloatSize m_size;
+    FloatSize m_contentsSize;
+    FloatRect m_visibleRect;
+    FloatRect m_scaledvisibleRect;
     RefPtr<Image> m_image;
     float m_contentsScale { 1 };
     bool m_isScaleDirty { false };
+    bool m_isSizeDirty { false };
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebKit2/ChangeLog (196802 => 196803)


--- trunk/Source/WebKit2/ChangeLog	2016-02-19 07:22:36 UTC (rev 196802)
+++ trunk/Source/WebKit2/ChangeLog	2016-02-19 07:27:28 UTC (rev 196803)
@@ -1,3 +1,17 @@
+2016-02-18  Gwang Yoon Hwang  <[email protected]>
+
+        [GTK] Limit the number of tiles according to the visible area
+        https://bugs.webkit.org/show_bug.cgi?id=126122
+
+        Reviewed by Carlos Garcia Campos.
+
+        * WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp:
+        (WebKit::LayerTreeHostGtk::initialize): Because we creates
+        nonCompositingLayer with a size of current view, we should not apply
+        the currently visible rect when creating / deleting tiles.
+        (WebKit::LayerTreeHostGtk::flushPendingLayerChanges): Passes the current
+        visible rect to the GraphicsLayers.
+
 2016-02-18  Brady Eidson  <[email protected]>
 
         Modern IDB: Fix IDBGetResult encoder/decoder.

Modified: trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp (196802 => 196803)


--- trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp	2016-02-19 07:22:36 UTC (rev 196802)
+++ trunk/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp	2016-02-19 07:27:28 UTC (rev 196803)
@@ -172,6 +172,7 @@
 
     // The non-composited contents are a child of the root layer.
     m_nonCompositedContentLayer = GraphicsLayer::create(graphicsLayerFactory(), *this);
+    downcast<GraphicsLayerTextureMapper>(*m_nonCompositedContentLayer).setAsNonCompositingLayer();
     m_nonCompositedContentLayer->setDrawsContent(true);
     m_nonCompositedContentLayer->setContentsOpaque(m_webPage->drawsBackground());
     m_nonCompositedContentLayer->setSize(m_webPage->size());
@@ -322,7 +323,8 @@
     if (m_viewOverlayRootLayer)
         m_viewOverlayRootLayer->flushCompositingState(FloatRect(FloatPoint(), m_rootLayer->size()), viewportIsStable);
 
-    downcast<GraphicsLayerTextureMapper>(*m_rootLayer).updateBackingStoreIncludingSubLayers();
+    FloatRect visibleRect(m_webPage->mainFrame()->view()->scrollPosition(), m_webPage->size());
+    downcast<GraphicsLayerTextureMapper>(*m_rootLayer).updateBackingStoreIncludingSubLayers(visibleRect);
     return true;
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to