| 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/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 | 421 |
| 422 SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F(LayerTreeHostDamageTestForcedFullDamage); | 422 SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F(LayerTreeHostDamageTestForcedFullDamage); |
| 423 | 423 |
| 424 class LayerTreeHostScrollbarDamageTest : public LayerTreeHostDamageTest { | 424 class LayerTreeHostScrollbarDamageTest : public LayerTreeHostDamageTest { |
| 425 virtual void SetupTree() OVERRIDE { | 425 virtual void SetupTree() OVERRIDE { |
| 426 scoped_refptr<Layer> root_layer = Layer::Create(); | 426 scoped_refptr<Layer> root_layer = Layer::Create(); |
| 427 root_layer->SetBounds(gfx::Size(400, 400)); | 427 root_layer->SetBounds(gfx::Size(400, 400)); |
| 428 root_layer->SetMasksToBounds(true); | 428 root_layer->SetMasksToBounds(true); |
| 429 layer_tree_host()->SetRootLayer(root_layer); | 429 layer_tree_host()->SetRootLayer(root_layer); |
| 430 | 430 |
| 431 scoped_refptr<Layer> scroll_clip_layer = Layer::Create(); | |
| 432 scoped_refptr<Layer> content_layer = FakeContentLayer::Create(&client_); | 431 scoped_refptr<Layer> content_layer = FakeContentLayer::Create(&client_); |
| 433 content_layer->SetScrollClipLayer(scroll_clip_layer.get()); | 432 content_layer->SetScrollable(true); |
| 434 content_layer->SetScrollOffset(gfx::Vector2d(10, 20)); | 433 content_layer->SetScrollOffset(gfx::Vector2d(10, 20)); |
| 434 content_layer->SetMaxScrollOffset(gfx::Vector2d(30, 50)); |
| 435 content_layer->SetBounds(gfx::Size(100, 200)); | 435 content_layer->SetBounds(gfx::Size(100, 200)); |
| 436 scroll_clip_layer->SetBounds( | 436 root_layer->AddChild(content_layer); |
| 437 gfx::Size(content_layer->bounds().width() - 30, | |
| 438 content_layer->bounds().height() - 50)); | |
| 439 scroll_clip_layer->AddChild(content_layer); | |
| 440 root_layer->AddChild(scroll_clip_layer); | |
| 441 | 437 |
| 442 scoped_refptr<Layer> scrollbar_layer = | 438 scoped_refptr<Layer> scrollbar_layer = |
| 443 FakePaintedScrollbarLayer::Create(false, true, content_layer.get()); | 439 FakePaintedScrollbarLayer::Create(false, true, content_layer->id()); |
| 444 scrollbar_layer->SetPosition(gfx::Point(300, 300)); | 440 scrollbar_layer->SetPosition(gfx::Point(300, 300)); |
| 445 scrollbar_layer->SetBounds(gfx::Size(10, 100)); | 441 scrollbar_layer->SetBounds(gfx::Size(10, 100)); |
| 446 scrollbar_layer->ToScrollbarLayer()->SetClipLayer(scroll_clip_layer); | |
| 447 scrollbar_layer->ToScrollbarLayer()->SetScrollLayer(content_layer); | |
| 448 root_layer->AddChild(scrollbar_layer); | 442 root_layer->AddChild(scrollbar_layer); |
| 449 | 443 |
| 450 gfx::RectF content_rect(content_layer->position(), | 444 gfx::RectF content_rect(content_layer->position(), |
| 451 content_layer->bounds()); | 445 content_layer->bounds()); |
| 452 gfx::RectF scrollbar_rect(scrollbar_layer->position(), | 446 gfx::RectF scrollbar_rect(scrollbar_layer->position(), |
| 453 scrollbar_layer->bounds()); | 447 scrollbar_layer->bounds()); |
| 454 EXPECT_FALSE(content_rect.Intersects(scrollbar_rect)); | 448 EXPECT_FALSE(content_rect.Intersects(scrollbar_rect)); |
| 455 | 449 |
| 456 LayerTreeHostDamageTest::SetupTree(); | 450 LayerTreeHostDamageTest::SetupTree(); |
| 457 } | 451 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 break; | 489 break; |
| 496 } | 490 } |
| 497 return result; | 491 return result; |
| 498 } | 492 } |
| 499 | 493 |
| 500 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, | 494 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, |
| 501 bool result) OVERRIDE { | 495 bool result) OVERRIDE { |
| 502 ++did_swaps_; | 496 ++did_swaps_; |
| 503 EXPECT_TRUE(result); | 497 EXPECT_TRUE(result); |
| 504 LayerImpl* root = host_impl->active_tree()->root_layer(); | 498 LayerImpl* root = host_impl->active_tree()->root_layer(); |
| 505 LayerImpl* scroll_clip_layer = root->children()[0]; | 499 LayerImpl* scroll_layer = root->children()[0]; |
| 506 LayerImpl* scroll_layer = scroll_clip_layer->children()[0]; | |
| 507 switch (did_swaps_) { | 500 switch (did_swaps_) { |
| 508 case 1: | 501 case 1: |
| 509 // Test that modifying the position of the content layer (not | 502 // Test that modifying the position of the content layer (not |
| 510 // scrolling) won't damage the scrollbar. | 503 // scrolling) won't damage the scrollbar. |
| 511 scroll_layer->SetPosition(gfx::Point(1, 1)); | 504 scroll_layer->SetPosition(gfx::Point(1, 1)); |
| 512 scroll_layer->SetScrollOffset(scroll_layer->scroll_offset()); | 505 scroll_layer->SetScrollOffset(scroll_layer->scroll_offset()); |
| 513 host_impl->SetNeedsRedraw(); | 506 host_impl->SetNeedsRedraw(); |
| 514 break; | 507 break; |
| 515 case 2: | 508 case 2: |
| 516 scroll_layer->ScrollBy(gfx::Vector2dF(10.f, 10.f)); | 509 scroll_layer->ScrollBy(gfx::Vector2dF(10.f, 10.f)); |
| 517 host_impl->SetNeedsRedraw(); | 510 host_impl->SetNeedsRedraw(); |
| 518 break; | 511 break; |
| 519 case 3: | 512 case 3: |
| 520 scroll_layer->SetBounds(gfx::Size(root->bounds().width() + 60, | 513 scroll_layer->SetMaxScrollOffset(gfx::Vector2d(60, 100)); |
| 521 root->bounds().height() + 100)); | |
| 522 host_impl->SetNeedsRedraw(); | 514 host_impl->SetNeedsRedraw(); |
| 523 break; | 515 break; |
| 524 } | 516 } |
| 525 } | 517 } |
| 526 | 518 |
| 527 virtual void AfterTest() OVERRIDE { | 519 virtual void AfterTest() OVERRIDE { |
| 528 EXPECT_EQ(4, did_swaps_); | 520 EXPECT_EQ(4, did_swaps_); |
| 529 } | 521 } |
| 530 | 522 |
| 531 int did_swaps_; | 523 int did_swaps_; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 break; | 562 break; |
| 571 } | 563 } |
| 572 return result; | 564 return result; |
| 573 } | 565 } |
| 574 | 566 |
| 575 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, | 567 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, |
| 576 bool result) OVERRIDE { | 568 bool result) OVERRIDE { |
| 577 ++did_swaps_; | 569 ++did_swaps_; |
| 578 EXPECT_TRUE(result); | 570 EXPECT_TRUE(result); |
| 579 LayerImpl* root = host_impl->active_tree()->root_layer(); | 571 LayerImpl* root = host_impl->active_tree()->root_layer(); |
| 580 LayerImpl* scroll_clip_layer = root->children()[0]; | 572 LayerImpl* scroll_layer = root->children()[0]; |
| 581 LayerImpl* scroll_layer = scroll_clip_layer->children()[0]; | |
| 582 switch (did_swaps_) { | 573 switch (did_swaps_) { |
| 583 case 1: | 574 case 1: |
| 584 // Scroll on the thread. This should damage the scrollbar for the | 575 // Scroll on the thread. This should damage the scrollbar for the |
| 585 // next draw on the thread. | 576 // next draw on the thread. |
| 586 scroll_layer->ScrollBy(gfx::Vector2dF(10.f, 10.f)); | 577 scroll_layer->ScrollBy(gfx::Vector2dF(10.f, 10.f)); |
| 587 host_impl->SetNeedsRedraw(); | 578 host_impl->SetNeedsRedraw(); |
| 588 break; | 579 break; |
| 589 case 2: | 580 case 2: |
| 590 // Forcibly send the scroll to the main thread. | 581 // Forcibly send the scroll to the main thread. |
| 591 PostSetNeedsCommitToMainThread(); | 582 PostSetNeedsCommitToMainThread(); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 FakeContentLayerClient client_; | 692 FakeContentLayerClient client_; |
| 702 int swap_count_; | 693 int swap_count_; |
| 703 int prepare_to_draw_count_; | 694 int prepare_to_draw_count_; |
| 704 int update_visible_tile_count_; | 695 int update_visible_tile_count_; |
| 705 }; | 696 }; |
| 706 | 697 |
| 707 MULTI_THREAD_TEST_F(LayerTreeHostDamageTestVisibleTilesStillTriggerDraws); | 698 MULTI_THREAD_TEST_F(LayerTreeHostDamageTestVisibleTilesStillTriggerDraws); |
| 708 | 699 |
| 709 } // namespace | 700 } // namespace |
| 710 } // namespace cc | 701 } // namespace cc |
| OLD | NEW |