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

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

Issue 2581843002: Implement merging non-composited paint property nodes in the PACompositor. (Closed)
Patch Set: none Created 3 years, 12 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 DisplayItemList;
19 class Layer; 20 class Layer;
20 } 21 }
21 22
22 namespace gfx { 23 namespace gfx {
23 class Vector2dF; 24 class Vector2dF;
24 } 25 }
25 26
26 namespace blink { 27 namespace blink {
27 28
29 class GeometryMapper;
28 class JSONObject; 30 class JSONObject;
29 class PaintArtifact; 31 class PaintArtifact;
30 class WebLayer; 32 class WebLayer;
31 struct PaintChunk; 33 struct PaintChunk;
32 34
33 // Responsible for managing compositing in terms of a PaintArtifact. 35 // Responsible for managing compositing in terms of a PaintArtifact.
34 // 36 //
35 // Owns a subtree of the compositor layer tree, and updates it in response to 37 // Owns a subtree of the compositor layer tree, and updates it in response to
36 // changes in the paint artifact. 38 // changes in the paint artifact.
37 // 39 //
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 return m_extraDataForTesting.get(); 77 return m_extraDataForTesting.get();
76 } 78 }
77 79
78 void setTracksRasterInvalidations(bool); 80 void setTracksRasterInvalidations(bool);
79 void resetTrackedRasterInvalidations(); 81 void resetTrackedRasterInvalidations();
80 bool hasTrackedRasterInvalidations() const; 82 bool hasTrackedRasterInvalidations() const;
81 83
82 std::unique_ptr<JSONObject> layersAsJSON(LayerTreeFlags) const; 84 std::unique_ptr<JSONObject> layersAsJSON(LayerTreeFlags) const;
83 85
84 private: 86 private:
87 // A pending layer is a collection of paint chunks that will end up in
88 // the same cc::Layer.
89 struct PendingLayer {
90 PendingLayer(const PaintChunk& firstPaintChunk);
91 void add(const PaintChunk&, GeometryMapper*);
92 FloatRect bounds;
93 Vector<const PaintChunk*> paintChunks;
94 bool knownToBeOpaque;
95 bool backfaceHidden;
96 PropertyTreeState propertyTreeState;
97 };
98
85 PaintArtifactCompositor(); 99 PaintArtifactCompositor();
86 100
87 class ContentLayerClientImpl; 101 class ContentLayerClientImpl;
88 102
103 // Collects the PaintChunks into groups which will end up in the same
104 // cc layer. This includes testing PaintChunks for "merge" compatibility (e.g.
105 // directly composited property tree states are separately composited)
106 // and overlap testing (PaintChunks that overlap existing PaintLayers they
107 // are not compatible with must be separately composited).
108 void collectPendingLayers(const PaintArtifact&,
109 Vector<PendingLayer>& pendingLayers,
110 GeometryMapper&);
111
89 // Builds a leaf layer that represents a single paint chunk. 112 // Builds a leaf layer that represents a single paint chunk.
90 // Note: cc::Layer API assumes the layer bounds start at (0, 0), but the 113 // Note: cc::Layer API assumes the layer bounds start at (0, 0), but the
91 // bounding box of a paint chunk does not necessarily start at (0, 0) (and 114 // bounding box of a paint chunk does not necessarily start at (0, 0) (and
92 // could even be negative). Internally the generated layer translates the 115 // could even be negative). Internally the generated layer translates the
93 // paint chunk to align the bounding box to (0, 0) and return the actual 116 // paint chunk to align the bounding box to (0, 0) and return the actual
94 // origin of the paint chunk in the |layerOffset| outparam. 117 // origin of the paint chunk in the |layerOffset| outparam.
95 scoped_refptr<cc::Layer> layerForPaintChunk( 118 scoped_refptr<cc::Layer> compositedLayerForPendingLayer(
96 const PaintArtifact&, 119 const PaintArtifact&,
97 const PaintChunk&, 120 const PendingLayer&,
98 gfx::Vector2dF& layerOffset, 121 gfx::Vector2dF& layerOffset,
99 Vector<std::unique_ptr<ContentLayerClientImpl>>& newContentLayerClients, 122 Vector<std::unique_ptr<ContentLayerClientImpl>>& newContentLayerClients,
100 RasterInvalidationTracking*, 123 RasterInvalidationTrackingMap<const PaintChunk>*,
101 bool storeDebugInfo); 124 bool storeDebugInfo,
125 GeometryMapper&);
102 126
103 // Finds a client among the current vector of clients that matches the paint 127 // Finds a client among the current vector of clients that matches the paint
104 // chunk's id, or otherwise allocates a new one. 128 // chunk's id, or otherwise allocates a new one.
105 std::unique_ptr<ContentLayerClientImpl> clientForPaintChunk( 129 std::unique_ptr<ContentLayerClientImpl> clientForPaintChunk(
106 const PaintChunk&, 130 const PaintChunk&,
107 const PaintArtifact&); 131 const PaintArtifact&);
108 132
133 // This method is an implementation of Algorithm step 4 from goo.gl/6xP8Oe.
134 static scoped_refptr<cc::DisplayItemList> recordPendingLayer(
135 const PaintArtifact&,
136 const PendingLayer&,
137 const gfx::Rect& combinedBounds,
138 GeometryMapper&);
139
140 static bool canMergeInto(const PaintArtifact&,
141 const PaintChunk& newChunk,
142 const PendingLayer& candidatePendingLayer);
143
144 // Returns true if |newChunk| might overlap |candidatePendingLayer| in the
145 // root property tree space. If it does overlap, it will always return true.
146 // If it doesn't overlap, it might return true in cases were we can't
147 // efficiently determine a false value, or the truth depends on
148 // compositor animations.
149 static bool mightOverlap(const PaintChunk& newChunk,
150 const PendingLayer& candidatePendingLayer,
151 GeometryMapper&);
152
109 scoped_refptr<cc::Layer> m_rootLayer; 153 scoped_refptr<cc::Layer> m_rootLayer;
110 std::unique_ptr<WebLayer> m_webLayer; 154 std::unique_ptr<WebLayer> m_webLayer;
111 Vector<std::unique_ptr<ContentLayerClientImpl>> m_contentLayerClients; 155 Vector<std::unique_ptr<ContentLayerClientImpl>> m_contentLayerClients;
112 156
113 bool m_extraDataForTestingEnabled = false; 157 bool m_extraDataForTestingEnabled = false;
114 std::unique_ptr<ExtraDataForTesting> m_extraDataForTesting; 158 std::unique_ptr<ExtraDataForTesting> m_extraDataForTesting;
115 friend class StubChromeClientForSPv2; 159 friend class StubChromeClientForSPv2;
116 160
117 bool m_isTrackingRasterInvalidations; 161 bool m_isTrackingRasterInvalidations;
162 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees,
163 ForeignLayerPassesThrough);
164 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees,
165 MergeSimpleChunks);
166 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees,
167 Merge2DTransform);
168 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees,
169 MergeClip);
170 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees,
171 MergeOpacity);
172 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees,
173 MergeNested);
174 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees,
175 ClipPushedUp);
176 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees,
177 EffectPushedUp);
178 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees,
179 EffectAndClipPushedUp);
180 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees,
181 ClipAndEffectNoTransform);
182 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees,
183 TwoClips);
184 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees,
185 TwoEffects);
186
187 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees,
188 PendingLayer);
189 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees,
190 PendingLayerWithGeometry);
118 }; 191 };
119 192
120 } // namespace blink 193 } // namespace blink
121 194
122 #endif // PaintArtifactCompositor_h 195 #endif // PaintArtifactCompositor_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698