Changeset 90589 in webkit


Ignore:
Timestamp:
Jul 7, 2011 2:06:58 PM (13 years ago)
Author:
enne@google.com
Message:

[chromium] Reduce compositor texture memory by skipping layers and clipping surfaces
https://bugs.webkit.org/show_bug.cgi?id=64052

Reviewed by James Robinson.

Layers and surfaces that are entirely transparent are now skipped.
Parent scissor rects are now applied to the content rect of surfaces
so that offscreen surfaces can be skipped.

Landing this for vangelis@chromium.org.

Covered by existing tests.

  • platform/graphics/chromium/LayerRendererChromium.cpp:

(WebCore::calculateVisibleRect):
(WebCore::calculateVisibleLayerRect):
(WebCore::LayerRendererChromium::paintLayerContents):
(WebCore::LayerRendererChromium::drawLayers):
(WebCore::LayerRendererChromium::updatePropertiesAndRenderSurfaces):
(WebCore::LayerRendererChromium::updateCompositorResources):
(WebCore::LayerRendererChromium::drawLayer):

  • platform/graphics/chromium/RenderSurfaceChromium.cpp:

(WebCore::RenderSurfaceChromium::RenderSurfaceChromium):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r90588 r90589  
     12011-07-06  Adrienne Walker  <enne@google.com>
     2
     3        [chromium] Reduce compositor texture memory by skipping layers and clipping surfaces
     4        https://bugs.webkit.org/show_bug.cgi?id=64052
     5
     6        Reviewed by James Robinson.
     7
     8        Layers and surfaces that are entirely transparent are now skipped.
     9        Parent scissor rects are now applied to the content rect of surfaces
     10        so that offscreen surfaces can be skipped.
     11
     12        Landing this for vangelis@chromium.org.
     13
     14        Covered by existing tests.
     15
     16        * platform/graphics/chromium/LayerRendererChromium.cpp:
     17        (WebCore::calculateVisibleRect):
     18        (WebCore::calculateVisibleLayerRect):
     19        (WebCore::LayerRendererChromium::paintLayerContents):
     20        (WebCore::LayerRendererChromium::drawLayers):
     21        (WebCore::LayerRendererChromium::updatePropertiesAndRenderSurfaces):
     22        (WebCore::LayerRendererChromium::updateCompositorResources):
     23        (WebCore::LayerRendererChromium::drawLayer):
     24        * platform/graphics/chromium/RenderSurfaceChromium.cpp:
     25        (WebCore::RenderSurfaceChromium::RenderSurfaceChromium):
     26
    1272011-07-07  Adam Barth  <abarth@webkit.org>
    228
  • trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp

    r90587 r90589  
    374374}
    375375
    376 static IntRect calculateVisibleLayerRect(const IntRect& targetSurfaceRect, const IntSize& bounds, const IntSize& contentBounds, const TransformationMatrix& tilingTransform)
    377 {
    378     if (targetSurfaceRect.isEmpty() || contentBounds.isEmpty())
    379         return targetSurfaceRect;
    380 
    381     const IntRect layerBoundRect = IntRect(IntPoint(), contentBounds);
    382     TransformationMatrix transform = tilingTransform;
    383 
    384     transform.scaleNonUniform(bounds.width() / static_cast<double>(contentBounds.width()),
    385                               bounds.height() / static_cast<double>(contentBounds.height()));
    386     transform.translate(-contentBounds.width() / 2.0, -contentBounds.height() / 2.0);
    387 
     376static IntRect calculateVisibleRect(const IntRect& targetSurfaceRect, const IntRect& layerBoundRect, const TransformationMatrix& transform)
     377{
    388378    // Is this layer fully contained within the target surface?
    389379    IntRect layerInSurfaceSpace = transform.mapRect(layerBoundRect);
     
    407397}
    408398
     399static IntRect calculateVisibleLayerRect(const IntRect& targetSurfaceRect, const IntSize& bounds, const IntSize& contentBounds, const TransformationMatrix& tilingTransform)
     400{
     401    if (targetSurfaceRect.isEmpty() || contentBounds.isEmpty())
     402        return targetSurfaceRect;
     403
     404    const IntRect layerBoundRect = IntRect(IntPoint(), contentBounds);
     405    TransformationMatrix transform = tilingTransform;
     406
     407    transform.scaleNonUniform(bounds.width() / static_cast<double>(contentBounds.width()),
     408                              bounds.height() / static_cast<double>(contentBounds.height()));
     409    transform.translate(-contentBounds.width() / 2.0, -contentBounds.height() / 2.0);
     410
     411    return calculateVisibleRect(targetSurfaceRect, layerBoundRect, transform);
     412}
     413
    409414static void paintContentsIfDirty(LayerChromium* layer, const IntRect& visibleLayerRect)
    410415{
     
    432437            continue;
    433438
     439        if (!renderSurface->m_drawOpacity)
     440            continue;
     441
    434442        LayerList& layerList = renderSurface->m_layerList;
    435443        ASSERT(layerList.size());
     
    445453
    446454            layer->setLayerRenderer(this);
     455
     456            if (!layer->opacity())
     457                continue;
    447458
    448459            if (layer->maskLayer())
     
    525536    for (int surfaceIndex = renderSurfaceLayerList.size() - 1; surfaceIndex >= 0 ; --surfaceIndex) {
    526537        CCLayerImpl* renderSurfaceLayer = renderSurfaceLayerList[surfaceIndex].get();
    527         ASSERT(renderSurfaceLayer->renderSurface());
     538        RenderSurfaceChromium* renderSurface = renderSurfaceLayer->renderSurface();
     539        ASSERT(renderSurface);
     540
     541        renderSurface->m_skipsDraw = true;
    528542
    529543        // Render surfaces whose drawable area has zero width or height
    530544        // will have no layers associated with them and should be skipped.
    531         if (!renderSurfaceLayer->renderSurface()->m_layerList.size())
     545        if (!renderSurface->m_layerList.size())
    532546            continue;
    533547
    534         if (useRenderSurface(renderSurfaceLayer->renderSurface())) {
     548        // Skip completely transparent render surfaces.
     549        if (!renderSurface->m_drawOpacity)
     550            continue;
     551
     552        if (useRenderSurface(renderSurface)) {
     553            renderSurface->m_skipsDraw = false;
     554
    535555            if (renderSurfaceLayer != rootDrawLayer) {
    536556                GLC(m_context.get(), m_context->disable(GraphicsContext3D::SCISSOR_TEST));
     
    540560            }
    541561
    542             LayerList& layerList = renderSurfaceLayer->renderSurface()->m_layerList;
    543             ASSERT(layerList.size());
     562            LayerList& layerList = renderSurface->m_layerList;
    544563            for (unsigned layerIndex = 0; layerIndex < layerList.size(); ++layerIndex)
    545                 drawLayer(layerList[layerIndex].get(), renderSurfaceLayer->renderSurface());
     564                drawLayer(layerList[layerIndex].get(), renderSurface);
    546565        }
    547566    }
     
    799818    // drawableContentRect() is always stored in the coordinate system of the
    800819    // RenderSurface the layer draws into.
    801     if (layer->drawsContent())
    802         layer->setDrawableContentRect(transformedLayerRect);
    803     else
     820    if (layer->drawsContent()) {
     821        IntRect drawableContentRect = transformedLayerRect;
     822        if (layer->usesLayerScissor())
     823            drawableContentRect.intersect(layer->scissorRect());
     824        layer->setDrawableContentRect(drawableContentRect);
     825    } else
    804826        layer->setDrawableContentRect(IntRect());
    805827
     
    864886        // clipped.
    865887        if (!layer->replicaLayer()) {
    866             if (!layer->scissorRect().isEmpty())
    867                 renderSurface->m_contentRect.intersect(layer->scissorRect());
     888            if (!renderSurface->m_scissorRect.isEmpty() && !renderSurface->m_contentRect.isEmpty()) {
     889                IntRect surfaceScissorRect = calculateVisibleRect(renderSurface->m_scissorRect, renderSurface->m_contentRect, renderSurface->m_originTransform);
     890                renderSurface->m_contentRect.intersect(surfaceScissorRect);
     891            }
    868892            FloatPoint clippedSurfaceCenter = renderSurface->contentRectCenter();
    869893            centerOffsetDueToClipping = clippedSurfaceCenter - surfaceCenter;
     
    910934        ASSERT(renderSurface);
    911935
    912         if (!renderSurface->m_layerList.size())
     936        if (!renderSurface->m_layerList.size() || !renderSurface->m_drawOpacity)
    913937            continue;
    914938
     
    930954
    931955    if (layer->bounds().isEmpty())
     956        return;
     957
     958    if (!layer->opacity())
    932959        return;
    933960
     
    10181045        return;
    10191046
     1047    if (!layer->opacity())
     1048        return;
     1049
    10201050    if (layer->bounds().isEmpty())
    10211051        return;
    10221052
    1023     if (layer->usesLayerScissor())
    1024         setScissorToRect(layer->scissorRect());
    1025     else
    1026         GLC(m_context.get(), m_context->disable(GraphicsContext3D::SCISSOR_TEST));
    1027    
    10281053    IntRect targetSurfaceRect = layer->targetRenderSurface() ? layer->targetRenderSurface()->contentRect() : m_defaultRenderSurface->contentRect();
    10291054    if (layer->usesLayerScissor()) {
    10301055        IntRect scissorRect = layer->scissorRect();
    10311056        targetSurfaceRect.intersect(scissorRect);
    1032     }
     1057        if (targetSurfaceRect.isEmpty())
     1058            return;
     1059        setScissorToRect(scissorRect);
     1060    } else
     1061        GLC(m_context.get(), m_context->disable(GraphicsContext3D::SCISSOR_TEST));
     1062
    10331063
    10341064    // FIXME: Need to take into account the commulative render surface transforms all the way from
  • trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.cpp

    r90492 r90589  
    4444    , m_maskLayer(0)
    4545    , m_skipsDraw(false)
     46    , m_drawOpacity(1)
    4647{
    4748}
Note: See TracChangeset for help on using the changeset viewer.