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 4038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4067 | 4068 |
4068 private: | 4069 private: |
4069 FakeVideoFrameProvider provider_; | 4070 FakeVideoFrameProvider provider_; |
4070 scoped_refptr<VideoLayer> video_layer_; | 4071 scoped_refptr<VideoLayer> video_layer_; |
4071 int num_commits_; | 4072 int num_commits_; |
4072 int num_draws_; | 4073 int num_draws_; |
4073 }; | 4074 }; |
4074 | 4075 |
4075 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestVideoLayerInvalidate); | 4076 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestVideoLayerInvalidate); |
4076 | 4077 |
| 4078 class LayerTreeHostTestPushHiddenLayer : public LayerTreeHostTest { |
| 4079 protected: |
| 4080 virtual void SetupTree() OVERRIDE { |
| 4081 root_layer_ = Layer::Create(); |
| 4082 root_layer_->SetAnchorPoint(gfx::PointF()); |
| 4083 root_layer_->SetPosition(gfx::Point()); |
| 4084 root_layer_->SetBounds(gfx::Size(10, 10)); |
| 4085 |
| 4086 parent_layer_ = SolidColorLayer::Create(); |
| 4087 parent_layer_->SetAnchorPoint(gfx::PointF()); |
| 4088 parent_layer_->SetPosition(gfx::Point()); |
| 4089 parent_layer_->SetBounds(gfx::Size(10, 10)); |
| 4090 parent_layer_->SetIsDrawable(true); |
| 4091 root_layer_->AddChild(parent_layer_); |
| 4092 |
| 4093 child_layer_ = SolidColorLayer::Create(); |
| 4094 child_layer_->SetAnchorPoint(gfx::PointF()); |
| 4095 child_layer_->SetPosition(gfx::Point()); |
| 4096 child_layer_->SetBounds(gfx::Size(10, 10)); |
| 4097 child_layer_->SetIsDrawable(true); |
| 4098 parent_layer_->AddChild(child_layer_); |
| 4099 |
| 4100 layer_tree_host()->SetRootLayer(root_layer_); |
| 4101 LayerTreeHostTest::SetupTree(); |
| 4102 } |
| 4103 |
| 4104 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
| 4105 |
| 4106 virtual void DidCommitAndDrawFrame() OVERRIDE { |
| 4107 switch (layer_tree_host()->source_frame_number()) { |
| 4108 case 1: |
| 4109 // The layer type used does not need to push properties every frame. |
| 4110 EXPECT_FALSE(child_layer_->needs_push_properties()); |
| 4111 |
| 4112 // Change the bounds of the child layer, but make it skipped |
| 4113 // by CalculateDrawProperties. |
| 4114 parent_layer_->SetOpacity(0.f); |
| 4115 child_layer_->SetBounds(gfx::Size(5, 5)); |
| 4116 break; |
| 4117 case 2: |
| 4118 // The bounds of the child layer were pushed to the impl side. |
| 4119 EXPECT_FALSE(child_layer_->needs_push_properties()); |
| 4120 |
| 4121 EndTest(); |
| 4122 break; |
| 4123 } |
| 4124 } |
| 4125 |
| 4126 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 4127 LayerImpl* root = impl->active_tree()->root_layer(); |
| 4128 LayerImpl* parent = root->children()[0]; |
| 4129 LayerImpl* child = parent->children()[0]; |
| 4130 |
| 4131 switch (impl->active_tree()->source_frame_number()) { |
| 4132 case 1: |
| 4133 EXPECT_EQ(gfx::Size(5, 5).ToString(), child->bounds().ToString()); |
| 4134 break; |
| 4135 } |
| 4136 } |
| 4137 |
| 4138 virtual void AfterTest() OVERRIDE {} |
| 4139 |
| 4140 scoped_refptr<Layer> root_layer_; |
| 4141 scoped_refptr<SolidColorLayer> parent_layer_; |
| 4142 scoped_refptr<SolidColorLayer> child_layer_; |
| 4143 }; |
| 4144 |
| 4145 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPushHiddenLayer); |
| 4146 |
| 4147 class LayerTreeHostTestUpdateLayerInEmptyViewport : public LayerTreeHostTest { |
| 4148 protected: |
| 4149 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
| 4150 settings->impl_side_painting = true; |
| 4151 } |
| 4152 |
| 4153 virtual void SetupTree() OVERRIDE { |
| 4154 root_layer_ = FakePictureLayer::Create(&client_); |
| 4155 root_layer_->SetAnchorPoint(gfx::PointF()); |
| 4156 root_layer_->SetBounds(gfx::Size(10, 10)); |
| 4157 |
| 4158 layer_tree_host()->SetRootLayer(root_layer_); |
| 4159 LayerTreeHostTest::SetupTree(); |
| 4160 } |
| 4161 |
| 4162 virtual void BeginTest() OVERRIDE { |
| 4163 // The viewport is empty, but we still need to update layers on the main |
| 4164 // thread. |
| 4165 layer_tree_host()->SetViewportSize(gfx::Size(0, 0)); |
| 4166 PostSetNeedsCommitToMainThread(); |
| 4167 } |
| 4168 |
| 4169 virtual void DidCommit() OVERRIDE { |
| 4170 // The layer should be updated even though the viewport is empty, so we |
| 4171 // are capable of drawing it on the impl tree. |
| 4172 EXPECT_GT(root_layer_->update_count(), 0u); |
| 4173 EndTest(); |
| 4174 } |
| 4175 |
| 4176 virtual void AfterTest() OVERRIDE {} |
| 4177 |
| 4178 FakeContentLayerClient client_; |
| 4179 scoped_refptr<FakePictureLayer> root_layer_; |
| 4180 }; |
| 4181 |
| 4182 MULTI_THREAD_TEST_F(LayerTreeHostTestUpdateLayerInEmptyViewport); |
| 4183 |
4077 } // namespace | 4184 } // namespace |
4078 } // namespace cc | 4185 } // namespace cc |
OLD | NEW |