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 "wtf/Noncopyable.h" | 10 #include "wtf/Noncopyable.h" |
| 11 #include "wtf/PtrUtil.h" |
11 #include "wtf/Vector.h" | 12 #include "wtf/Vector.h" |
12 #include <memory> | 13 #include <memory> |
13 | 14 |
14 namespace cc { | 15 namespace cc { |
15 class Layer; | 16 class Layer; |
16 } | 17 } |
17 | 18 |
18 namespace gfx { | 19 namespace gfx { |
19 class Transform; | 20 class Transform; |
20 class Vector2dF; | 21 class Vector2dF; |
21 } | 22 } |
22 | 23 |
23 namespace blink { | 24 namespace blink { |
24 | 25 |
25 class PaintArtifact; | 26 class PaintArtifact; |
26 class WebLayer; | 27 class WebLayer; |
27 struct PaintChunk; | 28 struct PaintChunk; |
28 | 29 |
29 // Responsible for managing compositing in terms of a PaintArtifact. | 30 // Responsible for managing compositing in terms of a PaintArtifact. |
30 // | 31 // |
31 // Owns a subtree of the compositor layer tree, and updates it in response to | 32 // Owns a subtree of the compositor layer tree, and updates it in response to |
32 // changes in the paint artifact. | 33 // changes in the paint artifact. |
33 // | 34 // |
34 // PaintArtifactCompositor is the successor to PaintLayerCompositor, reflecting | 35 // PaintArtifactCompositor is the successor to PaintLayerCompositor, reflecting |
35 // the new home of compositing decisions after paint in Slimming Paint v2. | 36 // the new home of compositing decisions after paint in Slimming Paint v2. |
36 class PLATFORM_EXPORT PaintArtifactCompositor { | 37 class PLATFORM_EXPORT PaintArtifactCompositor { |
37 WTF_MAKE_NONCOPYABLE(PaintArtifactCompositor); | 38 WTF_MAKE_NONCOPYABLE(PaintArtifactCompositor); |
38 public: | 39 public: |
39 PaintArtifactCompositor(); | |
40 ~PaintArtifactCompositor(); | 40 ~PaintArtifactCompositor(); |
41 | 41 |
| 42 static std::unique_ptr<PaintArtifactCompositor> create() |
| 43 { |
| 44 return wrapUnique(new PaintArtifactCompositor()); |
| 45 } |
| 46 |
42 // Updates the layer tree to match the provided paint artifact. | 47 // Updates the layer tree to match the provided paint artifact. |
43 void update(const PaintArtifact&); | 48 void update(const PaintArtifact&); |
44 | 49 |
45 // The root layer of the tree managed by this object. | 50 // The root layer of the tree managed by this object. |
46 cc::Layer* rootLayer() const { return m_rootLayer.get(); } | 51 cc::Layer* rootLayer() const { return m_rootLayer.get(); } |
47 | 52 |
48 // Wraps rootLayer(), so that it can be attached as a child of another | 53 // Wraps rootLayer(), so that it can be attached as a child of another |
49 // WebLayer. | 54 // WebLayer. |
50 WebLayer* getWebLayer() const { return m_webLayer.get(); } | 55 WebLayer* getWebLayer() const { return m_webLayer.get(); } |
51 | 56 |
52 // Returns extra information recorded during unit tests. | 57 // Returns extra information recorded during unit tests. |
53 // While not part of the normal output of this class, this provides a simple | 58 // While not part of the normal output of this class, this provides a simple |
54 // way of locating the layers of interest, since there are still a slew of | 59 // way of locating the layers of interest, since there are still a slew of |
55 // placeholder layers required. | 60 // placeholder layers required. |
56 struct ExtraDataForTesting { | 61 struct ExtraDataForTesting { |
57 Vector<scoped_refptr<cc::Layer>> contentLayers; | 62 Vector<scoped_refptr<cc::Layer>> contentLayers; |
58 }; | 63 }; |
59 void enableExtraDataForTesting() { m_extraDataForTestingEnabled = true; } | 64 void enableExtraDataForTesting() { m_extraDataForTestingEnabled = true; } |
60 ExtraDataForTesting* getExtraDataForTesting() const { return m_extraDataForT
esting.get(); } | 65 ExtraDataForTesting* getExtraDataForTesting() const { return m_extraDataForT
esting.get(); } |
61 | 66 |
62 private: | 67 private: |
| 68 PaintArtifactCompositor(); |
| 69 |
63 class ContentLayerClientImpl; | 70 class ContentLayerClientImpl; |
64 | 71 |
65 // Builds a leaf layer that represents a single paint chunk. | 72 // Builds a leaf layer that represents a single paint chunk. |
66 // Note: cc::Layer API assumes the layer bounds to start at (0, 0) but the b
ounding box of | 73 // Note: cc::Layer API assumes the layer bounds to start at (0, 0) but the b
ounding box of |
67 // a paint chunk does not necessarily start at (0, 0) and could even be nega
tive. Internally | 74 // a paint chunk does not necessarily start at (0, 0) and could even be nega
tive. Internally |
68 // the generated layer translates the paint chunk to align the bounding box
to (0, 0) and | 75 // the generated layer translates the paint chunk to align the bounding box
to (0, 0) and |
69 // return the actual origin of the paint chunk in output parameter layerOffs
et. | 76 // return the actual origin of the paint chunk in output parameter layerOffs
et. |
70 scoped_refptr<cc::Layer> layerForPaintChunk(const PaintArtifact&, const Pain
tChunk&, gfx::Vector2dF& layerOffset); | 77 scoped_refptr<cc::Layer> layerForPaintChunk(const PaintArtifact&, const Pain
tChunk&, gfx::Vector2dF& layerOffset); |
71 | 78 |
72 scoped_refptr<cc::Layer> m_rootLayer; | 79 scoped_refptr<cc::Layer> m_rootLayer; |
73 std::unique_ptr<WebLayer> m_webLayer; | 80 std::unique_ptr<WebLayer> m_webLayer; |
74 Vector<std::unique_ptr<ContentLayerClientImpl>> m_contentLayerClients; | 81 Vector<std::unique_ptr<ContentLayerClientImpl>> m_contentLayerClients; |
75 | 82 |
76 bool m_extraDataForTestingEnabled = false; | 83 bool m_extraDataForTestingEnabled = false; |
77 std::unique_ptr<ExtraDataForTesting> m_extraDataForTesting; | 84 std::unique_ptr<ExtraDataForTesting> m_extraDataForTesting; |
| 85 friend class StubChromeClientForSPv2; |
78 }; | 86 }; |
79 | 87 |
80 } // namespace blink | 88 } // namespace blink |
81 | 89 |
82 #endif // PaintArtifactCompositor_h | 90 #endif // PaintArtifactCompositor_h |
OLD | NEW |