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

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

Issue 2714673002: [SPv2] Implement effect compositing for indirect reasons (Closed)
Patch Set: mark tests 589265 Created 3 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 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"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 std::unique_ptr<JSONObject> layersAsJSON(LayerTreeFlags) const; 84 std::unique_ptr<JSONObject> layersAsJSON(LayerTreeFlags) const;
85 85
86 #ifndef NDEBUG 86 #ifndef NDEBUG
87 void showDebugData(); 87 void showDebugData();
88 #endif 88 #endif
89 89
90 private: 90 private:
91 // A pending layer is a collection of paint chunks that will end up in 91 // A pending layer is a collection of paint chunks that will end up in
92 // the same cc::Layer. 92 // the same cc::Layer.
93 struct PLATFORM_EXPORT PendingLayer { 93 struct PLATFORM_EXPORT PendingLayer {
94 PendingLayer(const PaintChunk& firstPaintChunk); 94 PendingLayer(const PaintChunk& firstPaintChunk, bool chunkIsForeign);
95 void add(const PaintChunk&, GeometryMapper*); 95 // Merge another pending layer after this one, appending all its paint
96 // chunks after chunks in this layer, with appropriate space conversion
97 // applied. The merged layer must have a property tree state that's deeper
98 // than this layer, i.e. can "upcast" to this layer's state.
99 void merge(const PendingLayer& guest, GeometryMapper&);
100 bool canMerge(const PendingLayer& guest) const;
101 // Mutate this layer's property tree state to a more general (shallower)
102 // state, thus the name "upcast". The concrete effect of this is to
103 // "decomposite" some of the properties, so that fewer properties will be
104 // applied by the compositor, and more properties will be applied internally
105 // to the chunks as Skia commands.
106 void upcast(const PropertyTreeState&, GeometryMapper&);
96 FloatRect bounds; 107 FloatRect bounds;
97 Vector<const PaintChunk*> paintChunks; 108 Vector<const PaintChunk*> paintChunks;
98 bool knownToBeOpaque; 109 bool knownToBeOpaque;
99 bool backfaceHidden; 110 bool backfaceHidden;
100 PropertyTreeState propertyTreeState; 111 PropertyTreeState propertyTreeState;
112 bool isForeign;
101 }; 113 };
102 114
103 PaintArtifactCompositor(); 115 PaintArtifactCompositor();
104 116
105 class ContentLayerClientImpl; 117 class ContentLayerClientImpl;
106 118
107 // Collects the PaintChunks into groups which will end up in the same 119 // Collects the PaintChunks into groups which will end up in the same
108 // cc layer. This includes testing PaintChunks for "merge" compatibility (e.g. 120 // cc layer. This is the entry point of the layerization algorithm.
109 // directly composited property tree states are separately composited)
110 // and overlap testing (PaintChunks that overlap existing PaintLayers they
111 // are not compatible with must be separately composited).
112 void collectPendingLayers(const PaintArtifact&, 121 void collectPendingLayers(const PaintArtifact&,
113 Vector<PendingLayer>& pendingLayers, 122 Vector<PendingLayer>& pendingLayers,
114 GeometryMapper&); 123 GeometryMapper&);
124 // This is the internal recursion of collectPendingLayers. This function
125 // loops over the list of paint chunks, scoped by an isolated group
126 // (i.e. effect node). Inside of the loop, chunks are tested for overlap
127 // and merge compatibility. Subgroups are handled by recursion, and will
128 // be tested for "decompositing" upon return.
129 // Merge compatibility means consecutive chunks may be layerized into the
130 // same backing (i.e. merged) if their property states don't cross
131 // direct-compositing boundary.
132 // Non-consecutive chunks that are nevertheless compatible may still be
133 // merged, if reordering of the chunks won't affect the ultimate result.
134 // This is determined by overlap testing such that chunks can be safely
135 // reordered if their effective bounds in screen space can't overlap.
136 // The recursion only tests merge & overlap for chunks scoped by the same
137 // group. This is where "decompositing" came in. Upon returning from a
138 // recursion, the layerization of the subgroup may be tested for merge &
139 // overlap with other chunks in the parent group, if grouping requirement
140 // can be satisfied (and the effect node has no direct reason).
141 static void layerizeGroup(const PaintArtifact&,
142 Vector<PendingLayer>& pendingLayers,
143 GeometryMapper&,
144 const EffectPaintPropertyNode&,
145 Vector<PaintChunk>::const_iterator& chunkCursor);
146 static bool mightOverlap(const PendingLayer&,
147 const PendingLayer&,
148 GeometryMapper&);
149 static bool canDecompositeEffect(const EffectPaintPropertyNode*,
150 const PendingLayer&);
115 151
116 // Builds a leaf layer that represents a single paint chunk. 152 // Builds a leaf layer that represents a single paint chunk.
117 // Note: cc::Layer API assumes the layer bounds start at (0, 0), but the 153 // Note: cc::Layer API assumes the layer bounds start at (0, 0), but the
118 // bounding box of a paint chunk does not necessarily start at (0, 0) (and 154 // bounding box of a paint chunk does not necessarily start at (0, 0) (and
119 // could even be negative). Internally the generated layer translates the 155 // could even be negative). Internally the generated layer translates the
120 // paint chunk to align the bounding box to (0, 0) and return the actual 156 // paint chunk to align the bounding box to (0, 0) and return the actual
121 // origin of the paint chunk in the |layerOffset| outparam. 157 // origin of the paint chunk in the |layerOffset| outparam.
122 scoped_refptr<cc::Layer> compositedLayerForPendingLayer( 158 scoped_refptr<cc::Layer> compositedLayerForPendingLayer(
123 const PaintArtifact&, 159 const PaintArtifact&,
124 const PendingLayer&, 160 const PendingLayer&,
125 gfx::Vector2dF& layerOffset, 161 gfx::Vector2dF& layerOffset,
126 Vector<std::unique_ptr<ContentLayerClientImpl>>& newContentLayerClients, 162 Vector<std::unique_ptr<ContentLayerClientImpl>>& newContentLayerClients,
127 RasterInvalidationTrackingMap<const PaintChunk>*, 163 RasterInvalidationTrackingMap<const PaintChunk>*,
128 bool storeDebugInfo, 164 bool storeDebugInfo,
129 GeometryMapper&); 165 GeometryMapper&);
130 166
131 // Finds a client among the current vector of clients that matches the paint 167 // Finds a client among the current vector of clients that matches the paint
132 // chunk's id, or otherwise allocates a new one. 168 // chunk's id, or otherwise allocates a new one.
133 std::unique_ptr<ContentLayerClientImpl> clientForPaintChunk( 169 std::unique_ptr<ContentLayerClientImpl> clientForPaintChunk(
134 const PaintChunk&, 170 const PaintChunk&,
135 const PaintArtifact&); 171 const PaintArtifact&);
136 172
137 static bool canMergeInto(const PaintArtifact&,
138 const PaintChunk& newChunk,
139 const PendingLayer& candidatePendingLayer);
140
141 // Returns true if |newChunk| might overlap |candidatePendingLayer| in the
142 // root property tree space. If it does overlap, it will always return true.
143 // If it doesn't overlap, it might return true in cases were we can't
144 // efficiently determine a false value, or the truth depends on
145 // compositor animations.
146 static bool mightOverlap(const PaintChunk& newChunk,
147 const PendingLayer& candidatePendingLayer,
148 GeometryMapper&);
149
150 scoped_refptr<cc::Layer> m_rootLayer; 173 scoped_refptr<cc::Layer> m_rootLayer;
151 std::unique_ptr<WebLayer> m_webLayer; 174 std::unique_ptr<WebLayer> m_webLayer;
152 Vector<std::unique_ptr<ContentLayerClientImpl>> m_contentLayerClients; 175 Vector<std::unique_ptr<ContentLayerClientImpl>> m_contentLayerClients;
153 176
154 bool m_extraDataForTestingEnabled = false; 177 bool m_extraDataForTestingEnabled = false;
155 std::unique_ptr<ExtraDataForTesting> m_extraDataForTesting; 178 std::unique_ptr<ExtraDataForTesting> m_extraDataForTesting;
156 friend class StubChromeClientForSPv2; 179 friend class StubChromeClientForSPv2;
157 180
158 bool m_isTrackingRasterInvalidations; 181 bool m_isTrackingRasterInvalidations;
159 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees, 182 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees,
(...skipping 29 matching lines...) Expand all
189 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees, 212 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees,
190 OverlapTransform); 213 OverlapTransform);
191 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees, 214 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees,
192 MightOverlap); 215 MightOverlap);
193 216
194 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees, 217 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees,
195 PendingLayer); 218 PendingLayer);
196 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees, 219 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees,
197 PendingLayerWithGeometry); 220 PendingLayerWithGeometry);
198 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees, 221 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees,
199 PendingLayerKnownOpaque); 222 PendingLayerKnownOpaque_DISABLED);
200 }; 223 };
201 224
202 } // namespace blink 225 } // namespace blink
203 226
204 #endif // PaintArtifactCompositor_h 227 #endif // PaintArtifactCompositor_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698