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

Side by Side Diff: third_party/WebKit/Source/core/paint/PrePaintTreeWalk.cpp

Issue 2798513002: Revert of Make GeometryMapper fully static (Closed)
Patch Set: Created 3 years, 8 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 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"
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/paint/PaintLayer.h" 13 #include "core/paint/PaintLayer.h"
14 #include "platform/graphics/paint/GeometryMapper.h"
15 14
16 namespace blink { 15 namespace blink {
17 16
18 struct PrePaintTreeWalkContext { 17 struct PrePaintTreeWalkContext {
19 PrePaintTreeWalkContext() 18 PrePaintTreeWalkContext(GeometryMapper& geometryMapper)
20 : treeBuilderContext( 19 : treeBuilderContext(
21 WTF::wrapUnique(new PaintPropertyTreeBuilderContext)), 20 WTF::wrapUnique(new PaintPropertyTreeBuilderContext)),
22 paintInvalidatorContext(*treeBuilderContext), 21 paintInvalidatorContext(*treeBuilderContext, geometryMapper),
23 ancestorOverflowPaintLayer(nullptr), 22 ancestorOverflowPaintLayer(nullptr),
24 ancestorTransformedOrRootPaintLayer(nullptr) {} 23 ancestorTransformedOrRootPaintLayer(nullptr) {}
25 PrePaintTreeWalkContext(const PrePaintTreeWalkContext& parentContext) 24 PrePaintTreeWalkContext(const PrePaintTreeWalkContext& parentContext)
26 : treeBuilderContext(WTF::wrapUnique(new PaintPropertyTreeBuilderContext( 25 : treeBuilderContext(WTF::wrapUnique(new PaintPropertyTreeBuilderContext(
27 *parentContext.treeBuilderContext))), 26 *parentContext.treeBuilderContext))),
28 paintInvalidatorContext(*treeBuilderContext, 27 paintInvalidatorContext(*treeBuilderContext,
29 parentContext.paintInvalidatorContext), 28 parentContext.paintInvalidatorContext),
30 ancestorOverflowPaintLayer(parentContext.ancestorOverflowPaintLayer), 29 ancestorOverflowPaintLayer(parentContext.ancestorOverflowPaintLayer),
31 ancestorTransformedOrRootPaintLayer( 30 ancestorTransformedOrRootPaintLayer(
32 parentContext.ancestorTransformedOrRootPaintLayer) {} 31 parentContext.ancestorTransformedOrRootPaintLayer) {}
33 32
34 // PaintPropertyTreeBuilderContext is large and can lead to stack overflows 33 // PaintPropertyTreeBuilderContext is large and can lead to stack overflows
35 // when recursion is deep so this context object is allocated on the heap. 34 // when recursion is deep so this context object is allocated on the heap.
36 // See: https://crbug.com/698653. 35 // See: https://crbug.com/698653.
37 std::unique_ptr<PaintPropertyTreeBuilderContext> treeBuilderContext; 36 std::unique_ptr<PaintPropertyTreeBuilderContext> treeBuilderContext;
38 37
39 PaintInvalidatorContext paintInvalidatorContext; 38 PaintInvalidatorContext paintInvalidatorContext;
40 39
41 // The ancestor in the PaintLayer tree which has overflow clip, or 40 // The ancestor in the PaintLayer tree which has overflow clip, or
42 // is the root layer. Note that it is tree ancestor, not containing 41 // is the root layer. Note that it is tree ancestor, not containing
43 // block or stacking ancestor. 42 // block or stacking ancestor.
44 PaintLayer* ancestorOverflowPaintLayer; 43 PaintLayer* ancestorOverflowPaintLayer;
45 PaintLayer* ancestorTransformedOrRootPaintLayer; 44 PaintLayer* ancestorTransformedOrRootPaintLayer;
46 }; 45 };
47 46
48 void PrePaintTreeWalk::walk(FrameView& rootFrame) { 47 void PrePaintTreeWalk::walk(FrameView& rootFrame) {
49 DCHECK(rootFrame.frame().document()->lifecycle().state() == 48 DCHECK(rootFrame.frame().document()->lifecycle().state() ==
50 DocumentLifecycle::InPrePaint); 49 DocumentLifecycle::InPrePaint);
51 50
52 PrePaintTreeWalkContext initialContext; 51 PrePaintTreeWalkContext initialContext(m_geometryMapper);
53 initialContext.ancestorTransformedOrRootPaintLayer = 52 initialContext.ancestorTransformedOrRootPaintLayer =
54 rootFrame.layoutView()->layer(); 53 rootFrame.layoutView()->layer();
55 54
56 // GeometryMapper caches depend on paint properties. 55 // GeometryMapper depends on paint properties.
57 if (rootFrame.needsPaintPropertyUpdate() || 56 if (rootFrame.needsPaintPropertyUpdate() ||
58 (rootFrame.layoutView() && 57 (rootFrame.layoutView() &&
59 !shouldEndWalkBefore(*rootFrame.layoutView(), initialContext))) 58 !shouldEndWalkBefore(*rootFrame.layoutView(), initialContext)))
60 GeometryMapper::clearCache(); 59 m_geometryMapper.clearCache();
61 60
62 walk(rootFrame, initialContext); 61 walk(rootFrame, initialContext);
63 m_paintInvalidator.processPendingDelayedPaintInvalidations(); 62 m_paintInvalidator.processPendingDelayedPaintInvalidations();
64 } 63 }
65 64
66 void PrePaintTreeWalk::walk(FrameView& frameView, 65 void PrePaintTreeWalk::walk(FrameView& frameView,
67 const PrePaintTreeWalkContext& parentContext) { 66 const PrePaintTreeWalkContext& parentContext) {
68 if (frameView.shouldThrottleRendering()) { 67 if (frameView.shouldThrottleRendering()) {
69 // Skip the throttled frame. Will update it when it becomes unthrottled. 68 // Skip the throttled frame. Will update it when it becomes unthrottled.
70 return; 69 return;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 // Only return a non-infinite clip if clips differ, or the "ancestor" state is 130 // Only return a non-infinite clip if clips differ, or the "ancestor" state is
132 // actually an ancestor clip. This ensures no accuracy issues due to 131 // actually an ancestor clip. This ensures no accuracy issues due to
133 // transforms applied to infinite rects. 132 // transforms applied to infinite rects.
134 if (isAncestorOfOrEqualTo(context.clip, ancestorState.clip())) 133 if (isAncestorOfOrEqualTo(context.clip, ancestorState.clip()))
135 clipRect = FloatClipRect(); 134 clipRect = FloatClipRect();
136 135
137 hasClip = true; 136 hasClip = true;
138 PropertyTreeState localState(context.transform, context.clip, effect); 137 PropertyTreeState localState(context.transform, context.clip, effect);
139 138
140 clipRect = 139 clipRect =
141 GeometryMapper::sourceToDestinationClipRect(localState, ancestorState); 140 m_geometryMapper.sourceToDestinationClipRect(localState, ancestorState);
142 clipRect.moveBy(-FloatPoint(ancestorPaintOffset)); 141 clipRect.moveBy(-FloatPoint(ancestorPaintOffset));
143 } 142 }
144 143
145 void PrePaintTreeWalk::invalidatePaintLayerOptimizationsIfNeeded( 144 void PrePaintTreeWalk::invalidatePaintLayerOptimizationsIfNeeded(
146 const LayoutObject& object, 145 const LayoutObject& object,
147 PrePaintTreeWalkContext& context) { 146 PrePaintTreeWalkContext& context) {
148 if (!object.hasLayer()) 147 if (!object.hasLayer())
149 return; 148 return;
150 149
151 PaintLayer& paintLayer = *toLayoutBoxModelObject(object).layer(); 150 PaintLayer& paintLayer = *toLayoutBoxModelObject(object).layer();
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 roundedIntPoint(context.treeBuilderContext->current.paintOffset); 280 roundedIntPoint(context.treeBuilderContext->current.paintOffset);
282 walk(*toFrameView(frameViewBase), context); 281 walk(*toFrameView(frameViewBase), context);
283 } 282 }
284 // TODO(pdr): Investigate RemoteFrameView (crbug.com/579281). 283 // TODO(pdr): Investigate RemoteFrameView (crbug.com/579281).
285 } 284 }
286 285
287 object.getMutableForPainting().clearPaintFlags(); 286 object.getMutableForPainting().clearPaintFlags();
288 } 287 }
289 288
290 } // namespace blink 289 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698