Title: [100530] trunk/Source
Revision
100530
Author
commit-qu...@webkit.org
Date
2011-11-16 16:59:48 -0800 (Wed, 16 Nov 2011)

Log Message

[chromium] Track property changes for render surfaces.
https://bugs.webkit.org/show_bug.cgi?id=72521

Patch by Shawn Singh <shawnsi...@chromium.org> on 2011-11-16
Reviewed by James Robinson.

Source/WebCore:

Created CCRenderSurfaceTest for testing.

* platform/graphics/chromium/LayerRendererChromium.cpp:
(WebCore::LayerRendererChromium::drawLayersOntoRenderSurfaces):
* platform/graphics/chromium/cc/CCLayerImpl.cpp:
(WebCore::CCLayerImpl::resetPropertyChangedFlagForSubtree):
* platform/graphics/chromium/cc/CCLayerImpl.h:
* platform/graphics/chromium/cc/CCRenderSurface.cpp:
(WebCore::CCRenderSurface::CCRenderSurface):
(WebCore::CCRenderSurface::setClipRect):
(WebCore::CCRenderSurface::setContentRect):
(WebCore::CCRenderSurface::surfacePropertyChanged):
* platform/graphics/chromium/cc/CCRenderSurface.h:
(WebCore::CCRenderSurface::resetPropertyChangedFlag):

Source/WebKit/chromium:

* WebKit.gypi:
* tests/CCLayerImplTest.cpp:
(WebCore::TEST):
* tests/CCRenderSurfaceTest.cpp: Added.
(WebCore::TEST):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (100529 => 100530)


--- trunk/Source/WebCore/ChangeLog	2011-11-17 00:58:40 UTC (rev 100529)
+++ trunk/Source/WebCore/ChangeLog	2011-11-17 00:59:48 UTC (rev 100530)
@@ -1,3 +1,25 @@
+2011-11-16  Shawn Singh  <shawnsi...@chromium.org>
+
+        [chromium] Track property changes for render surfaces.
+        https://bugs.webkit.org/show_bug.cgi?id=72521
+
+        Reviewed by James Robinson.
+
+        Created CCRenderSurfaceTest for testing.
+
+        * platform/graphics/chromium/LayerRendererChromium.cpp:
+        (WebCore::LayerRendererChromium::drawLayersOntoRenderSurfaces):
+        * platform/graphics/chromium/cc/CCLayerImpl.cpp:
+        (WebCore::CCLayerImpl::resetPropertyChangedFlagForSubtree):
+        * platform/graphics/chromium/cc/CCLayerImpl.h:
+        * platform/graphics/chromium/cc/CCRenderSurface.cpp:
+        (WebCore::CCRenderSurface::CCRenderSurface):
+        (WebCore::CCRenderSurface::setClipRect):
+        (WebCore::CCRenderSurface::setContentRect):
+        (WebCore::CCRenderSurface::surfacePropertyChanged):
+        * platform/graphics/chromium/cc/CCRenderSurface.h:
+        (WebCore::CCRenderSurface::resetPropertyChangedFlag):
+
 2011-11-16  Ben Wells  <benwe...@chromium.org>
 
         Seaming on border corners with mixed colour alpha borders

Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp (100529 => 100530)


--- trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp	2011-11-17 00:58:40 UTC (rev 100529)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp	2011-11-17 00:59:48 UTC (rev 100530)
@@ -343,6 +343,9 @@
                 drawLayer(layerList[layerIndex].get(), renderSurface);
         }
     }
+
+    // The next frame should start by assuming nothing has changed, and changes are noted as they occur.
+    rootDrawLayer->resetPropertyChangedFlagForSubtree();
 }
 
 

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.cpp (100529 => 100530)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.cpp	2011-11-17 00:58:40 UTC (rev 100529)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.cpp	2011-11-17 00:59:48 UTC (rev 100530)
@@ -239,6 +239,17 @@
         m_children[i]->noteLayerPropertyChangedForSubtree();
 }
 
+void CCLayerImpl::resetPropertyChangedFlagForSubtree()
+{
+    m_layerPropertyChanged = false;
+
+    if (m_renderSurface)
+        m_renderSurface->resetPropertyChangedFlag();
+
+    for (size_t i = 0; i < m_children.size(); ++i)
+        m_children[i]->resetPropertyChangedFlagForSubtree();
+}
+
 void CCLayerImpl::setBounds(const IntSize& bounds)
 {
     if (m_bounds != bounds) {

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.h (100529 => 100530)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.h	2011-11-17 00:58:40 UTC (rev 100529)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.h	2011-11-17 00:59:48 UTC (rev 100530)
@@ -192,7 +192,7 @@
     String layerTreeAsText() const;
 
     bool layerPropertyChanged() const { return m_layerPropertyChanged; }
-    void resetLayerPropertyChanged() { m_layerPropertyChanged = false; }
+    void resetPropertyChangedFlagForSubtree(); // also resets property change for existing render surfaces.
 
 protected:
     explicit CCLayerImpl(int);

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.cpp (100529 => 100530)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.cpp	2011-11-17 00:58:40 UTC (rev 100529)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.cpp	2011-11-17 00:59:48 UTC (rev 100530)
@@ -43,6 +43,7 @@
     : m_owningLayer(owningLayer)
     , m_maskLayer(0)
     , m_skipsDraw(false)
+    , m_surfacePropertyChanged(false)
     , m_drawOpacity(1)
 {
 }
@@ -235,5 +236,37 @@
     return m_owningLayer ? m_owningLayer->id() : 0;
 }
 
+void CCRenderSurface::setClipRect(const IntRect& clipRect)
+{
+    if (m_clipRect == clipRect)
+        return;
+
+    m_surfacePropertyChanged = true;
+    m_clipRect = clipRect;
 }
+
+void CCRenderSurface::setContentRect(const IntRect& contentRect)
+{
+    if (m_contentRect == contentRect)
+        return;
+
+    m_surfacePropertyChanged = true;
+    m_contentRect = contentRect;
+}
+
+bool CCRenderSurface::surfacePropertyChanged() const
+{
+    // Surface property changes are tracked as follows:
+    //
+    // - m_surfacePropertyChanged is flagged when the clipRect or contentRect change. As
+    //   of now, these are the only two properties that can be affected by descendant layers.
+    //
+    // - all other property changes come from the owning layer (or some ancestor layer
+    //   that propagates its change to the owning layer).
+    //
+    ASSERT(m_owningLayer);
+    return m_surfacePropertyChanged || m_owningLayer->layerPropertyChanged();
+}
+
+}
 #endif // USE(ACCELERATED_COMPOSITING)

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.h (100529 => 100530)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.h	2011-11-17 00:58:40 UTC (rev 100529)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.h	2011-11-17 00:59:48 UTC (rev 100530)
@@ -75,10 +75,10 @@
     void setOriginTransform(const TransformationMatrix& originTransform) { m_originTransform = originTransform; }
     const TransformationMatrix& originTransform() const { return m_originTransform; }
 
-    void setClipRect(const IntRect& clipRect) { m_clipRect = clipRect; }
+    void setClipRect(const IntRect&);
     const IntRect& clipRect() const { return m_clipRect; }
 
-    void setContentRect(const IntRect& contentRect) { m_contentRect = contentRect; }
+    void setContentRect(const IntRect&);
     const IntRect& contentRect() const { return m_contentRect; }
 
     void setSkipsDraw(bool skipsDraw) { m_skipsDraw = skipsDraw; }
@@ -97,6 +97,10 @@
     ManagedTexture* contentsTexture() const { return m_contentsTexture.get(); }
 
     int owningLayerId() const;
+
+    void resetPropertyChangedFlag() { m_surfacePropertyChanged = false; }
+    bool surfacePropertyChanged() const;
+
 private:
     void drawLayer(LayerRendererChromium*, CCLayerImpl*, const TransformationMatrix&);
     template <class T>
@@ -107,6 +111,7 @@
 
     IntRect m_contentRect;
     bool m_skipsDraw;
+    bool m_surfacePropertyChanged;
 
     OwnPtr<ManagedTexture> m_contentsTexture;
     float m_drawOpacity;

Modified: trunk/Source/WebKit/chromium/ChangeLog (100529 => 100530)


--- trunk/Source/WebKit/chromium/ChangeLog	2011-11-17 00:58:40 UTC (rev 100529)
+++ trunk/Source/WebKit/chromium/ChangeLog	2011-11-17 00:59:48 UTC (rev 100530)
@@ -1,3 +1,16 @@
+2011-11-16  Shawn Singh  <shawnsi...@chromium.org>
+
+        [chromium] Track property changes for render surfaces.
+        https://bugs.webkit.org/show_bug.cgi?id=72521
+
+        Reviewed by James Robinson.
+
+        * WebKit.gypi:
+        * tests/CCLayerImplTest.cpp:
+        (WebCore::TEST):
+        * tests/CCRenderSurfaceTest.cpp: Added.
+        (WebCore::TEST):
+
 2011-11-16  Alexandre Elias  <ael...@google.com>
 
         [chromium] Improvements for page scale delta during commit

Modified: trunk/Source/WebKit/chromium/WebKit.gypi (100529 => 100530)


--- trunk/Source/WebKit/chromium/WebKit.gypi	2011-11-17 00:58:40 UTC (rev 100529)
+++ trunk/Source/WebKit/chromium/WebKit.gypi	2011-11-17 00:59:48 UTC (rev 100530)
@@ -61,6 +61,7 @@
             'tests/CCLayerTreeHostCommonTest.cpp',
             'tests/CCLayerTreeHostImplTest.cpp',
             'tests/CCLayerTreeHostTest.cpp',
+            'tests/CCRenderSurfaceTest.cpp',
             'tests/CCSchedulerTest.cpp',
             'tests/CCSchedulerStateMachineTest.cpp',
             'tests/CCSchedulerTestCommon.h',

Modified: trunk/Source/WebKit/chromium/tests/CCLayerImplTest.cpp (100529 => 100530)


--- trunk/Source/WebKit/chromium/tests/CCLayerImplTest.cpp	2011-11-17 00:58:40 UTC (rev 100529)
+++ trunk/Source/WebKit/chromium/tests/CCLayerImplTest.cpp	2011-11-17 00:59:48 UTC (rev 100530)
@@ -35,27 +35,21 @@
 namespace {
 
 #define EXECUTE_AND_VERIFY_SUBTREE_CHANGED(codeToTest)                  \
-    root->resetLayerPropertyChanged();                                  \
-    child->resetLayerPropertyChanged();                                 \
-    grandChild->resetLayerPropertyChanged();                            \
+    root->resetPropertyChangedFlagForSubtree();                         \
     codeToTest;                                                         \
     EXPECT_TRUE(root->layerPropertyChanged());                          \
     EXPECT_TRUE(child->layerPropertyChanged());                         \
     EXPECT_TRUE(grandChild->layerPropertyChanged())
 
 #define EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(codeToTest)           \
-    root->resetLayerPropertyChanged();                                  \
-    child->resetLayerPropertyChanged();                                 \
-    grandChild->resetLayerPropertyChanged();                            \
+    root->resetPropertyChangedFlagForSubtree();                         \
     codeToTest;                                                         \
     EXPECT_FALSE(root->layerPropertyChanged());                         \
     EXPECT_FALSE(child->layerPropertyChanged());                        \
     EXPECT_FALSE(grandChild->layerPropertyChanged())
 
 #define EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(codeToTest)               \
-    root->resetLayerPropertyChanged();                                  \
-    child->resetLayerPropertyChanged();                                 \
-    grandChild->resetLayerPropertyChanged();                            \
+    root->resetPropertyChangedFlagForSubtree();                         \
     codeToTest;                                                         \
     EXPECT_TRUE(root->layerPropertyChanged());                          \
     EXPECT_FALSE(child->layerPropertyChanged());                        \
@@ -121,9 +115,7 @@
     EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->setBackgroundColor(Color::gray));
 
     // Special case: check that sublayer transform changes all layer's descendants, but not the layer itself.
-    root->resetLayerPropertyChanged();
-    child->resetLayerPropertyChanged();
-    grandChild->resetLayerPropertyChanged();
+    root->resetPropertyChangedFlagForSubtree();
     root->setSublayerTransform(arbitraryTransform);
     EXPECT_FALSE(root->layerPropertyChanged());
     EXPECT_TRUE(child->layerPropertyChanged());

Added: trunk/Source/WebKit/chromium/tests/CCRenderSurfaceTest.cpp (0 => 100530)


--- trunk/Source/WebKit/chromium/tests/CCRenderSurfaceTest.cpp	                        (rev 0)
+++ trunk/Source/WebKit/chromium/tests/CCRenderSurfaceTest.cpp	2011-11-17 00:59:48 UTC (rev 100530)
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include "cc/CCRenderSurface.h"
+
+#include "cc/CCLayerImpl.h"
+#include "cc/CCSingleThreadProxy.h"
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+using namespace WebCore;
+
+namespace {
+
+#define EXECUTE_AND_VERIFY_SURFACE_CHANGED(codeToTest)                  \
+    renderSurface->resetPropertyChangedFlag();                          \
+    codeToTest;                                                         \
+    EXPECT_TRUE(renderSurface->surfacePropertyChanged())
+
+#define EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(codeToTest)           \
+    renderSurface->resetPropertyChangedFlag();                          \
+    codeToTest;                                                         \
+    EXPECT_FALSE(renderSurface->surfacePropertyChanged())
+
+TEST(CCRenderSurfaceTest, verifySurfaceChangesAreTrackedProperly)
+{
+    //
+    // This test checks that surfacePropertyChanged() has the correct behavior.
+    //
+
+    // This will fake that we are on the correct thread for testing purposes.
+    DebugScopedSetImplThread setImplThread;
+
+    RefPtr<CCLayerImpl> owningLayer = CCLayerImpl::create(0);
+    owningLayer->createRenderSurface();
+    ASSERT_TRUE(owningLayer->renderSurface());
+    CCRenderSurface* renderSurface = owningLayer->renderSurface();
+    IntRect testRect = IntRect(IntPoint(3, 4), IntSize(5, 6));
+
+    owningLayer->resetPropertyChangedFlagForSubtree();
+
+    // Currently, the contentRect, clipRect, and owningLayer->layerPropertyChanged() are
+    // the only sources of change.
+    EXECUTE_AND_VERIFY_SURFACE_CHANGED(renderSurface->setClipRect(testRect));
+    EXECUTE_AND_VERIFY_SURFACE_CHANGED(renderSurface->setContentRect(testRect));
+
+    owningLayer->resetPropertyChangedFlagForSubtree();
+    owningLayer->setOpacity(0.5f);
+    EXPECT_TRUE(renderSurface->surfacePropertyChanged());
+    owningLayer->resetPropertyChangedFlagForSubtree();
+
+    // Setting the surface properties to the same values again should not be considered "change".
+    EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setClipRect(testRect));
+    EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setContentRect(testRect));
+
+    RefPtr<CCLayerImpl> dummyMask = CCLayerImpl::create(1);
+    TransformationMatrix dummyMatrix;
+    dummyMatrix.translate(1.0, 2.0);
+
+    // The rest of the surface properties are either internal and should not cause change,
+    // or they are already accounted for by the owninglayer->layerPropertyChanged().
+    EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setDrawOpacity(0.5));
+    EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setDrawTransform(dummyMatrix));
+    EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setReplicaDrawTransform(dummyMatrix));
+    EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setOriginTransform(dummyMatrix));
+    EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setSkipsDraw(true));
+    EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->clearLayerList());
+    EXECUTE_AND_VERIFY_SURFACE_DID_NOT_CHANGE(renderSurface->setMaskLayer(dummyMask.get()));
+}
+
+} // namespace
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to