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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutObject.cpp

Issue 1391753005: (WIP) Invalidation during painting (for synchronized painting) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/LayoutObject.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutObject.cpp b/third_party/WebKit/Source/core/layout/LayoutObject.cpp
index 8e93284e88e682418c6fdb27953634e0a248a56a..d0b63262af75db30484bb7f358420f96bf60bd31 100644
--- a/third_party/WebKit/Source/core/layout/LayoutObject.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutObject.cpp
@@ -73,6 +73,7 @@
#include "core/layout/compositing/PaintLayerCompositor.h"
#include "core/page/AutoscrollController.h"
#include "core/page/Page.h"
+#include "core/paint/LineBoxListPainter.h"
#include "core/paint/ObjectPaintProperties.h"
#include "core/paint/ObjectPainter.h"
#include "core/paint/PaintInfo.h"
@@ -254,10 +255,6 @@ LayoutObject::LayoutObject(Node* node)
#endif
, m_bitfields(node)
{
- // TODO(wangxianzhu): Move this into initialization list when we enable the feature by default.
- if (RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled())
- m_previousPositionFromPaintInvalidationBacking = uninitializedPaintOffset();
-
#ifndef NDEBUG
layoutObjectCounter().increment();
#endif
@@ -1420,9 +1417,9 @@ PaintInvalidationReason LayoutObject::invalidatePaintIfNeeded(PaintInvalidationS
return PaintInvalidationNone; // Don't invalidate paints if we're printing.
const LayoutRect oldBounds = previousPaintInvalidationRect();
- const LayoutPoint oldLocation = RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled() ? LayoutPoint() : previousPositionFromPaintInvalidationBacking();
+ const LayoutPoint oldLocation = RuntimeEnabledFeatures::slimmingPaintV2Enabled() ? LayoutPoint() : previousPositionFromPaintInvalidationBacking();
LayoutRect newBounds = boundsRectForPaintInvalidation(paintInvalidationContainer, &paintInvalidationState);
- LayoutPoint newLocation = RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled() ? LayoutPoint() : PaintLayer::positionFromPaintInvalidationBacking(this, &paintInvalidationContainer, &paintInvalidationState);
+ LayoutPoint newLocation = RuntimeEnabledFeatures::slimmingPaintV2Enabled() ? LayoutPoint() : PaintLayer::positionFromPaintInvalidationBacking(this, &paintInvalidationContainer, &paintInvalidationState);
// Composited scrolling should not be included in the bounds and position tracking, because the graphics layer backing the scroller
// does not move on scroll.
@@ -1433,11 +1430,12 @@ PaintInvalidationReason LayoutObject::invalidatePaintIfNeeded(PaintInvalidationS
}
setPreviousPaintInvalidationRect(newBounds);
- if (!RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled())
+ if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled())
setPreviousPositionFromPaintInvalidationBacking(newLocation);
if (!shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState() && !paintInvalidationState.forcedSubtreeInvalidationWithinContainer()) {
- ASSERT(paintInvalidationState.forcedSubtreeInvalidationRectUpdateWithinContainer());
+ ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()
+ || paintInvalidationState.forcedSubtreeInvalidationRectUpdateWithinContainer());
return PaintInvalidationNone;
}
@@ -1462,7 +1460,7 @@ PaintInvalidationReason LayoutObject::invalidatePaintIfNeeded(PaintInvalidationS
// mutation, but incurs no pixel difference (i.e. bounds stay the same) so no rect-based
// invalidation is issued. See crbug.com/508383 and crbug.com/515977.
// This is a workaround to force display items to update paint offset.
- if (!RuntimeEnabledFeatures::slimmingPaintOffsetCachingEnabled() && paintInvalidationState.forcedSubtreeInvalidationWithinContainer())
+ if (!RuntimeEnabledFeatures::slimmingPaintV2Enabled() && paintInvalidationState.forcedSubtreeInvalidationWithinContainer())
invalidateDisplayItemClientsWithPaintInvalidationState(paintInvalidationContainer, paintInvalidationState, invalidationReason);
return invalidationReason;
@@ -1480,6 +1478,61 @@ PaintInvalidationReason LayoutObject::invalidatePaintIfNeeded(PaintInvalidationS
return invalidationReason;
}
+void LayoutObject::invalidatePaintIfNeededForSlimmingPaintV2(const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
+{
+ ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled());
+
+ PaintController& paintController = paintInfo.context->paintController();
+
+ // In some cases, the caller doesn't have enough information to create paintInvalidationState.
+ if (!paintInfo.paintInvalidationState) {
+ WTFLogAlways("No paint invalidation state for: %s\n", debugName().ascii().data());
+ // TODO(wangxianzhu): What to do?
+ return;
+ }
+
+ PaintInvalidationState& paintInvalidationState = *paintInfo.paintInvalidationState;
+
+ const LayoutBoxModelObject& paintInvalidationContainer = paintInvalidationState.paintInvalidationContainer();
+
+ if (!paintController.skippingCache() && paintOffsetChanged(paintOffset)) {
+ m_bitfields.setFullPaintInvalidationReason(PaintInvalidationLocationChange);
+ setPreviousPaintOffset(paintOffset);
+ if (isLayoutInline() || (isLayoutBlock() && toLayoutBlock(this)->childrenInline())) {
+ const LineBoxList& lineBoxList = isLayoutInline() ? *toLayoutInline(this)->lineBoxes() : *toLayoutBlock(this)->lineBoxes();
+ LineBoxListPainter(lineBoxList).invalidateLineBoxPaintOffsets(*this, paintInfo);
+ }
+ }
+
+ // Set paintInvalidationState's paint offset to that of the parent of this LayoutObject, to let
+ // invalidatePaintIfNeeded() and boundsRectForPaintInvalidation() work for this LayoutObject.
+ LayoutSize layerPaintOffset = paintInvalidationState.paintOffset();
+ bool originalCachedOffsetsEnabled = paintInvalidationState.cachedOffsetsEnabled();
+ if (paintController.skippingCache()) {
+ paintInvalidationState.setCachedOffsetsEnabled(false);
+ } else if (paintInvalidationState.cachedOffsetsEnabled()) {
+ // The legacy paint invalidation code expects that the paint offset in PaintInvalidationState
+ // is that of the container of the current object.
+ LayoutPoint containerPaintOffset = paintOffset + layerPaintOffset;
+ if (isBox())
+ containerPaintOffset.moveBy(-toLayoutBox(this)->location());
+ if (styleRef().hasInFlowPosition() && hasLayer())
+ containerPaintOffset.move(-toLayoutBoxModelObject(this)->layer()->offsetForInFlowPosition());
+ paintInvalidationState.setPaintOffset(toSize(containerPaintOffset));
+ }
+
+ PaintInvalidationReason reason = invalidatePaintIfNeeded(paintInvalidationState, paintInvalidationContainer);
+ clearPaintInvalidationState(paintInvalidationState);
+
+ // Restore our own values after calling legacy paint invalidation code.
+ if (paintController.skippingCache())
+ paintInvalidationState.setCachedOffsetsEnabled(originalCachedOffsetsEnabled);
+ paintInvalidationState.setPaintOffset(layerPaintOffset);
+
+ if (reason == PaintInvalidationDelayedFull)
+ setShouldDoFullPaintInvalidation(PaintInvalidationFull);
+}
+
PaintInvalidationReason LayoutObject::paintInvalidationReason(const LayoutBoxModelObject& paintInvalidationContainer,
const LayoutRect& oldBounds, const LayoutPoint& oldPositionFromPaintInvalidationBacking,
const LayoutRect& newBounds, const LayoutPoint& newPositionFromPaintInvalidationBacking) const
@@ -3401,6 +3454,15 @@ void LayoutObject::setShouldDoFullPaintInvalidation(PaintInvalidationReason reas
// Only full invalidation reasons are allowed.
ASSERT(isFullPaintInvalidationReason(reason));
+ // TODO(wangxianzhu): This is temporary for table column rect-based paint invalidation in synchronized painting mode.
+ // We won't paint table columns during synchronized painting so won't call their invalidatePaintIfNeeded().
+ // Delegate their style-caused paint invalidation to their table just like their invalidatePaintIfNeeded does.
+ // Remove this when we remove rect-based paint invalidation.
+ if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) {
+ if (isLayoutTableCol())
+ toLayoutTableCol(this)->table()->setShouldDoFullPaintInvalidation(reason);
+ }
+
bool isUpgradingDelayedFullToFull = m_bitfields.fullPaintInvalidationReason() == PaintInvalidationDelayedFull && reason != PaintInvalidationDelayedFull;
if (m_bitfields.fullPaintInvalidationReason() == PaintInvalidationNone || isUpgradingDelayedFullToFull) {
@@ -3427,7 +3489,10 @@ void LayoutObject::clearPaintInvalidationState(const PaintInvalidationState& pai
{
// paintInvalidationStateIsDirty should be kept in sync with the
// booleans that are cleared below.
- ASSERT(paintInvalidationState.forcedSubtreeInvalidationWithinContainer() || paintInvalidationState.forcedSubtreeInvalidationRectUpdateWithinContainer() || paintInvalidationStateIsDirty());
+ ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()
+ || paintInvalidationState.forcedSubtreeInvalidationWithinContainer()
+ || paintInvalidationState.forcedSubtreeInvalidationRectUpdateWithinContainer()
+ || paintInvalidationStateIsDirty());
clearShouldDoFullPaintInvalidation();
m_bitfields.setChildShouldCheckForPaintInvalidation(false);
m_bitfields.setNeededLayoutBecauseOfChildren(false);
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutObject.h ('k') | third_party/WebKit/Source/core/layout/LayoutTable.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698