Changeset 70010 in webkit
- Timestamp:
- Oct 18, 2010 4:53:10 PM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r70003 r70010 1 2010-10-18 Vangelis Kokkevis <vangelis@chromium.org> 2 3 Reviewed by James Robinson. 4 5 [chromium] Prevent the creation of very large textures for layers by switching 6 to "large layer" mode when a texture is larger than some fixed reasonable size 7 (set to 2000 pixels for now). 8 https://bugs.webkit.org/show_bug.cgi?id=47751 9 10 The code also changes the large layer logic to use the current scissor rect used 11 by the compositor instead of the visible rect to determine how to clip large layers. 12 This will provide additional texture savings. In addition, the various layer rects 13 have been converted to use integers instead of floats to preserve uniformity in the code. 14 15 Tests: Existing large layer layout tests including huge-layer and huge-layer-img 16 17 * platform/graphics/chromium/ContentLayerChromium.cpp: 18 (WebCore::ContentLayerChromium::requiresClippedUpdateRect): 19 (WebCore::ContentLayerChromium::calculateClippedUpdateRect): 20 * platform/graphics/chromium/LayerChromium.cpp: 21 (WebCore::LayerChromium::getDrawRect): 22 * platform/graphics/chromium/LayerChromium.h: 23 * platform/graphics/chromium/LayerRendererChromium.cpp: 24 (WebCore::LayerRendererChromium::drawLayers): 25 (WebCore::LayerRendererChromium::drawLayersRecursive): 26 (WebCore::LayerRendererChromium::scissorToRect): 27 * platform/graphics/chromium/LayerRendererChromium.h: 28 (WebCore::LayerRendererChromium::currentScissorRect): 29 1 30 2010-10-18 Jia Pu <jpu@apple.com> 2 31 -
trunk/WebCore/platform/graphics/chromium/ContentLayerChromium.cpp
r69747 r70010 144 144 bool ContentLayerChromium::requiresClippedUpdateRect() const 145 145 { 146 return !layerRenderer()->checkTextureSize(m_bounds); 146 // To avoid allocating excessively large textures, switch into "large layer mode" if 147 // one of the layer's dimensions is larger than 2000 pixels or the current size 148 // of the visible rect. This is a temporary measure until layer tiling is implemented. 149 static const int maxLayerSize = 2000; 150 return (m_bounds.width() > max(maxLayerSize, layerRenderer()->rootLayerContentRect().width()) 151 || m_bounds.height() > max(maxLayerSize, layerRenderer()->rootLayerContentRect().height()) 152 || !layerRenderer()->checkTextureSize(m_bounds)); 147 153 } 148 154 … … 153 159 // 2) The content rect-relative rectangle to draw this texture in, returned in drawRect. 154 160 155 const IntRect c ontentRect = layerRenderer()->rootLayerContentRect();161 const IntRect clipRect = layerRenderer()->currentScissorRect(); 156 162 const TransformationMatrix& transform = drawTransform(); 157 163 // The layer's draw transform points to the center of the layer, relative to … … 161 167 m_bounds.height() / 2 - transform.m42()); 162 168 // Transform the contentRect into the space of the layer. 163 IntRect contentRectInLayerSpace(layerPos, c ontentRect.size());169 IntRect contentRectInLayerSpace(layerPos, clipRect.size()); 164 170 165 171 // Clip the entire layer against the visible region in the content rect -
trunk/WebCore/platform/graphics/chromium/LayerChromium.cpp
r69166 r70010 452 452 } 453 453 454 const FloatRect LayerChromium::getDrawRect() const454 const IntRect LayerChromium::getDrawRect() const 455 455 { 456 456 // Form the matrix used by the shader to map the corners of the layer's 457 457 // bounds into the view space. 458 TransformationMatrix renderMatrix = drawTransform(); 459 renderMatrix.scale3d(bounds().width(), bounds().height(), 1); 460 461 FloatRect layerRect(-0.5, -0.5, 1, 1); 462 FloatRect mappedRect = renderMatrix.mapRect(layerRect); 458 FloatRect layerRect(-0.5 * bounds().width(), -0.5 * bounds().height(), bounds().width(), bounds().height()); 459 IntRect mappedRect = enclosingIntRect(drawTransform().mapRect(layerRect)); 463 460 return mappedRect; 464 461 } -
trunk/WebCore/platform/graphics/chromium/LayerChromium.h
r69166 r70010 157 157 158 158 // Returns the rect containtaining this layer in the current view's coordinate system. 159 const FloatRect getDrawRect() const;159 const IntRect getDrawRect() const; 160 160 161 161 // These methods typically need to be overwritten by derived classes. -
trunk/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
r69747 r70010 322 322 // Enable scissoring to avoid rendering composited layers over the scrollbars. 323 323 GLC(m_context, m_context->enable(GraphicsContext3D::SCISSOR_TEST)); 324 FloatRect scissorRect(contentRect);324 IntRect scissorRect(contentRect); 325 325 326 326 // The scissorRect should not include the scroll offset. … … 335 335 // Traverse the layer tree one more time to draw the layers. 336 336 for (size_t i = 0; i < sublayers.size(); i++) 337 drawLayersRecursive(sublayers[i].get() , scissorRect);337 drawLayersRecursive(sublayers[i].get()); 338 338 339 339 GLC(m_context, m_context->disable(GraphicsContext3D::SCISSOR_TEST)); … … 502 502 503 503 // Recursively walk the layer tree and draw the layers. 504 void LayerRendererChromium::drawLayersRecursive(LayerChromium* layer , const FloatRect& scissorRect)504 void LayerRendererChromium::drawLayersRecursive(LayerChromium* layer) 505 505 { 506 506 static bool depthTestEnabledForSubtree = false; … … 508 508 509 509 // Check if the layer falls within the visible bounds of the page. 510 FloatRect layerRect = layer->getDrawRect();511 bool isLayerVisible = scissorRect.intersects(layerRect);510 IntRect layerRect = layer->getDrawRect(); 511 bool isLayerVisible = m_currentScissorRect.intersects(layerRect); 512 512 513 513 // Enable depth testing for this layer and all its descendants if preserves3D is set. … … 528 528 // FIXME: We should check here if the layer has descendants that draw content 529 529 // before we setup for clipping. 530 FloatRect currentScissorRect = scissorRect;530 IntRect previousScissorRect = m_currentScissorRect; 531 531 bool mustResetScissorRect = false; 532 532 bool didStencilDraw = false; … … 535 535 // to clip using the stencil buffer. 536 536 if (layer->drawTransform().isIdentityOrTranslation()) { 537 IntRect currentScissorRect = previousScissorRect; 537 538 currentScissorRect.intersect(layerRect); 538 if (currentScissorRect != scissorRect) {539 if (currentScissorRect != previousScissorRect) { 539 540 scissorToRect(currentScissorRect); 540 541 mustResetScissorRect = true; … … 581 582 582 583 for (i = 0; i < sublayerList.size(); i++) 583 drawLayersRecursive(sublayerList[i] , currentScissorRect);584 drawLayersRecursive(sublayerList[i]); 584 585 } else { 585 586 const Vector<RefPtr<LayerChromium> >& sublayers = layer->getSublayers(); 586 587 for (size_t i = 0; i < sublayers.size(); i++) 587 drawLayersRecursive(sublayers[i].get() , currentScissorRect);588 drawLayersRecursive(sublayers[i].get()); 588 589 } 589 590 … … 601 602 602 603 if (mustResetScissorRect) { 603 scissorToRect( scissorRect);604 scissorToRect(previousScissorRect); 604 605 } 605 606 … … 637 638 // Sets the scissor region to the given rectangle. The coordinate system for the 638 639 // scissorRect has its origin at the top left corner of the current visible rect. 639 void LayerRendererChromium::scissorToRect(const FloatRect& scissorRect)640 void LayerRendererChromium::scissorToRect(const IntRect& scissorRect) 640 641 { 641 642 // Compute the lower left corner of the scissor rect. 642 float bottom = std::max((float)m_rootVisibleRect.height() - scissorRect.bottom(), 0.f);643 int bottom = std::max(m_rootVisibleRect.height() - scissorRect.bottom(), 0); 643 644 GLC(m_context, m_context->scissor(scissorRect.x(), bottom, scissorRect.width(), scissorRect.height())); 645 m_currentScissorRect = scissorRect; 644 646 } 645 647 -
trunk/WebCore/platform/graphics/chromium/LayerRendererChromium.h
r69747 r70010 93 93 void deleteLayerTexture(unsigned); 94 94 95 IntRect currentScissorRect() const { return m_currentScissorRect; } 96 95 97 static void debugGLCall(GraphicsContext3D*, const char* command, const char* file, int line); 96 98 … … 117 119 void updateLayersRecursive(LayerChromium* layer, const TransformationMatrix& parentMatrix, float opacity); 118 120 119 void drawLayersRecursive(LayerChromium* , const FloatRect& scissorRect);121 void drawLayersRecursive(LayerChromium*); 120 122 121 123 void drawLayer(LayerChromium*); … … 125 127 void drawLayerIntoStencilBuffer(LayerChromium*, bool decrement); 126 128 127 void scissorToRect(const FloatRect&);129 void scissorToRect(const IntRect&); 128 130 129 131 bool makeContextCurrent(); … … 164 166 IntRect m_rootVisibleRect; 165 167 IntRect m_rootContentRect; 168 IntRect m_currentScissorRect; 166 169 167 170 int m_maxTextureSize;
Note: See TracChangeset
for help on using the changeset viewer.