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" |
(...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1011 | 1011 |
1012 Layer* root_layer = layer_tree_host()->root_layer(); | 1012 Layer* root_layer = layer_tree_host()->root_layer(); |
1013 scroll_layer_->SetScrollClipLayerId(root_layer->id()); | 1013 scroll_layer_->SetScrollClipLayerId(root_layer->id()); |
1014 scroll_layer_->SetIsContainerForFixedPositionLayers(true); | 1014 scroll_layer_->SetIsContainerForFixedPositionLayers(true); |
1015 scroll_layer_->SetBounds(gfx::Size(2 * root_layer->bounds().width(), | 1015 scroll_layer_->SetBounds(gfx::Size(2 * root_layer->bounds().width(), |
1016 2 * root_layer->bounds().height())); | 1016 2 * root_layer->bounds().height())); |
1017 scroll_layer_->SetScrollOffset(gfx::ScrollOffset()); | 1017 scroll_layer_->SetScrollOffset(gfx::ScrollOffset()); |
1018 layer_tree_host()->root_layer()->AddChild(scroll_layer_); | 1018 layer_tree_host()->root_layer()->AddChild(scroll_layer_); |
1019 // This test requires the page_scale and inner viewport layers to be | 1019 // This test requires the page_scale and inner viewport layers to be |
1020 // identified. | 1020 // identified. |
1021 layer_tree_host()->RegisterViewportLayers( | 1021 layer_tree_host()->RegisterViewportLayers(NULL, root_layer, |
1022 root_layer, scroll_layer_.get(), NULL); | 1022 scroll_layer_.get(), NULL); |
1023 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.5f, 2.f); | 1023 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.5f, 2.f); |
1024 } | 1024 } |
1025 | 1025 |
1026 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 1026 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
1027 | 1027 |
1028 void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, | 1028 void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, |
1029 float scale, | 1029 float scale, |
1030 float) override { | 1030 float) override { |
1031 gfx::ScrollOffset offset = scroll_layer_->scroll_offset(); | 1031 gfx::ScrollOffset offset = scroll_layer_->scroll_offset(); |
1032 scroll_layer_->SetScrollOffset(ScrollOffsetWithDelta(offset, | 1032 scroll_layer_->SetScrollOffset(ScrollOffsetWithDelta(offset, |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1301 scoped_refptr<FakePictureLayer> child_layer_; | 1301 scoped_refptr<FakePictureLayer> child_layer_; |
1302 }; | 1302 }; |
1303 | 1303 |
1304 MULTI_THREAD_TEST_F(LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers); | 1304 MULTI_THREAD_TEST_F(LayerTreeHostTestDeviceScaleFactorScalesViewportAndLayers); |
1305 | 1305 |
1306 // TODO(sohanjg) : Remove it once impl-side painting ships everywhere. | 1306 // TODO(sohanjg) : Remove it once impl-side painting ships everywhere. |
1307 // Verify atomicity of commits and reuse of textures. | 1307 // Verify atomicity of commits and reuse of textures. |
1308 class LayerTreeHostTestDirectRendererAtomicCommit : public LayerTreeHostTest { | 1308 class LayerTreeHostTestDirectRendererAtomicCommit : public LayerTreeHostTest { |
1309 public: | 1309 public: |
1310 void InitializeSettings(LayerTreeSettings* settings) override { | 1310 void InitializeSettings(LayerTreeSettings* settings) override { |
1311 settings->texture_id_allocation_chunk_size = 1; | 1311 settings->renderer_settings.texture_id_allocation_chunk_size = 1; |
1312 // Make sure partial texture updates are turned off. | 1312 // Make sure partial texture updates are turned off. |
1313 settings->max_partial_texture_updates = 0; | 1313 settings->max_partial_texture_updates = 0; |
1314 // Linear fade animator prevents scrollbars from drawing immediately. | 1314 // Linear fade animator prevents scrollbars from drawing immediately. |
1315 settings->scrollbar_animator = LayerTreeSettings::NoAnimator; | 1315 settings->scrollbar_animator = LayerTreeSettings::NoAnimator; |
1316 } | 1316 } |
1317 | 1317 |
1318 void SetupTree() override { | 1318 void SetupTree() override { |
1319 layer_ = FakeContentLayer::Create(&client_); | 1319 layer_ = FakeContentLayer::Create(&client_); |
1320 layer_->SetBounds(gfx::Size(10, 20)); | 1320 layer_->SetBounds(gfx::Size(10, 20)); |
1321 | 1321 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1478 layer->SetPosition(position); | 1478 layer->SetPosition(position); |
1479 layer->SetBounds(bounds); | 1479 layer->SetBounds(bounds); |
1480 layer->SetContentsOpaque(opaque); | 1480 layer->SetContentsOpaque(opaque); |
1481 } | 1481 } |
1482 | 1482 |
1483 // TODO(sohanjg) : Remove it once impl-side painting ships everywhere. | 1483 // TODO(sohanjg) : Remove it once impl-side painting ships everywhere. |
1484 class LayerTreeHostTestAtomicCommitWithPartialUpdate | 1484 class LayerTreeHostTestAtomicCommitWithPartialUpdate |
1485 : public LayerTreeHostTest { | 1485 : public LayerTreeHostTest { |
1486 public: | 1486 public: |
1487 void InitializeSettings(LayerTreeSettings* settings) override { | 1487 void InitializeSettings(LayerTreeSettings* settings) override { |
1488 settings->texture_id_allocation_chunk_size = 1; | 1488 settings->renderer_settings.texture_id_allocation_chunk_size = 1; |
1489 // Allow one partial texture update. | 1489 // Allow one partial texture update. |
1490 settings->max_partial_texture_updates = 1; | 1490 settings->max_partial_texture_updates = 1; |
1491 // No partial updates when impl side painting is enabled. | 1491 // No partial updates when impl side painting is enabled. |
1492 settings->impl_side_painting = false; | 1492 settings->impl_side_painting = false; |
1493 } | 1493 } |
1494 | 1494 |
1495 void SetupTree() override { | 1495 void SetupTree() override { |
1496 parent_ = FakeContentLayer::Create(&client_); | 1496 parent_ = FakeContentLayer::Create(&client_); |
1497 parent_->SetBounds(gfx::Size(10, 20)); | 1497 parent_->SetBounds(gfx::Size(10, 20)); |
1498 | 1498 |
(...skipping 1474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2973 }; | 2973 }; |
2974 | 2974 |
2975 MULTI_THREAD_TEST_F(LayerTreeHostTestDeferredInitializeWithGpuRasterization); | 2975 MULTI_THREAD_TEST_F(LayerTreeHostTestDeferredInitializeWithGpuRasterization); |
2976 | 2976 |
2977 // Test for UI Resource management. | 2977 // Test for UI Resource management. |
2978 class LayerTreeHostTestUIResource : public LayerTreeHostTest { | 2978 class LayerTreeHostTestUIResource : public LayerTreeHostTest { |
2979 public: | 2979 public: |
2980 LayerTreeHostTestUIResource() : num_ui_resources_(0) {} | 2980 LayerTreeHostTestUIResource() : num_ui_resources_(0) {} |
2981 | 2981 |
2982 void InitializeSettings(LayerTreeSettings* settings) override { | 2982 void InitializeSettings(LayerTreeSettings* settings) override { |
2983 settings->texture_id_allocation_chunk_size = 1; | 2983 settings->renderer_settings.texture_id_allocation_chunk_size = 1; |
2984 } | 2984 } |
2985 | 2985 |
2986 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 2986 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
2987 | 2987 |
2988 void DidCommit() override { | 2988 void DidCommit() override { |
2989 int frame = layer_tree_host()->source_frame_number(); | 2989 int frame = layer_tree_host()->source_frame_number(); |
2990 switch (frame) { | 2990 switch (frame) { |
2991 case 1: | 2991 case 1: |
2992 CreateResource(); | 2992 CreateResource(); |
2993 CreateResource(); | 2993 CreateResource(); |
(...skipping 2139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5133 } | 5133 } |
5134 | 5134 |
5135 void BeginTest() override { | 5135 void BeginTest() override { |
5136 MainThreadTaskRunner()->PostTask( | 5136 MainThreadTaskRunner()->PostTask( |
5137 FROM_HERE, | 5137 FROM_HERE, |
5138 base::Bind( | 5138 base::Bind( |
5139 &LayerTreeHostTestContinuousPainting::EnableContinuousPainting, | 5139 &LayerTreeHostTestContinuousPainting::EnableContinuousPainting, |
5140 base::Unretained(this))); | 5140 base::Unretained(this))); |
5141 // Wait 50x longer than expected. | 5141 // Wait 50x longer than expected. |
5142 double milliseconds_per_frame = | 5142 double milliseconds_per_frame = |
5143 1000.0 / layer_tree_host()->settings().refresh_rate; | 5143 1000.0 / layer_tree_host()->settings().renderer_settings.refresh_rate; |
5144 MainThreadTaskRunner()->PostDelayedTask( | 5144 MainThreadTaskRunner()->PostDelayedTask( |
5145 FROM_HERE, | 5145 FROM_HERE, |
5146 base::Bind( | 5146 base::Bind( |
5147 &LayerTreeHostTestContinuousPainting::DisableContinuousPainting, | 5147 &LayerTreeHostTestContinuousPainting::DisableContinuousPainting, |
5148 base::Unretained(this)), | 5148 base::Unretained(this)), |
5149 base::TimeDelta::FromMilliseconds(50 * kExpectedNumCommits * | 5149 base::TimeDelta::FromMilliseconds(50 * kExpectedNumCommits * |
5150 milliseconds_per_frame)); | 5150 milliseconds_per_frame)); |
5151 } | 5151 } |
5152 | 5152 |
5153 void BeginMainFrame(const BeginFrameArgs& args) override { | 5153 void BeginMainFrame(const BeginFrameArgs& args) override { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5190 int num_draws_; | 5190 int num_draws_; |
5191 const gfx::Size bounds_; | 5191 const gfx::Size bounds_; |
5192 FakeContentLayerClient client_; | 5192 FakeContentLayerClient client_; |
5193 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; | 5193 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; |
5194 scoped_refptr<FakePictureLayer> picture_layer_; | 5194 scoped_refptr<FakePictureLayer> picture_layer_; |
5195 Layer* child_layer_; | 5195 Layer* child_layer_; |
5196 }; | 5196 }; |
5197 | 5197 |
5198 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); | 5198 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); |
5199 | 5199 |
| 5200 class LayerTreeHostTestSendBeginFramesToChildren : public LayerTreeHostTest { |
| 5201 public: |
| 5202 LayerTreeHostTestSendBeginFramesToChildren() |
| 5203 : begin_frame_sent_to_children_(false) { |
| 5204 } |
| 5205 |
| 5206 void InitializeSettings(LayerTreeSettings* settings) override { |
| 5207 settings->forward_begin_frames_to_children = true; |
| 5208 } |
| 5209 |
| 5210 void BeginTest() override { |
| 5211 // Kick off the test with a commit. |
| 5212 PostSetNeedsCommitToMainThread(); |
| 5213 } |
| 5214 |
| 5215 void SendBeginFramesToChildren(const BeginFrameArgs& args) override { |
| 5216 begin_frame_sent_to_children_ = true; |
| 5217 EndTest(); |
| 5218 } |
| 5219 |
| 5220 void DidBeginMainFrame() override { |
| 5221 // Children requested BeginFrames. |
| 5222 layer_tree_host()->SetChildrenNeedBeginFrames(true); |
| 5223 } |
| 5224 |
| 5225 void AfterTest() override { |
| 5226 // Ensure that BeginFrame message is sent to children during parent |
| 5227 // scheduler handles its BeginFrame. |
| 5228 EXPECT_TRUE(begin_frame_sent_to_children_); |
| 5229 } |
| 5230 |
| 5231 private: |
| 5232 bool begin_frame_sent_to_children_; |
| 5233 }; |
| 5234 |
| 5235 SINGLE_THREAD_TEST_F(LayerTreeHostTestSendBeginFramesToChildren); |
| 5236 |
| 5237 class LayerTreeHostTestSendBeginFramesToChildrenWithExternalBFS |
| 5238 : public LayerTreeHostTest { |
| 5239 public: |
| 5240 LayerTreeHostTestSendBeginFramesToChildrenWithExternalBFS() |
| 5241 : begin_frame_sent_to_children_(false) { |
| 5242 } |
| 5243 |
| 5244 void InitializeSettings(LayerTreeSettings* settings) override { |
| 5245 settings->use_external_begin_frame_source = true; |
| 5246 settings->forward_begin_frames_to_children = true; |
| 5247 } |
| 5248 |
| 5249 void BeginTest() override { |
| 5250 // Kick off the test with a commit. |
| 5251 PostSetNeedsCommitToMainThread(); |
| 5252 } |
| 5253 |
| 5254 void SendBeginFramesToChildren(const BeginFrameArgs& args) override { |
| 5255 begin_frame_sent_to_children_ = true; |
| 5256 EndTest(); |
| 5257 } |
| 5258 |
| 5259 void DidBeginMainFrame() override { |
| 5260 // Children requested BeginFrames. |
| 5261 layer_tree_host()->SetChildrenNeedBeginFrames(true); |
| 5262 } |
| 5263 |
| 5264 void AfterTest() override { |
| 5265 // Ensure that BeginFrame message is sent to children during parent |
| 5266 // scheduler handles its BeginFrame. |
| 5267 EXPECT_TRUE(begin_frame_sent_to_children_); |
| 5268 } |
| 5269 |
| 5270 private: |
| 5271 bool begin_frame_sent_to_children_; |
| 5272 }; |
| 5273 |
| 5274 SINGLE_THREAD_TEST_F(LayerTreeHostTestSendBeginFramesToChildrenWithExternalBFS); |
| 5275 |
5200 class LayerTreeHostTestActivateOnInvisible : public LayerTreeHostTest { | 5276 class LayerTreeHostTestActivateOnInvisible : public LayerTreeHostTest { |
5201 public: | 5277 public: |
5202 LayerTreeHostTestActivateOnInvisible() | 5278 LayerTreeHostTestActivateOnInvisible() |
5203 : activation_count_(0), visible_(true) {} | 5279 : activation_count_(0), visible_(true) {} |
5204 | 5280 |
5205 void InitializeSettings(LayerTreeSettings* settings) override { | 5281 void InitializeSettings(LayerTreeSettings* settings) override { |
5206 settings->impl_side_painting = true; | 5282 settings->impl_side_painting = true; |
5207 } | 5283 } |
5208 | 5284 |
5209 void BeginTest() override { | 5285 void BeginTest() override { |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5405 pile->SetPlaybackAllowedEvent(&playback_allowed_event_); | 5481 pile->SetPlaybackAllowedEvent(&playback_allowed_event_); |
5406 scoped_refptr<FakePictureLayer> layer = | 5482 scoped_refptr<FakePictureLayer> layer = |
5407 FakePictureLayer::CreateWithRecordingSource(&client_, pile.Pass()); | 5483 FakePictureLayer::CreateWithRecordingSource(&client_, pile.Pass()); |
5408 layer->SetBounds(gfx::Size(500, 500)); | 5484 layer->SetBounds(gfx::Size(500, 500)); |
5409 layer->SetContentsOpaque(true); | 5485 layer->SetContentsOpaque(true); |
5410 // Avoid LCD text on the layer so we don't cause extra commits when we | 5486 // Avoid LCD text on the layer so we don't cause extra commits when we |
5411 // pinch. | 5487 // pinch. |
5412 layer->disable_lcd_text(); | 5488 layer->disable_lcd_text(); |
5413 pinch->AddChild(layer); | 5489 pinch->AddChild(layer); |
5414 | 5490 |
5415 layer_tree_host()->RegisterViewportLayers(root, pinch, pinch); | 5491 layer_tree_host()->RegisterViewportLayers(NULL, root, pinch, pinch); |
5416 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 1.f, 4.f); | 5492 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 1.f, 4.f); |
5417 layer_tree_host()->SetRootLayer(root); | 5493 layer_tree_host()->SetRootLayer(root); |
5418 LayerTreeHostTest::SetupTree(); | 5494 LayerTreeHostTest::SetupTree(); |
5419 } | 5495 } |
5420 | 5496 |
5421 // Returns the delta scale of all quads in the frame's root pass from their | 5497 // Returns the delta scale of all quads in the frame's root pass from their |
5422 // ideal, or 0 if they are not all the same. | 5498 // ideal, or 0 if they are not all the same. |
5423 float FrameQuadScaleDeltaFromIdeal(LayerTreeHostImpl::FrameData* frame_data) { | 5499 float FrameQuadScaleDeltaFromIdeal(LayerTreeHostImpl::FrameData* frame_data) { |
5424 if (frame_data->has_no_damage) | 5500 if (frame_data->has_no_damage) |
5425 return 0.f; | 5501 return 0.f; |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5615 pile->SetPlaybackAllowedEvent(&playback_allowed_event_); | 5691 pile->SetPlaybackAllowedEvent(&playback_allowed_event_); |
5616 scoped_refptr<FakePictureLayer> layer = | 5692 scoped_refptr<FakePictureLayer> layer = |
5617 FakePictureLayer::CreateWithRecordingSource(&client_, pile.Pass()); | 5693 FakePictureLayer::CreateWithRecordingSource(&client_, pile.Pass()); |
5618 layer->SetBounds(gfx::Size(500, 500)); | 5694 layer->SetBounds(gfx::Size(500, 500)); |
5619 layer->SetContentsOpaque(true); | 5695 layer->SetContentsOpaque(true); |
5620 // Avoid LCD text on the layer so we don't cause extra commits when we | 5696 // Avoid LCD text on the layer so we don't cause extra commits when we |
5621 // pinch. | 5697 // pinch. |
5622 layer->disable_lcd_text(); | 5698 layer->disable_lcd_text(); |
5623 pinch->AddChild(layer); | 5699 pinch->AddChild(layer); |
5624 | 5700 |
5625 layer_tree_host()->RegisterViewportLayers(root, pinch, pinch); | 5701 layer_tree_host()->RegisterViewportLayers(NULL, root, pinch, pinch); |
5626 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 1.f, 4.f); | 5702 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 1.f, 4.f); |
5627 layer_tree_host()->SetRootLayer(root); | 5703 layer_tree_host()->SetRootLayer(root); |
5628 LayerTreeHostTest::SetupTree(); | 5704 LayerTreeHostTest::SetupTree(); |
5629 } | 5705 } |
5630 | 5706 |
5631 // Returns the delta scale of all quads in the frame's root pass from their | 5707 // Returns the delta scale of all quads in the frame's root pass from their |
5632 // ideal, or 0 if they are not all the same. | 5708 // ideal, or 0 if they are not all the same. |
5633 float FrameQuadScaleDeltaFromIdeal(LayerTreeHostImpl::FrameData* frame_data) { | 5709 float FrameQuadScaleDeltaFromIdeal(LayerTreeHostImpl::FrameData* frame_data) { |
5634 if (frame_data->has_no_damage) | 5710 if (frame_data->has_no_damage) |
5635 return 0.f; | 5711 return 0.f; |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5758 | 5834 |
5759 FakeContentLayerClient client_; | 5835 FakeContentLayerClient client_; |
5760 int step_; | 5836 int step_; |
5761 int continuous_draws_; | 5837 int continuous_draws_; |
5762 base::WaitableEvent playback_allowed_event_; | 5838 base::WaitableEvent playback_allowed_event_; |
5763 }; | 5839 }; |
5764 | 5840 |
5765 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles); | 5841 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles); |
5766 | 5842 |
5767 } // namespace cc | 5843 } // namespace cc |
OLD | NEW |