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