Changeset 91322 in webkit


Ignore:
Timestamp:
Jul 19, 2011 5:07:39 PM (13 years ago)
Author:
jamesr@google.com
Message:

[chromium] LayerRendererChromium shouldn't be a friend of RenderSurfaceChromium
https://bugs.webkit.org/show_bug.cgi?id=64834

Reviewed by Kenneth Russell.

Uses setters and getters to access RenderSurfaceChromium's private member variables instead of directly
accessing them via a friend declaration. This cleans up a minor code smell and will be helpful for future
refactoring.

Refactor only, no change in behavior. Tested by compositing/ tests.

  • platform/graphics/chromium/LayerRendererChromium.cpp:

(WebCore::LayerRendererChromium::updateLayers):
(WebCore::LayerRendererChromium::paintLayerContents):
(WebCore::LayerRendererChromium::drawLayers):
(WebCore::LayerRendererChromium::updatePropertiesAndRenderSurfaces):
(WebCore::LayerRendererChromium::updateCompositorResources):
(WebCore::LayerRendererChromium::getOffscreenLayerTexture):
(WebCore::LayerRendererChromium::copyOffscreenTextureToDisplay):
(WebCore::LayerRendererChromium::useRenderSurface):
(WebCore::LayerRendererChromium::drawLayer):
(WebCore::LayerRendererChromium::setScissorToRect):

  • platform/graphics/chromium/RenderSurfaceChromium.cpp:

(WebCore::RenderSurfaceChromium::clearLayerList):

  • platform/graphics/chromium/RenderSurfaceChromium.h:

(WebCore::RenderSurfaceChromium::layerList):
(WebCore::RenderSurfaceChromium::contentRect):
(WebCore::RenderSurfaceChromium::setContentRect):
(WebCore::RenderSurfaceChromium::drawOpacity):
(WebCore::RenderSurfaceChromium::setDrawOpacity):
(WebCore::RenderSurfaceChromium::drawTransform):
(WebCore::RenderSurfaceChromium::setDrawTransform):
(WebCore::RenderSurfaceChromium::maskLayer):
(WebCore::RenderSurfaceChromium::setMaskLayer):
(WebCore::RenderSurfaceChromium::originTransform):
(WebCore::RenderSurfaceChromium::setOriginTransform):
(WebCore::RenderSurfaceChromium::replicaDrawTransform):
(WebCore::RenderSurfaceChromium::setReplicaDrawTransform):
(WebCore::RenderSurfaceChromium::scissorRect):
(WebCore::RenderSurfaceChromium::setScissorRect):
(WebCore::RenderSurfaceChromium::skipsDraw):
(WebCore::RenderSurfaceChromium::setSkipsDraw):
(WebCore::RenderSurfaceChromium::contentsTexture):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r91320 r91322  
     12011-07-19  James Robinson  <jamesr@chromium.org>
     2
     3        [chromium] LayerRendererChromium shouldn't be a friend of RenderSurfaceChromium
     4        https://bugs.webkit.org/show_bug.cgi?id=64834
     5
     6        Reviewed by Kenneth Russell.
     7
     8        Uses setters and getters to access RenderSurfaceChromium's private member variables instead of directly
     9        accessing them via a friend declaration. This cleans up a minor code smell and will be helpful for future
     10        refactoring.
     11
     12        Refactor only, no change in behavior.  Tested by compositing/ tests.
     13
     14        * platform/graphics/chromium/LayerRendererChromium.cpp:
     15        (WebCore::LayerRendererChromium::updateLayers):
     16        (WebCore::LayerRendererChromium::paintLayerContents):
     17        (WebCore::LayerRendererChromium::drawLayers):
     18        (WebCore::LayerRendererChromium::updatePropertiesAndRenderSurfaces):
     19        (WebCore::LayerRendererChromium::updateCompositorResources):
     20        (WebCore::LayerRendererChromium::getOffscreenLayerTexture):
     21        (WebCore::LayerRendererChromium::copyOffscreenTextureToDisplay):
     22        (WebCore::LayerRendererChromium::useRenderSurface):
     23        (WebCore::LayerRendererChromium::drawLayer):
     24        (WebCore::LayerRendererChromium::setScissorToRect):
     25        * platform/graphics/chromium/RenderSurfaceChromium.cpp:
     26        (WebCore::RenderSurfaceChromium::clearLayerList):
     27        * platform/graphics/chromium/RenderSurfaceChromium.h:
     28        (WebCore::RenderSurfaceChromium::layerList):
     29        (WebCore::RenderSurfaceChromium::contentRect):
     30        (WebCore::RenderSurfaceChromium::setContentRect):
     31        (WebCore::RenderSurfaceChromium::drawOpacity):
     32        (WebCore::RenderSurfaceChromium::setDrawOpacity):
     33        (WebCore::RenderSurfaceChromium::drawTransform):
     34        (WebCore::RenderSurfaceChromium::setDrawTransform):
     35        (WebCore::RenderSurfaceChromium::maskLayer):
     36        (WebCore::RenderSurfaceChromium::setMaskLayer):
     37        (WebCore::RenderSurfaceChromium::originTransform):
     38        (WebCore::RenderSurfaceChromium::setOriginTransform):
     39        (WebCore::RenderSurfaceChromium::replicaDrawTransform):
     40        (WebCore::RenderSurfaceChromium::setReplicaDrawTransform):
     41        (WebCore::RenderSurfaceChromium::scissorRect):
     42        (WebCore::RenderSurfaceChromium::setScissorRect):
     43        (WebCore::RenderSurfaceChromium::skipsDraw):
     44        (WebCore::RenderSurfaceChromium::setSkipsDraw):
     45        (WebCore::RenderSurfaceChromium::contentsTexture):
     46
    1472011-07-19  Jessie Berlin  <jberlin@apple.com>
    248
  • trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp

    r90963 r91322  
    338338    ASSERT(rootDrawLayer->renderSurface());
    339339
    340     rootDrawLayer->renderSurface()->m_contentRect = IntRect(IntPoint(0, 0), m_viewportVisibleRect.size());
     340    rootDrawLayer->renderSurface()->setContentRect(IntRect(IntPoint(0, 0), m_viewportVisibleRect.size()));
    341341
    342342    IntRect rootScissorRect(m_viewportVisibleRect);
     
    350350
    351351    TransformationMatrix identityMatrix;
    352     m_defaultRenderSurface->m_layerList.clear();
     352    m_defaultRenderSurface->clearLayerList();
    353353    // Unfortunately, updatePropertiesAndRenderSurfaces() currently both updates the layers and updates the draw state
    354354    // (transforms, etc). It'd be nicer if operations on the presentation layers happened later, but the draw
    355355    // transforms are needed by large layers to determine visibility. Tiling will fix this by eliminating the
    356356    // concept of a large content layer.
    357     updatePropertiesAndRenderSurfaces(rootDrawLayer, identityMatrix, renderSurfaceLayerList, m_defaultRenderSurface->m_layerList);
     357    updatePropertiesAndRenderSurfaces(rootDrawLayer, identityMatrix, renderSurfaceLayerList, m_defaultRenderSurface->layerList());
    358358
    359359#ifndef NDEBUG
     
    433433        // Render surfaces whose drawable area has zero width or height
    434434        // will have no layers associated with them and should be skipped.
    435         if (!renderSurface->m_layerList.size())
     435        if (!renderSurface->layerList().size())
    436436            continue;
    437437
    438         if (!renderSurface->m_drawOpacity)
     438        if (!renderSurface->drawOpacity())
    439439            continue;
    440440
    441         LayerList& layerList = renderSurface->m_layerList;
     441        LayerList& layerList = renderSurface->layerList();
    442442        ASSERT(layerList.size());
    443443        for (unsigned layerIndex = 0; layerIndex < layerList.size(); ++layerIndex) {
     
    538538        ASSERT(renderSurface);
    539539
    540         renderSurface->m_skipsDraw = true;
     540        renderSurface->setSkipsDraw(true);
    541541
    542542        // Render surfaces whose drawable area has zero width or height
    543543        // will have no layers associated with them and should be skipped.
    544         if (!renderSurface->m_layerList.size())
     544        if (!renderSurface->layerList().size())
    545545            continue;
    546546
    547547        // Skip completely transparent render surfaces.
    548         if (!renderSurface->m_drawOpacity)
     548        if (!renderSurface->drawOpacity())
    549549            continue;
    550550
    551551        if (useRenderSurface(renderSurface)) {
    552             renderSurface->m_skipsDraw = false;
     552            renderSurface->setSkipsDraw(false);
    553553
    554554            if (renderSurfaceLayer != rootDrawLayer) {
     
    559559            }
    560560
    561             LayerList& layerList = renderSurface->m_layerList;
     561            LayerList& layerList = renderSurface->layerList();
    562562            for (unsigned layerIndex = 0; layerIndex < layerList.size(); ++layerIndex)
    563563                drawLayer(layerList[layerIndex].get(), renderSurface);
     
    751751
    752752        // Layer's opacity will be applied when drawing the render surface.
    753         renderSurface->m_drawOpacity = layer->opacity();
     753        float drawOpacity = layer->opacity();
    754754        if (layer->parent() && layer->parent()->preserves3D())
    755             renderSurface->m_drawOpacity *= layer->parent()->drawOpacity();
     755            drawOpacity *= layer->parent()->drawOpacity();
     756        renderSurface->setDrawOpacity(drawOpacity);
    756757        layer->setDrawOpacity(1);
    757758
    758759        TransformationMatrix layerOriginTransform = combinedTransform;
    759760        layerOriginTransform.translate3d(-0.5 * bounds.width(), -0.5 * bounds.height(), 0);
    760         renderSurface->m_originTransform = layerOriginTransform;
     761        renderSurface->setOriginTransform(layerOriginTransform);
    761762
    762763        // The render surface scissor rect is the scissor rect that needs to
    763764        // be applied before drawing the render surface onto its containing
    764765        // surface and is therefore expressed in the parent's coordinate system.
    765         renderSurface->m_scissorRect = layer->parent() ? layer->parent()->scissorRect() : layer->scissorRect();
    766 
    767         renderSurface->m_layerList.clear();
     766        renderSurface->setScissorRect(layer->parent() ? layer->parent()->scissorRect() : layer->scissorRect());
     767
     768        renderSurface->clearLayerList();
    768769
    769770        if (layer->maskLayer()) {
    770             renderSurface->m_maskLayer = layer->maskLayer();
     771            renderSurface->setMaskLayer(layer->maskLayer());
    771772            layer->maskLayer()->setTargetRenderSurface(renderSurface);
    772773        } else
    773             renderSurface->m_maskLayer = 0;
     774            renderSurface->setMaskLayer(0);
    774775
    775776        if (layer->replicaLayer() && layer->replicaLayer()->maskLayer())
     
    846847    sublayerMatrix.translate3d(-bounds.width() * 0.5, -bounds.height() * 0.5, 0);
    847848
    848     LayerList& descendants = (layer->renderSurface() ? layer->renderSurface()->m_layerList : layerList);
     849    LayerList& descendants = (layer->renderSurface() ? layer->renderSurface()->layerList() : layerList);
    849850    descendants.append(layer);
    850851
     
    876877    if (layer->renderSurface() && layer != m_rootCCLayerImpl.get()) {
    877878        RenderSurfaceChromium* renderSurface = layer->renderSurface();
    878         renderSurface->m_contentRect = layer->drawableContentRect();
    879         FloatPoint surfaceCenter = renderSurface->contentRectCenter();
     879        IntRect renderSurfaceContentRect = layer->drawableContentRect();
     880        FloatPoint surfaceCenter = FloatRect(renderSurfaceContentRect).center();
    880881
    881882        // Restrict the RenderSurface size to the portion that's visible.
     
    885886        // clipped.
    886887        if (!layer->replicaLayer()) {
    887             if (!renderSurface->m_scissorRect.isEmpty() && !renderSurface->m_contentRect.isEmpty()) {
    888                 IntRect surfaceScissorRect = calculateVisibleRect(renderSurface->m_scissorRect, renderSurface->m_contentRect, renderSurface->m_originTransform);
    889                 renderSurface->m_contentRect.intersect(surfaceScissorRect);
     888            if (!renderSurface->scissorRect().isEmpty() && !renderSurfaceContentRect.isEmpty()) {
     889                IntRect surfaceScissorRect = calculateVisibleRect(renderSurface->scissorRect(), renderSurfaceContentRect, renderSurface->originTransform());
     890                renderSurfaceContentRect.intersect(surfaceScissorRect);
    890891            }
    891             FloatPoint clippedSurfaceCenter = renderSurface->contentRectCenter();
     892            FloatPoint clippedSurfaceCenter = FloatRect(renderSurfaceContentRect).center();
    892893            centerOffsetDueToClipping = clippedSurfaceCenter - surfaceCenter;
    893894        }
     
    895896        // The RenderSurface backing texture cannot exceed the maximum supported
    896897        // texture size.
    897         renderSurface->m_contentRect.setWidth(std::min(renderSurface->m_contentRect.width(), m_maxTextureSize));
    898         renderSurface->m_contentRect.setHeight(std::min(renderSurface->m_contentRect.height(), m_maxTextureSize));
    899 
    900         if (renderSurface->m_contentRect.isEmpty())
    901             renderSurface->m_layerList.clear();
     898        renderSurfaceContentRect.setWidth(std::min(renderSurfaceContentRect.width(), m_maxTextureSize));
     899        renderSurfaceContentRect.setHeight(std::min(renderSurfaceContentRect.height(), m_maxTextureSize));
     900
     901        if (renderSurfaceContentRect.isEmpty())
     902            renderSurface->clearLayerList();
     903        renderSurface->setContentRect(renderSurfaceContentRect);
    902904
    903905        // Since the layer starts a new render surface we need to adjust its
     
    906908
    907909        // Adjust the origin of the transform to be the center of the render surface.
    908         renderSurface->m_drawTransform = renderSurface->m_originTransform;
    909         renderSurface->m_drawTransform.translate3d(surfaceCenter.x() + centerOffsetDueToClipping.width(), surfaceCenter.y() + centerOffsetDueToClipping.height(), 0);
     910        TransformationMatrix drawTransform = renderSurface->originTransform();
     911        drawTransform.translate3d(surfaceCenter.x() + centerOffsetDueToClipping.width(), surfaceCenter.y() + centerOffsetDueToClipping.height(), 0);
     912        renderSurface->setDrawTransform(drawTransform);
    910913
    911914        // Compute the transformation matrix used to draw the replica of the render
    912915        // surface.
    913916        if (layer->replicaLayer()) {
    914             renderSurface->m_replicaDrawTransform = renderSurface->m_originTransform;
    915             renderSurface->m_replicaDrawTransform.translate3d(layer->replicaLayer()->position().x(), layer->replicaLayer()->position().y(), 0);
    916             renderSurface->m_replicaDrawTransform.multiply(layer->replicaLayer()->transform());
    917             renderSurface->m_replicaDrawTransform.translate3d(surfaceCenter.x() - anchorPoint.x() * bounds.width(), surfaceCenter.y() - anchorPoint.y() * bounds.height(), 0);
     917            TransformationMatrix replicaDrawTransform = renderSurface->originTransform();
     918            replicaDrawTransform.translate3d(layer->replicaLayer()->position().x(), layer->replicaLayer()->position().y(), 0);
     919            replicaDrawTransform.multiply(layer->replicaLayer()->transform());
     920            replicaDrawTransform.translate3d(surfaceCenter.x() - anchorPoint.x() * bounds.width(), surfaceCenter.y() - anchorPoint.y() * bounds.height(), 0);
     921            renderSurface->setReplicaDrawTransform(replicaDrawTransform);
    918922        }
    919923    }
     
    933937        ASSERT(renderSurface);
    934938
    935         if (!renderSurface->m_layerList.size() || !renderSurface->m_drawOpacity)
     939        if (!renderSurface->layerList().size() || !renderSurface->drawOpacity())
    936940            continue;
    937941
    938         LayerList& layerList = renderSurface->m_layerList;
     942        const LayerList& layerList = renderSurface->layerList();
    939943        ASSERT(layerList.size());
    940944        for (unsigned layerIndex = 0; layerIndex < layerList.size(); ++layerIndex) {
     
    982986LayerTexture* LayerRendererChromium::getOffscreenLayerTexture()
    983987{
    984     return m_compositeOffscreen ? m_rootLayer->ccLayerImpl()->renderSurface()->m_contentsTexture.get() : 0;
     988    return m_compositeOffscreen ? m_rootLayer->ccLayerImpl()->renderSurface()->contentsTexture() : 0;
    985989}
    986990
     
    991995
    992996        useRenderSurface(0);
    993         m_defaultRenderSurface->m_drawTransform.makeIdentity();
    994         m_defaultRenderSurface->m_drawTransform.translate3d(0.5 * m_defaultRenderSurface->m_contentRect.width(),
    995                                                             0.5 * m_defaultRenderSurface->m_contentRect.height(), 0);
    996         m_defaultRenderSurface->m_drawOpacity = 1;
    997         m_defaultRenderSurface->draw(m_defaultRenderSurface->m_contentRect);
     997        TransformationMatrix drawTransform;
     998        drawTransform.translate3d(0.5 * m_defaultRenderSurface->contentRect().width(), 0.5 * m_defaultRenderSurface->contentRect().height(), 0);
     999        m_defaultRenderSurface->setDrawTransform(drawTransform);
     1000        m_defaultRenderSurface->setDrawOpacity(1);
     1001        m_defaultRenderSurface->draw(m_defaultRenderSurface->contentRect());
    9981002    }
    9991003}
     
    10091013        GLC(m_context.get(), m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, 0));
    10101014        if (renderSurface)
    1011             setDrawViewportRect(renderSurface->m_contentRect, true);
     1015            setDrawViewportRect(renderSurface->contentRect(), true);
    10121016        else
    1013             setDrawViewportRect(m_defaultRenderSurface->m_contentRect, true);
     1017            setDrawViewportRect(m_defaultRenderSurface->contentRect(), true);
    10141018        return true;
    10151019    }
     
    10201024        return false;
    10211025
    1022     renderSurface->m_contentsTexture->framebufferTexture2D();
     1026    renderSurface->contentsTexture()->framebufferTexture2D();
    10231027
    10241028#if !defined ( NDEBUG )
     
    10291033#endif
    10301034
    1031     setDrawViewportRect(renderSurface->m_contentRect, false);
     1035    setDrawViewportRect(renderSurface->contentRect(), false);
    10321036    return true;
    10331037}
     
    10611065
    10621066
    1063     // FIXME: Need to take into account the commulative render surface transforms all the way from
    1064     //        the default render surface in order to determine visibility.
    1065     TransformationMatrix combinedDrawMatrix = (layer->targetRenderSurface() ? layer->targetRenderSurface()->drawTransform().multiply(layer->drawTransform()) : layer->drawTransform());
    1066    
    10671067    if (!layer->doubleSided()) {
     1068        // FIXME: Need to take into account the cumulative render surface transforms all the way from
     1069        //        the default render surface in order to determine visibility.
     1070        TransformationMatrix combinedDrawMatrix;
     1071        if (layer->targetRenderSurface()) {
     1072            combinedDrawMatrix = layer->targetRenderSurface()->drawTransform();
     1073            combinedDrawMatrix.multiply(layer->drawTransform());
     1074        } else
     1075            combinedDrawMatrix = layer->drawTransform();
     1076
    10681077        FloatRect layerRect(FloatPoint(0, 0), FloatSize(layer->bounds()));
    10691078        FloatQuad mappedLayer = combinedDrawMatrix.mapQuad(FloatQuad(layerRect));
     
    10871096void LayerRendererChromium::setScissorToRect(const IntRect& scissorRect)
    10881097{
    1089     IntRect contentRect = (m_currentRenderSurface ? m_currentRenderSurface->m_contentRect : m_defaultRenderSurface->m_contentRect);
     1098    IntRect contentRect = (m_currentRenderSurface ? m_currentRenderSurface->contentRect() : m_defaultRenderSurface->contentRect());
    10901099
    10911100    GLC(m_context.get(), m_context->enable(GraphicsContext3D::SCISSOR_TEST));
     
    10991108    int scissorY;
    11001109    if (m_currentRenderSurface == m_defaultRenderSurface && !m_compositeOffscreen)
    1101         scissorY = m_currentRenderSurface->m_contentRect.height() - (scissorRect.maxY() - m_currentRenderSurface->m_contentRect.y());
     1110        scissorY = m_currentRenderSurface->contentRect().height() - (scissorRect.maxY() - m_currentRenderSurface->contentRect().y());
    11021111    else
    11031112        scissorY = scissorRect.y() - contentRect.y();
  • trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.cpp

    r90589 r91322  
    174174}
    175175
     176void RenderSurfaceChromium::clearLayerList()
     177{
     178    m_layerList.clear();
     179}
     180
    176181String RenderSurfaceChromium::name() const
    177182{
  • trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.h

    r90260 r91322  
    4646class RenderSurfaceChromium {
    4747    WTF_MAKE_NONCOPYABLE(RenderSurfaceChromium);
    48     friend class LayerRendererChromium;
    4948public:
    5049    explicit RenderSurfaceChromium(CCLayerImpl*);
     
    5958    void dumpSurface(TextStream&, int indent) const;
    6059
    61     FloatPoint contentRectCenter() const { return FloatRect(m_contentRect).center(); }
    62     IntRect contentRect() const { return m_contentRect; }
    63 
    6460    // Returns the rect that encloses the RenderSurface including any reflection.
    6561    FloatRect drawableContentRect() const;
    6662
    67     TransformationMatrix drawTransform() const { return m_drawTransform; }
     63    Vector<RefPtr<CCLayerImpl> >& layerList() { return m_layerList; }
     64    void clearLayerList();
     65
     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; }
     76    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(); }
    6891
    6992    typedef ProgramBinding<VertexShaderPosTex, FragmentShaderRGBATexAlpha> Program;
Note: See TracChangeset for help on using the changeset viewer.