Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(412)

Side by Side Diff: third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp

Issue 1393083003: Implement interest rects for synchronized paint. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 2092 matching lines...) Expand 10 before | Expand all | Expand 10 after
2103 FontCachePurgePreventer fontCachePurgePreventer; 2103 FontCachePurgePreventer fontCachePurgePreventer;
2104 2104
2105 IntSize offset = paintInfo.offsetFromLayoutObject; 2105 IntSize offset = paintInfo.offsetFromLayoutObject;
2106 AffineTransform translation; 2106 AffineTransform translation;
2107 translation.translate(-offset.width(), -offset.height()); 2107 translation.translate(-offset.width(), -offset.height());
2108 TransformRecorder transformRecorder(*context, *this, translation); 2108 TransformRecorder transformRecorder(*context, *this, translation);
2109 2109
2110 // The dirtyRect is in the coords of the painting root. 2110 // The dirtyRect is in the coords of the painting root.
2111 IntRect dirtyRect(clip); 2111 IntRect dirtyRect(clip);
2112 dirtyRect.move(offset); 2112 dirtyRect.move(offset);
2113
2114 if (!(paintLayerFlags & PaintLayerPaintingOverflowContents)) { 2113 if (!(paintLayerFlags & PaintLayerPaintingOverflowContents)) {
2115 LayoutRect bounds = paintInfo.compositedBounds; 2114 LayoutRect bounds = paintInfo.compositedBounds;
2116 bounds.move(paintInfo.paintLayer->subpixelAccumulation()); 2115 bounds.move(paintInfo.paintLayer->subpixelAccumulation());
2117 dirtyRect.intersect(pixelSnappedIntRect(bounds)); 2116 dirtyRect.intersect(pixelSnappedIntRect(bounds));
2118 } else { 2117 } else {
2119 dirtyRect.move(roundedIntSize(paintInfo.paintLayer->subpixelAccumulation ())); 2118 dirtyRect.move(roundedIntSize(paintInfo.paintLayer->subpixelAccumulation ()));
2120 } 2119 }
2121 2120
2122 #if ENABLE(ASSERT) 2121 #if ENABLE(ASSERT)
2123 paintInfo.paintLayer->layoutObject()->assertSubtreeIsLaidOut(); 2122 paintInfo.paintLayer->layoutObject()->assertSubtreeIsLaidOut();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2159 if (!scrollbar) 2158 if (!scrollbar)
2160 return; 2159 return;
2161 2160
2162 const IntRect& scrollbarRect = scrollbar->frameRect(); 2161 const IntRect& scrollbarRect = scrollbar->frameRect();
2163 TransformRecorder transformRecorder(context, *scrollbar, AffineTransform::tr anslation(-scrollbarRect.x(), -scrollbarRect.y())); 2162 TransformRecorder transformRecorder(context, *scrollbar, AffineTransform::tr anslation(-scrollbarRect.x(), -scrollbarRect.y()));
2164 IntRect transformedClip = clip; 2163 IntRect transformedClip = clip;
2165 transformedClip.moveBy(scrollbarRect.location()); 2164 transformedClip.moveBy(scrollbarRect.location());
2166 scrollbar->paint(&context, transformedClip); 2165 scrollbar->paint(&context, transformedClip);
2167 } 2166 }
2168 2167
2169 // Up-call from compositing layer drawing callback. 2168 static const int kPixelDistanceToRecord = 4000;
2170 void CompositedLayerMapping::paintContents(const GraphicsLayer* graphicsLayer, G raphicsContext& context, GraphicsLayerPaintingPhase graphicsLayerPaintingPhase, const IntRect& clip) const 2169
2170 IntRect CompositedLayerMapping::computeInterestRect(const GraphicsLayer* graphic sLayer, LayoutObject* owningLayoutObject)
2171 {
2172 FloatRect graphicsLayerBounds(FloatPoint(), graphicsLayer->size());
2173
2174 // Start with the bounds of the graphics layer in the space of the owning La youtObject.
2175 FloatRect graphicsLayerBoundsInObjectSpace(graphicsLayerBounds);
2176 graphicsLayerBoundsInObjectSpace.move(graphicsLayer->offsetFromLayoutObject( ));
2177
2178 // Now map the bounds to its visible content rect in screen space, including applying clips along the way.
2179 LayoutRect visibleContentRect(graphicsLayerBoundsInObjectSpace);
2180 LayoutView* rootView = owningLayoutObject->view();
2181 while (rootView->frame()->ownerLayoutObject())
2182 rootView = rootView->frame()->ownerLayoutObject()->view();
2183 owningLayoutObject->mapRectToPaintInvalidationBacking(rootView, visibleConte ntRect, 0);
2184 visibleContentRect.intersect(LayoutRect(rootView->frameView()->visibleConten tRect()));
2185
2186 // Map the visible content rect from screen space to local graphics layer sp ace.
2187 IntRect localInterestRect;
2188 // If the visible content rect is empty, then it makes no sense to map it ba ck since there is nothing to map.
2189 if (!visibleContentRect.isEmpty()) {
2190 localInterestRect = owningLayoutObject->absoluteToLocalQuad(FloatRect(vi sibleContentRect), UseTransforms).enclosingBoundingBox();
2191 localInterestRect.move(-graphicsLayer->offsetFromLayoutObject());
2192 }
2193 // Expand by interest rect padding amount.
2194 localInterestRect.expand(IntRectOutsets(kPixelDistanceToRecord, kPixelDistan ceToRecord, kPixelDistanceToRecord, kPixelDistanceToRecord));
2195 localInterestRect.intersect(enclosingIntRect(graphicsLayerBounds));
2196 return localInterestRect;
2197 }
2198
2199 void CompositedLayerMapping::paintContentsIfNeeded(const GraphicsLayer* graphics Layer, GraphicsContext& context, GraphicsLayerPaintingPhase graphicsLayerPaintin gPhase) const
2200 {
2201 // TODO(chrishtr): paint if needsDisplay is true *or* the interest rect has changed sufficiently.
2202 if (!graphicsLayer->needsDisplay())
2203 return;
2204
2205 IntRect interestRect;
2206 if (graphicsLayer == m_graphicsLayer || graphicsLayer == m_squashingLayer)
2207 interestRect = computeInterestRect(graphicsLayer, m_owningLayer.layoutOb ject());
2208 else
2209 interestRect = enclosingIntRect(FloatRect(FloatPoint(), graphicsLayer->s ize()));
2210
2211 ASSERT(RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled());
2212 paintContents(graphicsLayer, context, graphicsLayerPaintingPhase, interestRe ct);
2213 }
2214
2215 void CompositedLayerMapping::paintContents(const GraphicsLayer* graphicsLayer, G raphicsContext& context, GraphicsLayerPaintingPhase graphicsLayerPaintingPhase, const IntRect& interestRect) const
2171 { 2216 {
2172 // https://code.google.com/p/chromium/issues/detail?id=343772 2217 // https://code.google.com/p/chromium/issues/detail?id=343772
2173 DisableCompositingQueryAsserts disabler; 2218 DisableCompositingQueryAsserts disabler;
2174 #if ENABLE(ASSERT) 2219 #if ENABLE(ASSERT)
2175 // FIXME: once the state machine is ready, this can be removed and we can re fer to that instead. 2220 // FIXME: once the state machine is ready, this can be removed and we can re fer to that instead.
2176 if (Page* page = layoutObject()->frame()->page()) 2221 if (Page* page = layoutObject()->frame()->page())
2177 page->setIsPainting(true); 2222 page->setIsPainting(true);
2178 #endif 2223 #endif
2179 TRACE_EVENT1("devtools.timeline", "Paint", "data", InspectorPaintEvent::data (m_owningLayer.layoutObject(), LayoutRect(clip), graphicsLayer)); 2224
2225 TRACE_EVENT1("devtools.timeline", "Paint", "data", InspectorPaintEvent::data (m_owningLayer.layoutObject(), LayoutRect(interestRect), graphicsLayer));
2180 2226
2181 PaintLayerFlags paintLayerFlags = 0; 2227 PaintLayerFlags paintLayerFlags = 0;
2182 if (graphicsLayerPaintingPhase & GraphicsLayerPaintBackground) 2228 if (graphicsLayerPaintingPhase & GraphicsLayerPaintBackground)
2183 paintLayerFlags |= PaintLayerPaintingCompositingBackgroundPhase; 2229 paintLayerFlags |= PaintLayerPaintingCompositingBackgroundPhase;
2184 if (graphicsLayerPaintingPhase & GraphicsLayerPaintForeground) 2230 if (graphicsLayerPaintingPhase & GraphicsLayerPaintForeground)
2185 paintLayerFlags |= PaintLayerPaintingCompositingForegroundPhase; 2231 paintLayerFlags |= PaintLayerPaintingCompositingForegroundPhase;
2186 if (graphicsLayerPaintingPhase & GraphicsLayerPaintMask) 2232 if (graphicsLayerPaintingPhase & GraphicsLayerPaintMask)
2187 paintLayerFlags |= PaintLayerPaintingCompositingMaskPhase; 2233 paintLayerFlags |= PaintLayerPaintingCompositingMaskPhase;
2188 if (graphicsLayerPaintingPhase & GraphicsLayerPaintChildClippingMask) 2234 if (graphicsLayerPaintingPhase & GraphicsLayerPaintChildClippingMask)
2189 paintLayerFlags |= PaintLayerPaintingChildClippingMaskPhase; 2235 paintLayerFlags |= PaintLayerPaintingChildClippingMaskPhase;
(...skipping 14 matching lines...) Expand all
2204 || graphicsLayer == m_childClippingMaskLayer.get() 2250 || graphicsLayer == m_childClippingMaskLayer.get()
2205 || graphicsLayer == m_scrollingContentsLayer.get() 2251 || graphicsLayer == m_scrollingContentsLayer.get()
2206 || graphicsLayer == m_scrollingBlockSelectionLayer.get()) { 2252 || graphicsLayer == m_scrollingBlockSelectionLayer.get()) {
2207 2253
2208 GraphicsLayerPaintInfo paintInfo; 2254 GraphicsLayerPaintInfo paintInfo;
2209 paintInfo.paintLayer = &m_owningLayer; 2255 paintInfo.paintLayer = &m_owningLayer;
2210 paintInfo.compositedBounds = compositedBounds(); 2256 paintInfo.compositedBounds = compositedBounds();
2211 paintInfo.offsetFromLayoutObject = graphicsLayer->offsetFromLayoutObject (); 2257 paintInfo.offsetFromLayoutObject = graphicsLayer->offsetFromLayoutObject ();
2212 2258
2213 // We have to use the same root as for hit testing, because both methods can compute and cache clipRects. 2259 // We have to use the same root as for hit testing, because both methods can compute and cache clipRects.
2214 doPaintTask(paintInfo, paintLayerFlags, &context, clip); 2260 doPaintTask(paintInfo, paintLayerFlags, &context, interestRect);
2215 } else if (graphicsLayer == m_squashingLayer.get()) { 2261 } else if (graphicsLayer == m_squashingLayer.get()) {
2216 for (size_t i = 0; i < m_squashedLayers.size(); ++i) 2262 for (size_t i = 0; i < m_squashedLayers.size(); ++i)
2217 doPaintTask(m_squashedLayers[i], paintLayerFlags, &context, clip); 2263 doPaintTask(m_squashedLayers[i], paintLayerFlags, &context, interest Rect);
2218 } else if (graphicsLayer == layerForHorizontalScrollbar()) { 2264 } else if (graphicsLayer == layerForHorizontalScrollbar()) {
2219 paintScrollbar(m_owningLayer.scrollableArea()->horizontalScrollbar(), co ntext, clip); 2265 paintScrollbar(m_owningLayer.scrollableArea()->horizontalScrollbar(), co ntext, interestRect);
2220 } else if (graphicsLayer == layerForVerticalScrollbar()) { 2266 } else if (graphicsLayer == layerForVerticalScrollbar()) {
2221 paintScrollbar(m_owningLayer.scrollableArea()->verticalScrollbar(), cont ext, clip); 2267 paintScrollbar(m_owningLayer.scrollableArea()->verticalScrollbar(), cont ext, interestRect);
2222 } else if (graphicsLayer == layerForScrollCorner()) { 2268 } else if (graphicsLayer == layerForScrollCorner()) {
2223 IntPoint scrollCornerAndResizerLocation = m_owningLayer.scrollableArea() ->scrollCornerAndResizerRect().location(); 2269 IntPoint scrollCornerAndResizerLocation = m_owningLayer.scrollableArea() ->scrollCornerAndResizerRect().location();
2224 ScrollableAreaPainter(*m_owningLayer.scrollableArea()).paintScrollCorner (&context, -scrollCornerAndResizerLocation, clip); 2270 ScrollableAreaPainter(*m_owningLayer.scrollableArea()).paintScrollCorner (&context, -scrollCornerAndResizerLocation, interestRect);
2225 ScrollableAreaPainter(*m_owningLayer.scrollableArea()).paintResizer(&con text, -scrollCornerAndResizerLocation, clip); 2271 ScrollableAreaPainter(*m_owningLayer.scrollableArea()).paintResizer(&con text, -scrollCornerAndResizerLocation, interestRect);
2226 } 2272 }
2227 InspectorInstrumentation::didPaint(m_owningLayer.layoutObject(), graphicsLay er, &context, LayoutRect(clip)); 2273 InspectorInstrumentation::didPaint(m_owningLayer.layoutObject(), graphicsLay er, &context, LayoutRect(interestRect));
2228 #if ENABLE(ASSERT) 2274 #if ENABLE(ASSERT)
2229 if (Page* page = layoutObject()->frame()->page()) 2275 if (Page* page = layoutObject()->frame()->page())
2230 page->setIsPainting(false); 2276 page->setIsPainting(false);
2231 #endif 2277 #endif
2232 } 2278 }
2233 2279
2234 bool CompositedLayerMapping::isTrackingPaintInvalidations() const 2280 bool CompositedLayerMapping::isTrackingPaintInvalidations() const
2235 { 2281 {
2236 GraphicsLayerClient* client = compositor(); 2282 GraphicsLayerClient* client = compositor();
2237 return client ? client->isTrackingPaintInvalidations() : false; 2283 return client ? client->isTrackingPaintInvalidations() : false;
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
2390 } else if (graphicsLayer == m_scrollingBlockSelectionLayer.get()) { 2436 } else if (graphicsLayer == m_scrollingBlockSelectionLayer.get()) {
2391 name = "Scrolling Block Selection Layer"; 2437 name = "Scrolling Block Selection Layer";
2392 } else { 2438 } else {
2393 ASSERT_NOT_REACHED(); 2439 ASSERT_NOT_REACHED();
2394 } 2440 }
2395 2441
2396 return name; 2442 return name;
2397 } 2443 }
2398 2444
2399 } // namespace blink 2445 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698