Chromium Code Reviews| 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()); | |
|
enne (OOO)
2013/08/02 22:04:55
Are the anchor point and position settings necessa
danakj
2013/08/02 22:05:58
I guess not, it just makes the layer be positioned
| |
| 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 LayerTreeHostTestUpdateLayerInEmptyViewport : public LayerTreeHostTest { | |
| 4147 protected: | |
| 4148 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | |
| 4149 settings->impl_side_painting = true; | |
| 4150 } | |
| 4151 | |
| 4152 virtual void SetupTree() OVERRIDE { | |
| 4153 root_layer_ = FakePictureLayer::Create(&client_); | |
| 4154 root_layer_->SetAnchorPoint(gfx::PointF()); | |
| 4155 root_layer_->SetPosition(gfx::Point()); | |
| 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 virtual void AfterTest() OVERRIDE {} | |
| 4176 | |
| 4177 FakeContentLayerClient client_; | |
| 4178 scoped_refptr<FakePictureLayer> root_layer_; | |
| 4179 }; | |
| 4180 | |
| 4181 MULTI_THREAD_TEST_F(LayerTreeHostTestUpdateLayerInEmptyViewport); | |
| 4182 | |
| 4076 } // namespace | 4183 } // namespace |
| 4077 } // namespace cc | 4184 } // namespace cc |
| OLD | NEW |