Changeset 86208 in webkit


Ignore:
Timestamp:
May 10, 2011 7:28:52 PM (13 years ago)
Author:
jamesr@google.com
Message:

2011-05-10 James Robinson <jamesr@chromium.org>

Reviewed by Kenneth Russell.

[chromium] Clean up setLayerRenderer() calls in LayerRendererChromium
https://bugs.webkit.org/show_bug.cgi?id=60524

This refactors the way LayerRendererChromium calls setLayerRenderer on its layers in a few ways to clean things
up:

*) Move the pre-paint call to setLayerRenderer from updatePropertiesAndRenderSurfaces() to paintLayerContents().

updatePropertiesAndRenderSurfaces() does too much and the layer renderer pointer only has to be up to date to do
the actual paint. Longer term we won't need to call this at all in order to call paint and this call will just
go away.

*) Tweaks updateCompositorResourcesRecursive() to be slightly shorter and less error-prone.
*) Explicitly set the LayerRendererChromium for each layer in the tree when transfering the root layer (used

during lost context). LayerChromium::setLayerRenderer checks if the new LayerRendererChromium is different
by comparing the pointer value to the old one. This check will be incorrect if there are multiple lost
contexts between a setLayerRenderer() call and a new LayerRendererChromium happens to be allocated at the
same address as the old one. An explicit call to setLayerRenderer() for every layer in the tree fixes this
since when this function is called the new and old LayerRendererChromium are still live and so they cannot
live at the same address.

The first two changes are purely refactors and do not change behavior. The third issue can't be tested via a
layout test directly as we don't have a way to induce a lost context on the compositor in a layout test.

  • platform/graphics/chromium/LayerRendererChromium.cpp: (WebCore::LayerRendererChromium::paintLayerContents): (WebCore::LayerRendererChromium::clearLayerRendererRecursive): (WebCore::LayerRendererChromium::transferRootLayer): (WebCore::LayerRendererChromium::updatePropertiesAndRenderSurfaces): (WebCore::LayerRendererChromium::updateCompositorResourcesRecursive):
  • platform/graphics/chromium/LayerRendererChromium.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r86205 r86208  
     12011-05-10  James Robinson  <jamesr@chromium.org>
     2
     3        Reviewed by Kenneth Russell.
     4
     5        [chromium] Clean up setLayerRenderer() calls in LayerRendererChromium
     6        https://bugs.webkit.org/show_bug.cgi?id=60524
     7
     8        This refactors the way LayerRendererChromium calls setLayerRenderer on its layers in a few ways to clean things
     9        up:
     10
     11        *) Move the pre-paint call to setLayerRenderer from updatePropertiesAndRenderSurfaces() to paintLayerContents().
     12            updatePropertiesAndRenderSurfaces() does too much and the layer renderer pointer only has to be up to date to do
     13            the actual paint. Longer term we won't need to call this at all in order to call paint and this call will just
     14            go away.
     15        *) Tweaks updateCompositorResourcesRecursive() to be slightly shorter and less error-prone.
     16        *) Explicitly set the LayerRendererChromium for each layer in the tree when transfering the root layer (used
     17            during lost context).  LayerChromium::setLayerRenderer checks if the new LayerRendererChromium is different
     18            by comparing the pointer value to the old one.  This check will be incorrect if there are multiple lost
     19            contexts between a setLayerRenderer() call and a new LayerRendererChromium happens to be allocated at the
     20            same address as the old one.  An explicit call to setLayerRenderer() for every layer in the tree fixes this
     21            since when this function is called the new and old LayerRendererChromium are still live and so they cannot
     22            live at the same address.
     23
     24        The first two changes are purely refactors and do not change behavior.  The third issue can't be tested via a
     25        layout test directly as we don't have a way to induce a lost context on the compositor in a layout test.
     26
     27        * platform/graphics/chromium/LayerRendererChromium.cpp:
     28        (WebCore::LayerRendererChromium::paintLayerContents):
     29        (WebCore::LayerRendererChromium::clearLayerRendererRecursive):
     30        (WebCore::LayerRendererChromium::transferRootLayer):
     31        (WebCore::LayerRendererChromium::updatePropertiesAndRenderSurfaces):
     32        (WebCore::LayerRendererChromium::updateCompositorResourcesRecursive):
     33        * platform/graphics/chromium/LayerRendererChromium.h:
     34
    1352011-05-10  Anton D'Auria  <adauria@apple.com>
    236
  • trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp

    r86189 r86208  
    366366                continue;
    367367
     368            layer->setLayerRenderer(this);
     369            if (layer->maskLayer())
     370                layer->maskLayer()->setLayerRenderer(this);
     371            if (layer->replicaLayer()) {
     372                layer->replicaLayer()->setLayerRenderer(this);
     373                if (layer->replicaLayer()->maskLayer())
     374                    layer->replicaLayer()->maskLayer()->setLayerRenderer(this);
     375            }
     376
    368377            IntRect targetSurfaceRect = ccLayerImpl->targetRenderSurface() ? ccLayerImpl->targetRenderSurface()->contentRect() : m_defaultRenderSurface->contentRect();
    369378            IntRect scissorRect = layer->ccLayerImpl()->scissorRect();
     
    484493        m_rootLayer->setLayerRenderer(this);
    485494    m_rootLayerContentTiler->invalidateEntireLayer();
     495}
     496
     497void LayerRendererChromium::setLayerRendererRecursive(LayerChromium* layer)
     498{
     499    const Vector<RefPtr<LayerChromium> >& children = layer->children();
     500    for (size_t i = 0; i < children.size(); ++i)
     501        setLayerRendererRecursive(children[i].get());
     502
     503    if (layer->maskLayer())
     504        setLayerRendererRecursive(layer->maskLayer());
     505    if (layer->replicaLayer())
     506        setLayerRendererRecursive(layer->replicaLayer());
     507
     508    layer->setLayerRenderer(this);
     509}
     510
     511void LayerRendererChromium::transferRootLayer(LayerRendererChromium* other)
     512{
     513    other->setLayerRendererRecursive(m_rootLayer.get());
     514    other->m_rootLayer = m_rootLayer.release();
    486515}
    487516
     
    545574    // Make sure we have CCLayerImpls for this subtree.
    546575    layer->createCCLayerImplIfNeeded();
    547     layer->setLayerRenderer(this);
    548     if (layer->maskLayer()) {
     576    if (layer->maskLayer())
    549577        layer->maskLayer()->createCCLayerImplIfNeeded();
    550         layer->maskLayer()->setLayerRenderer(this);
    551     }
    552     if (layer->replicaLayer()) {
     578    if (layer->replicaLayer())
    553579        layer->replicaLayer()->createCCLayerImplIfNeeded();
    554         layer->replicaLayer()->setLayerRenderer(this);
    555     }
    556     if (layer->replicaLayer() && layer->replicaLayer()->maskLayer()) {
     580    if (layer->replicaLayer() && layer->replicaLayer()->maskLayer())
    557581        layer->replicaLayer()->maskLayer()->createCCLayerImplIfNeeded();
    558         layer->replicaLayer()->maskLayer()->setLayerRenderer(this);
    559     }
    560582
    561583    CCLayerImpl* drawLayer = layer->ccLayerImpl();
     
    813835        return;
    814836
     837    if (layer->maskLayer())
     838        updateCompositorResourcesRecursive(layer->maskLayer());
     839    if (layer->replicaLayer())
     840        updateCompositorResourcesRecursive(layer->replicaLayer());
     841
    815842    CCLayerImpl* drawLayer = layer->ccLayerImpl();
    816843
    817844    if (drawLayer->drawsContent())
    818845        drawLayer->updateCompositorResources();
    819     if (drawLayer->maskLayer() && drawLayer->maskLayer()->drawsContent())
    820         drawLayer->maskLayer()->updateCompositorResources();
    821     if (drawLayer->replicaLayer() && drawLayer->replicaLayer()->drawsContent())
    822         drawLayer->replicaLayer()->updateCompositorResources();
    823     if (drawLayer->replicaLayer() && drawLayer->replicaLayer()->maskLayer() && drawLayer->replicaLayer()->maskLayer()->drawsContent())
    824         drawLayer->replicaLayer()->maskLayer()->updateCompositorResources();
    825846
    826847    layer->pushPropertiesTo(drawLayer);
  • trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.h

    r85814 r86208  
    9292    void setRootLayer(PassRefPtr<LayerChromium>);
    9393    LayerChromium* rootLayer() { return m_rootLayer.get(); }
    94     void transferRootLayer(LayerRendererChromium* other) { other->m_rootLayer = m_rootLayer.release(); }
     94    void transferRootLayer(LayerRendererChromium* other);
    9595
    9696    bool hardwareCompositing() const { return m_hardwareCompositing; }
     
    173173    bool initializeSharedObjects();
    174174    void cleanupSharedObjects();
     175
     176    void setLayerRendererRecursive(LayerChromium*);
    175177
    176178    IntRect m_viewportVisibleRect;
Note: See TracChangeset for help on using the changeset viewer.