Changeset 92245 in webkit


Ignore:
Timestamp:
Aug 2, 2011 4:20:44 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

[chromium] Decouple layer visibility calculations from render surfaces / computed draw transforms
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):

Location:
trunk/Source
Files:
25 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r92243 r92245  
     12011-08-02  James Robinson  <jamesr@chromium.org>
     2
     3        [chromium] Decouple layer visibility calculations from render surfaces / computed draw transforms
     4        https://bugs.webkit.org/show_bug.cgi?id=58840
     5
     6        Reviewed by Kenneth Russell.
     7
     8        This decouples the layer visibility related calculations from the LayerChromium and CCLayerImpl trees.  This is
     9        done by making LayerRendererChromium's "calculate the world" function (renamed
     10        calculateDrawTransformsAndVisibility()) a templated, free function that can operate on either LayerChromium +
     11        RenderSurfaceChromium pairs or on CCLayerImpl + CCRenderSurface pairs and invoking it twice, once before
     12        painting and once before drawing.  Before painting, these calculations are used to determine which layers are
     13        potentially visible and should be painted, which depends on the calculated opacity, render surface bounds, and
     14        draw transforms.  Before drawing, these calculations are used to figure out everything needed to draw.
     15
     16        RenderSurfaceChromium is now used just for visibility calculations when painting.  CCRenderSurfaceChromium is
     17        responsible for actually drawing the render surfaces.
     18
     19        This does mean that in the current implementation the second calculations are redundant, but in the future this
     20        won't be the case since the pre-draw time calculations might be influenced by animations or gestures.  I've
     21        added some traces to try to monitor if this math is a significant amount of the per-frame computation.  Note
     22        that layer sorting only happens on the CCLayerImpl tree and the layer sort algorithm is the most expensive part
     23        of the calculations currently.
     24
     25        This removes all of the weak back/forward pointers between LayerChromium and CCLayerImpls, the trees are now
     26        truly decoupled.
     27
     28        Covered by compositing/ tests.
     29
     30        * WebCore.gypi:
     31        * platform/graphics/chromium/CanvasLayerChromium.cpp:
     32        (WebCore::CanvasLayerChromium::createCCLayerImpl):
     33        * platform/graphics/chromium/LayerChromium.cpp:
     34        (WebCore::LayerChromium::LayerChromium):
     35        (WebCore::LayerChromium::~LayerChromium):
     36        (WebCore::LayerChromium::createCCLayerImpl):
     37        (WebCore::LayerChromium::createRenderSurface):
     38        (WebCore::LayerChromium::descendantsDrawsContent):
     39        * platform/graphics/chromium/LayerChromium.h:
     40        (WebCore::LayerChromium::setUsesLayerScissor):
     41        (WebCore::LayerChromium::usesLayerScissor):
     42        (WebCore::LayerChromium::clearRenderSurface):
     43        (WebCore::LayerChromium::renderSurface):
     44        (WebCore::LayerChromium::drawOpacity):
     45        (WebCore::LayerChromium::setDrawOpacity):
     46        (WebCore::LayerChromium::scissorRect):
     47        (WebCore::LayerChromium::setScissorRect):
     48        (WebCore::LayerChromium::targetRenderSurface):
     49        (WebCore::LayerChromium::setTargetRenderSurface):
     50        (WebCore::LayerChromium::drawTransform):
     51        (WebCore::LayerChromium::setDrawTransform):
     52        (WebCore::LayerChromium::drawableContentRect):
     53        (WebCore::LayerChromium::setDrawableContentRect):
     54        * platform/graphics/chromium/LayerRendererChromium.cpp:
     55        (WebCore::LayerRendererChromium::updateLayers):
     56        (WebCore::LayerRendererChromium::drawLayers):
     57        (WebCore::LayerRendererChromium::paintLayerContents):
     58        (WebCore::LayerRendererChromium::drawLayersInternal):
     59        (WebCore::LayerRendererChromium::updateCompositorResources):
     60        (WebCore::LayerRendererChromium::setCompositeOffscreen):
     61        (WebCore::LayerRendererChromium::getOffscreenLayerTexture):
     62        (WebCore::LayerRendererChromium::useRenderSurface):
     63        (WebCore::LayerRendererChromium::drawLayer):
     64        (WebCore::LayerRendererChromium::initializeSharedObjects):
     65        (WebCore::LayerRendererChromium::renderSurfaceProgram):
     66        (WebCore::LayerRendererChromium::renderSurfaceMaskProgram):
     67        (WebCore::LayerRendererChromium::dumpRenderSurfaces):
     68        * platform/graphics/chromium/LayerRendererChromium.h:
     69        * platform/graphics/chromium/PluginLayerChromium.cpp:
     70        (WebCore::PluginLayerChromium::createCCLayerImpl):
     71        * platform/graphics/chromium/RenderSurfaceChromium.cpp:
     72        (WebCore::RenderSurfaceChromium::RenderSurfaceChromium):
     73        (WebCore::RenderSurfaceChromium::~RenderSurfaceChromium):
     74        * platform/graphics/chromium/RenderSurfaceChromium.h:
     75        (WebCore::RenderSurfaceChromium::clearLayerList):
     76        (WebCore::RenderSurfaceChromium::layerList):
     77        (WebCore::RenderSurfaceChromium::setMaskLayer):
     78        * platform/graphics/chromium/TiledLayerChromium.cpp:
     79        (WebCore::TiledLayerChromium::createCCLayerImpl):
     80        (WebCore::TiledLayerChromium::tilingTransform):
     81        * platform/graphics/chromium/TreeSynchronizer.cpp:
     82        (WebCore::TreeSynchronizer::synchronizeTreeRecursive):
     83        * platform/graphics/chromium/VideoLayerChromium.cpp:
     84        (WebCore::VideoLayerChromium::createCCLayerImpl):
     85        * platform/graphics/chromium/cc/CCCanvasLayerImpl.cpp:
     86        (WebCore::CCCanvasLayerImpl::CCCanvasLayerImpl):
     87        * platform/graphics/chromium/cc/CCCanvasLayerImpl.h:
     88        (WebCore::CCCanvasLayerImpl::create):
     89        * platform/graphics/chromium/cc/CCLayerImpl.cpp:
     90        (WebCore::CCLayerImpl::CCLayerImpl):
     91        (WebCore::CCLayerImpl::~CCLayerImpl):
     92        (WebCore::CCLayerImpl::createRenderSurface):
     93        (WebCore::CCLayerImpl::bindContentsTexture):
     94        * platform/graphics/chromium/cc/CCLayerImpl.h:
     95        (WebCore::CCLayerImpl::create):
     96        (WebCore::CCLayerImpl::renderSurface):
     97        (WebCore::CCLayerImpl::targetRenderSurface):
     98        (WebCore::CCLayerImpl::setTargetRenderSurface):
     99        * platform/graphics/chromium/cc/CCLayerSorter.cpp:
     100        (WebCore::CCLayerSorter::createGraphNodes):
     101        * platform/graphics/chromium/cc/CCPluginLayerImpl.cpp:
     102        (WebCore::CCPluginLayerImpl::CCPluginLayerImpl):
     103        * platform/graphics/chromium/cc/CCPluginLayerImpl.h:
     104        (WebCore::CCPluginLayerImpl::create):
     105        * platform/graphics/chromium/cc/CCRenderSurface.cpp: Copied from Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.cpp.
     106        (WebCore::CCRenderSurface::CCRenderSurface):
     107        (WebCore::CCRenderSurface::~CCRenderSurface):
     108        (WebCore::CCRenderSurface::cleanupResources):
     109        (WebCore::CCRenderSurface::layerRenderer):
     110        (WebCore::CCRenderSurface::drawableContentRect):
     111        (WebCore::CCRenderSurface::prepareContentsTexture):
     112        (WebCore::CCRenderSurface::releaseContentsTexture):
     113        (WebCore::CCRenderSurface::drawSurface):
     114        (WebCore::CCRenderSurface::draw):
     115        (WebCore::CCRenderSurface::name):
     116        (WebCore::writeIndent):
     117        (WebCore::CCRenderSurface::dumpSurface):
     118        (WebCore::CCRenderSurface::owningLayerId):
     119        * platform/graphics/chromium/cc/CCRenderSurface.h: Copied from Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h.
     120        (WebCore::CCRenderSurface::contentRectCenter):
     121        (WebCore::CCRenderSurface::drawOpacity):
     122        (WebCore::CCRenderSurface::setDrawOpacity):
     123        (WebCore::CCRenderSurface::setDrawTransform):
     124        (WebCore::CCRenderSurface::drawTransform):
     125        (WebCore::CCRenderSurface::setReplicaDrawTransform):
     126        (WebCore::CCRenderSurface::replicaDrawTransform):
     127        (WebCore::CCRenderSurface::setOriginTransform):
     128        (WebCore::CCRenderSurface::originTransform):
     129        (WebCore::CCRenderSurface::setScissorRect):
     130        (WebCore::CCRenderSurface::scissorRect):
     131        (WebCore::CCRenderSurface::setContentRect):
     132        (WebCore::CCRenderSurface::contentRect):
     133        (WebCore::CCRenderSurface::setSkipsDraw):
     134        (WebCore::CCRenderSurface::skipsDraw):
     135        (WebCore::CCRenderSurface::clearLayerList):
     136        (WebCore::CCRenderSurface::layerList):
     137        (WebCore::CCRenderSurface::setMaskLayer):
     138        (WebCore::CCRenderSurface::contentsTexture):
     139        * platform/graphics/chromium/cc/CCTiledLayerImpl.cpp:
     140        (WebCore::CCTiledLayerImpl::CCTiledLayerImpl):
     141        * platform/graphics/chromium/cc/CCTiledLayerImpl.h:
     142        (WebCore::CCTiledLayerImpl::create):
     143        * platform/graphics/chromium/cc/CCVideoLayerImpl.cpp:
     144        (WebCore::CCVideoLayerImpl::CCVideoLayerImpl):
     145        * platform/graphics/chromium/cc/CCVideoLayerImpl.h:
     146        (WebCore::CCVideoLayerImpl::create):
     147
    11482011-08-02  Luke Macpherson   <macpherson@chromium.org>
    2149
  • trunk/Source/WebCore/WebCore.gypi

    r92161 r92245  
    35603560            'platform/graphics/chromium/cc/CCPluginLayerImpl.cpp',
    35613561            'platform/graphics/chromium/cc/CCPluginLayerImpl.h',
     3562            'platform/graphics/chromium/cc/CCRenderSurface.cpp',
     3563            'platform/graphics/chromium/cc/CCRenderSurface.h',
    35623564            'platform/graphics/chromium/cc/CCThread.cpp',
    35633565            'platform/graphics/chromium/cc/CCThread.h',
  • trunk/Source/WebCore/platform/graphics/chromium/CanvasLayerChromium.cpp

    r86905 r92245  
    5656PassRefPtr<CCLayerImpl> CanvasLayerChromium::createCCLayerImpl()
    5757{
    58     return CCCanvasLayerImpl::create(this, m_layerId);
     58    return CCCanvasLayerImpl::create(m_layerId);
    5959}
    6060
  • trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp

    r90963 r92245  
    6262    , m_layerId(s_nextLayerId++)
    6363    , m_parent(0)
    64     , m_ccLayerImpl(0)
    6564    , m_anchorPoint(0.5, 0.5)
    6665    , m_backgroundColor(0, 0, 0, 0)
     66    , m_debugBorderWidth(0)
    6767    , m_opacity(1.0)
    6868    , m_zPosition(0.0)
     
    7575    , m_needsDisplayOnBoundsChange(false)
    7676    , m_doubleSided(true)
     77    , m_usesLayerScissor(false)
    7778    , m_replicaLayer(0)
     79    , m_drawOpacity(0)
     80    , m_targetRenderSurface(0)
    7881{
    7982    ASSERT(!LayerRendererChromium::s_inPaintLayerContents);
     
    8689    // way for us to be destroyed while we still have a parent.
    8790    ASSERT(!parent());
    88 
    89     if (m_ccLayerImpl)
    90         m_ccLayerImpl->clearOwner();
    9191
    9292    // Remove the parent reference from all children.
     
    382382PassRefPtr<CCLayerImpl> LayerChromium::createCCLayerImpl()
    383383{
    384     return CCLayerImpl::create(this, m_layerId);
    385 }
    386 
    387 CCLayerImpl* LayerChromium::ccLayerImpl() const
    388 {
    389     return m_ccLayerImpl;
     384    return CCLayerImpl::create(m_layerId);
    390385}
    391386
     
    407402}
    408403
     404void LayerChromium::createRenderSurface()
     405{
     406    ASSERT(!m_renderSurface);
     407    m_renderSurface = adoptPtr(new RenderSurfaceChromium(this));
     408}
     409
     410bool LayerChromium::descendantDrawsContent()
     411{
     412    for (size_t i = 0; i < m_children.size(); ++i) {
     413        if (m_children[i]->drawsContent() || m_children[i]->descendantDrawsContent())
     414            return true;
     415    }
     416    return false;
     417}
     418
    409419}
    410420#endif // USE(ACCELERATED_COMPOSITING)
  • trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h

    r90963 r92245  
    105105
    106106    void setMaskLayer(LayerChromium* maskLayer) { m_maskLayer = maskLayer; }
    107     CCLayerImpl* maskDrawLayer() const { return m_maskLayer ? m_maskLayer->ccLayerImpl() : 0; }
    108107    LayerChromium* maskLayer() const { return m_maskLayer.get(); }
    109108
     
    145144
    146145    bool preserves3D() { return m_owner && m_owner->preserves3D(); }
     146
     147    void setUsesLayerScissor(bool usesLayerScissor) { m_usesLayerScissor = usesLayerScissor; }
     148    bool usesLayerScissor() const { return m_usesLayerScissor; }
    147149
    148150    // Derived types must override this method if they need to react to a change
     
    171173    void setBorderWidth(float);
    172174
    173     // Everything from here down in the public section will move to CCLayerImpl.
    174     CCLayerImpl* ccLayerImpl() const;
    175 
    176175    static void drawTexturedQuad(GraphicsContext3D*, const TransformationMatrix& projectionMatrix, const TransformationMatrix& layerMatrix,
    177176                                 float width, float height, float opacity,
     
    187186
    188187    int id() const { return m_layerId; }
     188
     189    void clearRenderSurface() { m_renderSurface.clear(); }
     190    RenderSurfaceChromium* renderSurface() const { return m_renderSurface.get(); }
     191    void createRenderSurface();
     192
     193    float drawOpacity() const { return m_drawOpacity; }
     194    void setDrawOpacity(float opacity) { m_drawOpacity = opacity; }
     195    const IntRect& scissorRect() const { return m_scissorRect; }
     196    void setScissorRect(const IntRect& rect) { m_scissorRect = rect; }
     197    RenderSurfaceChromium* targetRenderSurface() const { return m_targetRenderSurface; }
     198    void setTargetRenderSurface(RenderSurfaceChromium* surface) { m_targetRenderSurface = surface; }
     199    const TransformationMatrix& drawTransform() const { return m_drawTransform; }
     200    void setDrawTransform(const TransformationMatrix& matrix) { m_drawTransform = matrix; }
     201    const IntRect& drawableContentRect() const { return m_drawableContentRect; }
     202    void setDrawableContentRect(const IntRect& rect) { m_drawableContentRect = rect; }
     203
     204    // Returns true if any of the layer's descendants has content to draw.
     205    bool descendantDrawsContent();
    189206
    190207protected:
     
    211228    RefPtr<LayerChromium> m_maskLayer;
    212229
    213     // All layer shaders share the same attribute locations for the vertex positions
    214     // and texture coordinates. This allows switching shaders without rebinding attribute
    215     // arrays.
    216     static const unsigned s_positionAttribLocation;
    217     static const unsigned s_texCoordAttribLocation;
    218 
    219230    friend class TreeSynchronizer;
    220231    friend class CCLayerImpl;
    221232    // Constructs a CCLayerImpl of the correct runtime type for this LayerChromium type.
    222233    virtual PassRefPtr<CCLayerImpl> createCCLayerImpl();
    223     // FIXME: Remove when https://bugs.webkit.org/show_bug.cgi?id=58830 is fixed.
    224     void setCCLayerImpl(CCLayerImpl* impl) { m_ccLayerImpl = impl; }
    225234    int m_layerId;
    226235
     
    245254
    246255    RefPtr<LayerRendererChromium> m_layerRenderer;
    247 
    248     // Temporary forward weak pointer to the CCLayerImpl associated with this layer.
    249     // FIXME: Remove when https://bugs.webkit.org/show_bug.cgi?id=58830 is fixed.
    250     CCLayerImpl* m_ccLayerImpl;
    251256
    252257    // Layer properties.
     
    268273    bool m_needsDisplayOnBoundsChange;
    269274    bool m_doubleSided;
     275    bool m_usesLayerScissor;
    270276
    271277    TransformationMatrix m_transform;
     
    277283    RefPtr<LayerChromium> m_replicaLayer;
    278284
     285    // Transient properties.
     286    OwnPtr<RenderSurfaceChromium> m_renderSurface;
     287    float m_drawOpacity;
     288    IntRect m_scissorRect;
     289    RenderSurfaceChromium* m_targetRenderSurface;
     290    TransformationMatrix m_drawTransform;
     291    IntRect m_drawableContentRect;
     292
    279293    String m_name;
    280294};
  • trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp

    r92206 r92245  
    4545#include "LayerTextureUpdaterCanvas.h"
    4646#include "NotImplemented.h"
     47#include "RenderSurfaceChromium.h"
    4748#include "TextStream.h"
    4849#include "TextureManager.h"
     
    6465#include <wtf/MainThread.h>
    6566
     67using namespace std;
     68
    6669namespace WebCore {
    6770
     
    7982#endif
    8083
    81 static IntRect calculateVisibleRect(const IntRect& targetSurfaceRect, const IntRect& layerBoundRect, const TransformationMatrix& transform)
     84namespace {
     85
     86IntRect calculateVisibleRect(const IntRect& targetSurfaceRect, const IntRect& layerBoundRect, const TransformationMatrix& transform)
    8287{
    8388    // Is this layer fully contained within the target surface?
     
    103108
    104109// Returns true if the matrix has no rotation, skew or perspective components to it.
    105 static bool isScaleOrTranslation(const TransformationMatrix& m)
     110bool isScaleOrTranslation(const TransformationMatrix& m)
    106111{
    107112    return !m.m12() && !m.m13() && !m.m14()
     
    112117}
    113118
     119void sortLayers(Vector<RefPtr<LayerChromium> >::iterator, Vector<RefPtr<LayerChromium> >::iterator, void*)
     120{
     121    // Currently we don't use z-order to decide what to paint, so there's no need to actually sort LayerChromiums.
     122}
     123
     124void sortLayers(Vector<RefPtr<CCLayerImpl> >::iterator first, Vector<RefPtr<CCLayerImpl> >::iterator end, CCLayerSorter* layerSorter)
     125{
     126    TRACE_EVENT("LayerRendererChromium::sortLayers", 0, 0);
     127    layerSorter->sort(first, end);
     128}
     129
    114130// Recursively walks the layer tree starting at the given node and computes all the
    115131// necessary transformations, scissor rectangles, render surfaces, etc.
    116 void LayerRendererChromium::updatePropertiesAndRenderSurfaces(CCLayerImpl* layer, const TransformationMatrix& parentMatrix, LayerList& renderSurfaceLayerList, LayerList& layerList)
    117 {
     132template<typename LayerType, typename RenderSurfaceType, typename LayerSorter>
     133void calculateDrawTransformsAndVisibility(LayerType* layer, LayerType* rootLayer, const TransformationMatrix& parentMatrix, Vector<RefPtr<LayerType> >& renderSurfaceLayerList, Vector<RefPtr<LayerType> >& layerList, LayerSorter* layerSorter, int maxTextureSize)
     134{
     135    typedef Vector<RefPtr<LayerType> > LayerList;
    118136    // Compute the new matrix transformation that will be applied to this layer and
    119137    // all its children. It's important to remember that the layer's position
     
    173191    bool useSurfaceForMasking = layer->maskLayer();
    174192    bool useSurfaceForReflection = layer->replicaLayer();
    175     bool useSurfaceForFlatDescendants = layer->parent() && layer->parent()->preserves3D() && !layer->preserves3D() && layer->descendantsDrawsContent();
    176     if (useSurfaceForMasking || useSurfaceForReflection || useSurfaceForFlatDescendants || ((useSurfaceForClipping || useSurfaceForOpacity) && layer->descendantsDrawsContent())) {
    177         RenderSurfaceChromium* renderSurface = layer->renderSurface();
    178         if (!renderSurface)
    179             renderSurface = layer->createRenderSurface();
     193    bool useSurfaceForFlatDescendants = layer->parent() && layer->parent()->preserves3D() && !layer->preserves3D() && layer->descendantDrawsContent();
     194    if (useSurfaceForMasking || useSurfaceForReflection || useSurfaceForFlatDescendants || ((useSurfaceForClipping || useSurfaceForOpacity) && layer->descendantDrawsContent())) {
     195        if (!layer->renderSurface())
     196            layer->createRenderSurface();
     197        RenderSurfaceType* renderSurface = layer->renderSurface();
    180198
    181199        // The origin of the new surface is the upper left corner of the layer.
     
    233251        }
    234252
    235         if (layer != m_rootCCLayerImpl.get())
     253        if (layer != rootLayer)
    236254            layer->clearRenderSurface();
    237255
     
    289307
    290308    for (size_t i = 0; i < layer->children().size(); ++i) {
    291         CCLayerImpl* child = layer->children()[i].get();
    292         updatePropertiesAndRenderSurfaces(child, sublayerMatrix, renderSurfaceLayerList, descendants);
     309        LayerType* child = layer->children()[i].get();
     310        calculateDrawTransformsAndVisibility<LayerType, RenderSurfaceType, LayerSorter>(child, rootLayer, sublayerMatrix, renderSurfaceLayerList, descendants, layerSorter, maxTextureSize);
    293311
    294312        if (child->renderSurface()) {
    295             RenderSurfaceChromium* childRenderSurface = child->renderSurface();
     313            RenderSurfaceType* childRenderSurface = child->renderSurface();
    296314            IntRect drawableContentRect = layer->drawableContentRect();
    297315            drawableContentRect.unite(enclosingIntRect(childRenderSurface->drawableContentRect()));
     
    311329    }
    312330
    313     if (layer->renderSurface() && layer != m_rootCCLayerImpl.get()) {
    314         RenderSurfaceChromium* renderSurface = layer->renderSurface();
    315         IntRect renderSurfaceContentRect = layer->drawableContentRect();
    316         FloatPoint surfaceCenter = FloatRect(renderSurfaceContentRect).center();
     331    if (layer->renderSurface() && layer != rootLayer) {
     332        RenderSurfaceType* renderSurface = layer->renderSurface();
     333        IntRect clippedContentRect = layer->drawableContentRect();
     334        FloatPoint surfaceCenter = FloatRect(clippedContentRect).center();
    317335
    318336        // Restrict the RenderSurface size to the portion that's visible.
     
    322340        // clipped.
    323341        if (!layer->replicaLayer()) {
    324             if (!renderSurface->scissorRect().isEmpty() && !renderSurfaceContentRect.isEmpty()) {
    325                 IntRect surfaceScissorRect = calculateVisibleRect(renderSurface->scissorRect(), renderSurfaceContentRect, renderSurface->originTransform());
    326                 renderSurfaceContentRect.intersect(surfaceScissorRect);
     342            if (!renderSurface->scissorRect().isEmpty() && !clippedContentRect.isEmpty()) {
     343                IntRect surfaceScissorRect = calculateVisibleRect(renderSurface->scissorRect(), clippedContentRect, renderSurface->originTransform());
     344                clippedContentRect.intersect(surfaceScissorRect);
    327345            }
    328             FloatPoint clippedSurfaceCenter = FloatRect(renderSurfaceContentRect).center();
     346            FloatPoint clippedSurfaceCenter = FloatRect(clippedContentRect).center();
    329347            centerOffsetDueToClipping = clippedSurfaceCenter - surfaceCenter;
    330348        }
     
    332350        // The RenderSurface backing texture cannot exceed the maximum supported
    333351        // texture size.
    334         renderSurfaceContentRect.setWidth(std::min(renderSurfaceContentRect.width(), m_maxTextureSize));
    335         renderSurfaceContentRect.setHeight(std::min(renderSurfaceContentRect.height(), m_maxTextureSize));
    336 
    337         if (renderSurfaceContentRect.isEmpty())
     352        clippedContentRect.setWidth(min(clippedContentRect.width(), maxTextureSize));
     353        clippedContentRect.setHeight(min(clippedContentRect.height(), maxTextureSize));
     354
     355        if (clippedContentRect.isEmpty())
    338356            renderSurface->clearLayerList();
    339         renderSurface->setContentRect(renderSurfaceContentRect);
     357
     358        renderSurface->setContentRect(clippedContentRect);
    340359
    341360        // Since the layer starts a new render surface we need to adjust its
     
    363382    // skip the sorting as the parent will sort all the descendants anyway.
    364383    if (layer->preserves3D() && (!layer->parent() || !layer->parent()->preserves3D()))
    365         m_layerSorter.sort(&descendants.at(thisLayerIndex), descendants.end());
     384        sortLayers(&descendants.at(thisLayerIndex), descendants.end(), layerSorter);
     385}
     386
    366387}
    367388
     
    550571        return;
    551572
    552     {
    553         TRACE_EVENT("LayerRendererChromium::synchronizeTrees", this, 0);
    554         m_rootCCLayerImpl = TreeSynchronizer::synchronizeTrees(m_rootLayer.get(), m_rootCCLayerImpl.get());
    555     }
    556 
    557     m_computedRenderSurfaceLayerList = adoptPtr(new LayerList());
    558     updateLayers(*m_computedRenderSurfaceLayerList);
     573    updateLayers(m_rootLayer.get());
    559574}
    560575
     
    562577{
    563578    ASSERT(m_hardwareCompositing);
    564     ASSERT(m_computedRenderSurfaceLayerList);
    565579    // Before drawLayers:
    566580    if (hardwareCompositing()) {
     
    576590    }
    577591
     592    {
     593        TRACE_EVENT("LayerRendererChromium::synchronizeTrees", this, 0);
     594        m_rootCCLayerImpl = TreeSynchronizer::synchronizeTrees(m_rootLayer.get(), m_rootCCLayerImpl.get());
     595    }
     596
     597
    578598    m_renderSurfaceTextureManager->setMemoryLimitBytes(textureMemoryHighLimitBytes - m_contentsTextureManager->currentMemoryUseBytes());
    579     drawLayers(*m_computedRenderSurfaceLayerList);
     599    drawLayersInternal();
    580600
    581601    m_contentsTextureManager->unprotectAllTextures();
     
    591611}
    592612
    593 void LayerRendererChromium::updateLayers(LayerList& renderSurfaceLayerList)
     613void LayerRendererChromium::updateLayers(LayerChromium* rootLayer)
    594614{
    595615    TRACE_EVENT("LayerRendererChromium::updateLayers", this, 0);
    596     CCLayerImpl* rootDrawLayer = m_rootLayer->ccLayerImpl();
    597 
    598     if (!rootDrawLayer->renderSurface())
    599         rootDrawLayer->createRenderSurface();
    600     ASSERT(rootDrawLayer->renderSurface());
    601 
    602     rootDrawLayer->renderSurface()->setContentRect(IntRect(IntPoint(0, 0), m_viewportVisibleRect.size()));
     616
     617    if (!rootLayer->renderSurface())
     618        rootLayer->createRenderSurface();
     619    rootLayer->renderSurface()->setContentRect(IntRect(IntPoint(0, 0), m_viewportVisibleRect.size()));
    603620
    604621    IntRect rootScissorRect(m_viewportVisibleRect);
    605622    // The scissorRect should not include the scroll offset.
    606623    rootScissorRect.move(-m_viewportScrollPosition.x(), -m_viewportScrollPosition.y());
    607     rootDrawLayer->setScissorRect(rootScissorRect);
    608 
    609     m_defaultRenderSurface = rootDrawLayer->renderSurface();
    610 
    611     renderSurfaceLayerList.append(rootDrawLayer);
     624    rootLayer->setScissorRect(rootScissorRect);
     625
     626    LayerList renderSurfaceLayerList;
     627    renderSurfaceLayerList.append(rootLayer);
     628
     629    RenderSurfaceChromium* rootRenderSurface = rootLayer->renderSurface();
     630    rootRenderSurface->clearLayerList();
    612631
    613632    TransformationMatrix identityMatrix;
    614     m_defaultRenderSurface->clearLayerList();
    615     // Unfortunately, updatePropertiesAndRenderSurfaces() currently both updates the layers and updates the draw state
    616     // (transforms, etc). It'd be nicer if operations on the presentation layers happened later, but the draw
    617     // transforms are needed by large layers to determine visibility. Tiling will fix this by eliminating the
    618     // concept of a large content layer.
    619     updatePropertiesAndRenderSurfaces(rootDrawLayer, identityMatrix, renderSurfaceLayerList, m_defaultRenderSurface->layerList());
     633
     634    {
     635        TRACE_EVENT("LayerRendererChromium::updateLayers::calcDrawEtc", this, 0);
     636        calculateDrawTransformsAndVisibility<LayerChromium, RenderSurfaceChromium, void*>(rootLayer, rootLayer, identityMatrix, renderSurfaceLayerList, rootRenderSurface->layerList(), 0, m_maxTextureSize);
     637    }
    620638
    621639#ifndef NDEBUG
     
    662680{
    663681    for (int surfaceIndex = renderSurfaceLayerList.size() - 1; surfaceIndex >= 0 ; --surfaceIndex) {
    664         CCLayerImpl* renderSurfaceLayer = renderSurfaceLayerList[surfaceIndex].get();
     682        LayerChromium* renderSurfaceLayer = renderSurfaceLayerList[surfaceIndex].get();
    665683        RenderSurfaceChromium* renderSurface = renderSurfaceLayer->renderSurface();
    666684        ASSERT(renderSurface);
     
    679697            continue;
    680698
    681         LayerList& layerList = renderSurface->layerList();
     699        const LayerList& layerList = renderSurface->layerList();
    682700        ASSERT(layerList.size());
    683701        for (unsigned layerIndex = 0; layerIndex < layerList.size(); ++layerIndex) {
    684             CCLayerImpl* ccLayerImpl = layerList[layerIndex].get();
     702            LayerChromium* layer = layerList[layerIndex].get();
    685703
    686704            // Layers that start a new render surface will be painted when the render
    687705            // surface's list is processed.
    688             if (ccLayerImpl->renderSurface() && ccLayerImpl->renderSurface() != renderSurface)
     706            if (layer->renderSurface() && layer->renderSurface() != renderSurface)
    689707                continue;
    690 
    691             LayerChromium* layer = ccLayerImpl->owner();
    692708
    693709            layer->setLayerRenderer(this);
     
    707723                continue;
    708724
    709             IntRect targetSurfaceRect = ccLayerImpl->targetRenderSurface() ? ccLayerImpl->targetRenderSurface()->contentRect() : m_defaultRenderSurface->contentRect();
    710             if (layer->ccLayerImpl()->usesLayerScissor())
    711                 targetSurfaceRect.intersect(layer->ccLayerImpl()->scissorRect());
    712             IntRect visibleLayerRect = calculateVisibleLayerRect(targetSurfaceRect, layer->bounds(), layer->contentBounds(), ccLayerImpl->drawTransform());
     725            IntRect targetSurfaceRect = layer->targetRenderSurface() ? layer->targetRenderSurface()->contentRect() : m_defaultRenderSurface->contentRect();
     726            if (layer->usesLayerScissor())
     727                targetSurfaceRect.intersect(layer->scissorRect());
     728            IntRect visibleLayerRect = calculateVisibleLayerRect(targetSurfaceRect, layer->bounds(), layer->contentBounds(), layer->drawTransform());
    713729
    714730            paintContentsIfDirty(layer, visibleLayerRect);
     
    729745}
    730746
    731 void LayerRendererChromium::drawLayers(const LayerList& renderSurfaceLayerList)
     747void LayerRendererChromium::drawLayersInternal()
    732748{
    733749    if (m_viewportVisibleRect.isEmpty() || !m_rootLayer)
     
    735751
    736752    TRACE_EVENT("LayerRendererChromium::drawLayers", this, 0);
    737     CCLayerImpl* rootDrawLayer = m_rootLayer->ccLayerImpl();
     753    CCLayerImpl* rootDrawLayer = m_rootCCLayerImpl.get();
    738754    makeContextCurrent();
     755
     756    if (!rootDrawLayer->renderSurface())
     757        rootDrawLayer->createRenderSurface();
     758    rootDrawLayer->renderSurface()->setContentRect(IntRect(IntPoint(0, 0), m_viewportVisibleRect.size()));
     759
     760    IntRect rootScissorRect(m_viewportVisibleRect);
     761    // The scissorRect should not include the scroll offset.
     762    rootScissorRect.move(-m_viewportScrollPosition.x(), -m_viewportScrollPosition.y());
     763    rootDrawLayer->setScissorRect(rootScissorRect);
     764
     765    CCLayerList renderSurfaceLayerList;
     766    renderSurfaceLayerList.append(rootDrawLayer);
     767
     768    TransformationMatrix identityMatrix;
     769    m_defaultRenderSurface = rootDrawLayer->renderSurface();
     770    m_defaultRenderSurface->clearLayerList();
     771
     772    {
     773        TRACE_EVENT("LayerRendererChromium::drawLayersInternal::calcDrawEtc", this, 0);
     774        calculateDrawTransformsAndVisibility<CCLayerImpl, CCRenderSurface, CCLayerSorter>(rootDrawLayer, rootDrawLayer, identityMatrix, renderSurfaceLayerList, m_defaultRenderSurface->layerList(), &m_layerSorter, m_maxTextureSize);
     775    }
    739776
    740777    // The GL viewport covers the entire visible area, including the scrollbars.
     
    775812    for (int surfaceIndex = renderSurfaceLayerList.size() - 1; surfaceIndex >= 0 ; --surfaceIndex) {
    776813        CCLayerImpl* renderSurfaceLayer = renderSurfaceLayerList[surfaceIndex].get();
    777         RenderSurfaceChromium* renderSurface = renderSurfaceLayer->renderSurface();
     814        CCRenderSurface* renderSurface = renderSurfaceLayer->renderSurface();
    778815        ASSERT(renderSurface);
    779816
     
    799836            }
    800837
    801             LayerList& layerList = renderSurface->layerList();
     838            const CCLayerList& layerList = renderSurface->layerList();
    802839            for (unsigned layerIndex = 0; layerIndex < layerList.size(); ++layerIndex)
    803840                drawLayer(layerList[layerIndex].get(), renderSurface);
     
    919956{
    920957    for (int surfaceIndex = renderSurfaceLayerList.size() - 1; surfaceIndex >= 0 ; --surfaceIndex) {
    921         CCLayerImpl* renderSurfaceLayer = renderSurfaceLayerList[surfaceIndex].get();
     958        LayerChromium* renderSurfaceLayer = renderSurfaceLayerList[surfaceIndex].get();
    922959        RenderSurfaceChromium* renderSurface = renderSurfaceLayer->renderSurface();
    923960        ASSERT(renderSurface);
     
    929966        ASSERT(layerList.size());
    930967        for (unsigned layerIndex = 0; layerIndex < layerList.size(); ++layerIndex) {
    931             CCLayerImpl* ccLayerImpl = layerList[layerIndex].get();
    932             if (ccLayerImpl->renderSurface() && ccLayerImpl->renderSurface() != renderSurface)
     968            LayerChromium* layer = layerList[layerIndex].get();
     969            if (layer->renderSurface() && layer->renderSurface() != renderSurface)
    933970                continue;
    934971
    935             updateCompositorResources(ccLayerImpl);
     972            updateCompositorResources(layer);
    936973        }
    937974    }
    938975}
    939976
    940 void LayerRendererChromium::updateCompositorResources(CCLayerImpl* ccLayerImpl)
    941 {
    942     LayerChromium* layer = ccLayerImpl->owner();
    943 
     977void LayerRendererChromium::updateCompositorResources(LayerChromium* layer)
     978{
    944979    if (layer->bounds().isEmpty())
    945980        return;
     
    949984
    950985    if (layer->maskLayer())
    951         updateCompositorResources(ccLayerImpl->maskLayer());
     986        updateCompositorResources(layer->maskLayer());
    952987    if (layer->replicaLayer())
    953         updateCompositorResources(ccLayerImpl->replicaLayer());
     988        updateCompositorResources(layer->replicaLayer());
    954989
    955990    if (layer->drawsContent())
    956991        layer->updateCompositorResources();
    957 
    958     layer->pushPropertiesTo(ccLayerImpl);
    959992}
    960993
     
    966999    m_compositeOffscreen = compositeOffscreen;
    9671000
    968     if (!m_compositeOffscreen && m_rootLayer)
    969         m_rootLayer->ccLayerImpl()->clearRenderSurface();
     1001    if (!m_compositeOffscreen && m_rootCCLayerImpl)
     1002        m_rootCCLayerImpl->clearRenderSurface();
    9701003}
    9711004
    9721005LayerTexture* LayerRendererChromium::getOffscreenLayerTexture()
    9731006{
    974     return m_compositeOffscreen ? m_rootLayer->ccLayerImpl()->renderSurface()->contentsTexture() : 0;
     1007    return m_compositeOffscreen && m_rootCCLayerImpl ? m_rootCCLayerImpl->renderSurface()->contentsTexture() : 0;
    9751008}
    9761009
     
    9891022}
    9901023
    991 bool LayerRendererChromium::useRenderSurface(RenderSurfaceChromium* renderSurface)
     1024bool LayerRendererChromium::useRenderSurface(CCRenderSurface* renderSurface)
    9921025{
    9931026    if (m_currentRenderSurface == renderSurface)
     
    10231056}
    10241057
    1025 void LayerRendererChromium::drawLayer(CCLayerImpl* layer, RenderSurfaceChromium* targetSurface)
     1058void LayerRendererChromium::drawLayer(CCLayerImpl* layer, CCRenderSurface* targetSurface)
    10261059{
    10271060    if (layer->renderSurface() && layer->renderSurface() != targetSurface) {
     
    10491082    } else
    10501083        GLC(m_context.get(), m_context->disable(GraphicsContext3D::SCISSOR_TEST));
    1051 
    10521084
    10531085    if (!layer->doubleSided()) {
     
    11421174    // start while we do other work. Other programs are created lazily on first access.
    11431175    m_sharedGeometry = adoptPtr(new GeometryBinding(m_context.get()));
    1144     m_renderSurfaceProgram = adoptPtr(new RenderSurfaceChromium::Program(m_context.get()));
     1176    m_renderSurfaceProgram = adoptPtr(new CCRenderSurface::Program(m_context.get()));
    11451177    m_tilerProgram = adoptPtr(new LayerTilerChromium::Program(m_context.get()));
    11461178
     
    11741206}
    11751207
    1176 const RenderSurfaceChromium::Program* LayerRendererChromium::renderSurfaceProgram()
     1208const CCRenderSurface::Program* LayerRendererChromium::renderSurfaceProgram()
    11771209{
    11781210    ASSERT(m_renderSurfaceProgram);
     
    11841216}
    11851217
    1186 const RenderSurfaceChromium::MaskProgram* LayerRendererChromium::renderSurfaceMaskProgram()
     1218const CCRenderSurface::MaskProgram* LayerRendererChromium::renderSurfaceMaskProgram()
    11871219{
    11881220    if (!m_renderSurfaceMaskProgram)
    1189         m_renderSurfaceMaskProgram = adoptPtr(new RenderSurfaceChromium::MaskProgram(m_context.get()));
     1221        m_renderSurfaceMaskProgram = adoptPtr(new CCRenderSurface::MaskProgram(m_context.get()));
    11901222    if (!m_renderSurfaceMaskProgram->initialized()) {
    11911223        TRACE_EVENT("LayerRendererChromium::borderProgram::initialize", this, 0);
     
    13401372void LayerRendererChromium::dumpRenderSurfaces(TextStream& ts, int indent, LayerChromium* layer) const
    13411373{
    1342     if (layer->ccLayerImpl()->renderSurface())
    1343         layer->ccLayerImpl()->renderSurface()->dumpSurface(ts, indent);
     1374    if (layer->renderSurface())
     1375        layer->renderSurface()->dumpSurface(ts, indent);
    13441376
    13451377    for (size_t i = 0; i < layer->children().size(); ++i)
  • trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h

    r92206 r92245  
    3939#include "LayerChromium.h"
    4040#include "LayerTilerChromium.h"
    41 #include "RenderSurfaceChromium.h"
    4241#include "SkBitmap.h"
    4342#include "VideoLayerChromium.h"
     
    130129    const LayerChromium::BorderProgram* borderProgram();
    131130    const CCHeadsUpDisplay::Program* headsUpDisplayProgram();
    132     const RenderSurfaceChromium::Program* renderSurfaceProgram();
    133     const RenderSurfaceChromium::MaskProgram* renderSurfaceMaskProgram();
     131    const CCRenderSurface::Program* renderSurfaceProgram();
     132    const CCRenderSurface::MaskProgram* renderSurfaceMaskProgram();
    134133    const LayerTilerChromium::Program* tilerProgram();
    135134    const LayerTilerChromium::ProgramSwizzle* tilerProgramSwizzle();
     
    161160    static bool s_inPaintLayerContents;
    162161#endif
     162    typedef Vector<RefPtr<LayerChromium> > LayerList;
     163    typedef Vector<RefPtr<CCLayerImpl> > CCLayerList;
     164
    163165protected:
    164166    virtual PassOwnPtr<CCLayerTreeHostImplProxy> createLayerTreeHostImplProxy();
    165167
    166168private:
    167     typedef Vector<RefPtr<CCLayerImpl> > LayerList;
    168169    typedef HashMap<GraphicsContext3D*, int> ChildContextMap;
    169170
     
    173174    LayerRendererChromium(CCLayerTreeHostClient*, PassRefPtr<GraphicsContext3D>, PassOwnPtr<LayerPainterChromium> contentPaint, bool accelerateDrawing);
    174175
    175     void updateLayers(LayerList& renderSurfaceLayerList);
     176    void updateLayers(LayerChromium*);
    176177    void updateRootLayerContents();
    177     void updatePropertiesAndRenderSurfaces(CCLayerImpl*, const TransformationMatrix& parentMatrix, LayerList& renderSurfaceLayerList, LayerList& layers);
    178178
    179179    void paintLayerContents(const LayerList&);
    180180    void updateCompositorResources(const LayerList& renderSurfaceLayerList);
    181     void updateCompositorResources(CCLayerImpl*);
    182 
    183     void drawLayers(const LayerList& renderSurfaceLayerList);
    184     void drawLayer(CCLayerImpl*, RenderSurfaceChromium*);
     181    void updateCompositorResources(LayerChromium*);
     182
     183    void drawLayersInternal();
     184    void drawLayer(CCLayerImpl*, CCRenderSurface*);
    185185
    186186    void drawRootLayer();
     
    192192    void setDrawViewportRect(const IntRect&, bool flipY);
    193193
    194     bool useRenderSurface(RenderSurfaceChromium*);
     194    bool useRenderSurface(CCRenderSurface*);
    195195
    196196    bool makeContextCurrent();
     
    220220    OwnPtr<LayerList> m_computedRenderSurfaceLayerList;
    221221
    222     RenderSurfaceChromium* m_currentRenderSurface;
     222    CCRenderSurface* m_currentRenderSurface;
    223223    unsigned m_offscreenFramebufferId;
    224224    bool m_compositeOffscreen;
     
    234234    OwnPtr<LayerChromium::BorderProgram> m_borderProgram;
    235235    OwnPtr<CCHeadsUpDisplay::Program> m_headsUpDisplayProgram;
    236     OwnPtr<RenderSurfaceChromium::Program> m_renderSurfaceProgram;
    237     OwnPtr<RenderSurfaceChromium::MaskProgram> m_renderSurfaceMaskProgram;
    238236    OwnPtr<LayerTilerChromium::Program> m_tilerProgram;
    239237    OwnPtr<LayerTilerChromium::ProgramSwizzle> m_tilerProgramSwizzle;
    240238    OwnPtr<CCCanvasLayerImpl::Program> m_canvasLayerProgram;
     239    OwnPtr<CCPluginLayerImpl::Program> m_pluginLayerProgram;
     240    OwnPtr<CCRenderSurface::MaskProgram> m_renderSurfaceMaskProgram;
     241    OwnPtr<CCRenderSurface::Program> m_renderSurfaceProgram;
    241242    OwnPtr<CCVideoLayerImpl::RGBAProgram> m_videoLayerRGBAProgram;
    242243    OwnPtr<CCVideoLayerImpl::YUVProgram> m_videoLayerYUVProgram;
    243     OwnPtr<CCPluginLayerImpl::Program> m_pluginLayerProgram;
    244244
    245245    OwnPtr<TextureManager> m_contentsTextureManager;
     
    261261    bool m_animating;
    262262
    263     RenderSurfaceChromium* m_defaultRenderSurface;
     263    CCRenderSurface* m_defaultRenderSurface;
    264264
    265265    CCLayerSorter m_layerSorter;
  • trunk/Source/WebCore/platform/graphics/chromium/PluginLayerChromium.cpp

    r86652 r92245  
    5050PassRefPtr<CCLayerImpl> PluginLayerChromium::createCCLayerImpl()
    5151{
    52     return CCPluginLayerImpl::create(this, m_layerId);
     52    return CCPluginLayerImpl::create(m_layerId);
    5353}
    5454
  • trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.cpp

    r91629 r92245  
    3030#include "RenderSurfaceChromium.h"
    3131
    32 #include "cc/CCLayerImpl.h"
    3332#include "GraphicsContext3D.h"
    3433#include "LayerChromium.h"
    3534#include "LayerRendererChromium.h"
    36 #include "LayerTexture.h"
    37 #include "TextStream.h"
    3835#include <wtf/text/CString.h>
    3936
    4037namespace WebCore {
    4138
    42 RenderSurfaceChromium::RenderSurfaceChromium(CCLayerImpl* owningLayer)
     39RenderSurfaceChromium::RenderSurfaceChromium(LayerChromium* owningLayer)
    4340    : m_owningLayer(owningLayer)
    4441    , m_maskLayer(0)
     
    5047RenderSurfaceChromium::~RenderSurfaceChromium()
    5148{
    52     cleanupResources();
    53 }
    54 
    55 void RenderSurfaceChromium::cleanupResources()
    56 {
    57     if (!m_contentsTexture)
    58         return;
    59 
    60     ASSERT(layerRenderer());
    61 
    62     m_contentsTexture.clear();
    6349}
    6450
     
    7864
    7965    return drawableContentRect;
    80 }
    81 
    82 bool RenderSurfaceChromium::prepareContentsTexture()
    83 {
    84     IntSize requiredSize(m_contentRect.size());
    85     TextureManager* textureManager = layerRenderer()->renderSurfaceTextureManager();
    86 
    87     if (!m_contentsTexture)
    88         m_contentsTexture = LayerTexture::create(layerRenderer()->context(), textureManager);
    89 
    90     if (m_contentsTexture->isReserved())
    91         return true;
    92 
    93     if (!m_contentsTexture->reserve(requiredSize, GraphicsContext3D::RGBA)) {
    94         m_skipsDraw = true;
    95         return false;
    96     }
    97 
    98     m_skipsDraw = false;
    99     return true;
    100 }
    101 
    102 void RenderSurfaceChromium::releaseContentsTexture()
    103 {
    104     if (m_skipsDraw || !m_contentsTexture)
    105         return;
    106     m_contentsTexture->unreserve();
    107 }
    108 
    109 void RenderSurfaceChromium::drawSurface(CCLayerImpl* maskLayer, const TransformationMatrix& drawTransform)
    110 {
    111     GraphicsContext3D* context3D = layerRenderer()->context();
    112 
    113     int shaderMatrixLocation = -1;
    114     int shaderAlphaLocation = -1;
    115     const RenderSurfaceChromium::Program* program = layerRenderer()->renderSurfaceProgram();
    116     const RenderSurfaceChromium::MaskProgram* maskProgram = layerRenderer()->renderSurfaceMaskProgram();
    117     ASSERT(program && program->initialized());
    118     bool useMask = false;
    119     if (maskLayer && maskLayer->drawsContent()) {
    120         if (!maskLayer->bounds().isEmpty()) {
    121             context3D->makeContextCurrent();
    122             GLC(context3D, context3D->useProgram(maskProgram->program()));
    123             GLC(context3D, context3D->activeTexture(GraphicsContext3D::TEXTURE0));
    124             GLC(context3D, context3D->uniform1i(maskProgram->fragmentShader().samplerLocation(), 0));
    125             m_contentsTexture->bindTexture();
    126             GLC(context3D, context3D->activeTexture(GraphicsContext3D::TEXTURE1));
    127             GLC(context3D, context3D->uniform1i(maskProgram->fragmentShader().maskSamplerLocation(), 1));
    128             maskLayer->bindContentsTexture();
    129             GLC(context3D, context3D->activeTexture(GraphicsContext3D::TEXTURE0));
    130             shaderMatrixLocation = maskProgram->vertexShader().matrixLocation();
    131             shaderAlphaLocation = maskProgram->fragmentShader().alphaLocation();
    132             useMask = true;
    133         }
    134     }
    135 
    136     if (!useMask) {
    137         GLC(context3D, context3D->useProgram(program->program()));
    138         m_contentsTexture->bindTexture();
    139         GLC(context3D, context3D->uniform1i(program->fragmentShader().samplerLocation(), 0));
    140         shaderMatrixLocation = program->vertexShader().matrixLocation();
    141         shaderAlphaLocation = program->fragmentShader().alphaLocation();
    142     }
    143    
    144     LayerChromium::drawTexturedQuad(layerRenderer()->context(), layerRenderer()->projectionMatrix(), drawTransform,
    145                                         m_contentRect.width(), m_contentRect.height(), m_drawOpacity,
    146                                         shaderMatrixLocation, shaderAlphaLocation);
    147 }
    148 
    149 void RenderSurfaceChromium::draw(const IntRect&)
    150 {
    151     if (m_skipsDraw || !m_contentsTexture)
    152         return;
    153     // FIXME: By using the same RenderSurface for both the content and its reflection,
    154     // it's currently not possible to apply a separate mask to the reflection layer
    155     // or correctly handle opacity in reflections (opacity must be applied after drawing
    156     // both the layer and its reflection). The solution is to introduce yet another RenderSurface
    157     // to draw the layer and its reflection in. For now we only apply a separate reflection
    158     // mask if the contents don't have a mask of their own.
    159     CCLayerImpl* replicaMaskLayer = m_maskLayer;
    160     if (!m_maskLayer && m_owningLayer->replicaLayer())
    161         replicaMaskLayer = m_owningLayer->replicaLayer()->maskLayer();
    162 
    163     if (m_owningLayer->parent() && m_owningLayer->parent()->usesLayerScissor())
    164         layerRenderer()->setScissorToRect(m_scissorRect);
    165     else
    166         GLC(layerRenderer()->context(), layerRenderer()->context()->disable(GraphicsContext3D::SCISSOR_TEST));
    167 
    168 
    169     // Reflection draws before the layer.
    170     if (m_owningLayer->replicaLayer())
    171         drawSurface(replicaMaskLayer, m_replicaDrawTransform);
    172 
    173     drawSurface(m_maskLayer, m_drawTransform);
    174 }
    175 
    176 void RenderSurfaceChromium::clearLayerList()
    177 {
    178     m_layerList.clear();
    17966}
    18067
  • trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h

    r91322 r92245  
    4040namespace WebCore {
    4141
    42 class CCLayerImpl;
     42class LayerChromium;
    4343class LayerRendererChromium;
    4444class LayerTexture;
     
    4747    WTF_MAKE_NONCOPYABLE(RenderSurfaceChromium);
    4848public:
    49     explicit RenderSurfaceChromium(CCLayerImpl*);
     49    explicit RenderSurfaceChromium(LayerChromium*);
    5050    ~RenderSurfaceChromium();
    5151
     
    6161    FloatRect drawableContentRect() const;
    6262
    63     Vector<RefPtr<CCLayerImpl> >& layerList() { return m_layerList; }
    64     void clearLayerList();
    65 
    6663    const IntRect& contentRect() const { return m_contentRect; }
    6764    void setContentRect(const IntRect& contentRect) { m_contentRect = contentRect; }
     
    7269    const TransformationMatrix& drawTransform() const { return m_drawTransform; }
    7370    void setDrawTransform(const TransformationMatrix& drawTransform) { m_drawTransform = drawTransform; }
    74 
    75     CCLayerImpl* maskLayer() const { return m_maskLayer; }
    76     void setMaskLayer(CCLayerImpl* maskLayer) { m_maskLayer = maskLayer; }
    7771
    7872    const TransformationMatrix& originTransform() const { return m_originTransform; }
     
    8882    void setSkipsDraw(bool skipsDraw) { m_skipsDraw = skipsDraw; }
    8983
    90     LayerTexture* contentsTexture() const { return m_contentsTexture.get(); }
     84    void clearLayerList() { m_layerList.clear(); }
     85    Vector<RefPtr<LayerChromium> >& layerList() { return m_layerList; }
    9186
    92     typedef ProgramBinding<VertexShaderPosTex, FragmentShaderRGBATexAlpha> Program;
    93     typedef ProgramBinding<VertexShaderPosTex, FragmentShaderRGBATexAlphaMask> MaskProgram;
     87    void setMaskLayer(LayerChromium* maskLayer) { m_maskLayer = maskLayer; }
    9488
    9589private:
    9690    LayerRendererChromium* layerRenderer();
    97     void drawSurface(CCLayerImpl* maskLayer, const TransformationMatrix& drawTransform);
    9891
    99     CCLayerImpl* m_owningLayer;
    100     CCLayerImpl* m_maskLayer;
     92    LayerChromium* m_owningLayer;
     93    LayerChromium* m_maskLayer;
    10194
    10295    IntRect m_contentRect;
    10396    bool m_skipsDraw;
    10497
    105     OwnPtr<LayerTexture> m_contentsTexture;
    10698    float m_drawOpacity;
    10799    TransformationMatrix m_drawTransform;
     
    109101    TransformationMatrix m_originTransform;
    110102    IntRect m_scissorRect;
    111     Vector<RefPtr<CCLayerImpl> > m_layerList;
     103    Vector<RefPtr<LayerChromium> > m_layerList;
    112104};
    113105
  • trunk/Source/WebCore/platform/graphics/chromium/TiledLayerChromium.cpp

    r90963 r92245  
    6161PassRefPtr<CCLayerImpl> TiledLayerChromium::createCCLayerImpl()
    6262{
    63     return CCTiledLayerImpl::create(this, id());
     63    return CCTiledLayerImpl::create(id());
    6464}
    6565
     
    151151TransformationMatrix TiledLayerChromium::tilingTransform() const
    152152{
    153     TransformationMatrix transform = ccLayerImpl()->drawTransform();
     153    TransformationMatrix transform = drawTransform();
    154154
    155155    if (contentBounds().isEmpty())
  • trunk/Source/WebCore/platform/graphics/chromium/TreeSynchronizer.cpp

    r87868 r92245  
    7575        ccLayerImpl->setReplicaLayer(0);
    7676
    77     layer->setCCLayerImpl(ccLayerImpl.get());
    78 
    7977    layer->pushPropertiesTo(ccLayerImpl.get());
    8078    return ccLayerImpl.release();
  • trunk/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.cpp

    r91584 r92245  
    7070PassRefPtr<CCLayerImpl> VideoLayerChromium::createCCLayerImpl()
    7171{
    72     return CCVideoLayerImpl::create(this, m_layerId);
     72    return CCVideoLayerImpl::create(m_layerId);
    7373}
    7474
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCCanvasLayerImpl.cpp

    r90492 r92245  
    3030#include "cc/CCCanvasLayerImpl.h"
    3131
    32 #include "CanvasLayerChromium.h"
    3332#include "GraphicsContext3D.h"
    3433#include "LayerRendererChromium.h"
     
    3736namespace WebCore {
    3837
    39 CCCanvasLayerImpl::CCCanvasLayerImpl(LayerChromium* owner, int id)
    40     : CCLayerImpl(owner, id)
     38CCCanvasLayerImpl::CCCanvasLayerImpl(int id)
     39    : CCLayerImpl(id)
    4140    , m_textureId(0)
    4241    , m_hasAlpha(true)
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCCanvasLayerImpl.h

    r90492 r92245  
    3535class CCCanvasLayerImpl : public CCLayerImpl {
    3636public:
    37     static PassRefPtr<CCCanvasLayerImpl> create(LayerChromium* owner, int id)
     37    static PassRefPtr<CCCanvasLayerImpl> create(int id)
    3838    {
    39         return adoptRef(new CCCanvasLayerImpl(owner, id));
     39        return adoptRef(new CCCanvasLayerImpl(id));
    4040    }
    4141    virtual ~CCCanvasLayerImpl();
     
    5151    void setPremultipliedAlpha(bool premultipliedAlpha) { m_premultipliedAlpha = premultipliedAlpha; }
    5252private:
    53     CCCanvasLayerImpl(LayerChromium*, int);
     53    explicit CCCanvasLayerImpl(int);
    5454
    5555    unsigned m_textureId;
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.cpp

    r90963 r92245  
    3333#include "LayerChromium.h"
    3434#include "LayerRendererChromium.h"
    35 #include "RenderSurfaceChromium.h"
    3635#include <wtf/text/WTFString.h>
    3736
     
    6160namespace WebCore {
    6261
    63 CCLayerImpl::CCLayerImpl(LayerChromium* owner, int id)
    64     : m_owner(owner)
    65     , m_parent(0)
     62CCLayerImpl::CCLayerImpl(int id)
     63    : m_parent(0)
    6664    , m_layerId(id)
    6765    , m_anchorPoint(0.5, 0.5)
     
    8482CCLayerImpl::~CCLayerImpl()
    8583{
    86     if (m_owner)
    87         m_owner->setCCLayerImpl(0);
    8884}
    8985
     
    123119}
    124120
    125 RenderSurfaceChromium* CCLayerImpl::createRenderSurface()
    126 {
    127     m_renderSurface = adoptPtr(new RenderSurfaceChromium(this));
    128     return m_renderSurface.get();
    129 }
    130 
    131 bool CCLayerImpl::descendantsDrawsContent()
     121void CCLayerImpl::createRenderSurface()
     122{
     123    ASSERT(!m_renderSurface);
     124    m_renderSurface = adoptPtr(new CCRenderSurface(this));
     125}
     126
     127bool CCLayerImpl::descendantDrawsContent()
    132128{
    133129    for (size_t i = 0; i < m_children.size(); ++i) {
    134         if (m_children[i]->drawsContent() || m_children[i]->descendantsDrawsContent())
     130        if (m_children[i]->drawsContent() || m_children[i]->descendantDrawsContent())
    135131            return true;
    136132    }
     
    143139}
    144140
    145 void CCLayerImpl::updateCompositorResources()
    146 {
    147     m_owner->updateCompositorResources();
    148 }
    149 
    150 void CCLayerImpl::unreserveContentsTexture()
    151 {
    152     m_owner->unreserveContentsTexture();
    153 }
    154 
    155141void CCLayerImpl::bindContentsTexture()
    156142{
    157     m_owner->bindContentsTexture();
    158143}
    159144
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerImpl.h

    r90963 r92245  
    3232#include "TextStream.h"
    3333#include "TransformationMatrix.h"
     34#include "cc/CCRenderSurface.h"
    3435#include <wtf/OwnPtr.h>
    3536#include <wtf/PassRefPtr.h>
     
    4142class LayerChromium;
    4243class LayerRendererChromium;
    43 class RenderSurfaceChromium;
    4444
    4545class CCLayerImpl : public RefCounted<CCLayerImpl> {
    4646public:
    47     static PassRefPtr<CCLayerImpl> create(LayerChromium* owner, int id)
     47    static PassRefPtr<CCLayerImpl> create(int id)
    4848    {
    49         return adoptRef(new CCLayerImpl(owner, id));
     49        return adoptRef(new CCLayerImpl(id));
    5050    }
    5151    virtual ~CCLayerImpl();
     
    7171
    7272    virtual void draw();
    73     virtual void updateCompositorResources();
    7473    void unreserveContentsTexture();
    7574    virtual void bindContentsTexture();
     
    8079
    8180    // Returns true if any of the layer's descendants has content to draw.
    82     bool descendantsDrawsContent();
     81    bool descendantDrawsContent();
    8382
    8483    void cleanupResources();
     
    125124    LayerRendererChromium* layerRenderer() const { return m_layerRenderer.get(); }
    126125
    127     RenderSurfaceChromium* createRenderSurface();
    128 
    129     RenderSurfaceChromium* renderSurface() const { return m_renderSurface.get(); }
     126    CCRenderSurface* renderSurface() const { return m_renderSurface.get(); }
     127    void createRenderSurface();
    130128    void clearRenderSurface() { m_renderSurface.clear(); }
    131129
     
    135133    const IntRect& scissorRect() const { return m_scissorRect; }
    136134    void setScissorRect(const IntRect& rect) { m_scissorRect = rect; }
    137 
    138     RenderSurfaceChromium* targetRenderSurface() const { return m_targetRenderSurface; }
    139     void setTargetRenderSurface(RenderSurfaceChromium* surface) { m_targetRenderSurface = surface; }
     135    CCRenderSurface* targetRenderSurface() const { return m_targetRenderSurface; }
     136    void setTargetRenderSurface(CCRenderSurface* surface) { m_targetRenderSurface = surface; }
    140137
    141138    const IntSize& bounds() const { return m_bounds; }
     
    161158    virtual void dumpLayerProperties(TextStream&, int indent) const;
    162159
    163     // HACK TODO fix this
    164     LayerChromium* owner() const { return m_owner; }
    165     void clearOwner() { m_owner = 0; }
    166 
    167160protected:
    168     // For now, CCLayerImpls have a back pointer to their LayerChromium.
    169     // FIXME: remove this after https://bugs.webkit.org/show_bug.cgi?id=58833 is fixed.
    170     LayerChromium* m_owner;
    171     CCLayerImpl(LayerChromium*, int);
     161    explicit CCLayerImpl(int);
    172162
    173163    static void writeIndent(TextStream&, int indent);
     
    217207    // to an ancestor of this layer. The target render surface determines the
    218208    // coordinate system the layer's transforms are relative to.
    219     RenderSurfaceChromium* m_targetRenderSurface;
     209    CCRenderSurface* m_targetRenderSurface;
    220210
    221211    // The global depth value of the center of the layer. This value is used
     
    237227    // Render surface associated with this layer. The layer and its descendants
    238228    // will render to this surface.
    239     OwnPtr<RenderSurfaceChromium> m_renderSurface;
     229    OwnPtr<CCRenderSurface> m_renderSurface;
    240230
    241231    // Hierarchical bounding rect containing the layer and its descendants.
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerSorter.cpp

    r90872 r92245  
    2727#include "cc/CCLayerSorter.h"
    2828
    29 #include "RenderSurfaceChromium.h"
    3029#include "TransformationMatrix.h"
     30#include "cc/CCRenderSurface.h"
    3131#include <limits.h>
    3232
     
    279279        m_nodes.append(GraphNode(it->get()));
    280280        GraphNode& node = m_nodes.at(m_nodes.size() - 1);
    281         RenderSurfaceChromium* renderSurface = node.layer->renderSurface();
     281        CCRenderSurface* renderSurface = node.layer->renderSurface();
    282282        if (!node.layer->drawsContent() && !renderSurface)
    283283            continue;
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCPluginLayerImpl.cpp

    r90492 r92245  
    3232#include "GraphicsContext3D.h"
    3333#include "LayerRendererChromium.h"
    34 #include "PluginLayerChromium.h"
    3534#include <wtf/text/WTFString.h>
    3635
    3736namespace WebCore {
    3837
    39 CCPluginLayerImpl::CCPluginLayerImpl(LayerChromium* owner, int id)
    40     : CCLayerImpl(owner, id)
     38CCPluginLayerImpl::CCPluginLayerImpl(int id)
     39    : CCLayerImpl(id)
    4140    , m_textureId(0)
    4241{
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCPluginLayerImpl.h

    r90492 r92245  
    3535class CCPluginLayerImpl : public CCLayerImpl {
    3636public:
    37     static PassRefPtr<CCPluginLayerImpl> create(LayerChromium* owner, int id)
     37    static PassRefPtr<CCPluginLayerImpl> create(int id)
    3838    {
    39         return adoptRef(new CCPluginLayerImpl(owner, id));
     39        return adoptRef(new CCPluginLayerImpl(id));
    4040    }
    4141    virtual ~CCPluginLayerImpl();
     
    5050
    5151private:
    52     CCPluginLayerImpl(LayerChromium*, int);
     52    explicit CCPluginLayerImpl(int);
    5353
    5454    unsigned m_textureId;
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.cpp

    r92244 r92245  
    11/*
    2  * Copyright (C) 2010 Google Inc. All rights reserved.
     2 * Copyright (C) 2011 Google Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2828#if USE(ACCELERATED_COMPOSITING)
    2929
    30 #include "RenderSurfaceChromium.h"
    31 
    32 #include "cc/CCLayerImpl.h"
     30#include "cc/CCRenderSurface.h"
     31
    3332#include "GraphicsContext3D.h"
    3433#include "LayerChromium.h"
     
    3635#include "LayerTexture.h"
    3736#include "TextStream.h"
     37#include "cc/CCLayerImpl.h"
    3838#include <wtf/text/CString.h>
    3939
    4040namespace WebCore {
    4141
    42 RenderSurfaceChromium::RenderSurfaceChromium(CCLayerImpl* owningLayer)
     42CCRenderSurface::CCRenderSurface(CCLayerImpl* owningLayer)
    4343    : m_owningLayer(owningLayer)
    4444    , m_maskLayer(0)
     
    4848}
    4949
    50 RenderSurfaceChromium::~RenderSurfaceChromium()
     50CCRenderSurface::~CCRenderSurface()
    5151{
    5252    cleanupResources();
    5353}
    5454
    55 void RenderSurfaceChromium::cleanupResources()
     55void CCRenderSurface::cleanupResources()
    5656{
    5757    if (!m_contentsTexture)
     
    6363}
    6464
    65 LayerRendererChromium* RenderSurfaceChromium::layerRenderer()
     65LayerRendererChromium* CCRenderSurface::layerRenderer()
    6666{
    6767    ASSERT(m_owningLayer);
     
    6969}
    7070
    71 FloatRect RenderSurfaceChromium::drawableContentRect() const
     71FloatRect CCRenderSurface::drawableContentRect() const
    7272{
    7373    FloatRect localContentRect(-0.5 * m_contentRect.width(), -0.5 * m_contentRect.height(),
     
    8080}
    8181
    82 bool RenderSurfaceChromium::prepareContentsTexture()
     82bool CCRenderSurface::prepareContentsTexture()
    8383{
    8484    IntSize requiredSize(m_contentRect.size());
     
    100100}
    101101
    102 void RenderSurfaceChromium::releaseContentsTexture()
     102void CCRenderSurface::releaseContentsTexture()
    103103{
    104104    if (m_skipsDraw || !m_contentsTexture)
     
    107107}
    108108
    109 void RenderSurfaceChromium::drawSurface(CCLayerImpl* maskLayer, const TransformationMatrix& drawTransform)
     109
     110void CCRenderSurface::drawSurface(CCLayerImpl* maskLayer, const TransformationMatrix& drawTransform)
    110111{
    111112    GraphicsContext3D* context3D = layerRenderer()->context();
     
    113114    int shaderMatrixLocation = -1;
    114115    int shaderAlphaLocation = -1;
    115     const RenderSurfaceChromium::Program* program = layerRenderer()->renderSurfaceProgram();
    116     const RenderSurfaceChromium::MaskProgram* maskProgram = layerRenderer()->renderSurfaceMaskProgram();
     116    const CCRenderSurface::Program* program = layerRenderer()->renderSurfaceProgram();
     117    const CCRenderSurface::MaskProgram* maskProgram = layerRenderer()->renderSurfaceMaskProgram();
    117118    ASSERT(program && program->initialized());
    118119    bool useMask = false;
     
    141142        shaderAlphaLocation = program->fragmentShader().alphaLocation();
    142143    }
    143    
     144
    144145    LayerChromium::drawTexturedQuad(layerRenderer()->context(), layerRenderer()->projectionMatrix(), drawTransform,
    145146                                        m_contentRect.width(), m_contentRect.height(), m_drawOpacity,
     
    147148}
    148149
    149 void RenderSurfaceChromium::draw(const IntRect&)
     150void CCRenderSurface::draw(const IntRect&)
    150151{
    151152    if (m_skipsDraw || !m_contentsTexture)
     
    166167        GLC(layerRenderer()->context(), layerRenderer()->context()->disable(GraphicsContext3D::SCISSOR_TEST));
    167168
    168 
    169169    // Reflection draws before the layer.
    170170    if (m_owningLayer->replicaLayer())
     
    174174}
    175175
    176 void RenderSurfaceChromium::clearLayerList()
    177 {
    178     m_layerList.clear();
    179 }
    180 
    181 String RenderSurfaceChromium::name() const
    182 {
    183     return String::format("RenderSurface(id=%d,owner=%s)", m_owningLayer->id(), m_owningLayer->name().utf8().data());
     176String CCRenderSurface::name() const
     177{
     178    return String::format("RenderSurface(id=%i,owner=%s)", m_owningLayer->id(), m_owningLayer->name().utf8().data());
    184179}
    185180
     
    190185}
    191186
    192 void RenderSurfaceChromium::dumpSurface(TextStream& ts, int indent) const
     187void CCRenderSurface::dumpSurface(TextStream& ts, int indent) const
    193188{
    194189    writeIndent(ts, indent);
     
    199194}
    200195
     196int CCRenderSurface::owningLayerId() const
     197{
     198    return m_owningLayer ? m_owningLayer->id() : 0;
     199}
     200
    201201}
    202202#endif // USE(ACCELERATED_COMPOSITING)
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCRenderSurface.h

    r92244 r92245  
    11/*
    2  * Copyright (C) 2010 Google Inc. All rights reserved.
     2 * Copyright (C) 2011 Google Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2525
    2626
    27 #ifndef RenderSurfaceChromium_h
    28 #define RenderSurfaceChromium_h
     27#ifndef CCRenderSurface_h
     28#define CCRenderSurface_h
    2929
    3030#if USE(ACCELERATED_COMPOSITING)
     
    4444class LayerTexture;
    4545
    46 class RenderSurfaceChromium {
    47     WTF_MAKE_NONCOPYABLE(RenderSurfaceChromium);
     46class CCRenderSurface {
     47    WTF_MAKE_NONCOPYABLE(CCRenderSurface);
    4848public:
    49     explicit RenderSurfaceChromium(CCLayerImpl*);
    50     ~RenderSurfaceChromium();
     49    explicit CCRenderSurface(CCLayerImpl*);
     50    ~CCRenderSurface();
    5151
    5252    bool prepareContentsTexture();
     
    5858    void dumpSurface(TextStream&, int indent) const;
    5959
     60    FloatPoint contentRectCenter() const { return FloatRect(m_contentRect).center(); }
     61
    6062    // Returns the rect that encloses the RenderSurface including any reflection.
    6163    FloatRect drawableContentRect() const;
    6264
     65    float drawOpacity() const { return m_drawOpacity; }
     66    void setDrawOpacity(float opacity) { m_drawOpacity = opacity; }
     67
     68    void setDrawTransform(const TransformationMatrix& drawTransform) { m_drawTransform = drawTransform; }
     69    const TransformationMatrix& drawTransform() const { return m_drawTransform; }
     70
     71    void setReplicaDrawTransform(const TransformationMatrix& replicaDrawTransform) { m_replicaDrawTransform = replicaDrawTransform; }
     72    const TransformationMatrix& replicaDrawTransform() const { return m_replicaDrawTransform; }
     73
     74    void setOriginTransform(const TransformationMatrix& originTransform) { m_originTransform = originTransform; }
     75    const TransformationMatrix& originTransform() const { return m_originTransform; }
     76
     77    void setScissorRect(const IntRect& scissorRect) { m_scissorRect = scissorRect; }
     78    const IntRect& scissorRect() const { return m_scissorRect; }
     79
     80    void setContentRect(const IntRect& contentRect) { m_contentRect = contentRect; }
     81    const IntRect& contentRect() const { return m_contentRect; }
     82
     83    void setSkipsDraw(bool skipsDraw) { m_skipsDraw = skipsDraw; }
     84    bool skipsDraw() const { return m_skipsDraw; }
     85
     86    void clearLayerList() { m_layerList.clear(); }
    6387    Vector<RefPtr<CCLayerImpl> >& layerList() { return m_layerList; }
    64     void clearLayerList();
    6588
    66     const IntRect& contentRect() const { return m_contentRect; }
    67     void setContentRect(const IntRect& contentRect) { m_contentRect = contentRect; }
    68 
    69     float drawOpacity() const { return m_drawOpacity; }
    70     void setDrawOpacity(float drawOpacity) { m_drawOpacity = drawOpacity; }
    71 
    72     const TransformationMatrix& drawTransform() const { return m_drawTransform; }
    73     void setDrawTransform(const TransformationMatrix& drawTransform) { m_drawTransform = drawTransform; }
    74 
    75     CCLayerImpl* maskLayer() const { return m_maskLayer; }
    7689    void setMaskLayer(CCLayerImpl* maskLayer) { m_maskLayer = maskLayer; }
    77 
    78     const TransformationMatrix& originTransform() const { return m_originTransform; }
    79     void setOriginTransform(const TransformationMatrix& originTransform) { m_originTransform = originTransform; }
    80 
    81     const TransformationMatrix& replicaDrawTransform() const { return m_replicaDrawTransform; }
    82     void setReplicaDrawTransform(const TransformationMatrix& replicaDrawTransform) { m_replicaDrawTransform = replicaDrawTransform; }
    83 
    84     const IntRect& scissorRect() const { return m_scissorRect; }
    85     void setScissorRect(const IntRect& scissorRect) { m_scissorRect = scissorRect; }
    86 
    87     bool skipsDraw() const { return m_skipsDraw; }
    88     void setSkipsDraw(bool skipsDraw) { m_skipsDraw = skipsDraw; }
    89 
    90     LayerTexture* contentsTexture() const { return m_contentsTexture.get(); }
    9190
    9291    typedef ProgramBinding<VertexShaderPosTex, FragmentShaderRGBATexAlpha> Program;
    9392    typedef ProgramBinding<VertexShaderPosTex, FragmentShaderRGBATexAlphaMask> MaskProgram;
    9493
     94    LayerTexture* contentsTexture() const { return m_contentsTexture.get(); }
     95
     96    int owningLayerId() const;
    9597private:
    9698    LayerRendererChromium* layerRenderer();
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.cpp

    r90963 r92245  
    3030#include "cc/CCTiledLayerImpl.h"
    3131
    32 #include "ContentLayerChromium.h"
    33 
    3432#include <wtf/text/WTFString.h>
    3533
     
    3836class LayerTexture;
    3937
    40 CCTiledLayerImpl::CCTiledLayerImpl(LayerChromium* owner, int id)
    41     : CCLayerImpl(owner, id)
     38CCTiledLayerImpl::CCTiledLayerImpl(int id)
     39    : CCLayerImpl(id)
    4240    , m_tiler(0)
    4341{
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCTiledLayerImpl.h

    r90963 r92245  
    3434class CCTiledLayerImpl : public CCLayerImpl {
    3535public:
    36     static PassRefPtr<CCTiledLayerImpl> create(LayerChromium* owner, int id)
     36    static PassRefPtr<CCTiledLayerImpl> create(int id)
    3737    {
    38         return adoptRef(new CCTiledLayerImpl(owner, id));
     38        return adoptRef(new CCTiledLayerImpl(id));
    3939    }
    4040    virtual ~CCTiledLayerImpl();
     
    4949
    5050private:
    51     CCTiledLayerImpl(LayerChromium*, int id);
     51    explicit CCTiledLayerImpl(int id);
    5252
    5353    TransformationMatrix m_tilingTransform;
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.cpp

    r90492 r92245  
    6060};
    6161
    62 CCVideoLayerImpl::CCVideoLayerImpl(LayerChromium* owner, int id)
    63     : CCLayerImpl(owner, id)
     62CCVideoLayerImpl::CCVideoLayerImpl(int id)
     63    : CCLayerImpl(id)
    6464{
    6565}
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.h

    r90492 r92245  
    3939class CCVideoLayerImpl : public CCLayerImpl {
    4040public:
    41     static PassRefPtr<CCVideoLayerImpl> create(LayerChromium* owner, int id)
     41    static PassRefPtr<CCVideoLayerImpl> create(int id)
    4242    {
    43         return adoptRef(new CCVideoLayerImpl(owner, id));
     43        return adoptRef(new CCVideoLayerImpl(id));
    4444    }
    4545    virtual ~CCVideoLayerImpl();
     
    5757
    5858private:
    59     CCVideoLayerImpl(LayerChromium*, int);
     59    explicit CCVideoLayerImpl(int);
    6060
    6161    void drawYUV(const YUVProgram*) const;
  • trunk/Source/WebKit/chromium/tests/TreeSynchronizerTest.cpp

    r87868 r92245  
    3737class MockCCLayerImpl : public CCLayerImpl {
    3838public:
    39     static PassRefPtr<MockCCLayerImpl> create(LayerChromium* owner, int layerId)
    40     {
    41         return adoptRef(new MockCCLayerImpl(owner, layerId));
     39    static PassRefPtr<MockCCLayerImpl> create(int layerId)
     40    {
     41        return adoptRef(new MockCCLayerImpl(layerId));
    4242    }
    4343    virtual ~MockCCLayerImpl()
     
    5050
    5151private:
    52     MockCCLayerImpl(LayerChromium* owner, int layerId)
    53         : CCLayerImpl(owner, layerId)
     52    MockCCLayerImpl(int layerId)
     53        : CCLayerImpl(layerId)
    5454        , m_ccLayerDestructionList(0)
    5555    {
     
    7070    virtual PassRefPtr<CCLayerImpl> createCCLayerImpl()
    7171    {
    72         return MockCCLayerImpl::create(this, m_layerId);
     72        return MockCCLayerImpl::create(m_layerId);
    7373    }
    7474
Note: See TracChangeset for help on using the changeset viewer.