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

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

Issue 1428643004: Repaint on interest rect change (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@EnableSyncPaint
Patch Set: 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 2184 matching lines...) Expand 10 before | Expand all | Expand 10 after
2195 if (!visibleContentRect.isEmpty()) { 2195 if (!visibleContentRect.isEmpty()) {
2196 localInterestRect = owningLayoutObject->absoluteToLocalQuad(FloatRect(vi sibleContentRect), UseTransforms).enclosingBoundingBox(); 2196 localInterestRect = owningLayoutObject->absoluteToLocalQuad(FloatRect(vi sibleContentRect), UseTransforms).enclosingBoundingBox();
2197 localInterestRect.move(-graphicsLayer->offsetFromLayoutObject()); 2197 localInterestRect.move(-graphicsLayer->offsetFromLayoutObject());
2198 } 2198 }
2199 // Expand by interest rect padding amount. 2199 // Expand by interest rect padding amount.
2200 localInterestRect.expand(IntRectOutsets(kPixelDistanceToRecord, kPixelDistan ceToRecord, kPixelDistanceToRecord, kPixelDistanceToRecord)); 2200 localInterestRect.expand(IntRectOutsets(kPixelDistanceToRecord, kPixelDistan ceToRecord, kPixelDistanceToRecord, kPixelDistanceToRecord));
2201 localInterestRect.intersect(enclosingIntRect(graphicsLayerBounds)); 2201 localInterestRect.intersect(enclosingIntRect(graphicsLayerBounds));
2202 return localInterestRect; 2202 return localInterestRect;
2203 } 2203 }
2204 2204
2205 void CompositedLayerMapping::paintContentsIfNeeded(const GraphicsLayer* graphics Layer, GraphicsContext& context, GraphicsLayerPaintingPhase graphicsLayerPaintin gPhase) const 2205 static bool changedSufficiently(int newValue, int previousValue, int baseValue)
2206 { 2206 {
2207 ASSERT(RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()); 2207 return std::abs(newValue - previousValue) * 16 < baseValue;
chrishtr 2015/10/28 21:03:54 > instead of < ?
2208 }
2208 2209
2209 // TODO(chrishtr): Also paint if the interest rect has changed sufficiently. 2210 static bool interestRectChangeNeedsRepaint(const IntRect& newInterestRect, const IntRect& previousInterestRect)
chrishtr 2015/10/28 21:03:54 This is a little different than what DisplayListRe
Xianzhu 2015/10/29 01:55:09 Done.
2210 if (!m_owningLayer.needsRepaint()) { 2211 {
2211 context.paintController().createAndAppend<CachedDisplayItem>(*this, Disp layItem::CachedDisplayItemList); 2212 if (previousInterestRect.contains(newInterestRect))
2212 return; 2213 return false;
2214 return changedSufficiently(newInterestRect.x(), previousInterestRect.x(), pr eviousInterestRect.width())
2215 || changedSufficiently(newInterestRect.y(), previousInterestRect.y(), pr eviousInterestRect.height())
2216 || changedSufficiently(newInterestRect.maxX(), previousInterestRect.maxX (), previousInterestRect.width())
2217 || changedSufficiently(newInterestRect.maxY(), previousInterestRect.maxY (), previousInterestRect.height());
2218 }
2219
2220 void CompositedLayerMapping::paintContents(const GraphicsLayer* graphicsLayer, G raphicsContext& context, GraphicsLayerPaintingPhase graphicsLayerPaintingPhase, const IntRect* interestRect) const
2221 {
2222 IntRect defaultInterestRect;
2223 if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()) {
2224 if (!interestRect) {
2225 if (graphicsLayer == m_graphicsLayer || graphicsLayer == m_squashing Layer)
2226 defaultInterestRect = computeInterestRect(graphicsLayer, m_ownin gLayer.layoutObject());
2227 else
2228 defaultInterestRect = enclosingIntRect(FloatRect(FloatPoint(), g raphicsLayer->size()));
2229 interestRect = &defaultInterestRect;
2230 }
2231
2232 if (!m_owningLayer.needsRepaint()
2233 && context.paintController().clientCacheIsValid(m_owningLayer.displa yItemClient())
2234 && !interestRectChangeNeedsRepaint(*interestRect, m_previousPaintInt erestRect)) {
2235 context.paintController().createAndAppend<CachedDisplayItem>(*this, DisplayItem::CachedDisplayItemList);
2236 return;
2237
2238 m_previousPaintInterestRect = *interestRect;
2213 } 2239 }
2214 2240
2215 IntRect interestRect; 2241 ASSERT(interestRect);
2216 if (graphicsLayer == m_graphicsLayer || graphicsLayer == m_squashingLayer) 2242 paintContentsInternal(graphicsLayer, context, graphicsLayerPaintingPhase, *i nterestRect);
2217 interestRect = computeInterestRect(graphicsLayer, m_owningLayer.layoutOb ject());
2218 else
2219 interestRect = enclosingIntRect(FloatRect(FloatPoint(), graphicsLayer->s ize()));
2220
2221 paintContents(graphicsLayer, context, graphicsLayerPaintingPhase, interestRe ct);
2222 } 2243 }
2223 2244
2224 void CompositedLayerMapping::paintContents(const GraphicsLayer* graphicsLayer, G raphicsContext& context, GraphicsLayerPaintingPhase graphicsLayerPaintingPhase, const IntRect& interestRect) const 2245 void CompositedLayerMapping::paintContentsInternal(const GraphicsLayer* graphics Layer, GraphicsContext& context, GraphicsLayerPaintingPhase graphicsLayerPaintin gPhase, const IntRect& interestRect) const
2225 { 2246 {
2226 // https://code.google.com/p/chromium/issues/detail?id=343772 2247 // https://code.google.com/p/chromium/issues/detail?id=343772
2227 DisableCompositingQueryAsserts disabler; 2248 DisableCompositingQueryAsserts disabler;
2228 #if ENABLE(ASSERT) 2249 #if ENABLE(ASSERT)
2229 // FIXME: once the state machine is ready, this can be removed and we can re fer to that instead. 2250 // FIXME: once the state machine is ready, this can be removed and we can re fer to that instead.
2230 if (Page* page = layoutObject()->frame()->page()) 2251 if (Page* page = layoutObject()->frame()->page())
2231 page->setIsPainting(true); 2252 page->setIsPainting(true);
2232 #endif 2253 #endif
2233 2254
2234 TRACE_EVENT1("devtools.timeline", "Paint", "data", InspectorPaintEvent::data (m_owningLayer.layoutObject(), LayoutRect(interestRect), graphicsLayer)); 2255 TRACE_EVENT1("devtools.timeline", "Paint", "data", InspectorPaintEvent::data (m_owningLayer.layoutObject(), LayoutRect(interestRect), graphicsLayer));
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
2460 } else if (graphicsLayer == m_scrollingBlockSelectionLayer.get()) { 2481 } else if (graphicsLayer == m_scrollingBlockSelectionLayer.get()) {
2461 name = "Scrolling Block Selection Layer"; 2482 name = "Scrolling Block Selection Layer";
2462 } else { 2483 } else {
2463 ASSERT_NOT_REACHED(); 2484 ASSERT_NOT_REACHED();
2464 } 2485 }
2465 2486
2466 return name; 2487 return name;
2467 } 2488 }
2468 2489
2469 } // namespace blink 2490 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698