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 <utility> | 10 #include <utility> |
(...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 scoped_ptr<T> layer = | 61 scoped_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_impl_->AddChild(std::move(layer)); | 64 LayerImpl* root_layer_impl = host_->active_tree()->root_layer(); |
| 65 root_layer_impl->AddChild(std::move(layer)); |
65 return ptr; | 66 return ptr; |
66 } | 67 } |
67 | 68 |
68 template <typename T> | 69 template <typename T> |
69 T* AddChild(LayerImpl* parent) { | 70 T* AddChild(LayerImpl* parent) { |
70 scoped_ptr<T> layer = | 71 scoped_ptr<T> layer = |
71 T::Create(host_->host_impl()->active_tree(), layer_impl_id_++); | 72 T::Create(host_->host_impl()->active_tree(), layer_impl_id_++); |
72 T* ptr = layer.get(); | 73 T* ptr = layer.get(); |
73 parent->AddChild(std::move(layer)); | 74 parent->AddChild(std::move(layer)); |
74 return ptr; | 75 return ptr; |
75 } | 76 } |
76 | 77 |
77 template <typename T> | 78 template <typename T> |
78 T* AddReplicaLayer(LayerImpl* origin) { | 79 T* AddReplicaLayer(LayerImpl* origin) { |
79 scoped_ptr<T> layer = | 80 scoped_ptr<T> layer = |
80 T::Create(host_->host_impl()->active_tree(), layer_impl_id_++); | 81 T::Create(host_->host_impl()->active_tree(), layer_impl_id_++); |
81 T* ptr = layer.get(); | 82 T* ptr = layer.get(); |
82 origin->SetReplicaLayer(std::move(layer)); | 83 origin->SetReplicaLayer(std::move(layer)); |
83 return ptr; | 84 return ptr; |
84 } | 85 } |
85 | 86 |
86 template <typename T, typename A> | 87 template <typename T, typename A> |
87 T* AddChildToRoot(const A& a) { | 88 T* AddChildToRoot(const A& a) { |
88 scoped_ptr<T> layer = | 89 scoped_ptr<T> layer = |
89 T::Create(host_->host_impl()->active_tree(), layer_impl_id_++, a); | 90 T::Create(host_->host_impl()->active_tree(), layer_impl_id_++, a); |
90 T* ptr = layer.get(); | 91 T* ptr = layer.get(); |
91 root_layer_impl_->AddChild(std::move(layer)); | 92 LayerImpl* root_layer_impl = host_->active_tree()->root_layer(); |
| 93 root_layer_impl->AddChild(std::move(layer)); |
92 return ptr; | 94 return ptr; |
93 } | 95 } |
94 | 96 |
95 template <typename T, typename A, typename B> | 97 template <typename T, typename A, typename B> |
96 T* AddChildToRoot(const A& a, const B& b) { | 98 T* AddChildToRoot(const A& a, const B& b) { |
97 scoped_ptr<T> layer = | 99 scoped_ptr<T> layer = |
98 T::Create(host_->host_impl()->active_tree(), layer_impl_id_++, a, b); | 100 T::Create(host_->host_impl()->active_tree(), layer_impl_id_++, a, b); |
99 T* ptr = layer.get(); | 101 T* ptr = layer.get(); |
100 root_layer_impl_->AddChild(std::move(layer)); | 102 LayerImpl* root_layer_impl = host_->active_tree()->root_layer(); |
| 103 root_layer_impl->AddChild(std::move(layer)); |
101 return ptr; | 104 return ptr; |
102 } | 105 } |
103 | 106 |
104 template <typename T, typename A, typename B, typename C, typename D> | 107 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) { | 108 T* AddChildToRoot(const A& a, const B& b, const C& c, const D& d) { |
106 scoped_ptr<T> layer = T::Create(host_->host_impl()->active_tree(), | 109 scoped_ptr<T> layer = T::Create(host_->host_impl()->active_tree(), |
107 layer_impl_id_++, a, b, c, d); | 110 layer_impl_id_++, a, b, c, d); |
108 T* ptr = layer.get(); | 111 T* ptr = layer.get(); |
109 root_layer_impl_->AddChild(std::move(layer)); | 112 LayerImpl* root_layer_impl = host_->active_tree()->root_layer(); |
| 113 root_layer_impl->AddChild(std::move(layer)); |
110 return ptr; | 114 return ptr; |
111 } | 115 } |
112 | 116 |
113 template <typename T, | 117 template <typename T, |
114 typename A, | 118 typename A, |
115 typename B, | 119 typename B, |
116 typename C, | 120 typename C, |
117 typename D, | 121 typename D, |
118 typename E> | 122 typename E> |
119 T* AddChildToRoot(const A& a, | 123 T* AddChildToRoot(const A& a, |
120 const B& b, | 124 const B& b, |
121 const C& c, | 125 const C& c, |
122 const D& d, | 126 const D& d, |
123 const E& e) { | 127 const E& e) { |
124 scoped_ptr<T> layer = T::Create(host_->host_impl()->active_tree(), | 128 scoped_ptr<T> layer = T::Create(host_->host_impl()->active_tree(), |
125 layer_impl_id_++, a, b, c, d, e); | 129 layer_impl_id_++, a, b, c, d, e); |
126 T* ptr = layer.get(); | 130 T* ptr = layer.get(); |
127 root_layer_impl_->AddChild(std::move(layer)); | 131 LayerImpl* root_layer_impl = host_->active_tree()->root_layer(); |
| 132 root_layer_impl->AddChild(std::move(layer)); |
128 return ptr; | 133 return ptr; |
129 } | 134 } |
130 | 135 |
131 void CalcDrawProps(const gfx::Size& viewport_size); | 136 void CalcDrawProps(const gfx::Size& viewport_size); |
132 void AppendQuadsWithOcclusion(LayerImpl* layer_impl, | 137 void AppendQuadsWithOcclusion(LayerImpl* layer_impl, |
133 const gfx::Rect& occluded); | 138 const gfx::Rect& occluded); |
134 void AppendQuadsForPassWithOcclusion(LayerImpl* layer_impl, | 139 void AppendQuadsForPassWithOcclusion(LayerImpl* layer_impl, |
135 RenderPass* given_render_pass, | 140 RenderPass* given_render_pass, |
136 const gfx::Rect& occluded); | 141 const gfx::Rect& occluded); |
137 void AppendSurfaceQuadsWithOcclusion(RenderSurfaceImpl* surface_impl, | 142 void AppendSurfaceQuadsWithOcclusion(RenderSurfaceImpl* surface_impl, |
138 const gfx::Rect& occluded); | 143 const gfx::Rect& occluded); |
139 | 144 |
140 void RequestCopyOfOutput(); | 145 void RequestCopyOfOutput(); |
141 | 146 |
142 void SetSecureOutputSurface(bool secure_output) { | 147 void SetSecureOutputSurface(bool secure_output) { |
143 host_->host_impl()->output_surface()->set_is_secure(secure_output); | 148 host_->host_impl()->output_surface()->set_is_secure(secure_output); |
144 } | 149 } |
145 | 150 |
146 OutputSurface* output_surface() const { | 151 OutputSurface* output_surface() const { |
147 return host_->host_impl()->output_surface(); | 152 return host_->host_impl()->output_surface(); |
148 } | 153 } |
149 ResourceProvider* resource_provider() const { | 154 ResourceProvider* resource_provider() const { |
150 return host_->host_impl()->resource_provider(); | 155 return host_->host_impl()->resource_provider(); |
151 } | 156 } |
152 LayerImpl* root_layer() const { return root_layer_impl_.get(); } | 157 LayerImpl* root_layer() const { |
| 158 return host_->host_impl()->active_tree()->root_layer(); |
| 159 } |
153 FakeLayerTreeHost* host() { return host_.get(); } | 160 FakeLayerTreeHost* host() { return host_.get(); } |
154 FakeLayerTreeHostImpl* host_impl() const { return host_->host_impl(); } | 161 FakeLayerTreeHostImpl* host_impl() const { return host_->host_impl(); } |
155 TaskRunnerProvider* task_runner_provider() const { | 162 TaskRunnerProvider* task_runner_provider() const { |
156 return host_->host_impl()->task_runner_provider(); | 163 return host_->host_impl()->task_runner_provider(); |
157 } | 164 } |
158 const QuadList& quad_list() const { return render_pass_->quad_list; } | 165 const QuadList& quad_list() const { return render_pass_->quad_list; } |
159 scoped_refptr<AnimationTimeline> timeline() { return timeline_; } | 166 scoped_refptr<AnimationTimeline> timeline() { return timeline_; } |
160 scoped_refptr<AnimationTimeline> timeline_impl() { return timeline_impl_; } | 167 scoped_refptr<AnimationTimeline> timeline_impl() { return timeline_impl_; } |
161 | 168 |
162 private: | 169 private: |
163 FakeLayerTreeHostClient client_; | 170 FakeLayerTreeHostClient client_; |
164 TestTaskGraphRunner task_graph_runner_; | 171 TestTaskGraphRunner task_graph_runner_; |
165 scoped_ptr<OutputSurface> output_surface_; | 172 scoped_ptr<OutputSurface> output_surface_; |
166 scoped_ptr<FakeLayerTreeHost> host_; | 173 scoped_ptr<FakeLayerTreeHost> host_; |
167 scoped_ptr<LayerImpl> root_layer_impl_; | |
168 scoped_ptr<RenderPass> render_pass_; | 174 scoped_ptr<RenderPass> render_pass_; |
169 scoped_refptr<AnimationTimeline> timeline_; | 175 scoped_refptr<AnimationTimeline> timeline_; |
170 scoped_refptr<AnimationTimeline> timeline_impl_; | 176 scoped_refptr<AnimationTimeline> timeline_impl_; |
171 int layer_impl_id_; | 177 int layer_impl_id_; |
172 }; | 178 }; |
173 }; | 179 }; |
174 | 180 |
175 } // namespace cc | 181 } // namespace cc |
176 | 182 |
177 #endif // CC_TEST_LAYER_TEST_COMMON_H_ | 183 #endif // CC_TEST_LAYER_TEST_COMMON_H_ |
OLD | NEW |