OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 CC_TEST_LAYER_TEST_COMMON_H_ | 5 #ifndef CC_TEST_LAYER_TEST_COMMON_H_ |
6 #define CC_TEST_LAYER_TEST_COMMON_H_ | 6 #define CC_TEST_LAYER_TEST_COMMON_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 public: | 54 public: |
55 LayerImplTest(); | 55 LayerImplTest(); |
56 explicit LayerImplTest(const LayerTreeSettings& settings); | 56 explicit LayerImplTest(const LayerTreeSettings& settings); |
57 ~LayerImplTest(); | 57 ~LayerImplTest(); |
58 | 58 |
59 template <typename T> | 59 template <typename T> |
60 T* AddChildToRoot() { | 60 T* AddChildToRoot() { |
61 std::unique_ptr<T> layer = | 61 std::unique_ptr<T> layer = |
62 T::Create(host_->host_impl()->active_tree(), layer_impl_id_++); | 62 T::Create(host_->host_impl()->active_tree(), layer_impl_id_++); |
63 T* ptr = layer.get(); | 63 T* ptr = layer.get(); |
64 root_layer()->test_properties()->AddChild(std::move(layer)); | 64 root_layer_for_testing()->test_properties()->AddChild(std::move(layer)); |
65 return ptr; | 65 return ptr; |
66 } | 66 } |
67 | 67 |
68 template <typename T> | 68 template <typename T> |
69 T* AddChild(LayerImpl* parent) { | 69 T* AddChild(LayerImpl* parent) { |
70 std::unique_ptr<T> layer = | 70 std::unique_ptr<T> layer = |
71 T::Create(host_->host_impl()->active_tree(), layer_impl_id_++); | 71 T::Create(host_->host_impl()->active_tree(), layer_impl_id_++); |
72 T* ptr = layer.get(); | 72 T* ptr = layer.get(); |
73 parent->test_properties()->AddChild(std::move(layer)); | 73 parent->test_properties()->AddChild(std::move(layer)); |
74 return ptr; | 74 return ptr; |
75 } | 75 } |
76 | 76 |
77 template <typename T> | 77 template <typename T> |
78 T* AddReplicaLayer(LayerImpl* origin) { | 78 T* AddReplicaLayer(LayerImpl* origin) { |
79 std::unique_ptr<T> layer = | 79 std::unique_ptr<T> layer = |
80 T::Create(host_->host_impl()->active_tree(), layer_impl_id_++); | 80 T::Create(host_->host_impl()->active_tree(), layer_impl_id_++); |
81 T* ptr = layer.get(); | 81 T* ptr = layer.get(); |
82 origin->test_properties()->SetReplicaLayer(std::move(layer)); | 82 origin->test_properties()->SetReplicaLayer(std::move(layer)); |
83 return ptr; | 83 return ptr; |
84 } | 84 } |
85 | 85 |
86 template <typename T, typename A> | 86 template <typename T, typename A> |
87 T* AddChildToRoot(const A& a) { | 87 T* AddChildToRoot(const A& a) { |
88 std::unique_ptr<T> layer = | 88 std::unique_ptr<T> layer = |
89 T::Create(host_->host_impl()->active_tree(), layer_impl_id_++, a); | 89 T::Create(host_->host_impl()->active_tree(), layer_impl_id_++, a); |
90 T* ptr = layer.get(); | 90 T* ptr = layer.get(); |
91 root_layer()->test_properties()->AddChild(std::move(layer)); | 91 root_layer_for_testing()->test_properties()->AddChild(std::move(layer)); |
92 return ptr; | 92 return ptr; |
93 } | 93 } |
94 | 94 |
95 template <typename T, typename A, typename B> | 95 template <typename T, typename A, typename B> |
96 T* AddChildToRoot(const A& a, const B& b) { | 96 T* AddChildToRoot(const A& a, const B& b) { |
97 std::unique_ptr<T> layer = | 97 std::unique_ptr<T> layer = |
98 T::Create(host_->host_impl()->active_tree(), layer_impl_id_++, a, b); | 98 T::Create(host_->host_impl()->active_tree(), layer_impl_id_++, a, b); |
99 T* ptr = layer.get(); | 99 T* ptr = layer.get(); |
100 root_layer()->test_properties()->AddChild(std::move(layer)); | 100 root_layer_for_testing()->test_properties()->AddChild(std::move(layer)); |
101 return ptr; | 101 return ptr; |
102 } | 102 } |
103 | 103 |
104 template <typename T, typename A, typename B, typename C, typename D> | 104 template <typename T, typename A, typename B, typename C, typename D> |
105 T* AddChildToRoot(const A& a, const B& b, const C& c, const D& d) { | 105 T* AddChildToRoot(const A& a, const B& b, const C& c, const D& d) { |
106 std::unique_ptr<T> layer = T::Create(host_->host_impl()->active_tree(), | 106 std::unique_ptr<T> layer = T::Create(host_->host_impl()->active_tree(), |
107 layer_impl_id_++, a, b, c, d); | 107 layer_impl_id_++, a, b, c, d); |
108 T* ptr = layer.get(); | 108 T* ptr = layer.get(); |
109 root_layer()->test_properties()->AddChild(std::move(layer)); | 109 root_layer_for_testing()->test_properties()->AddChild(std::move(layer)); |
110 return ptr; | 110 return ptr; |
111 } | 111 } |
112 | 112 |
113 template <typename T, | 113 template <typename T, |
114 typename A, | 114 typename A, |
115 typename B, | 115 typename B, |
116 typename C, | 116 typename C, |
117 typename D, | 117 typename D, |
118 typename E> | 118 typename E> |
119 T* AddChildToRoot(const A& a, | 119 T* AddChildToRoot(const A& a, |
120 const B& b, | 120 const B& b, |
121 const C& c, | 121 const C& c, |
122 const D& d, | 122 const D& d, |
123 const E& e) { | 123 const E& e) { |
124 std::unique_ptr<T> layer = T::Create(host_->host_impl()->active_tree(), | 124 std::unique_ptr<T> layer = T::Create(host_->host_impl()->active_tree(), |
125 layer_impl_id_++, a, b, c, d, e); | 125 layer_impl_id_++, a, b, c, d, e); |
126 T* ptr = layer.get(); | 126 T* ptr = layer.get(); |
127 root_layer()->test_properties()->AddChild(std::move(layer)); | 127 root_layer_for_testing()->test_properties()->AddChild(std::move(layer)); |
128 return ptr; | 128 return ptr; |
129 } | 129 } |
130 | 130 |
131 void CalcDrawProps(const gfx::Size& viewport_size); | 131 void CalcDrawProps(const gfx::Size& viewport_size); |
132 void AppendQuadsWithOcclusion(LayerImpl* layer_impl, | 132 void AppendQuadsWithOcclusion(LayerImpl* layer_impl, |
133 const gfx::Rect& occluded); | 133 const gfx::Rect& occluded); |
134 void AppendQuadsForPassWithOcclusion(LayerImpl* layer_impl, | 134 void AppendQuadsForPassWithOcclusion(LayerImpl* layer_impl, |
135 RenderPass* given_render_pass, | 135 RenderPass* given_render_pass, |
136 const gfx::Rect& occluded); | 136 const gfx::Rect& occluded); |
137 void AppendSurfaceQuadsWithOcclusion(RenderSurfaceImpl* surface_impl, | 137 void AppendSurfaceQuadsWithOcclusion(RenderSurfaceImpl* surface_impl, |
138 const gfx::Rect& occluded); | 138 const gfx::Rect& occluded); |
139 | 139 |
140 void RequestCopyOfOutput(); | 140 void RequestCopyOfOutput(); |
141 | 141 |
142 OutputSurface* output_surface() const { | 142 OutputSurface* output_surface() const { |
143 return host_->host_impl()->output_surface(); | 143 return host_->host_impl()->output_surface(); |
144 } | 144 } |
145 ResourceProvider* resource_provider() const { | 145 ResourceProvider* resource_provider() const { |
146 return host_->host_impl()->resource_provider(); | 146 return host_->host_impl()->resource_provider(); |
147 } | 147 } |
148 LayerImpl* root_layer() const { | 148 LayerImpl* root_layer_for_testing() const { |
149 return host_impl()->active_tree()->root_layer(); | 149 return host_impl()->active_tree()->root_layer_for_testing(); |
150 } | 150 } |
151 FakeLayerTreeHost* host() { return host_.get(); } | 151 FakeLayerTreeHost* host() { return host_.get(); } |
152 FakeLayerTreeHostImpl* host_impl() const { return host_->host_impl(); } | 152 FakeLayerTreeHostImpl* host_impl() const { return host_->host_impl(); } |
153 TaskRunnerProvider* task_runner_provider() const { | 153 TaskRunnerProvider* task_runner_provider() const { |
154 return host_->host_impl()->task_runner_provider(); | 154 return host_->host_impl()->task_runner_provider(); |
155 } | 155 } |
156 const QuadList& quad_list() const { return render_pass_->quad_list; } | 156 const QuadList& quad_list() const { return render_pass_->quad_list; } |
157 scoped_refptr<AnimationTimeline> timeline() { return timeline_; } | 157 scoped_refptr<AnimationTimeline> timeline() { return timeline_; } |
158 scoped_refptr<AnimationTimeline> timeline_impl() { return timeline_impl_; } | 158 scoped_refptr<AnimationTimeline> timeline_impl() { return timeline_impl_; } |
159 | 159 |
160 private: | 160 private: |
161 FakeLayerTreeHostClient client_; | 161 FakeLayerTreeHostClient client_; |
162 TestTaskGraphRunner task_graph_runner_; | 162 TestTaskGraphRunner task_graph_runner_; |
163 std::unique_ptr<OutputSurface> output_surface_; | 163 std::unique_ptr<OutputSurface> output_surface_; |
164 std::unique_ptr<FakeLayerTreeHost> host_; | 164 std::unique_ptr<FakeLayerTreeHost> host_; |
165 std::unique_ptr<RenderPass> render_pass_; | 165 std::unique_ptr<RenderPass> render_pass_; |
166 scoped_refptr<AnimationTimeline> timeline_; | 166 scoped_refptr<AnimationTimeline> timeline_; |
167 scoped_refptr<AnimationTimeline> timeline_impl_; | 167 scoped_refptr<AnimationTimeline> timeline_impl_; |
168 int layer_impl_id_; | 168 int layer_impl_id_; |
169 }; | 169 }; |
170 }; | 170 }; |
171 | 171 |
172 } // namespace cc | 172 } // namespace cc |
173 | 173 |
174 #endif // CC_TEST_LAYER_TEST_COMMON_H_ | 174 #endif // CC_TEST_LAYER_TEST_COMMON_H_ |
OLD | NEW |