Chromium Code Reviews| Index: third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp |
| diff --git a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp |
| index 078055e5331926713b4732101823e2956efab40a..3298f4000c067c71c40db46cbbbdec0915b95b92 100644 |
| --- a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp |
| +++ b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp |
| @@ -2202,26 +2202,47 @@ IntRect CompositedLayerMapping::computeInterestRect(const GraphicsLayer* graphic |
| return localInterestRect; |
| } |
| -void CompositedLayerMapping::paintContentsIfNeeded(const GraphicsLayer* graphicsLayer, GraphicsContext& context, GraphicsLayerPaintingPhase graphicsLayerPaintingPhase) const |
| +static bool changedSufficiently(int newValue, int previousValue, int baseValue) |
| { |
| - ASSERT(RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()); |
| + return std::abs(newValue - previousValue) * 16 < baseValue; |
|
chrishtr
2015/10/28 21:03:54
> instead of < ?
|
| +} |
| - // TODO(chrishtr): Also paint if the interest rect has changed sufficiently. |
| - if (!m_owningLayer.needsRepaint()) { |
| - context.paintController().createAndAppend<CachedDisplayItem>(*this, DisplayItem::CachedDisplayItemList); |
| - return; |
| - } |
| +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.
|
| +{ |
| + if (previousInterestRect.contains(newInterestRect)) |
| + return false; |
| + return changedSufficiently(newInterestRect.x(), previousInterestRect.x(), previousInterestRect.width()) |
| + || changedSufficiently(newInterestRect.y(), previousInterestRect.y(), previousInterestRect.height()) |
| + || changedSufficiently(newInterestRect.maxX(), previousInterestRect.maxX(), previousInterestRect.width()) |
| + || changedSufficiently(newInterestRect.maxY(), previousInterestRect.maxY(), previousInterestRect.height()); |
| +} |
| + |
| +void CompositedLayerMapping::paintContents(const GraphicsLayer* graphicsLayer, GraphicsContext& context, GraphicsLayerPaintingPhase graphicsLayerPaintingPhase, const IntRect* interestRect) const |
| +{ |
| + IntRect defaultInterestRect; |
| + if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()) { |
| + if (!interestRect) { |
| + if (graphicsLayer == m_graphicsLayer || graphicsLayer == m_squashingLayer) |
| + defaultInterestRect = computeInterestRect(graphicsLayer, m_owningLayer.layoutObject()); |
| + else |
| + defaultInterestRect = enclosingIntRect(FloatRect(FloatPoint(), graphicsLayer->size())); |
| + interestRect = &defaultInterestRect; |
| + } |
| - IntRect interestRect; |
| - if (graphicsLayer == m_graphicsLayer || graphicsLayer == m_squashingLayer) |
| - interestRect = computeInterestRect(graphicsLayer, m_owningLayer.layoutObject()); |
| - else |
| - interestRect = enclosingIntRect(FloatRect(FloatPoint(), graphicsLayer->size())); |
| + if (!m_owningLayer.needsRepaint() |
| + && context.paintController().clientCacheIsValid(m_owningLayer.displayItemClient()) |
| + && !interestRectChangeNeedsRepaint(*interestRect, m_previousPaintInterestRect)) { |
| + context.paintController().createAndAppend<CachedDisplayItem>(*this, DisplayItem::CachedDisplayItemList); |
| + return; |
| + |
| + m_previousPaintInterestRect = *interestRect; |
| + } |
| - paintContents(graphicsLayer, context, graphicsLayerPaintingPhase, interestRect); |
| + ASSERT(interestRect); |
| + paintContentsInternal(graphicsLayer, context, graphicsLayerPaintingPhase, *interestRect); |
| } |
| -void CompositedLayerMapping::paintContents(const GraphicsLayer* graphicsLayer, GraphicsContext& context, GraphicsLayerPaintingPhase graphicsLayerPaintingPhase, const IntRect& interestRect) const |
| +void CompositedLayerMapping::paintContentsInternal(const GraphicsLayer* graphicsLayer, GraphicsContext& context, GraphicsLayerPaintingPhase graphicsLayerPaintingPhase, const IntRect& interestRect) const |
| { |
| // https://code.google.com/p/chromium/issues/detail?id=343772 |
| DisableCompositingQueryAsserts disabler; |