Title: [113248] trunk/Source
Revision
113248
Author
shawnsi...@chromium.org
Date
2012-04-04 15:23:28 -0700 (Wed, 04 Apr 2012)

Log Message

[chromium] Move recursive renderSurface clearing to CCLayerTreeHostImpl
https://bugs.webkit.org/show_bug.cgi?id=82091

Reviewed by James Robinson.

Source/WebCore:

No new tests needed, minor refactoring covered by existing tests.

This patch is just a minor cleanup, moving clearRenderSurfacesOnCCLayerImplRecursive()
from LayerRendererChromium to CCLayerTreeHostImpl. It makes more sense to place the code
there, so that LayerRendererChromium is more like a blind utility for drawing things
while CCLayerTreeHostImpl actually manages the state of the resources.

* platform/graphics/chromium/LayerRendererChromium.cpp:
(WebCore::LayerRendererChromium::beginDrawingFrame):
* platform/graphics/chromium/LayerRendererChromium.h:
(LayerRendererChromium):
* platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
(WebCore::CCLayerTreeHostImpl::~CCLayerTreeHostImpl):
(WebCore::CCLayerTreeHostImpl::initializeLayerRenderer):
(WebCore::CCLayerTreeHostImpl::sendDidLoseContextRecursive):
(WebCore::CCLayerTreeHostImpl::clearRenderSurfacesOnCCLayerImplRecursive):
(WebCore):
* platform/graphics/chromium/cc/CCLayerTreeHostImpl.h:
(WebCore::CCLayerTreeHostImpl::rootLayer):
(CCLayerTreeHostImpl):

Source/WebKit/chromium:

* tests/LayerRendererChromiumTest.cpp:
(FakeLayerRendererChromiumClient::FakeLayerRendererChromiumClient):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (113247 => 113248)


--- trunk/Source/WebCore/ChangeLog	2012-04-04 22:23:10 UTC (rev 113247)
+++ trunk/Source/WebCore/ChangeLog	2012-04-04 22:23:28 UTC (rev 113248)
@@ -1,3 +1,31 @@
+2012-04-04  Shawn Singh  <shawnsi...@chromium.org>
+
+        [chromium] Move recursive renderSurface clearing to CCLayerTreeHostImpl
+        https://bugs.webkit.org/show_bug.cgi?id=82091
+
+        Reviewed by James Robinson.
+
+        No new tests needed, minor refactoring covered by existing tests.
+
+        This patch is just a minor cleanup, moving clearRenderSurfacesOnCCLayerImplRecursive()
+        from LayerRendererChromium to CCLayerTreeHostImpl. It makes more sense to place the code
+        there, so that LayerRendererChromium is more like a blind utility for drawing things
+        while CCLayerTreeHostImpl actually manages the state of the resources.
+
+        * platform/graphics/chromium/LayerRendererChromium.cpp:
+        (WebCore::LayerRendererChromium::beginDrawingFrame):
+        * platform/graphics/chromium/LayerRendererChromium.h:
+        (LayerRendererChromium):
+        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
+        (WebCore::CCLayerTreeHostImpl::~CCLayerTreeHostImpl):
+        (WebCore::CCLayerTreeHostImpl::initializeLayerRenderer):
+        (WebCore::CCLayerTreeHostImpl::sendDidLoseContextRecursive):
+        (WebCore::CCLayerTreeHostImpl::clearRenderSurfacesOnCCLayerImplRecursive):
+        (WebCore):
+        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.h:
+        (WebCore::CCLayerTreeHostImpl::rootLayer):
+        (CCLayerTreeHostImpl):
+
 2012-04-04  Chris Rogers  <crog...@google.com>
 
         Web Audio should use MutexTryLocker class

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


--- trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp	2012-04-04 22:23:10 UTC (rev 113247)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp	2012-04-04 22:23:28 UTC (rev 113248)
@@ -320,19 +320,6 @@
     cleanupSharedObjects();
 }
 
-void LayerRendererChromium::clearRenderSurfacesOnCCLayerImplRecursive(CCLayerImpl* layer)
-{
-    for (size_t i = 0; i < layer->children().size(); ++i)
-        clearRenderSurfacesOnCCLayerImplRecursive(layer->children()[i].get());
-    layer->clearRenderSurface();
-}
-
-void LayerRendererChromium::close()
-{
-    if (rootLayer())
-        clearRenderSurfacesOnCCLayerImplRecursive(rootLayer());
-}
-
 GraphicsContext3D* LayerRendererChromium::context()
 {
     return m_context.get();
@@ -407,6 +394,7 @@
     ensureFramebuffer();
 
     m_defaultRenderSurface = rootLayer()->renderSurface();
+    ASSERT(m_defaultRenderSurface);
 
     // FIXME: use the frame begin time from the overall compositor scheduler.
     // This value is currently inaccessible because it is up in Chromium's

Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h (113247 => 113248)


--- trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h	2012-04-04 22:23:10 UTC (rev 113247)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h	2012-04-04 22:23:28 UTC (rev 113248)
@@ -81,9 +81,6 @@
 public:
     static PassOwnPtr<LayerRendererChromium> create(LayerRendererChromiumClient*, PassRefPtr<GraphicsContext3D>);
 
-    // Must be called in order to allow the LayerRendererChromium to destruct
-    void close();
-
     ~LayerRendererChromium();
 
     const CCSettings& settings() const { return m_client->settings(); }
@@ -209,8 +206,6 @@
     bool initializeSharedObjects();
     void cleanupSharedObjects();
 
-    void clearRenderSurfacesOnCCLayerImplRecursive(CCLayerImpl*);
-
     friend class LayerRendererSwapBuffersCompleteCallbackAdapter;
     void onSwapBuffersComplete();
 

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp (113247 => 113248)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp	2012-04-04 22:23:10 UTC (rev 113247)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp	2012-04-04 22:23:28 UTC (rev 113248)
@@ -124,8 +124,9 @@
 {
     ASSERT(CCProxy::isImplThread());
     TRACE_EVENT("CCLayerTreeHostImpl::~CCLayerTreeHostImpl()", this, 0);
-    if (m_layerRenderer)
-        m_layerRenderer->close();
+
+    if (rootLayer())
+        clearRenderSurfacesOnCCLayerImplRecursive(rootLayer());
 }
 
 void CCLayerTreeHostImpl::beginCommit()
@@ -499,9 +500,11 @@
     OwnPtr<LayerRendererChromium> layerRenderer;
     layerRenderer = LayerRendererChromium::create(this, context);
 
-    if (m_layerRenderer) {
-        m_layerRenderer->close();
-        sendDidLoseContextRecursive(m_rootLayerImpl.get());
+    // Since we now have a new context/layerRenderer, we cannot continue to use the old
+    // resources (i.e. renderSurfaces and texture IDs).
+    if (rootLayer()) {
+        clearRenderSurfacesOnCCLayerImplRecursive(rootLayer());
+        sendDidLoseContextRecursive(rootLayer());
     }
 
     m_layerRenderer = layerRenderer.release();
@@ -820,16 +823,24 @@
 
 void CCLayerTreeHostImpl::sendDidLoseContextRecursive(CCLayerImpl* current)
 {
-    if (!current)
-        return;
-
+    ASSERT(current);
     current->didLoseContext();
-    sendDidLoseContextRecursive(current->maskLayer());
-    sendDidLoseContextRecursive(current->replicaLayer());
+    if (current->maskLayer())
+        sendDidLoseContextRecursive(current->maskLayer());
+    if (current->replicaLayer())
+        sendDidLoseContextRecursive(current->replicaLayer());
     for (size_t i = 0; i < current->children().size(); ++i)
         sendDidLoseContextRecursive(current->children()[i].get());
 }
 
+void CCLayerTreeHostImpl::clearRenderSurfacesOnCCLayerImplRecursive(CCLayerImpl* current)
+{
+    ASSERT(current);
+    for (size_t i = 0; i < current->children().size(); ++i)
+        clearRenderSurfacesOnCCLayerImplRecursive(current->children()[i].get());
+    current->clearRenderSurface();
+}
+
 void CCLayerTreeHostImpl::animateGestures(double monotonicTime)
 {
     if (!m_activeGestureAnimation)

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h (113247 => 113248)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h	2012-04-04 22:23:10 UTC (rev 113247)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.h	2012-04-04 22:23:28 UTC (rev 113248)
@@ -96,7 +96,7 @@
     virtual const IntSize& viewportSize() const { return m_viewportSize; }
     virtual const CCSettings& settings() const { return m_settings; }
     virtual CCLayerImpl* rootLayer() { return m_rootLayerImpl.get(); }
-    virtual const CCLayerImpl* rootLayer() const  { return m_rootLayerImpl.get(); }
+    virtual const CCLayerImpl* rootLayer() const { return m_rootLayerImpl.get(); }
     virtual void didLoseContext();
     virtual void onSwapBuffersComplete();
     virtual void setFullRootLayerDamage();
@@ -173,6 +173,7 @@
     void animateLayersRecursive(CCLayerImpl*, double monotonicTime, double wallClockTime, CCAnimationEventsVector*, bool& didAnimate, bool& needsAnimateLayers);
     IntSize contentSize() const;
     void sendDidLoseContextRecursive(CCLayerImpl*);
+    void clearRenderSurfacesOnCCLayerImplRecursive(CCLayerImpl*);
 
     OwnPtr<LayerRendererChromium> m_layerRenderer;
     OwnPtr<CCLayerImpl> m_rootLayerImpl;

Modified: trunk/Source/WebKit/chromium/ChangeLog (113247 => 113248)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-04-04 22:23:10 UTC (rev 113247)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-04-04 22:23:28 UTC (rev 113248)
@@ -1,3 +1,13 @@
+2012-04-04  Shawn Singh  <shawnsi...@chromium.org>
+
+        [chromium] Move recursive renderSurface clearing to CCLayerTreeHostImpl
+        https://bugs.webkit.org/show_bug.cgi?id=82091
+
+        Reviewed by James Robinson.
+
+        * tests/LayerRendererChromiumTest.cpp:
+        (FakeLayerRendererChromiumClient::FakeLayerRendererChromiumClient):
+
 2012-04-04  Daniel Sievers  <siev...@chromium.org>
 
         [Chromium] Always skip draw and readback if there is nothing

Modified: trunk/Source/WebKit/chromium/tests/LayerRendererChromiumTest.cpp (113247 => 113248)


--- trunk/Source/WebKit/chromium/tests/LayerRendererChromiumTest.cpp	2012-04-04 22:23:10 UTC (rev 113247)
+++ trunk/Source/WebKit/chromium/tests/LayerRendererChromiumTest.cpp	2012-04-04 22:23:28 UTC (rev 113248)
@@ -67,6 +67,7 @@
         : m_setFullRootLayerDamageCount(0)
         , m_rootLayer(CCLayerImpl::create(1))
     {
+        m_rootLayer->createRenderSurface();
     }
 
     // LayerRendererChromiumClient methods.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to