| 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 #include "cc/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 class LayerTreeHostDamageTestSetNeedsRedraw | 26 class LayerTreeHostDamageTestSetNeedsRedraw |
| 27 : public LayerTreeHostDamageTest { | 27 : public LayerTreeHostDamageTest { |
| 28 void SetupTree() override { | 28 void SetupTree() override { |
| 29 // Viewport is 10x10. | 29 // Viewport is 10x10. |
| 30 scoped_refptr<FakePictureLayer> root = | 30 scoped_refptr<FakePictureLayer> root = |
| 31 FakePictureLayer::Create(layer_settings(), &client_); | 31 FakePictureLayer::Create(layer_settings(), &client_); |
| 32 root->SetBounds(gfx::Size(10, 10)); | 32 root->SetBounds(gfx::Size(10, 10)); |
| 33 | 33 |
| 34 layer_tree_host()->SetRootLayer(root); | 34 layer_tree_host()->SetRootLayer(root); |
| 35 LayerTreeHostDamageTest::SetupTree(); | 35 LayerTreeHostDamageTest::SetupTree(); |
| 36 client_.set_bounds(root->bounds()); |
| 36 } | 37 } |
| 37 | 38 |
| 38 void BeginTest() override { | 39 void BeginTest() override { |
| 39 draw_count_ = 0; | 40 draw_count_ = 0; |
| 40 PostSetNeedsCommitToMainThread(); | 41 PostSetNeedsCommitToMainThread(); |
| 41 } | 42 } |
| 42 | 43 |
| 43 void DidCommitAndDrawFrame() override { | 44 void DidCommitAndDrawFrame() override { |
| 44 switch (layer_tree_host()->source_frame_number()) { | 45 switch (layer_tree_host()->source_frame_number()) { |
| 45 case 1: | 46 case 1: |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 class LayerTreeHostDamageTestSetViewportSize | 89 class LayerTreeHostDamageTestSetViewportSize |
| 89 : public LayerTreeHostDamageTest { | 90 : public LayerTreeHostDamageTest { |
| 90 void SetupTree() override { | 91 void SetupTree() override { |
| 91 // Viewport is 10x10. | 92 // Viewport is 10x10. |
| 92 scoped_refptr<FakePictureLayer> root = | 93 scoped_refptr<FakePictureLayer> root = |
| 93 FakePictureLayer::Create(layer_settings(), &client_); | 94 FakePictureLayer::Create(layer_settings(), &client_); |
| 94 root->SetBounds(gfx::Size(10, 10)); | 95 root->SetBounds(gfx::Size(10, 10)); |
| 95 | 96 |
| 96 layer_tree_host()->SetRootLayer(root); | 97 layer_tree_host()->SetRootLayer(root); |
| 97 LayerTreeHostDamageTest::SetupTree(); | 98 LayerTreeHostDamageTest::SetupTree(); |
| 99 client_.set_bounds(root->bounds()); |
| 98 } | 100 } |
| 99 | 101 |
| 100 void BeginTest() override { | 102 void BeginTest() override { |
| 101 draw_count_ = 0; | 103 draw_count_ = 0; |
| 102 PostSetNeedsCommitToMainThread(); | 104 PostSetNeedsCommitToMainThread(); |
| 103 } | 105 } |
| 104 | 106 |
| 105 void DidCommitAndDrawFrame() override { | 107 void DidCommitAndDrawFrame() override { |
| 106 switch (layer_tree_host()->source_frame_number()) { | 108 switch (layer_tree_host()->source_frame_number()) { |
| 107 case 1: | 109 case 1: |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 FakePictureLayer::Create(layer_settings(), &client_); | 162 FakePictureLayer::Create(layer_settings(), &client_); |
| 161 root->SetBounds(gfx::Size(10, 10)); | 163 root->SetBounds(gfx::Size(10, 10)); |
| 162 | 164 |
| 163 // Most of the layer isn't visible. | 165 // Most of the layer isn't visible. |
| 164 content_ = FakePictureLayer::Create(layer_settings(), &client_); | 166 content_ = FakePictureLayer::Create(layer_settings(), &client_); |
| 165 content_->SetBounds(gfx::Size(2000, 100)); | 167 content_->SetBounds(gfx::Size(2000, 100)); |
| 166 root->AddChild(content_); | 168 root->AddChild(content_); |
| 167 | 169 |
| 168 layer_tree_host()->SetRootLayer(root); | 170 layer_tree_host()->SetRootLayer(root); |
| 169 LayerTreeHostDamageTest::SetupTree(); | 171 LayerTreeHostDamageTest::SetupTree(); |
| 172 client_.set_bounds(root->bounds()); |
| 170 } | 173 } |
| 171 | 174 |
| 172 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | 175 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
| 173 LayerTreeHostImpl::FrameData* frame_data, | 176 LayerTreeHostImpl::FrameData* frame_data, |
| 174 DrawResult draw_result) override { | 177 DrawResult draw_result) override { |
| 175 EXPECT_EQ(DRAW_SUCCESS, draw_result); | 178 EXPECT_EQ(DRAW_SUCCESS, draw_result); |
| 176 | 179 |
| 177 int source_frame = host_impl->active_tree()->source_frame_number(); | 180 int source_frame = host_impl->active_tree()->source_frame_number(); |
| 178 switch (source_frame) { | 181 switch (source_frame) { |
| 179 case 0: | 182 case 0: |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 root_ = FakePictureLayer::Create(layer_settings(), &client_); | 247 root_ = FakePictureLayer::Create(layer_settings(), &client_); |
| 245 child_ = FakePictureLayer::Create(layer_settings(), &client_); | 248 child_ = FakePictureLayer::Create(layer_settings(), &client_); |
| 246 | 249 |
| 247 root_->SetBounds(gfx::Size(500, 500)); | 250 root_->SetBounds(gfx::Size(500, 500)); |
| 248 child_->SetPosition(gfx::PointF(100.f, 100.f)); | 251 child_->SetPosition(gfx::PointF(100.f, 100.f)); |
| 249 child_->SetBounds(gfx::Size(30, 30)); | 252 child_->SetBounds(gfx::Size(30, 30)); |
| 250 | 253 |
| 251 root_->AddChild(child_); | 254 root_->AddChild(child_); |
| 252 layer_tree_host()->SetRootLayer(root_); | 255 layer_tree_host()->SetRootLayer(root_); |
| 253 LayerTreeHostDamageTest::SetupTree(); | 256 LayerTreeHostDamageTest::SetupTree(); |
| 257 client_.set_bounds(root_->bounds()); |
| 254 } | 258 } |
| 255 | 259 |
| 256 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, | 260 DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
| 257 LayerTreeHostImpl::FrameData* frame_data, | 261 LayerTreeHostImpl::FrameData* frame_data, |
| 258 DrawResult draw_result) override { | 262 DrawResult draw_result) override { |
| 259 EXPECT_EQ(DRAW_SUCCESS, draw_result); | 263 EXPECT_EQ(DRAW_SUCCESS, draw_result); |
| 260 | 264 |
| 261 RenderSurfaceImpl* root_surface = | 265 RenderSurfaceImpl* root_surface = |
| 262 host_impl->active_tree()->root_layer()->render_surface(); | 266 host_impl->active_tree()->root_layer()->render_surface(); |
| 263 gfx::Rect root_damage = | 267 gfx::Rect root_damage = |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 scrollbar_layer->ToScrollbarLayer()->SetScrollLayer(content_layer->id()); | 360 scrollbar_layer->ToScrollbarLayer()->SetScrollLayer(content_layer->id()); |
| 357 root_layer->AddChild(scrollbar_layer); | 361 root_layer->AddChild(scrollbar_layer); |
| 358 | 362 |
| 359 gfx::RectF content_rect(content_layer->position(), | 363 gfx::RectF content_rect(content_layer->position(), |
| 360 gfx::SizeF(content_layer->bounds())); | 364 gfx::SizeF(content_layer->bounds())); |
| 361 gfx::RectF scrollbar_rect(scrollbar_layer->position(), | 365 gfx::RectF scrollbar_rect(scrollbar_layer->position(), |
| 362 gfx::SizeF(scrollbar_layer->bounds())); | 366 gfx::SizeF(scrollbar_layer->bounds())); |
| 363 EXPECT_FALSE(content_rect.Intersects(scrollbar_rect)); | 367 EXPECT_FALSE(content_rect.Intersects(scrollbar_rect)); |
| 364 | 368 |
| 365 LayerTreeHostDamageTest::SetupTree(); | 369 LayerTreeHostDamageTest::SetupTree(); |
| 370 client_.set_bounds(root_layer->bounds()); |
| 366 } | 371 } |
| 367 | 372 |
| 368 private: | 373 private: |
| 369 FakeContentLayerClient client_; | 374 FakeContentLayerClient client_; |
| 370 }; | 375 }; |
| 371 | 376 |
| 372 class LayerTreeHostDamageTestScrollbarDoesDamage | 377 class LayerTreeHostDamageTestScrollbarDoesDamage |
| 373 : public LayerTreeHostScrollbarDamageTest { | 378 : public LayerTreeHostScrollbarDamageTest { |
| 374 void BeginTest() override { | 379 void BeginTest() override { |
| 375 did_swaps_ = 0; | 380 did_swaps_ = 0; |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 | 533 |
| 529 void AfterTest() override { EXPECT_EQ(3, did_swaps_); } | 534 void AfterTest() override { EXPECT_EQ(3, did_swaps_); } |
| 530 | 535 |
| 531 int did_swaps_; | 536 int did_swaps_; |
| 532 }; | 537 }; |
| 533 | 538 |
| 534 MULTI_THREAD_TEST_F(LayerTreeHostDamageTestScrollbarCommitDoesNoDamage); | 539 MULTI_THREAD_TEST_F(LayerTreeHostDamageTestScrollbarCommitDoesNoDamage); |
| 535 | 540 |
| 536 } // namespace | 541 } // namespace |
| 537 } // namespace cc | 542 } // namespace cc |
| OLD | NEW |