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

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 2148 matching lines...) Expand 10 before | Expand all | Expand 10 after
2159 if (!scrollbar) 2159 if (!scrollbar)
2160 return; 2160 return;
2161 2161
2162 const IntRect& scrollbarRect = scrollbar->frameRect(); 2162 const IntRect& scrollbarRect = scrollbar->frameRect();
2163 TransformRecorder transformRecorder(context, *scrollbar, AffineTransform::tr anslation(-scrollbarRect.x(), -scrollbarRect.y())); 2163 TransformRecorder transformRecorder(context, *scrollbar, AffineTransform::tr anslation(-scrollbarRect.x(), -scrollbarRect.y()));
2164 IntRect transformedClip = clip; 2164 IntRect transformedClip = clip;
2165 transformedClip.moveBy(scrollbarRect.location()); 2165 transformedClip.moveBy(scrollbarRect.location());
2166 scrollbar->paint(&context, transformedClip); 2166 scrollbar->paint(&context, transformedClip);
2167 } 2167 }
2168 2168
2169 // Up-call from compositing layer drawing callback. 2169 static const int kPixelDistanceToRecord = 4000;
2170 void CompositedLayerMapping::paintContents(const GraphicsLayer* graphicsLayer, G raphicsContext& context, GraphicsLayerPaintingPhase graphicsLayerPaintingPhase, const IntRect& clip) const 2170
2171 IntRect CompositedLayerMapping::computeInterestRect(const GraphicsLayer* graphic sLayer, LayoutObject* owningLayoutObject)
2172 {
2173 FloatRect graphicsLayerBounds(FloatPoint(), graphicsLayer->size());
2174
2175 // Start with the bounds of the graphics layer in the space of the owning La youtObject.
2176 FloatRect graphicsLayerBoundsInObjectSpace(graphicsLayerBounds);
2177 graphicsLayerBoundsInObjectSpace.move(graphicsLayer->offsetFromLayoutObject( ));
2178
2179 // Now map the bounds to its visible content rect in screen space, including applying clips along the way.
wkorman 2015/10/09 19:46:32 Where are the clips applied, is it basically just
chrishtr 2015/10/09 20:54:52 mapRectToPaintInvalidationBacking actually takes c
2180 LayoutRect visibleContentRect(graphicsLayerBoundsInObjectSpace);
2181 LayoutView* rootView = owningLayoutObject->view();
2182 while (rootView->frame()->ownerLayoutObject())
2183 rootView = rootView->frame()->ownerLayoutObject()->view();
2184 owningLayoutObject->mapRectToPaintInvalidationBacking(rootView, visibleConte ntRect, 0);
2185 visibleContentRect.intersect(LayoutRect(rootView->frameView()->visibleConten tRect()));
2186
2187 // Map the visible content rect from screen space to local graphics layer sp ace.
2188 IntRect localInterestRect;
2189 // If the visible content rect is empty, then it makes no sense to map it ba ck since there is nothing to map.
2190 if (!visibleContentRect.isEmpty()) {
2191 localInterestRect = owningLayoutObject->absoluteToLocalQuad(FloatRect(vi sibleContentRect), UseTransforms).enclosingBoundingBox();
2192 localInterestRect.move(-graphicsLayer->offsetFromLayoutObject());
2193 }
2194 // Expand by interest rect padding amount.
2195 localInterestRect.expand(IntRectOutsets(kPixelDistanceToRecord, kPixelDistan ceToRecord, kPixelDistanceToRecord, kPixelDistanceToRecord));
wkorman 2015/10/09 19:46:32 If we have no visible content rect, do we still ne
chrishtr 2015/10/09 20:54:52 Yes, or otherwise nothing will be recorded because
2196 localInterestRect.intersect(enclosingIntRect(graphicsLayerBounds));
2197 return localInterestRect;
2198 }
ajuma 2015/10/09 20:55:27 Do you have a sense of how efficient this approach
chrishtr 2015/10/09 21:35:45 In that example it should be relatively cheap, bec
2199
2200 void CompositedLayerMapping::paintContentsIfNeeded(const GraphicsLayer* graphics Layer, GraphicsContext& context, GraphicsLayerPaintingPhase graphicsLayerPaintin gPhase) const
2201 {
2202 // TODO(chrishtr): paint if needsDisplay is true *or* the interest rect has changed sufficiently.
2203 if (!graphicsLayer->needsDisplay())
2204 return;
2205
2206 IntRect interestRect;
2207 if (graphicsLayer == m_graphicsLayer || graphicsLayer == m_squashingLayer)
2208 interestRect = computeInterestRect(graphicsLayer, m_owningLayer.layoutOb ject());
2209 else
2210 interestRect = enclosingIntRect(FloatRect(FloatPoint(), graphicsLayer->s ize()));
2211
2212 ASSERT(RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled());
2213 paintContents(graphicsLayer, context, graphicsLayerPaintingPhase, interestRe ct);
2214 }
2215
2216 void CompositedLayerMapping::paintContents(const GraphicsLayer* graphicsLayer, G raphicsContext& context, GraphicsLayerPaintingPhase graphicsLayerPaintingPhase, const IntRect& interestRect) const
2171 { 2217 {
2172 // https://code.google.com/p/chromium/issues/detail?id=343772 2218 // https://code.google.com/p/chromium/issues/detail?id=343772
2173 DisableCompositingQueryAsserts disabler; 2219 DisableCompositingQueryAsserts disabler;
2174 #if ENABLE(ASSERT) 2220 #if ENABLE(ASSERT)
2175 // FIXME: once the state machine is ready, this can be removed and we can re fer to that instead. 2221 // 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()) 2222 if (Page* page = layoutObject()->frame()->page())
2177 page->setIsPainting(true); 2223 page->setIsPainting(true);
2178 #endif 2224 #endif
2179 TRACE_EVENT1("devtools.timeline", "Paint", "data", InspectorPaintEvent::data (m_owningLayer.layoutObject(), LayoutRect(clip), graphicsLayer)); 2225
2226 TRACE_EVENT1("devtools.timeline", "Paint", "data", InspectorPaintEvent::data (m_owningLayer.layoutObject(), LayoutRect(interestRect), graphicsLayer));
2180 2227
2181 PaintLayerFlags paintLayerFlags = 0; 2228 PaintLayerFlags paintLayerFlags = 0;
2182 if (graphicsLayerPaintingPhase & GraphicsLayerPaintBackground) 2229 if (graphicsLayerPaintingPhase & GraphicsLayerPaintBackground)
2183 paintLayerFlags |= PaintLayerPaintingCompositingBackgroundPhase; 2230 paintLayerFlags |= PaintLayerPaintingCompositingBackgroundPhase;
2184 if (graphicsLayerPaintingPhase & GraphicsLayerPaintForeground) 2231 if (graphicsLayerPaintingPhase & GraphicsLayerPaintForeground)
2185 paintLayerFlags |= PaintLayerPaintingCompositingForegroundPhase; 2232 paintLayerFlags |= PaintLayerPaintingCompositingForegroundPhase;
2186 if (graphicsLayerPaintingPhase & GraphicsLayerPaintMask) 2233 if (graphicsLayerPaintingPhase & GraphicsLayerPaintMask)
2187 paintLayerFlags |= PaintLayerPaintingCompositingMaskPhase; 2234 paintLayerFlags |= PaintLayerPaintingCompositingMaskPhase;
2188 if (graphicsLayerPaintingPhase & GraphicsLayerPaintChildClippingMask) 2235 if (graphicsLayerPaintingPhase & GraphicsLayerPaintChildClippingMask)
2189 paintLayerFlags |= PaintLayerPaintingChildClippingMaskPhase; 2236 paintLayerFlags |= PaintLayerPaintingChildClippingMaskPhase;
(...skipping 14 matching lines...) Expand all
2204 || graphicsLayer == m_childClippingMaskLayer.get() 2251 || graphicsLayer == m_childClippingMaskLayer.get()
2205 || graphicsLayer == m_scrollingContentsLayer.get() 2252 || graphicsLayer == m_scrollingContentsLayer.get()
2206 || graphicsLayer == m_scrollingBlockSelectionLayer.get()) { 2253 || graphicsLayer == m_scrollingBlockSelectionLayer.get()) {
2207 2254
2208 GraphicsLayerPaintInfo paintInfo; 2255 GraphicsLayerPaintInfo paintInfo;
2209 paintInfo.paintLayer = &m_owningLayer; 2256 paintInfo.paintLayer = &m_owningLayer;
2210 paintInfo.compositedBounds = compositedBounds(); 2257 paintInfo.compositedBounds = compositedBounds();
2211 paintInfo.offsetFromLayoutObject = graphicsLayer->offsetFromLayoutObject (); 2258 paintInfo.offsetFromLayoutObject = graphicsLayer->offsetFromLayoutObject ();
2212 2259
2213 // We have to use the same root as for hit testing, because both methods can compute and cache clipRects. 2260 // 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); 2261 doPaintTask(paintInfo, paintLayerFlags, &context, interestRect);
2215 } else if (graphicsLayer == m_squashingLayer.get()) { 2262 } else if (graphicsLayer == m_squashingLayer.get()) {
2216 for (size_t i = 0; i < m_squashedLayers.size(); ++i) 2263 for (size_t i = 0; i < m_squashedLayers.size(); ++i)
2217 doPaintTask(m_squashedLayers[i], paintLayerFlags, &context, clip); 2264 doPaintTask(m_squashedLayers[i], paintLayerFlags, &context, interest Rect);
2218 } else if (graphicsLayer == layerForHorizontalScrollbar()) { 2265 } else if (graphicsLayer == layerForHorizontalScrollbar()) {
2219 paintScrollbar(m_owningLayer.scrollableArea()->horizontalScrollbar(), co ntext, clip); 2266 paintScrollbar(m_owningLayer.scrollableArea()->horizontalScrollbar(), co ntext, interestRect);
2220 } else if (graphicsLayer == layerForVerticalScrollbar()) { 2267 } else if (graphicsLayer == layerForVerticalScrollbar()) {
2221 paintScrollbar(m_owningLayer.scrollableArea()->verticalScrollbar(), cont ext, clip); 2268 paintScrollbar(m_owningLayer.scrollableArea()->verticalScrollbar(), cont ext, interestRect);
2222 } else if (graphicsLayer == layerForScrollCorner()) { 2269 } else if (graphicsLayer == layerForScrollCorner()) {
2223 IntPoint scrollCornerAndResizerLocation = m_owningLayer.scrollableArea() ->scrollCornerAndResizerRect().location(); 2270 IntPoint scrollCornerAndResizerLocation = m_owningLayer.scrollableArea() ->scrollCornerAndResizerRect().location();
2224 ScrollableAreaPainter(*m_owningLayer.scrollableArea()).paintScrollCorner (&context, -scrollCornerAndResizerLocation, clip); 2271 ScrollableAreaPainter(*m_owningLayer.scrollableArea()).paintScrollCorner (&context, -scrollCornerAndResizerLocation, interestRect);
2225 ScrollableAreaPainter(*m_owningLayer.scrollableArea()).paintResizer(&con text, -scrollCornerAndResizerLocation, clip); 2272 ScrollableAreaPainter(*m_owningLayer.scrollableArea()).paintResizer(&con text, -scrollCornerAndResizerLocation, interestRect);
2226 } 2273 }
2227 InspectorInstrumentation::didPaint(m_owningLayer.layoutObject(), graphicsLay er, &context, LayoutRect(clip)); 2274 InspectorInstrumentation::didPaint(m_owningLayer.layoutObject(), graphicsLay er, &context, LayoutRect(interestRect));
2228 #if ENABLE(ASSERT) 2275 #if ENABLE(ASSERT)
2229 if (Page* page = layoutObject()->frame()->page()) 2276 if (Page* page = layoutObject()->frame()->page())
2230 page->setIsPainting(false); 2277 page->setIsPainting(false);
2231 #endif 2278 #endif
2232 } 2279 }
2233 2280
2234 bool CompositedLayerMapping::isTrackingPaintInvalidations() const 2281 bool CompositedLayerMapping::isTrackingPaintInvalidations() const
2235 { 2282 {
2236 GraphicsLayerClient* client = compositor(); 2283 GraphicsLayerClient* client = compositor();
2237 return client ? client->isTrackingPaintInvalidations() : false; 2284 return client ? client->isTrackingPaintInvalidations() : false;
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
2390 } else if (graphicsLayer == m_scrollingBlockSelectionLayer.get()) { 2437 } else if (graphicsLayer == m_scrollingBlockSelectionLayer.get()) {
2391 name = "Scrolling Block Selection Layer"; 2438 name = "Scrolling Block Selection Layer";
2392 } else { 2439 } else {
2393 ASSERT_NOT_REACHED(); 2440 ASSERT_NOT_REACHED();
2394 } 2441 }
2395 2442
2396 return name; 2443 return name;
2397 } 2444 }
2398 2445
2399 } // namespace blink 2446 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698