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

Side by Side Diff: third_party/WebKit/Source/core/layout/PaintInvalidationState.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, 9 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/layout/LayoutInline.h" 7 #include "core/layout/LayoutInline.h"
8 #include "core/layout/LayoutView.h" 8 #include "core/layout/LayoutView.h"
9 #include "core/layout/svg/LayoutSVGModelObject.h" 9 #include "core/layout/svg/LayoutSVGModelObject.h"
10 #include "core/layout/svg/LayoutSVGRoot.h" 10 #include "core/layout/svg/LayoutSVGRoot.h"
11 #include "core/paint/PaintLayer.h" 11 #include "core/paint/PaintLayer.h"
12 12
13 namespace blink { 13 namespace blink {
14 14
15 PaintInvalidationState::PaintInvalidationState(const LayoutView& layoutView, Vec tor<LayoutObject*>& pendingDelayedPaintInvalidations, PaintInvalidationState* ow nerPaintInvalidationState) 15 PaintInvalidationState::PaintInvalidationState(const LayoutView& layoutView, Vec tor<LayoutObject*>& pendingDelayedPaintInvalidations, PaintInvalidationState* ow nerPaintInvalidationState)
16 : m_clipped(false) 16 : m_clipped(false)
17 , m_cachedOffsetsEnabled(true) 17 , m_cachedOffsetsEnabled(true)
18 , m_forcedSubtreeInvalidationWithinContainer(false) 18 , m_forcedSubtreeInvalidationWithinContainer(false)
19 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(false) 19 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(false)
20 , m_viewClippingAndScrollOffsetDisabled(false) 20 , m_viewClippingAndScrollOffsetDisabled(false)
21 , m_paintInvalidationContainer(layoutView.containerForPaintInvalidation()) 21 , m_paintInvalidationContainer(*layoutView.containerForPaintInvalidation())
22 , m_pendingDelayedPaintInvalidations(pendingDelayedPaintInvalidations) 22 , m_pendingDelayedPaintInvalidations(&pendingDelayedPaintInvalidations)
23 , m_enclosingSelfPaintingLayer(*layoutView.layer()) 23 , m_enclosingSelfPaintingLayer(*layoutView.layer())
24 { 24 {
25 ASSERT(!RuntimeEnabledFeatures::slimmingPaintV2Enabled());
26
25 bool establishesPaintInvalidationContainer = layoutView == m_paintInvalidati onContainer; 27 bool establishesPaintInvalidationContainer = layoutView == m_paintInvalidati onContainer;
26 if (!establishesPaintInvalidationContainer) { 28 if (!establishesPaintInvalidationContainer) {
27 if ((ownerPaintInvalidationState && !ownerPaintInvalidationState->m_cach edOffsetsEnabled) 29 if ((ownerPaintInvalidationState && !ownerPaintInvalidationState->m_cach edOffsetsEnabled)
28 || !layoutView.supportsPaintInvalidationStateCachedOffsets()) { 30 || !layoutView.supportsPaintInvalidationStateCachedOffsets()) {
29 m_cachedOffsetsEnabled = false; 31 m_cachedOffsetsEnabled = false;
30 return; 32 return;
31 } 33 }
32 if (ownerPaintInvalidationState && ownerPaintInvalidationState->m_forced SubtreeInvalidationWithinContainer) 34 if (ownerPaintInvalidationState && ownerPaintInvalidationState->m_forced SubtreeInvalidationWithinContainer)
33 m_forcedSubtreeInvalidationWithinContainer = true; 35 m_forcedSubtreeInvalidationWithinContainer = true;
34 FloatPoint point = layoutView.localToAncestorPoint(FloatPoint(), &m_pain tInvalidationContainer, TraverseDocumentBoundaries); 36 FloatPoint point = layoutView.localToAncestorPoint(FloatPoint(), &m_pain tInvalidationContainer, TraverseDocumentBoundaries);
35 m_paintOffset = LayoutSize(point.x(), point.y()); 37 m_paintOffset = LayoutSize(point.x(), point.y());
36 } 38 }
37 m_clipRect = layoutView.viewRect(); 39 m_clipRect = layoutView.viewRect();
38 m_clipRect.move(m_paintOffset); 40 m_clipRect.move(m_paintOffset);
39 m_clipped = true; 41 m_clipped = true;
40 } 42 }
41 43
42 PaintInvalidationState::PaintInvalidationState(PaintInvalidationState& next, Lay outBoxModelObject& layoutObject, const LayoutBoxModelObject& paintInvalidationCo ntainer) 44 PaintInvalidationState::PaintInvalidationState(PaintInvalidationState& next, con st LayoutBoxModelObject& layoutObject, const LayoutBoxModelObject& paintInvalida tionContainer)
43 : m_clipped(false) 45 : m_clipped(false)
44 , m_cachedOffsetsEnabled(true) 46 , m_cachedOffsetsEnabled(true)
45 , m_forcedSubtreeInvalidationWithinContainer(next.m_forcedSubtreeInvalidatio nWithinContainer) 47 , m_forcedSubtreeInvalidationWithinContainer(next.m_forcedSubtreeInvalidatio nWithinContainer)
46 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(next.m_forcedSubtreeI nvalidationRectUpdateWithinContainer) 48 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(next.m_forcedSubtreeI nvalidationRectUpdateWithinContainer)
47 , m_viewClippingAndScrollOffsetDisabled(false) 49 , m_viewClippingAndScrollOffsetDisabled(false)
48 , m_paintInvalidationContainer(paintInvalidationContainer) 50 , m_paintInvalidationContainer(paintInvalidationContainer)
49 , m_pendingDelayedPaintInvalidations(next.pendingDelayedPaintInvalidationTar gets()) 51 , m_pendingDelayedPaintInvalidations(next.m_pendingDelayedPaintInvalidations )
50 , m_enclosingSelfPaintingLayer(next.enclosingSelfPaintingLayer(layoutObject) ) 52 , m_enclosingSelfPaintingLayer(next.enclosingSelfPaintingLayer(layoutObject) )
51 { 53 {
54 ASSERT(!RuntimeEnabledFeatures::slimmingPaintV2Enabled() || layoutObject.isS VGRoot());
55
52 // FIXME: SVG could probably benefit from a stack-based optimization like ht ml does. crbug.com/391054 56 // FIXME: SVG could probably benefit from a stack-based optimization like ht ml does. crbug.com/391054
53 bool establishesPaintInvalidationContainer = layoutObject == m_paintInvalida tionContainer; 57 bool establishesPaintInvalidationContainer = layoutObject == m_paintInvalida tionContainer;
54 bool fixed = layoutObject.style()->position() == FixedPosition; 58 bool fixed = layoutObject.style()->position() == FixedPosition;
55 59
56 if (!layoutObject.supportsPaintInvalidationStateCachedOffsets() || !next.m_c achedOffsetsEnabled) 60 if (!layoutObject.supportsPaintInvalidationStateCachedOffsets() || !next.m_c achedOffsetsEnabled)
57 m_cachedOffsetsEnabled = false; 61 m_cachedOffsetsEnabled = false;
58 if (establishesPaintInvalidationContainer) { 62 if (establishesPaintInvalidationContainer) {
59 // When we hit a new paint invalidation container, we don't need to 63 // When we hit a new paint invalidation container, we don't need to
60 // continue forcing a check for paint invalidation, since we're 64 // continue forcing a check for paint invalidation, since we're
61 // descending into a different invalidation container. (For instance if 65 // descending into a different invalidation container. (For instance if
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 , m_paintInvalidationContainer(next.m_paintInvalidationContainer) 114 , m_paintInvalidationContainer(next.m_paintInvalidationContainer)
111 , m_pendingDelayedPaintInvalidations(next.pendingDelayedPaintInvalidationTar gets()) 115 , m_pendingDelayedPaintInvalidations(next.pendingDelayedPaintInvalidationTar gets())
112 , m_enclosingSelfPaintingLayer(next.enclosingSelfPaintingLayer(layoutObject) ) 116 , m_enclosingSelfPaintingLayer(next.enclosingSelfPaintingLayer(layoutObject) )
113 { 117 {
114 ASSERT(layoutObject != m_paintInvalidationContainer); 118 ASSERT(layoutObject != m_paintInvalidationContainer);
115 119
116 if (m_cachedOffsetsEnabled) 120 if (m_cachedOffsetsEnabled)
117 m_svgTransform = AffineTransform(next.svgTransform() * layoutObject.loca lToParentTransform()); 121 m_svgTransform = AffineTransform(next.svgTransform() * layoutObject.loca lToParentTransform());
118 } 122 }
119 123
124 PaintInvalidationState::PaintInvalidationState(const LayoutBoxModelObject& paint ingContainer, const LayoutRect& clipRect, unsigned flags)
125 : m_clipped(flags & HasClip)
126 , m_cachedOffsetsEnabled(paintingContainer.supportsPaintInvalidationStateCac hedOffsets())
127 , m_forcedSubtreeInvalidationWithinContainer(false)
128 , m_forcedSubtreeInvalidationRectUpdateWithinContainer(false)
129 , m_clipRect(clipRect)
130 , m_paintInvalidationContainer(paintingContainer.isPaintInvalidationContaine r() ? paintingContainer : *paintingContainer.containerForPaintInvalidation())
131 , m_pendingDelayedPaintInvalidations(nullptr)
132 {
133 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled());
134
135 if (paintingContainer.isPaintInvalidationContainer())
136 return;
137
138 if (flags & HasNonIdentityAndNonTranslateTransform) {
139 m_cachedOffsetsEnabled = false;
140 return;
141 }
142
143 FloatPoint point = paintingContainer.localToContainerPoint(FloatPoint(), &m_ paintInvalidationContainer, TraverseDocumentBoundaries);
144 m_paintOffset = LayoutSize(point.x(), point.y());
145 if (m_clipped)
146 m_clipRect.move(m_paintOffset);
147 }
148
120 void PaintInvalidationState::addClipRectRelativeToPaintOffset(const LayoutSize& clipSize) 149 void PaintInvalidationState::addClipRectRelativeToPaintOffset(const LayoutSize& clipSize)
121 { 150 {
122 LayoutRect clipRect(toPoint(m_paintOffset), clipSize); 151 LayoutRect clipRect(toPoint(m_paintOffset), clipSize);
123 if (m_clipped) { 152 if (m_clipped) {
124 m_clipRect.intersect(clipRect); 153 m_clipRect.intersect(clipRect);
125 } else { 154 } else {
126 m_clipRect = clipRect; 155 m_clipRect = clipRect;
127 m_clipped = true; 156 m_clipped = true;
128 } 157 }
129 } 158 }
(...skipping 17 matching lines...) Expand all
147 176
148 PaintLayer& PaintInvalidationState::enclosingSelfPaintingLayer(const LayoutObjec t& layoutObject) const 177 PaintLayer& PaintInvalidationState::enclosingSelfPaintingLayer(const LayoutObjec t& layoutObject) const
149 { 178 {
150 if (layoutObject.hasLayer() && toLayoutBoxModelObject(layoutObject).hasSelfP aintingLayer()) 179 if (layoutObject.hasLayer() && toLayoutBoxModelObject(layoutObject).hasSelfP aintingLayer())
151 return *toLayoutBoxModelObject(layoutObject).layer(); 180 return *toLayoutBoxModelObject(layoutObject).layer();
152 181
153 return m_enclosingSelfPaintingLayer; 182 return m_enclosingSelfPaintingLayer;
154 } 183 }
155 184
156 } // namespace blink 185 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698