Changeset 136179 in webkit
- Timestamp:
- Nov 29, 2012, 4:20:46 PM (14 years ago)
- Location:
- branches/safari-536.28-branch/Source/WebCore
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
platform/graphics/mac/WebLayer.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-536.28-branch/Source/WebCore/ChangeLog
r136043 r136179 1 2012-11-29 Simon Fraser <simon.fraser@apple.com> 2 3 <rdar://problem/12781055> 4 5 Merge r136174 6 7 2012-11-29 Simon Fraser <simon.fraser@apple.com> 8 9 Avoid painting lots of small rects in WebLayer painting 10 https://bugs.webkit.org/show_bug.cgi?id=103673 11 12 Reviewed by Tim Horton. 13 14 r109186 added code in drawLayerContents() to enumerate over the rects in 15 the CALayer's dirty region, and paint them individually. This was done 16 to help performance on the IE Maze Solver test. 17 18 On large, complex pages like Facebook, the overhead of traversing the 19 RenderLayer tree for painting is such that it's better to paint a single, 20 or fewer rects rather than lots of little ones. 21 22 So adopt a heuristic similar to that in DrawingArea, where if the 23 combined area of the small rects is 75% or more of the combined rect, 24 just paint the combined rect. Also paint the combined rect if there 25 are more than 5 individual rects. 26 27 I verified that this preserves the optimization for IE Maze Solver. 28 29 * platform/graphics/mac/WebLayer.mm: 30 (drawLayerContents): 31 1 32 2012-11-28 Lucas Forschler <lforschler@apple.com> 2 33 -
branches/safari-536.28-branch/Source/WebCore/platform/graphics/mac/WebLayer.mm
r116048 r136179 86 86 87 87 #if !defined(BUILDING_ON_SNOW_LEOPARD) 88 __block GraphicsContext* ctx = &graphicsContext; 89 90 wkCALayerEnumerateRectsBeingDrawnWithBlock(layer, context, ^(CGRect rect){ 91 FloatRect rectBeingDrawn(rect); 92 rectBeingDrawn.intersect(clipBounds); 93 94 GraphicsContextStateSaver stateSaver(*ctx); 95 ctx->clip(rectBeingDrawn); 96 97 layerContents->platformCALayerPaintContents(*ctx, enclosingIntRect(rectBeingDrawn)); 88 const float wastedSpaceThreshold = 0.75f; 89 const unsigned maxRectsToPaint = 5; 90 91 double clipArea = clipBounds.width() * clipBounds.height(); 92 __block double totalRectArea = 0; 93 __block unsigned rectCount = 0; 94 __block Vector<FloatRect, maxRectsToPaint> dirtyRects; 95 96 wkCALayerEnumerateRectsBeingDrawnWithBlock(layer, context, ^(CGRect rect) { 97 if (++rectCount > maxRectsToPaint) 98 return; 99 100 totalRectArea += rect.size.width * rect.size.height; 101 dirtyRects.append(rect); 98 102 }); 103 104 if (rectCount < maxRectsToPaint && totalRectArea < clipArea * wastedSpaceThreshold) { 105 for (unsigned i = 0; i < rectCount; ++i) { 106 const FloatRect& currentRect = dirtyRects[i]; 107 108 GraphicsContextStateSaver stateSaver(graphicsContext); 109 graphicsContext.clip(currentRect); 110 111 layerContents->platformCALayerPaintContents(graphicsContext, enclosingIntRect(currentRect)); 112 } 113 } else { 114 // CGContextGetClipBoundingBox() gives us the bounds of the dirty region, so clipBounds 115 // encompasses all the dirty rects. 116 layerContents->platformCALayerPaintContents(graphicsContext, enclosingIntRect(clipBounds)); 117 } 99 118 100 119 #else
Note:
See TracChangeset
for help on using the changeset viewer.