From f55e36e68c0ae2ccca7f11ffe30a578b34655f3b Mon Sep 17 00:00:00 2001 From: "shawnsingh@chromium.org" Date: Wed, 22 Feb 2012 01:49:36 +0000 Subject: [PATCH] [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): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@108426 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebCore/ChangeLog | 25 ++++++++++++++++++++++ .../platform/graphics/chromium/LayerChromium.cpp | 1 + .../platform/graphics/chromium/cc/CCLayerImpl.cpp | 1 + .../graphics/chromium/cc/CCLayerTreeHostCommon.cpp | 16 +++++--------- 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 7c9bd29..1a5c998 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,28 @@ +2012-02-21 Shawn Singh + + [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 Remove FIXME from resolve-supplemental.pl diff --git a/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp b/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp index 4bcf297..df2598f 100644 --- a/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp +++ b/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp @@ -503,6 +503,7 @@ void LayerChromium::createRenderSurface() { ASSERT(!m_renderSurface); m_renderSurface = adoptPtr(new RenderSurfaceChromium(this)); + setTargetRenderSurface(m_renderSurface.get()); } bool LayerChromium::descendantDrawsContent() diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.cpp index c2bd34b..ce54e7e 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.cpp @@ -104,6 +104,7 @@ void CCLayerImpl::createRenderSurface() { ASSERT(!m_renderSurface); m_renderSurface = adoptPtr(new CCRenderSurface(this)); + setTargetRenderSurface(m_renderSurface.get()); } bool CCLayerImpl::descendantDrawsContent() diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp index 9b250d0..4fc8694 100644 --- a/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp +++ b/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostCommon.cpp @@ -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()) { -- 2.7.4