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