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 | |
pdr.
2016/09/15 20:53:07
Nit: extra space
chrishtr
2016/09/15 21:05:39
Done.
| |
47 | |
42 // Updates the layer tree to match the provided paint artifact. | 48 // Updates the layer tree to match the provided paint artifact. |
43 void update(const PaintArtifact&); | 49 void update(const PaintArtifact&); |
44 | 50 |
45 // The root layer of the tree managed by this object. | 51 // The root layer of the tree managed by this object. |
46 cc::Layer* rootLayer() const { return m_rootLayer.get(); } | 52 cc::Layer* rootLayer() const { return m_rootLayer.get(); } |
47 | 53 |
48 // Wraps rootLayer(), so that it can be attached as a child of another | 54 // Wraps rootLayer(), so that it can be attached as a child of another |
49 // WebLayer. | 55 // WebLayer. |
50 WebLayer* getWebLayer() const { return m_webLayer.get(); } | 56 WebLayer* getWebLayer() const { return m_webLayer.get(); } |
51 | 57 |
52 // Returns extra information recorded during unit tests. | 58 // Returns extra information recorded during unit tests. |
53 // While not part of the normal output of this class, this provides a simple | 59 // 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 | 60 // way of locating the layers of interest, since there are still a slew of |
55 // placeholder layers required. | 61 // placeholder layers required. |
56 struct ExtraDataForTesting { | 62 struct ExtraDataForTesting { |
57 Vector<scoped_refptr<cc::Layer>> contentLayers; | 63 Vector<scoped_refptr<cc::Layer>> contentLayers; |
58 }; | 64 }; |
59 void enableExtraDataForTesting() { m_extraDataForTestingEnabled = true; } | 65 void enableExtraDataForTesting() { m_extraDataForTestingEnabled = true; } |
60 ExtraDataForTesting* getExtraDataForTesting() const { return m_extraDataForT esting.get(); } | 66 ExtraDataForTesting* getExtraDataForTesting() const { return m_extraDataForT esting.get(); } |
61 | 67 |
62 private: | 68 private: |
69 PaintArtifactCompositor(); | |
70 | |
63 class ContentLayerClientImpl; | 71 class ContentLayerClientImpl; |
64 | 72 |
65 // Builds a leaf layer that represents a single paint chunk. | 73 // 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 | 74 // 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 | 75 // 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 | 76 // 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. | 77 // 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); | 78 scoped_refptr<cc::Layer> layerForPaintChunk(const PaintArtifact&, const Pain tChunk&, gfx::Vector2dF& layerOffset); |
71 | 79 |
72 scoped_refptr<cc::Layer> m_rootLayer; | 80 scoped_refptr<cc::Layer> m_rootLayer; |
73 std::unique_ptr<WebLayer> m_webLayer; | 81 std::unique_ptr<WebLayer> m_webLayer; |
74 Vector<std::unique_ptr<ContentLayerClientImpl>> m_contentLayerClients; | 82 Vector<std::unique_ptr<ContentLayerClientImpl>> m_contentLayerClients; |
75 | 83 |
76 bool m_extraDataForTestingEnabled = false; | 84 bool m_extraDataForTestingEnabled = false; |
77 std::unique_ptr<ExtraDataForTesting> m_extraDataForTesting; | 85 std::unique_ptr<ExtraDataForTesting> m_extraDataForTesting; |
86 friend class StubChromeClientForSPv2; | |
78 }; | 87 }; |
79 | 88 |
80 } // namespace blink | 89 } // namespace blink |
81 | 90 |
82 #endif // PaintArtifactCompositor_h | 91 #endif // PaintArtifactCompositor_h |
OLD | NEW |