[chromium] Decouple layer visibility calculations from render surfaces / computed...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 2 Aug 2011 23:20:44 +0000 (23:20 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 2 Aug 2011 23:20:44 +0000 (23:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=58840

Patch by James Robinson <jamesr@chromium.org> on 2011-08-02
Reviewed by Kenneth Russell.

This decouples the layer visibility related calculations from the LayerChromium and CCLayerImpl trees.  This is
done by making LayerRendererChromium's "calculate the world" function (renamed
calculateDrawTransformsAndVisibility()) a templated, free function that can operate on either LayerChromium +
RenderSurfaceChromium pairs or on CCLayerImpl + CCRenderSurface pairs and invoking it twice, once before
painting and once before drawing.  Before painting, these calculations are used to determine which layers are
potentially visible and should be painted, which depends on the calculated opacity, render surface bounds, and
draw transforms.  Before drawing, these calculations are used to figure out everything needed to draw.

RenderSurfaceChromium is now used just for visibility calculations when painting.  CCRenderSurfaceChromium is
responsible for actually drawing the render surfaces.

This does mean that in the current implementation the second calculations are redundant, but in the future this
won't be the case since the pre-draw time calculations might be influenced by animations or gestures.  I've
added some traces to try to monitor if this math is a significant amount of the per-frame computation.  Note
that layer sorting only happens on the CCLayerImpl tree and the layer sort algorithm is the most expensive part
of the calculations currently.

This removes all of the weak back/forward pointers between LayerChromium and CCLayerImpls, the trees are now
truly decoupled.

Covered by compositing/ tests.

* WebCore.gypi:
* platform/graphics/chromium/CanvasLayerChromium.cpp:
(WebCore::CanvasLayerChromium::createCCLayerImpl):
* platform/graphics/chromium/LayerChromium.cpp:
(WebCore::LayerChromium::LayerChromium):
(WebCore::LayerChromium::~LayerChromium):
(WebCore::LayerChromium::createCCLayerImpl):
(WebCore::LayerChromium::createRenderSurface):
(WebCore::LayerChromium::descendantsDrawsContent):
* platform/graphics/chromium/LayerChromium.h:
(WebCore::LayerChromium::setUsesLayerScissor):
(WebCore::LayerChromium::usesLayerScissor):
(WebCore::LayerChromium::clearRenderSurface):
(WebCore::LayerChromium::renderSurface):
(WebCore::LayerChromium::drawOpacity):
(WebCore::LayerChromium::setDrawOpacity):
(WebCore::LayerChromium::scissorRect):
(WebCore::LayerChromium::setScissorRect):
(WebCore::LayerChromium::targetRenderSurface):
(WebCore::LayerChromium::setTargetRenderSurface):
(WebCore::LayerChromium::drawTransform):
(WebCore::LayerChromium::setDrawTransform):
(WebCore::LayerChromium::drawableContentRect):
(WebCore::LayerChromium::setDrawableContentRect):
* platform/graphics/chromium/LayerRendererChromium.cpp:
(WebCore::LayerRendererChromium::updateLayers):
(WebCore::LayerRendererChromium::drawLayers):
(WebCore::LayerRendererChromium::paintLayerContents):
(WebCore::LayerRendererChromium::drawLayersInternal):
(WebCore::LayerRendererChromium::updateCompositorResources):
(WebCore::LayerRendererChromium::setCompositeOffscreen):
(WebCore::LayerRendererChromium::getOffscreenLayerTexture):
(WebCore::LayerRendererChromium::useRenderSurface):
(WebCore::LayerRendererChromium::drawLayer):
(WebCore::LayerRendererChromium::initializeSharedObjects):
(WebCore::LayerRendererChromium::renderSurfaceProgram):
(WebCore::LayerRendererChromium::renderSurfaceMaskProgram):
(WebCore::LayerRendererChromium::dumpRenderSurfaces):
* platform/graphics/chromium/LayerRendererChromium.h:
* platform/graphics/chromium/PluginLayerChromium.cpp:
(WebCore::PluginLayerChromium::createCCLayerImpl):
* platform/graphics/chromium/RenderSurfaceChromium.cpp:
(WebCore::RenderSurfaceChromium::RenderSurfaceChromium):
(WebCore::RenderSurfaceChromium::~RenderSurfaceChromium):
* platform/graphics/chromium/RenderSurfaceChromium.h:
(WebCore::RenderSurfaceChromium::clearLayerList):
(WebCore::RenderSurfaceChromium::layerList):
(WebCore::RenderSurfaceChromium::setMaskLayer):
* platform/graphics/chromium/TiledLayerChromium.cpp:
(WebCore::TiledLayerChromium::createCCLayerImpl):
(WebCore::TiledLayerChromium::tilingTransform):
* platform/graphics/chromium/TreeSynchronizer.cpp:
(WebCore::TreeSynchronizer::synchronizeTreeRecursive):
* platform/graphics/chromium/VideoLayerChromium.cpp:
(WebCore::VideoLayerChromium::createCCLayerImpl):
* platform/graphics/chromium/cc/CCCanvasLayerImpl.cpp:
(WebCore::CCCanvasLayerImpl::CCCanvasLayerImpl):
* platform/graphics/chromium/cc/CCCanvasLayerImpl.h:
(WebCore::CCCanvasLayerImpl::create):
* platform/graphics/chromium/cc/CCLayerImpl.cpp:
(WebCore::CCLayerImpl::CCLayerImpl):
(WebCore::CCLayerImpl::~CCLayerImpl):
(WebCore::CCLayerImpl::createRenderSurface):
(WebCore::CCLayerImpl::bindContentsTexture):
* platform/graphics/chromium/cc/CCLayerImpl.h:
(WebCore::CCLayerImpl::create):
(WebCore::CCLayerImpl::renderSurface):
(WebCore::CCLayerImpl::targetRenderSurface):
(WebCore::CCLayerImpl::setTargetRenderSurface):
* platform/graphics/chromium/cc/CCLayerSorter.cpp:
(WebCore::CCLayerSorter::createGraphNodes):
* platform/graphics/chromium/cc/CCPluginLayerImpl.cpp:
(WebCore::CCPluginLayerImpl::CCPluginLayerImpl):
* platform/graphics/chromium/cc/CCPluginLayerImpl.h:
(WebCore::CCPluginLayerImpl::create):
* platform/graphics/chromium/cc/CCRenderSurface.cpp: Copied from Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.cpp.
(WebCore::CCRenderSurface::CCRenderSurface):
(WebCore::CCRenderSurface::~CCRenderSurface):
(WebCore::CCRenderSurface::cleanupResources):
(WebCore::CCRenderSurface::layerRenderer):
(WebCore::CCRenderSurface::drawableContentRect):
(WebCore::CCRenderSurface::prepareContentsTexture):
(WebCore::CCRenderSurface::releaseContentsTexture):
(WebCore::CCRenderSurface::drawSurface):
(WebCore::CCRenderSurface::draw):
(WebCore::CCRenderSurface::name):
(WebCore::writeIndent):
(WebCore::CCRenderSurface::dumpSurface):
(WebCore::CCRenderSurface::owningLayerId):
* platform/graphics/chromium/cc/CCRenderSurface.h: Copied from Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h.
(WebCore::CCRenderSurface::contentRectCenter):
(WebCore::CCRenderSurface::drawOpacity):
(WebCore::CCRenderSurface::setDrawOpacity):
(WebCore::CCRenderSurface::setDrawTransform):
(WebCore::CCRenderSurface::drawTransform):
(WebCore::CCRenderSurface::setReplicaDrawTransform):
(WebCore::CCRenderSurface::replicaDrawTransform):
(WebCore::CCRenderSurface::setOriginTransform):
(WebCore::CCRenderSurface::originTransform):
(WebCore::CCRenderSurface::setScissorRect):
(WebCore::CCRenderSurface::scissorRect):
(WebCore::CCRenderSurface::setContentRect):
(WebCore::CCRenderSurface::contentRect):
(WebCore::CCRenderSurface::setSkipsDraw):
(WebCore::CCRenderSurface::skipsDraw):
(WebCore::CCRenderSurface::clearLayerList):
(WebCore::CCRenderSurface::layerList):
(WebCore::CCRenderSurface::setMaskLayer):
(WebCore::CCRenderSurface::contentsTexture):
* platform/graphics/chromium/cc/CCTiledLayerImpl.cpp:
(WebCore::CCTiledLayerImpl::CCTiledLayerImpl):
* platform/graphics/chromium/cc/CCTiledLayerImpl.h:
(WebCore::CCTiledLayerImpl::create):
* platform/graphics/chromium/cc/CCVideoLayerImpl.cpp:
(WebCore::CCVideoLayerImpl::CCVideoLayerImpl):
* platform/graphics/chromium/cc/CCVideoLayerImpl.h:
(WebCore::CCVideoLayerImpl::create):

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

27 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.gypi
Source/WebCore/platform/graphics/chromium/CanvasLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/LayerChromium.cpp
Source/WebCore/platform/graphics/chromium/LayerChromium.h
Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h
Source/WebCore/platform/graphics/chromium/PluginLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.cpp
Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h
Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/TreeSynchronizer.cpp
Source/WebCore/platform/graphics/chromium/VideoLayerChromium.cpp
Source/WebCore/platform/graphics/chromium/cc/CCCanvasLayerImpl.cpp
Source/WebCore/platform/graphics/chromium/cc/CCCanvasLayerImpl.h
Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.cpp
Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.h
Source/WebCore/platform/graphics/chromium/cc/CCLayerSorter.cpp
Source/WebCore/platform/graphics/chromium/cc/CCPluginLayerImpl.cpp
Source/WebCore/platform/graphics/chromium/cc/CCPluginLayerImpl.h
Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.h [new file with mode: 0644]
Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.cpp
Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.h
Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.cpp
Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.h
Source/WebKit/chromium/tests/TreeSynchronizerTest.cpp

index 548ec42..a28bbfc 100644 (file)
@@ -1,3 +1,150 @@
+2011-08-02  James Robinson  <jamesr@chromium.org>
+
+        [chromium] Decouple layer visibility calculations from render surfaces / computed draw transforms
+        https://bugs.webkit.org/show_bug.cgi?id=58840
+
+        Reviewed by Kenneth Russell.
+
+        This decouples the layer visibility related calculations from the LayerChromium and CCLayerImpl trees.  This is
+        done by making LayerRendererChromium's "calculate the world" function (renamed
+        calculateDrawTransformsAndVisibility()) a templated, free function that can operate on either LayerChromium +
+        RenderSurfaceChromium pairs or on CCLayerImpl + CCRenderSurface pairs and invoking it twice, once before
+        painting and once before drawing.  Before painting, these calculations are used to determine which layers are
+        potentially visible and should be painted, which depends on the calculated opacity, render surface bounds, and
+        draw transforms.  Before drawing, these calculations are used to figure out everything needed to draw.
+
+        RenderSurfaceChromium is now used just for visibility calculations when painting.  CCRenderSurfaceChromium is
+        responsible for actually drawing the render surfaces.
+
+        This does mean that in the current implementation the second calculations are redundant, but in the future this
+        won't be the case since the pre-draw time calculations might be influenced by animations or gestures.  I've
+        added some traces to try to monitor if this math is a significant amount of the per-frame computation.  Note
+        that layer sorting only happens on the CCLayerImpl tree and the layer sort algorithm is the most expensive part
+        of the calculations currently.
+
+        This removes all of the weak back/forward pointers between LayerChromium and CCLayerImpls, the trees are now
+        truly decoupled.
+
+        Covered by compositing/ tests.
+
+        * WebCore.gypi:
+        * platform/graphics/chromium/CanvasLayerChromium.cpp:
+        (WebCore::CanvasLayerChromium::createCCLayerImpl):
+        * platform/graphics/chromium/LayerChromium.cpp:
+        (WebCore::LayerChromium::LayerChromium):
+        (WebCore::LayerChromium::~LayerChromium):
+        (WebCore::LayerChromium::createCCLayerImpl):
+        (WebCore::LayerChromium::createRenderSurface):
+        (WebCore::LayerChromium::descendantsDrawsContent):
+        * platform/graphics/chromium/LayerChromium.h:
+        (WebCore::LayerChromium::setUsesLayerScissor):
+        (WebCore::LayerChromium::usesLayerScissor):
+        (WebCore::LayerChromium::clearRenderSurface):
+        (WebCore::LayerChromium::renderSurface):
+        (WebCore::LayerChromium::drawOpacity):
+        (WebCore::LayerChromium::setDrawOpacity):
+        (WebCore::LayerChromium::scissorRect):
+        (WebCore::LayerChromium::setScissorRect):
+        (WebCore::LayerChromium::targetRenderSurface):
+        (WebCore::LayerChromium::setTargetRenderSurface):
+        (WebCore::LayerChromium::drawTransform):
+        (WebCore::LayerChromium::setDrawTransform):
+        (WebCore::LayerChromium::drawableContentRect):
+        (WebCore::LayerChromium::setDrawableContentRect):
+        * platform/graphics/chromium/LayerRendererChromium.cpp:
+        (WebCore::LayerRendererChromium::updateLayers):
+        (WebCore::LayerRendererChromium::drawLayers):
+        (WebCore::LayerRendererChromium::paintLayerContents):
+        (WebCore::LayerRendererChromium::drawLayersInternal):
+        (WebCore::LayerRendererChromium::updateCompositorResources):
+        (WebCore::LayerRendererChromium::setCompositeOffscreen):
+        (WebCore::LayerRendererChromium::getOffscreenLayerTexture):
+        (WebCore::LayerRendererChromium::useRenderSurface):
+        (WebCore::LayerRendererChromium::drawLayer):
+        (WebCore::LayerRendererChromium::initializeSharedObjects):
+        (WebCore::LayerRendererChromium::renderSurfaceProgram):
+        (WebCore::LayerRendererChromium::renderSurfaceMaskProgram):
+        (WebCore::LayerRendererChromium::dumpRenderSurfaces):
+        * platform/graphics/chromium/LayerRendererChromium.h:
+        * platform/graphics/chromium/PluginLayerChromium.cpp:
+        (WebCore::PluginLayerChromium::createCCLayerImpl):
+        * platform/graphics/chromium/RenderSurfaceChromium.cpp:
+        (WebCore::RenderSurfaceChromium::RenderSurfaceChromium):
+        (WebCore::RenderSurfaceChromium::~RenderSurfaceChromium):
+        * platform/graphics/chromium/RenderSurfaceChromium.h:
+        (WebCore::RenderSurfaceChromium::clearLayerList):
+        (WebCore::RenderSurfaceChromium::layerList):
+        (WebCore::RenderSurfaceChromium::setMaskLayer):
+        * platform/graphics/chromium/TiledLayerChromium.cpp:
+        (WebCore::TiledLayerChromium::createCCLayerImpl):
+        (WebCore::TiledLayerChromium::tilingTransform):
+        * platform/graphics/chromium/TreeSynchronizer.cpp:
+        (WebCore::TreeSynchronizer::synchronizeTreeRecursive):
+        * platform/graphics/chromium/VideoLayerChromium.cpp:
+        (WebCore::VideoLayerChromium::createCCLayerImpl):
+        * platform/graphics/chromium/cc/CCCanvasLayerImpl.cpp:
+        (WebCore::CCCanvasLayerImpl::CCCanvasLayerImpl):
+        * platform/graphics/chromium/cc/CCCanvasLayerImpl.h:
+        (WebCore::CCCanvasLayerImpl::create):
+        * platform/graphics/chromium/cc/CCLayerImpl.cpp:
+        (WebCore::CCLayerImpl::CCLayerImpl):
+        (WebCore::CCLayerImpl::~CCLayerImpl):
+        (WebCore::CCLayerImpl::createRenderSurface):
+        (WebCore::CCLayerImpl::bindContentsTexture):
+        * platform/graphics/chromium/cc/CCLayerImpl.h:
+        (WebCore::CCLayerImpl::create):
+        (WebCore::CCLayerImpl::renderSurface):
+        (WebCore::CCLayerImpl::targetRenderSurface):
+        (WebCore::CCLayerImpl::setTargetRenderSurface):
+        * platform/graphics/chromium/cc/CCLayerSorter.cpp:
+        (WebCore::CCLayerSorter::createGraphNodes):
+        * platform/graphics/chromium/cc/CCPluginLayerImpl.cpp:
+        (WebCore::CCPluginLayerImpl::CCPluginLayerImpl):
+        * platform/graphics/chromium/cc/CCPluginLayerImpl.h:
+        (WebCore::CCPluginLayerImpl::create):
+        * platform/graphics/chromium/cc/CCRenderSurface.cpp: Copied from Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.cpp.
+        (WebCore::CCRenderSurface::CCRenderSurface):
+        (WebCore::CCRenderSurface::~CCRenderSurface):
+        (WebCore::CCRenderSurface::cleanupResources):
+        (WebCore::CCRenderSurface::layerRenderer):
+        (WebCore::CCRenderSurface::drawableContentRect):
+        (WebCore::CCRenderSurface::prepareContentsTexture):
+        (WebCore::CCRenderSurface::releaseContentsTexture):
+        (WebCore::CCRenderSurface::drawSurface):
+        (WebCore::CCRenderSurface::draw):
+        (WebCore::CCRenderSurface::name):
+        (WebCore::writeIndent):
+        (WebCore::CCRenderSurface::dumpSurface):
+        (WebCore::CCRenderSurface::owningLayerId):
+        * platform/graphics/chromium/cc/CCRenderSurface.h: Copied from Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h.
+        (WebCore::CCRenderSurface::contentRectCenter):
+        (WebCore::CCRenderSurface::drawOpacity):
+        (WebCore::CCRenderSurface::setDrawOpacity):
+        (WebCore::CCRenderSurface::setDrawTransform):
+        (WebCore::CCRenderSurface::drawTransform):
+        (WebCore::CCRenderSurface::setReplicaDrawTransform):
+        (WebCore::CCRenderSurface::replicaDrawTransform):
+        (WebCore::CCRenderSurface::setOriginTransform):
+        (WebCore::CCRenderSurface::originTransform):
+        (WebCore::CCRenderSurface::setScissorRect):
+        (WebCore::CCRenderSurface::scissorRect):
+        (WebCore::CCRenderSurface::setContentRect):
+        (WebCore::CCRenderSurface::contentRect):
+        (WebCore::CCRenderSurface::setSkipsDraw):
+        (WebCore::CCRenderSurface::skipsDraw):
+        (WebCore::CCRenderSurface::clearLayerList):
+        (WebCore::CCRenderSurface::layerList):
+        (WebCore::CCRenderSurface::setMaskLayer):
+        (WebCore::CCRenderSurface::contentsTexture):
+        * platform/graphics/chromium/cc/CCTiledLayerImpl.cpp:
+        (WebCore::CCTiledLayerImpl::CCTiledLayerImpl):
+        * platform/graphics/chromium/cc/CCTiledLayerImpl.h:
+        (WebCore::CCTiledLayerImpl::create):
+        * platform/graphics/chromium/cc/CCVideoLayerImpl.cpp:
+        (WebCore::CCVideoLayerImpl::CCVideoLayerImpl):
+        * platform/graphics/chromium/cc/CCVideoLayerImpl.h:
+        (WebCore::CCVideoLayerImpl::create):
+
 2011-08-02  Luke Macpherson   <macpherson@chromium.org>
 
         Implement CSSPropertyWebkitTextCombine, CSSPropertyWebkitTextEmphasisPosition and CSSPropertyWebkitTextEmphasisStyle in CSSStyleApplyProperty.
index 55c8c12..b140ad8 100644 (file)
             'platform/graphics/chromium/cc/CCMainThreadTask.h',
             'platform/graphics/chromium/cc/CCPluginLayerImpl.cpp',
             'platform/graphics/chromium/cc/CCPluginLayerImpl.h',
+            'platform/graphics/chromium/cc/CCRenderSurface.cpp',
+            'platform/graphics/chromium/cc/CCRenderSurface.h',
             'platform/graphics/chromium/cc/CCThread.cpp',
             'platform/graphics/chromium/cc/CCThread.h',
             'platform/graphics/chromium/cc/CCThreadTask.h',
index 0a1d32e..ac4b9f2 100644 (file)
@@ -55,7 +55,7 @@ CanvasLayerChromium::~CanvasLayerChromium()
 
 PassRefPtr<CCLayerImpl> CanvasLayerChromium::createCCLayerImpl()
 {
-    return CCCanvasLayerImpl::create(this, m_layerId);
+    return CCCanvasLayerImpl::create(m_layerId);
 }
 
 void CanvasLayerChromium::pushPropertiesTo(CCLayerImpl* layer)
index 1d873dc..ba713eb 100644 (file)
@@ -61,9 +61,9 @@ LayerChromium::LayerChromium(GraphicsLayerChromium* owner)
     , m_contentsDirty(false)
     , m_layerId(s_nextLayerId++)
     , m_parent(0)
-    , m_ccLayerImpl(0)
     , m_anchorPoint(0.5, 0.5)
     , m_backgroundColor(0, 0, 0, 0)
+    , m_debugBorderWidth(0)
     , m_opacity(1.0)
     , m_zPosition(0.0)
     , m_anchorPointZ(0)
@@ -74,7 +74,10 @@ LayerChromium::LayerChromium(GraphicsLayerChromium* owner)
     , m_geometryFlipped(false)
     , m_needsDisplayOnBoundsChange(false)
     , m_doubleSided(true)
+    , m_usesLayerScissor(false)
     , m_replicaLayer(0)
+    , m_drawOpacity(0)
+    , m_targetRenderSurface(0)
 {
     ASSERT(!LayerRendererChromium::s_inPaintLayerContents);
 }
@@ -86,9 +89,6 @@ LayerChromium::~LayerChromium()
     // way for us to be destroyed while we still have a parent.
     ASSERT(!parent());
 
-    if (m_ccLayerImpl)
-        m_ccLayerImpl->clearOwner();
-
     // Remove the parent reference from all children.
     removeAllChildren();
 }
@@ -381,12 +381,7 @@ void LayerChromium::dumpLayerProperties(TextStream& ts, int indent) const
 
 PassRefPtr<CCLayerImpl> LayerChromium::createCCLayerImpl()
 {
-    return CCLayerImpl::create(this, m_layerId);
-}
-
-CCLayerImpl* LayerChromium::ccLayerImpl() const
-{
-    return m_ccLayerImpl;
+    return CCLayerImpl::create(m_layerId);
 }
 
 void LayerChromium::setBorderColor(const Color& color)
@@ -406,5 +401,20 @@ LayerRendererChromium* LayerChromium::layerRenderer() const
     return m_layerRenderer.get();
 }
 
+void LayerChromium::createRenderSurface()
+{
+    ASSERT(!m_renderSurface);
+    m_renderSurface = adoptPtr(new RenderSurfaceChromium(this));
+}
+
+bool LayerChromium::descendantDrawsContent()
+{
+    for (size_t i = 0; i < m_children.size(); ++i) {
+        if (m_children[i]->drawsContent() || m_children[i]->descendantDrawsContent())
+            return true;
+    }
+    return false;
+}
+
 }
 #endif // USE(ACCELERATED_COMPOSITING)
index 3ba7b9f..4e401cc 100644 (file)
@@ -104,7 +104,6 @@ public:
     const String& name() const { return m_name; }
 
     void setMaskLayer(LayerChromium* maskLayer) { m_maskLayer = maskLayer; }
-    CCLayerImpl* maskDrawLayer() const { return m_maskLayer ? m_maskLayer->ccLayerImpl() : 0; }
     LayerChromium* maskLayer() const { return m_maskLayer.get(); }
 
     void setNeedsDisplay(const FloatRect& dirtyRect);
@@ -145,6 +144,9 @@ public:
 
     bool preserves3D() { return m_owner && m_owner->preserves3D(); }
 
+    void setUsesLayerScissor(bool usesLayerScissor) { m_usesLayerScissor = usesLayerScissor; }
+    bool usesLayerScissor() const { return m_usesLayerScissor; }
+
     // Derived types must override this method if they need to react to a change
     // in the LayerRendererChromium.
     virtual void setLayerRenderer(LayerRendererChromium*);
@@ -170,9 +172,6 @@ public:
 
     void setBorderWidth(float);
 
-    // Everything from here down in the public section will move to CCLayerImpl.
-    CCLayerImpl* ccLayerImpl() const;
-
     static void drawTexturedQuad(GraphicsContext3D*, const TransformationMatrix& projectionMatrix, const TransformationMatrix& layerMatrix,
                                  float width, float height, float opacity,
                                  int matrixLocation, int alphaLocation);
@@ -187,6 +186,24 @@ public:
 
     int id() const { return m_layerId; }
 
+    void clearRenderSurface() { m_renderSurface.clear(); }
+    RenderSurfaceChromium* renderSurface() const { return m_renderSurface.get(); }
+    void createRenderSurface();
+
+    float drawOpacity() const { return m_drawOpacity; }
+    void setDrawOpacity(float opacity) { m_drawOpacity = opacity; }
+    const IntRect& scissorRect() const { return m_scissorRect; }
+    void setScissorRect(const IntRect& rect) { m_scissorRect = rect; }
+    RenderSurfaceChromium* targetRenderSurface() const { return m_targetRenderSurface; }
+    void setTargetRenderSurface(RenderSurfaceChromium* surface) { m_targetRenderSurface = surface; }
+    const TransformationMatrix& drawTransform() const { return m_drawTransform; }
+    void setDrawTransform(const TransformationMatrix& matrix) { m_drawTransform = matrix; }
+    const IntRect& drawableContentRect() const { return m_drawableContentRect; }
+    void setDrawableContentRect(const IntRect& rect) { m_drawableContentRect = rect; }
+
+    // Returns true if any of the layer's descendants has content to draw.
+    bool descendantDrawsContent();
+
 protected:
     GraphicsLayerChromium* m_owner;
     explicit LayerChromium(GraphicsLayerChromium* owner);
@@ -210,18 +227,10 @@ protected:
 
     RefPtr<LayerChromium> m_maskLayer;
 
-    // All layer shaders share the same attribute locations for the vertex positions
-    // and texture coordinates. This allows switching shaders without rebinding attribute
-    // arrays.
-    static const unsigned s_positionAttribLocation;
-    static const unsigned s_texCoordAttribLocation;
-
     friend class TreeSynchronizer;
     friend class CCLayerImpl;
     // Constructs a CCLayerImpl of the correct runtime type for this LayerChromium type.
     virtual PassRefPtr<CCLayerImpl> createCCLayerImpl();
-    // FIXME: Remove when https://bugs.webkit.org/show_bug.cgi?id=58830 is fixed.
-    void setCCLayerImpl(CCLayerImpl* impl) { m_ccLayerImpl = impl; }
     int m_layerId;
 
 private:
@@ -245,10 +254,6 @@ private:
 
     RefPtr<LayerRendererChromium> m_layerRenderer;
 
-    // Temporary forward weak pointer to the CCLayerImpl associated with this layer.
-    // FIXME: Remove when https://bugs.webkit.org/show_bug.cgi?id=58830 is fixed.
-    CCLayerImpl* m_ccLayerImpl;
-
     // Layer properties.
     IntSize m_bounds;
     IntRect m_visibleLayerRect;
@@ -267,6 +272,7 @@ private:
     bool m_geometryFlipped;
     bool m_needsDisplayOnBoundsChange;
     bool m_doubleSided;
+    bool m_usesLayerScissor;
 
     TransformationMatrix m_transform;
     TransformationMatrix m_sublayerTransform;
@@ -276,6 +282,14 @@ private:
     // Replica layer used for reflections.
     RefPtr<LayerChromium> m_replicaLayer;
 
+    // Transient properties.
+    OwnPtr<RenderSurfaceChromium> m_renderSurface;
+    float m_drawOpacity;
+    IntRect m_scissorRect;
+    RenderSurfaceChromium* m_targetRenderSurface;
+    TransformationMatrix m_drawTransform;
+    IntRect m_drawableContentRect;
+
     String m_name;
 };
 
index 60ec939..60d4a07 100644 (file)
@@ -44,6 +44,7 @@
 #include "LayerTexture.h"
 #include "LayerTextureUpdaterCanvas.h"
 #include "NotImplemented.h"
+#include "RenderSurfaceChromium.h"
 #include "TextStream.h"
 #include "TextureManager.h"
 #include "TreeSynchronizer.h"
@@ -63,6 +64,8 @@
 #include <wtf/CurrentTime.h>
 #include <wtf/MainThread.h>
 
+using namespace std;
+
 namespace WebCore {
 
 // FIXME: Make this limit adjustable and give it a useful value.
@@ -78,7 +81,9 @@ static size_t textureMemoryLowLimitBytes = 3 * 1024 * 1024;
 bool LayerRendererChromium::s_inPaintLayerContents = false;
 #endif
 
-static IntRect calculateVisibleRect(const IntRect& targetSurfaceRect, const IntRect& layerBoundRect, const TransformationMatrix& transform)
+namespace {
+
+IntRect calculateVisibleRect(const IntRect& targetSurfaceRect, const IntRect& layerBoundRect, const TransformationMatrix& transform)
 {
     // Is this layer fully contained within the target surface?
     IntRect layerInSurfaceSpace = transform.mapRect(layerBoundRect);
@@ -102,7 +107,7 @@ static IntRect calculateVisibleRect(const IntRect& targetSurfaceRect, const IntR
 }
 
 // Returns true if the matrix has no rotation, skew or perspective components to it.
-static bool isScaleOrTranslation(const TransformationMatrix& m)
+bool isScaleOrTranslation(const TransformationMatrix& m)
 {
     return !m.m12() && !m.m13() && !m.m14()
            && !m.m21() && !m.m23() && !m.m24()
@@ -111,10 +116,23 @@ static bool isScaleOrTranslation(const TransformationMatrix& m)
 
 }
 
+void sortLayers(Vector<RefPtr<LayerChromium> >::iterator, Vector<RefPtr<LayerChromium> >::iterator, void*)
+{
+    // Currently we don't use z-order to decide what to paint, so there's no need to actually sort LayerChromiums.
+}
+
+void sortLayers(Vector<RefPtr<CCLayerImpl> >::iterator first, Vector<RefPtr<CCLayerImpl> >::iterator end, CCLayerSorter* layerSorter)
+{
+    TRACE_EVENT("LayerRendererChromium::sortLayers", 0, 0);
+    layerSorter->sort(first, end);
+}
+
 // Recursively walks the layer tree starting at the given node and computes all the
 // necessary transformations, scissor rectangles, render surfaces, etc.
-void LayerRendererChromium::updatePropertiesAndRenderSurfaces(CCLayerImpl* layer, const TransformationMatrix& parentMatrix, LayerList& renderSurfaceLayerList, LayerList& layerList)
+template<typename LayerType, typename RenderSurfaceType, typename LayerSorter>
+void calculateDrawTransformsAndVisibility(LayerType* layer, LayerType* rootLayer, const TransformationMatrix& parentMatrix, Vector<RefPtr<LayerType> >& renderSurfaceLayerList, Vector<RefPtr<LayerType> >& layerList, LayerSorter* layerSorter, int maxTextureSize)
 {
+    typedef Vector<RefPtr<LayerType> > LayerList;
     // Compute the new matrix transformation that will be applied to this layer and
     // all its children. It's important to remember that the layer's position
     // is the position of the layer's anchor point. Also, the coordinate system used
@@ -172,11 +190,11 @@ void LayerRendererChromium::updatePropertiesAndRenderSurfaces(CCLayerImpl* layer
     bool useSurfaceForOpacity = layer->opacity() != 1 && !layer->preserves3D();
     bool useSurfaceForMasking = layer->maskLayer();
     bool useSurfaceForReflection = layer->replicaLayer();
-    bool useSurfaceForFlatDescendants = layer->parent() && layer->parent()->preserves3D() && !layer->preserves3D() && layer->descendantsDrawsContent();
-    if (useSurfaceForMasking || useSurfaceForReflection || useSurfaceForFlatDescendants || ((useSurfaceForClipping || useSurfaceForOpacity) && layer->descendantsDrawsContent())) {
-        RenderSurfaceChromium* renderSurface = layer->renderSurface();
-        if (!renderSurface)
-            renderSurface = layer->createRenderSurface();
+    bool useSurfaceForFlatDescendants = layer->parent() && layer->parent()->preserves3D() && !layer->preserves3D() && layer->descendantDrawsContent();
+    if (useSurfaceForMasking || useSurfaceForReflection || useSurfaceForFlatDescendants || ((useSurfaceForClipping || useSurfaceForOpacity) && layer->descendantDrawsContent())) {
+        if (!layer->renderSurface())
+            layer->createRenderSurface();
+        RenderSurfaceType* renderSurface = layer->renderSurface();
 
         // The origin of the new surface is the upper left corner of the layer.
         TransformationMatrix drawTransform;
@@ -232,7 +250,7 @@ void LayerRendererChromium::updatePropertiesAndRenderSurfaces(CCLayerImpl* layer
             layer->setTargetRenderSurface(layer->parent()->targetRenderSurface());
         }
 
-        if (layer != m_rootCCLayerImpl.get())
+        if (layer != rootLayer)
             layer->clearRenderSurface();
 
         if (layer->masksToBounds()) {
@@ -288,11 +306,11 @@ void LayerRendererChromium::updatePropertiesAndRenderSurfaces(CCLayerImpl* layer
     unsigned thisLayerIndex = descendants.size() - 1;
 
     for (size_t i = 0; i < layer->children().size(); ++i) {
-        CCLayerImpl* child = layer->children()[i].get();
-        updatePropertiesAndRenderSurfaces(child, sublayerMatrix, renderSurfaceLayerList, descendants);
+        LayerType* child = layer->children()[i].get();
+        calculateDrawTransformsAndVisibility<LayerType, RenderSurfaceType, LayerSorter>(child, rootLayer, sublayerMatrix, renderSurfaceLayerList, descendants, layerSorter, maxTextureSize);
 
         if (child->renderSurface()) {
-            RenderSurfaceChromium* childRenderSurface = child->renderSurface();
+            RenderSurfaceType* childRenderSurface = child->renderSurface();
             IntRect drawableContentRect = layer->drawableContentRect();
             drawableContentRect.unite(enclosingIntRect(childRenderSurface->drawableContentRect()));
             layer->setDrawableContentRect(drawableContentRect);
@@ -310,10 +328,10 @@ void LayerRendererChromium::updatePropertiesAndRenderSurfaces(CCLayerImpl* layer
         layer->setDrawableContentRect(drawableContentRect);
     }
 
-    if (layer->renderSurface() && layer != m_rootCCLayerImpl.get()) {
-        RenderSurfaceChromium* renderSurface = layer->renderSurface();
-        IntRect renderSurfaceContentRect = layer->drawableContentRect();
-        FloatPoint surfaceCenter = FloatRect(renderSurfaceContentRect).center();
+    if (layer->renderSurface() && layer != rootLayer) {
+        RenderSurfaceType* renderSurface = layer->renderSurface();
+        IntRect clippedContentRect = layer->drawableContentRect();
+        FloatPoint surfaceCenter = FloatRect(clippedContentRect).center();
 
         // Restrict the RenderSurface size to the portion that's visible.
         FloatSize centerOffsetDueToClipping;
@@ -321,22 +339,23 @@ void LayerRendererChromium::updatePropertiesAndRenderSurfaces(CCLayerImpl* layer
         // Don't clip if the layer is reflected as the reflection shouldn't be
         // clipped.
         if (!layer->replicaLayer()) {
-            if (!renderSurface->scissorRect().isEmpty() && !renderSurfaceContentRect.isEmpty()) {
-                IntRect surfaceScissorRect = calculateVisibleRect(renderSurface->scissorRect(), renderSurfaceContentRect, renderSurface->originTransform());
-                renderSurfaceContentRect.intersect(surfaceScissorRect);
+            if (!renderSurface->scissorRect().isEmpty() && !clippedContentRect.isEmpty()) {
+                IntRect surfaceScissorRect = calculateVisibleRect(renderSurface->scissorRect(), clippedContentRect, renderSurface->originTransform());
+                clippedContentRect.intersect(surfaceScissorRect);
             }
-            FloatPoint clippedSurfaceCenter = FloatRect(renderSurfaceContentRect).center();
+            FloatPoint clippedSurfaceCenter = FloatRect(clippedContentRect).center();
             centerOffsetDueToClipping = clippedSurfaceCenter - surfaceCenter;
         }
 
         // The RenderSurface backing texture cannot exceed the maximum supported
         // texture size.
-        renderSurfaceContentRect.setWidth(std::min(renderSurfaceContentRect.width(), m_maxTextureSize));
-        renderSurfaceContentRect.setHeight(std::min(renderSurfaceContentRect.height(), m_maxTextureSize));
+        clippedContentRect.setWidth(min(clippedContentRect.width(), maxTextureSize));
+        clippedContentRect.setHeight(min(clippedContentRect.height(), maxTextureSize));
 
-        if (renderSurfaceContentRect.isEmpty())
+        if (clippedContentRect.isEmpty())
             renderSurface->clearLayerList();
-        renderSurface->setContentRect(renderSurfaceContentRect);
+
+        renderSurface->setContentRect(clippedContentRect);
 
         // Since the layer starts a new render surface we need to adjust its
         // scissor rect to be expressed in the new surface's coordinate system.
@@ -362,7 +381,9 @@ void LayerRendererChromium::updatePropertiesAndRenderSurfaces(CCLayerImpl* layer
     // drawn from back to front. If the preserves-3d property is also set on the parent then
     // skip the sorting as the parent will sort all the descendants anyway.
     if (layer->preserves3D() && (!layer->parent() || !layer->parent()->preserves3D()))
-        m_layerSorter.sort(&descendants.at(thisLayerIndex), descendants.end());
+        sortLayers(&descendants.at(thisLayerIndex), descendants.end(), layerSorter);
+}
+
 }
 
 static TransformationMatrix orthoMatrix(float left, float right, float bottom, float top)
@@ -549,19 +570,12 @@ void LayerRendererChromium::updateLayers()
     if (!m_rootLayer)
         return;
 
-    {
-        TRACE_EVENT("LayerRendererChromium::synchronizeTrees", this, 0);
-        m_rootCCLayerImpl = TreeSynchronizer::synchronizeTrees(m_rootLayer.get(), m_rootCCLayerImpl.get());
-    }
-
-    m_computedRenderSurfaceLayerList = adoptPtr(new LayerList());
-    updateLayers(*m_computedRenderSurfaceLayerList);
+    updateLayers(m_rootLayer.get());
 }
 
 void LayerRendererChromium::drawLayers()
 {
     ASSERT(m_hardwareCompositing);
-    ASSERT(m_computedRenderSurfaceLayerList);
     // Before drawLayers:
     if (hardwareCompositing()) {
         // FIXME: The multithreaded compositor case will not work as long as
@@ -575,8 +589,14 @@ void LayerRendererChromium::drawLayers()
         }
     }
 
+    {
+        TRACE_EVENT("LayerRendererChromium::synchronizeTrees", this, 0);
+        m_rootCCLayerImpl = TreeSynchronizer::synchronizeTrees(m_rootLayer.get(), m_rootCCLayerImpl.get());
+    }
+
+
     m_renderSurfaceTextureManager->setMemoryLimitBytes(textureMemoryHighLimitBytes - m_contentsTextureManager->currentMemoryUseBytes());
-    drawLayers(*m_computedRenderSurfaceLayerList);
+    drawLayersInternal();
 
     m_contentsTextureManager->unprotectAllTextures();
     m_contentsTextureManager->reduceMemoryToLimit(textureMemoryReclaimLimitBytes);
@@ -590,33 +610,31 @@ void LayerRendererChromium::drawLayers()
         copyOffscreenTextureToDisplay();
 }
 
-void LayerRendererChromium::updateLayers(LayerList& renderSurfaceLayerList)
+void LayerRendererChromium::updateLayers(LayerChromium* rootLayer)
 {
     TRACE_EVENT("LayerRendererChromium::updateLayers", this, 0);
-    CCLayerImpl* rootDrawLayer = m_rootLayer->ccLayerImpl();
 
-    if (!rootDrawLayer->renderSurface())
-        rootDrawLayer->createRenderSurface();
-    ASSERT(rootDrawLayer->renderSurface());
-
-    rootDrawLayer->renderSurface()->setContentRect(IntRect(IntPoint(0, 0), m_viewportVisibleRect.size()));
+    if (!rootLayer->renderSurface())
+        rootLayer->createRenderSurface();
+    rootLayer->renderSurface()->setContentRect(IntRect(IntPoint(0, 0), m_viewportVisibleRect.size()));
 
     IntRect rootScissorRect(m_viewportVisibleRect);
     // The scissorRect should not include the scroll offset.
     rootScissorRect.move(-m_viewportScrollPosition.x(), -m_viewportScrollPosition.y());
-    rootDrawLayer->setScissorRect(rootScissorRect);
+    rootLayer->setScissorRect(rootScissorRect);
 
-    m_defaultRenderSurface = rootDrawLayer->renderSurface();
+    LayerList renderSurfaceLayerList;
+    renderSurfaceLayerList.append(rootLayer);
 
-    renderSurfaceLayerList.append(rootDrawLayer);
+    RenderSurfaceChromium* rootRenderSurface = rootLayer->renderSurface();
+    rootRenderSurface->clearLayerList();
 
     TransformationMatrix identityMatrix;
-    m_defaultRenderSurface->clearLayerList();
-    // Unfortunately, updatePropertiesAndRenderSurfaces() currently both updates the layers and updates the draw state
-    // (transforms, etc). It'd be nicer if operations on the presentation layers happened later, but the draw
-    // transforms are needed by large layers to determine visibility. Tiling will fix this by eliminating the
-    // concept of a large content layer.
-    updatePropertiesAndRenderSurfaces(rootDrawLayer, identityMatrix, renderSurfaceLayerList, m_defaultRenderSurface->layerList());
+
+    {
+        TRACE_EVENT("LayerRendererChromium::updateLayers::calcDrawEtc", this, 0);
+        calculateDrawTransformsAndVisibility<LayerChromium, RenderSurfaceChromium, void*>(rootLayer, rootLayer, identityMatrix, renderSurfaceLayerList, rootRenderSurface->layerList(), 0, m_maxTextureSize);
+    }
 
 #ifndef NDEBUG
     s_inPaintLayerContents = true;
@@ -661,7 +679,7 @@ static void paintContentsIfDirty(LayerChromium* layer, const IntRect& visibleLay
 void LayerRendererChromium::paintLayerContents(const LayerList& renderSurfaceLayerList)
 {
     for (int surfaceIndex = renderSurfaceLayerList.size() - 1; surfaceIndex >= 0 ; --surfaceIndex) {
-        CCLayerImpl* renderSurfaceLayer = renderSurfaceLayerList[surfaceIndex].get();
+        LayerChromium* renderSurfaceLayer = renderSurfaceLayerList[surfaceIndex].get();
         RenderSurfaceChromium* renderSurface = renderSurfaceLayer->renderSurface();
         ASSERT(renderSurface);
 
@@ -678,18 +696,16 @@ void LayerRendererChromium::paintLayerContents(const LayerList& renderSurfaceLay
         if (!renderSurface->drawOpacity())
             continue;
 
-        LayerList& layerList = renderSurface->layerList();
+        const LayerList& layerList = renderSurface->layerList();
         ASSERT(layerList.size());
         for (unsigned layerIndex = 0; layerIndex < layerList.size(); ++layerIndex) {
-            CCLayerImpl* ccLayerImpl = layerList[layerIndex].get();
+            LayerChromium* layer = layerList[layerIndex].get();
 
             // Layers that start a new render surface will be painted when the render
             // surface's list is processed.
-            if (ccLayerImpl->renderSurface() && ccLayerImpl->renderSurface() != renderSurface)
+            if (layer->renderSurface() && layer->renderSurface() != renderSurface)
                 continue;
 
-            LayerChromium* layer = ccLayerImpl->owner();
-
             layer->setLayerRenderer(this);
 
             if (!layer->opacity())
@@ -706,10 +722,10 @@ void LayerRendererChromium::paintLayerContents(const LayerList& renderSurfaceLay
             if (layer->bounds().isEmpty())
                 continue;
 
-            IntRect targetSurfaceRect = ccLayerImpl->targetRenderSurface() ? ccLayerImpl->targetRenderSurface()->contentRect() : m_defaultRenderSurface->contentRect();
-            if (layer->ccLayerImpl()->usesLayerScissor())
-                targetSurfaceRect.intersect(layer->ccLayerImpl()->scissorRect());
-            IntRect visibleLayerRect = calculateVisibleLayerRect(targetSurfaceRect, layer->bounds(), layer->contentBounds(), ccLayerImpl->drawTransform());
+            IntRect targetSurfaceRect = layer->targetRenderSurface() ? layer->targetRenderSurface()->contentRect() : m_defaultRenderSurface->contentRect();
+            if (layer->usesLayerScissor())
+                targetSurfaceRect.intersect(layer->scissorRect());
+            IntRect visibleLayerRect = calculateVisibleLayerRect(targetSurfaceRect, layer->bounds(), layer->contentBounds(), layer->drawTransform());
 
             paintContentsIfDirty(layer, visibleLayerRect);
 
@@ -728,15 +744,36 @@ void LayerRendererChromium::paintLayerContents(const LayerList& renderSurfaceLay
     }
 }
 
-void LayerRendererChromium::drawLayers(const LayerList& renderSurfaceLayerList)
+void LayerRendererChromium::drawLayersInternal()
 {
     if (m_viewportVisibleRect.isEmpty() || !m_rootLayer)
         return;
 
     TRACE_EVENT("LayerRendererChromium::drawLayers", this, 0);
-    CCLayerImpl* rootDrawLayer = m_rootLayer->ccLayerImpl();
+    CCLayerImpl* rootDrawLayer = m_rootCCLayerImpl.get();
     makeContextCurrent();
 
+    if (!rootDrawLayer->renderSurface())
+        rootDrawLayer->createRenderSurface();
+    rootDrawLayer->renderSurface()->setContentRect(IntRect(IntPoint(0, 0), m_viewportVisibleRect.size()));
+
+    IntRect rootScissorRect(m_viewportVisibleRect);
+    // The scissorRect should not include the scroll offset.
+    rootScissorRect.move(-m_viewportScrollPosition.x(), -m_viewportScrollPosition.y());
+    rootDrawLayer->setScissorRect(rootScissorRect);
+
+    CCLayerList renderSurfaceLayerList;
+    renderSurfaceLayerList.append(rootDrawLayer);
+
+    TransformationMatrix identityMatrix;
+    m_defaultRenderSurface = rootDrawLayer->renderSurface();
+    m_defaultRenderSurface->clearLayerList();
+
+    {
+        TRACE_EVENT("LayerRendererChromium::drawLayersInternal::calcDrawEtc", this, 0);
+        calculateDrawTransformsAndVisibility<CCLayerImpl, CCRenderSurface, CCLayerSorter>(rootDrawLayer, rootDrawLayer, identityMatrix, renderSurfaceLayerList, m_defaultRenderSurface->layerList(), &m_layerSorter, m_maxTextureSize);
+    }
+
     // The GL viewport covers the entire visible area, including the scrollbars.
     GLC(m_context.get(), m_context->viewport(0, 0, m_viewportVisibleRect.width(), m_viewportVisibleRect.height()));
 
@@ -774,7 +811,7 @@ void LayerRendererChromium::drawLayers(const LayerList& renderSurfaceLayerList)
     // correct order.
     for (int surfaceIndex = renderSurfaceLayerList.size() - 1; surfaceIndex >= 0 ; --surfaceIndex) {
         CCLayerImpl* renderSurfaceLayer = renderSurfaceLayerList[surfaceIndex].get();
-        RenderSurfaceChromium* renderSurface = renderSurfaceLayer->renderSurface();
+        CCRenderSurface* renderSurface = renderSurfaceLayer->renderSurface();
         ASSERT(renderSurface);
 
         renderSurface->setSkipsDraw(true);
@@ -798,7 +835,7 @@ void LayerRendererChromium::drawLayers(const LayerList& renderSurfaceLayerList)
                 GLC(m_context.get(), m_context->enable(GraphicsContext3D::SCISSOR_TEST));
             }
 
-            LayerList& layerList = renderSurface->layerList();
+            const CCLayerList& layerList = renderSurface->layerList();
             for (unsigned layerIndex = 0; layerIndex < layerList.size(); ++layerIndex)
                 drawLayer(layerList[layerIndex].get(), renderSurface);
         }
@@ -918,7 +955,7 @@ bool LayerRendererChromium::isLayerVisible(LayerChromium* layer, const Transform
 void LayerRendererChromium::updateCompositorResources(const LayerList& renderSurfaceLayerList)
 {
     for (int surfaceIndex = renderSurfaceLayerList.size() - 1; surfaceIndex >= 0 ; --surfaceIndex) {
-        CCLayerImpl* renderSurfaceLayer = renderSurfaceLayerList[surfaceIndex].get();
+        LayerChromium* renderSurfaceLayer = renderSurfaceLayerList[surfaceIndex].get();
         RenderSurfaceChromium* renderSurface = renderSurfaceLayer->renderSurface();
         ASSERT(renderSurface);
 
@@ -928,19 +965,17 @@ void LayerRendererChromium::updateCompositorResources(const LayerList& renderSur
         const LayerList& layerList = renderSurface->layerList();
         ASSERT(layerList.size());
         for (unsigned layerIndex = 0; layerIndex < layerList.size(); ++layerIndex) {
-            CCLayerImpl* ccLayerImpl = layerList[layerIndex].get();
-            if (ccLayerImpl->renderSurface() && ccLayerImpl->renderSurface() != renderSurface)
+            LayerChromium* layer = layerList[layerIndex].get();
+            if (layer->renderSurface() && layer->renderSurface() != renderSurface)
                 continue;
 
-            updateCompositorResources(ccLayerImpl);
+            updateCompositorResources(layer);
         }
     }
 }
 
-void LayerRendererChromium::updateCompositorResources(CCLayerImpl* ccLayerImpl)
+void LayerRendererChromium::updateCompositorResources(LayerChromium* layer)
 {
-    LayerChromium* layer = ccLayerImpl->owner();
-
     if (layer->bounds().isEmpty())
         return;
 
@@ -948,14 +983,12 @@ void LayerRendererChromium::updateCompositorResources(CCLayerImpl* ccLayerImpl)
         return;
 
     if (layer->maskLayer())
-        updateCompositorResources(ccLayerImpl->maskLayer());
+        updateCompositorResources(layer->maskLayer());
     if (layer->replicaLayer())
-        updateCompositorResources(ccLayerImpl->replicaLayer());
+        updateCompositorResources(layer->replicaLayer());
 
     if (layer->drawsContent())
         layer->updateCompositorResources();
-
-    layer->pushPropertiesTo(ccLayerImpl);
 }
 
 void LayerRendererChromium::setCompositeOffscreen(bool compositeOffscreen)
@@ -965,13 +998,13 @@ void LayerRendererChromium::setCompositeOffscreen(bool compositeOffscreen)
 
     m_compositeOffscreen = compositeOffscreen;
 
-    if (!m_compositeOffscreen && m_rootLayer)
-        m_rootLayer->ccLayerImpl()->clearRenderSurface();
+    if (!m_compositeOffscreen && m_rootCCLayerImpl)
+        m_rootCCLayerImpl->clearRenderSurface();
 }
 
 LayerTexture* LayerRendererChromium::getOffscreenLayerTexture()
 {
-    return m_compositeOffscreen ? m_rootLayer->ccLayerImpl()->renderSurface()->contentsTexture() : 0;
+    return m_compositeOffscreen && m_rootCCLayerImpl ? m_rootCCLayerImpl->renderSurface()->contentsTexture() : 0;
 }
 
 void LayerRendererChromium::copyOffscreenTextureToDisplay()
@@ -988,7 +1021,7 @@ void LayerRendererChromium::copyOffscreenTextureToDisplay()
     }
 }
 
-bool LayerRendererChromium::useRenderSurface(RenderSurfaceChromium* renderSurface)
+bool LayerRendererChromium::useRenderSurface(CCRenderSurface* renderSurface)
 {
     if (m_currentRenderSurface == renderSurface)
         return true;
@@ -1022,7 +1055,7 @@ bool LayerRendererChromium::useRenderSurface(RenderSurfaceChromium* renderSurfac
     return true;
 }
 
-void LayerRendererChromium::drawLayer(CCLayerImpl* layer, RenderSurfaceChromium* targetSurface)
+void LayerRendererChromium::drawLayer(CCLayerImpl* layer, CCRenderSurface* targetSurface)
 {
     if (layer->renderSurface() && layer->renderSurface() != targetSurface) {
         layer->renderSurface()->draw(layer->getDrawRect());
@@ -1049,7 +1082,6 @@ void LayerRendererChromium::drawLayer(CCLayerImpl* layer, RenderSurfaceChromium*
     } else
         GLC(m_context.get(), m_context->disable(GraphicsContext3D::SCISSOR_TEST));
 
-
     if (!layer->doubleSided()) {
         // FIXME: Need to take into account the cumulative render surface transforms all the way from
         //        the default render surface in order to determine visibility.
@@ -1141,7 +1173,7 @@ bool LayerRendererChromium::initializeSharedObjects()
     // We will always need these programs to render, so create the programs eagerly so that the shader compilation can
     // start while we do other work. Other programs are created lazily on first access.
     m_sharedGeometry = adoptPtr(new GeometryBinding(m_context.get()));
-    m_renderSurfaceProgram = adoptPtr(new RenderSurfaceChromium::Program(m_context.get()));
+    m_renderSurfaceProgram = adoptPtr(new CCRenderSurface::Program(m_context.get()));
     m_tilerProgram = adoptPtr(new LayerTilerChromium::Program(m_context.get()));
 
     GLC(m_context.get(), m_context->flush());
@@ -1173,7 +1205,7 @@ const CCHeadsUpDisplay::Program* LayerRendererChromium::headsUpDisplayProgram()
     return m_headsUpDisplayProgram.get();
 }
 
-const RenderSurfaceChromium::Program* LayerRendererChromium::renderSurfaceProgram()
+const CCRenderSurface::Program* LayerRendererChromium::renderSurfaceProgram()
 {
     ASSERT(m_renderSurfaceProgram);
     if (!m_renderSurfaceProgram->initialized()) {
@@ -1183,10 +1215,10 @@ const RenderSurfaceChromium::Program* LayerRendererChromium::renderSurfaceProgra
     return m_renderSurfaceProgram.get();
 }
 
-const RenderSurfaceChromium::MaskProgram* LayerRendererChromium::renderSurfaceMaskProgram()
+const CCRenderSurface::MaskProgram* LayerRendererChromium::renderSurfaceMaskProgram()
 {
     if (!m_renderSurfaceMaskProgram)
-        m_renderSurfaceMaskProgram = adoptPtr(new RenderSurfaceChromium::MaskProgram(m_context.get()));
+        m_renderSurfaceMaskProgram = adoptPtr(new CCRenderSurface::MaskProgram(m_context.get()));
     if (!m_renderSurfaceMaskProgram->initialized()) {
         TRACE_EVENT("LayerRendererChromium::borderProgram::initialize", this, 0);
         m_renderSurfaceMaskProgram->initialize();
@@ -1339,8 +1371,8 @@ bool LayerRendererChromium::isCompositorContextLost()
 
 void LayerRendererChromium::dumpRenderSurfaces(TextStream& ts, int indent, LayerChromium* layer) const
 {
-    if (layer->ccLayerImpl()->renderSurface())
-        layer->ccLayerImpl()->renderSurface()->dumpSurface(ts, indent);
+    if (layer->renderSurface())
+        layer->renderSurface()->dumpSurface(ts, indent);
 
     for (size_t i = 0; i < layer->children().size(); ++i)
         dumpRenderSurfaces(ts, indent, layer->children()[i].get());
index 5a9f0c1..d5703d4 100644 (file)
@@ -38,7 +38,6 @@
 #include "IntRect.h"
 #include "LayerChromium.h"
 #include "LayerTilerChromium.h"
-#include "RenderSurfaceChromium.h"
 #include "SkBitmap.h"
 #include "VideoLayerChromium.h"
 #include "cc/CCCanvasLayerImpl.h"
@@ -129,8 +128,8 @@ public:
     const GeometryBinding* sharedGeometry() const { return m_sharedGeometry.get(); }
     const LayerChromium::BorderProgram* borderProgram();
     const CCHeadsUpDisplay::Program* headsUpDisplayProgram();
-    const RenderSurfaceChromium::Program* renderSurfaceProgram();
-    const RenderSurfaceChromium::MaskProgram* renderSurfaceMaskProgram();
+    const CCRenderSurface::Program* renderSurfaceProgram();
+    const CCRenderSurface::MaskProgram* renderSurfaceMaskProgram();
     const LayerTilerChromium::Program* tilerProgram();
     const LayerTilerChromium::ProgramSwizzle* tilerProgramSwizzle();
     const CCCanvasLayerImpl::Program* canvasLayerProgram();
@@ -160,11 +159,13 @@ public:
 #ifndef NDEBUG
     static bool s_inPaintLayerContents;
 #endif
+    typedef Vector<RefPtr<LayerChromium> > LayerList;
+    typedef Vector<RefPtr<CCLayerImpl> > CCLayerList;
+
 protected:
     virtual PassOwnPtr<CCLayerTreeHostImplProxy> createLayerTreeHostImplProxy();
 
 private:
-    typedef Vector<RefPtr<CCLayerImpl> > LayerList;
     typedef HashMap<GraphicsContext3D*, int> ChildContextMap;
 
     // FIXME: This needs to be moved to the CCLayerTreeHostImpl when that class exists.
@@ -172,16 +173,15 @@ private:
 
     LayerRendererChromium(CCLayerTreeHostClient*, PassRefPtr<GraphicsContext3D>, PassOwnPtr<LayerPainterChromium> contentPaint, bool accelerateDrawing);
 
-    void updateLayers(LayerList& renderSurfaceLayerList);
+    void updateLayers(LayerChromium*);
     void updateRootLayerContents();
-    void updatePropertiesAndRenderSurfaces(CCLayerImpl*, const TransformationMatrix& parentMatrix, LayerList& renderSurfaceLayerList, LayerList& layers);
 
     void paintLayerContents(const LayerList&);
     void updateCompositorResources(const LayerList& renderSurfaceLayerList);
-    void updateCompositorResources(CCLayerImpl*);
+    void updateCompositorResources(LayerChromium*);
 
-    void drawLayers(const LayerList& renderSurfaceLayerList);
-    void drawLayer(CCLayerImpl*, RenderSurfaceChromium*);
+    void drawLayersInternal();
+    void drawLayer(CCLayerImpl*, CCRenderSurface*);
 
     void drawRootLayer();
     LayerTexture* getOffscreenLayerTexture();
@@ -191,7 +191,7 @@ private:
 
     void setDrawViewportRect(const IntRect&, bool flipY);
 
-    bool useRenderSurface(RenderSurfaceChromium*);
+    bool useRenderSurface(CCRenderSurface*);
 
     bool makeContextCurrent();
 
@@ -219,7 +219,7 @@ private:
 
     OwnPtr<LayerList> m_computedRenderSurfaceLayerList;
 
-    RenderSurfaceChromium* m_currentRenderSurface;
+    CCRenderSurface* m_currentRenderSurface;
     unsigned m_offscreenFramebufferId;
     bool m_compositeOffscreen;
 
@@ -233,14 +233,14 @@ private:
     OwnPtr<GeometryBinding> m_sharedGeometry;
     OwnPtr<LayerChromium::BorderProgram> m_borderProgram;
     OwnPtr<CCHeadsUpDisplay::Program> m_headsUpDisplayProgram;
-    OwnPtr<RenderSurfaceChromium::Program> m_renderSurfaceProgram;
-    OwnPtr<RenderSurfaceChromium::MaskProgram> m_renderSurfaceMaskProgram;
     OwnPtr<LayerTilerChromium::Program> m_tilerProgram;
     OwnPtr<LayerTilerChromium::ProgramSwizzle> m_tilerProgramSwizzle;
     OwnPtr<CCCanvasLayerImpl::Program> m_canvasLayerProgram;
+    OwnPtr<CCPluginLayerImpl::Program> m_pluginLayerProgram;
+    OwnPtr<CCRenderSurface::MaskProgram> m_renderSurfaceMaskProgram;
+    OwnPtr<CCRenderSurface::Program> m_renderSurfaceProgram;
     OwnPtr<CCVideoLayerImpl::RGBAProgram> m_videoLayerRGBAProgram;
     OwnPtr<CCVideoLayerImpl::YUVProgram> m_videoLayerYUVProgram;
-    OwnPtr<CCPluginLayerImpl::Program> m_pluginLayerProgram;
 
     OwnPtr<TextureManager> m_contentsTextureManager;
     OwnPtr<TextureManager> m_renderSurfaceTextureManager;
@@ -260,7 +260,7 @@ private:
 
     bool m_animating;
 
-    RenderSurfaceChromium* m_defaultRenderSurface;
+    CCRenderSurface* m_defaultRenderSurface;
 
     CCLayerSorter m_layerSorter;
 };
index 000f295..b6e3506 100644 (file)
@@ -49,7 +49,7 @@ PluginLayerChromium::PluginLayerChromium(GraphicsLayerChromium* owner)
 
 PassRefPtr<CCLayerImpl> PluginLayerChromium::createCCLayerImpl()
 {
-    return CCPluginLayerImpl::create(this, m_layerId);
+    return CCPluginLayerImpl::create(m_layerId);
 }
 
 void PluginLayerChromium::setTextureId(unsigned id)
index 6a27216..e9a3dfd 100644 (file)
 
 #include "RenderSurfaceChromium.h"
 
-#include "cc/CCLayerImpl.h"
 #include "GraphicsContext3D.h"
 #include "LayerChromium.h"
 #include "LayerRendererChromium.h"
-#include "LayerTexture.h"
-#include "TextStream.h"
 #include <wtf/text/CString.h>
 
 namespace WebCore {
 
-RenderSurfaceChromium::RenderSurfaceChromium(CCLayerImpl* owningLayer)
+RenderSurfaceChromium::RenderSurfaceChromium(LayerChromium* owningLayer)
     : m_owningLayer(owningLayer)
     , m_maskLayer(0)
     , m_skipsDraw(false)
@@ -49,17 +46,6 @@ RenderSurfaceChromium::RenderSurfaceChromium(CCLayerImpl* owningLayer)
 
 RenderSurfaceChromium::~RenderSurfaceChromium()
 {
-    cleanupResources();
-}
-
-void RenderSurfaceChromium::cleanupResources()
-{
-    if (!m_contentsTexture)
-        return;
-
-    ASSERT(layerRenderer());
-
-    m_contentsTexture.clear();
 }
 
 LayerRendererChromium* RenderSurfaceChromium::layerRenderer()
@@ -79,105 +65,6 @@ FloatRect RenderSurfaceChromium::drawableContentRect() const
     return drawableContentRect;
 }
 
-bool RenderSurfaceChromium::prepareContentsTexture()
-{
-    IntSize requiredSize(m_contentRect.size());
-    TextureManager* textureManager = layerRenderer()->renderSurfaceTextureManager();
-
-    if (!m_contentsTexture)
-        m_contentsTexture = LayerTexture::create(layerRenderer()->context(), textureManager);
-
-    if (m_contentsTexture->isReserved())
-        return true;
-
-    if (!m_contentsTexture->reserve(requiredSize, GraphicsContext3D::RGBA)) {
-        m_skipsDraw = true;
-        return false;
-    }
-
-    m_skipsDraw = false;
-    return true;
-}
-
-void RenderSurfaceChromium::releaseContentsTexture()
-{
-    if (m_skipsDraw || !m_contentsTexture)
-        return;
-    m_contentsTexture->unreserve();
-}
-
-void RenderSurfaceChromium::drawSurface(CCLayerImpl* maskLayer, const TransformationMatrix& drawTransform)
-{
-    GraphicsContext3D* context3D = layerRenderer()->context();
-
-    int shaderMatrixLocation = -1;
-    int shaderAlphaLocation = -1;
-    const RenderSurfaceChromium::Program* program = layerRenderer()->renderSurfaceProgram();
-    const RenderSurfaceChromium::MaskProgram* maskProgram = layerRenderer()->renderSurfaceMaskProgram();
-    ASSERT(program && program->initialized());
-    bool useMask = false;
-    if (maskLayer && maskLayer->drawsContent()) {
-        if (!maskLayer->bounds().isEmpty()) {
-            context3D->makeContextCurrent();
-            GLC(context3D, context3D->useProgram(maskProgram->program()));
-            GLC(context3D, context3D->activeTexture(GraphicsContext3D::TEXTURE0));
-            GLC(context3D, context3D->uniform1i(maskProgram->fragmentShader().samplerLocation(), 0));
-            m_contentsTexture->bindTexture();
-            GLC(context3D, context3D->activeTexture(GraphicsContext3D::TEXTURE1));
-            GLC(context3D, context3D->uniform1i(maskProgram->fragmentShader().maskSamplerLocation(), 1));
-            maskLayer->bindContentsTexture();
-            GLC(context3D, context3D->activeTexture(GraphicsContext3D::TEXTURE0));
-            shaderMatrixLocation = maskProgram->vertexShader().matrixLocation();
-            shaderAlphaLocation = maskProgram->fragmentShader().alphaLocation();
-            useMask = true;
-        }
-    }
-
-    if (!useMask) {
-        GLC(context3D, context3D->useProgram(program->program()));
-        m_contentsTexture->bindTexture();
-        GLC(context3D, context3D->uniform1i(program->fragmentShader().samplerLocation(), 0));
-        shaderMatrixLocation = program->vertexShader().matrixLocation();
-        shaderAlphaLocation = program->fragmentShader().alphaLocation();
-    }
-    
-    LayerChromium::drawTexturedQuad(layerRenderer()->context(), layerRenderer()->projectionMatrix(), drawTransform,
-                                        m_contentRect.width(), m_contentRect.height(), m_drawOpacity,
-                                        shaderMatrixLocation, shaderAlphaLocation);
-}
-
-void RenderSurfaceChromium::draw(const IntRect&)
-{
-    if (m_skipsDraw || !m_contentsTexture)
-        return;
-    // FIXME: By using the same RenderSurface for both the content and its reflection,
-    // it's currently not possible to apply a separate mask to the reflection layer
-    // or correctly handle opacity in reflections (opacity must be applied after drawing
-    // both the layer and its reflection). The solution is to introduce yet another RenderSurface
-    // to draw the layer and its reflection in. For now we only apply a separate reflection
-    // mask if the contents don't have a mask of their own.
-    CCLayerImpl* replicaMaskLayer = m_maskLayer;
-    if (!m_maskLayer && m_owningLayer->replicaLayer())
-        replicaMaskLayer = m_owningLayer->replicaLayer()->maskLayer();
-
-    if (m_owningLayer->parent() && m_owningLayer->parent()->usesLayerScissor())
-        layerRenderer()->setScissorToRect(m_scissorRect);
-    else
-        GLC(layerRenderer()->context(), layerRenderer()->context()->disable(GraphicsContext3D::SCISSOR_TEST));
-
-
-    // Reflection draws before the layer.
-    if (m_owningLayer->replicaLayer())
-        drawSurface(replicaMaskLayer, m_replicaDrawTransform);
-
-    drawSurface(m_maskLayer, m_drawTransform);
-}
-
-void RenderSurfaceChromium::clearLayerList()
-{
-    m_layerList.clear();
-}
-
 String RenderSurfaceChromium::name() const
 {
     return String::format("RenderSurface(id=%d,owner=%s)", m_owningLayer->id(), m_owningLayer->name().utf8().data());
index 1d2cb62..c34edae 100644 (file)
 
 namespace WebCore {
 
-class CCLayerImpl;
+class LayerChromium;
 class LayerRendererChromium;
 class LayerTexture;
 
 class RenderSurfaceChromium {
     WTF_MAKE_NONCOPYABLE(RenderSurfaceChromium);
 public:
-    explicit RenderSurfaceChromium(CCLayerImpl*);
+    explicit RenderSurfaceChromium(LayerChromium*);
     ~RenderSurfaceChromium();
 
     bool prepareContentsTexture();
@@ -60,9 +60,6 @@ public:
     // Returns the rect that encloses the RenderSurface including any reflection.
     FloatRect drawableContentRect() const;
 
-    Vector<RefPtr<CCLayerImpl> >& layerList() { return m_layerList; }
-    void clearLayerList();
-
     const IntRect& contentRect() const { return m_contentRect; }
     void setContentRect(const IntRect& contentRect) { m_contentRect = contentRect; }
 
@@ -72,9 +69,6 @@ public:
     const TransformationMatrix& drawTransform() const { return m_drawTransform; }
     void setDrawTransform(const TransformationMatrix& drawTransform) { m_drawTransform = drawTransform; }
 
-    CCLayerImpl* maskLayer() const { return m_maskLayer; }
-    void setMaskLayer(CCLayerImpl* maskLayer) { m_maskLayer = maskLayer; }
-
     const TransformationMatrix& originTransform() const { return m_originTransform; }
     void setOriginTransform(const TransformationMatrix& originTransform) { m_originTransform = originTransform; }
 
@@ -87,28 +81,26 @@ public:
     bool skipsDraw() const { return m_skipsDraw; }
     void setSkipsDraw(bool skipsDraw) { m_skipsDraw = skipsDraw; }
 
-    LayerTexture* contentsTexture() const { return m_contentsTexture.get(); }
+    void clearLayerList() { m_layerList.clear(); }
+    Vector<RefPtr<LayerChromium> >& layerList() { return m_layerList; }
 
-    typedef ProgramBinding<VertexShaderPosTex, FragmentShaderRGBATexAlpha> Program;
-    typedef ProgramBinding<VertexShaderPosTex, FragmentShaderRGBATexAlphaMask> MaskProgram;
+    void setMaskLayer(LayerChromium* maskLayer) { m_maskLayer = maskLayer; }
 
 private:
     LayerRendererChromium* layerRenderer();
-    void drawSurface(CCLayerImpl* maskLayer, const TransformationMatrix& drawTransform);
 
-    CCLayerImpl* m_owningLayer;
-    CCLayerImpl* m_maskLayer;
+    LayerChromium* m_owningLayer;
+    LayerChromium* m_maskLayer;
 
     IntRect m_contentRect;
     bool m_skipsDraw;
 
-    OwnPtr<LayerTexture> m_contentsTexture;
     float m_drawOpacity;
     TransformationMatrix m_drawTransform;
     TransformationMatrix m_replicaDrawTransform;
     TransformationMatrix m_originTransform;
     IntRect m_scissorRect;
-    Vector<RefPtr<CCLayerImpl> > m_layerList;
+    Vector<RefPtr<LayerChromium> > m_layerList;
 };
 
 }
index 3e9e6dd..2a8c551 100644 (file)
@@ -60,7 +60,7 @@ TiledLayerChromium::~TiledLayerChromium()
 
 PassRefPtr<CCLayerImpl> TiledLayerChromium::createCCLayerImpl()
 {
-    return CCTiledLayerImpl::create(this, id());
+    return CCTiledLayerImpl::create(id());
 }
 
 void TiledLayerChromium::cleanupResources()
@@ -150,7 +150,7 @@ void TiledLayerChromium::setIsMask(bool isMask)
 
 TransformationMatrix TiledLayerChromium::tilingTransform() const
 {
-    TransformationMatrix transform = ccLayerImpl()->drawTransform();
+    TransformationMatrix transform = drawTransform();
 
     if (contentBounds().isEmpty())
         return transform;
index 6ad4b11..d0fd0ce 100644 (file)
@@ -74,8 +74,6 @@ PassRefPtr<CCLayerImpl> TreeSynchronizer::synchronizeTreeRecursive(LayerChromium
     else
         ccLayerImpl->setReplicaLayer(0);
 
-    layer->setCCLayerImpl(ccLayerImpl.get());
-
     layer->pushPropertiesTo(ccLayerImpl.get());
     return ccLayerImpl.release();
 }
index 2fcd219..22bd30c 100644 (file)
@@ -69,7 +69,7 @@ VideoLayerChromium::~VideoLayerChromium()
 
 PassRefPtr<CCLayerImpl> VideoLayerChromium::createCCLayerImpl()
 {
-    return CCVideoLayerImpl::create(this, m_layerId);
+    return CCVideoLayerImpl::create(m_layerId);
 }
 
 void VideoLayerChromium::deleteTexturesInUse()
index 7125b96..865fd72 100644 (file)
 
 #include "cc/CCCanvasLayerImpl.h"
 
-#include "CanvasLayerChromium.h"
 #include "GraphicsContext3D.h"
 #include "LayerRendererChromium.h"
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
-CCCanvasLayerImpl::CCCanvasLayerImpl(LayerChromium* owner, int id)
-    : CCLayerImpl(owner, id)
+CCCanvasLayerImpl::CCCanvasLayerImpl(int id)
+    : CCLayerImpl(id)
     , m_textureId(0)
     , m_hasAlpha(true)
     , m_premultipliedAlpha(true)
index c17af5f..d85eba8 100644 (file)
@@ -34,9 +34,9 @@ namespace WebCore {
 
 class CCCanvasLayerImpl : public CCLayerImpl {
 public:
-    static PassRefPtr<CCCanvasLayerImpl> create(LayerChromium* owner, int id)
+    static PassRefPtr<CCCanvasLayerImpl> create(int id)
     {
-        return adoptRef(new CCCanvasLayerImpl(owner, id));
+        return adoptRef(new CCCanvasLayerImpl(id));
     }
     virtual ~CCCanvasLayerImpl();
 
@@ -50,7 +50,7 @@ public:
     void setHasAlpha(bool hasAlpha) { m_hasAlpha = hasAlpha; }
     void setPremultipliedAlpha(bool premultipliedAlpha) { m_premultipliedAlpha = premultipliedAlpha; }
 private:
-    CCCanvasLayerImpl(LayerChromium*, int);
+    explicit CCCanvasLayerImpl(int);
 
     unsigned m_textureId;
     bool m_hasAlpha;
index 24e9b5f..3cead4c 100644 (file)
@@ -32,7 +32,6 @@
 #include "GraphicsContext3D.h"
 #include "LayerChromium.h"
 #include "LayerRendererChromium.h"
-#include "RenderSurfaceChromium.h"
 #include <wtf/text/WTFString.h>
 
 namespace {
@@ -60,9 +59,8 @@ void toGLMatrix(float* flattened, const WebCore::TransformationMatrix& m)
 
 namespace WebCore {
 
-CCLayerImpl::CCLayerImpl(LayerChromium* owner, int id)
-    : m_owner(owner)
-    , m_parent(0)
+CCLayerImpl::CCLayerImpl(int id)
+    : m_parent(0)
     , m_layerId(id)
     , m_anchorPoint(0.5, 0.5)
     , m_anchorPointZ(0)
@@ -83,8 +81,6 @@ CCLayerImpl::CCLayerImpl(LayerChromium* owner, int id)
 
 CCLayerImpl::~CCLayerImpl()
 {
-    if (m_owner)
-        m_owner->setCCLayerImpl(0);
 }
 
 void CCLayerImpl::addChild(PassRefPtr<CCLayerImpl> child)
@@ -122,16 +118,16 @@ void CCLayerImpl::setLayerRenderer(LayerRendererChromium* renderer)
     m_layerRenderer = renderer;
 }
 
-RenderSurfaceChromium* CCLayerImpl::createRenderSurface()
+void CCLayerImpl::createRenderSurface()
 {
-    m_renderSurface = adoptPtr(new RenderSurfaceChromium(this));
-    return m_renderSurface.get();
+    ASSERT(!m_renderSurface);
+    m_renderSurface = adoptPtr(new CCRenderSurface(this));
 }
 
-bool CCLayerImpl::descendantsDrawsContent()
+bool CCLayerImpl::descendantDrawsContent()
 {
     for (size_t i = 0; i < m_children.size(); ++i) {
-        if (m_children[i]->drawsContent() || m_children[i]->descendantsDrawsContent())
+        if (m_children[i]->drawsContent() || m_children[i]->descendantDrawsContent())
             return true;
     }
     return false;
@@ -142,19 +138,8 @@ void CCLayerImpl::draw()
     ASSERT_NOT_REACHED();
 }
 
-void CCLayerImpl::updateCompositorResources()
-{
-    m_owner->updateCompositorResources();
-}
-
-void CCLayerImpl::unreserveContentsTexture()
-{
-    m_owner->unreserveContentsTexture();
-}
-
 void CCLayerImpl::bindContentsTexture()
 {
-    m_owner->bindContentsTexture();
 }
 
 void CCLayerImpl::cleanupResources()
index bd276fe..ffd7aa4 100644 (file)
@@ -31,6 +31,7 @@
 #include "IntRect.h"
 #include "TextStream.h"
 #include "TransformationMatrix.h"
+#include "cc/CCRenderSurface.h"
 #include <wtf/OwnPtr.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
@@ -40,13 +41,12 @@ namespace WebCore {
 
 class LayerChromium;
 class LayerRendererChromium;
-class RenderSurfaceChromium;
 
 class CCLayerImpl : public RefCounted<CCLayerImpl> {
 public:
-    static PassRefPtr<CCLayerImpl> create(LayerChromium* owner, int id)
+    static PassRefPtr<CCLayerImpl> create(int id)
     {
-        return adoptRef(new CCLayerImpl(owner, id));
+        return adoptRef(new CCLayerImpl(id));
     }
     virtual ~CCLayerImpl();
 
@@ -70,7 +70,6 @@ public:
 #endif
 
     virtual void draw();
-    virtual void updateCompositorResources();
     void unreserveContentsTexture();
     virtual void bindContentsTexture();
 
@@ -79,7 +78,7 @@ public:
     bool drawsContent() const { return m_drawsContent; }
 
     // Returns true if any of the layer's descendants has content to draw.
-    bool descendantsDrawsContent();
+    bool descendantDrawsContent();
 
     void cleanupResources();
 
@@ -124,9 +123,8 @@ public:
     void setLayerRenderer(LayerRendererChromium*);
     LayerRendererChromium* layerRenderer() const { return m_layerRenderer.get(); }
 
-    RenderSurfaceChromium* createRenderSurface();
-
-    RenderSurfaceChromium* renderSurface() const { return m_renderSurface.get(); }
+    CCRenderSurface* renderSurface() const { return m_renderSurface.get(); }
+    void createRenderSurface();
     void clearRenderSurface() { m_renderSurface.clear(); }
 
     float drawOpacity() const { return m_drawOpacity; }
@@ -134,9 +132,8 @@ public:
 
     const IntRect& scissorRect() const { return m_scissorRect; }
     void setScissorRect(const IntRect& rect) { m_scissorRect = rect; }
-
-    RenderSurfaceChromium* targetRenderSurface() const { return m_targetRenderSurface; }
-    void setTargetRenderSurface(RenderSurfaceChromium* surface) { m_targetRenderSurface = surface; }
+    CCRenderSurface* targetRenderSurface() const { return m_targetRenderSurface; }
+    void setTargetRenderSurface(CCRenderSurface* surface) { m_targetRenderSurface = surface; }
 
     const IntSize& bounds() const { return m_bounds; }
     void setBounds(const IntSize& bounds) { m_bounds = bounds; }
@@ -160,15 +157,8 @@ public:
 
     virtual void dumpLayerProperties(TextStream&, int indent) const;
 
-    // HACK TODO fix this
-    LayerChromium* owner() const { return m_owner; }
-    void clearOwner() { m_owner = 0; }
-
 protected:
-    // For now, CCLayerImpls have a back pointer to their LayerChromium.
-    // FIXME: remove this after https://bugs.webkit.org/show_bug.cgi?id=58833 is fixed.
-    LayerChromium* m_owner;
-    CCLayerImpl(LayerChromium*, int);
+    explicit CCLayerImpl(int);
 
     static void writeIndent(TextStream&, int indent);
 
@@ -216,7 +206,7 @@ private:
     // either to this layer (if m_targetRenderSurface == m_renderSurface) or
     // to an ancestor of this layer. The target render surface determines the
     // coordinate system the layer's transforms are relative to.
-    RenderSurfaceChromium* m_targetRenderSurface;
+    CCRenderSurface* m_targetRenderSurface;
 
     // The global depth value of the center of the layer. This value is used
     // to sort layers from back to front.
@@ -236,7 +226,7 @@ private:
 
     // Render surface associated with this layer. The layer and its descendants
     // will render to this surface.
-    OwnPtr<RenderSurfaceChromium> m_renderSurface;
+    OwnPtr<CCRenderSurface> m_renderSurface;
 
     // Hierarchical bounding rect containing the layer and its descendants.
     IntRect m_drawableContentRect;
index b2c5574..d101cc0 100644 (file)
@@ -26,8 +26,8 @@
 
 #include "cc/CCLayerSorter.h"
 
-#include "RenderSurfaceChromium.h"
 #include "TransformationMatrix.h"
+#include "cc/CCRenderSurface.h"
 #include <limits.h>
 
 using namespace std;
@@ -278,7 +278,7 @@ void CCLayerSorter::createGraphNodes(LayerList::iterator first, LayerList::itera
     for (LayerList::const_iterator it = first; it < last; it++) {
         m_nodes.append(GraphNode(it->get()));
         GraphNode& node = m_nodes.at(m_nodes.size() - 1);
-        RenderSurfaceChromium* renderSurface = node.layer->renderSurface();
+        CCRenderSurface* renderSurface = node.layer->renderSurface();
         if (!node.layer->drawsContent() && !renderSurface)
             continue;
 
index dee1ef0..8a25c5b 100644 (file)
 
 #include "GraphicsContext3D.h"
 #include "LayerRendererChromium.h"
-#include "PluginLayerChromium.h"
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
-CCPluginLayerImpl::CCPluginLayerImpl(LayerChromium* owner, int id)
-    : CCLayerImpl(owner, id)
+CCPluginLayerImpl::CCPluginLayerImpl(int id)
+    : CCLayerImpl(id)
     , m_textureId(0)
 {
 }
index 6e482d1..9b4c536 100644 (file)
@@ -34,9 +34,9 @@ namespace WebCore {
 
 class CCPluginLayerImpl : public CCLayerImpl {
 public:
-    static PassRefPtr<CCPluginLayerImpl> create(LayerChromium* owner, int id)
+    static PassRefPtr<CCPluginLayerImpl> create(int id)
     {
-        return adoptRef(new CCPluginLayerImpl(owner, id));
+        return adoptRef(new CCPluginLayerImpl(id));
     }
     virtual ~CCPluginLayerImpl();
 
@@ -49,7 +49,7 @@ public:
     void setTextureId(unsigned id) { m_textureId = id; }
 
 private:
-    CCPluginLayerImpl(LayerChromium*, int);
+    explicit CCPluginLayerImpl(int);
 
     unsigned m_textureId;
 };
diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.cpp b/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.cpp
new file mode 100644 (file)
index 0000000..c060bcc
--- /dev/null
@@ -0,0 +1,202 @@
+/*
+ * 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 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 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"
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#include "cc/CCRenderSurface.h"
+
+#include "GraphicsContext3D.h"
+#include "LayerChromium.h"
+#include "LayerRendererChromium.h"
+#include "LayerTexture.h"
+#include "TextStream.h"
+#include "cc/CCLayerImpl.h"
+#include <wtf/text/CString.h>
+
+namespace WebCore {
+
+CCRenderSurface::CCRenderSurface(CCLayerImpl* owningLayer)
+    : m_owningLayer(owningLayer)
+    , m_maskLayer(0)
+    , m_skipsDraw(false)
+    , m_drawOpacity(1)
+{
+}
+
+CCRenderSurface::~CCRenderSurface()
+{
+    cleanupResources();
+}
+
+void CCRenderSurface::cleanupResources()
+{
+    if (!m_contentsTexture)
+        return;
+
+    ASSERT(layerRenderer());
+
+    m_contentsTexture.clear();
+}
+
+LayerRendererChromium* CCRenderSurface::layerRenderer()
+{
+    ASSERT(m_owningLayer);
+    return m_owningLayer->layerRenderer();
+}
+
+FloatRect CCRenderSurface::drawableContentRect() const
+{
+    FloatRect localContentRect(-0.5 * m_contentRect.width(), -0.5 * m_contentRect.height(),
+                               m_contentRect.width(), m_contentRect.height());
+    FloatRect drawableContentRect = m_drawTransform.mapRect(localContentRect);
+    if (m_owningLayer->replicaLayer())
+        drawableContentRect.unite(m_replicaDrawTransform.mapRect(localContentRect));
+
+    return drawableContentRect;
+}
+
+bool CCRenderSurface::prepareContentsTexture()
+{
+    IntSize requiredSize(m_contentRect.size());
+    TextureManager* textureManager = layerRenderer()->renderSurfaceTextureManager();
+
+    if (!m_contentsTexture)
+        m_contentsTexture = LayerTexture::create(layerRenderer()->context(), textureManager);
+
+    if (m_contentsTexture->isReserved())
+        return true;
+
+    if (!m_contentsTexture->reserve(requiredSize, GraphicsContext3D::RGBA)) {
+        m_skipsDraw = true;
+        return false;
+    }
+
+    m_skipsDraw = false;
+    return true;
+}
+
+void CCRenderSurface::releaseContentsTexture()
+{
+    if (m_skipsDraw || !m_contentsTexture)
+        return;
+    m_contentsTexture->unreserve();
+}
+
+
+void CCRenderSurface::drawSurface(CCLayerImpl* maskLayer, const TransformationMatrix& drawTransform)
+{
+    GraphicsContext3D* context3D = layerRenderer()->context();
+
+    int shaderMatrixLocation = -1;
+    int shaderAlphaLocation = -1;
+    const CCRenderSurface::Program* program = layerRenderer()->renderSurfaceProgram();
+    const CCRenderSurface::MaskProgram* maskProgram = layerRenderer()->renderSurfaceMaskProgram();
+    ASSERT(program && program->initialized());
+    bool useMask = false;
+    if (maskLayer && maskLayer->drawsContent()) {
+        if (!maskLayer->bounds().isEmpty()) {
+            context3D->makeContextCurrent();
+            GLC(context3D, context3D->useProgram(maskProgram->program()));
+            GLC(context3D, context3D->activeTexture(GraphicsContext3D::TEXTURE0));
+            GLC(context3D, context3D->uniform1i(maskProgram->fragmentShader().samplerLocation(), 0));
+            m_contentsTexture->bindTexture();
+            GLC(context3D, context3D->activeTexture(GraphicsContext3D::TEXTURE1));
+            GLC(context3D, context3D->uniform1i(maskProgram->fragmentShader().maskSamplerLocation(), 1));
+            maskLayer->bindContentsTexture();
+            GLC(context3D, context3D->activeTexture(GraphicsContext3D::TEXTURE0));
+            shaderMatrixLocation = maskProgram->vertexShader().matrixLocation();
+            shaderAlphaLocation = maskProgram->fragmentShader().alphaLocation();
+            useMask = true;
+        }
+    }
+
+    if (!useMask) {
+        GLC(context3D, context3D->useProgram(program->program()));
+        m_contentsTexture->bindTexture();
+        GLC(context3D, context3D->uniform1i(program->fragmentShader().samplerLocation(), 0));
+        shaderMatrixLocation = program->vertexShader().matrixLocation();
+        shaderAlphaLocation = program->fragmentShader().alphaLocation();
+    }
+
+    LayerChromium::drawTexturedQuad(layerRenderer()->context(), layerRenderer()->projectionMatrix(), drawTransform,
+                                        m_contentRect.width(), m_contentRect.height(), m_drawOpacity,
+                                        shaderMatrixLocation, shaderAlphaLocation);
+}
+
+void CCRenderSurface::draw(const IntRect&)
+{
+    if (m_skipsDraw || !m_contentsTexture)
+        return;
+    // FIXME: By using the same RenderSurface for both the content and its reflection,
+    // it's currently not possible to apply a separate mask to the reflection layer
+    // or correctly handle opacity in reflections (opacity must be applied after drawing
+    // both the layer and its reflection). The solution is to introduce yet another RenderSurface
+    // to draw the layer and its reflection in. For now we only apply a separate reflection
+    // mask if the contents don't have a mask of their own.
+    CCLayerImpl* replicaMaskLayer = m_maskLayer;
+    if (!m_maskLayer && m_owningLayer->replicaLayer())
+        replicaMaskLayer = m_owningLayer->replicaLayer()->maskLayer();
+
+    if (m_owningLayer->parent() && m_owningLayer->parent()->usesLayerScissor())
+        layerRenderer()->setScissorToRect(m_scissorRect);
+    else
+        GLC(layerRenderer()->context(), layerRenderer()->context()->disable(GraphicsContext3D::SCISSOR_TEST));
+
+    // Reflection draws before the layer.
+    if (m_owningLayer->replicaLayer())
+        drawSurface(replicaMaskLayer, m_replicaDrawTransform);
+
+    drawSurface(m_maskLayer, m_drawTransform);
+}
+
+String CCRenderSurface::name() const
+{
+    return String::format("RenderSurface(id=%i,owner=%s)", m_owningLayer->id(), m_owningLayer->name().utf8().data());
+}
+
+static void writeIndent(TextStream& ts, int indent)
+{
+    for (int i = 0; i != indent; ++i)
+        ts << "  ";
+}
+
+void CCRenderSurface::dumpSurface(TextStream& ts, int indent) const
+{
+    writeIndent(ts, indent);
+    ts << name() << "\n";
+
+    writeIndent(ts, indent+1);
+    ts << "contentRect: (" << m_contentRect.x() << ", " << m_contentRect.y() << ", " << m_contentRect.width() << ", " << m_contentRect.height() << "\n";
+}
+
+int CCRenderSurface::owningLayerId() const
+{
+    return m_owningLayer ? m_owningLayer->id() : 0;
+}
+
+}
+#endif // USE(ACCELERATED_COMPOSITING)
diff --git a/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.h b/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.h
new file mode 100644 (file)
index 0000000..97726db
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ * 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 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 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.
+ */
+
+
+#ifndef CCRenderSurface_h
+#define CCRenderSurface_h
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#include "FloatRect.h"
+#include "IntRect.h"
+#include "ProgramBinding.h"
+#include "ShaderChromium.h"
+#include "TextureManager.h"
+#include "TransformationMatrix.h"
+#include <wtf/Noncopyable.h>
+
+namespace WebCore {
+
+class CCLayerImpl;
+class LayerRendererChromium;
+class LayerTexture;
+
+class CCRenderSurface {
+    WTF_MAKE_NONCOPYABLE(CCRenderSurface);
+public:
+    explicit CCRenderSurface(CCLayerImpl*);
+    ~CCRenderSurface();
+
+    bool prepareContentsTexture();
+    void releaseContentsTexture();
+    void cleanupResources();
+    void draw(const IntRect& targetSurfaceRect);
+
+    String name() const;
+    void dumpSurface(TextStream&, int indent) const;
+
+    FloatPoint contentRectCenter() const { return FloatRect(m_contentRect).center(); }
+
+    // Returns the rect that encloses the RenderSurface including any reflection.
+    FloatRect drawableContentRect() const;
+
+    float drawOpacity() const { return m_drawOpacity; }
+    void setDrawOpacity(float opacity) { m_drawOpacity = opacity; }
+
+    void setDrawTransform(const TransformationMatrix& drawTransform) { m_drawTransform = drawTransform; }
+    const TransformationMatrix& drawTransform() const { return m_drawTransform; }
+
+    void setReplicaDrawTransform(const TransformationMatrix& replicaDrawTransform) { m_replicaDrawTransform = replicaDrawTransform; }
+    const TransformationMatrix& replicaDrawTransform() const { return m_replicaDrawTransform; }
+
+    void setOriginTransform(const TransformationMatrix& originTransform) { m_originTransform = originTransform; }
+    const TransformationMatrix& originTransform() const { return m_originTransform; }
+
+    void setScissorRect(const IntRect& scissorRect) { m_scissorRect = scissorRect; }
+    const IntRect& scissorRect() const { return m_scissorRect; }
+
+    void setContentRect(const IntRect& contentRect) { m_contentRect = contentRect; }
+    const IntRect& contentRect() const { return m_contentRect; }
+
+    void setSkipsDraw(bool skipsDraw) { m_skipsDraw = skipsDraw; }
+    bool skipsDraw() const { return m_skipsDraw; }
+
+    void clearLayerList() { m_layerList.clear(); }
+    Vector<RefPtr<CCLayerImpl> >& layerList() { return m_layerList; }
+
+    void setMaskLayer(CCLayerImpl* maskLayer) { m_maskLayer = maskLayer; }
+
+    typedef ProgramBinding<VertexShaderPosTex, FragmentShaderRGBATexAlpha> Program;
+    typedef ProgramBinding<VertexShaderPosTex, FragmentShaderRGBATexAlphaMask> MaskProgram;
+
+    LayerTexture* contentsTexture() const { return m_contentsTexture.get(); }
+
+    int owningLayerId() const;
+private:
+    LayerRendererChromium* layerRenderer();
+    void drawSurface(CCLayerImpl* maskLayer, const TransformationMatrix& drawTransform);
+
+    CCLayerImpl* m_owningLayer;
+    CCLayerImpl* m_maskLayer;
+
+    IntRect m_contentRect;
+    bool m_skipsDraw;
+
+    OwnPtr<LayerTexture> m_contentsTexture;
+    float m_drawOpacity;
+    TransformationMatrix m_drawTransform;
+    TransformationMatrix m_replicaDrawTransform;
+    TransformationMatrix m_originTransform;
+    IntRect m_scissorRect;
+    Vector<RefPtr<CCLayerImpl> > m_layerList;
+};
+
+}
+#endif // USE(ACCELERATED_COMPOSITING)
+
+#endif
index 803ba06..fc103ea 100644 (file)
 
 #include "cc/CCTiledLayerImpl.h"
 
-#include "ContentLayerChromium.h"
-
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
 class LayerTexture;
 
-CCTiledLayerImpl::CCTiledLayerImpl(LayerChromium* owner, int id)
-    : CCLayerImpl(owner, id)
+CCTiledLayerImpl::CCTiledLayerImpl(int id)
+    : CCLayerImpl(id)
     , m_tiler(0)
 {
 }
index b0d1031..7346bb7 100644 (file)
@@ -33,9 +33,9 @@ namespace WebCore {
 
 class CCTiledLayerImpl : public CCLayerImpl {
 public:
-    static PassRefPtr<CCTiledLayerImpl> create(LayerChromium* owner, int id)
+    static PassRefPtr<CCTiledLayerImpl> create(int id)
     {
-        return adoptRef(new CCTiledLayerImpl(owner, id));
+        return adoptRef(new CCTiledLayerImpl(id));
     }
     virtual ~CCTiledLayerImpl();
 
@@ -48,7 +48,7 @@ public:
     void setTiler(LayerTilerChromium* tiler) { m_tiler = tiler; }
 
 private:
-    CCTiledLayerImpl(LayerChromium*, int id);
+    explicit CCTiledLayerImpl(int id);
 
     TransformationMatrix m_tilingTransform;
     LayerTilerChromium* m_tiler;
index f44abb0..0c93932 100644 (file)
@@ -59,8 +59,8 @@ const float CCVideoLayerImpl::yuvAdjust[3] = {
     -0.5f,
 };
 
-CCVideoLayerImpl::CCVideoLayerImpl(LayerChromium* owner, int id)
-    : CCLayerImpl(owner, id)
+CCVideoLayerImpl::CCVideoLayerImpl(int id)
+    : CCLayerImpl(id)
 {
 }
 
index fc07f77..ee9d421 100644 (file)
@@ -38,9 +38,9 @@ class VideoFrameProvider;
 
 class CCVideoLayerImpl : public CCLayerImpl {
 public:
-    static PassRefPtr<CCVideoLayerImpl> create(LayerChromium* owner, int id)
+    static PassRefPtr<CCVideoLayerImpl> create(int id)
     {
-        return adoptRef(new CCVideoLayerImpl(owner, id));
+        return adoptRef(new CCVideoLayerImpl(id));
     }
     virtual ~CCVideoLayerImpl();
 
@@ -56,7 +56,7 @@ public:
     void setTexture(size_t, VideoLayerChromium::Texture);
 
 private:
-    CCVideoLayerImpl(LayerChromium*, int);
+    explicit CCVideoLayerImpl(int);
 
     void drawYUV(const YUVProgram*) const;
     void drawRGBA(const RGBAProgram*) const;
index 702620a..8adf476 100644 (file)
@@ -36,9 +36,9 @@ namespace {
 
 class MockCCLayerImpl : public CCLayerImpl {
 public:
-    static PassRefPtr<MockCCLayerImpl> create(LayerChromium* owner, int layerId)
+    static PassRefPtr<MockCCLayerImpl> create(int layerId)
     {
-        return adoptRef(new MockCCLayerImpl(owner, layerId));
+        return adoptRef(new MockCCLayerImpl(layerId));
     }
     virtual ~MockCCLayerImpl()
     {
@@ -49,8 +49,8 @@ public:
     void setCCLayerDestructionList(Vector<int>* list) { m_ccLayerDestructionList = list; }
 
 private:
-    MockCCLayerImpl(LayerChromium* owner, int layerId)
-        : CCLayerImpl(owner, layerId)
+    MockCCLayerImpl(int layerId)
+        : CCLayerImpl(layerId)
         , m_ccLayerDestructionList(0)
     {
     }
@@ -69,7 +69,7 @@ public:
 
     virtual PassRefPtr<CCLayerImpl> createCCLayerImpl()
     {
-        return MockCCLayerImpl::create(this, m_layerId);
+        return MockCCLayerImpl::create(m_layerId);
     }
 
     virtual void pushPropertiesTo(CCLayerImpl* ccLayer)