Title: [90589] trunk/Source/WebCore
Revision
90589
Author
[email protected]
Date
2011-07-07 14:06:58 -0700 (Thu, 07 Jul 2011)

Log 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 [email protected].

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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (90588 => 90589)


--- trunk/Source/WebCore/ChangeLog	2011-07-07 20:45:10 UTC (rev 90588)
+++ trunk/Source/WebCore/ChangeLog	2011-07-07 21:06:58 UTC (rev 90589)
@@ -1,3 +1,29 @@
+2011-07-06  Adrienne Walker  <[email protected]>
+
+        [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 [email protected].
+
+        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):
+
 2011-07-07  Adam Barth  <[email protected]>
 
         Unreviewed, rolling out r90581.

Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp (90588 => 90589)


--- trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp	2011-07-07 20:45:10 UTC (rev 90588)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp	2011-07-07 21:06:58 UTC (rev 90589)
@@ -373,18 +373,8 @@
     updateCompositorResources(renderSurfaceLayerList);
 }
 
-static IntRect calculateVisibleLayerRect(const IntRect& targetSurfaceRect, const IntSize& bounds, const IntSize& contentBounds, const TransformationMatrix& tilingTransform)
+static IntRect calculateVisibleRect(const IntRect& targetSurfaceRect, const IntRect& layerBoundRect, const TransformationMatrix& transform)
 {
-    if (targetSurfaceRect.isEmpty() || contentBounds.isEmpty())
-        return targetSurfaceRect;
-
-    const IntRect layerBoundRect = IntRect(IntPoint(), contentBounds);
-    TransformationMatrix transform = tilingTransform;
-
-    transform.scaleNonUniform(bounds.width() / static_cast<double>(contentBounds.width()),
-                              bounds.height() / static_cast<double>(contentBounds.height()));
-    transform.translate(-contentBounds.width() / 2.0, -contentBounds.height() / 2.0);
-
     // Is this layer fully contained within the target surface?
     IntRect layerInSurfaceSpace = transform.mapRect(layerBoundRect);
     if (targetSurfaceRect.contains(layerInSurfaceSpace))
@@ -406,6 +396,21 @@
     return layerRect;
 }
 
+static IntRect calculateVisibleLayerRect(const IntRect& targetSurfaceRect, const IntSize& bounds, const IntSize& contentBounds, const TransformationMatrix& tilingTransform)
+{
+    if (targetSurfaceRect.isEmpty() || contentBounds.isEmpty())
+        return targetSurfaceRect;
+
+    const IntRect layerBoundRect = IntRect(IntPoint(), contentBounds);
+    TransformationMatrix transform = tilingTransform;
+
+    transform.scaleNonUniform(bounds.width() / static_cast<double>(contentBounds.width()),
+                              bounds.height() / static_cast<double>(contentBounds.height()));
+    transform.translate(-contentBounds.width() / 2.0, -contentBounds.height() / 2.0);
+
+    return calculateVisibleRect(targetSurfaceRect, layerBoundRect, transform);
+}
+
 static void paintContentsIfDirty(LayerChromium* layer, const IntRect& visibleLayerRect)
 {
     if (layer->drawsContent()) {
@@ -431,6 +436,9 @@
         if (!renderSurface->m_layerList.size())
             continue;
 
+        if (!renderSurface->m_drawOpacity)
+            continue;
+
         LayerList& layerList = renderSurface->m_layerList;
         ASSERT(layerList.size());
         for (unsigned layerIndex = 0; layerIndex < layerList.size(); ++layerIndex) {
@@ -445,6 +453,9 @@
 
             layer->setLayerRenderer(this);
 
+            if (!layer->opacity())
+                continue;
+
             if (layer->maskLayer())
                 layer->maskLayer()->setLayerRenderer(this);
             if (layer->replicaLayer()) {
@@ -524,14 +535,23 @@
     // correct order.
     for (int surfaceIndex = renderSurfaceLayerList.size() - 1; surfaceIndex >= 0 ; --surfaceIndex) {
         CCLayerImpl* renderSurfaceLayer = renderSurfaceLayerList[surfaceIndex].get();
-        ASSERT(renderSurfaceLayer->renderSurface());
+        RenderSurfaceChromium* renderSurface = renderSurfaceLayer->renderSurface();
+        ASSERT(renderSurface);
 
+        renderSurface->m_skipsDraw = true;
+
         // Render surfaces whose drawable area has zero width or height
         // will have no layers associated with them and should be skipped.
-        if (!renderSurfaceLayer->renderSurface()->m_layerList.size())
+        if (!renderSurface->m_layerList.size())
             continue;
 
-        if (useRenderSurface(renderSurfaceLayer->renderSurface())) {
+        // Skip completely transparent render surfaces.
+        if (!renderSurface->m_drawOpacity)
+            continue;
+
+        if (useRenderSurface(renderSurface)) {
+            renderSurface->m_skipsDraw = false;
+
             if (renderSurfaceLayer != rootDrawLayer) {
                 GLC(m_context.get(), m_context->disable(GraphicsContext3D::SCISSOR_TEST));
                 GLC(m_context.get(), m_context->clearColor(0, 0, 0, 0));
@@ -539,10 +559,9 @@
                 GLC(m_context.get(), m_context->enable(GraphicsContext3D::SCISSOR_TEST));
             }
 
-            LayerList& layerList = renderSurfaceLayer->renderSurface()->m_layerList;
-            ASSERT(layerList.size());
+            LayerList& layerList = renderSurface->m_layerList;
             for (unsigned layerIndex = 0; layerIndex < layerList.size(); ++layerIndex)
-                drawLayer(layerList[layerIndex].get(), renderSurfaceLayer->renderSurface());
+                drawLayer(layerList[layerIndex].get(), renderSurface);
         }
     }
 
@@ -798,9 +817,12 @@
 
     // drawableContentRect() is always stored in the coordinate system of the
     // RenderSurface the layer draws into.
-    if (layer->drawsContent())
-        layer->setDrawableContentRect(transformedLayerRect);
-    else
+    if (layer->drawsContent()) {
+        IntRect drawableContentRect = transformedLayerRect;
+        if (layer->usesLayerScissor())
+            drawableContentRect.intersect(layer->scissorRect());
+        layer->setDrawableContentRect(drawableContentRect);
+    } else
         layer->setDrawableContentRect(IntRect());
 
     TransformationMatrix sublayerMatrix = layer->drawTransform();
@@ -863,8 +885,10 @@
         // Don't clip if the layer is reflected as the reflection shouldn't be
         // clipped.
         if (!layer->replicaLayer()) {
-            if (!layer->scissorRect().isEmpty())
-                renderSurface->m_contentRect.intersect(layer->scissorRect());
+            if (!renderSurface->m_scissorRect.isEmpty() && !renderSurface->m_contentRect.isEmpty()) {
+                IntRect surfaceScissorRect = calculateVisibleRect(renderSurface->m_scissorRect, renderSurface->m_contentRect, renderSurface->m_originTransform);
+                renderSurface->m_contentRect.intersect(surfaceScissorRect);
+            }
             FloatPoint clippedSurfaceCenter = renderSurface->contentRectCenter();
             centerOffsetDueToClipping = clippedSurfaceCenter - surfaceCenter;
         }
@@ -909,7 +933,7 @@
         RenderSurfaceChromium* renderSurface = renderSurfaceLayer->renderSurface();
         ASSERT(renderSurface);
 
-        if (!renderSurface->m_layerList.size())
+        if (!renderSurface->m_layerList.size() || !renderSurface->m_drawOpacity)
             continue;
 
         LayerList& layerList = renderSurface->m_layerList;
@@ -931,6 +955,9 @@
     if (layer->bounds().isEmpty())
         return;
 
+    if (!layer->opacity())
+        return;
+
     if (layer->maskLayer())
         updateCompositorResources(ccLayerImpl->maskLayer());
     if (layer->replicaLayer())
@@ -1017,20 +1044,23 @@
     if (!layer->drawsContent())
         return;
 
+    if (!layer->opacity())
+        return;
+
     if (layer->bounds().isEmpty())
         return;
 
-    if (layer->usesLayerScissor())
-        setScissorToRect(layer->scissorRect());
-    else
-        GLC(m_context.get(), m_context->disable(GraphicsContext3D::SCISSOR_TEST));
-    
     IntRect targetSurfaceRect = layer->targetRenderSurface() ? layer->targetRenderSurface()->contentRect() : m_defaultRenderSurface->contentRect();
     if (layer->usesLayerScissor()) {
         IntRect scissorRect = layer->scissorRect();
         targetSurfaceRect.intersect(scissorRect);
-    }
+        if (targetSurfaceRect.isEmpty())
+            return;
+        setScissorToRect(scissorRect);
+    } else
+        GLC(m_context.get(), m_context->disable(GraphicsContext3D::SCISSOR_TEST));
 
+
     // FIXME: Need to take into account the commulative render surface transforms all the way from
     //        the default render surface in order to determine visibility.
     TransformationMatrix combinedDrawMatrix = (layer->targetRenderSurface() ? layer->targetRenderSurface()->drawTransform().multiply(layer->drawTransform()) : layer->drawTransform());

Modified: trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.cpp (90588 => 90589)


--- trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.cpp	2011-07-07 20:45:10 UTC (rev 90588)
+++ trunk/Source/WebCore/platform/graphics/chromium/RenderSurfaceChromium.cpp	2011-07-07 21:06:58 UTC (rev 90589)
@@ -43,6 +43,7 @@
     : m_owningLayer(owningLayer)
     , m_maskLayer(0)
     , m_skipsDraw(false)
+    , m_drawOpacity(1)
 {
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to