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

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&);
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 Vector<PaintChunk>& paintChunks,
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 PaintChunk& newChunk,
141 const PendingLayer& candidatePendingLayer);
142
143 // Returns true if |newChunk| overlaps |candidatePendingLayer| in the
144 // root property tree space.
145 static bool overlaps(const PaintChunk& newChunk,
146 const PendingLayer& candidatePendingLayer,
147 GeometryMapper&);
148
109 scoped_refptr<cc::Layer> m_rootLayer; 149 scoped_refptr<cc::Layer> m_rootLayer;
110 std::unique_ptr<WebLayer> m_webLayer; 150 std::unique_ptr<WebLayer> m_webLayer;
111 Vector<std::unique_ptr<ContentLayerClientImpl>> m_contentLayerClients; 151 Vector<std::unique_ptr<ContentLayerClientImpl>> m_contentLayerClients;
112 152
113 bool m_extraDataForTestingEnabled = false; 153 bool m_extraDataForTestingEnabled = false;
114 std::unique_ptr<ExtraDataForTesting> m_extraDataForTesting; 154 std::unique_ptr<ExtraDataForTesting> m_extraDataForTesting;
115 friend class StubChromeClientForSPv2; 155 friend class StubChromeClientForSPv2;
116 156
117 bool m_isTrackingRasterInvalidations; 157 bool m_isTrackingRasterInvalidations;
158 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees,
159 MergeSimpleChunks);
160 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees,
161 Merge2DTransform);
162 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees,
163 MergeClip);
164 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees,
165 MergeOpacity);
166 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees,
167 MergeNested);
168 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees,
169 ClipPushedUp);
170 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees,
171 EffectPushedUp);
172 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees,
173 EffectAndClipPushedUp);
174 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees,
175 ClipAndEffectNoTransform);
176 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees,
177 TwoClips);
178 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees,
179 TwoEffects);
180
181 FRIEND_TEST_ALL_PREFIXES(PaintArtifactCompositorTestWithPropertyTrees,
182 PendingLayer);
118 }; 183 };
119 184
120 } // namespace blink 185 } // namespace blink
121 186
122 #endif // PaintArtifactCompositor_h 187 #endif // PaintArtifactCompositor_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698