OLD | NEW |
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" |
| 11 #include "platform/graphics/GraphicsLayerClient.h" |
| 12 #include "platform/graphics/paint/PaintController.h" |
10 #include "wtf/Noncopyable.h" | 13 #include "wtf/Noncopyable.h" |
11 #include "wtf/PtrUtil.h" | 14 #include "wtf/PtrUtil.h" |
12 #include "wtf/Vector.h" | 15 #include "wtf/Vector.h" |
13 #include <memory> | 16 #include <memory> |
14 | 17 |
15 namespace cc { | 18 namespace cc { |
16 class Layer; | 19 class Layer; |
17 } | 20 } |
18 | 21 |
19 namespace gfx { | 22 namespace gfx { |
20 class Transform; | 23 class Transform; |
21 class Vector2dF; | 24 class Vector2dF; |
22 } | 25 } |
23 | 26 |
24 namespace blink { | 27 namespace blink { |
25 | 28 |
| 29 class DisplayItemClient; |
| 30 class IntRect; |
| 31 class JSONObject; |
26 class PaintArtifact; | 32 class PaintArtifact; |
27 class WebLayer; | 33 class WebLayer; |
28 struct PaintChunk; | 34 struct PaintChunk; |
29 | 35 |
30 // Responsible for managing compositing in terms of a PaintArtifact. | 36 // Responsible for managing compositing in terms of a PaintArtifact. |
31 // | 37 // |
32 // Owns a subtree of the compositor layer tree, and updates it in response to | 38 // Owns a subtree of the compositor layer tree, and updates it in response to |
33 // changes in the paint artifact. | 39 // changes in the paint artifact. |
34 // | 40 // |
35 // PaintArtifactCompositor is the successor to PaintLayerCompositor, reflecting | 41 // PaintArtifactCompositor is the successor to PaintLayerCompositor, reflecting |
36 // the new home of compositing decisions after paint in Slimming Paint v2. | 42 // the new home of compositing decisions after paint in Slimming Paint v2. |
37 class PLATFORM_EXPORT PaintArtifactCompositor { | 43 class PLATFORM_EXPORT PaintArtifactCompositor { |
38 WTF_MAKE_NONCOPYABLE(PaintArtifactCompositor); | 44 WTF_MAKE_NONCOPYABLE(PaintArtifactCompositor); |
39 | 45 |
40 public: | 46 public: |
41 ~PaintArtifactCompositor(); | 47 ~PaintArtifactCompositor(); |
42 | 48 |
43 static std::unique_ptr<PaintArtifactCompositor> create() { | 49 static std::unique_ptr<PaintArtifactCompositor> create() { |
44 return wrapUnique(new PaintArtifactCompositor()); | 50 return wrapUnique(new PaintArtifactCompositor()); |
45 } | 51 } |
46 | 52 |
47 // Updates the layer tree to match the provided paint artifact. | 53 // Updates the layer tree to match the provided paint artifact. |
48 void update(const PaintArtifact&); | 54 void update( |
| 55 const PaintArtifact&, |
| 56 RasterInvalidationTrackingMap<const PaintChunk>* paintChunkInvalidations); |
49 | 57 |
50 // The root layer of the tree managed by this object. | 58 // The root layer of the tree managed by this object. |
51 cc::Layer* rootLayer() const { return m_rootLayer.get(); } | 59 cc::Layer* rootLayer() const { return m_rootLayer.get(); } |
52 | 60 |
53 // Wraps rootLayer(), so that it can be attached as a child of another | 61 // Wraps rootLayer(), so that it can be attached as a child of another |
54 // WebLayer. | 62 // WebLayer. |
55 WebLayer* getWebLayer() const { return m_webLayer.get(); } | 63 WebLayer* getWebLayer() const { return m_webLayer.get(); } |
56 | 64 |
57 // Returns extra information recorded during unit tests. | 65 // Returns extra information recorded during unit tests. |
58 // While not part of the normal output of this class, this provides a simple | 66 // While not part of the normal output of this class, this provides a simple |
59 // way of locating the layers of interest, since there are still a slew of | 67 // way of locating the layers of interest, since there are still a slew of |
60 // placeholder layers required. | 68 // placeholder layers required. |
61 struct ExtraDataForTesting { | 69 struct ExtraDataForTesting { |
62 Vector<scoped_refptr<cc::Layer>> contentLayers; | 70 Vector<scoped_refptr<cc::Layer>> contentLayers; |
63 }; | 71 }; |
64 void enableExtraDataForTesting() { m_extraDataForTestingEnabled = true; } | 72 void enableExtraDataForTesting() { m_extraDataForTestingEnabled = true; } |
65 ExtraDataForTesting* getExtraDataForTesting() const { | 73 ExtraDataForTesting* getExtraDataForTesting() const { |
66 return m_extraDataForTesting.get(); | 74 return m_extraDataForTesting.get(); |
67 } | 75 } |
68 | 76 |
| 77 void setTracksRasterInvalidations(bool); |
| 78 void resetTrackedRasterInvalidations(); |
| 79 bool hasTrackedRasterInvalidations() const; |
| 80 |
| 81 std::unique_ptr<JSONObject> layersAsJSON(LayerTreeFlags) const; |
| 82 |
69 private: | 83 private: |
70 PaintArtifactCompositor(); | 84 PaintArtifactCompositor(); |
71 | 85 |
72 class ContentLayerClientImpl; | 86 class ContentLayerClientImpl; |
73 | 87 |
74 // Builds a leaf layer that represents a single paint chunk. | 88 // Builds a leaf layer that represents a single paint chunk. |
75 // Note: cc::Layer API assumes the layer bounds to start at (0, 0) but the bou
nding box of | 89 // Note: cc::Layer API assumes the layer bounds to start at (0, 0) but the bou
nding box of |
76 // a paint chunk does not necessarily start at (0, 0) and could even be negati
ve. Internally | 90 // a paint chunk does not necessarily start at (0, 0) and could even be negati
ve. Internally |
77 // the generated layer translates the paint chunk to align the bounding box to
(0, 0) and | 91 // the generated layer translates the paint chunk to align the bounding box to
(0, 0) and |
78 // return the actual origin of the paint chunk in output parameter layerOffset
. | 92 // return the actual origin of the paint chunk in output parameter layerOffset
. |
79 scoped_refptr<cc::Layer> layerForPaintChunk( | 93 scoped_refptr<cc::Layer> layerForPaintChunk( |
80 const PaintArtifact&, | 94 const PaintArtifact&, |
81 const PaintChunk&, | 95 const PaintChunk&, |
82 gfx::Vector2dF& layerOffset, | 96 gfx::Vector2dF& layerOffset, |
83 Vector<std::unique_ptr<ContentLayerClientImpl>>& newContentLayerClients); | 97 Vector<std::unique_ptr<ContentLayerClientImpl>>& newContentLayerClients, |
| 98 RasterInvalidationTracking*); |
84 | 99 |
85 // Finds a client among the current vector of clients that matches the paint c
hunk's id, | 100 // Finds a client among the current vector of clients that matches the paint c
hunk's id, |
86 // or otherwise allocates a new one. | 101 // or otherwise allocates a new one. |
87 std::unique_ptr<ContentLayerClientImpl> clientForPaintChunk( | 102 std::unique_ptr<ContentLayerClientImpl> clientForPaintChunk( |
88 const PaintChunk&); | 103 const PaintChunk&, |
| 104 const PaintArtifact&); |
89 | 105 |
90 scoped_refptr<cc::Layer> m_rootLayer; | 106 scoped_refptr<cc::Layer> m_rootLayer; |
91 std::unique_ptr<WebLayer> m_webLayer; | 107 std::unique_ptr<WebLayer> m_webLayer; |
92 Vector<std::unique_ptr<ContentLayerClientImpl>> m_contentLayerClients; | 108 Vector<std::unique_ptr<ContentLayerClientImpl>> m_contentLayerClients; |
93 | 109 |
94 bool m_extraDataForTestingEnabled = false; | 110 bool m_extraDataForTestingEnabled = false; |
95 std::unique_ptr<ExtraDataForTesting> m_extraDataForTesting; | 111 std::unique_ptr<ExtraDataForTesting> m_extraDataForTesting; |
96 friend class StubChromeClientForSPv2; | 112 friend class StubChromeClientForSPv2; |
| 113 |
| 114 bool m_isTrackingRasterInvalidations; |
97 }; | 115 }; |
98 | 116 |
99 } // namespace blink | 117 } // namespace blink |
100 | 118 |
101 #endif // PaintArtifactCompositor_h | 119 #endif // PaintArtifactCompositor_h |
OLD | NEW |