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