Changeset 79659 in webkit


Ignore:
Timestamp:
Feb 24, 2011 7:20:12 PM (13 years ago)
Author:
jamesr@google.com
Message:

2011-02-24 James Robinson <jamesr@chromium.org>

Reviewed by Kenneth Russell.

[chromium] Move draw time properties out of *LayerChromium to CCLayerImpl
https://bugs.webkit.org/show_bug.cgi?id=55013

This adds a new type (tentatively named CCLayerImpl) responsible for drawing/compositing layers.
Currently LayerChromiums know about their CCLayerImpls and CCLayerImpls rely on the LayerChromium
tree for structure. In theory updates are a LayerChromium-only concept and draw is a CCLayerImpl-only
concept, but this patch doesn't go all there yet in the interest of keeping the patch small-ish.

RenderSurfaces are a CCLayerImpl-only concepts and no longer have any direct LayerChromium dependencies.

Note: I've put CCLayerImpl into a new 'cc' directory under platform/graphics/chromium/ and intentionally
not added it to the include path. We plan to add more compositor implementation details to this directory
and we want to keep accidental dependencies on these files to a minimum.

See https://bugs.webkit.org/show_bug.cgi?id=54047 for the big picture.

Refactor only, compositing/ tests cover these codepaths.

  • WebCore.gypi:
  • platform/graphics/chromium/CanvasLayerChromium.cpp: (WebCore::CanvasLayerChromium::draw):
  • platform/graphics/chromium/ContentLayerChromium.cpp: (WebCore::ContentLayerChromium::requiresClippedUpdateRect): (WebCore::ContentLayerChromium::updateContentsIfDirty): (WebCore::ContentLayerChromium::draw):
  • platform/graphics/chromium/LayerChromium.cpp: (WebCore::LayerChromium::LayerChromium): (WebCore::LayerChromium::cleanupResources): (WebCore::LayerChromium::setLayerRenderer): (WebCore::LayerChromium::setBounds): (WebCore::LayerChromium::setFrame): (WebCore::LayerChromium::setNeedsDisplay): (WebCore::LayerChromium::setBorderColor): (WebCore::LayerChromium::borderColor): (WebCore::LayerChromium::setBorderWidth): (WebCore::LayerChromium::borderWidth): (WebCore::LayerChromium::layerRenderer): (WebCore::LayerChromium::setDoubleSided): (WebCore::LayerChromium::bounds):
  • platform/graphics/chromium/LayerChromium.h: (WebCore::LayerChromium::maskDrawLayer): (WebCore::LayerChromium::ccLayerImpl):
  • platform/graphics/chromium/LayerRendererChromium.cpp: (WebCore::LayerRendererChromium::compareLayerZ): (WebCore::LayerRendererChromium::drawLayers): (WebCore::LayerRendererChromium::updateLayersRecursive): (WebCore::LayerRendererChromium::setCompositeOffscreen): (WebCore::LayerRendererChromium::getOffscreenLayerTexture): (WebCore::LayerRendererChromium::drawLayer):
  • platform/graphics/chromium/LayerRendererChromium.h:
  • platform/graphics/chromium/PluginLayerChromium.cpp: (WebCore::PluginLayerChromium::draw):
  • platform/graphics/chromium/RenderSurfaceChromium.cpp: (WebCore::RenderSurfaceChromium::RenderSurfaceChromium): (WebCore::RenderSurfaceChromium::drawSurface): (WebCore::RenderSurfaceChromium::draw):
  • platform/graphics/chromium/RenderSurfaceChromium.h:
  • platform/graphics/chromium/VideoLayerChromium.cpp: (WebCore::VideoLayerChromium::drawYUV): (WebCore::VideoLayerChromium::drawRGBA):
  • platform/graphics/chromium/cc/CCLayerImpl.cpp: Added. (WebCore::CCLayerImpl::CCLayerImpl): (WebCore::CCLayerImpl::~CCLayerImpl): (WebCore::CCLayerImpl::superlayer): (WebCore::CCLayerImpl::maskLayer): (WebCore::CCLayerImpl::replicaLayer): (WebCore::CCLayerImpl::setLayerRenderer): (WebCore::CCLayerImpl::createRenderSurface): (WebCore::CCLayerImpl::updateContentsIfDirty): (WebCore::CCLayerImpl::drawsContent): (WebCore::CCLayerImpl::draw): (WebCore::CCLayerImpl::unreserveContentsTexture): (WebCore::CCLayerImpl::bindContentsTexture): (WebCore::CCLayerImpl::cleanupResources): (WebCore::CCLayerImpl::getDrawRect): (WebCore::CCLayerImpl::drawDebugBorder):
  • platform/graphics/chromium/cc/CCLayerImpl.h: Added. (WebCore::CCLayerImpl::create): (WebCore::CCLayerImpl::setDebugBorderColor): (WebCore::CCLayerImpl::debugBorderColor): (WebCore::CCLayerImpl::setDebugBorderWidth): (WebCore::CCLayerImpl::debugBorderWidth): (WebCore::CCLayerImpl::layerRenderer): (WebCore::CCLayerImpl::renderSurface): (WebCore::CCLayerImpl::clearRenderSurface): (WebCore::CCLayerImpl::drawDepth): (WebCore::CCLayerImpl::setDrawDepth): (WebCore::CCLayerImpl::drawOpacity): (WebCore::CCLayerImpl::setDrawOpacity): (WebCore::CCLayerImpl::scissorRect): (WebCore::CCLayerImpl::setScissorRect): (WebCore::CCLayerImpl::targetRenderSurface): (WebCore::CCLayerImpl::setTargetRenderSurface): (WebCore::CCLayerImpl::doubleSided): (WebCore::CCLayerImpl::setDoubleSided): (WebCore::CCLayerImpl::bounds): (WebCore::CCLayerImpl::setBounds): (WebCore::CCLayerImpl::drawTransform): (WebCore::CCLayerImpl::setDrawTransform): (WebCore::CCLayerImpl::drawableContentRect): (WebCore::CCLayerImpl::setDrawableContentRect):
Location:
trunk/Source/WebCore
Files:
3 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r79656 r79659  
     12011-02-24  James Robinson  <jamesr@chromium.org>
     2
     3        Reviewed by Kenneth Russell.
     4
     5        [chromium] Move draw time properties out of *LayerChromium to CCLayerImpl
     6        https://bugs.webkit.org/show_bug.cgi?id=55013
     7
     8        This adds a new type (tentatively named CCLayerImpl) responsible for drawing/compositing layers.
     9        Currently LayerChromiums know about their CCLayerImpls and CCLayerImpls rely on the LayerChromium
     10        tree for structure.  In theory updates are a LayerChromium-only concept and draw is a CCLayerImpl-only
     11        concept, but this patch doesn't go all there yet in the interest of keeping the patch small-ish.
     12
     13        RenderSurfaces are a CCLayerImpl-only concepts and no longer have any direct LayerChromium dependencies.
     14
     15        Note: I've put CCLayerImpl into a new 'cc' directory under platform/graphics/chromium/ and intentionally
     16        not added it to the include path.  We plan to add more compositor implementation details to this directory
     17        and we want to keep accidental dependencies on these files to a minimum.
     18
     19        See https://bugs.webkit.org/show_bug.cgi?id=54047 for the big picture.
     20
     21        Refactor only, compositing/ tests cover these codepaths.
     22
     23        * WebCore.gypi:
     24        * platform/graphics/chromium/CanvasLayerChromium.cpp:
     25        (WebCore::CanvasLayerChromium::draw):
     26        * platform/graphics/chromium/ContentLayerChromium.cpp:
     27        (WebCore::ContentLayerChromium::requiresClippedUpdateRect):
     28        (WebCore::ContentLayerChromium::updateContentsIfDirty):
     29        (WebCore::ContentLayerChromium::draw):
     30        * platform/graphics/chromium/LayerChromium.cpp:
     31        (WebCore::LayerChromium::LayerChromium):
     32        (WebCore::LayerChromium::cleanupResources):
     33        (WebCore::LayerChromium::setLayerRenderer):
     34        (WebCore::LayerChromium::setBounds):
     35        (WebCore::LayerChromium::setFrame):
     36        (WebCore::LayerChromium::setNeedsDisplay):
     37        (WebCore::LayerChromium::setBorderColor):
     38        (WebCore::LayerChromium::borderColor):
     39        (WebCore::LayerChromium::setBorderWidth):
     40        (WebCore::LayerChromium::borderWidth):
     41        (WebCore::LayerChromium::layerRenderer):
     42        (WebCore::LayerChromium::setDoubleSided):
     43        (WebCore::LayerChromium::bounds):
     44        * platform/graphics/chromium/LayerChromium.h:
     45        (WebCore::LayerChromium::maskDrawLayer):
     46        (WebCore::LayerChromium::ccLayerImpl):
     47        * platform/graphics/chromium/LayerRendererChromium.cpp:
     48        (WebCore::LayerRendererChromium::compareLayerZ):
     49        (WebCore::LayerRendererChromium::drawLayers):
     50        (WebCore::LayerRendererChromium::updateLayersRecursive):
     51        (WebCore::LayerRendererChromium::setCompositeOffscreen):
     52        (WebCore::LayerRendererChromium::getOffscreenLayerTexture):
     53        (WebCore::LayerRendererChromium::drawLayer):
     54        * platform/graphics/chromium/LayerRendererChromium.h:
     55        * platform/graphics/chromium/PluginLayerChromium.cpp:
     56        (WebCore::PluginLayerChromium::draw):
     57        * platform/graphics/chromium/RenderSurfaceChromium.cpp:
     58        (WebCore::RenderSurfaceChromium::RenderSurfaceChromium):
     59        (WebCore::RenderSurfaceChromium::drawSurface):
     60        (WebCore::RenderSurfaceChromium::draw):
     61        * platform/graphics/chromium/RenderSurfaceChromium.h:
     62        * platform/graphics/chromium/VideoLayerChromium.cpp:
     63        (WebCore::VideoLayerChromium::drawYUV):
     64        (WebCore::VideoLayerChromium::drawRGBA):
     65        * platform/graphics/chromium/cc/CCLayerImpl.cpp: Added.
     66        (WebCore::CCLayerImpl::CCLayerImpl):
     67        (WebCore::CCLayerImpl::~CCLayerImpl):
     68        (WebCore::CCLayerImpl::superlayer):
     69        (WebCore::CCLayerImpl::maskLayer):
     70        (WebCore::CCLayerImpl::replicaLayer):
     71        (WebCore::CCLayerImpl::setLayerRenderer):
     72        (WebCore::CCLayerImpl::createRenderSurface):
     73        (WebCore::CCLayerImpl::updateContentsIfDirty):
     74        (WebCore::CCLayerImpl::drawsContent):
     75        (WebCore::CCLayerImpl::draw):
     76        (WebCore::CCLayerImpl::unreserveContentsTexture):
     77        (WebCore::CCLayerImpl::bindContentsTexture):
     78        (WebCore::CCLayerImpl::cleanupResources):
     79        (WebCore::CCLayerImpl::getDrawRect):
     80        (WebCore::CCLayerImpl::drawDebugBorder):
     81        * platform/graphics/chromium/cc/CCLayerImpl.h: Added.
     82        (WebCore::CCLayerImpl::create):
     83        (WebCore::CCLayerImpl::setDebugBorderColor):
     84        (WebCore::CCLayerImpl::debugBorderColor):
     85        (WebCore::CCLayerImpl::setDebugBorderWidth):
     86        (WebCore::CCLayerImpl::debugBorderWidth):
     87        (WebCore::CCLayerImpl::layerRenderer):
     88        (WebCore::CCLayerImpl::renderSurface):
     89        (WebCore::CCLayerImpl::clearRenderSurface):
     90        (WebCore::CCLayerImpl::drawDepth):
     91        (WebCore::CCLayerImpl::setDrawDepth):
     92        (WebCore::CCLayerImpl::drawOpacity):
     93        (WebCore::CCLayerImpl::setDrawOpacity):
     94        (WebCore::CCLayerImpl::scissorRect):
     95        (WebCore::CCLayerImpl::setScissorRect):
     96        (WebCore::CCLayerImpl::targetRenderSurface):
     97        (WebCore::CCLayerImpl::setTargetRenderSurface):
     98        (WebCore::CCLayerImpl::doubleSided):
     99        (WebCore::CCLayerImpl::setDoubleSided):
     100        (WebCore::CCLayerImpl::bounds):
     101        (WebCore::CCLayerImpl::setBounds):
     102        (WebCore::CCLayerImpl::drawTransform):
     103        (WebCore::CCLayerImpl::setDrawTransform):
     104        (WebCore::CCLayerImpl::drawableContentRect):
     105        (WebCore::CCLayerImpl::setDrawableContentRect):
     106
    11072011-02-24  Dan Bernstein  <mitz@apple.com>
    2108
  • trunk/Source/WebCore/WebCore.gypi

    r79616 r79659  
    25982598            'platform/graphics/chromium/FontUtilsChromiumWin.cpp',
    25992599            'platform/graphics/chromium/FontUtilsChromiumWin.h',
     2600            'platform/graphics/chromium/GLES2Canvas.cpp',
     2601            'platform/graphics/chromium/GLES2Canvas.h',
    26002602            'platform/graphics/chromium/GeometryBinding.cpp',
    26012603            'platform/graphics/chromium/GeometryBinding.h',
    2602             'platform/graphics/chromium/GLES2Canvas.cpp',
    2603             'platform/graphics/chromium/GLES2Canvas.h',
    26042604            'platform/graphics/chromium/GlyphPageTreeNodeChromiumWin.cpp',
    26052605            'platform/graphics/chromium/GraphicsLayerChromium.cpp',
     
    26272627            'platform/graphics/chromium/ProgramBinding.cpp',
    26282628            'platform/graphics/chromium/ProgramBinding.h',
     2629            'platform/graphics/chromium/RenderSurfaceChromium.cpp',
    26292630            'platform/graphics/chromium/RenderSurfaceChromium.h',
    2630             'platform/graphics/chromium/RenderSurfaceChromium.cpp',
    26312631            'platform/graphics/chromium/ShaderChromium.cpp',
    26322632            'platform/graphics/chromium/ShaderChromium.h',
     
    26412641            'platform/graphics/chromium/UniscribeHelperTextRun.cpp',
    26422642            'platform/graphics/chromium/UniscribeHelperTextRun.h',
     2643            'platform/graphics/chromium/VDMXParser.cpp',
     2644            'platform/graphics/chromium/VDMXParser.h',
    26432645            'platform/graphics/chromium/VideoFrameChromium.cpp',
    26442646            'platform/graphics/chromium/VideoFrameChromium.h',
    26452647            'platform/graphics/chromium/VideoLayerChromium.cpp',
    26462648            'platform/graphics/chromium/VideoLayerChromium.h',
    2647             'platform/graphics/chromium/VDMXParser.cpp',
    2648             'platform/graphics/chromium/VDMXParser.h',
    26492649            'platform/graphics/chromium/WebGLLayerChromium.cpp',
    26502650            'platform/graphics/chromium/WebGLLayerChromium.h',
     2651            'platform/graphics/chromium/cc/CCLayerImpl.cpp',
     2652            'platform/graphics/chromium/cc/CCLayerImpl.h',
    26512653            'platform/graphics/cocoa/FontPlatformData.h',
    26522654            'platform/graphics/cocoa/FontPlatformDataCocoa.mm',
  • trunk/Source/WebCore/platform/graphics/chromium/CanvasLayerChromium.cpp

    r79043 r79659  
    3535#include "CanvasLayerChromium.h"
    3636
     37#include "cc/CCLayerImpl.h"
    3738#include "GraphicsContext3D.h"
    3839#include "LayerRendererChromium.h"
     
    6364    layerRenderer()->useShader(program->program());
    6465    GLC(context, context->uniform1i(program->fragmentShader().samplerLocation(), 0));
    65     drawTexturedQuad(context, layerRenderer()->projectionMatrix(), drawTransform(),
    66                      bounds().width(), bounds().height(), drawOpacity(),
     66    drawTexturedQuad(context, layerRenderer()->projectionMatrix(), ccLayerImpl()->drawTransform(),
     67                     bounds().width(), bounds().height(), ccLayerImpl()->drawOpacity(),
    6768                     program->vertexShader().matrixLocation(),
    6869                     program->fragmentShader().alphaLocation());
    69 
    7070}
    7171
  • trunk/Source/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp

    r79578 r79659  
    3535#include "ContentLayerChromium.h"
    3636
     37#include "cc/CCLayerImpl.h"
    3738#include "GraphicsContext3D.h"
    3839#include "LayerRendererChromium.h"
     
    8081    // surface it's rendering into. This is a temporary measure until layer tiling is implemented.
    8182    static const int maxLayerSize = 2000;
    82     return (bounds().width() > max(maxLayerSize, m_targetRenderSurface->contentRect().width())
    83             || bounds().height() > max(maxLayerSize, m_targetRenderSurface->contentRect().height())
     83    return (bounds().width() > max(maxLayerSize, ccLayerImpl()->targetRenderSurface()->contentRect().width())
     84            || bounds().height() > max(maxLayerSize, ccLayerImpl()->targetRenderSurface()->contentRect().height())
    8485            || !layerRenderer()->checkTextureSize(bounds()));
    8586}
     
    104105        // of texels to be repainted, so ignore these layers until tiling is
    105106        // implemented.
    106         if (!drawTransform().isIdentityOrTranslation()) {
     107        if (!ccLayerImpl()->drawTransform().isIdentityOrTranslation()) {
    107108            m_skipsDraw = true;
    108109            return;
     
    110111
    111112        // Calculate the region of this layer that is currently visible.
    112         const IntRect clipRect = m_targetRenderSurface->contentRect();
    113 
    114         TransformationMatrix layerOriginTransform = drawTransform();
     113        const IntRect clipRect = ccLayerImpl()->targetRenderSurface()->contentRect();
     114
     115        TransformationMatrix layerOriginTransform = ccLayerImpl()->drawTransform();
    115116        layerOriginTransform.translate3d(-0.5 * bounds().width(), -0.5 * bounds().height(), 0);
    116117
     
    342343
    343344    if (requiresClippedUpdateRect()) {
    344         float m43 = drawTransform().m43();
     345        float m43 = ccLayerImpl()->drawTransform().m43();
    345346        TransformationMatrix transform;
    346347        transform.translate3d(m_layerCenterInSurfaceCoords.x(), m_layerCenterInSurfaceCoords.y(), m43);
    347348        drawTexturedQuad(context, layerRenderer()->projectionMatrix(),
    348349                         transform, m_visibleRectInLayerCoords.width(),
    349                          m_visibleRectInLayerCoords.height(), drawOpacity(),
     350                         m_visibleRectInLayerCoords.height(), ccLayerImpl()->drawOpacity(),
    350351                         program->vertexShader().matrixLocation(),
    351352                         program->fragmentShader().alphaLocation());
    352353    } else {
    353354        drawTexturedQuad(context, layerRenderer()->projectionMatrix(),
    354                          drawTransform(), bounds().width(), bounds().height(),
    355                          drawOpacity(), program->vertexShader().matrixLocation(),
     355                         ccLayerImpl()->drawTransform(), bounds().width(), bounds().height(),
     356                         ccLayerImpl()->drawOpacity(), program->vertexShader().matrixLocation(),
    356357                         program->fragmentShader().alphaLocation());
    357358    }
  • trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp

    r79578 r79659  
    3535#include "LayerChromium.h"
    3636
     37#include "cc/CCLayerImpl.h"
    3738#include "GraphicsContext3D.h"
    3839#include "LayerRendererChromium.h"
     
    5859    , m_contentsDirty(false)
    5960    , m_maskLayer(0)
    60     , m_targetRenderSurface(0)
    6161    , m_superlayer(0)
    6262    , m_anchorPoint(0.5, 0.5)
    6363    , m_backgroundColor(0, 0, 0, 0)
    64     , m_borderColor(0, 0, 0, 0)
    6564    , m_opacity(1.0)
    6665    , m_zPosition(0.0)
    6766    , m_anchorPointZ(0)
    68     , m_borderWidth(0)
    6967    , m_clearsContext(false)
    70     , m_doubleSided(true)
    7168    , m_hidden(false)
    7269    , m_masksToBounds(false)
     
    7471    , m_geometryFlipped(false)
    7572    , m_needsDisplayOnBoundsChange(false)
    76     , m_drawDepth(0)
    77     , m_layerRenderer(0)
    78     , m_renderSurface(0)
     73    , m_ccLayerImpl(CCLayerImpl::create(this))
    7974    , m_replicaLayer(0)
    8075{
     
    9388void LayerChromium::cleanupResources()
    9489{
    95     if (m_renderSurface)
    96         m_renderSurface->cleanupResources();
     90    m_ccLayerImpl->cleanupResources();
    9791}
    9892
     
    106100    }
    107101
    108     m_layerRenderer = renderer;
    109 }
    110 
    111 RenderSurfaceChromium* LayerChromium::createRenderSurface()
    112 {
    113     m_renderSurface = new RenderSurfaceChromium(this);
    114     return m_renderSurface.get();
     102    m_ccLayerImpl->setLayerRenderer(renderer);
    115103}
    116104
     
    189177void LayerChromium::setBounds(const IntSize& size)
    190178{
    191     if (m_bounds == size)
    192         return;
    193 
    194     bool firstResize = !m_bounds.width() && !m_bounds.height() && size.width() && size.height();
    195 
    196     m_bounds = size;
     179    if (bounds() == size)
     180        return;
     181
     182    bool firstResize = !bounds().width() && !bounds().height() && size.width() && size.height();
     183
     184    m_ccLayerImpl->setBounds(size);
    197185
    198186    if (firstResize)
    199         setNeedsDisplay(FloatRect(0, 0, m_bounds.width(), m_bounds.height()));
     187        setNeedsDisplay(FloatRect(0, 0, bounds().width(), bounds().height()));
    200188    else
    201189        setNeedsCommit();
     
    208196
    209197    m_frame = rect;
    210     setNeedsDisplay(FloatRect(0, 0, m_bounds.width(), m_bounds.height()));
     198    setNeedsDisplay(FloatRect(0, 0, bounds().width(), bounds().height()));
    211199}
    212200
     
    257245{
    258246    m_dirtyRect.setLocation(FloatPoint());
    259     m_dirtyRect.setSize(m_bounds);
     247    m_dirtyRect.setSize(bounds());
    260248    m_contentsDirty = true;
    261249    setNeedsCommit();
     
    316304}
    317305
    318 void LayerChromium::drawDebugBorder()
    319 {
    320     static float glMatrix[16];
    321     if (!borderColor().alpha())
    322         return;
    323 
    324     ASSERT(layerRenderer());
    325     const BorderProgram* program = layerRenderer()->borderProgram();
    326     ASSERT(program && program->initialized());
    327     layerRenderer()->useShader(program->program());
    328     TransformationMatrix renderMatrix = drawTransform();
    329     renderMatrix.scale3d(bounds().width(), bounds().height(), 1);
    330     toGLMatrix(&glMatrix[0], layerRenderer()->projectionMatrix() * renderMatrix);
    331     GraphicsContext3D* context = layerRendererContext();
    332     GLC(context, context->uniformMatrix4fv(program->vertexShader().matrixLocation(), false, &glMatrix[0], 1));
    333 
    334     GLC(context, context->uniform4f(program->fragmentShader().colorLocation(), borderColor().red() / 255.0, borderColor().green() / 255.0, borderColor().blue() / 255.0, 1));
    335 
    336     GLC(context, context->lineWidth(borderWidth()));
    337 
    338     // The indices for the line are stored in the same array as the triangle indices.
    339     GLC(context, context->drawElements(GraphicsContext3D::LINE_LOOP, 4, GraphicsContext3D::UNSIGNED_SHORT, 6 * sizeof(unsigned short)));
    340 }
    341 
    342 const IntRect LayerChromium::getDrawRect() const
    343 {
    344     // Form the matrix used by the shader to map the corners of the layer's
    345     // bounds into the view space.
    346     FloatRect layerRect(-0.5 * bounds().width(), -0.5 * bounds().height(), bounds().width(), bounds().height());
    347     IntRect mappedRect = enclosingIntRect(drawTransform().mapRect(layerRect));
    348     return mappedRect;
    349 }
     306
    350307
    351308// Returns true if any of the layer's descendants has drawable content.
     
    372329}
    373330
     331// Begin calls that forward to the CCLayerImpl.
     332// ==============================================
     333// These exists just for debugging (via drawDebugBorder()).
     334void LayerChromium::setBorderColor(const Color& color)
     335{
     336    m_ccLayerImpl->setDebugBorderColor(color);
     337    setNeedsCommit();
     338}
     339
     340Color LayerChromium::borderColor() const
     341{
     342    return m_ccLayerImpl->debugBorderColor();
     343}
     344
     345void LayerChromium::setBorderWidth(float width)
     346{
     347    m_ccLayerImpl->setDebugBorderWidth(width);
     348    setNeedsCommit();
     349}
     350
     351float LayerChromium::borderWidth() const
     352{
     353    return m_ccLayerImpl->debugBorderWidth();
     354}
     355
     356LayerRendererChromium* LayerChromium::layerRenderer() const
     357{
     358    return m_ccLayerImpl->layerRenderer();
     359}
     360
     361void LayerChromium::setDoubleSided(bool doubleSided)
     362{
     363    m_ccLayerImpl->setDoubleSided(doubleSided);
     364    setNeedsCommit();
     365}
     366
     367const IntSize& LayerChromium::bounds() const
     368{
     369    return m_ccLayerImpl->bounds();
     370}
     371// ==============================================
     372// End calls that forward to the CCLayerImpl.
     373
    374374}
    375375#endif // USE(ACCELERATED_COMPOSITING)
  • trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.h

    r79043 r79659  
    4343#include "ShaderChromium.h"
    4444#include "TransformationMatrix.h"
     45
    4546#include <wtf/OwnPtr.h>
    4647#include <wtf/PassRefPtr.h>
     
    5657namespace WebCore {
    5758
     59class CCLayerImpl;
    5860class GraphicsContext3D;
    5961class LayerRendererChromium;
     
    6264// this class.
    6365class LayerChromium : public RefCounted<LayerChromium> {
    64     friend class LayerRendererChromium;
     66    friend class LayerTilerChromium;
    6567public:
    6668    static PassRefPtr<LayerChromium> create(GraphicsLayerChromium* owner = 0);
     
    8789    Color backgroundColor() const { return m_backgroundColor; }
    8890
    89     void setBorderColor(const Color& color) { m_borderColor = color; setNeedsCommit(); }
    90     Color borderColor() const { return m_borderColor; }
    91 
    92     void setBorderWidth(float width) { m_borderWidth = width; setNeedsCommit(); }
    93     float borderWidth() const { return m_borderWidth; }
    94 
    95     void setBounds(const IntSize&);
    96     IntSize bounds() const { return m_bounds; }
    97 
    9891    void setClearsContext(bool clears) { m_clearsContext = clears; setNeedsCommit(); }
    9992    bool clearsContext() const { return m_clearsContext; }
    10093
    101     void setDoubleSided(bool doubleSided) { m_doubleSided = doubleSided; setNeedsCommit(); }
    102     bool doubleSided() const { return m_doubleSided; }
    103 
    10494    void setFrame(const FloatRect&);
    10595    FloatRect frame() const { return m_frame; }
     
    115105
    116106    void setMaskLayer(LayerChromium* maskLayer) { m_maskLayer = maskLayer; }
     107    CCLayerImpl* maskDrawLayer() const { return m_maskLayer ? m_maskLayer->ccLayerImpl() : 0; }
    117108    LayerChromium* maskLayer() const { return m_maskLayer.get(); }
    118109
     
    146137    bool geometryFlipped() const { return m_geometryFlipped; }
    147138
    148     const TransformationMatrix& drawTransform() const { return m_drawTransform; }
    149     float drawOpacity() const { return m_drawOpacity; }
    150 
    151139    bool preserves3D() { return m_owner && m_owner->preserves3D(); }
    152140
     
    155143    virtual void setLayerRenderer(LayerRendererChromium*);
    156144
     145    // Returns true if any of the layer's descendants has content to draw.
     146    bool descendantsDrawContent();
     147
    157148    void setOwner(GraphicsLayerChromium* owner) { m_owner = owner; }
    158149
    159150    void setReplicaLayer(LayerChromium* layer) { m_replicaLayer = layer; }
    160151    LayerChromium* replicaLayer() { return m_replicaLayer; }
    161 
    162     // Returns the rect containtaining this layer in the current view's coordinate system.
    163     const IntRect getDrawRect() const;
    164152
    165153    // These methods typically need to be overwritten by derived classes.
     
    170158    virtual void draw() { }
    171159
    172     void drawDebugBorder();
    173 
    174     RenderSurfaceChromium* createRenderSurface();
    175 
    176     LayerRendererChromium* layerRenderer() const { return m_layerRenderer.get(); }
    177 
    178     static void toGLMatrix(float*, const TransformationMatrix&);
     160    // These exists just for debugging (via drawDebugBorder()).
     161    void setBorderColor(const Color&);
     162    Color borderColor() const;
     163
     164    void setBorderWidth(float);
     165    float borderWidth() const;
     166
     167    // Everything from here down in the public section will move to CCLayerImpl.
     168
     169    CCLayerImpl* ccLayerImpl() const { return m_ccLayerImpl.get(); }
    179170
    180171    static void drawTexturedQuad(GraphicsContext3D*, const TransformationMatrix& projectionMatrix, const TransformationMatrix& layerMatrix,
     
    182173                                 int matrixLocation, int alphaLocation);
    183174
     175    // Begin calls that forward to the CCLayerImpl.
     176    LayerRendererChromium* layerRenderer() const;
     177    void setDoubleSided(bool);
     178    void setBounds(const IntSize&);
     179    const IntSize& bounds() const;
     180    // End calls that forward to the CCLayerImpl.
     181
    184182    typedef ProgramBinding<VertexShaderPos, FragmentShaderColor> BorderProgram;
    185183protected:
    186184    GraphicsLayerChromium* m_owner;
    187     LayerChromium(GraphicsLayerChromium* owner);
     185    explicit LayerChromium(GraphicsLayerChromium* owner);
    188186
    189187    // This is called to clean up resources being held in the same context as
     
    194192    GraphicsContext3D* layerRendererContext() const;
    195193
    196     // Returns true if any of the layer's descendants has content to draw.
    197     bool descendantsDrawContent();
    198 
    199     IntSize m_bounds;
     194    static void toGLMatrix(float*, const TransformationMatrix&);
     195
    200196    FloatRect m_dirtyRect;
    201197    bool m_contentsDirty;
     
    203199    RefPtr<LayerChromium> m_maskLayer;
    204200
    205     // Render surface this layer draws into. This is a surface that can belong
    206     // either to this layer (if m_targetRenderSurface == m_renderSurface) or
    207     // to an ancestor of this layer. The target render surface determines the
    208     // coordinate system the layer's transforms are relative to.
    209     RenderSurfaceChromium* m_targetRenderSurface;
     201    // All layer shaders share the same attribute locations for the vertex positions
     202    // and texture coordinates. This allows switching shaders without rebinding attribute
     203    // arrays.
     204    static const unsigned s_positionAttribLocation;
     205    static const unsigned s_texCoordAttribLocation;
    210206
    211207private:
     
    234230    FloatPoint m_anchorPoint;
    235231    Color m_backgroundColor;
    236     Color m_borderColor;
    237232    float m_opacity;
    238233    float m_zPosition;
    239234    float m_anchorPointZ;
    240     float m_borderWidth;
    241     float m_drawOpacity;
    242235    bool m_clearsContext;
    243     bool m_doubleSided;
    244236    bool m_hidden;
    245237    bool m_masksToBounds;
     
    248240    bool m_needsDisplayOnBoundsChange;
    249241
    250     // The global depth value of the center of the layer. This value is used
    251     // to sort layers from back to front.
    252     float m_drawDepth;
    253 
    254     // Points to the layer renderer that updates and draws this layer.
    255     RefPtr<LayerRendererChromium> m_layerRenderer;
    256 
    257     FloatRect m_frame;
    258242    TransformationMatrix m_transform;
    259243    TransformationMatrix m_sublayerTransform;
    260     TransformationMatrix m_drawTransform;
    261 
    262     // The scissor rectangle that should be used when this layer is drawn.
    263     // Inherited by the parent layer and further restricted if this layer masks
    264     // to bounds.
    265     IntRect m_scissorRect;
    266 
    267     // Render surface associated with this layer. The layer and its descendants
    268     // will render to this surface.
    269     OwnPtr<RenderSurfaceChromium> m_renderSurface;
    270 
    271     // Hierarchical bounding rect containing the layer and its descendants.
    272     IntRect m_drawableContentRect;
     244
     245    FloatRect m_frame;
     246    // For now, the LayerChromium directly owns its CCLayerImpl.
     247    RefPtr<CCLayerImpl> m_ccLayerImpl;
    273248
    274249    // Replica layer used for reflections.
  • trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp

    r79578 r79659  
    4343#include "TextureManager.h"
    4444#include "WebGLLayerChromium.h"
     45#include "cc/CCLayerImpl.h"
    4546#if USE(SKIA)
    4647#include "NativeImageSkia.h"
     
    8485}
    8586
    86 bool LayerRendererChromium::compareLayerZ(const LayerChromium* a, const LayerChromium* b)
    87 {
    88     return a->m_drawDepth < b->m_drawDepth;
     87bool LayerRendererChromium::compareLayerZ(const CCLayerImpl* a, const CCLayerImpl* b)
     88{
     89    return a->drawDepth() < b->drawDepth();
    8990}
    9091
     
    221222    int visibleRectHeight = visibleRect.height();
    222223
    223     if (!m_rootLayer->m_renderSurface)
    224         m_rootLayer->createRenderSurface();
    225     m_rootLayer->m_renderSurface->m_contentRect = IntRect(0, 0, visibleRectWidth, visibleRectHeight);
     224    if (!m_rootLayer->ccLayerImpl()->renderSurface())
     225        m_rootLayer->ccLayerImpl()->createRenderSurface();
     226    m_rootLayer->ccLayerImpl()->renderSurface()->m_contentRect = IntRect(0, 0, visibleRectWidth, visibleRectHeight);
    226227
    227228    if (visibleRectWidth != m_rootLayerTextureWidth || visibleRectHeight != m_rootLayerTextureHeight) {
     
    249250    m_scrollPosition = scrollPosition;
    250251
    251     ASSERT(m_rootLayer->m_renderSurface);
    252     m_defaultRenderSurface = m_rootLayer->m_renderSurface.get();
     252    ASSERT(m_rootLayer->ccLayerImpl()->renderSurface());
     253    m_defaultRenderSurface = m_rootLayer->ccLayerImpl()->renderSurface();
    253254
    254255    useRenderSurface(m_defaultRenderSurface);
     
    280281    // The scissorRect should not include the scroll offset.
    281282    rootScissorRect.move(-m_scrollPosition.x(), -m_scrollPosition.y());
    282     m_rootLayer->m_scissorRect = rootScissorRect;
    283 
    284     Vector<LayerChromium*> renderSurfaceLayerList;
    285     renderSurfaceLayerList.append(m_rootLayer.get());
     283    m_rootLayer->ccLayerImpl()->setScissorRect(rootScissorRect);
     284
     285    Vector<CCLayerImpl*> renderSurfaceLayerList;
     286    renderSurfaceLayerList.append(m_rootLayer->ccLayerImpl());
    286287
    287288    TransformationMatrix identityMatrix;
     
    299300    // correct order.
    300301    for (int surfaceIndex = renderSurfaceLayerList.size() - 1; surfaceIndex >= 0 ; --surfaceIndex) {
    301         LayerChromium* renderSurfaceLayer = renderSurfaceLayerList[surfaceIndex];
    302         ASSERT(renderSurfaceLayer->m_renderSurface);
     302        CCLayerImpl* renderSurfaceLayer = renderSurfaceLayerList[surfaceIndex];
     303        ASSERT(renderSurfaceLayer->renderSurface());
    303304
    304305        // Render surfaces whose drawable area has zero width or height
    305306        // will have no layers associated with them and should be skipped.
    306         if (!renderSurfaceLayer->m_renderSurface->m_layerList.size())
     307        if (!renderSurfaceLayer->renderSurface()->m_layerList.size())
    307308            continue;
    308309
    309         if (useRenderSurface(renderSurfaceLayer->m_renderSurface.get())) {
    310             if (renderSurfaceLayer != m_rootLayer) {
     310        if (useRenderSurface(renderSurfaceLayer->renderSurface())) {
     311            if (renderSurfaceLayer != m_rootLayer->ccLayerImpl()) {
    311312                GLC(m_context.get(), m_context->disable(GraphicsContext3D::SCISSOR_TEST));
    312313                GLC(m_context.get(), m_context->clearColor(0, 0, 0, 0));
     
    315316            }
    316317
    317             Vector<LayerChromium*>& layerList = renderSurfaceLayer->m_renderSurface->m_layerList;
     318            Vector<CCLayerImpl*>& layerList = renderSurfaceLayer->renderSurface()->m_layerList;
    318319            ASSERT(layerList.size());
    319320            for (unsigned layerIndex = 0; layerIndex < layerList.size(); ++layerIndex)
    320                 drawLayer(layerList[layerIndex], renderSurfaceLayer->m_renderSurface.get());
     321                drawLayer(layerList[layerIndex], renderSurfaceLayer->renderSurface());
    321322        }
    322323    }
     
    408409// Recursively walks the layer tree starting at the given node and computes all the
    409410// necessary transformations, scissor rectangles, render surfaces, etc.
    410 void LayerRendererChromium::updateLayersRecursive(LayerChromium* layer, const TransformationMatrix& parentMatrix, Vector<LayerChromium*>& renderSurfaceLayerList, Vector<LayerChromium*>& layerList)
     411void LayerRendererChromium::updateLayersRecursive(LayerChromium* layer, const TransformationMatrix& parentMatrix, Vector<CCLayerImpl*>& renderSurfaceLayerList, Vector<CCLayerImpl*>& layerList)
    411412{
    412413    layer->setLayerRenderer(this);
     414    CCLayerImpl* drawLayer = layer->ccLayerImpl();
    413415
    414416    // Compute the new matrix transformation that will be applied to this layer and
     
    467469    if (((useSurfaceForClipping || useSurfaceForOpacity) && layer->descendantsDrawContent())
    468470        || useSurfaceForMasking || useSurfaceForReflection) {
    469         RenderSurfaceChromium* renderSurface = layer->m_renderSurface.get();
     471        RenderSurfaceChromium* renderSurface = drawLayer->renderSurface();
    470472        if (!renderSurface)
    471             renderSurface = layer->createRenderSurface();
     473            renderSurface = drawLayer->createRenderSurface();
    472474
    473475        // The origin of the new surface is the upper left corner of the layer.
    474         layer->m_drawTransform = TransformationMatrix();
    475         layer->m_drawTransform.translate3d(0.5 * bounds.width(), 0.5 * bounds.height(), 0);
     476        TransformationMatrix drawTransform;;
     477        drawTransform.translate3d(0.5 * bounds.width(), 0.5 * bounds.height(), 0);
     478        drawLayer->setDrawTransform(drawTransform);
    476479
    477480        transformedLayerRect = IntRect(0, 0, bounds.width(), bounds.height());
     
    480483        renderSurface->m_drawOpacity = layer->opacity();
    481484        if (layer->superlayer()->preserves3D())
    482             renderSurface->m_drawOpacity *= layer->superlayer()->drawOpacity();
    483         layer->m_drawOpacity = 1;
     485            renderSurface->m_drawOpacity *= drawLayer->superlayer()->drawOpacity();
     486        drawLayer->setDrawOpacity(1);
    484487
    485488        TransformationMatrix layerOriginTransform = combinedTransform;
     
    489492            TransformationMatrix parentToLayer = layerOriginTransform.inverse();
    490493
    491             layer->m_scissorRect = parentToLayer.mapRect(layer->superlayer()->m_scissorRect);
     494            drawLayer->setScissorRect(parentToLayer.mapRect(drawLayer->superlayer()->scissorRect()));
    492495        } else
    493             layer->m_scissorRect = IntRect();
     496            drawLayer->setScissorRect(IntRect());
    494497
    495498        // The render surface scissor rect is the scissor rect that needs to
    496499        // be applied before drawing the render surface onto its containing
    497500        // surface and is therefore expressed in the superlayer's coordinate system.
    498         renderSurface->m_scissorRect = layer->superlayer()->m_scissorRect;
     501        renderSurface->m_scissorRect = drawLayer->superlayer()->scissorRect();
    499502
    500503        renderSurface->m_layerList.clear();
    501504
    502         if (layer->maskLayer()) {
    503             renderSurface->m_maskLayer = layer->maskLayer();
    504             layer->maskLayer()->setLayerRenderer(this);
    505             layer->maskLayer()->m_targetRenderSurface = renderSurface;
     505        if (layer->maskDrawLayer()) {
     506            renderSurface->m_maskLayer = layer->maskDrawLayer();
     507            layer->maskDrawLayer()->setLayerRenderer(this);
     508            layer->maskDrawLayer()->setTargetRenderSurface(renderSurface);
    506509        } else
    507510            renderSurface->m_maskLayer = 0;
    508511
    509         if (layer->replicaLayer() && layer->replicaLayer()->maskLayer()) {
    510             layer->replicaLayer()->maskLayer()->setLayerRenderer(this);
    511             layer->replicaLayer()->maskLayer()->m_targetRenderSurface = renderSurface;
     512        if (layer->replicaLayer() && layer->replicaLayer()->maskDrawLayer()) {
     513            layer->replicaLayer()->maskDrawLayer()->setLayerRenderer(this);
     514            layer->replicaLayer()->maskDrawLayer()->setTargetRenderSurface(renderSurface);
    512515        }
    513516
    514         renderSurfaceLayerList.append(layer);
     517        renderSurfaceLayerList.append(drawLayer);
    515518    } else {
    516519        // DT = M[p] * LT
    517         layer->m_drawTransform = combinedTransform;
    518         transformedLayerRect = enclosingIntRect(layer->m_drawTransform.mapRect(layerRect));
    519 
    520         layer->m_drawOpacity = layer->opacity();
     520        drawLayer->setDrawTransform(combinedTransform);
     521        transformedLayerRect = enclosingIntRect(drawLayer->drawTransform().mapRect(layerRect));
     522
     523        drawLayer->setDrawOpacity(layer->opacity());
    521524
    522525        if (layer->superlayer()) {
    523526            if (layer->superlayer()->preserves3D())
    524                layer->m_drawOpacity *= layer->superlayer()->m_drawOpacity;
     527               drawLayer->setDrawOpacity(drawLayer->drawOpacity() * drawLayer->superlayer()->drawOpacity());
    525528
    526529            // Layers inherit the scissor rect from their superlayer.
    527             layer->m_scissorRect = layer->superlayer()->m_scissorRect;
    528 
    529             layer->m_targetRenderSurface = layer->superlayer()->m_targetRenderSurface;
     530            drawLayer->setScissorRect(drawLayer->superlayer()->scissorRect());
     531
     532            drawLayer->setTargetRenderSurface(drawLayer->superlayer()->targetRenderSurface());
    530533        }
    531534
    532535        if (layer != m_rootLayer)
    533             layer->m_renderSurface = 0;
    534 
    535         if (layer->masksToBounds())
    536             layer->m_scissorRect.intersect(transformedLayerRect);
    537     }
    538 
    539     if (layer->m_renderSurface)
    540         layer->m_targetRenderSurface = layer->m_renderSurface.get();
     536            drawLayer->clearRenderSurface();
     537
     538        if (layer->masksToBounds()) {
     539            IntRect scissor = drawLayer->scissorRect();
     540            scissor.intersect(transformedLayerRect);
     541            drawLayer->setScissorRect(scissor);
     542        }
     543    }
     544
     545    if (drawLayer->renderSurface())
     546        drawLayer->setTargetRenderSurface(drawLayer->renderSurface());
    541547    else {
    542548        ASSERT(layer->superlayer());
    543         layer->m_targetRenderSurface = layer->superlayer()->m_targetRenderSurface;
     549        drawLayer->setTargetRenderSurface(drawLayer->superlayer()->targetRenderSurface());
    544550    }
    545551
    546552    // m_drawableContentRect is always stored in the coordinate system of the
    547553    // RenderSurface the layer draws into.
    548     if (layer->drawsContent())
    549         layer->m_drawableContentRect = transformedLayerRect;
     554    if (drawLayer->drawsContent())
     555        drawLayer->setDrawableContentRect(transformedLayerRect);
    550556    else
    551         layer->m_drawableContentRect = IntRect();
    552 
    553     TransformationMatrix sublayerMatrix = layer->m_drawTransform;
     557        drawLayer->setDrawableContentRect(IntRect());
     558
     559    TransformationMatrix sublayerMatrix = drawLayer->drawTransform();
    554560
    555561    // Flatten to 2D if the layer doesn't preserve 3D.
     
    572578    sublayerMatrix.translate3d(-bounds.width() * 0.5, -bounds.height() * 0.5, 0);
    573579
    574     Vector<LayerChromium*>& descendants = (layer->m_renderSurface ? layer->m_renderSurface->m_layerList : layerList);
    575     descendants.append(layer);
     580    Vector<CCLayerImpl*>& descendants = (drawLayer->renderSurface() ? drawLayer->renderSurface()->m_layerList : layerList);
     581    descendants.append(drawLayer);
    576582    unsigned thisLayerIndex = descendants.size() - 1;
    577583
    578584    const Vector<RefPtr<LayerChromium> >& sublayers = layer->getSublayers();
    579585    for (size_t i = 0; i < sublayers.size(); ++i) {
    580         LayerChromium* sublayer = sublayers[i].get();
    581         updateLayersRecursive(sublayer, sublayerMatrix, renderSurfaceLayerList, descendants);
    582 
    583         if (sublayer->m_renderSurface) {
    584             RenderSurfaceChromium* sublayerRenderSurface = sublayer->m_renderSurface.get();
    585             layer->m_drawableContentRect.unite(enclosingIntRect(sublayerRenderSurface->drawableContentRect()));
     586        CCLayerImpl* sublayer = sublayers[i]->ccLayerImpl();
     587        updateLayersRecursive(sublayers[i].get(), sublayerMatrix, renderSurfaceLayerList, descendants);
     588
     589        if (sublayer->renderSurface()) {
     590            RenderSurfaceChromium* sublayerRenderSurface = sublayer->renderSurface();
     591            IntRect drawableContentRect = drawLayer->drawableContentRect();
     592            drawableContentRect.unite(enclosingIntRect(sublayerRenderSurface->drawableContentRect()));
     593            drawLayer->setDrawableContentRect(drawableContentRect);
    586594            descendants.append(sublayer);
    587         } else
    588             layer->m_drawableContentRect.unite(sublayer->m_drawableContentRect);
    589     }
    590 
    591     if (layer->masksToBounds() || useSurfaceForMasking)
    592         layer->m_drawableContentRect.intersect(transformedLayerRect);
    593 
    594     if (layer->m_renderSurface && layer != m_rootLayer) {
    595         RenderSurfaceChromium* renderSurface = layer->m_renderSurface.get();
    596         renderSurface->m_contentRect = layer->m_drawableContentRect;
     595        } else {
     596            IntRect drawableContentRect = drawLayer->drawableContentRect();
     597            drawableContentRect.unite(sublayer->drawableContentRect());
     598            drawLayer->setDrawableContentRect(drawableContentRect);
     599        }
     600    }
     601
     602    if (layer->masksToBounds() || useSurfaceForMasking) {
     603        IntRect drawableContentRect = drawLayer->drawableContentRect();
     604        drawableContentRect.intersect(transformedLayerRect);
     605        drawLayer->setDrawableContentRect(drawableContentRect);
     606    }
     607
     608    if (drawLayer->renderSurface() && layer != m_rootLayer) {
     609        RenderSurfaceChromium* renderSurface = drawLayer->renderSurface();
     610        renderSurface->m_contentRect = drawLayer->drawableContentRect();
    597611        FloatPoint surfaceCenter = renderSurface->contentRectCenter();
    598612
     
    602616        // clipped.
    603617        if (!layer->replicaLayer()) {
    604             renderSurface->m_contentRect.intersect(layer->m_scissorRect);
     618            renderSurface->m_contentRect.intersect(drawLayer->scissorRect());
    605619            FloatPoint clippedSurfaceCenter = renderSurface->contentRectCenter();
    606620            centerOffsetDueToClipping = clippedSurfaceCenter - surfaceCenter;
     
    617631        // Since the layer starts a new render surface we need to adjust its
    618632        // scissor rect to be expressed in the new surface's coordinate system.
    619         layer->m_scissorRect = layer->m_drawableContentRect;
     633        drawLayer->setScissorRect(drawLayer->drawableContentRect());
    620634
    621635        // Adjust the origin of the transform to be the center of the render surface.
     
    635649    // Compute the depth value of the center of the layer which will be used when
    636650    // sorting the layers for the preserves-3d property.
    637     TransformationMatrix& layerDrawMatrix = layer->m_renderSurface ? layer->m_renderSurface->m_drawTransform : layer->m_drawTransform;
     651    const TransformationMatrix& layerDrawMatrix = drawLayer->renderSurface() ? drawLayer->renderSurface()->m_drawTransform : drawLayer->drawTransform();
    638652    if (layer->superlayer()) {
    639653        if (!layer->superlayer()->preserves3D())
    640             layer->m_drawDepth = layer->superlayer()->m_drawDepth;
     654            drawLayer->setDrawDepth(drawLayer->superlayer()->drawDepth());
    641655        else
    642             layer->m_drawDepth = layerDrawMatrix.m43();
     656            drawLayer->setDrawDepth(layerDrawMatrix.m43());
    643657    } else
    644         layer->m_drawDepth = 0;
     658        drawLayer->setDrawDepth(0);
    645659
    646660    // If preserves-3d then sort all the descendants by the Z coordinate of their
     
    659673
    660674    if (!m_compositeOffscreen && m_rootLayer)
    661         m_rootLayer->m_renderSurface.clear();
     675        m_rootLayer->ccLayerImpl()->clearRenderSurface();
     676}
     677
     678LayerTexture* LayerRendererChromium::getOffscreenLayerTexture()
     679{
     680    return m_compositeOffscreen ? m_rootLayer->ccLayerImpl()->renderSurface()->m_contentsTexture.get() : 0;
    662681}
    663682
     
    710729}
    711730
    712 void LayerRendererChromium::drawLayer(LayerChromium* layer, RenderSurfaceChromium* targetSurface)
    713 {
    714     if (layer->m_renderSurface && layer->m_renderSurface != targetSurface) {
    715         layer->m_renderSurface->draw();
     731void LayerRendererChromium::drawLayer(CCLayerImpl* layer, RenderSurfaceChromium* targetSurface)
     732{
     733    if (layer->renderSurface() && layer->renderSurface() != targetSurface) {
     734        layer->renderSurface()->draw();
    716735        return;
    717736    }
    718737
    719     if (layer->m_bounds.isEmpty())
     738    if (layer->bounds().isEmpty())
    720739        return;
    721740
    722     setScissorToRect(layer->m_scissorRect);
     741    setScissorToRect(layer->scissorRect());
    723742
    724743    // Check if the layer falls within the visible bounds of the page.
    725744    IntRect layerRect = layer->getDrawRect();
    726     bool isLayerVisible = layer->m_scissorRect.intersects(layerRect);
     745    bool isLayerVisible = layer->scissorRect().intersects(layerRect);
    727746    if (!isLayerVisible)
    728747        return;
     
    730749    // FIXME: Need to take into account the commulative render surface transforms all the way from
    731750    //        the default render surface in order to determine visibility.
    732     TransformationMatrix combinedDrawMatrix = (layer->m_renderSurface ? layer->m_renderSurface->drawTransform().multiply(layer->m_drawTransform) : layer->m_drawTransform);
     751    TransformationMatrix combinedDrawMatrix = (layer->renderSurface() ? layer->renderSurface()->drawTransform().multiply(layer->drawTransform()) : layer->drawTransform());
    733752    if (!layer->doubleSided() && combinedDrawMatrix.m33() < 0)
    734753         return;
    735754
    736755    if (layer->drawsContent()) {
    737         // Update the contents of the layer if necessary.
    738756        layer->updateContentsIfDirty();
    739757        m_context->makeContextCurrent();
  • trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h

    r79578 r79659  
    5858namespace WebCore {
    5959
     60class CCLayerImpl;
    6061class GeometryBinding;
    6162class GraphicsContext3D;
     
    9192    void setCompositeOffscreen(bool);
    9293    bool isCompositingOffscreen() const { return m_compositeOffscreen; }
    93     LayerTexture* getOffscreenLayerTexture() { return m_compositeOffscreen ? m_rootLayer->m_renderSurface->m_contentsTexture.get() : 0; }
     94    LayerTexture* getOffscreenLayerTexture();
    9495    void copyOffscreenTextureToDisplay();
    9596
     
    132133private:
    133134    explicit LayerRendererChromium(PassRefPtr<GraphicsContext3D> graphicsContext3D);
    134     void updateLayersRecursive(LayerChromium* layer, const TransformationMatrix& parentMatrix, Vector<LayerChromium*>& renderSurfaceLayerList, Vector<LayerChromium*>& layerList);
    135 
    136     void drawLayer(LayerChromium*, RenderSurfaceChromium*);
     135    void updateLayersRecursive(LayerChromium*, const TransformationMatrix& parentMatrix, Vector<CCLayerImpl*>& renderSurfaceLayerList, Vector<CCLayerImpl*>& layerList);
     136
     137    void drawLayer(CCLayerImpl*, RenderSurfaceChromium*);
    137138
    138139    void updateAndDrawRootLayer(TilePaintInterface& tilePaint, TilePaintInterface& scrollbarPaint, const IntRect& visibleRect, const IntRect& contentRect);
     
    146147    bool makeContextCurrent();
    147148
    148     static bool compareLayerZ(const LayerChromium*, const LayerChromium*);
     149    static bool compareLayerZ(const CCLayerImpl*, const CCLayerImpl*);
    149150
    150151    bool initializeSharedObjects();
  • trunk/Source/WebCore/platform/graphics/chromium/PluginLayerChromium.cpp

    r79043 r79659  
    3030#include "PluginLayerChromium.h"
    3131
     32#include "cc/CCLayerImpl.h"
    3233#include "GraphicsContext3D.h"
    3334#include "LayerRendererChromium.h"
     
    7374    layerRenderer()->useShader(program->program());
    7475    GLC(context, context->uniform1i(program->fragmentShader().samplerLocation(), 0));
    75     drawTexturedQuad(context, layerRenderer()->projectionMatrix(), drawTransform(),
    76                      bounds().width(), bounds().height(), drawOpacity(),
     76    drawTexturedQuad(context, layerRenderer()->projectionMatrix(), ccLayerImpl()->drawTransform(),
     77                     bounds().width(), bounds().height(), ccLayerImpl()->drawOpacity(),
    7778                     program->vertexShader().matrixLocation(),
    7879                     program->fragmentShader().alphaLocation());
  • trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.cpp

    r79043 r79659  
    3030#include "RenderSurfaceChromium.h"
    3131
     32#include "cc/CCLayerImpl.h"
    3233#include "GraphicsContext3D.h"
    3334#include "LayerRendererChromium.h"
     
    3637namespace WebCore {
    3738
    38 RenderSurfaceChromium::RenderSurfaceChromium(LayerChromium* owningLayer)
     39RenderSurfaceChromium::RenderSurfaceChromium(CCLayerImpl* owningLayer)
    3940    : m_owningLayer(owningLayer)
    4041    , m_maskLayer(0)
     
    9596}
    9697
    97 void RenderSurfaceChromium::drawSurface(LayerChromium* maskLayer, const TransformationMatrix& drawTransform)
     98void RenderSurfaceChromium::drawSurface(CCLayerImpl* maskLayer, const TransformationMatrix& drawTransform)
    9899{
    99100    GraphicsContext3D* context3D = layerRenderer()->context();
     
    151152    // to draw the layer and its reflection in. For now we only apply a separate reflection
    152153    // mask if the contents don't have a mask of their own.
    153     LayerChromium* replicaMaskLayer = m_maskLayer;
     154    CCLayerImpl* replicaMaskLayer = m_maskLayer;
    154155    if (!m_maskLayer && m_owningLayer->replicaLayer())
    155156        replicaMaskLayer = m_owningLayer->replicaLayer()->maskLayer();
  • trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h

    r79043 r79659  
    4040namespace WebCore {
    4141
    42 class LayerChromium;
     42class CCLayerImpl;
    4343class LayerRendererChromium;
    4444class LayerTexture;
     
    4848    friend class LayerRendererChromium;
    4949public:
    50     explicit RenderSurfaceChromium(LayerChromium*);
     50    explicit RenderSurfaceChromium(CCLayerImpl*);
    5151    ~RenderSurfaceChromium();
    5252
     
    6868private:
    6969    LayerRendererChromium* layerRenderer();
    70     void drawSurface(LayerChromium* maskLayer, const TransformationMatrix& drawTransform);
     70    void drawSurface(CCLayerImpl* maskLayer, const TransformationMatrix& drawTransform);
    7171
    72     LayerChromium* m_owningLayer;
    73     LayerChromium* m_maskLayer;
     72    CCLayerImpl* m_owningLayer;
     73    CCLayerImpl* m_maskLayer;
    7474
    7575    IntRect m_contentRect;
     
    8181    TransformationMatrix m_originTransform;
    8282    IntRect m_scissorRect;
    83     Vector<LayerChromium*> m_layerList;
     83    Vector<CCLayerImpl*> m_layerList;
    8484};
    8585
  • trunk/Source/WebCore/platform/graphics/chromium/VideoLayerChromium.cpp

    r79043 r79659  
    3434#include "VideoLayerChromium.h"
    3535
     36#include "cc/CCLayerImpl.h"
    3637#include "Extensions3DChromium.h"
    3738#include "GraphicsContext3D.h"
     
    295296    GLC(context, context->uniformMatrix3fv(program->fragmentShader().ccMatrixLocation(), 0, const_cast<float*>(yuv2RGB), 1));
    296297
    297     drawTexturedQuad(context, layerRenderer()->projectionMatrix(), drawTransform(),
    298                      bounds().width(), bounds().height(), drawOpacity(),
     298    drawTexturedQuad(context, layerRenderer()->projectionMatrix(), ccLayerImpl()->drawTransform(),
     299                     bounds().width(), bounds().height(), ccLayerImpl()->drawOpacity(),
    299300                     program->vertexShader().matrixLocation(),
    300301                     program->fragmentShader().alphaLocation());
     
    318319    GLC(context, context->uniform1i(program->fragmentShader().samplerLocation(), 0));
    319320
    320     drawTexturedQuad(context, layerRenderer()->projectionMatrix(), drawTransform(),
    321                      bounds().width(), bounds().height(), drawOpacity(),
     321    drawTexturedQuad(context, layerRenderer()->projectionMatrix(), ccLayerImpl()->drawTransform(),
     322                     bounds().width(), bounds().height(), ccLayerImpl()->drawOpacity(),
    322323                     program->vertexShader().matrixLocation(),
    323324                     program->fragmentShader().alphaLocation());
Note: See TracChangeset for help on using the changeset viewer.