| 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 <utility> | 11 #include <utility> |
| 11 | 12 |
| 12 #include "base/memory/scoped_ptr.h" | |
| 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_task_graph_runner.h" | 16 #include "cc/test/test_task_graph_runner.h" |
| 17 #include "cc/trees/layer_tree_host_impl.h" | 17 #include "cc/trees/layer_tree_host_impl.h" |
| 18 | 18 |
| 19 #define EXPECT_SET_NEEDS_COMMIT(expect, code_to_test) \ | 19 #define EXPECT_SET_NEEDS_COMMIT(expect, code_to_test) \ |
| 20 do { \ | 20 do { \ |
| 21 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times((expect)); \ | 21 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times((expect)); \ |
| 22 code_to_test; \ | 22 code_to_test; \ |
| (...skipping 28 matching lines...) Expand all Loading... |
| 51 size_t* partially_occluded_count); | 51 size_t* partially_occluded_count); |
| 52 | 52 |
| 53 class LayerImplTest { | 53 class LayerImplTest { |
| 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 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()->AddChild(std::move(layer)); | 64 root_layer()->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 scoped_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->AddChild(std::move(layer)); | 73 parent->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 scoped_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->SetReplicaLayer(std::move(layer)); | 82 origin->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 scoped_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()->AddChild(std::move(layer)); | 91 root_layer()->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 scoped_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()->AddChild(std::move(layer)); | 100 root_layer()->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 scoped_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()->AddChild(std::move(layer)); | 109 root_layer()->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 scoped_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()->AddChild(std::move(layer)); | 127 root_layer()->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, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 157 TaskRunnerProvider* task_runner_provider() const { | 157 TaskRunnerProvider* task_runner_provider() const { |
| 158 return host_->host_impl()->task_runner_provider(); | 158 return host_->host_impl()->task_runner_provider(); |
| 159 } | 159 } |
| 160 const QuadList& quad_list() const { return render_pass_->quad_list; } | 160 const QuadList& quad_list() const { return render_pass_->quad_list; } |
| 161 scoped_refptr<AnimationTimeline> timeline() { return timeline_; } | 161 scoped_refptr<AnimationTimeline> timeline() { return timeline_; } |
| 162 scoped_refptr<AnimationTimeline> timeline_impl() { return timeline_impl_; } | 162 scoped_refptr<AnimationTimeline> timeline_impl() { return timeline_impl_; } |
| 163 | 163 |
| 164 private: | 164 private: |
| 165 FakeLayerTreeHostClient client_; | 165 FakeLayerTreeHostClient client_; |
| 166 TestTaskGraphRunner task_graph_runner_; | 166 TestTaskGraphRunner task_graph_runner_; |
| 167 scoped_ptr<OutputSurface> output_surface_; | 167 std::unique_ptr<OutputSurface> output_surface_; |
| 168 scoped_ptr<FakeLayerTreeHost> host_; | 168 std::unique_ptr<FakeLayerTreeHost> host_; |
| 169 scoped_ptr<RenderPass> render_pass_; | 169 std::unique_ptr<RenderPass> render_pass_; |
| 170 scoped_refptr<AnimationTimeline> timeline_; | 170 scoped_refptr<AnimationTimeline> timeline_; |
| 171 scoped_refptr<AnimationTimeline> timeline_impl_; | 171 scoped_refptr<AnimationTimeline> timeline_impl_; |
| 172 int layer_impl_id_; | 172 int layer_impl_id_; |
| 173 }; | 173 }; |
| 174 }; | 174 }; |
| 175 | 175 |
| 176 } // namespace cc | 176 } // namespace cc |
| 177 | 177 |
| 178 #endif // CC_TEST_LAYER_TEST_COMMON_H_ | 178 #endif // CC_TEST_LAYER_TEST_COMMON_H_ |
| OLD | NEW |