<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[196932] releases/WebKitGTK/webkit-2.10/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/196932">196932</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2016-02-22 03:44:40 -0800 (Mon, 22 Feb 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/196803">r196803</a> - [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.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit210SourceWebCoreChangeLog">releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceWebCoreplatformgraphicstexmapGraphicsLayerTextureMappercpp">releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceWebCoreplatformgraphicstexmapGraphicsLayerTextureMapperh">releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceWebCoreplatformgraphicstexmapTextureMapperTiledBackingStorecpp">releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceWebCoreplatformgraphicstexmapTextureMapperTiledBackingStoreh">releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.h</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceWebKit2ChangeLog">releases/WebKitGTK/webkit-2.10/Source/WebKit2/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceWebKit2WebProcessWebPagegtkLayerTreeHostGtkcpp">releases/WebKitGTK/webkit-2.10/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="releasesWebKitGTKwebkit210SourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog (196931 => 196932)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog        2016-02-22 10:53:47 UTC (rev 196931)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog        2016-02-22 11:44:40 UTC (rev 196932)
</span><span class="lines">@@ -1,3 +1,41 @@
</span><ins>+2016-02-18  Gwang Yoon Hwang  &lt;yoon@igalia.com&gt;
+
+        [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.
+
</ins><span class="cx"> 2016-02-16  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Every RenderLayer should not have to remove itself from the scrollableArea set
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceWebCoreplatformgraphicstexmapGraphicsLayerTextureMappercpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp (196931 => 196932)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp        2016-02-22 10:53:47 UTC (rev 196931)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp        2016-02-22 11:44:40 UTC (rev 196932)
</span><span class="lines">@@ -48,6 +48,8 @@
</span><span class="cx">     , m_contentsLayer(0)
</span><span class="cx">     , m_animationStartTime(0)
</span><span class="cx">     , m_isScrollable(false)
</span><ins>+    , m_isNonCompositingLayer(false)
+    , m_isVisibleRectDirty(true)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -167,6 +169,7 @@
</span><span class="cx">         return;
</span><span class="cx">     GraphicsLayer::setPosition(value);
</span><span class="cx">     notifyChange(PositionChange);
</span><ins>+    markVisibleRectAsDirty();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GraphicsLayerTextureMapper::setAnchorPoint(const FloatPoint3D&amp; value)
</span><span class="lines">@@ -175,6 +178,7 @@
</span><span class="cx">         return;
</span><span class="cx">     GraphicsLayer::setAnchorPoint(value);
</span><span class="cx">     notifyChange(AnchorPointChange);
</span><ins>+    markVisibleRectAsDirty();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GraphicsLayerTextureMapper::setSize(const FloatSize&amp; value)
</span><span class="lines">@@ -186,6 +190,7 @@
</span><span class="cx">     if (maskLayer())
</span><span class="cx">         maskLayer()-&gt;setSize(value);
</span><span class="cx">     notifyChange(SizeChange);
</span><ins>+    markVisibleRectAsDirty();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GraphicsLayerTextureMapper::setTransform(const TransformationMatrix&amp; value)
</span><span class="lines">@@ -195,6 +200,7 @@
</span><span class="cx"> 
</span><span class="cx">     GraphicsLayer::setTransform(value);
</span><span class="cx">     notifyChange(TransformChange);
</span><ins>+    markVisibleRectAsDirty();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GraphicsLayerTextureMapper::setChildrenTransform(const TransformationMatrix&amp; value)
</span><span class="lines">@@ -203,6 +209,7 @@
</span><span class="cx">         return;
</span><span class="cx">     GraphicsLayer::setChildrenTransform(value);
</span><span class="cx">     notifyChange(ChildrenTransformChange);
</span><ins>+    markVisibleRectAsDirty();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GraphicsLayerTextureMapper::setPreserves3D(bool value)
</span><span class="lines">@@ -211,6 +218,7 @@
</span><span class="cx">         return;
</span><span class="cx">     GraphicsLayer::setPreserves3D(value);
</span><span class="cx">     notifyChange(Preserves3DChange);
</span><ins>+    markVisibleRectAsDirty();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GraphicsLayerTextureMapper::setMasksToBounds(bool value)
</span><span class="lines">@@ -219,6 +227,7 @@
</span><span class="cx">         return;
</span><span class="cx">     GraphicsLayer::setMasksToBounds(value);
</span><span class="cx">     notifyChange(MasksToBoundsChange);
</span><ins>+    markVisibleRectAsDirty();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GraphicsLayerTextureMapper::setDrawsContent(bool value)
</span><span class="lines">@@ -301,6 +310,7 @@
</span><span class="cx">             m_compositedImage = TextureMapperTiledBackingStore::create();
</span><span class="cx">         m_compositedImage-&gt;setContentsToImage(image);
</span><span class="cx">         m_compositedImage-&gt;updateContentsScale(pageScaleFactor() * deviceScaleFactor());
</span><ins>+        m_compositedImage-&gt;updateContentsSize(image-&gt;size());
</ins><span class="cx">     } else {
</span><span class="cx">         m_compositedNativeImagePtr = nullptr;
</span><span class="cx">         m_compositedImage = nullptr;
</span><span class="lines">@@ -369,6 +379,8 @@
</span><span class="cx">     prepareBackingStoreIfNeeded();
</span><span class="cx">     commitLayerChanges();
</span><span class="cx">     m_layer.syncAnimations();
</span><ins>+    if (!m_isNonCompositingLayer)
+        computeTransformedVisibleRect();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GraphicsLayerTextureMapper::prepareBackingStoreIfNeeded()
</span><span class="lines">@@ -512,22 +524,22 @@
</span><span class="cx">         child-&gt;flushCompositingState(rect, viewportIsStable);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GraphicsLayerTextureMapper::updateBackingStoreIncludingSubLayers()
</del><ins>+void GraphicsLayerTextureMapper::updateBackingStoreIncludingSubLayers(const FloatRect&amp; visibleContentRect)
</ins><span class="cx"> {
</span><span class="cx">     if (!m_layer.textureMapper())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    updateBackingStoreIfNeeded();
</del><ins>+    updateBackingStoreIfNeeded(visibleContentRect);
</ins><span class="cx"> 
</span><span class="cx">     if (maskLayer())
</span><del>-        downcast&lt;GraphicsLayerTextureMapper&gt;(*maskLayer()).updateBackingStoreIfNeeded();
</del><ins>+        downcast&lt;GraphicsLayerTextureMapper&gt;(*maskLayer()).updateBackingStoreIfNeeded(visibleContentRect);
</ins><span class="cx">     if (replicaLayer())
</span><del>-        downcast&lt;GraphicsLayerTextureMapper&gt;(*replicaLayer()).updateBackingStoreIfNeeded();
</del><ins>+        downcast&lt;GraphicsLayerTextureMapper&gt;(*replicaLayer()).updateBackingStoreIfNeeded(visibleContentRect);
</ins><span class="cx">     for (auto* child : children())
</span><del>-        downcast&lt;GraphicsLayerTextureMapper&gt;(*child).updateBackingStoreIncludingSubLayers();
</del><ins>+        downcast&lt;GraphicsLayerTextureMapper&gt;(*child).updateBackingStoreIncludingSubLayers(visibleContentRect);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GraphicsLayerTextureMapper::updateBackingStoreIfNeeded()
</del><ins>+void GraphicsLayerTextureMapper::updateBackingStoreIfNeeded(const FloatRect&amp; visibleContentRect)
</ins><span class="cx"> {
</span><span class="cx">     TextureMapper* textureMapper = m_layer.textureMapper();
</span><span class="cx">     if (!textureMapper)
</span><span class="lines">@@ -547,9 +559,10 @@
</span><span class="cx"> 
</span><span class="cx">     TextureMapperTiledBackingStore* backingStore = static_cast&lt;TextureMapperTiledBackingStore*&gt;(m_backingStore.get());
</span><span class="cx">     backingStore-&gt;updateContentsScale(pageScaleFactor() * deviceScaleFactor());
</span><ins>+    backingStore-&gt;updateContentsSize(m_size);
</ins><span class="cx"> 
</span><span class="cx">     dirtyRect.scale(pageScaleFactor() * deviceScaleFactor());
</span><del>-    backingStore-&gt;updateContents(textureMapper, this, m_size, dirtyRect, BitmapTexture::UpdateCanModifyOriginalImageData);
</del><ins>+    backingStore-&gt;updateContents(textureMapper, this, transformedVisibleRect(visibleContentRect), dirtyRect, BitmapTexture::UpdateCanModifyOriginalImageData);
</ins><span class="cx"> 
</span><span class="cx">     m_needsDisplay = false;
</span><span class="cx">     m_needsDisplayRect = IntRect();
</span><span class="lines">@@ -626,5 +639,81 @@
</span><span class="cx">     notifyChange(RepaintCountChange);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void GraphicsLayerTextureMapper::markVisibleRectAsDirty()
+{
+    m_isVisibleRectDirty = true;
+
+    if (maskLayer())
+        downcast&lt;GraphicsLayerTextureMapper&gt;(*maskLayer()).markVisibleRectAsDirty();
+    if (replicaLayer())
+        downcast&lt;GraphicsLayerTextureMapper&gt;(*replicaLayer()).markVisibleRectAsDirty();
+    for (auto* child : children())
+        downcast&lt;GraphicsLayerTextureMapper&gt;(*child).markVisibleRectAsDirty();
</ins><span class="cx"> }
</span><ins>+
+bool GraphicsLayerTextureMapper::selfOrAncestorHasActiveTransformAnimation() const
+{
+    if (m_animations.hasActiveAnimationsOfType(AnimatedPropertyTransform))
+        return true;
+
+    if (!parent())
+        return false;
+
+    return downcast&lt;GraphicsLayerTextureMapper&gt;(*parent()).selfOrAncestorHasActiveTransformAnimation();
+}
+
+void GraphicsLayerTextureMapper::computeTransformedVisibleRect()
+{
+    if (!m_isVisibleRectDirty &amp;&amp; !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&lt;GraphicsLayerTextureMapper&gt;(*parent()).m_layerTransform.combinedForChildren() : TransformationMatrix());
+
+    m_cachedInverseTransform = m_layerTransform.combined().isInvertible() ? m_layerTransform.combined().inverse() : TransformationMatrix();
+}
+
+static void clampToContentsRectIfRectIsInfinite(FloatRect&amp; rect, const FloatSize&amp; contentsSize)
+{
+    if (rect.width() &gt;= LayoutUnit::nearlyMax() || rect.width() &lt;= LayoutUnit::nearlyMin()) {
+        rect.setX(0);
+        rect.setWidth(contentsSize.width());
+    }
+
+    if (rect.height() &gt;= LayoutUnit::nearlyMax() || rect.height() &lt;= LayoutUnit::nearlyMin()) {
+        rect.setY(0);
+        rect.setHeight(contentsSize.height());
+    }
+}
+
+FloatRect GraphicsLayerTextureMapper::transformedVisibleRect(const FloatRect&amp; 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;
+}
+
+}
</ins><span class="cx"> #endif
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceWebCoreplatformgraphicstexmapGraphicsLayerTextureMapperh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h (196931 => 196932)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h        2016-02-22 10:53:47 UTC (rev 196931)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h        2016-02-22 11:44:40 UTC (rev 196932)
</span><span class="lines">@@ -86,7 +86,7 @@
</span><span class="cx">     virtual void flushCompositingState(const FloatRect&amp;, bool) override;
</span><span class="cx">     virtual void flushCompositingStateForThisLayerOnly(bool) override;
</span><span class="cx"> 
</span><del>-    void updateBackingStoreIncludingSubLayers();
</del><ins>+    void updateBackingStoreIncludingSubLayers(const FloatRect&amp;);
</ins><span class="cx"> 
</span><span class="cx">     TextureMapperLayer&amp; layer() { return m_layer; }
</span><span class="cx"> 
</span><span class="lines">@@ -102,6 +102,7 @@
</span><span class="cx">     void setRepaintCount(int);
</span><span class="cx"> 
</span><span class="cx">     void setAnimations(const TextureMapperAnimations&amp;);
</span><ins>+    void setAsNonCompositingLayer() { m_isNonCompositingLayer = true; }
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     // GraphicsLayer
</span><span class="lines">@@ -113,10 +114,15 @@
</span><span class="cx"> 
</span><span class="cx">     void commitLayerChanges();
</span><span class="cx">     void updateDebugBorderAndRepaintCount();
</span><del>-    void updateBackingStoreIfNeeded();
</del><ins>+    void updateBackingStoreIfNeeded(const FloatRect&amp;);
</ins><span class="cx">     void prepareBackingStoreIfNeeded();
</span><span class="cx">     bool shouldHaveBackingStore() const;
</span><span class="cx"> 
</span><ins>+    bool selfOrAncestorHasActiveTransformAnimation() const;
+    void computeTransformedVisibleRect();
+    void markVisibleRectAsDirty();
+    FloatRect transformedVisibleRect(const FloatRect&amp;);
+
</ins><span class="cx">     // This set of flags help us defer which properties of the layer have been
</span><span class="cx">     // modified by the compositor, so we can know what to look for in the next flush.
</span><span class="cx">     enum ChangeMask {
</span><span class="lines">@@ -182,6 +188,11 @@
</span><span class="cx"> 
</span><span class="cx">     IntSize m_committedScrollOffset;
</span><span class="cx">     bool m_isScrollable;
</span><ins>+
+    bool m_isNonCompositingLayer;
+    bool m_isVisibleRectDirty;
+    GraphicsLayerTransform m_layerTransform;
+    TransformationMatrix m_cachedInverseTransform;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceWebCoreplatformgraphicstexmapTextureMapperTiledBackingStorecpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.cpp (196931 => 196932)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.cpp        2016-02-22 10:53:47 UTC (rev 196931)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.cpp        2016-02-22 11:44:40 UTC (rev 196932)
</span><span class="lines">@@ -34,21 +34,29 @@
</span><span class="cx">     if (!m_image)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    updateContents(textureMapper, m_image.get(), m_image-&gt;size(), enclosingIntRect(m_image-&gt;rect()), BitmapTexture::UpdateCannotModifyOriginalImageData);
</del><ins>+    updateContents(textureMapper, m_image.get(), m_image-&gt;rect(), enclosingIntRect(m_image-&gt;rect()), BitmapTexture::UpdateCannotModifyOriginalImageData);
</ins><span class="cx">     m_image = nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TransformationMatrix TextureMapperTiledBackingStore::adjustedTransformForRect(const FloatRect&amp; targetRect)
</span><span class="cx"> {
</span><del>-    return TransformationMatrix::rectToRect(rect(), targetRect);
</del><ins>+    FloatRect scaledContentsRect(FloatPoint::zero(), m_contentsSize);
+    scaledContentsRect.scale(m_contentsScale);
+    return TransformationMatrix::rectToRect(scaledContentsRect, targetRect);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void TextureMapperTiledBackingStore::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect&amp; targetRect, const TransformationMatrix&amp; transform, float opacity)
</span><span class="cx"> {
</span><ins>+    FloatRect scaledTargetRect(targetRect);
+    if (m_image)
+        scaledTargetRect.scale(m_contentsScale);
+
</ins><span class="cx">     updateContentsFromImageIfNeeded(textureMapper);
</span><del>-    TransformationMatrix adjustedTransform = transform * adjustedTransformForRect(targetRect);
</del><ins>+    TransformationMatrix adjustedTransform = transform * adjustedTransformForRect(scaledTargetRect);
+    FloatRect scaledContentsRect(FloatPoint::zero(), m_contentsSize);
+    scaledContentsRect.scale(m_contentsScale);
</ins><span class="cx">     for (auto&amp; tile : m_tiles)
</span><del>-        tile.paint(textureMapper, adjustedTransform, opacity, calculateExposedTileEdges(rect(), tile.rect()));
</del><ins>+        tile.paint(textureMapper, adjustedTransform, opacity, calculateExposedTileEdges(scaledContentsRect, tile.rect()));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void TextureMapperTiledBackingStore::drawBorder(TextureMapper* textureMapper, const Color&amp; borderColor, float borderWidth, const FloatRect&amp; targetRect, const TransformationMatrix&amp; transform)
</span><span class="lines">@@ -74,29 +82,50 @@
</span><span class="cx">     m_contentsScale = scale;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TextureMapperTiledBackingStore::createOrDestroyTilesIfNeeded(const FloatSize&amp; size, const IntSize&amp; tileSize, bool hasAlpha)
</del><ins>+void TextureMapperTiledBackingStore::updateContentsSize(const FloatSize&amp; size)
</ins><span class="cx"> {
</span><del>-    if (size == m_size &amp;&amp; !m_isScaleDirty)
</del><ins>+    if (m_contentsSize == size)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    m_size = size;
</del><ins>+    m_isSizeDirty = true;
+    m_contentsSize = size;
+}
+
+void TextureMapperTiledBackingStore::createOrDestroyTilesIfNeeded(const FloatRect&amp; visibleRect, const IntSize&amp; tileSize, bool hasAlpha)
+{
+    if (visibleRect == m_visibleRect &amp;&amp; !m_isScaleDirty &amp;&amp; !m_isSizeDirty)
+        return;
+
+    m_visibleRect = visibleRect;
</ins><span class="cx">     m_isScaleDirty = false;
</span><ins>+    m_isSizeDirty = false;
</ins><span class="cx"> 
</span><del>-    FloatSize scaledSize(m_size);
-    if (!m_image)
-        scaledSize.scale(m_contentsScale);
</del><ins>+    FloatRect scaledContentsRect(FloatRect(FloatPoint::zero(), m_contentsSize));
+    FloatRect scaledVisibleRect(m_visibleRect);
</ins><span class="cx"> 
</span><ins>+    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);
+    }
+
</ins><span class="cx">     Vector&lt;FloatRect&gt; tileRectsToAdd;
</span><span class="cx">     Vector&lt;int&gt; tileIndicesToRemove;
</span><span class="cx">     static const size_t TileEraseThreshold = 6;
</span><span class="cx"> 
</span><span class="cx">     // This method recycles tiles. We check which tiles we need to add, which to remove, and use as many
</span><span class="cx">     // removable tiles as replacement for new tiles when possible.
</span><del>-    for (float y = 0; y &lt; scaledSize.height(); y += tileSize.height()) {
-        for (float x = 0; x &lt; scaledSize.width(); x += tileSize.width()) {
</del><ins>+    for (float y = 0; y &lt; scaledContentsRect.height(); y += tileSize.height()) {
+        for (float x = 0; x &lt; scaledContentsRect.width(); x += tileSize.width()) {
</ins><span class="cx">             FloatRect tileRect(x, y, tileSize.width(), tileSize.height());
</span><del>-            tileRect.intersect(rect());
-            tileRectsToAdd.append(tileRect);
</del><ins>+            tileRect.intersect(scaledContentsRect);
+            if (tileRect.intersects(scaledVisibleRect))
+                tileRectsToAdd.append(tileRect);
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -146,16 +175,16 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TextureMapperTiledBackingStore::updateContents(TextureMapper* textureMapper, Image* image, const FloatSize&amp; totalSize, const IntRect&amp; dirtyRect, BitmapTexture::UpdateContentsFlag updateContentsFlag)
</del><ins>+void TextureMapperTiledBackingStore::updateContents(TextureMapper* textureMapper, Image* image, const FloatRect&amp; visibleRect, const IntRect&amp; dirtyRect, BitmapTexture::UpdateContentsFlag updateContentsFlag)
</ins><span class="cx"> {
</span><del>-    createOrDestroyTilesIfNeeded(totalSize, textureMapper-&gt;maxTextureSize(), !image-&gt;currentFrameKnownToBeOpaque());
</del><ins>+    createOrDestroyTilesIfNeeded(visibleRect, textureMapper-&gt;maxTextureSize(), !image-&gt;currentFrameKnownToBeOpaque());
</ins><span class="cx">     for (auto&amp; tile : m_tiles)
</span><span class="cx">         tile.updateContents(textureMapper, image, dirtyRect, updateContentsFlag);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TextureMapperTiledBackingStore::updateContents(TextureMapper* textureMapper, GraphicsLayer* sourceLayer, const FloatSize&amp; totalSize, const IntRect&amp; dirtyRect, BitmapTexture::UpdateContentsFlag updateContentsFlag)
</del><ins>+void TextureMapperTiledBackingStore::updateContents(TextureMapper* textureMapper, GraphicsLayer* sourceLayer, const FloatRect&amp; visibleRect, const IntRect&amp; dirtyRect, BitmapTexture::UpdateContentsFlag updateContentsFlag)
</ins><span class="cx"> {
</span><del>-    createOrDestroyTilesIfNeeded(totalSize, textureMapper-&gt;maxTextureSize(), true);
</del><ins>+    createOrDestroyTilesIfNeeded(visibleRect, textureMapper-&gt;maxTextureSize(), true);
</ins><span class="cx">     for (auto&amp; tile : m_tiles)
</span><span class="cx">         tile.updateContents(textureMapper, sourceLayer, dirtyRect, updateContentsFlag, m_contentsScale);
</span><span class="cx"> }
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceWebCoreplatformgraphicstexmapTextureMapperTiledBackingStoreh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.h (196931 => 196932)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.h        2016-02-22 10:53:47 UTC (rev 196931)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/texmap/TextureMapperTiledBackingStore.h        2016-02-22 11:44:40 UTC (rev 196932)
</span><span class="lines">@@ -43,29 +43,29 @@
</span><span class="cx">     virtual void drawRepaintCounter(TextureMapper*, int repaintCount, const Color&amp;, const FloatRect&amp;, const TransformationMatrix&amp;) override;
</span><span class="cx"> 
</span><span class="cx">     void updateContentsScale(float);
</span><del>-    void updateContents(TextureMapper*, Image*, const FloatSize&amp;, const IntRect&amp;, BitmapTexture::UpdateContentsFlag);
-    void updateContents(TextureMapper*, GraphicsLayer*, const FloatSize&amp;, const IntRect&amp;, BitmapTexture::UpdateContentsFlag);
</del><ins>+    void updateContentsSize(const FloatSize&amp;);
</ins><span class="cx"> 
</span><ins>+    void updateContents(TextureMapper*, Image*, const FloatRect&amp;, const IntRect&amp;, BitmapTexture::UpdateContentsFlag);
+    void updateContents(TextureMapper*, GraphicsLayer*, const FloatRect&amp;, const IntRect&amp;, BitmapTexture::UpdateContentsFlag);
+
</ins><span class="cx">     void setContentsToImage(Image* image) { m_image = image; }
</span><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     TextureMapperTiledBackingStore() { }
</span><span class="cx"> 
</span><del>-    void createOrDestroyTilesIfNeeded(const FloatSize&amp; backingStoreSize, const IntSize&amp; tileSize, bool hasAlpha);
</del><ins>+    void createOrDestroyTilesIfNeeded(const FloatRect&amp; visibleRect, const IntSize&amp; tileSize, bool hasAlpha);
</ins><span class="cx">     void updateContentsFromImageIfNeeded(TextureMapper*);
</span><ins>+
</ins><span class="cx">     TransformationMatrix adjustedTransformForRect(const FloatRect&amp;);
</span><del>-    inline FloatRect rect() const
-    {
-        FloatRect rect(FloatPoint::zero(), m_size);
-        rect.scale(m_contentsScale);
-        return rect;
-    }
</del><span class="cx"> 
</span><span class="cx">     Vector&lt;TextureMapperTile&gt; m_tiles;
</span><del>-    FloatSize m_size;
</del><ins>+    FloatSize m_contentsSize;
+    FloatRect m_visibleRect;
+    FloatRect m_scaledvisibleRect;
</ins><span class="cx">     RefPtr&lt;Image&gt; m_image;
</span><span class="cx">     float m_contentsScale { 1 };
</span><span class="cx">     bool m_isScaleDirty { false };
</span><ins>+    bool m_isSizeDirty { false };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/WebKit2/ChangeLog (196931 => 196932)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/WebKit2/ChangeLog        2016-02-22 10:53:47 UTC (rev 196931)
+++ releases/WebKitGTK/webkit-2.10/Source/WebKit2/ChangeLog        2016-02-22 11:44:40 UTC (rev 196932)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2016-02-18  Gwang Yoon Hwang  &lt;yoon@igalia.com&gt;
+
+        [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.
+
</ins><span class="cx"> 2016-02-12  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [GTK] HTTP auth dialog incorrectly rendered with Accelerated Compositing enabled
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceWebKit2WebProcessWebPagegtkLayerTreeHostGtkcpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp (196931 => 196932)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp        2016-02-22 10:53:47 UTC (rev 196931)
+++ releases/WebKitGTK/webkit-2.10/Source/WebKit2/WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp        2016-02-22 11:44:40 UTC (rev 196932)
</span><span class="lines">@@ -107,6 +107,7 @@
</span><span class="cx"> 
</span><span class="cx">     // The non-composited contents are a child of the root layer.
</span><span class="cx">     m_nonCompositedContentLayer = GraphicsLayer::create(graphicsLayerFactory(), *this);
</span><ins>+    downcast&lt;GraphicsLayerTextureMapper&gt;(*m_nonCompositedContentLayer).setAsNonCompositingLayer();
</ins><span class="cx">     m_nonCompositedContentLayer-&gt;setDrawsContent(true);
</span><span class="cx">     m_nonCompositedContentLayer-&gt;setContentsOpaque(m_webPage-&gt;drawsBackground() &amp;&amp; !m_webPage-&gt;drawsTransparentBackground());
</span><span class="cx">     m_nonCompositedContentLayer-&gt;setSize(m_webPage-&gt;size());
</span><span class="lines">@@ -291,7 +292,8 @@
</span><span class="cx">     if (m_viewOverlayRootLayer)
</span><span class="cx">         m_viewOverlayRootLayer-&gt;flushCompositingState(FloatRect(FloatPoint(), m_rootLayer-&gt;size()), viewportIsStable);
</span><span class="cx"> 
</span><del>-    downcast&lt;GraphicsLayerTextureMapper&gt;(*m_rootLayer).updateBackingStoreIncludingSubLayers();
</del><ins>+    FloatRect visibleRect(m_webPage-&gt;mainFrame()-&gt;view()-&gt;scrollPosition(), m_webPage-&gt;size());
+    downcast&lt;GraphicsLayerTextureMapper&gt;(*m_rootLayer).updateBackingStoreIncludingSubLayers(visibleRect);
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>