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> |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "cc/animation/animation_timeline.h" | 13 #include "cc/animation/animation_timeline.h" |
14 #include "cc/quads/render_pass.h" | 14 #include "cc/quads/render_pass.h" |
15 #include "cc/test/fake_layer_tree_host.h" | 15 #include "cc/test/fake_layer_tree_host.h" |
| 16 #include "cc/test/test_element_id.h" |
16 #include "cc/test/test_task_graph_runner.h" | 17 #include "cc/test/test_task_graph_runner.h" |
17 #include "cc/trees/layer_tree_host_impl.h" | 18 #include "cc/trees/layer_tree_host_impl.h" |
18 | 19 |
19 #define EXPECT_SET_NEEDS_COMMIT(expect, code_to_test) \ | 20 #define EXPECT_SET_NEEDS_COMMIT(expect, code_to_test) \ |
20 do { \ | 21 do { \ |
21 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times((expect)); \ | 22 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times((expect)); \ |
22 code_to_test; \ | 23 code_to_test; \ |
23 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); \ | 24 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); \ |
24 } while (false) | 25 } while (false) |
25 | 26 |
(...skipping 27 matching lines...) Expand all Loading... |
53 class LayerImplTest { | 54 class LayerImplTest { |
54 public: | 55 public: |
55 LayerImplTest(); | 56 LayerImplTest(); |
56 explicit LayerImplTest(const LayerTreeSettings& settings); | 57 explicit LayerImplTest(const LayerTreeSettings& settings); |
57 ~LayerImplTest(); | 58 ~LayerImplTest(); |
58 | 59 |
59 template <typename T> | 60 template <typename T> |
60 T* AddChildToRoot() { | 61 T* AddChildToRoot() { |
61 std::unique_ptr<T> layer = | 62 std::unique_ptr<T> layer = |
62 T::Create(host_->host_impl()->active_tree(), layer_impl_id_++); | 63 T::Create(host_->host_impl()->active_tree(), layer_impl_id_++); |
| 64 layer->SetElementId(NextTestElementId()); |
63 T* ptr = layer.get(); | 65 T* ptr = layer.get(); |
64 root_layer()->AddChild(std::move(layer)); | 66 root_layer()->AddChild(std::move(layer)); |
65 return ptr; | 67 return ptr; |
66 } | 68 } |
67 | 69 |
68 template <typename T> | 70 template <typename T> |
69 T* AddChild(LayerImpl* parent) { | 71 T* AddChild(LayerImpl* parent) { |
70 std::unique_ptr<T> layer = | 72 std::unique_ptr<T> layer = |
71 T::Create(host_->host_impl()->active_tree(), layer_impl_id_++); | 73 T::Create(host_->host_impl()->active_tree(), layer_impl_id_++); |
| 74 layer->SetElementId(NextTestElementId()); |
72 T* ptr = layer.get(); | 75 T* ptr = layer.get(); |
73 parent->AddChild(std::move(layer)); | 76 parent->AddChild(std::move(layer)); |
74 return ptr; | 77 return ptr; |
75 } | 78 } |
76 | 79 |
77 template <typename T> | 80 template <typename T> |
78 T* AddReplicaLayer(LayerImpl* origin) { | 81 T* AddReplicaLayer(LayerImpl* origin) { |
79 std::unique_ptr<T> layer = | 82 std::unique_ptr<T> layer = |
80 T::Create(host_->host_impl()->active_tree(), layer_impl_id_++); | 83 T::Create(host_->host_impl()->active_tree(), layer_impl_id_++); |
| 84 layer->SetElementId(NextTestElementId()); |
81 T* ptr = layer.get(); | 85 T* ptr = layer.get(); |
82 origin->SetReplicaLayer(std::move(layer)); | 86 origin->SetReplicaLayer(std::move(layer)); |
83 return ptr; | 87 return ptr; |
84 } | 88 } |
85 | 89 |
86 template <typename T, typename A> | 90 template <typename T, typename A> |
87 T* AddChildToRoot(const A& a) { | 91 T* AddChildToRoot(const A& a) { |
88 std::unique_ptr<T> layer = | 92 std::unique_ptr<T> layer = |
89 T::Create(host_->host_impl()->active_tree(), layer_impl_id_++, a); | 93 T::Create(host_->host_impl()->active_tree(), layer_impl_id_++, a); |
| 94 layer->SetElementId(NextTestElementId()); |
90 T* ptr = layer.get(); | 95 T* ptr = layer.get(); |
91 root_layer()->AddChild(std::move(layer)); | 96 root_layer()->AddChild(std::move(layer)); |
92 return ptr; | 97 return ptr; |
93 } | 98 } |
94 | 99 |
95 template <typename T, typename A, typename B> | 100 template <typename T, typename A, typename B> |
96 T* AddChildToRoot(const A& a, const B& b) { | 101 T* AddChildToRoot(const A& a, const B& b) { |
97 std::unique_ptr<T> layer = | 102 std::unique_ptr<T> layer = |
98 T::Create(host_->host_impl()->active_tree(), layer_impl_id_++, a, b); | 103 T::Create(host_->host_impl()->active_tree(), layer_impl_id_++, a, b); |
| 104 layer->SetElementId(NextTestElementId()); |
99 T* ptr = layer.get(); | 105 T* ptr = layer.get(); |
100 root_layer()->AddChild(std::move(layer)); | 106 root_layer()->AddChild(std::move(layer)); |
101 return ptr; | 107 return ptr; |
102 } | 108 } |
103 | 109 |
104 template <typename T, typename A, typename B, typename C, typename D> | 110 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) { | 111 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(), | 112 std::unique_ptr<T> layer = T::Create(host_->host_impl()->active_tree(), |
107 layer_impl_id_++, a, b, c, d); | 113 layer_impl_id_++, a, b, c, d); |
| 114 layer->SetElementId(NextTestElementId()); |
108 T* ptr = layer.get(); | 115 T* ptr = layer.get(); |
109 root_layer()->AddChild(std::move(layer)); | 116 root_layer()->AddChild(std::move(layer)); |
110 return ptr; | 117 return ptr; |
111 } | 118 } |
112 | 119 |
113 template <typename T, | 120 template <typename T, |
114 typename A, | 121 typename A, |
115 typename B, | 122 typename B, |
116 typename C, | 123 typename C, |
117 typename D, | 124 typename D, |
118 typename E> | 125 typename E> |
119 T* AddChildToRoot(const A& a, | 126 T* AddChildToRoot(const A& a, |
120 const B& b, | 127 const B& b, |
121 const C& c, | 128 const C& c, |
122 const D& d, | 129 const D& d, |
123 const E& e) { | 130 const E& e) { |
124 std::unique_ptr<T> layer = T::Create(host_->host_impl()->active_tree(), | 131 std::unique_ptr<T> layer = T::Create(host_->host_impl()->active_tree(), |
125 layer_impl_id_++, a, b, c, d, e); | 132 layer_impl_id_++, a, b, c, d, e); |
| 133 layer->SetElementId(NextTestElementId()); |
126 T* ptr = layer.get(); | 134 T* ptr = layer.get(); |
127 root_layer()->AddChild(std::move(layer)); | 135 root_layer()->AddChild(std::move(layer)); |
128 return ptr; | 136 return ptr; |
129 } | 137 } |
130 | 138 |
131 void CalcDrawProps(const gfx::Size& viewport_size); | 139 void CalcDrawProps(const gfx::Size& viewport_size); |
132 void AppendQuadsWithOcclusion(LayerImpl* layer_impl, | 140 void AppendQuadsWithOcclusion(LayerImpl* layer_impl, |
133 const gfx::Rect& occluded); | 141 const gfx::Rect& occluded); |
134 void AppendQuadsForPassWithOcclusion(LayerImpl* layer_impl, | 142 void AppendQuadsForPassWithOcclusion(LayerImpl* layer_impl, |
135 RenderPass* given_render_pass, | 143 RenderPass* given_render_pass, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 std::unique_ptr<RenderPass> render_pass_; | 177 std::unique_ptr<RenderPass> render_pass_; |
170 scoped_refptr<AnimationTimeline> timeline_; | 178 scoped_refptr<AnimationTimeline> timeline_; |
171 scoped_refptr<AnimationTimeline> timeline_impl_; | 179 scoped_refptr<AnimationTimeline> timeline_impl_; |
172 int layer_impl_id_; | 180 int layer_impl_id_; |
173 }; | 181 }; |
174 }; | 182 }; |
175 | 183 |
176 } // namespace cc | 184 } // namespace cc |
177 | 185 |
178 #endif // CC_TEST_LAYER_TEST_COMMON_H_ | 186 #endif // CC_TEST_LAYER_TEST_COMMON_H_ |
OLD | NEW |