[chromium] Ubercomp: clean up CCRenderer interface
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Jul 2012 22:33:06 +0000 (22:33 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Jul 2012 22:33:06 +0000 (22:33 +0000)
https://bugs.webkit.org/show_bug.cgi?id=91555

Patch by Alexandre Elias <aelias@google.com> on 2012-07-18
Reviewed by Adrienne Walker.

I replaced the one-by-one RenderPass calls with a new drawFrame()
method that directly takes a CCRenderPassList, and moved a small
amount of code from CCLayerTreeHostImpl to implement it.  In ubercomp
mode, we will produce a frame bundle rather than a command-stream, so
the full list is easier to work with.

Also, give empty default implementations for the methods that don't
need to do anything in a non-GL context, and make private
setScissorToRect.

Source/WebCore:

No new tests (no-op refactoring).

* platform/graphics/chromium/LayerRendererChromium.cpp:
(WebCore::LayerRendererChromium::drawFrame):
(WebCore):
* platform/graphics/chromium/LayerRendererChromium.h:
(LayerRendererChromium):
* platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
(WebCore::CCLayerTreeHostImpl::drawLayers):
* platform/graphics/chromium/cc/CCRenderer.h:
(WebCore::CCRenderer::viewportChanged):
(WebCore::CCRenderer::decideRenderPassAllocationsForFrame):
(WebCore::CCRenderer::haveCachedResourcesForRenderPassId):
(CCRenderer):
(WebCore::CCRenderer::finishDrawingFrame):
(WebCore::CCRenderer::doNoOp):
(WebCore::CCRenderer::isContextLost):

Source/WebKit/chromium:

* tests/LayerRendererChromiumTest.cpp:
(FakeCCRendererClient::FakeCCRendererClient):
(FakeCCRendererClient::renderPasses):
(FakeCCRendererClient):
(TEST_F):
(TEST):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h
Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp
Source/WebCore/platform/graphics/chromium/cc/CCRenderer.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/tests/LayerRendererChromiumTest.cpp

index a118202..50299bf 100644 (file)
@@ -1,3 +1,38 @@
+2012-07-18  Alexandre Elias  <aelias@google.com>
+
+        [chromium] Ubercomp: clean up CCRenderer interface
+        https://bugs.webkit.org/show_bug.cgi?id=91555
+
+        Reviewed by Adrienne Walker.
+
+        I replaced the one-by-one RenderPass calls with a new drawFrame()
+        method that directly takes a CCRenderPassList, and moved a small
+        amount of code from CCLayerTreeHostImpl to implement it.  In ubercomp
+        mode, we will produce a frame bundle rather than a command-stream, so
+        the full list is easier to work with.
+
+        Also, give empty default implementations for the methods that don't
+        need to do anything in a non-GL context, and make private
+        setScissorToRect.
+
+        No new tests (no-op refactoring).
+
+        * platform/graphics/chromium/LayerRendererChromium.cpp:
+        (WebCore::LayerRendererChromium::drawFrame):
+        (WebCore):
+        * platform/graphics/chromium/LayerRendererChromium.h:
+        (LayerRendererChromium):
+        * platform/graphics/chromium/cc/CCLayerTreeHostImpl.cpp:
+        (WebCore::CCLayerTreeHostImpl::drawLayers):
+        * platform/graphics/chromium/cc/CCRenderer.h:
+        (WebCore::CCRenderer::viewportChanged):
+        (WebCore::CCRenderer::decideRenderPassAllocationsForFrame):
+        (WebCore::CCRenderer::haveCachedResourcesForRenderPassId):
+        (CCRenderer):
+        (WebCore::CCRenderer::finishDrawingFrame):
+        (WebCore::CCRenderer::doNoOp):
+        (WebCore::CCRenderer::isContextLost):
+
 2012-07-18  Pravin D  <pravind.2k4@gmail.com>
 
         Content size of child having percent height inside a fixed height container having overflow:auto is wrongly calculated
 2012-07-18  Pravin D  <pravind.2k4@gmail.com>
 
         Content size of child having percent height inside a fixed height container having overflow:auto is wrongly calculated
index 950b932..337d746 100644 (file)
@@ -46,6 +46,7 @@
 #include "ThrottledTextureUploader.h"
 #include "TraceEvent.h"
 #include "TrackingTextureAllocator.h"
 #include "ThrottledTextureUploader.h"
 #include "TraceEvent.h"
 #include "TrackingTextureAllocator.h"
+#include "cc/CCDamageTracker.h"
 #include "cc/CCLayerQuad.h"
 #include "cc/CCMathUtil.h"
 #include "cc/CCProxy.h"
 #include "cc/CCLayerQuad.h"
 #include "cc/CCMathUtil.h"
 #include "cc/CCProxy.h"
@@ -353,6 +354,19 @@ bool LayerRendererChromium::haveCachedResourcesForRenderPassId(int id) const
     return texture && texture->id();
 }
 
     return texture && texture->id();
 }
 
+void LayerRendererChromium::drawFrame(const CCRenderPassList& renderPasses, const FloatRect& rootScissorRect)
+{
+    const CCRenderPass* rootRenderPass = renderPasses.last();
+    beginDrawingFrame(rootRenderPass);
+
+    for (size_t i = 0; i < renderPasses.size(); ++i) {
+        const CCRenderPass* renderPass = renderPasses[i];
+
+        FloatRect rootScissorRectInCurrentSurface = renderPass->targetSurface()->computeRootScissorRectInCurrentSurface(rootScissorRect);
+        drawRenderPass(renderPass, rootScissorRectInCurrentSurface);
+    }
+}
+
 void LayerRendererChromium::beginDrawingFrame(const CCRenderPass* rootRenderPass)
 {
     // FIXME: Remove this once framebuffer is automatically recreated on first use
 void LayerRendererChromium::beginDrawingFrame(const CCRenderPass* rootRenderPass)
 {
     // FIXME: Remove this once framebuffer is automatically recreated on first use
index 5facd6f..bd7b4e1 100644 (file)
@@ -81,8 +81,7 @@ public:
     virtual void decideRenderPassAllocationsForFrame(const CCRenderPassList&) OVERRIDE;
     virtual bool haveCachedResourcesForRenderPassId(int id) const OVERRIDE;
 
     virtual void decideRenderPassAllocationsForFrame(const CCRenderPassList&) OVERRIDE;
     virtual bool haveCachedResourcesForRenderPassId(int id) const OVERRIDE;
 
-    virtual void beginDrawingFrame(const CCRenderPass* defaultRenderPass) OVERRIDE;
-    virtual void drawRenderPass(const CCRenderPass*, const FloatRect& framebufferDamageRect) OVERRIDE;
+    virtual void drawFrame(const CCRenderPassList&, const FloatRect& rootScissorRect) OVERRIDE;
     virtual void finishDrawingFrame() OVERRIDE;
 
     virtual void drawHeadsUpDisplay(const CCScopedTexture*, const IntSize& hudSize) OVERRIDE;
     virtual void finishDrawingFrame() OVERRIDE;
 
     virtual void drawHeadsUpDisplay(const CCScopedTexture*, const IntSize& hudSize) OVERRIDE;
@@ -106,8 +105,6 @@ public:
     virtual TextureAllocator* implTextureAllocator() const OVERRIDE { return m_implTextureAllocator.get(); }
     virtual TextureAllocator* contentsTextureAllocator() const OVERRIDE { return m_contentsTextureAllocator.get(); }
 
     virtual TextureAllocator* implTextureAllocator() const OVERRIDE { return m_implTextureAllocator.get(); }
     virtual TextureAllocator* contentsTextureAllocator() const OVERRIDE { return m_contentsTextureAllocator.get(); }
 
-    virtual void setScissorToRect(const IntRect&) OVERRIDE;
-
     virtual bool isContextLost() OVERRIDE;
 
     virtual void setVisible(bool) OVERRIDE;
     virtual bool isContextLost() OVERRIDE;
 
     virtual void setVisible(bool) OVERRIDE;
@@ -128,6 +125,9 @@ protected:
 private:
     static void toGLMatrix(float*, const WebKit::WebTransformationMatrix&);
 
 private:
     static void toGLMatrix(float*, const WebKit::WebTransformationMatrix&);
 
+    void beginDrawingFrame(const CCRenderPass* rootRenderPass);
+    void drawRenderPass(const CCRenderPass*, const FloatRect& framebufferDamageRect);
+
     void drawQuad(const CCDrawQuad*);
     void drawCheckerboardQuad(const CCCheckerboardDrawQuad*);
     void drawDebugBorderQuad(const CCDebugBorderDrawQuad*);
     void drawQuad(const CCDrawQuad*);
     void drawCheckerboardQuad(const CCCheckerboardDrawQuad*);
     void drawDebugBorderQuad(const CCDebugBorderDrawQuad*);
@@ -140,6 +140,8 @@ private:
     void drawTileQuad(const CCTileDrawQuad*);
     void drawYUVVideoQuad(const CCYUVVideoDrawQuad*);
 
     void drawTileQuad(const CCTileDrawQuad*);
     void drawYUVVideoQuad(const CCYUVVideoDrawQuad*);
 
+    void setScissorToRect(const IntRect&);
+
     void setDrawFramebufferRect(const IntRect&, bool flipY);
 
     // The current drawing target is either a RenderPass or ScopedTexture. Use these functions to switch to a new drawing target.
     void setDrawFramebufferRect(const IntRect&, bool flipY);
 
     // The current drawing target is either a RenderPass or ScopedTexture. Use these functions to switch to a new drawing target.
index 04bb786..2008d9f 100644 (file)
@@ -547,30 +547,19 @@ void CCLayerTreeHostImpl::drawLayers(const FrameData& frame)
     // FIXME: use the frame begin time from the overall compositor scheduler.
     // This value is currently inaccessible because it is up in Chromium's
     // RenderWidget.
     // FIXME: use the frame begin time from the overall compositor scheduler.
     // This value is currently inaccessible because it is up in Chromium's
     // RenderWidget.
-
-    // The root RenderPass is the last one to be drawn.
-    const CCRenderPass* rootRenderPass = frame.renderPasses.last();
-
     m_fpsCounter->markBeginningOfFrame(currentTime());
     m_fpsCounter->markBeginningOfFrame(currentTime());
-    m_layerRenderer->beginDrawingFrame(rootRenderPass);
-
-    for (size_t i = 0; i < frame.renderPasses.size(); ++i) {
-        const CCRenderPass* renderPass = frame.renderPasses[i];
 
 
-        FloatRect rootScissorRectInCurrentSurface = renderPass->targetSurface()->computeRootScissorRectInCurrentSurface(m_rootScissorRect);
-        m_layerRenderer->drawRenderPass(renderPass, rootScissorRectInCurrentSurface);
+    m_layerRenderer->drawFrame(frame.renderPasses, m_rootScissorRect);
+    if (m_headsUpDisplay->enabled(settings()))
+        m_headsUpDisplay->draw(this);
+    m_layerRenderer->finishDrawingFrame();
 
 
-        renderPass->targetSurface()->damageTracker()->didDrawDamagedArea();
-    }
+    for (unsigned int i = 0; i < frame.renderPasses.size(); i++)
+        frame.renderPasses[i]->targetSurface()->damageTracker()->didDrawDamagedArea();
 
     if (m_debugRectHistory->enabled(settings()))
         m_debugRectHistory->saveDebugRectsForCurrentFrame(m_rootLayerImpl.get(), *frame.renderSurfaceLayerList, frame.occludingScreenSpaceRects, settings());
 
 
     if (m_debugRectHistory->enabled(settings()))
         m_debugRectHistory->saveDebugRectsForCurrentFrame(m_rootLayerImpl.get(), *frame.renderSurfaceLayerList, frame.occludingScreenSpaceRects, settings());
 
-    if (m_headsUpDisplay->enabled(settings()))
-        m_headsUpDisplay->draw(this);
-
-    m_layerRenderer->finishDrawingFrame();
-
     ++m_sourceAnimationFrameNumber;
 
     // The next frame should start by assuming nothing has changed, and changes are noted as they occur.
     ++m_sourceAnimationFrameNumber;
 
     // The next frame should start by assuming nothing has changed, and changes are noted as they occur.
index ded0efd..6b05d94 100644 (file)
@@ -67,24 +67,23 @@ public:
     int viewportWidth() { return viewportSize().width(); }
     int viewportHeight() { return viewportSize().height(); }
 
     int viewportWidth() { return viewportSize().width(); }
     int viewportHeight() { return viewportSize().height(); }
 
-    virtual void viewportChanged() = 0;
+    virtual void viewportChanged() { }
 
     const WebKit::WebTransformationMatrix& projectionMatrix() const { return m_projectionMatrix; }
     const WebKit::WebTransformationMatrix& windowMatrix() const { return m_windowMatrix; }
 
 
     const WebKit::WebTransformationMatrix& projectionMatrix() const { return m_projectionMatrix; }
     const WebKit::WebTransformationMatrix& windowMatrix() const { return m_windowMatrix; }
 
-    virtual void decideRenderPassAllocationsForFrame(const CCRenderPassList&) = 0;
-    virtual bool haveCachedResourcesForRenderPassId(int) const = 0;
+    virtual void decideRenderPassAllocationsForFrame(const CCRenderPassList&) { }
+    virtual bool haveCachedResourcesForRenderPassId(int) const { return false; }
 
 
-    virtual void beginDrawingFrame(const CCRenderPass* defaultRenderPass) = 0;
-    virtual void drawRenderPass(const CCRenderPass*, const FloatRect& rootScissorRectInCurrentPass) = 0;
-    virtual void finishDrawingFrame() = 0;
+    virtual void drawFrame(const CCRenderPassList&, const FloatRect& rootScissorRect) = 0;
+    virtual void finishDrawingFrame() { }
 
     virtual void drawHeadsUpDisplay(const CCScopedTexture*, const IntSize& hudSize) = 0;
 
     // waits for rendering to finish
     virtual void finish() = 0;
 
 
     virtual void drawHeadsUpDisplay(const CCScopedTexture*, const IntSize& hudSize) = 0;
 
     // waits for rendering to finish
     virtual void finish() = 0;
 
-    virtual void doNoOp() = 0;
+    virtual void doNoOp() { }
     // puts backbuffer onscreen
     virtual bool swapBuffers(const IntRect& subBuffer) = 0;
 
     // puts backbuffer onscreen
     virtual bool swapBuffers(const IntRect& subBuffer) = 0;
 
@@ -95,9 +94,7 @@ public:
     virtual TextureAllocator* implTextureAllocator() const = 0;
     virtual TextureAllocator* contentsTextureAllocator() const = 0;
 
     virtual TextureAllocator* implTextureAllocator() const = 0;
     virtual TextureAllocator* contentsTextureAllocator() const = 0;
 
-    virtual void setScissorToRect(const IntRect&) = 0;
-
-    virtual bool isContextLost() = 0;
+    virtual bool isContextLost() { return false; }
 
     virtual void setVisible(bool) = 0;
 
 
     virtual void setVisible(bool) = 0;
 
index 554c1fc..47225b8 100644 (file)
@@ -1,3 +1,27 @@
+2012-07-18  Alexandre Elias  <aelias@google.com>
+
+        [chromium] Ubercomp: clean up CCRenderer interface
+        https://bugs.webkit.org/show_bug.cgi?id=91555
+
+        Reviewed by Adrienne Walker.
+
+        I replaced the one-by-one RenderPass calls with a new drawFrame()
+        method that directly takes a CCRenderPassList, and moved a small
+        amount of code from CCLayerTreeHostImpl to implement it.  In ubercomp
+        mode, we will produce a frame bundle rather than a command-stream, so
+        the full list is easier to work with.
+
+        Also, give empty default implementations for the methods that don't
+        need to do anything in a non-GL context, and make private
+        setScissorToRect.
+
+        * tests/LayerRendererChromiumTest.cpp:
+        (FakeCCRendererClient::FakeCCRendererClient):
+        (FakeCCRendererClient::renderPasses):
+        (FakeCCRendererClient):
+        (TEST_F):
+        (TEST):
+
 2012-07-18  Joshua Bell  <jsbell@chromium.org>
 
         IndexedDB: Fix some coding style violations
 2012-07-18  Joshua Bell  <jsbell@chromium.org>
 
         IndexedDB: Fix some coding style violations
index 7cdba80..141b719 100644 (file)
@@ -81,6 +81,7 @@ public:
     {
         m_rootLayer->createRenderSurface();
         m_rootRenderPass = CCRenderPass::create(m_rootLayer->renderSurface(), m_rootLayer->id());
     {
         m_rootLayer->createRenderSurface();
         m_rootRenderPass = CCRenderPass::create(m_rootLayer->renderSurface(), m_rootLayer->id());
+        m_renderPasses.append(m_rootRenderPass.get());
     }
 
     // CCRendererClient methods.
     }
 
     // CCRendererClient methods.
@@ -96,6 +97,7 @@ public:
     int setFullRootLayerDamageCount() const { return m_setFullRootLayerDamageCount; }
 
     CCRenderPass* rootRenderPass() { return m_rootRenderPass.get(); }
     int setFullRootLayerDamageCount() const { return m_setFullRootLayerDamageCount; }
 
     CCRenderPass* rootRenderPass() { return m_rootRenderPass.get(); }
+    const CCRenderPassList& renderPasses() { return m_renderPasses; }
 
     size_t memoryAllocationLimitBytes() const { return m_memoryAllocationLimitBytes; }
 
 
     size_t memoryAllocationLimitBytes() const { return m_memoryAllocationLimitBytes; }
 
@@ -104,6 +106,7 @@ private:
     DebugScopedSetImplThread m_implThread;
     OwnPtr<CCLayerImpl> m_rootLayer;
     OwnPtr<CCRenderPass> m_rootRenderPass;
     DebugScopedSetImplThread m_implThread;
     OwnPtr<CCLayerImpl> m_rootLayer;
     OwnPtr<CCRenderPass> m_rootRenderPass;
+    CCRenderPassList m_renderPasses;
     size_t m_memoryAllocationLimitBytes;
 };
 
     size_t m_memoryAllocationLimitBytes;
 };
 
@@ -215,7 +218,7 @@ TEST_F(LayerRendererChromiumTest, DiscardedBackbufferIsRecreatedForScopeDuration
     EXPECT_EQ(1, m_mockClient.setFullRootLayerDamageCount());
 
     m_layerRendererChromium.setVisible(true);
     EXPECT_EQ(1, m_mockClient.setFullRootLayerDamageCount());
 
     m_layerRendererChromium.setVisible(true);
-    m_layerRendererChromium.beginDrawingFrame(m_mockClient.rootRenderPass());
+    m_layerRendererChromium.drawFrame(m_mockClient.renderPasses(), FloatRect());
     EXPECT_FALSE(m_layerRendererChromium.isFramebufferDiscarded());
 
     swapBuffers();
     EXPECT_FALSE(m_layerRendererChromium.isFramebufferDiscarded());
 
     swapBuffers();
@@ -230,7 +233,7 @@ TEST_F(LayerRendererChromiumTest, FramebufferDiscardedAfterReadbackWhenNotVisibl
     EXPECT_EQ(1, m_mockClient.setFullRootLayerDamageCount());
 
     char pixels[4];
     EXPECT_EQ(1, m_mockClient.setFullRootLayerDamageCount());
 
     char pixels[4];
-    m_layerRendererChromium.beginDrawingFrame(m_mockClient.rootRenderPass());
+    m_layerRendererChromium.drawFrame(m_mockClient.renderPasses(), FloatRect());
     EXPECT_FALSE(m_layerRendererChromium.isFramebufferDiscarded());
 
     m_layerRendererChromium.getFramebufferPixels(pixels, IntRect(0, 0, 1, 1));
     EXPECT_FALSE(m_layerRendererChromium.isFramebufferDiscarded());
 
     m_layerRendererChromium.getFramebufferPixels(pixels, IntRect(0, 0, 1, 1));
@@ -406,8 +409,7 @@ TEST(LayerRendererChromiumTest2, opaqueBackground)
 
     EXPECT_TRUE(layerRendererChromium.initialize());
 
 
     EXPECT_TRUE(layerRendererChromium.initialize());
 
-    layerRendererChromium.beginDrawingFrame(mockClient.rootRenderPass());
-    layerRendererChromium.drawRenderPass(mockClient.rootRenderPass(), FloatRect());
+    layerRendererChromium.drawFrame(mockClient.renderPasses(), FloatRect());
     layerRendererChromium.finishDrawingFrame();
 
     // On DEBUG builds, render passes with opaque background clear to blue to
     layerRendererChromium.finishDrawingFrame();
 
     // On DEBUG builds, render passes with opaque background clear to blue to
@@ -429,8 +431,7 @@ TEST(LayerRendererChromiumTest2, transparentBackground)
 
     EXPECT_TRUE(layerRendererChromium.initialize());
 
 
     EXPECT_TRUE(layerRendererChromium.initialize());
 
-    layerRendererChromium.beginDrawingFrame(mockClient.rootRenderPass());
-    layerRendererChromium.drawRenderPass(mockClient.rootRenderPass(), FloatRect());
+    layerRendererChromium.drawFrame(mockClient.renderPasses(), FloatRect());
     layerRendererChromium.finishDrawingFrame();
 
     EXPECT_EQ(1, context->clearCount());
     layerRendererChromium.finishDrawingFrame();
 
     EXPECT_EQ(1, context->clearCount());