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 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 | 426 |
427 SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F(LayerTreeHostDamageTestForcedFullDamage); | 427 SINGLE_AND_MULTI_THREAD_NOIMPL_TEST_F(LayerTreeHostDamageTestForcedFullDamage); |
428 | 428 |
429 class LayerTreeHostScrollbarDamageTest : public LayerTreeHostDamageTest { | 429 class LayerTreeHostScrollbarDamageTest : public LayerTreeHostDamageTest { |
430 virtual void SetupTree() OVERRIDE { | 430 virtual void SetupTree() OVERRIDE { |
431 scoped_refptr<Layer> root_layer = Layer::Create(); | 431 scoped_refptr<Layer> root_layer = Layer::Create(); |
432 root_layer->SetBounds(gfx::Size(400, 400)); | 432 root_layer->SetBounds(gfx::Size(400, 400)); |
433 root_layer->SetMasksToBounds(true); | 433 root_layer->SetMasksToBounds(true); |
434 layer_tree_host()->SetRootLayer(root_layer); | 434 layer_tree_host()->SetRootLayer(root_layer); |
435 | 435 |
| 436 scoped_refptr<Layer> scroll_clip_layer = Layer::Create(); |
436 scoped_refptr<Layer> content_layer = FakeContentLayer::Create(&client_); | 437 scoped_refptr<Layer> content_layer = FakeContentLayer::Create(&client_); |
437 content_layer->SetScrollable(true); | 438 content_layer->SetScrollClipLayerId(scroll_clip_layer->id()); |
438 content_layer->SetScrollOffset(gfx::Vector2d(10, 20)); | 439 content_layer->SetScrollOffset(gfx::Vector2d(10, 20)); |
439 content_layer->SetMaxScrollOffset(gfx::Vector2d(30, 50)); | |
440 content_layer->SetBounds(gfx::Size(100, 200)); | 440 content_layer->SetBounds(gfx::Size(100, 200)); |
441 root_layer->AddChild(content_layer); | 441 scroll_clip_layer->SetBounds( |
| 442 gfx::Size(content_layer->bounds().width() - 30, |
| 443 content_layer->bounds().height() - 50)); |
| 444 scroll_clip_layer->AddChild(content_layer); |
| 445 root_layer->AddChild(scroll_clip_layer); |
442 | 446 |
443 scoped_refptr<Layer> scrollbar_layer = | 447 scoped_refptr<Layer> scrollbar_layer = |
444 FakePaintedScrollbarLayer::Create(false, true, content_layer->id()); | 448 FakePaintedScrollbarLayer::Create(false, true, content_layer->id()); |
445 scrollbar_layer->SetPosition(gfx::Point(300, 300)); | 449 scrollbar_layer->SetPosition(gfx::Point(300, 300)); |
446 scrollbar_layer->SetBounds(gfx::Size(10, 100)); | 450 scrollbar_layer->SetBounds(gfx::Size(10, 100)); |
| 451 scrollbar_layer->ToScrollbarLayer()->SetClipLayer(scroll_clip_layer->id()); |
| 452 scrollbar_layer->ToScrollbarLayer()->SetScrollLayer(content_layer->id()); |
447 root_layer->AddChild(scrollbar_layer); | 453 root_layer->AddChild(scrollbar_layer); |
448 | 454 |
449 gfx::RectF content_rect(content_layer->position(), | 455 gfx::RectF content_rect(content_layer->position(), |
450 content_layer->bounds()); | 456 content_layer->bounds()); |
451 gfx::RectF scrollbar_rect(scrollbar_layer->position(), | 457 gfx::RectF scrollbar_rect(scrollbar_layer->position(), |
452 scrollbar_layer->bounds()); | 458 scrollbar_layer->bounds()); |
453 EXPECT_FALSE(content_rect.Intersects(scrollbar_rect)); | 459 EXPECT_FALSE(content_rect.Intersects(scrollbar_rect)); |
454 | 460 |
455 LayerTreeHostDamageTest::SetupTree(); | 461 LayerTreeHostDamageTest::SetupTree(); |
456 } | 462 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 break; | 501 break; |
496 } | 502 } |
497 return draw_result; | 503 return draw_result; |
498 } | 504 } |
499 | 505 |
500 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, | 506 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, |
501 bool result) OVERRIDE { | 507 bool result) OVERRIDE { |
502 ++did_swaps_; | 508 ++did_swaps_; |
503 EXPECT_TRUE(result); | 509 EXPECT_TRUE(result); |
504 LayerImpl* root = host_impl->active_tree()->root_layer(); | 510 LayerImpl* root = host_impl->active_tree()->root_layer(); |
505 LayerImpl* scroll_layer = root->children()[0]; | 511 LayerImpl* scroll_clip_layer = root->children()[0]; |
| 512 LayerImpl* scroll_layer = scroll_clip_layer->children()[0]; |
506 switch (did_swaps_) { | 513 switch (did_swaps_) { |
507 case 1: | 514 case 1: |
508 // Test that modifying the position of the content layer (not | 515 // Test that modifying the position of the content layer (not |
509 // scrolling) won't damage the scrollbar. | 516 // scrolling) won't damage the scrollbar. |
510 scroll_layer->SetPosition(gfx::Point(1, 1)); | 517 scroll_layer->SetPosition(gfx::Point(1, 1)); |
511 scroll_layer->SetScrollOffset(scroll_layer->scroll_offset()); | 518 scroll_layer->SetScrollOffset(scroll_layer->scroll_offset()); |
512 host_impl->SetNeedsRedraw(); | 519 host_impl->SetNeedsRedraw(); |
513 break; | 520 break; |
514 case 2: | 521 case 2: |
515 scroll_layer->ScrollBy(gfx::Vector2dF(10.f, 10.f)); | 522 scroll_layer->ScrollBy(gfx::Vector2dF(10.f, 10.f)); |
516 host_impl->SetNeedsRedraw(); | 523 host_impl->SetNeedsRedraw(); |
517 break; | 524 break; |
518 case 3: | 525 case 3: |
519 scroll_layer->SetMaxScrollOffset(gfx::Vector2d(60, 100)); | 526 scroll_layer->SetBounds(gfx::Size(root->bounds().width() + 60, |
| 527 root->bounds().height() + 100)); |
520 host_impl->SetNeedsRedraw(); | 528 host_impl->SetNeedsRedraw(); |
521 break; | 529 break; |
522 } | 530 } |
523 } | 531 } |
524 | 532 |
525 virtual void AfterTest() OVERRIDE { | 533 virtual void AfterTest() OVERRIDE { |
526 EXPECT_EQ(4, did_swaps_); | 534 EXPECT_EQ(4, did_swaps_); |
527 } | 535 } |
528 | 536 |
529 int did_swaps_; | 537 int did_swaps_; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 break; | 577 break; |
570 } | 578 } |
571 return draw_result; | 579 return draw_result; |
572 } | 580 } |
573 | 581 |
574 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, | 582 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl, |
575 bool result) OVERRIDE { | 583 bool result) OVERRIDE { |
576 ++did_swaps_; | 584 ++did_swaps_; |
577 EXPECT_TRUE(result); | 585 EXPECT_TRUE(result); |
578 LayerImpl* root = host_impl->active_tree()->root_layer(); | 586 LayerImpl* root = host_impl->active_tree()->root_layer(); |
579 LayerImpl* scroll_layer = root->children()[0]; | 587 LayerImpl* scroll_clip_layer = root->children()[0]; |
| 588 LayerImpl* scroll_layer = scroll_clip_layer->children()[0]; |
580 switch (did_swaps_) { | 589 switch (did_swaps_) { |
581 case 1: | 590 case 1: |
582 // Scroll on the thread. This should damage the scrollbar for the | 591 // Scroll on the thread. This should damage the scrollbar for the |
583 // next draw on the thread. | 592 // next draw on the thread. |
584 scroll_layer->ScrollBy(gfx::Vector2dF(10.f, 10.f)); | 593 scroll_layer->ScrollBy(gfx::Vector2dF(10.f, 10.f)); |
585 host_impl->SetNeedsRedraw(); | 594 host_impl->SetNeedsRedraw(); |
586 break; | 595 break; |
587 case 2: | 596 case 2: |
588 // Forcibly send the scroll to the main thread. | 597 // Forcibly send the scroll to the main thread. |
589 PostSetNeedsCommitToMainThread(); | 598 PostSetNeedsCommitToMainThread(); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 FakeContentLayerClient client_; | 709 FakeContentLayerClient client_; |
701 int swap_count_; | 710 int swap_count_; |
702 int prepare_to_draw_count_; | 711 int prepare_to_draw_count_; |
703 int update_visible_tile_count_; | 712 int update_visible_tile_count_; |
704 }; | 713 }; |
705 | 714 |
706 MULTI_THREAD_TEST_F(LayerTreeHostDamageTestVisibleTilesStillTriggerDraws); | 715 MULTI_THREAD_TEST_F(LayerTreeHostDamageTestVisibleTilesStillTriggerDraws); |
707 | 716 |
708 } // namespace | 717 } // namespace |
709 } // namespace cc | 718 } // namespace cc |
OLD | NEW |