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

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

Issue 2208463003: First step of PaintInvalidator implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: - Created 4 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/layout/PaintInvalidationState.h" 5 #include "core/layout/PaintInvalidationState.h"
6 6
7 #include "core/frame/FrameView.h" 7 #include "core/frame/FrameView.h"
8 #include "core/frame/LocalFrame.h" 8 #include "core/frame/LocalFrame.h"
9 #include "core/frame/Settings.h" 9 #include "core/frame/Settings.h"
10 #include "core/layout/LayoutInline.h" 10 #include "core/layout/LayoutInline.h"
11 #include "core/layout/LayoutPart.h" 11 #include "core/layout/LayoutPart.h"
12 #include "core/layout/LayoutView.h" 12 #include "core/layout/LayoutView.h"
13 #include "core/layout/svg/LayoutSVGRoot.h" 13 #include "core/layout/svg/LayoutSVGRoot.h"
14 #include "core/layout/svg/SVGLayoutSupport.h" 14 #include "core/layout/svg/SVGLayoutSupport.h"
15 #include "core/paint/PaintInvalidator.h"
15 #include "core/paint/PaintLayer.h" 16 #include "core/paint/PaintLayer.h"
17 #include "core/paint/PaintPropertyTreeBuilder.h"
16 18
17 namespace blink { 19 namespace blink {
18 20
19 static bool supportsCachedOffsets(const LayoutObject& object) 21 static bool supportsCachedOffsets(const LayoutObject& object)
20 { 22 {
21 return !object.hasTransformRelatedProperty() 23 return !object.hasTransformRelatedProperty()
22 && !object.hasReflection() 24 && !object.hasReflection()
23 && !object.hasFilterInducingProperty() 25 && !object.hasFilterInducingProperty()
24 && !object.isLayoutFlowThread() 26 && !object.isLayoutFlowThread()
25 && !object.isLayoutMultiColumnSpannerPlaceholder() 27 && !object.isLayoutMultiColumnSpannerPlaceholder()
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 // The current object is stacked, so we should use m_paintInvalidationCo ntainerForStackedContents as its 112 // The current object is stacked, so we should use m_paintInvalidationCo ntainerForStackedContents as its
111 // paint invalidation container on which the current object is painted. 113 // paint invalidation container on which the current object is painted.
112 m_paintInvalidationContainer = m_paintInvalidationContainerForStackedCon tents; 114 m_paintInvalidationContainer = m_paintInvalidationContainerForStackedCon tents;
113 // We are changing paintInvalidationContainer to m_paintInvalidationCont ainerForStackedContents. Must disable 115 // We are changing paintInvalidationContainer to m_paintInvalidationCont ainerForStackedContents. Must disable
114 // cached offsets because we didn't track paint offset from m_paintInval idationContainerForStackedContents. 116 // cached offsets because we didn't track paint offset from m_paintInval idationContainerForStackedContents.
115 // TODO(wangxianzhu): There are optimization opportunities: 117 // TODO(wangxianzhu): There are optimization opportunities:
116 // - Like what we do for fixed-position, calculate the paint offset in s low path and enable fast path for 118 // - Like what we do for fixed-position, calculate the paint offset in s low path and enable fast path for
117 // descendants if possible; or 119 // descendants if possible; or
118 // - Track offset between the two paintInvalidationContainers. 120 // - Track offset between the two paintInvalidationContainers.
119 m_cachedOffsetsEnabled = false; 121 m_cachedOffsetsEnabled = false;
120 if (m_forcedSubtreeInvalidationFlags & FullInvalidationForStackedContent s) 122 if (m_forcedSubtreeInvalidationFlags & PaintInvalidatorContext::ForcedSu btreeFullInvalidationForStackedContents)
121 m_forcedSubtreeInvalidationFlags |= FullInvalidation; 123 m_forcedSubtreeInvalidationFlags |= PaintInvalidatorContext::ForcedS ubtreeFullInvalidation;
122 } 124 }
123 125
124 if (!currentObject.isBoxModelObject() && !currentObject.isSVG()) 126 if (!currentObject.isBoxModelObject() && !currentObject.isSVG())
125 return; 127 return;
126 128
127 if (m_cachedOffsetsEnabled || currentObject == m_paintInvalidationContainer) 129 if (m_cachedOffsetsEnabled || currentObject == m_paintInvalidationContainer)
128 m_cachedOffsetsEnabled = supportsCachedOffsets(currentObject); 130 m_cachedOffsetsEnabled = supportsCachedOffsets(currentObject);
129 131
130 if (currentObject.isSVG()) { 132 if (currentObject.isSVG()) {
131 if (currentObject.isSVGRoot()) { 133 if (currentObject.isSVGRoot()) {
132 m_svgTransform = toLayoutSVGRoot(currentObject).localToBorderBoxTran sform(); 134 m_svgTransform = toLayoutSVGRoot(currentObject).localToBorderBoxTran sform();
133 // Don't early return here, because the SVGRoot object needs to exec ute the later code 135 // Don't early return here, because the SVGRoot object needs to exec ute the later code
134 // as a normal LayoutBox. 136 // as a normal LayoutBox.
135 } else { 137 } else {
136 ASSERT(currentObject != m_paintInvalidationContainer); 138 ASSERT(currentObject != m_paintInvalidationContainer);
137 m_svgTransform *= currentObject.localToSVGParentTransform(); 139 m_svgTransform *= currentObject.localToSVGParentTransform();
138 return; 140 return;
139 } 141 }
140 } 142 }
141 143
142 if (currentObject == m_paintInvalidationContainer) { 144 if (currentObject == m_paintInvalidationContainer) {
143 // When we hit a new paint invalidation container, we don't need to 145 // When we hit a new paint invalidation container, we don't need to
144 // continue forcing a check for paint invalidation, since we're 146 // continue forcing a check for paint invalidation, since we're
145 // descending into a different invalidation container. (For instance if 147 // descending into a different invalidation container. (For instance if
146 // our parents were moved, the entire container will just move.) 148 // our parents were moved, the entire container will just move.)
147 if (currentObject != m_paintInvalidationContainerForStackedContents) { 149 if (currentObject != m_paintInvalidationContainerForStackedContents) {
148 // However, we need to keep the FullInvalidationForStackedContents f lag 150 // However, we need to keep the FullInvalidationForStackedContents f lag
149 // if the current object isn't the paint invalidation container of 151 // if the current object isn't the paint invalidation container of
150 // stacked contents. 152 // stacked contents.
151 m_forcedSubtreeInvalidationFlags &= FullInvalidationForStackedConten ts; 153 m_forcedSubtreeInvalidationFlags &= PaintInvalidatorContext::ForcedS ubtreeFullInvalidationForStackedContents;
152 } else { 154 } else {
153 m_forcedSubtreeInvalidationFlags = 0; 155 m_forcedSubtreeInvalidationFlags = 0;
154 if (currentObject != m_containerForAbsolutePosition 156 if (currentObject != m_containerForAbsolutePosition
155 && m_cachedOffsetsForAbsolutePositionEnabled 157 && m_cachedOffsetsForAbsolutePositionEnabled
156 && m_cachedOffsetsEnabled) { 158 && m_cachedOffsetsEnabled) {
157 // The current object is the new paintInvalidationContainer for absolute-position descendants but is not their container. 159 // The current object is the new paintInvalidationContainer for absolute-position descendants but is not their container.
158 // Call updateForCurrentObject() before resetting m_paintOffset to get paint offset of the current object 160 // Call updateForCurrentObject() before resetting m_paintOffset to get paint offset of the current object
159 // from the original paintInvalidationContainerForStackingConten ts, then use this paint offset to adjust 161 // from the original paintInvalidationContainerForStackingConten ts, then use this paint offset to adjust
160 // m_paintOffsetForAbsolutePosition. 162 // m_paintOffsetForAbsolutePosition.
161 updateForCurrentObject(parentState); 163 updateForCurrentObject(parentState);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 #if ENABLE(ASSERT) 247 #if ENABLE(ASSERT)
246 ASSERT(!m_didUpdateForChildren); 248 ASSERT(!m_didUpdateForChildren);
247 m_didUpdateForChildren = true; 249 m_didUpdateForChildren = true;
248 #endif 250 #endif
249 251
250 switch (reason) { 252 switch (reason) {
251 case PaintInvalidationDelayedFull: 253 case PaintInvalidationDelayedFull:
252 m_pendingDelayedPaintInvalidations.append(&m_currentObject); 254 m_pendingDelayedPaintInvalidations.append(&m_currentObject);
253 break; 255 break;
254 case PaintInvalidationSubtree: 256 case PaintInvalidationSubtree:
255 m_forcedSubtreeInvalidationFlags |= (FullInvalidation | FullInvalidation ForStackedContents); 257 m_forcedSubtreeInvalidationFlags |= (PaintInvalidatorContext::ForcedSubt reeFullInvalidation | PaintInvalidatorContext::ForcedSubtreeFullInvalidationForS tackedContents);
256 break; 258 break;
257 case PaintInvalidationSVGResourceChange: 259 case PaintInvalidationSVGResourceChange:
258 setForceSubtreeInvalidationCheckingWithinContainer(); 260 setForceSubtreeInvalidationCheckingWithinContainer();
259 break; 261 break;
260 default: 262 default:
261 break; 263 break;
262 } 264 }
263 265
264 updateForNormalChildren(); 266 updateForNormalChildren();
265 267
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 507
506 WTFLogAlways("Fast path paint invalidation rect differs from slow path: fast : %s vs slow: %s", 508 WTFLogAlways("Fast path paint invalidation rect differs from slow path: fast : %s vs slow: %s",
507 fastPathRect.toString().ascii().data(), slowPathRect.toString().ascii(). data()); 509 fastPathRect.toString().ascii().data(), slowPathRect.toString().ascii(). data());
508 showLayoutTree(&m_currentObject); 510 showLayoutTree(&m_currentObject);
509 511
510 ASSERT_NOT_REACHED(); 512 ASSERT_NOT_REACHED();
511 } 513 }
512 514
513 #endif // CHECK_FAST_PATH_SLOW_PATH_EQUALITY 515 #endif // CHECK_FAST_PATH_SLOW_PATH_EQUALITY
514 516
517 static const PaintPropertyTreeBuilderContext& dummyTreeBuilderContext()
518 {
519 DEFINE_STATIC_LOCAL(PaintPropertyTreeBuilderContext, dummyContext, ());
520 return dummyContext;
521 }
522
523 PaintInvalidatorContextAdapter::PaintInvalidatorContextAdapter(const PaintInvali dationState& paintInvalidationState)
524 : PaintInvalidatorContext(dummyTreeBuilderContext())
525 , m_paintInvalidationState(paintInvalidationState)
526 {
527 forcedSubtreeInvalidationFlags = paintInvalidationState.m_forcedSubtreeInval idationFlags;
528 paintInvalidationContainer = &paintInvalidationState.paintInvalidationContai ner();
529 paintingLayer = &paintInvalidationState.paintingLayer();
530 }
531
532
533 void PaintInvalidatorContextAdapter::mapLocalRectToPaintInvalidationBacking(cons t LayoutObject& object, LayoutRect& rect) const
534 {
535 DCHECK(&object == &m_paintInvalidationState.currentObject());
536 m_paintInvalidationState.mapLocalRectToPaintInvalidationBacking(rect);
537 }
538
515 } // namespace blink 539 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698