[chromium] Refactor CCLayerTreeHostCommon: merge scattered setTargetRenderSurface...
authorshawnsingh@chromium.org <shawnsingh@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 22 Feb 2012 01:49:36 +0000 (01:49 +0000)
committershawnsingh@chromium.org <shawnsingh@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 22 Feb 2012 01:49:36 +0000 (01:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=78936

Reviewed by James Robinson.

No change in behavior, the code moved around already covered by existing tests.

In calculateDrawTransformsAndVisibility(), there are two separate
if-else statements where setTargetRenderSurface logic is
performed, and this makes the code less readable and more error
prone. This patch merges the logic, removing the redundant if-else
statements.

This code also merges one other set of if-statements that are
equivalent, if (layer->parent()) and if (layer!=rootLayer).

* platform/graphics/chromium/LayerChromium.cpp:
(WebCore::LayerChromium::createRenderSurface):
* platform/graphics/chromium/cc/CCLayerImpl.cpp:
(WebCore::CCLayerImpl::createRenderSurface):
* platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp:
(WebCore::calculateDrawTransformsAndVisibilityInternal):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/LayerChromium.cpp
Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.cpp
Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp

index 7c9bd29..1a5c998 100644 (file)
@@ -1,3 +1,28 @@
+2012-02-21  Shawn Singh  <shawnsingh@chromium.org>
+
+        [chromium] Refactor CCLayerTreeHostCommon: merge scattered setTargetRenderSurface logic
+        https://bugs.webkit.org/show_bug.cgi?id=78936
+
+        Reviewed by James Robinson.
+
+        No change in behavior, the code moved around already covered by existing tests.
+
+        In calculateDrawTransformsAndVisibility(), there are two separate
+        if-else statements where setTargetRenderSurface logic is
+        performed, and this makes the code less readable and more error
+        prone. This patch merges the logic, removing the redundant if-else
+        statements.
+
+        This code also merges one other set of if-statements that are
+        equivalent, if (layer->parent()) and if (layer!=rootLayer).
+
+        * platform/graphics/chromium/LayerChromium.cpp:
+        (WebCore::LayerChromium::createRenderSurface):
+        * platform/graphics/chromium/cc/CCLayerImpl.cpp:
+        (WebCore::CCLayerImpl::createRenderSurface):
+        * platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp:
+        (WebCore::calculateDrawTransformsAndVisibilityInternal):
+
 2012-02-21  Kentaro Hara  <haraken@chromium.org>
 
         Remove FIXME from resolve-supplemental.pl
index 4bcf297..df2598f 100644 (file)
@@ -503,6 +503,7 @@ void LayerChromium::createRenderSurface()
 {
     ASSERT(!m_renderSurface);
     m_renderSurface = adoptPtr(new RenderSurfaceChromium(this));
+    setTargetRenderSurface(m_renderSurface.get());
 }
 
 bool LayerChromium::descendantDrawsContent()
index c2bd34b..ce54e7e 100644 (file)
@@ -104,6 +104,7 @@ void CCLayerImpl::createRenderSurface()
 {
     ASSERT(!m_renderSurface);
     m_renderSurface = adoptPtr(new CCRenderSurface(this));
+    setTargetRenderSurface(m_renderSurface.get());
 }
 
 bool CCLayerImpl::descendantDrawsContent()
index 9b250d0..4fc8694 100644 (file)
@@ -323,18 +323,19 @@ static bool calculateDrawTransformsAndVisibilityInternal(LayerType* layer, Layer
 
         layer->setDrawOpacity(drawOpacity);
 
-        if (layer->parent()) {
+        if (layer != rootLayer) {
+            ASSERT(layer->parent());
+            layer->clearRenderSurface();
+
             // Layers inherit the clip rect from their parent.
             layer->setClipRect(layer->parent()->clipRect());
             if (layer->parent()->usesLayerClipping())
                 layer->setUsesLayerClipping(true);
 
+            // Layers without their own renderSurface will render into the nearest ancestor surface.
             layer->setTargetRenderSurface(layer->parent()->targetRenderSurface());
         }
 
-        if (layer != rootLayer)
-            layer->clearRenderSurface();
-
         if (layer->masksToBounds()) {
             IntRect clipRect = transformedLayerRect;
             clipRect.intersect(layer->clipRect());
@@ -350,13 +351,6 @@ static bool calculateDrawTransformsAndVisibilityInternal(LayerType* layer, Layer
     layerScreenSpaceTransform.translate3d(-0.5 * bounds.width(), -0.5 * bounds.height(), 0);
     layer->setScreenSpaceTransform(layerScreenSpaceTransform);
 
-    if (layer->renderSurface())
-        layer->setTargetRenderSurface(layer->renderSurface());
-    else {
-        ASSERT(layer->parent());
-        layer->setTargetRenderSurface(layer->parent()->targetRenderSurface());
-    }
-
     // drawableContentRect() is always stored in the coordinate system of the
     // RenderSurface the layer draws into.
     if (layer->drawsContent()) {