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