Changeset 90589 in webkit
- Timestamp:
- Jul 7, 2011 2:06:58 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r90588 r90589 1 2011-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 1 27 2011-07-07 Adam Barth <abarth@webkit.org> 2 28 -
trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
r90587 r90589 374 374 } 375 375 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 376 static IntRect calculateVisibleRect(const IntRect& targetSurfaceRect, const IntRect& layerBoundRect, const TransformationMatrix& transform) 377 { 388 378 // Is this layer fully contained within the target surface? 389 379 IntRect layerInSurfaceSpace = transform.mapRect(layerBoundRect); … … 407 397 } 408 398 399 static 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 409 414 static void paintContentsIfDirty(LayerChromium* layer, const IntRect& visibleLayerRect) 410 415 { … … 432 437 continue; 433 438 439 if (!renderSurface->m_drawOpacity) 440 continue; 441 434 442 LayerList& layerList = renderSurface->m_layerList; 435 443 ASSERT(layerList.size()); … … 445 453 446 454 layer->setLayerRenderer(this); 455 456 if (!layer->opacity()) 457 continue; 447 458 448 459 if (layer->maskLayer()) … … 525 536 for (int surfaceIndex = renderSurfaceLayerList.size() - 1; surfaceIndex >= 0 ; --surfaceIndex) { 526 537 CCLayerImpl* renderSurfaceLayer = renderSurfaceLayerList[surfaceIndex].get(); 527 ASSERT(renderSurfaceLayer->renderSurface()); 538 RenderSurfaceChromium* renderSurface = renderSurfaceLayer->renderSurface(); 539 ASSERT(renderSurface); 540 541 renderSurface->m_skipsDraw = true; 528 542 529 543 // Render surfaces whose drawable area has zero width or height 530 544 // will have no layers associated with them and should be skipped. 531 if (!renderSurface Layer->renderSurface()->m_layerList.size())545 if (!renderSurface->m_layerList.size()) 532 546 continue; 533 547 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 535 555 if (renderSurfaceLayer != rootDrawLayer) { 536 556 GLC(m_context.get(), m_context->disable(GraphicsContext3D::SCISSOR_TEST)); … … 540 560 } 541 561 542 LayerList& layerList = renderSurfaceLayer->renderSurface()->m_layerList; 543 ASSERT(layerList.size()); 562 LayerList& layerList = renderSurface->m_layerList; 544 563 for (unsigned layerIndex = 0; layerIndex < layerList.size(); ++layerIndex) 545 drawLayer(layerList[layerIndex].get(), renderSurface Layer->renderSurface());564 drawLayer(layerList[layerIndex].get(), renderSurface); 546 565 } 547 566 } … … 799 818 // drawableContentRect() is always stored in the coordinate system of the 800 819 // 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 804 826 layer->setDrawableContentRect(IntRect()); 805 827 … … 864 886 // clipped. 865 887 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 } 868 892 FloatPoint clippedSurfaceCenter = renderSurface->contentRectCenter(); 869 893 centerOffsetDueToClipping = clippedSurfaceCenter - surfaceCenter; … … 910 934 ASSERT(renderSurface); 911 935 912 if (!renderSurface->m_layerList.size() )936 if (!renderSurface->m_layerList.size() || !renderSurface->m_drawOpacity) 913 937 continue; 914 938 … … 930 954 931 955 if (layer->bounds().isEmpty()) 956 return; 957 958 if (!layer->opacity()) 932 959 return; 933 960 … … 1018 1045 return; 1019 1046 1047 if (!layer->opacity()) 1048 return; 1049 1020 1050 if (layer->bounds().isEmpty()) 1021 1051 return; 1022 1052 1023 if (layer->usesLayerScissor())1024 setScissorToRect(layer->scissorRect());1025 else1026 GLC(m_context.get(), m_context->disable(GraphicsContext3D::SCISSOR_TEST));1027 1028 1053 IntRect targetSurfaceRect = layer->targetRenderSurface() ? layer->targetRenderSurface()->contentRect() : m_defaultRenderSurface->contentRect(); 1029 1054 if (layer->usesLayerScissor()) { 1030 1055 IntRect scissorRect = layer->scissorRect(); 1031 1056 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 1033 1063 1034 1064 // 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 44 44 , m_maskLayer(0) 45 45 , m_skipsDraw(false) 46 , m_drawOpacity(1) 46 47 { 47 48 }
Note: See TracChangeset
for help on using the changeset viewer.