OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/paint/PrePaintTreeWalk.h" | 5 #include "core/paint/PrePaintTreeWalk.h" |
6 | 6 |
7 #include "core/dom/DocumentLifecycle.h" | 7 #include "core/dom/DocumentLifecycle.h" |
8 #include "core/frame/FrameView.h" | 8 #include "core/frame/FrameView.h" |
9 #include "core/frame/LocalFrame.h" | 9 #include "core/frame/LocalFrame.h" |
10 #include "core/layout/LayoutMultiColumnSpannerPlaceholder.h" | 10 #include "core/layout/LayoutMultiColumnSpannerPlaceholder.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 | 107 |
108 // Returns whether |a| is an ancestor of or equal to |b|. | 108 // Returns whether |a| is an ancestor of or equal to |b|. |
109 static bool isAncestorOfOrEqualTo(const ClipPaintPropertyNode* a, | 109 static bool isAncestorOfOrEqualTo(const ClipPaintPropertyNode* a, |
110 const ClipPaintPropertyNode* b) { | 110 const ClipPaintPropertyNode* b) { |
111 while (b && b != a) { | 111 while (b && b != a) { |
112 b = b->parent(); | 112 b = b->parent(); |
113 } | 113 } |
114 return b == a; | 114 return b == a; |
115 } | 115 } |
116 | 116 |
117 FloatClipRect PrePaintTreeWalk::clipRectForContext( | 117 void PrePaintTreeWalk::computeClipRectForContext( |
118 const PaintPropertyTreeBuilderContext::ContainingBlockContext& context, | 118 const PaintPropertyTreeBuilderContext::ContainingBlockContext& context, |
119 const EffectPaintPropertyNode* effect, | 119 const EffectPaintPropertyNode* effect, |
120 const PropertyTreeState& ancestorState, | 120 const PropertyTreeState& ancestorState, |
121 const LayoutPoint& ancestorPaintOffset, | 121 const LayoutPoint& ancestorPaintOffset, |
122 bool& hasClip) { | 122 bool& hasClip, |
123 FloatClipRect& clipRect) { | |
123 // Only return a non-infinite clip if clips differ, or the "ancestor" state is | 124 // Only return a non-infinite clip if clips differ, or the "ancestor" state is |
124 // actually an ancestor clip. This ensures no accuracy issues due to | 125 // actually an ancestor clip. This ensures no accuracy issues due to |
125 // transforms applied to infinite rects. | 126 // transforms applied to infinite rects. |
126 if (isAncestorOfOrEqualTo(context.clip, ancestorState.clip())) | 127 if (isAncestorOfOrEqualTo(context.clip, ancestorState.clip())) |
127 return FloatClipRect(); | 128 clipRect = FloatClipRect(); |
128 | 129 |
129 hasClip = true; | 130 hasClip = true; |
130 | |
131 PropertyTreeState localState(context.transform, context.clip, effect); | 131 PropertyTreeState localState(context.transform, context.clip, effect); |
132 | 132 |
133 FloatClipRect rect( | 133 clipRect = |
134 m_geometryMapper.sourceToDestinationClipRect(localState, ancestorState)); | 134 m_geometryMapper.sourceToDestinationClipRect(localState, ancestorState); |
135 | 135 clipRect.moveBy(-FloatPoint(ancestorPaintOffset)); |
136 rect.moveBy(-FloatPoint(ancestorPaintOffset)); | |
137 return rect; | |
138 } | 136 } |
139 | 137 |
140 void PrePaintTreeWalk::invalidatePaintLayerOptimizationsIfNeeded( | 138 void PrePaintTreeWalk::invalidatePaintLayerOptimizationsIfNeeded( |
141 const LayoutObject& object, | 139 const LayoutObject& object, |
142 PrePaintTreeWalkContext& context) { | 140 PrePaintTreeWalkContext& context) { |
143 if (!object.hasLayer()) | 141 if (!object.hasLayer()) |
Xianzhu
2017/03/10 00:06:49
(Can be follow-up) We can tighten this condition b
| |
144 return; | 142 return; |
145 | 143 |
146 PaintLayer& paintLayer = *toLayoutBoxModelObject(object).layer(); | 144 PaintLayer& paintLayer = *toLayoutBoxModelObject(object).layer(); |
147 if (object.styleRef().hasTransform() || | 145 if (object.styleRef().hasTransform() || |
148 &object == context.paintInvalidatorContext.paintInvalidationContainer) { | 146 &object == context.paintInvalidatorContext.paintInvalidationContainer) { |
149 context.ancestorTransformedOrRootPaintLayer = &paintLayer; | 147 context.ancestorTransformedOrRootPaintLayer = &paintLayer; |
150 } | 148 } |
151 | 149 |
Xianzhu
2017/03/10 00:06:49
(Can be follow-up) We can also check for some fast
| |
152 const ObjectPaintProperties& ancestorPaintProperties = | 150 const ObjectPaintProperties& ancestorPaintProperties = |
153 *context.ancestorTransformedOrRootPaintLayer->layoutObject() | 151 *context.ancestorTransformedOrRootPaintLayer->layoutObject() |
154 .paintProperties(); | 152 .paintProperties(); |
155 PropertyTreeState ancestorState = | 153 PropertyTreeState ancestorState = |
156 *ancestorPaintProperties.localBorderBoxProperties(); | 154 *ancestorPaintProperties.localBorderBoxProperties(); |
Xianzhu
2017/03/10 00:06:49
(Can be follow-up) If using the condition I propos
| |
157 const EffectPaintPropertyNode* effect = | 155 const EffectPaintPropertyNode* effect = |
158 context.treeBuilderContext.currentEffect; | 156 context.treeBuilderContext.currentEffect; |
159 | 157 |
160 #ifdef CHECK_CLIP_RECTS | 158 #ifdef CHECK_CLIP_RECTS |
161 ShouldRespectOverflowClipType respectOverflowClip = RespectOverflowClip; | 159 ShouldRespectOverflowClipType respectOverflowClip = RespectOverflowClip; |
162 #endif | 160 #endif |
163 if (context.ancestorTransformedOrRootPaintLayer->compositingState() == | 161 if (context.ancestorTransformedOrRootPaintLayer->compositingState() == |
164 PaintsIntoOwnBacking && | 162 PaintsIntoOwnBacking && |
165 ancestorPaintProperties.overflowClip()) { | 163 ancestorPaintProperties.overflowClip()) { |
166 ancestorState.setClip(ancestorPaintProperties.overflowClip()); | 164 ancestorState.setClip(ancestorPaintProperties.overflowClip()); |
167 #ifdef CHECK_CLIP_RECTS | 165 #ifdef CHECK_CLIP_RECTS |
168 respectOverflowClip = IgnoreOverflowClip; | 166 respectOverflowClip = IgnoreOverflowClip; |
169 #endif | 167 #endif |
170 } | 168 } |
171 | 169 |
172 #ifdef CHECK_CLIP_RECTS | 170 #ifdef CHECK_CLIP_RECTS |
173 ClipRects& oldClipRects = | 171 ClipRects& oldClipRects = |
174 paintLayer.clipper(PaintLayer::DoNotUseGeometryMapper) | 172 paintLayer.clipper(PaintLayer::DoNotUseGeometryMapper) |
175 .paintingClipRects(&ancestorTransformedOrRootPaintLayer, | 173 .paintingClipRects(&ancestorTransformedOrRootPaintLayer, |
176 respectOverflowClip, LayoutSize()); | 174 respectOverflowClip, LayoutSize()); |
177 #endif | 175 #endif |
178 | 176 |
179 bool hasClip = false; | 177 bool hasClip = false; |
180 RefPtr<ClipRects> clipRects = ClipRects::create(); | 178 RefPtr<ClipRects> clipRects = ClipRects::create(); |
Xianzhu
2017/03/10 00:06:49
(Can be follow-up) We can also skip line 178-210 i
chrishtr
2017/03/10 01:45:29
Do you mean if ancestorState.clip() is above all o
| |
181 const LayoutPoint& ancestorPaintOffset = | 179 const LayoutPoint& ancestorPaintOffset = |
182 context.ancestorTransformedOrRootPaintLayer->layoutObject().paintOffset(); | 180 context.ancestorTransformedOrRootPaintLayer->layoutObject().paintOffset(); |
183 clipRects->setOverflowClipRect( | 181 |
184 clipRectForContext(context.treeBuilderContext.current, effect, | 182 FloatClipRect clipRect; |
185 ancestorState, ancestorPaintOffset, hasClip)); | 183 computeClipRectForContext(context.treeBuilderContext.current, effect, |
184 ancestorState, ancestorPaintOffset, hasClip, | |
185 clipRect); | |
186 clipRects->setOverflowClipRect(clipRect); | |
186 #ifdef CHECK_CLIP_RECTS | 187 #ifdef CHECK_CLIP_RECTS |
187 CHECK(!hasClip || | 188 CHECK(!hasClip || |
188 clipRects->overflowClipRect() == oldClipRects.overflowClipRect()) | 189 clipRects->overflowClipRect() == oldClipRects.overflowClipRect()) |
189 << "rect= " << clipRects->overflowClipRect().toString(); | 190 << "rect= " << clipRects->overflowClipRect().toString(); |
190 #endif | 191 #endif |
191 | 192 |
192 clipRects->setFixedClipRect( | 193 computeClipRectForContext(context.treeBuilderContext.fixedPosition, effect, |
193 clipRectForContext(context.treeBuilderContext.fixedPosition, effect, | 194 ancestorState, ancestorPaintOffset, hasClip, |
194 ancestorState, ancestorPaintOffset, hasClip)); | 195 clipRect); |
196 clipRects->setFixedClipRect(clipRect); | |
195 #ifdef CHECK_CLIP_RECTS | 197 #ifdef CHECK_CLIP_RECTS |
196 CHECK(hasClip || clipRects->fixedClipRect() == oldClipRects.fixedClipRect()) | 198 CHECK(hasClip || clipRects->fixedClipRect() == oldClipRects.fixedClipRect()) |
197 << " fixed=" << clipRects->fixedClipRect().toString(); | 199 << " fixed=" << clipRects->fixedClipRect().toString(); |
198 #endif | 200 #endif |
199 | 201 |
200 clipRects->setPosClipRect( | 202 computeClipRectForContext(context.treeBuilderContext.absolutePosition, effect, |
201 clipRectForContext(context.treeBuilderContext.absolutePosition, effect, | 203 ancestorState, ancestorPaintOffset, hasClip, |
202 ancestorState, ancestorPaintOffset, hasClip)); | 204 clipRect); |
205 clipRects->setPosClipRect(clipRect); | |
203 #ifdef CHECK_CLIP_RECTS | 206 #ifdef CHECK_CLIP_RECTS |
204 CHECK(!hasClip || clipRects->posClipRect() == oldClipRects.posClipRect()) | 207 CHECK(!hasClip || clipRects->posClipRect() == oldClipRects.posClipRect()) |
205 << " abs=" << clipRects->posClipRect().toString(); | 208 << " abs=" << clipRects->posClipRect().toString(); |
206 #endif | 209 #endif |
207 | 210 |
208 ClipRects* previousClipRects = paintLayer.previousPaintingClipRects(); | 211 ClipRects* previousClipRects = paintLayer.previousPaintingClipRects(); |
209 | 212 |
210 if (!previousClipRects || *clipRects != *previousClipRects) { | 213 if (!previousClipRects || *clipRects != *previousClipRects) { |
211 paintLayer.setNeedsRepaint(); | 214 paintLayer.setNeedsRepaint(); |
212 paintLayer.setPreviousPaintPhaseDescendantOutlinesEmpty(false); | 215 paintLayer.setPreviousPaintPhaseDescendantOutlinesEmpty(false); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
277 roundedIntPoint(context->treeBuilderContext.current.paintOffset); | 280 roundedIntPoint(context->treeBuilderContext.current.paintOffset); |
278 walk(*toFrameView(frameViewBase), *context); | 281 walk(*toFrameView(frameViewBase), *context); |
279 } | 282 } |
280 // TODO(pdr): Investigate RemoteFrameView (crbug.com/579281). | 283 // TODO(pdr): Investigate RemoteFrameView (crbug.com/579281). |
281 } | 284 } |
282 | 285 |
283 object.getMutableForPainting().clearPaintFlags(); | 286 object.getMutableForPainting().clearPaintFlags(); |
284 } | 287 } |
285 | 288 |
286 } // namespace blink | 289 } // namespace blink |
OLD | NEW |