OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 #include "cc/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
11 #include "cc/animation/timing_function.h" | 11 #include "cc/animation/timing_function.h" |
12 #include "cc/debug/frame_rate_counter.h" | 12 #include "cc/debug/frame_rate_counter.h" |
13 #include "cc/layers/content_layer.h" | 13 #include "cc/layers/content_layer.h" |
14 #include "cc/layers/content_layer_client.h" | 14 #include "cc/layers/content_layer_client.h" |
15 #include "cc/layers/io_surface_layer.h" | 15 #include "cc/layers/io_surface_layer.h" |
16 #include "cc/layers/layer_impl.h" | 16 #include "cc/layers/layer_impl.h" |
17 #include "cc/layers/picture_layer.h" | 17 #include "cc/layers/picture_layer.h" |
18 #include "cc/layers/scrollbar_layer.h" | 18 #include "cc/layers/scrollbar_layer.h" |
| 19 #include "cc/layers/solid_color_layer.h" |
19 #include "cc/layers/video_layer.h" | 20 #include "cc/layers/video_layer.h" |
20 #include "cc/output/begin_frame_args.h" | 21 #include "cc/output/begin_frame_args.h" |
21 #include "cc/output/copy_output_request.h" | 22 #include "cc/output/copy_output_request.h" |
22 #include "cc/output/copy_output_result.h" | 23 #include "cc/output/copy_output_result.h" |
23 #include "cc/output/output_surface.h" | 24 #include "cc/output/output_surface.h" |
24 #include "cc/resources/prioritized_resource.h" | 25 #include "cc/resources/prioritized_resource.h" |
25 #include "cc/resources/prioritized_resource_manager.h" | 26 #include "cc/resources/prioritized_resource_manager.h" |
26 #include "cc/resources/resource_update_queue.h" | 27 #include "cc/resources/resource_update_queue.h" |
27 #include "cc/scheduler/frame_rate_controller.h" | 28 #include "cc/scheduler/frame_rate_controller.h" |
28 #include "cc/test/fake_content_layer.h" | 29 #include "cc/test/fake_content_layer.h" |
(...skipping 4037 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4066 | 4067 |
4067 private: | 4068 private: |
4068 FakeVideoFrameProvider provider_; | 4069 FakeVideoFrameProvider provider_; |
4069 scoped_refptr<VideoLayer> video_layer_; | 4070 scoped_refptr<VideoLayer> video_layer_; |
4070 int num_commits_; | 4071 int num_commits_; |
4071 int num_draws_; | 4072 int num_draws_; |
4072 }; | 4073 }; |
4073 | 4074 |
4074 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestVideoLayerInvalidate); | 4075 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestVideoLayerInvalidate); |
4075 | 4076 |
| 4077 class LayerTreeHostTestPushHiddenLayer : public LayerTreeHostTest { |
| 4078 protected: |
| 4079 virtual void SetupTree() OVERRIDE { |
| 4080 root_layer_ = Layer::Create(); |
| 4081 root_layer_->SetAnchorPoint(gfx::PointF()); |
| 4082 root_layer_->SetPosition(gfx::Point()); |
| 4083 root_layer_->SetBounds(gfx::Size(10, 10)); |
| 4084 |
| 4085 parent_layer_ = SolidColorLayer::Create(); |
| 4086 parent_layer_->SetAnchorPoint(gfx::PointF()); |
| 4087 parent_layer_->SetPosition(gfx::Point()); |
| 4088 parent_layer_->SetBounds(gfx::Size(10, 10)); |
| 4089 parent_layer_->SetIsDrawable(true); |
| 4090 root_layer_->AddChild(parent_layer_); |
| 4091 |
| 4092 child_layer_ = SolidColorLayer::Create(); |
| 4093 child_layer_->SetAnchorPoint(gfx::PointF()); |
| 4094 child_layer_->SetPosition(gfx::Point()); |
| 4095 child_layer_->SetBounds(gfx::Size(10, 10)); |
| 4096 child_layer_->SetIsDrawable(true); |
| 4097 parent_layer_->AddChild(child_layer_); |
| 4098 |
| 4099 layer_tree_host()->SetRootLayer(root_layer_); |
| 4100 LayerTreeHostTest::SetupTree(); |
| 4101 } |
| 4102 |
| 4103 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
| 4104 |
| 4105 virtual void DidCommitAndDrawFrame() OVERRIDE { |
| 4106 switch (layer_tree_host()->source_frame_number()) { |
| 4107 case 1: |
| 4108 // The layer type used does not need to push properties every frame. |
| 4109 EXPECT_FALSE(child_layer_->needs_push_properties()); |
| 4110 |
| 4111 // Change the bounds of the child layer, but make it skipped |
| 4112 // by CalculateDrawProperties. |
| 4113 parent_layer_->SetOpacity(0.f); |
| 4114 child_layer_->SetBounds(gfx::Size(5, 5)); |
| 4115 break; |
| 4116 case 2: |
| 4117 // The bounds of the child layer were pushed to the impl side. |
| 4118 EXPECT_FALSE(child_layer_->needs_push_properties()); |
| 4119 |
| 4120 EndTest(); |
| 4121 break; |
| 4122 } |
| 4123 } |
| 4124 |
| 4125 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 4126 LayerImpl* root = impl->active_tree()->root_layer(); |
| 4127 LayerImpl* parent = root->children()[0]; |
| 4128 LayerImpl* child = parent->children()[0]; |
| 4129 |
| 4130 switch (impl->active_tree()->source_frame_number()) { |
| 4131 case 1: |
| 4132 EXPECT_EQ(gfx::Size(5, 5).ToString(), child->bounds().ToString()); |
| 4133 break; |
| 4134 } |
| 4135 } |
| 4136 |
| 4137 virtual void AfterTest() OVERRIDE {} |
| 4138 |
| 4139 scoped_refptr<Layer> root_layer_; |
| 4140 scoped_refptr<SolidColorLayer> parent_layer_; |
| 4141 scoped_refptr<SolidColorLayer> child_layer_; |
| 4142 }; |
| 4143 |
| 4144 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPushHiddenLayer); |
| 4145 |
| 4146 class LayerTreeHostTestPushLayerInEmptyViewport : public LayerTreeHostTest { |
| 4147 protected: |
| 4148 virtual void SetupTree() OVERRIDE { |
| 4149 root_layer_ = Layer::Create(); |
| 4150 root_layer_->SetAnchorPoint(gfx::PointF()); |
| 4151 root_layer_->SetPosition(gfx::Point()); |
| 4152 root_layer_->SetBounds(gfx::Size(10, 10)); |
| 4153 |
| 4154 parent_layer_ = SolidColorLayer::Create(); |
| 4155 parent_layer_->SetAnchorPoint(gfx::PointF()); |
| 4156 parent_layer_->SetPosition(gfx::Point()); |
| 4157 parent_layer_->SetBounds(gfx::Size(10, 10)); |
| 4158 parent_layer_->SetIsDrawable(true); |
| 4159 root_layer_->AddChild(parent_layer_); |
| 4160 |
| 4161 child_layer_ = SolidColorLayer::Create(); |
| 4162 child_layer_->SetAnchorPoint(gfx::PointF()); |
| 4163 child_layer_->SetPosition(gfx::Point()); |
| 4164 child_layer_->SetBounds(gfx::Size(10, 10)); |
| 4165 child_layer_->SetIsDrawable(true); |
| 4166 parent_layer_->AddChild(child_layer_); |
| 4167 |
| 4168 layer_tree_host()->SetRootLayer(root_layer_); |
| 4169 LayerTreeHostTest::SetupTree(); |
| 4170 } |
| 4171 |
| 4172 virtual void BeginTest() OVERRIDE { |
| 4173 // The viewport is empty, so we don't need to update layers on the |
| 4174 // main thread. |
| 4175 layer_tree_host()->SetViewportSize(gfx::Size(0, 0)); |
| 4176 PostSetNeedsCommitToMainThread(); |
| 4177 } |
| 4178 |
| 4179 virtual void DidCommit() OVERRIDE { |
| 4180 switch (layer_tree_host()->source_frame_number()) { |
| 4181 case 1: |
| 4182 // The layer type used does not need to push properties every frame. |
| 4183 EXPECT_FALSE(child_layer_->needs_push_properties()); |
| 4184 |
| 4185 // Change the bounds of the child layer. |
| 4186 child_layer_->SetBounds(gfx::Size(5, 5)); |
| 4187 break; |
| 4188 case 2: |
| 4189 // The bounds of the child layer were pushed to the impl side. |
| 4190 EXPECT_FALSE(child_layer_->needs_push_properties()); |
| 4191 layer_tree_host()->SetNeedsCommit(); |
| 4192 break; |
| 4193 } |
| 4194 } |
| 4195 |
| 4196 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 4197 LayerImpl* root = impl->active_tree()->root_layer(); |
| 4198 LayerImpl* parent = root->children()[0]; |
| 4199 LayerImpl* child = parent->children()[0]; |
| 4200 |
| 4201 switch (impl->active_tree()->source_frame_number()) { |
| 4202 case 0: |
| 4203 EXPECT_EQ(gfx::Size(10, 10).ToString(), child->bounds().ToString()); |
| 4204 break; |
| 4205 case 1: |
| 4206 EXPECT_EQ(gfx::Size(5, 5).ToString(), child->bounds().ToString()); |
| 4207 break; |
| 4208 case 2: |
| 4209 EndTest(); |
| 4210 break; |
| 4211 } |
| 4212 } |
| 4213 |
| 4214 virtual void AfterTest() OVERRIDE {} |
| 4215 |
| 4216 scoped_refptr<Layer> root_layer_; |
| 4217 scoped_refptr<SolidColorLayer> parent_layer_; |
| 4218 scoped_refptr<SolidColorLayer> child_layer_; |
| 4219 }; |
| 4220 |
| 4221 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPushLayerInEmptyViewport); |
| 4222 |
4076 } // namespace | 4223 } // namespace |
4077 } // namespace cc | 4224 } // namespace cc |
OLD | NEW |