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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositor.h

Issue 2793993003: 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 #ifndef PaintArtifactCompositor_h 5 #ifndef PaintArtifactCompositor_h
6 #define PaintArtifactCompositor_h 6 #define PaintArtifactCompositor_h
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "platform/PlatformExport.h" 9 #include "platform/PlatformExport.h"
10 #include "platform/RuntimeEnabledFeatures.h" 10 #include "platform/RuntimeEnabledFeatures.h"
11 #include "platform/graphics/GraphicsLayerClient.h" 11 #include "platform/graphics/GraphicsLayerClient.h"
12 #include "platform/graphics/paint/PaintController.h" 12 #include "platform/graphics/paint/PaintController.h"
13 #include "wtf/Noncopyable.h" 13 #include "wtf/Noncopyable.h"
14 #include "wtf/PtrUtil.h" 14 #include "wtf/PtrUtil.h"
15 #include "wtf/Vector.h" 15 #include "wtf/Vector.h"
16 #include <memory> 16 #include <memory>
17 17
18 namespace cc { 18 namespace cc {
19 class Layer; 19 class Layer;
20 } 20 }
21 21
22 namespace gfx { 22 namespace gfx {
23 class Vector2dF; 23 class Vector2dF;
24 } 24 }
25 25
26 namespace blink { 26 namespace blink {
27 27
28 class GeometryMapper;
29 class JSONObject; 28 class JSONObject;
30 class PaintArtifact; 29 class PaintArtifact;
31 class WebLayer; 30 class WebLayer;
32 struct PaintChunk; 31 struct PaintChunk;
33 32
34 // Responsible for managing compositing in terms of a PaintArtifact. 33 // Responsible for managing compositing in terms of a PaintArtifact.
35 // 34 //
36 // Owns a subtree of the compositor layer tree, and updates it in response to 35 // Owns a subtree of the compositor layer tree, and updates it in response to
37 // changes in the paint artifact. 36 // changes in the paint artifact.
38 // 37 //
(...skipping 10 matching lines...) Expand all
49 return WTF::wrapUnique(new PaintArtifactCompositor()); 48 return WTF::wrapUnique(new PaintArtifactCompositor());
50 } 49 }
51 50
52 // Updates the layer tree to match the provided paint artifact. 51 // Updates the layer tree to match the provided paint artifact.
53 // If |storeDebugInfo| is true, stores detailed debugging information in 52 // If |storeDebugInfo| is true, stores detailed debugging information in
54 // the layers that will be output as part of a call to layersAsJSON 53 // the layers that will be output as part of a call to layersAsJSON
55 // (if LayerTreeIncludesDebugInfo is specified). 54 // (if LayerTreeIncludesDebugInfo is specified).
56 void update( 55 void update(
57 const PaintArtifact&, 56 const PaintArtifact&,
58 RasterInvalidationTrackingMap<const PaintChunk>* paintChunkInvalidations, 57 RasterInvalidationTrackingMap<const PaintChunk>* paintChunkInvalidations,
59 bool storeDebugInfo, 58 bool storeDebugInfo);
60 GeometryMapper&);
61 59
62 // The root layer of the tree managed by this object. 60 // The root layer of the tree managed by this object.
63 cc::Layer* rootLayer() const { return m_rootLayer.get(); } 61 cc::Layer* rootLayer() const { return m_rootLayer.get(); }
64 62
65 // Wraps rootLayer(), so that it can be attached as a child of another 63 // Wraps rootLayer(), so that it can be attached as a child of another
66 // WebLayer. 64 // WebLayer.
67 WebLayer* getWebLayer() const { return m_webLayer.get(); } 65 WebLayer* getWebLayer() const { return m_webLayer.get(); }
68 66
69 // Returns extra information recorded during unit tests. 67 // Returns extra information recorded during unit tests.
70 // While not part of the normal output of this class, this provides a simple 68 // While not part of the normal output of this class, this provides a simple
(...skipping 19 matching lines...) Expand all
90 88
91 private: 89 private:
92 // A pending layer is a collection of paint chunks that will end up in 90 // A pending layer is a collection of paint chunks that will end up in
93 // the same cc::Layer. 91 // the same cc::Layer.
94 struct PLATFORM_EXPORT PendingLayer { 92 struct PLATFORM_EXPORT PendingLayer {
95 PendingLayer(const PaintChunk& firstPaintChunk, bool chunkIsForeign); 93 PendingLayer(const PaintChunk& firstPaintChunk, bool chunkIsForeign);
96 // Merge another pending layer after this one, appending all its paint 94 // Merge another pending layer after this one, appending all its paint
97 // chunks after chunks in this layer, with appropriate space conversion 95 // chunks after chunks in this layer, with appropriate space conversion
98 // applied. The merged layer must have a property tree state that's deeper 96 // applied. The merged layer must have a property tree state that's deeper
99 // than this layer, i.e. can "upcast" to this layer's state. 97 // than this layer, i.e. can "upcast" to this layer's state.
100 void merge(const PendingLayer& guest, GeometryMapper&); 98 void merge(const PendingLayer& guest);
101 bool canMerge(const PendingLayer& guest) const; 99 bool canMerge(const PendingLayer& guest) const;
102 // Mutate this layer's property tree state to a more general (shallower) 100 // Mutate this layer's property tree state to a more general (shallower)
103 // state, thus the name "upcast". The concrete effect of this is to 101 // state, thus the name "upcast". The concrete effect of this is to
104 // "decomposite" some of the properties, so that fewer properties will be 102 // "decomposite" some of the properties, so that fewer properties will be
105 // applied by the compositor, and more properties will be applied internally 103 // applied by the compositor, and more properties will be applied internally
106 // to the chunks as Skia commands. 104 // to the chunks as Skia commands.
107 void upcast(const PropertyTreeState&, GeometryMapper&); 105 void upcast(const PropertyTreeState&);
108 FloatRect bounds; 106 FloatRect bounds;
109 Vector<const PaintChunk*> paintChunks; 107 Vector<const PaintChunk*> paintChunks;
110 bool knownToBeOpaque; 108 bool knownToBeOpaque;
111 bool backfaceHidden; 109 bool backfaceHidden;
112 PropertyTreeState propertyTreeState; 110 PropertyTreeState propertyTreeState;
113 bool isForeign; 111 bool isForeign;
114 }; 112 };
115 113
116 PaintArtifactCompositor(); 114 PaintArtifactCompositor();
117 115
118 class ContentLayerClientImpl; 116 class ContentLayerClientImpl;
119 117
120 // Collects the PaintChunks into groups which will end up in the same 118 // Collects the PaintChunks into groups which will end up in the same
121 // cc layer. This is the entry point of the layerization algorithm. 119 // cc layer. This is the entry point of the layerization algorithm.
122 void collectPendingLayers(const PaintArtifact&, 120 void collectPendingLayers(const PaintArtifact&,
123 Vector<PendingLayer>& pendingLayers, 121 Vector<PendingLayer>& pendingLayers);
124 GeometryMapper&);
125 // This is the internal recursion of collectPendingLayers. This function 122 // This is the internal recursion of collectPendingLayers. This function
126 // loops over the list of paint chunks, scoped by an isolated group 123 // loops over the list of paint chunks, scoped by an isolated group
127 // (i.e. effect node). Inside of the loop, chunks are tested for overlap 124 // (i.e. effect node). Inside of the loop, chunks are tested for overlap
128 // and merge compatibility. Subgroups are handled by recursion, and will 125 // and merge compatibility. Subgroups are handled by recursion, and will
129 // be tested for "decompositing" upon return. 126 // be tested for "decompositing" upon return.
130 // Merge compatibility means consecutive chunks may be layerized into the 127 // Merge compatibility means consecutive chunks may be layerized into the
131 // same backing (i.e. merged) if their property states don't cross 128 // same backing (i.e. merged) if their property states don't cross
132 // direct-compositing boundary. 129 // direct-compositing boundary.
133 // Non-consecutive chunks that are nevertheless compatible may still be 130 // Non-consecutive chunks that are nevertheless compatible may still be
134 // merged, if reordering of the chunks won't affect the ultimate result. 131 // merged, if reordering of the chunks won't affect the ultimate result.
135 // This is determined by overlap testing such that chunks can be safely 132 // This is determined by overlap testing such that chunks can be safely
136 // reordered if their effective bounds in screen space can't overlap. 133 // reordered if their effective bounds in screen space can't overlap.
137 // The recursion only tests merge & overlap for chunks scoped by the same 134 // The recursion only tests merge & overlap for chunks scoped by the same
138 // group. This is where "decompositing" came in. Upon returning from a 135 // group. This is where "decompositing" came in. Upon returning from a
139 // recursion, the layerization of the subgroup may be tested for merge & 136 // recursion, the layerization of the subgroup may be tested for merge &
140 // overlap with other chunks in the parent group, if grouping requirement 137 // overlap with other chunks in the parent group, if grouping requirement
141 // can be satisfied (and the effect node has no direct reason). 138 // can be satisfied (and the effect node has no direct reason).
142 static void layerizeGroup(const PaintArtifact&, 139 static void layerizeGroup(const PaintArtifact&,
143 Vector<PendingLayer>& pendingLayers, 140 Vector<PendingLayer>& pendingLayers,
144 GeometryMapper&,
145 const EffectPaintPropertyNode&, 141 const EffectPaintPropertyNode&,
146 Vector<PaintChunk>::const_iterator& chunkCursor); 142 Vector<PaintChunk>::const_iterator& chunkCursor);
147 static bool mightOverlap(const PendingLayer&, 143 static bool mightOverlap(const PendingLayer&, const PendingLayer&);
148 const PendingLayer&,
149 GeometryMapper&);
150 static bool canDecompositeEffect(const EffectPaintPropertyNode*, 144 static bool canDecompositeEffect(const EffectPaintPropertyNode*,
151 const PendingLayer&); 145 const PendingLayer&);
152 146
153 // Builds a leaf layer that represents a single paint chunk. 147 // Builds a leaf layer that represents a single paint chunk.
154 // Note: cc::Layer API assumes the layer bounds start at (0, 0), but the 148 // Note: cc::Layer API assumes the layer bounds start at (0, 0), but the
155 // bounding box of a paint chunk does not necessarily start at (0, 0) (and 149 // bounding box of a paint chunk does not necessarily start at (0, 0) (and
156 // could even be negative). Internally the generated layer translates the 150 // could even be negative). Internally the generated layer translates the
157 // paint chunk to align the bounding box to (0, 0) and return the actual 151 // paint chunk to align the bounding box to (0, 0) and return the actual
158 // origin of the paint chunk in the |layerOffset| outparam. 152 // origin of the paint chunk in the |layerOffset| outparam.
159 scoped_refptr<cc::Layer> compositedLayerForPendingLayer( 153 scoped_refptr<cc::Layer> compositedLayerForPendingLayer(
160 const PaintArtifact&, 154 const PaintArtifact&,
161 const PendingLayer&, 155 const PendingLayer&,
162 gfx::Vector2dF& layerOffset, 156 gfx::Vector2dF& layerOffset,
163 Vector<std::unique_ptr<ContentLayerClientImpl>>& newContentLayerClients, 157 Vector<std::unique_ptr<ContentLayerClientImpl>>& newContentLayerClients,
164 RasterInvalidationTrackingMap<const PaintChunk>*, 158 RasterInvalidationTrackingMap<const PaintChunk>*,
165 bool storeDebugInfo, 159 bool storeDebugInfo);
166 GeometryMapper&);
167 160
168 // Finds a client among the current vector of clients that matches the paint 161 // Finds a client among the current vector of clients that matches the paint
169 // chunk's id, or otherwise allocates a new one. 162 // chunk's id, or otherwise allocates a new one.
170 std::unique_ptr<ContentLayerClientImpl> clientForPaintChunk( 163 std::unique_ptr<ContentLayerClientImpl> clientForPaintChunk(
171 const PaintChunk&, 164 const PaintChunk&,
172 const PaintArtifact&); 165 const PaintArtifact&);
173 166
174 scoped_refptr<cc::Layer> m_rootLayer; 167 scoped_refptr<cc::Layer> m_rootLayer;
175 std::unique_ptr<WebLayer> m_webLayer; 168 std::unique_ptr<WebLayer> m_webLayer;
176 Vector<std::unique_ptr<ContentLayerClientImpl>> m_contentLayerClients; 169 Vector<std::unique_ptr<ContentLayerClientImpl>> m_contentLayerClients;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 PendingLayer); 212 PendingLayer);
220 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees, 213 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees,
221 PendingLayerWithGeometry); 214 PendingLayerWithGeometry);
222 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees, 215 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees,
223 PendingLayerKnownOpaque_DISABLED); 216 PendingLayerKnownOpaque_DISABLED);
224 }; 217 };
225 218
226 } // namespace blink 219 } // namespace blink
227 220
228 #endif // PaintArtifactCompositor_h 221 #endif // PaintArtifactCompositor_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698