Title: [104854] branches/chromium/963
Revision
104854
Author
[email protected]
Date
2012-01-12 13:34:27 -0800 (Thu, 12 Jan 2012)

Log Message

Merge 104782 - Repaint all graphics layers when their renderer offset changes
https://bugs.webkit.org/show_bug.cgi?id=75730

Reviewed by Simon Fraser.

Source/WebCore:

In RenderLayerBacking, only the main graphics layer gets repainted
when the offset changes. If the offset on other graphics layers (e.g.
the foreground layer) changes, they should get repainted as well.

Test: compositing/geometry/foreground-offset-change.html

* platform/graphics/GraphicsLayer.cpp:
(WebCore::GraphicsLayer::setOffsetFromRenderer):
(WebCore::GraphicsLayer::paintGraphicsLayerContents):
* platform/graphics/GraphicsLayer.h:
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::updateGraphicsLayerGeometry):
(WebCore::RenderLayerBacking::paintContents):

LayoutTests:

* compositing/geometry/foreground-offset-change-expected.png: Added.
* compositing/geometry/foreground-offset-change-expected.txt: Added.
* compositing/geometry/foreground-offset-change.html: Added.


[email protected]
Review URL: http://codereview.chromium.org/9187066

Modified Paths

Added Paths

Diff

Copied: branches/chromium/963/LayoutTests/compositing/geometry/foreground-offset-change-expected.png (from rev 104782, trunk/LayoutTests/compositing/geometry/foreground-offset-change-expected.png) (0 => 104854)


--- branches/chromium/963/LayoutTests/compositing/geometry/foreground-offset-change-expected.png	                        (rev 0)
+++ branches/chromium/963/LayoutTests/compositing/geometry/foreground-offset-change-expected.png	2012-01-12 21:34:27 UTC (rev 104854)
@@ -0,0 +1,7 @@
+\x89PNG
+
+
+IHDR X')tEXtchecksum919c4609446010053b38c67636334c9a\xAE\x92v\xA1
+\xD1IDATx\x9C\xEDٱ
+\x840As\xBA\xBE\xA0t\xA8\xCCW\xD9
+K\xC7L\xEA䅫\xEFm\xCE9\xE8|V\xF87 &\xB0b &\xB0b &\xB0b \xF6\xBD{\xB8\xAE\xEB\xC9\xBC־\xEF\xAB'@\xEC6\xB0\xC6\xC7y<5\x80\x97:\x8Fs\xF5\xE8\xF9"\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88	,\x80\x98\xC0\x88ms\xCE\xD5\xFE\x8A@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@L`\xC4@\xEC\xD2\xAD|\x81\xE2IEND\xAEB`\x82
\ No newline at end of file

Copied: branches/chromium/963/LayoutTests/compositing/geometry/foreground-offset-change-expected.txt (from rev 104782, trunk/LayoutTests/compositing/geometry/foreground-offset-change-expected.txt) (0 => 104854)


--- branches/chromium/963/LayoutTests/compositing/geometry/foreground-offset-change-expected.txt	                        (rev 0)
+++ branches/chromium/963/LayoutTests/compositing/geometry/foreground-offset-change-expected.txt	2012-01-12 21:34:27 UTC (rev 104854)
@@ -0,0 +1 @@
+

Copied: branches/chromium/963/LayoutTests/compositing/geometry/foreground-offset-change.html (from rev 104782, trunk/LayoutTests/compositing/geometry/foreground-offset-change.html) (0 => 104854)


--- branches/chromium/963/LayoutTests/compositing/geometry/foreground-offset-change.html	                        (rev 0)
+++ branches/chromium/963/LayoutTests/compositing/geometry/foreground-offset-change.html	2012-01-12 21:34:27 UTC (rev 104854)
@@ -0,0 +1,73 @@
+<html>
+<head>
+  <style>
+    #clipper {
+      width: 550px;
+      height: 550px;
+      overflow:hidden;
+    }
+
+    #trigger {
+      /* Only overlap with the contents element, not the stretch element */
+      -webkit-transform:translateZ(0);
+      position: absolute;
+      top: 0px;
+      left: 0px;
+      width: 500px;
+      height: 200px;
+    }
+
+    #container {
+      /* Force compositing for this layer if any children get composited */
+      -webkit-transform:translate(0px, 1px);
+    }
+
+    #negative {
+      /* Trigger foreground layer from container */
+      z-index: -1;
+      position: absolute;
+    }
+
+    #contents {
+      /* foreground layer contents */
+      width: 550px;
+      height: 550px;
+      background-color: green;
+    }
+
+    /* Move this element to stretch container to have a negative offset */
+    #stretch {
+      position: absolute;
+      background-color: blue;
+      top: 200px;
+      left: -200px;
+      width: 50px;
+      height: 50px;
+    }
+
+  </style>
+  <script>
+    if (window.layoutTestController)
+      layoutTestController.dumpAsText(true);
+
+    function doTest()
+    {
+      if (window.layoutTestController)
+        layoutTestController.display();
+
+      document.getElementById("stretch").style.left = "-100px";
+    }
+
+    window.addEventListener('load', doTest, false);
+  </script>
+</head>
+<body>
+  <div id="trigger"></div>
+  <div id="clipper">
+    <div id="container">
+      <img id="contents">
+      <div id="stretch"></div>
+      <div id="negative"></div>
+    </div>
+  </div>
+</body>

Modified: branches/chromium/963/Source/WebCore/platform/graphics/GraphicsLayer.cpp (104853 => 104854)


--- branches/chromium/963/Source/WebCore/platform/graphics/GraphicsLayer.cpp	2012-01-12 21:28:51 UTC (rev 104853)
+++ branches/chromium/963/Source/WebCore/platform/graphics/GraphicsLayer.cpp	2012-01-12 21:34:27 UTC (rev 104854)
@@ -30,6 +30,8 @@
 #include "GraphicsLayer.h"
 
 #include "FloatPoint.h"
+#include "GraphicsContext.h"
+#include "LayoutTypes.h"
 #include "RotateTransformOperation.h"
 #include "TextStream.h"
 #include <wtf/text/CString.h>
@@ -260,6 +262,17 @@
     m_replicaLayer = layer;
 }
 
+void GraphicsLayer::setOffsetFromRenderer(const IntSize& offset)
+{
+    if (offset == m_offsetFromRenderer)
+        return;
+
+    m_offsetFromRenderer = offset;
+
+    // If the compositing layer offset changes, we need to repaint.
+    setNeedsDisplay();
+}
+
 void GraphicsLayer::setBackgroundColor(const Color& color)
 {
     m_backgroundColor = color;
@@ -277,8 +290,15 @@
 #ifndef NDEBUG
     s_inPaintContents = true;
 #endif
-    if (m_client)
-        m_client->paintContents(this, context, m_paintingPhase, clip);
+    if (m_client) {
+        LayoutSize offset = offsetFromRenderer();
+        context.translate(-offset);
+
+        LayoutRect clipRect(clip);
+        clipRect.move(offset);
+
+        m_client->paintContents(this, context, m_paintingPhase, clipRect);
+    }
 #ifndef NDEBUG
     s_inPaintContents = false;
 #endif

Modified: branches/chromium/963/Source/WebCore/platform/graphics/GraphicsLayer.h (104853 => 104854)


--- branches/chromium/963/Source/WebCore/platform/graphics/GraphicsLayer.h	2012-01-12 21:28:51 UTC (rev 104853)
+++ branches/chromium/963/Source/WebCore/platform/graphics/GraphicsLayer.h	2012-01-12 21:34:27 UTC (rev 104854)
@@ -237,7 +237,7 @@
 
     // Offset is origin of the renderer minus origin of the graphics layer (so either zero or negative).
     IntSize offsetFromRenderer() const { return m_offsetFromRenderer; }
-    void setOffsetFromRenderer(const IntSize& offset) { m_offsetFromRenderer = offset; }
+    void setOffsetFromRenderer(const IntSize&);
 
     // The position of the layer (the location of its top-left corner in its parent)
     const FloatPoint& position() const { return m_position; }

Modified: branches/chromium/963/Source/WebCore/rendering/RenderLayerBacking.cpp (104853 => 104854)


--- branches/chromium/963/Source/WebCore/rendering/RenderLayerBacking.cpp	2012-01-12 21:28:51 UTC (rev 104853)
+++ branches/chromium/963/Source/WebCore/rendering/RenderLayerBacking.cpp	2012-01-12 21:34:27 UTC (rev 104854)
@@ -409,14 +409,8 @@
     }
 
     m_graphicsLayer->setPosition(FloatPoint() + (relativeCompositingBounds.location() - graphicsLayerParentLocation));
-    
-    LayoutSize oldOffsetFromRenderer = m_graphicsLayer->offsetFromRenderer();
     m_graphicsLayer->setOffsetFromRenderer(localCompositingBounds.location() - LayoutPoint());
     
-    // If the compositing layer offset changes, we need to repaint.
-    if (oldOffsetFromRenderer != m_graphicsLayer->offsetFromRenderer())
-        m_graphicsLayer->setNeedsDisplay();
-    
     FloatSize oldSize = m_graphicsLayer->size();
     FloatSize newSize = relativeCompositingBounds.size();
     if (oldSize != newSize) {
@@ -1198,15 +1192,9 @@
     if (graphicsLayer == m_graphicsLayer.get() || graphicsLayer == m_foregroundLayer.get() || graphicsLayer == m_maskLayer.get()) {
         InspectorInstrumentationCookie cookie = InspectorInstrumentation::willPaint(m_owningLayer->renderer()->frame(), clip);
 
-        LayoutSize offset = graphicsLayer->offsetFromRenderer();
-        context.translate(-offset);
-
-        LayoutRect clipRect(clip);
-        clipRect.move(offset);
-
         // The dirtyRect is in the coords of the painting root.
         LayoutRect dirtyRect = compositedBounds();
-        dirtyRect.intersect(clipRect);
+        dirtyRect.intersect(clip);
 
         // We have to use the same root as for hit testing, because both methods can compute and cache clipRects.
         paintIntoLayer(m_owningLayer, &context, dirtyRect, PaintBehaviorNormal, paintingPhase, renderer());
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to