OLD | NEW |
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 2153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2164 if (!scrollbar) | 2164 if (!scrollbar) |
2165 return; | 2165 return; |
2166 | 2166 |
2167 const IntRect& scrollbarRect = scrollbar->frameRect(); | 2167 const IntRect& scrollbarRect = scrollbar->frameRect(); |
2168 TransformRecorder transformRecorder(context, *scrollbar, AffineTransform::tr
anslation(-scrollbarRect.x(), -scrollbarRect.y())); | 2168 TransformRecorder transformRecorder(context, *scrollbar, AffineTransform::tr
anslation(-scrollbarRect.x(), -scrollbarRect.y())); |
2169 IntRect transformedClip = clip; | 2169 IntRect transformedClip = clip; |
2170 transformedClip.moveBy(scrollbarRect.location()); | 2170 transformedClip.moveBy(scrollbarRect.location()); |
2171 scrollbar->paint(&context, transformedClip); | 2171 scrollbar->paint(&context, transformedClip); |
2172 } | 2172 } |
2173 | 2173 |
| 2174 // The following should be kept in sync with the code computing potential_new_re
corded_viewport in |
| 2175 // cc::DisplayListRecordingSource::UpdateAndExpandInvalidation() before we keep
only one copy of the algorithm. |
2174 static const int kPixelDistanceToRecord = 4000; | 2176 static const int kPixelDistanceToRecord = 4000; |
2175 | 2177 |
2176 IntRect CompositedLayerMapping::computeInterestRect(const GraphicsLayer* graphic
sLayer, LayoutObject* owningLayoutObject) | 2178 IntRect CompositedLayerMapping::computeInterestRect(const GraphicsLayer* graphic
sLayer, LayoutObject* owningLayoutObject) |
2177 { | 2179 { |
2178 FloatRect graphicsLayerBounds(FloatPoint(), graphicsLayer->size()); | 2180 FloatRect graphicsLayerBounds(FloatPoint(), graphicsLayer->size()); |
2179 | 2181 |
2180 // Start with the bounds of the graphics layer in the space of the owning La
youtObject. | 2182 // Start with the bounds of the graphics layer in the space of the owning La
youtObject. |
2181 FloatRect graphicsLayerBoundsInObjectSpace(graphicsLayerBounds); | 2183 FloatRect graphicsLayerBoundsInObjectSpace(graphicsLayerBounds); |
2182 graphicsLayerBoundsInObjectSpace.move(graphicsLayer->offsetFromLayoutObject(
)); | 2184 graphicsLayerBoundsInObjectSpace.move(graphicsLayer->offsetFromLayoutObject(
)); |
2183 | 2185 |
2184 // Now map the bounds to its visible content rect in screen space, including
applying clips along the way. | 2186 // Now map the bounds to its visible content rect in screen space, including
applying clips along the way. |
2185 LayoutRect visibleContentRect(graphicsLayerBoundsInObjectSpace); | 2187 LayoutRect visibleContentRect(graphicsLayerBoundsInObjectSpace); |
2186 LayoutView* rootView = owningLayoutObject->view(); | 2188 LayoutView* rootView = owningLayoutObject->view(); |
2187 while (rootView->frame()->ownerLayoutObject()) | 2189 while (rootView->frame()->ownerLayoutObject()) |
2188 rootView = rootView->frame()->ownerLayoutObject()->view(); | 2190 rootView = rootView->frame()->ownerLayoutObject()->view(); |
2189 owningLayoutObject->mapRectToPaintInvalidationBacking(rootView, visibleConte
ntRect, 0); | 2191 owningLayoutObject->mapRectToPaintInvalidationBacking(rootView, visibleConte
ntRect, 0); |
2190 visibleContentRect.intersect(LayoutRect(rootView->frameView()->visibleConten
tRect())); | 2192 visibleContentRect.intersect(LayoutRect(rootView->frameView()->visibleConten
tRect())); |
2191 | 2193 |
2192 // Map the visible content rect from screen space to local graphics layer sp
ace. | 2194 // Map the visible content rect from screen space to local graphics layer sp
ace. |
2193 IntRect localInterestRect; | 2195 IntRect localInterestRect; |
2194 // If the visible content rect is empty, then it makes no sense to map it ba
ck since there is nothing to map. | 2196 // If the visible content rect is empty, then it makes no sense to map it ba
ck since there is nothing to map. |
2195 if (!visibleContentRect.isEmpty()) { | 2197 if (!visibleContentRect.isEmpty()) { |
2196 localInterestRect = owningLayoutObject->absoluteToLocalQuad(FloatRect(vi
sibleContentRect), UseTransforms).enclosingBoundingBox(); | 2198 localInterestRect = owningLayoutObject->absoluteToLocalQuad(FloatRect(vi
sibleContentRect), UseTransforms).enclosingBoundingBox(); |
2197 localInterestRect.move(-graphicsLayer->offsetFromLayoutObject()); | 2199 localInterestRect.move(-graphicsLayer->offsetFromLayoutObject()); |
2198 } | 2200 } |
2199 // Expand by interest rect padding amount. | 2201 // Expand by interest rect padding amount. |
2200 localInterestRect.expand(IntRectOutsets(kPixelDistanceToRecord, kPixelDistan
ceToRecord, kPixelDistanceToRecord, kPixelDistanceToRecord)); | 2202 localInterestRect.inflate(kPixelDistanceToRecord); |
2201 localInterestRect.intersect(enclosingIntRect(graphicsLayerBounds)); | 2203 localInterestRect.intersect(enclosingIntRect(graphicsLayerBounds)); |
2202 return localInterestRect; | 2204 return localInterestRect; |
2203 } | 2205 } |
2204 | 2206 |
2205 void CompositedLayerMapping::paintContentsIfNeeded(const GraphicsLayer* graphics
Layer, GraphicsContext& context, GraphicsLayerPaintingPhase graphicsLayerPaintin
gPhase) const | 2207 // The following should be kept in sync with cc::DisplayListRecordingSource::Exp
osesEnoughNewArea() |
| 2208 // before we keep only one copy of the algorithm. |
| 2209 static const int kMinimumDistanceBeforeRepaint = 512; |
| 2210 |
| 2211 bool CompositedLayerMapping::interestRectChangedEnoughToRepaint(const IntSize& l
ayerSize, const IntRect& previousInterestRect, const IntRect& newInterestRect) |
2206 { | 2212 { |
2207 ASSERT(RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()); | 2213 if (previousInterestRect.isEmpty() && newInterestRect.isEmpty()) |
| 2214 return false; |
2208 | 2215 |
2209 // TODO(chrishtr): Also paint if the interest rect has changed sufficiently. | 2216 // Repaint when going from empty to not-empty, to cover cases where the laye
r is |
2210 if (!m_owningLayer.needsRepaint()) { | 2217 // painted for the first time, or otherwise becomes visible. |
2211 context.paintController().createAndAppend<CachedDisplayItem>(*this, Disp
layItem::CachedDisplayItemList); | 2218 if (previousInterestRect.isEmpty()) |
2212 return; | 2219 return true; |
| 2220 |
| 2221 // Repaint if the new interest rect includes area outside of a skirt around
the existing interest rect. |
| 2222 IntRect expandedPreviousInterestRect(previousInterestRect); |
| 2223 expandedPreviousInterestRect.inflate(kMinimumDistanceBeforeRepaint); |
| 2224 if (!expandedPreviousInterestRect.contains(newInterestRect)) |
| 2225 return true; |
| 2226 |
| 2227 // Even if the new interest rect doesn't include enough new area to satisfy
the condition above, |
| 2228 // repaint anyway if it touches a layer edge not touched by the existing int
erest rect. |
| 2229 // Because it's impossible to expose more area in the direction, repainting
cannot be deferred |
| 2230 // until the exposed new area satisfies the condition above. |
| 2231 if (newInterestRect.x() == 0 && previousInterestRect.x() != 0) |
| 2232 return true; |
| 2233 if (newInterestRect.y() == 0 && previousInterestRect.y() != 0) |
| 2234 return true; |
| 2235 if (newInterestRect.maxX() == layerSize.width() && previousInterestRect.maxX
() != layerSize.width()) |
| 2236 return true; |
| 2237 if (newInterestRect.maxY() == layerSize.height() && previousInterestRect.max
Y() != layerSize.height()) |
| 2238 return true; |
| 2239 |
| 2240 return false; |
| 2241 } |
| 2242 |
| 2243 void CompositedLayerMapping::paintContents(const GraphicsLayer* graphicsLayer, G
raphicsContext& context, GraphicsLayerPaintingPhase graphicsLayerPaintingPhase,
const IntRect* interestRect) const |
| 2244 { |
| 2245 IntRect defaultInterestRect; |
| 2246 if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()) { |
| 2247 if (!interestRect) { |
| 2248 if (graphicsLayer == m_graphicsLayer || graphicsLayer == m_squashing
Layer) |
| 2249 defaultInterestRect = computeInterestRect(graphicsLayer, m_ownin
gLayer.layoutObject()); |
| 2250 else |
| 2251 defaultInterestRect = enclosingIntRect(FloatRect(FloatPoint(), g
raphicsLayer->size())); |
| 2252 interestRect = &defaultInterestRect; |
| 2253 } |
| 2254 |
| 2255 if (!m_owningLayer.needsRepaint() |
| 2256 && !context.paintController().cacheIsEmpty() |
| 2257 && !interestRectChangedEnoughToRepaint(expandedIntSize(graphicsLayer
->size()), m_previousPaintInterestRect, *interestRect)) { |
| 2258 context.paintController().createAndAppend<CachedDisplayItem>(*this,
DisplayItem::CachedDisplayItemList); |
| 2259 return; |
| 2260 } |
| 2261 |
| 2262 m_previousPaintInterestRect = *interestRect; |
2213 } | 2263 } |
2214 | 2264 |
2215 IntRect interestRect; | 2265 ASSERT(interestRect); |
2216 if (graphicsLayer == m_graphicsLayer || graphicsLayer == m_squashingLayer) | 2266 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 } | 2267 } |
2223 | 2268 |
2224 void CompositedLayerMapping::paintContents(const GraphicsLayer* graphicsLayer, G
raphicsContext& context, GraphicsLayerPaintingPhase graphicsLayerPaintingPhase,
const IntRect& interestRect) const | 2269 void CompositedLayerMapping::paintContentsInternal(const GraphicsLayer* graphics
Layer, GraphicsContext& context, GraphicsLayerPaintingPhase graphicsLayerPaintin
gPhase, const IntRect& interestRect) const |
2225 { | 2270 { |
2226 // https://code.google.com/p/chromium/issues/detail?id=343772 | 2271 // https://code.google.com/p/chromium/issues/detail?id=343772 |
2227 DisableCompositingQueryAsserts disabler; | 2272 DisableCompositingQueryAsserts disabler; |
2228 #if ENABLE(ASSERT) | 2273 #if ENABLE(ASSERT) |
2229 // FIXME: once the state machine is ready, this can be removed and we can re
fer to that instead. | 2274 // 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()) | 2275 if (Page* page = layoutObject()->frame()->page()) |
2231 page->setIsPainting(true); | 2276 page->setIsPainting(true); |
2232 #endif | 2277 #endif |
2233 | 2278 |
2234 TRACE_EVENT1("devtools.timeline", "Paint", "data", InspectorPaintEvent::data
(m_owningLayer.layoutObject(), LayoutRect(interestRect), graphicsLayer)); | 2279 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 Loading... |
2460 } else if (graphicsLayer == m_scrollingBlockSelectionLayer.get()) { | 2505 } else if (graphicsLayer == m_scrollingBlockSelectionLayer.get()) { |
2461 name = "Scrolling Block Selection Layer"; | 2506 name = "Scrolling Block Selection Layer"; |
2462 } else { | 2507 } else { |
2463 ASSERT_NOT_REACHED(); | 2508 ASSERT_NOT_REACHED(); |
2464 } | 2509 } |
2465 | 2510 |
2466 return name; | 2511 return name; |
2467 } | 2512 } |
2468 | 2513 |
2469 } // namespace blink | 2514 } // namespace blink |
OLD | NEW |