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

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

Issue 1441973003: Use recomputed interest rect only if it changed enough (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix release builds Created 5 years, 1 month 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 2173 matching lines...) Expand 10 before | Expand all | Expand 10 after
2184 TransformRecorder transformRecorder(context, *scrollbar, AffineTransform::tr anslation(-scrollbarRect.x(), -scrollbarRect.y())); 2184 TransformRecorder transformRecorder(context, *scrollbar, AffineTransform::tr anslation(-scrollbarRect.x(), -scrollbarRect.y()));
2185 IntRect transformedClip = clip; 2185 IntRect transformedClip = clip;
2186 transformedClip.moveBy(scrollbarRect.location()); 2186 transformedClip.moveBy(scrollbarRect.location());
2187 scrollbar->paint(&context, CullRect(transformedClip)); 2187 scrollbar->paint(&context, CullRect(transformedClip));
2188 } 2188 }
2189 2189
2190 // The following should be kept in sync with the code computing potential_new_re corded_viewport in 2190 // The following should be kept in sync with the code computing potential_new_re corded_viewport in
2191 // cc::DisplayListRecordingSource::UpdateAndExpandInvalidation() before we keep only one copy of the algorithm. 2191 // cc::DisplayListRecordingSource::UpdateAndExpandInvalidation() before we keep only one copy of the algorithm.
2192 static const int kPixelDistanceToRecord = 4000; 2192 static const int kPixelDistanceToRecord = 4000;
2193 2193
2194 IntRect CompositedLayerMapping::computeInterestRect(const GraphicsLayer* graphic sLayer, LayoutObject* owningLayoutObject) 2194 IntRect CompositedLayerMapping::recomputeInterestRect(const GraphicsLayer* graph icsLayer, LayoutObject* owningLayoutObject)
2195 { 2195 {
2196 FloatRect graphicsLayerBounds(FloatPoint(), graphicsLayer->size()); 2196 FloatRect graphicsLayerBounds(FloatPoint(), graphicsLayer->size());
2197 2197
2198 // Start with the bounds of the graphics layer in the space of the owning La youtObject. 2198 // Start with the bounds of the graphics layer in the space of the owning La youtObject.
2199 FloatRect graphicsLayerBoundsInObjectSpace(graphicsLayerBounds); 2199 FloatRect graphicsLayerBoundsInObjectSpace(graphicsLayerBounds);
2200 graphicsLayerBoundsInObjectSpace.move(graphicsLayer->offsetFromLayoutObject( )); 2200 graphicsLayerBoundsInObjectSpace.move(graphicsLayer->offsetFromLayoutObject( ));
2201 2201
2202 // Now map the bounds to its visible content rect in screen space, including applying clips along the way. 2202 // Now map the bounds to its visible content rect in screen space, including applying clips along the way.
2203 LayoutRect visibleContentRect(graphicsLayerBoundsInObjectSpace); 2203 LayoutRect visibleContentRect(graphicsLayerBoundsInObjectSpace);
2204 LayoutView* rootView = owningLayoutObject->view(); 2204 LayoutView* rootView = owningLayoutObject->view();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2249 if (newInterestRect.y() == 0 && previousInterestRect.y() != 0) 2249 if (newInterestRect.y() == 0 && previousInterestRect.y() != 0)
2250 return true; 2250 return true;
2251 if (newInterestRect.maxX() == layerSize.width() && previousInterestRect.maxX () != layerSize.width()) 2251 if (newInterestRect.maxX() == layerSize.width() && previousInterestRect.maxX () != layerSize.width())
2252 return true; 2252 return true;
2253 if (newInterestRect.maxY() == layerSize.height() && previousInterestRect.max Y() != layerSize.height()) 2253 if (newInterestRect.maxY() == layerSize.height() && previousInterestRect.max Y() != layerSize.height())
2254 return true; 2254 return true;
2255 2255
2256 return false; 2256 return false;
2257 } 2257 }
2258 2258
2259 void CompositedLayerMapping::paintContents(const GraphicsLayer* graphicsLayer, G raphicsContext& context, GraphicsLayerPaintingPhase graphicsLayerPaintingPhase, const IntRect* interestRect) const 2259 IntRect CompositedLayerMapping::computeInterestRect(const GraphicsLayer* graphic sLayer, const IntRect& previousInterestRect) const
2260 { 2260 {
2261 IntRect defaultInterestRect; 2261 if (graphicsLayer != m_graphicsLayer && graphicsLayer != m_squashingLayer)
2262 if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()) { 2262 return IntRect(IntPoint(), expandedIntSize(graphicsLayer->size()));
2263 if (!interestRect) {
2264 if (graphicsLayer == m_graphicsLayer || graphicsLayer == m_squashing Layer)
2265 defaultInterestRect = computeInterestRect(graphicsLayer, m_ownin gLayer.layoutObject());
2266 else
2267 defaultInterestRect = enclosingIntRect(FloatRect(FloatPoint(), g raphicsLayer->size()));
2268 interestRect = &defaultInterestRect;
2269 }
2270 2263
2271 if (!m_owningLayer.needsRepaint() 2264 IntRect newInterestRect = recomputeInterestRect(graphicsLayer, m_owningLayer .layoutObject());
2272 && !context.paintController().cacheIsEmpty() 2265 if (interestRectChangedEnoughToRepaint(previousInterestRect, newInterestRect , expandedIntSize(graphicsLayer->size())))
2273 && !interestRectChangedEnoughToRepaint(m_previousPaintInterestRect, *interestRect, expandedIntSize(graphicsLayer->size()))) { 2266 return newInterestRect;
2274 context.paintController().createAndAppend<CachedDisplayItem>(*this, DisplayItem::CachedDisplayItemList); 2267 return previousInterestRect;
2275 return;
2276 }
2277
2278 m_previousPaintInterestRect = *interestRect;
2279 }
2280
2281 ASSERT(interestRect);
2282 paintContentsInternal(graphicsLayer, context, graphicsLayerPaintingPhase, *i nterestRect);
2283 } 2268 }
2284 2269
2285 void CompositedLayerMapping::paintContentsInternal(const GraphicsLayer* graphics Layer, GraphicsContext& context, GraphicsLayerPaintingPhase graphicsLayerPaintin gPhase, const IntRect& interestRect) const 2270 bool CompositedLayerMapping::needsRepaint() const
2271 {
2272 return m_owningLayer.needsRepaint();
2273 }
2274
2275 void CompositedLayerMapping::paintContents(const GraphicsLayer* graphicsLayer, G raphicsContext& context, GraphicsLayerPaintingPhase graphicsLayerPaintingPhase, const IntRect& interestRect) const
2286 { 2276 {
2287 // https://code.google.com/p/chromium/issues/detail?id=343772 2277 // https://code.google.com/p/chromium/issues/detail?id=343772
2288 DisableCompositingQueryAsserts disabler; 2278 DisableCompositingQueryAsserts disabler;
2289 #if ENABLE(ASSERT) 2279 #if ENABLE(ASSERT)
2290 // FIXME: once the state machine is ready, this can be removed and we can re fer to that instead. 2280 // FIXME: once the state machine is ready, this can be removed and we can re fer to that instead.
2291 if (Page* page = layoutObject()->frame()->page()) 2281 if (Page* page = layoutObject()->frame()->page())
2292 page->setIsPainting(true); 2282 page->setIsPainting(true);
2293 #endif 2283 #endif
2294 2284
2295 TRACE_EVENT1("devtools.timeline", "Paint", "data", InspectorPaintEvent::data (m_owningLayer.layoutObject(), LayoutRect(interestRect), graphicsLayer)); 2285 TRACE_EVENT1("devtools.timeline", "Paint", "data", InspectorPaintEvent::data (m_owningLayer.layoutObject(), LayoutRect(interestRect), graphicsLayer));
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
2474 // before removing all the extra entries. 2464 // before removing all the extra entries.
2475 for (size_t i = nextSquashedLayerIndex; i < m_squashedLayers.size(); ++i ) { 2465 for (size_t i = nextSquashedLayerIndex; i < m_squashedLayers.size(); ++i ) {
2476 if (invalidateLayerIfNoPrecedingEntry(i)) 2466 if (invalidateLayerIfNoPrecedingEntry(i))
2477 m_squashedLayers[i].paintLayer->setGroupedMapping(nullptr, Paint Layer::DoNotInvalidateLayerAndRemoveFromMapping); 2467 m_squashedLayers[i].paintLayer->setGroupedMapping(nullptr, Paint Layer::DoNotInvalidateLayerAndRemoveFromMapping);
2478 } 2468 }
2479 2469
2480 m_squashedLayers.remove(nextSquashedLayerIndex, m_squashedLayers.size() - nextSquashedLayerIndex); 2470 m_squashedLayers.remove(nextSquashedLayerIndex, m_squashedLayers.size() - nextSquashedLayerIndex);
2481 } 2471 }
2482 } 2472 }
2483 2473
2484 String CompositedLayerMapping::debugName(const GraphicsLayer* graphicsLayer) 2474 String CompositedLayerMapping::debugName(const GraphicsLayer* graphicsLayer) con st
2485 { 2475 {
2486 String name; 2476 String name;
2487 if (graphicsLayer == m_graphicsLayer.get()) { 2477 if (graphicsLayer == m_graphicsLayer.get()) {
2488 name = m_owningLayer.debugName(); 2478 name = m_owningLayer.debugName();
2489 } else if (graphicsLayer == m_squashingContainmentLayer.get()) { 2479 } else if (graphicsLayer == m_squashingContainmentLayer.get()) {
2490 name = "Squashing Containment Layer"; 2480 name = "Squashing Containment Layer";
2491 } else if (graphicsLayer == m_squashingLayer.get()) { 2481 } else if (graphicsLayer == m_squashingLayer.get()) {
2492 name = "Squashing Layer (first squashed layer: " + (m_squashedLayers.siz e() > 0 ? m_squashedLayers[0].paintLayer->debugName() : "") + ")"; 2482 name = "Squashing Layer (first squashed layer: " + (m_squashedLayers.siz e() > 0 ? m_squashedLayers[0].paintLayer->debugName() : "") + ")";
2493 } else if (graphicsLayer == m_ancestorClippingLayer.get()) { 2483 } else if (graphicsLayer == m_ancestorClippingLayer.get()) {
2494 name = "Ancestor Clipping Layer"; 2484 name = "Ancestor Clipping Layer";
(...skipping 26 matching lines...) Expand all
2521 } else if (graphicsLayer == m_scrollingBlockSelectionLayer.get()) { 2511 } else if (graphicsLayer == m_scrollingBlockSelectionLayer.get()) {
2522 name = "Scrolling Block Selection Layer"; 2512 name = "Scrolling Block Selection Layer";
2523 } else { 2513 } else {
2524 ASSERT_NOT_REACHED(); 2514 ASSERT_NOT_REACHED();
2525 } 2515 }
2526 2516
2527 return name; 2517 return name;
2528 } 2518 }
2529 2519
2530 } // namespace blink 2520 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698