| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 <map> | 5 #include <map> |
| 6 | 6 |
| 7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 v1->AddChildView(v11); | 513 v1->AddChildView(v11); |
| 514 | 514 |
| 515 // |v2| is not. | 515 // |v2| is not. |
| 516 TestView* v2 = new TestView; | 516 TestView* v2 = new TestView; |
| 517 v2->SetBounds(3, 4, 6, 5); | 517 v2->SetBounds(3, 4, 6, 5); |
| 518 root_view->AddChildView(v2); | 518 root_view->AddChildView(v2); |
| 519 | 519 |
| 520 // Paint "everything". | 520 // Paint "everything". |
| 521 gfx::Rect first_paint(1, 1); | 521 gfx::Rect first_paint(1, 1); |
| 522 scoped_refptr<cc::DisplayItemList> list = | 522 scoped_refptr<cc::DisplayItemList> list = |
| 523 cc::DisplayItemList::Create(first_paint, cc::DisplayItemListSettings()); | 523 cc::DisplayItemList::Create(cc::DisplayItemListSettings()); |
| 524 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); | 524 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); |
| 525 | 525 |
| 526 // The empty view has nothing to paint so it doesn't try build a cache, nor do | 526 // The empty view has nothing to paint so it doesn't try build a cache, nor do |
| 527 // its children which would be clipped by its (empty) self. | 527 // its children which would be clipped by its (empty) self. |
| 528 EXPECT_FALSE(v1->did_paint_); | 528 EXPECT_FALSE(v1->did_paint_); |
| 529 EXPECT_FALSE(v11->did_paint_); | 529 EXPECT_FALSE(v11->did_paint_); |
| 530 EXPECT_TRUE(v2->did_paint_); | 530 EXPECT_TRUE(v2->did_paint_); |
| 531 } | 531 } |
| 532 | 532 |
| 533 TEST_F(ViewTest, PaintWithMovedViewUsesCache) { | 533 TEST_F(ViewTest, PaintWithMovedViewUsesCache) { |
| 534 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP)); | 534 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP)); |
| 535 View* root_view = widget->GetRootView(); | 535 View* root_view = widget->GetRootView(); |
| 536 TestView* v1 = new TestView; | 536 TestView* v1 = new TestView; |
| 537 v1->SetBounds(10, 11, 12, 13); | 537 v1->SetBounds(10, 11, 12, 13); |
| 538 root_view->AddChildView(v1); | 538 root_view->AddChildView(v1); |
| 539 | 539 |
| 540 // Paint everything once, since it has to build its cache. Then we can test | 540 // Paint everything once, since it has to build its cache. Then we can test |
| 541 // invalidation. | 541 // invalidation. |
| 542 gfx::Rect pixel_rect = gfx::Rect(1, 1); | 542 gfx::Rect pixel_rect = gfx::Rect(1, 1); |
| 543 float device_scale_factor = 1.f; | 543 float device_scale_factor = 1.f; |
| 544 scoped_refptr<cc::DisplayItemList> list = | 544 scoped_refptr<cc::DisplayItemList> list = |
| 545 cc::DisplayItemList::Create(pixel_rect, cc::DisplayItemListSettings()); | 545 cc::DisplayItemList::Create(cc::DisplayItemListSettings()); |
| 546 root_view->Paint( | 546 root_view->Paint( |
| 547 ui::PaintContext(list.get(), device_scale_factor, pixel_rect)); | 547 ui::PaintContext(list.get(), device_scale_factor, pixel_rect)); |
| 548 EXPECT_TRUE(v1->did_paint_); | 548 EXPECT_TRUE(v1->did_paint_); |
| 549 v1->Reset(); | 549 v1->Reset(); |
| 550 // The visual rects for (clip, drawing, transform) should be in layer space. | 550 // The visual rects for (clip, drawing, transform) should be in layer space. |
| 551 gfx::Rect expected_visual_rect_in_layer_space(10, 11, 12, 13); | 551 gfx::Rect expected_visual_rect_in_layer_space(10, 11, 12, 13); |
| 552 int item_index = 3; | 552 int item_index = 3; |
| 553 EXPECT_EQ(expected_visual_rect_in_layer_space, | 553 EXPECT_EQ(expected_visual_rect_in_layer_space, |
| 554 list->VisualRectForTesting(item_index++)); | 554 list->VisualRectForTesting(item_index++)); |
| 555 EXPECT_EQ(expected_visual_rect_in_layer_space, | 555 EXPECT_EQ(expected_visual_rect_in_layer_space, |
| 556 list->VisualRectForTesting(item_index++)); | 556 list->VisualRectForTesting(item_index++)); |
| 557 EXPECT_EQ(expected_visual_rect_in_layer_space, | 557 EXPECT_EQ(expected_visual_rect_in_layer_space, |
| 558 list->VisualRectForTesting(item_index)); | 558 list->VisualRectForTesting(item_index)); |
| 559 | 559 |
| 560 // If invalidation doesn't intersect v1, we paint with the cache. | 560 // If invalidation doesn't intersect v1, we paint with the cache. |
| 561 list = cc::DisplayItemList::Create(pixel_rect, cc::DisplayItemListSettings()); | 561 list = cc::DisplayItemList::Create(cc::DisplayItemListSettings()); |
| 562 root_view->Paint( | 562 root_view->Paint( |
| 563 ui::PaintContext(list.get(), device_scale_factor, pixel_rect)); | 563 ui::PaintContext(list.get(), device_scale_factor, pixel_rect)); |
| 564 EXPECT_FALSE(v1->did_paint_); | 564 EXPECT_FALSE(v1->did_paint_); |
| 565 v1->Reset(); | 565 v1->Reset(); |
| 566 | 566 |
| 567 // If invalidation does intersect v1, we don't paint with the cache. | 567 // If invalidation does intersect v1, we don't paint with the cache. |
| 568 list = cc::DisplayItemList::Create(pixel_rect, cc::DisplayItemListSettings()); | 568 list = cc::DisplayItemList::Create(cc::DisplayItemListSettings()); |
| 569 root_view->Paint( | 569 root_view->Paint( |
| 570 ui::PaintContext(list.get(), device_scale_factor, v1->bounds())); | 570 ui::PaintContext(list.get(), device_scale_factor, v1->bounds())); |
| 571 EXPECT_TRUE(v1->did_paint_); | 571 EXPECT_TRUE(v1->did_paint_); |
| 572 v1->Reset(); | 572 v1->Reset(); |
| 573 | 573 |
| 574 // Moving the view should still use the cache when the invalidation doesn't | 574 // Moving the view should still use the cache when the invalidation doesn't |
| 575 // intersect v1. | 575 // intersect v1. |
| 576 list = cc::DisplayItemList::Create(pixel_rect, cc::DisplayItemListSettings()); | 576 list = cc::DisplayItemList::Create(cc::DisplayItemListSettings()); |
| 577 v1->SetX(9); | 577 v1->SetX(9); |
| 578 root_view->Paint( | 578 root_view->Paint( |
| 579 ui::PaintContext(list.get(), device_scale_factor, pixel_rect)); | 579 ui::PaintContext(list.get(), device_scale_factor, pixel_rect)); |
| 580 EXPECT_FALSE(v1->did_paint_); | 580 EXPECT_FALSE(v1->did_paint_); |
| 581 v1->Reset(); | 581 v1->Reset(); |
| 582 item_index = 3; | 582 item_index = 3; |
| 583 expected_visual_rect_in_layer_space.SetRect(9, 11, 12, 13); | 583 expected_visual_rect_in_layer_space.SetRect(9, 11, 12, 13); |
| 584 EXPECT_EQ(expected_visual_rect_in_layer_space, | 584 EXPECT_EQ(expected_visual_rect_in_layer_space, |
| 585 list->VisualRectForTesting(item_index++)); | 585 list->VisualRectForTesting(item_index++)); |
| 586 EXPECT_EQ(expected_visual_rect_in_layer_space, | 586 EXPECT_EQ(expected_visual_rect_in_layer_space, |
| 587 list->VisualRectForTesting(item_index++)); | 587 list->VisualRectForTesting(item_index++)); |
| 588 EXPECT_EQ(expected_visual_rect_in_layer_space, | 588 EXPECT_EQ(expected_visual_rect_in_layer_space, |
| 589 list->VisualRectForTesting(item_index)); | 589 list->VisualRectForTesting(item_index)); |
| 590 | 590 |
| 591 // Moving the view should not use the cache when painting without | 591 // Moving the view should not use the cache when painting without |
| 592 // invalidation. | 592 // invalidation. |
| 593 list = cc::DisplayItemList::Create(pixel_rect, cc::DisplayItemListSettings()); | 593 list = cc::DisplayItemList::Create(cc::DisplayItemListSettings()); |
| 594 v1->SetX(8); | 594 v1->SetX(8); |
| 595 root_view->Paint(ui::PaintContext( | 595 root_view->Paint(ui::PaintContext( |
| 596 ui::PaintContext(list.get(), device_scale_factor, pixel_rect), | 596 ui::PaintContext(list.get(), device_scale_factor, pixel_rect), |
| 597 ui::PaintContext::CLONE_WITHOUT_INVALIDATION)); | 597 ui::PaintContext::CLONE_WITHOUT_INVALIDATION)); |
| 598 EXPECT_TRUE(v1->did_paint_); | 598 EXPECT_TRUE(v1->did_paint_); |
| 599 v1->Reset(); | 599 v1->Reset(); |
| 600 item_index = 3; | 600 item_index = 3; |
| 601 expected_visual_rect_in_layer_space.SetRect(8, 11, 12, 13); | 601 expected_visual_rect_in_layer_space.SetRect(8, 11, 12, 13); |
| 602 EXPECT_EQ(expected_visual_rect_in_layer_space, | 602 EXPECT_EQ(expected_visual_rect_in_layer_space, |
| 603 list->VisualRectForTesting(item_index++)); | 603 list->VisualRectForTesting(item_index++)); |
| 604 EXPECT_EQ(expected_visual_rect_in_layer_space, | 604 EXPECT_EQ(expected_visual_rect_in_layer_space, |
| 605 list->VisualRectForTesting(item_index++)); | 605 list->VisualRectForTesting(item_index++)); |
| 606 EXPECT_EQ(expected_visual_rect_in_layer_space, | 606 EXPECT_EQ(expected_visual_rect_in_layer_space, |
| 607 list->VisualRectForTesting(item_index)); | 607 list->VisualRectForTesting(item_index)); |
| 608 } | 608 } |
| 609 | 609 |
| 610 TEST_F(ViewTest, PaintWithMovedViewUsesCacheInRTL) { | 610 TEST_F(ViewTest, PaintWithMovedViewUsesCacheInRTL) { |
| 611 ScopedRTL rtl; | 611 ScopedRTL rtl; |
| 612 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP)); | 612 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP)); |
| 613 View* root_view = widget->GetRootView(); | 613 View* root_view = widget->GetRootView(); |
| 614 TestView* v1 = new TestView; | 614 TestView* v1 = new TestView; |
| 615 v1->SetBounds(10, 11, 12, 13); | 615 v1->SetBounds(10, 11, 12, 13); |
| 616 root_view->AddChildView(v1); | 616 root_view->AddChildView(v1); |
| 617 | 617 |
| 618 // Paint everything once, since it has to build its cache. Then we can test | 618 // Paint everything once, since it has to build its cache. Then we can test |
| 619 // invalidation. | 619 // invalidation. |
| 620 gfx::Rect pixel_rect = gfx::Rect(1, 1); | 620 gfx::Rect pixel_rect = gfx::Rect(1, 1); |
| 621 float device_scale_factor = 1.f; | 621 float device_scale_factor = 1.f; |
| 622 scoped_refptr<cc::DisplayItemList> list = | 622 scoped_refptr<cc::DisplayItemList> list = |
| 623 cc::DisplayItemList::Create(pixel_rect, cc::DisplayItemListSettings()); | 623 cc::DisplayItemList::Create(cc::DisplayItemListSettings()); |
| 624 root_view->Paint( | 624 root_view->Paint( |
| 625 ui::PaintContext(list.get(), device_scale_factor, pixel_rect)); | 625 ui::PaintContext(list.get(), device_scale_factor, pixel_rect)); |
| 626 EXPECT_TRUE(v1->did_paint_); | 626 EXPECT_TRUE(v1->did_paint_); |
| 627 v1->Reset(); | 627 v1->Reset(); |
| 628 // The visual rects for (clip, drawing, transform) should be in layer space. | 628 // The visual rects for (clip, drawing, transform) should be in layer space. |
| 629 // x: 25 - 10(x) - 12(width) = 3 | 629 // x: 25 - 10(x) - 12(width) = 3 |
| 630 gfx::Rect expected_visual_rect_in_layer_space(3, 11, 12, 13); | 630 gfx::Rect expected_visual_rect_in_layer_space(3, 11, 12, 13); |
| 631 int item_index = 3; | 631 int item_index = 3; |
| 632 EXPECT_EQ(expected_visual_rect_in_layer_space, | 632 EXPECT_EQ(expected_visual_rect_in_layer_space, |
| 633 list->VisualRectForTesting(item_index++)); | 633 list->VisualRectForTesting(item_index++)); |
| 634 EXPECT_EQ(expected_visual_rect_in_layer_space, | 634 EXPECT_EQ(expected_visual_rect_in_layer_space, |
| 635 list->VisualRectForTesting(item_index++)); | 635 list->VisualRectForTesting(item_index++)); |
| 636 EXPECT_EQ(expected_visual_rect_in_layer_space, | 636 EXPECT_EQ(expected_visual_rect_in_layer_space, |
| 637 list->VisualRectForTesting(item_index)); | 637 list->VisualRectForTesting(item_index)); |
| 638 | 638 |
| 639 // If invalidation doesn't intersect v1, we paint with the cache. | 639 // If invalidation doesn't intersect v1, we paint with the cache. |
| 640 list = cc::DisplayItemList::Create(pixel_rect, cc::DisplayItemListSettings()); | 640 list = cc::DisplayItemList::Create(cc::DisplayItemListSettings()); |
| 641 root_view->Paint( | 641 root_view->Paint( |
| 642 ui::PaintContext(list.get(), device_scale_factor, pixel_rect)); | 642 ui::PaintContext(list.get(), device_scale_factor, pixel_rect)); |
| 643 EXPECT_FALSE(v1->did_paint_); | 643 EXPECT_FALSE(v1->did_paint_); |
| 644 v1->Reset(); | 644 v1->Reset(); |
| 645 | 645 |
| 646 // If invalidation does intersect v1, we don't paint with the cache. | 646 // If invalidation does intersect v1, we don't paint with the cache. |
| 647 list = cc::DisplayItemList::Create(pixel_rect, cc::DisplayItemListSettings()); | 647 list = cc::DisplayItemList::Create(cc::DisplayItemListSettings()); |
| 648 root_view->Paint( | 648 root_view->Paint( |
| 649 ui::PaintContext(list.get(), device_scale_factor, v1->bounds())); | 649 ui::PaintContext(list.get(), device_scale_factor, v1->bounds())); |
| 650 EXPECT_TRUE(v1->did_paint_); | 650 EXPECT_TRUE(v1->did_paint_); |
| 651 v1->Reset(); | 651 v1->Reset(); |
| 652 | 652 |
| 653 // Moving the view should still use the cache when the invalidation doesn't | 653 // Moving the view should still use the cache when the invalidation doesn't |
| 654 // intersect v1. | 654 // intersect v1. |
| 655 list = cc::DisplayItemList::Create(pixel_rect, cc::DisplayItemListSettings()); | 655 list = cc::DisplayItemList::Create(cc::DisplayItemListSettings()); |
| 656 v1->SetX(9); | 656 v1->SetX(9); |
| 657 root_view->Paint( | 657 root_view->Paint( |
| 658 ui::PaintContext(list.get(), device_scale_factor, pixel_rect)); | 658 ui::PaintContext(list.get(), device_scale_factor, pixel_rect)); |
| 659 EXPECT_FALSE(v1->did_paint_); | 659 EXPECT_FALSE(v1->did_paint_); |
| 660 v1->Reset(); | 660 v1->Reset(); |
| 661 item_index = 3; | 661 item_index = 3; |
| 662 // x: 25 - 9(x) - 12(width) = 4 | 662 // x: 25 - 9(x) - 12(width) = 4 |
| 663 expected_visual_rect_in_layer_space.SetRect(4, 11, 12, 13); | 663 expected_visual_rect_in_layer_space.SetRect(4, 11, 12, 13); |
| 664 EXPECT_EQ(expected_visual_rect_in_layer_space, | 664 EXPECT_EQ(expected_visual_rect_in_layer_space, |
| 665 list->VisualRectForTesting(item_index++)); | 665 list->VisualRectForTesting(item_index++)); |
| 666 EXPECT_EQ(expected_visual_rect_in_layer_space, | 666 EXPECT_EQ(expected_visual_rect_in_layer_space, |
| 667 list->VisualRectForTesting(item_index++)); | 667 list->VisualRectForTesting(item_index++)); |
| 668 EXPECT_EQ(expected_visual_rect_in_layer_space, | 668 EXPECT_EQ(expected_visual_rect_in_layer_space, |
| 669 list->VisualRectForTesting(item_index)); | 669 list->VisualRectForTesting(item_index)); |
| 670 | 670 |
| 671 // Moving the view should not use the cache when painting without | 671 // Moving the view should not use the cache when painting without |
| 672 // invalidation. | 672 // invalidation. |
| 673 list = cc::DisplayItemList::Create(pixel_rect, cc::DisplayItemListSettings()); | 673 list = cc::DisplayItemList::Create(cc::DisplayItemListSettings()); |
| 674 v1->SetX(8); | 674 v1->SetX(8); |
| 675 root_view->Paint(ui::PaintContext( | 675 root_view->Paint(ui::PaintContext( |
| 676 ui::PaintContext(list.get(), device_scale_factor, pixel_rect), | 676 ui::PaintContext(list.get(), device_scale_factor, pixel_rect), |
| 677 ui::PaintContext::CLONE_WITHOUT_INVALIDATION)); | 677 ui::PaintContext::CLONE_WITHOUT_INVALIDATION)); |
| 678 EXPECT_TRUE(v1->did_paint_); | 678 EXPECT_TRUE(v1->did_paint_); |
| 679 v1->Reset(); | 679 v1->Reset(); |
| 680 item_index = 3; | 680 item_index = 3; |
| 681 // x: 25 - 8(x) - 12(width) = 5 | 681 // x: 25 - 8(x) - 12(width) = 5 |
| 682 expected_visual_rect_in_layer_space.SetRect(5, 11, 12, 13); | 682 expected_visual_rect_in_layer_space.SetRect(5, 11, 12, 13); |
| 683 EXPECT_EQ(expected_visual_rect_in_layer_space, | 683 EXPECT_EQ(expected_visual_rect_in_layer_space, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 697 root_view->AddChildView(v1); | 697 root_view->AddChildView(v1); |
| 698 | 698 |
| 699 TestView* v2 = new TestView; | 699 TestView* v2 = new TestView; |
| 700 v2->SetBounds(3, 4, 6, 5); | 700 v2->SetBounds(3, 4, 6, 5); |
| 701 v1->AddChildView(v2); | 701 v1->AddChildView(v2); |
| 702 | 702 |
| 703 // Paint everything once, since it has to build its cache. Then we can test | 703 // Paint everything once, since it has to build its cache. Then we can test |
| 704 // invalidation. | 704 // invalidation. |
| 705 gfx::Rect first_paint(1, 1); | 705 gfx::Rect first_paint(1, 1); |
| 706 scoped_refptr<cc::DisplayItemList> list = | 706 scoped_refptr<cc::DisplayItemList> list = |
| 707 cc::DisplayItemList::Create(first_paint, cc::DisplayItemListSettings()); | 707 cc::DisplayItemList::Create(cc::DisplayItemListSettings()); |
| 708 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); | 708 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); |
| 709 v1->Reset(); | 709 v1->Reset(); |
| 710 v2->Reset(); | 710 v2->Reset(); |
| 711 | 711 |
| 712 gfx::Rect paint_area(1, 1); | 712 gfx::Rect paint_area(1, 1); |
| 713 gfx::Rect root_area(root_view->size()); | 713 gfx::Rect root_area(root_view->size()); |
| 714 list = cc::DisplayItemList::Create(root_area, cc::DisplayItemListSettings()); | 714 list = cc::DisplayItemList::Create(cc::DisplayItemListSettings()); |
| 715 | 715 |
| 716 // With a known invalidation, v1 and v2 are not painted. | 716 // With a known invalidation, v1 and v2 are not painted. |
| 717 EXPECT_FALSE(v1->did_paint_); | 717 EXPECT_FALSE(v1->did_paint_); |
| 718 EXPECT_FALSE(v2->did_paint_); | 718 EXPECT_FALSE(v2->did_paint_); |
| 719 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); | 719 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); |
| 720 EXPECT_FALSE(v1->did_paint_); | 720 EXPECT_FALSE(v1->did_paint_); |
| 721 EXPECT_FALSE(v2->did_paint_); | 721 EXPECT_FALSE(v2->did_paint_); |
| 722 | 722 |
| 723 // With unknown invalidation, v1 and v2 are painted. | 723 // With unknown invalidation, v1 and v2 are painted. |
| 724 root_view->Paint( | 724 root_view->Paint( |
| (...skipping 12 matching lines...) Expand all Loading... |
| 737 root_view->AddChildView(v1); | 737 root_view->AddChildView(v1); |
| 738 | 738 |
| 739 TestView* v2 = new TestView; | 739 TestView* v2 = new TestView; |
| 740 v2->SetBounds(3, 4, 6, 5); | 740 v2->SetBounds(3, 4, 6, 5); |
| 741 v1->AddChildView(v2); | 741 v1->AddChildView(v2); |
| 742 | 742 |
| 743 // Paint everything once, since it has to build its cache. Then we can test | 743 // Paint everything once, since it has to build its cache. Then we can test |
| 744 // invalidation. | 744 // invalidation. |
| 745 gfx::Rect first_paint(1, 1); | 745 gfx::Rect first_paint(1, 1); |
| 746 scoped_refptr<cc::DisplayItemList> list = | 746 scoped_refptr<cc::DisplayItemList> list = |
| 747 cc::DisplayItemList::Create(first_paint, cc::DisplayItemListSettings()); | 747 cc::DisplayItemList::Create(cc::DisplayItemListSettings()); |
| 748 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); | 748 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); |
| 749 v1->Reset(); | 749 v1->Reset(); |
| 750 v2->Reset(); | 750 v2->Reset(); |
| 751 | 751 |
| 752 gfx::Rect paint_area(25, 26); | 752 gfx::Rect paint_area(25, 26); |
| 753 gfx::Rect root_area(root_view->size()); | 753 gfx::Rect root_area(root_view->size()); |
| 754 list = cc::DisplayItemList::Create(root_area, cc::DisplayItemListSettings()); | 754 list = cc::DisplayItemList::Create(cc::DisplayItemListSettings()); |
| 755 | 755 |
| 756 EXPECT_FALSE(v1->did_paint_); | 756 EXPECT_FALSE(v1->did_paint_); |
| 757 EXPECT_FALSE(v2->did_paint_); | 757 EXPECT_FALSE(v2->did_paint_); |
| 758 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); | 758 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); |
| 759 EXPECT_TRUE(v1->did_paint_); | 759 EXPECT_TRUE(v1->did_paint_); |
| 760 EXPECT_TRUE(v2->did_paint_); | 760 EXPECT_TRUE(v2->did_paint_); |
| 761 } | 761 } |
| 762 | 762 |
| 763 TEST_F(ViewTest, PaintContainsChildrenInRTL) { | 763 TEST_F(ViewTest, PaintContainsChildrenInRTL) { |
| 764 ScopedRTL rtl; | 764 ScopedRTL rtl; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 781 | 781 |
| 782 v2->SetPaintToLayer(true); | 782 v2->SetPaintToLayer(true); |
| 783 // x: 25 - 10(parent x) - 3(x) - 6(width) = 6 | 783 // x: 25 - 10(parent x) - 3(x) - 6(width) = 6 |
| 784 EXPECT_EQ(gfx::Rect(6, 15, 6, 5), v2->layer()->bounds()); | 784 EXPECT_EQ(gfx::Rect(6, 15, 6, 5), v2->layer()->bounds()); |
| 785 v2->SetPaintToLayer(false); | 785 v2->SetPaintToLayer(false); |
| 786 | 786 |
| 787 // Paint everything once, since it has to build its cache. Then we can test | 787 // Paint everything once, since it has to build its cache. Then we can test |
| 788 // invalidation. | 788 // invalidation. |
| 789 gfx::Rect first_paint(1, 1); | 789 gfx::Rect first_paint(1, 1); |
| 790 scoped_refptr<cc::DisplayItemList> list = | 790 scoped_refptr<cc::DisplayItemList> list = |
| 791 cc::DisplayItemList::Create(first_paint, cc::DisplayItemListSettings()); | 791 cc::DisplayItemList::Create(cc::DisplayItemListSettings()); |
| 792 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); | 792 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); |
| 793 v1->Reset(); | 793 v1->Reset(); |
| 794 v2->Reset(); | 794 v2->Reset(); |
| 795 | 795 |
| 796 gfx::Rect paint_area(25, 26); | 796 gfx::Rect paint_area(25, 26); |
| 797 gfx::Rect root_area(root_view->size()); | 797 gfx::Rect root_area(root_view->size()); |
| 798 list = cc::DisplayItemList::Create(root_area, cc::DisplayItemListSettings()); | 798 list = cc::DisplayItemList::Create(cc::DisplayItemListSettings()); |
| 799 | 799 |
| 800 EXPECT_FALSE(v1->did_paint_); | 800 EXPECT_FALSE(v1->did_paint_); |
| 801 EXPECT_FALSE(v2->did_paint_); | 801 EXPECT_FALSE(v2->did_paint_); |
| 802 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); | 802 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); |
| 803 EXPECT_TRUE(v1->did_paint_); | 803 EXPECT_TRUE(v1->did_paint_); |
| 804 EXPECT_TRUE(v2->did_paint_); | 804 EXPECT_TRUE(v2->did_paint_); |
| 805 } | 805 } |
| 806 | 806 |
| 807 TEST_F(ViewTest, PaintIntersectsChildren) { | 807 TEST_F(ViewTest, PaintIntersectsChildren) { |
| 808 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP)); | 808 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP)); |
| 809 View* root_view = widget->GetRootView(); | 809 View* root_view = widget->GetRootView(); |
| 810 | 810 |
| 811 TestView* v1 = new TestView; | 811 TestView* v1 = new TestView; |
| 812 v1->SetBounds(10, 11, 12, 13); | 812 v1->SetBounds(10, 11, 12, 13); |
| 813 root_view->AddChildView(v1); | 813 root_view->AddChildView(v1); |
| 814 | 814 |
| 815 TestView* v2 = new TestView; | 815 TestView* v2 = new TestView; |
| 816 v2->SetBounds(3, 4, 6, 5); | 816 v2->SetBounds(3, 4, 6, 5); |
| 817 v1->AddChildView(v2); | 817 v1->AddChildView(v2); |
| 818 | 818 |
| 819 // Paint everything once, since it has to build its cache. Then we can test | 819 // Paint everything once, since it has to build its cache. Then we can test |
| 820 // invalidation. | 820 // invalidation. |
| 821 gfx::Rect first_paint(1, 1); | 821 gfx::Rect first_paint(1, 1); |
| 822 scoped_refptr<cc::DisplayItemList> list = | 822 scoped_refptr<cc::DisplayItemList> list = |
| 823 cc::DisplayItemList::Create(first_paint, cc::DisplayItemListSettings()); | 823 cc::DisplayItemList::Create(cc::DisplayItemListSettings()); |
| 824 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); | 824 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); |
| 825 v1->Reset(); | 825 v1->Reset(); |
| 826 v2->Reset(); | 826 v2->Reset(); |
| 827 | 827 |
| 828 gfx::Rect paint_area(9, 10, 5, 6); | 828 gfx::Rect paint_area(9, 10, 5, 6); |
| 829 gfx::Rect root_area(root_view->size()); | 829 gfx::Rect root_area(root_view->size()); |
| 830 list = cc::DisplayItemList::Create(root_area, cc::DisplayItemListSettings()); | 830 list = cc::DisplayItemList::Create(cc::DisplayItemListSettings()); |
| 831 | 831 |
| 832 EXPECT_FALSE(v1->did_paint_); | 832 EXPECT_FALSE(v1->did_paint_); |
| 833 EXPECT_FALSE(v2->did_paint_); | 833 EXPECT_FALSE(v2->did_paint_); |
| 834 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); | 834 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); |
| 835 EXPECT_TRUE(v1->did_paint_); | 835 EXPECT_TRUE(v1->did_paint_); |
| 836 EXPECT_TRUE(v2->did_paint_); | 836 EXPECT_TRUE(v2->did_paint_); |
| 837 } | 837 } |
| 838 | 838 |
| 839 TEST_F(ViewTest, PaintIntersectsChildrenInRTL) { | 839 TEST_F(ViewTest, PaintIntersectsChildrenInRTL) { |
| 840 ScopedRTL rtl; | 840 ScopedRTL rtl; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 857 | 857 |
| 858 v2->SetPaintToLayer(true); | 858 v2->SetPaintToLayer(true); |
| 859 // x: 25 - 10(parent x) - 3(x) - 6(width) = 6 | 859 // x: 25 - 10(parent x) - 3(x) - 6(width) = 6 |
| 860 EXPECT_EQ(gfx::Rect(6, 15, 6, 5), v2->layer()->bounds()); | 860 EXPECT_EQ(gfx::Rect(6, 15, 6, 5), v2->layer()->bounds()); |
| 861 v2->SetPaintToLayer(false); | 861 v2->SetPaintToLayer(false); |
| 862 | 862 |
| 863 // Paint everything once, since it has to build its cache. Then we can test | 863 // Paint everything once, since it has to build its cache. Then we can test |
| 864 // invalidation. | 864 // invalidation. |
| 865 gfx::Rect first_paint(1, 1); | 865 gfx::Rect first_paint(1, 1); |
| 866 scoped_refptr<cc::DisplayItemList> list = | 866 scoped_refptr<cc::DisplayItemList> list = |
| 867 cc::DisplayItemList::Create(first_paint, cc::DisplayItemListSettings()); | 867 cc::DisplayItemList::Create(cc::DisplayItemListSettings()); |
| 868 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); | 868 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); |
| 869 v1->Reset(); | 869 v1->Reset(); |
| 870 v2->Reset(); | 870 v2->Reset(); |
| 871 | 871 |
| 872 gfx::Rect paint_area(2, 10, 5, 6); | 872 gfx::Rect paint_area(2, 10, 5, 6); |
| 873 gfx::Rect root_area(root_view->size()); | 873 gfx::Rect root_area(root_view->size()); |
| 874 list = cc::DisplayItemList::Create(root_area, cc::DisplayItemListSettings()); | 874 list = cc::DisplayItemList::Create(cc::DisplayItemListSettings()); |
| 875 | 875 |
| 876 EXPECT_FALSE(v1->did_paint_); | 876 EXPECT_FALSE(v1->did_paint_); |
| 877 EXPECT_FALSE(v2->did_paint_); | 877 EXPECT_FALSE(v2->did_paint_); |
| 878 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); | 878 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); |
| 879 EXPECT_TRUE(v1->did_paint_); | 879 EXPECT_TRUE(v1->did_paint_); |
| 880 EXPECT_TRUE(v2->did_paint_); | 880 EXPECT_TRUE(v2->did_paint_); |
| 881 } | 881 } |
| 882 | 882 |
| 883 TEST_F(ViewTest, PaintIntersectsChildButNotGrandChild) { | 883 TEST_F(ViewTest, PaintIntersectsChildButNotGrandChild) { |
| 884 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP)); | 884 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP)); |
| 885 View* root_view = widget->GetRootView(); | 885 View* root_view = widget->GetRootView(); |
| 886 | 886 |
| 887 TestView* v1 = new TestView; | 887 TestView* v1 = new TestView; |
| 888 v1->SetBounds(10, 11, 12, 13); | 888 v1->SetBounds(10, 11, 12, 13); |
| 889 root_view->AddChildView(v1); | 889 root_view->AddChildView(v1); |
| 890 | 890 |
| 891 TestView* v2 = new TestView; | 891 TestView* v2 = new TestView; |
| 892 v2->SetBounds(3, 4, 6, 5); | 892 v2->SetBounds(3, 4, 6, 5); |
| 893 v1->AddChildView(v2); | 893 v1->AddChildView(v2); |
| 894 | 894 |
| 895 // Paint everything once, since it has to build its cache. Then we can test | 895 // Paint everything once, since it has to build its cache. Then we can test |
| 896 // invalidation. | 896 // invalidation. |
| 897 gfx::Rect first_paint(1, 1); | 897 gfx::Rect first_paint(1, 1); |
| 898 scoped_refptr<cc::DisplayItemList> list = | 898 scoped_refptr<cc::DisplayItemList> list = |
| 899 cc::DisplayItemList::Create(first_paint, cc::DisplayItemListSettings()); | 899 cc::DisplayItemList::Create(cc::DisplayItemListSettings()); |
| 900 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); | 900 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); |
| 901 v1->Reset(); | 901 v1->Reset(); |
| 902 v2->Reset(); | 902 v2->Reset(); |
| 903 | 903 |
| 904 gfx::Rect paint_area(9, 10, 2, 3); | 904 gfx::Rect paint_area(9, 10, 2, 3); |
| 905 gfx::Rect root_area(root_view->size()); | 905 gfx::Rect root_area(root_view->size()); |
| 906 list = cc::DisplayItemList::Create(root_area, cc::DisplayItemListSettings()); | 906 list = cc::DisplayItemList::Create(cc::DisplayItemListSettings()); |
| 907 | 907 |
| 908 EXPECT_FALSE(v1->did_paint_); | 908 EXPECT_FALSE(v1->did_paint_); |
| 909 EXPECT_FALSE(v2->did_paint_); | 909 EXPECT_FALSE(v2->did_paint_); |
| 910 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); | 910 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); |
| 911 EXPECT_TRUE(v1->did_paint_); | 911 EXPECT_TRUE(v1->did_paint_); |
| 912 EXPECT_FALSE(v2->did_paint_); | 912 EXPECT_FALSE(v2->did_paint_); |
| 913 } | 913 } |
| 914 | 914 |
| 915 TEST_F(ViewTest, PaintIntersectsChildButNotGrandChildInRTL) { | 915 TEST_F(ViewTest, PaintIntersectsChildButNotGrandChildInRTL) { |
| 916 ScopedRTL rtl; | 916 ScopedRTL rtl; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 933 | 933 |
| 934 v2->SetPaintToLayer(true); | 934 v2->SetPaintToLayer(true); |
| 935 // x: 25 - 10(parent x) - 3(x) - 6(width) = 6 | 935 // x: 25 - 10(parent x) - 3(x) - 6(width) = 6 |
| 936 EXPECT_EQ(gfx::Rect(6, 15, 6, 5), v2->layer()->bounds()); | 936 EXPECT_EQ(gfx::Rect(6, 15, 6, 5), v2->layer()->bounds()); |
| 937 v2->SetPaintToLayer(false); | 937 v2->SetPaintToLayer(false); |
| 938 | 938 |
| 939 // Paint everything once, since it has to build its cache. Then we can test | 939 // Paint everything once, since it has to build its cache. Then we can test |
| 940 // invalidation. | 940 // invalidation. |
| 941 gfx::Rect first_paint(1, 1); | 941 gfx::Rect first_paint(1, 1); |
| 942 scoped_refptr<cc::DisplayItemList> list = | 942 scoped_refptr<cc::DisplayItemList> list = |
| 943 cc::DisplayItemList::Create(first_paint, cc::DisplayItemListSettings()); | 943 cc::DisplayItemList::Create(cc::DisplayItemListSettings()); |
| 944 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); | 944 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); |
| 945 v1->Reset(); | 945 v1->Reset(); |
| 946 v2->Reset(); | 946 v2->Reset(); |
| 947 | 947 |
| 948 gfx::Rect paint_area(2, 10, 2, 3); | 948 gfx::Rect paint_area(2, 10, 2, 3); |
| 949 gfx::Rect root_area(root_view->size()); | 949 gfx::Rect root_area(root_view->size()); |
| 950 list = cc::DisplayItemList::Create(root_area, cc::DisplayItemListSettings()); | 950 list = cc::DisplayItemList::Create(cc::DisplayItemListSettings()); |
| 951 | 951 |
| 952 EXPECT_FALSE(v1->did_paint_); | 952 EXPECT_FALSE(v1->did_paint_); |
| 953 EXPECT_FALSE(v2->did_paint_); | 953 EXPECT_FALSE(v2->did_paint_); |
| 954 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); | 954 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); |
| 955 EXPECT_TRUE(v1->did_paint_); | 955 EXPECT_TRUE(v1->did_paint_); |
| 956 EXPECT_FALSE(v2->did_paint_); | 956 EXPECT_FALSE(v2->did_paint_); |
| 957 } | 957 } |
| 958 | 958 |
| 959 TEST_F(ViewTest, PaintIntersectsNoChildren) { | 959 TEST_F(ViewTest, PaintIntersectsNoChildren) { |
| 960 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP)); | 960 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP)); |
| 961 View* root_view = widget->GetRootView(); | 961 View* root_view = widget->GetRootView(); |
| 962 | 962 |
| 963 TestView* v1 = new TestView; | 963 TestView* v1 = new TestView; |
| 964 v1->SetBounds(10, 11, 12, 13); | 964 v1->SetBounds(10, 11, 12, 13); |
| 965 root_view->AddChildView(v1); | 965 root_view->AddChildView(v1); |
| 966 | 966 |
| 967 TestView* v2 = new TestView; | 967 TestView* v2 = new TestView; |
| 968 v2->SetBounds(3, 4, 6, 5); | 968 v2->SetBounds(3, 4, 6, 5); |
| 969 v1->AddChildView(v2); | 969 v1->AddChildView(v2); |
| 970 | 970 |
| 971 // Paint everything once, since it has to build its cache. Then we can test | 971 // Paint everything once, since it has to build its cache. Then we can test |
| 972 // invalidation. | 972 // invalidation. |
| 973 gfx::Rect first_paint(1, 1); | 973 gfx::Rect first_paint(1, 1); |
| 974 scoped_refptr<cc::DisplayItemList> list = | 974 scoped_refptr<cc::DisplayItemList> list = |
| 975 cc::DisplayItemList::Create(first_paint, cc::DisplayItemListSettings()); | 975 cc::DisplayItemList::Create(cc::DisplayItemListSettings()); |
| 976 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); | 976 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); |
| 977 v1->Reset(); | 977 v1->Reset(); |
| 978 v2->Reset(); | 978 v2->Reset(); |
| 979 | 979 |
| 980 gfx::Rect paint_area(9, 10, 2, 1); | 980 gfx::Rect paint_area(9, 10, 2, 1); |
| 981 gfx::Rect root_area(root_view->size()); | 981 gfx::Rect root_area(root_view->size()); |
| 982 list = cc::DisplayItemList::Create(root_area, cc::DisplayItemListSettings()); | 982 list = cc::DisplayItemList::Create(cc::DisplayItemListSettings()); |
| 983 | 983 |
| 984 EXPECT_FALSE(v1->did_paint_); | 984 EXPECT_FALSE(v1->did_paint_); |
| 985 EXPECT_FALSE(v2->did_paint_); | 985 EXPECT_FALSE(v2->did_paint_); |
| 986 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); | 986 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); |
| 987 EXPECT_FALSE(v1->did_paint_); | 987 EXPECT_FALSE(v1->did_paint_); |
| 988 EXPECT_FALSE(v2->did_paint_); | 988 EXPECT_FALSE(v2->did_paint_); |
| 989 } | 989 } |
| 990 | 990 |
| 991 TEST_F(ViewTest, PaintIntersectsNoChildrenInRTL) { | 991 TEST_F(ViewTest, PaintIntersectsNoChildrenInRTL) { |
| 992 ScopedRTL rtl; | 992 ScopedRTL rtl; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1009 | 1009 |
| 1010 v2->SetPaintToLayer(true); | 1010 v2->SetPaintToLayer(true); |
| 1011 // x: 25 - 10(parent x) - 3(x) - 6(width) = 6 | 1011 // x: 25 - 10(parent x) - 3(x) - 6(width) = 6 |
| 1012 EXPECT_EQ(gfx::Rect(6, 15, 6, 5), v2->layer()->bounds()); | 1012 EXPECT_EQ(gfx::Rect(6, 15, 6, 5), v2->layer()->bounds()); |
| 1013 v2->SetPaintToLayer(false); | 1013 v2->SetPaintToLayer(false); |
| 1014 | 1014 |
| 1015 // Paint everything once, since it has to build its cache. Then we can test | 1015 // Paint everything once, since it has to build its cache. Then we can test |
| 1016 // invalidation. | 1016 // invalidation. |
| 1017 gfx::Rect first_paint(1, 1); | 1017 gfx::Rect first_paint(1, 1); |
| 1018 scoped_refptr<cc::DisplayItemList> list = | 1018 scoped_refptr<cc::DisplayItemList> list = |
| 1019 cc::DisplayItemList::Create(first_paint, cc::DisplayItemListSettings()); | 1019 cc::DisplayItemList::Create(cc::DisplayItemListSettings()); |
| 1020 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); | 1020 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); |
| 1021 v1->Reset(); | 1021 v1->Reset(); |
| 1022 v2->Reset(); | 1022 v2->Reset(); |
| 1023 | 1023 |
| 1024 gfx::Rect paint_area(2, 10, 2, 1); | 1024 gfx::Rect paint_area(2, 10, 2, 1); |
| 1025 gfx::Rect root_area(root_view->size()); | 1025 gfx::Rect root_area(root_view->size()); |
| 1026 list = cc::DisplayItemList::Create(root_area, cc::DisplayItemListSettings()); | 1026 list = cc::DisplayItemList::Create(cc::DisplayItemListSettings()); |
| 1027 | 1027 |
| 1028 EXPECT_FALSE(v1->did_paint_); | 1028 EXPECT_FALSE(v1->did_paint_); |
| 1029 EXPECT_FALSE(v2->did_paint_); | 1029 EXPECT_FALSE(v2->did_paint_); |
| 1030 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); | 1030 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); |
| 1031 EXPECT_FALSE(v1->did_paint_); | 1031 EXPECT_FALSE(v1->did_paint_); |
| 1032 EXPECT_FALSE(v2->did_paint_); | 1032 EXPECT_FALSE(v2->did_paint_); |
| 1033 } | 1033 } |
| 1034 | 1034 |
| 1035 TEST_F(ViewTest, PaintIntersectsOneChild) { | 1035 TEST_F(ViewTest, PaintIntersectsOneChild) { |
| 1036 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP)); | 1036 ScopedTestPaintWidget widget(CreateParams(Widget::InitParams::TYPE_POPUP)); |
| 1037 View* root_view = widget->GetRootView(); | 1037 View* root_view = widget->GetRootView(); |
| 1038 | 1038 |
| 1039 TestView* v1 = new TestView; | 1039 TestView* v1 = new TestView; |
| 1040 v1->SetBounds(10, 11, 12, 13); | 1040 v1->SetBounds(10, 11, 12, 13); |
| 1041 root_view->AddChildView(v1); | 1041 root_view->AddChildView(v1); |
| 1042 | 1042 |
| 1043 TestView* v2 = new TestView; | 1043 TestView* v2 = new TestView; |
| 1044 v2->SetBounds(3, 4, 6, 5); | 1044 v2->SetBounds(3, 4, 6, 5); |
| 1045 root_view->AddChildView(v2); | 1045 root_view->AddChildView(v2); |
| 1046 | 1046 |
| 1047 // Paint everything once, since it has to build its cache. Then we can test | 1047 // Paint everything once, since it has to build its cache. Then we can test |
| 1048 // invalidation. | 1048 // invalidation. |
| 1049 gfx::Rect first_paint(1, 1); | 1049 gfx::Rect first_paint(1, 1); |
| 1050 scoped_refptr<cc::DisplayItemList> list = | 1050 scoped_refptr<cc::DisplayItemList> list = |
| 1051 cc::DisplayItemList::Create(first_paint, cc::DisplayItemListSettings()); | 1051 cc::DisplayItemList::Create(cc::DisplayItemListSettings()); |
| 1052 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); | 1052 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); |
| 1053 v1->Reset(); | 1053 v1->Reset(); |
| 1054 v2->Reset(); | 1054 v2->Reset(); |
| 1055 | 1055 |
| 1056 // Intersects with the second child only. | 1056 // Intersects with the second child only. |
| 1057 gfx::Rect paint_area(3, 3, 1, 2); | 1057 gfx::Rect paint_area(3, 3, 1, 2); |
| 1058 gfx::Rect root_area(root_view->size()); | 1058 gfx::Rect root_area(root_view->size()); |
| 1059 list = cc::DisplayItemList::Create(root_area, cc::DisplayItemListSettings()); | 1059 list = cc::DisplayItemList::Create(cc::DisplayItemListSettings()); |
| 1060 | 1060 |
| 1061 EXPECT_FALSE(v1->did_paint_); | 1061 EXPECT_FALSE(v1->did_paint_); |
| 1062 EXPECT_FALSE(v2->did_paint_); | 1062 EXPECT_FALSE(v2->did_paint_); |
| 1063 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); | 1063 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); |
| 1064 EXPECT_FALSE(v1->did_paint_); | 1064 EXPECT_FALSE(v1->did_paint_); |
| 1065 EXPECT_TRUE(v2->did_paint_); | 1065 EXPECT_TRUE(v2->did_paint_); |
| 1066 | 1066 |
| 1067 // Intersects with the first child only. | 1067 // Intersects with the first child only. |
| 1068 paint_area = gfx::Rect(20, 10, 1, 2); | 1068 paint_area = gfx::Rect(20, 10, 1, 2); |
| 1069 | 1069 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1097 | 1097 |
| 1098 v2->SetPaintToLayer(true); | 1098 v2->SetPaintToLayer(true); |
| 1099 // x: 25 - 3(x) - 6(width) = 16 | 1099 // x: 25 - 3(x) - 6(width) = 16 |
| 1100 EXPECT_EQ(gfx::Rect(16, 4, 6, 5), v2->layer()->bounds()); | 1100 EXPECT_EQ(gfx::Rect(16, 4, 6, 5), v2->layer()->bounds()); |
| 1101 v2->SetPaintToLayer(false); | 1101 v2->SetPaintToLayer(false); |
| 1102 | 1102 |
| 1103 // Paint everything once, since it has to build its cache. Then we can test | 1103 // Paint everything once, since it has to build its cache. Then we can test |
| 1104 // invalidation. | 1104 // invalidation. |
| 1105 gfx::Rect first_paint(1, 1); | 1105 gfx::Rect first_paint(1, 1); |
| 1106 scoped_refptr<cc::DisplayItemList> list = | 1106 scoped_refptr<cc::DisplayItemList> list = |
| 1107 cc::DisplayItemList::Create(first_paint, cc::DisplayItemListSettings()); | 1107 cc::DisplayItemList::Create(cc::DisplayItemListSettings()); |
| 1108 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); | 1108 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); |
| 1109 v1->Reset(); | 1109 v1->Reset(); |
| 1110 v2->Reset(); | 1110 v2->Reset(); |
| 1111 | 1111 |
| 1112 // Intersects with the first child only. | 1112 // Intersects with the first child only. |
| 1113 gfx::Rect paint_area(3, 10, 1, 2); | 1113 gfx::Rect paint_area(3, 10, 1, 2); |
| 1114 gfx::Rect root_area(root_view->size()); | 1114 gfx::Rect root_area(root_view->size()); |
| 1115 list = cc::DisplayItemList::Create(root_area, cc::DisplayItemListSettings()); | 1115 list = cc::DisplayItemList::Create(cc::DisplayItemListSettings()); |
| 1116 | 1116 |
| 1117 EXPECT_FALSE(v1->did_paint_); | 1117 EXPECT_FALSE(v1->did_paint_); |
| 1118 EXPECT_FALSE(v2->did_paint_); | 1118 EXPECT_FALSE(v2->did_paint_); |
| 1119 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); | 1119 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); |
| 1120 EXPECT_TRUE(v1->did_paint_); | 1120 EXPECT_TRUE(v1->did_paint_); |
| 1121 EXPECT_FALSE(v2->did_paint_); | 1121 EXPECT_FALSE(v2->did_paint_); |
| 1122 | 1122 |
| 1123 // Intersects with the second child only. | 1123 // Intersects with the second child only. |
| 1124 paint_area = gfx::Rect(21, 3, 1, 2); | 1124 paint_area = gfx::Rect(21, 3, 1, 2); |
| 1125 | 1125 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1142 root_view->AddChildView(v1); | 1142 root_view->AddChildView(v1); |
| 1143 | 1143 |
| 1144 TestView* v2 = new TestView; | 1144 TestView* v2 = new TestView; |
| 1145 v2->SetBounds(3, 4, 6, 5); | 1145 v2->SetBounds(3, 4, 6, 5); |
| 1146 v1->AddChildView(v2); | 1146 v1->AddChildView(v2); |
| 1147 | 1147 |
| 1148 // Paint everything once, since it has to build its cache. Then we can test | 1148 // Paint everything once, since it has to build its cache. Then we can test |
| 1149 // invalidation. | 1149 // invalidation. |
| 1150 gfx::Rect first_paint(1, 1); | 1150 gfx::Rect first_paint(1, 1); |
| 1151 scoped_refptr<cc::DisplayItemList> list = | 1151 scoped_refptr<cc::DisplayItemList> list = |
| 1152 cc::DisplayItemList::Create(first_paint, cc::DisplayItemListSettings()); | 1152 cc::DisplayItemList::Create(cc::DisplayItemListSettings()); |
| 1153 v1->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); | 1153 v1->Paint(ui::PaintContext(list.get(), 1.f, first_paint)); |
| 1154 v1->Reset(); | 1154 v1->Reset(); |
| 1155 v2->Reset(); | 1155 v2->Reset(); |
| 1156 | 1156 |
| 1157 { | 1157 { |
| 1158 gfx::Rect paint_area(25, 26); | 1158 gfx::Rect paint_area(25, 26); |
| 1159 gfx::Rect view_area(root_view->size()); | 1159 gfx::Rect view_area(root_view->size()); |
| 1160 scoped_refptr<cc::DisplayItemList> list = | 1160 scoped_refptr<cc::DisplayItemList> list = |
| 1161 cc::DisplayItemList::Create(view_area, cc::DisplayItemListSettings()); | 1161 cc::DisplayItemList::Create(cc::DisplayItemListSettings()); |
| 1162 | 1162 |
| 1163 // The promoted views are not painted as they are separate paint roots. | 1163 // The promoted views are not painted as they are separate paint roots. |
| 1164 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); | 1164 root_view->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); |
| 1165 EXPECT_FALSE(v1->did_paint_); | 1165 EXPECT_FALSE(v1->did_paint_); |
| 1166 EXPECT_FALSE(v2->did_paint_); | 1166 EXPECT_FALSE(v2->did_paint_); |
| 1167 } | 1167 } |
| 1168 | 1168 |
| 1169 { | 1169 { |
| 1170 gfx::Rect paint_area(1, 1); | 1170 gfx::Rect paint_area(1, 1); |
| 1171 gfx::Rect view_area(v1->size()); | 1171 gfx::Rect view_area(v1->size()); |
| 1172 scoped_refptr<cc::DisplayItemList> list = | 1172 scoped_refptr<cc::DisplayItemList> list = |
| 1173 cc::DisplayItemList::Create(view_area, cc::DisplayItemListSettings()); | 1173 cc::DisplayItemList::Create(cc::DisplayItemListSettings()); |
| 1174 | 1174 |
| 1175 // The |v1| view is painted. If it used its offset incorrect, it would think | 1175 // The |v1| view is painted. If it used its offset incorrect, it would think |
| 1176 // its at (10,11) instead of at (0,0) since it is the paint root. | 1176 // its at (10,11) instead of at (0,0) since it is the paint root. |
| 1177 v1->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); | 1177 v1->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); |
| 1178 EXPECT_TRUE(v1->did_paint_); | 1178 EXPECT_TRUE(v1->did_paint_); |
| 1179 EXPECT_FALSE(v2->did_paint_); | 1179 EXPECT_FALSE(v2->did_paint_); |
| 1180 } | 1180 } |
| 1181 | 1181 |
| 1182 v1->Reset(); | 1182 v1->Reset(); |
| 1183 | 1183 |
| 1184 { | 1184 { |
| 1185 gfx::Rect paint_area(3, 3, 1, 2); | 1185 gfx::Rect paint_area(3, 3, 1, 2); |
| 1186 gfx::Rect view_area(v1->size()); | 1186 gfx::Rect view_area(v1->size()); |
| 1187 scoped_refptr<cc::DisplayItemList> list = | 1187 scoped_refptr<cc::DisplayItemList> list = |
| 1188 cc::DisplayItemList::Create(view_area, cc::DisplayItemListSettings()); | 1188 cc::DisplayItemList::Create(cc::DisplayItemListSettings()); |
| 1189 | 1189 |
| 1190 // The |v2| view is painted also. If it used its offset incorrect, it would | 1190 // The |v2| view is painted also. If it used its offset incorrect, it would |
| 1191 // think its at (13,15) instead of at (3,4) since |v1| is the paint root. | 1191 // think its at (13,15) instead of at (3,4) since |v1| is the paint root. |
| 1192 v1->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); | 1192 v1->Paint(ui::PaintContext(list.get(), 1.f, paint_area)); |
| 1193 EXPECT_TRUE(v1->did_paint_); | 1193 EXPECT_TRUE(v1->did_paint_); |
| 1194 EXPECT_TRUE(v2->did_paint_); | 1194 EXPECT_TRUE(v2->did_paint_); |
| 1195 } | 1195 } |
| 1196 } | 1196 } |
| 1197 | 1197 |
| 1198 // A derived class for testing paint. | 1198 // A derived class for testing paint. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1225 | 1225 |
| 1226 // Set bounds for |v1| such that it has an offset to its parent and only part | 1226 // Set bounds for |v1| such that it has an offset to its parent and only part |
| 1227 // of it is visible. The visible bounds does not intersect with |root_view|'s | 1227 // of it is visible. The visible bounds does not intersect with |root_view|'s |
| 1228 // bounds. | 1228 // bounds. |
| 1229 v1->SetBounds(0, -1000, 100, 1100); | 1229 v1->SetBounds(0, -1000, 100, 1100); |
| 1230 root_view->AddChildView(v1); | 1230 root_view->AddChildView(v1); |
| 1231 EXPECT_EQ(gfx::Rect(0, 0, 100, 1100), v1->GetLocalBounds()); | 1231 EXPECT_EQ(gfx::Rect(0, 0, 100, 1100), v1->GetLocalBounds()); |
| 1232 EXPECT_EQ(gfx::Rect(0, 1000, 100, 100), v1->GetVisibleBounds()); | 1232 EXPECT_EQ(gfx::Rect(0, 1000, 100, 100), v1->GetVisibleBounds()); |
| 1233 | 1233 |
| 1234 scoped_refptr<cc::DisplayItemList> list = | 1234 scoped_refptr<cc::DisplayItemList> list = |
| 1235 cc::DisplayItemList::Create(gfx::Rect(), cc::DisplayItemListSettings()); | 1235 cc::DisplayItemList::Create(cc::DisplayItemListSettings()); |
| 1236 ui::PaintContext context(list.get(), 1.f, gfx::Rect()); | 1236 ui::PaintContext context(list.get(), 1.f, gfx::Rect()); |
| 1237 | 1237 |
| 1238 v1->Paint(context); | 1238 v1->Paint(context); |
| 1239 EXPECT_TRUE(v1->did_paint_); | 1239 EXPECT_TRUE(v1->did_paint_); |
| 1240 | 1240 |
| 1241 // Check that the canvas produced by |v1| for paint contains all of |v1|'s | 1241 // Check that the canvas produced by |v1| for paint contains all of |v1|'s |
| 1242 // visible bounds. | 1242 // visible bounds. |
| 1243 EXPECT_TRUE(v1->canvas_bounds().Contains(v1->GetVisibleBounds())); | 1243 EXPECT_TRUE(v1->canvas_bounds().Contains(v1->GetVisibleBounds())); |
| 1244 } | 1244 } |
| 1245 | 1245 |
| (...skipping 3099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4345 | 4345 |
| 4346 // The View should continue receiving events after the |handler| is deleted. | 4346 // The View should continue receiving events after the |handler| is deleted. |
| 4347 v->Reset(); | 4347 v->Reset(); |
| 4348 ui::MouseEvent released(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), | 4348 ui::MouseEvent released(ui::ET_MOUSE_RELEASED, gfx::Point(), gfx::Point(), |
| 4349 ui::EventTimeForNow(), 0, 0); | 4349 ui::EventTimeForNow(), 0, 0); |
| 4350 root->OnMouseReleased(released); | 4350 root->OnMouseReleased(released); |
| 4351 EXPECT_EQ(ui::ET_MOUSE_RELEASED, v->last_mouse_event_type_); | 4351 EXPECT_EQ(ui::ET_MOUSE_RELEASED, v->last_mouse_event_type_); |
| 4352 } | 4352 } |
| 4353 | 4353 |
| 4354 } // namespace views | 4354 } // namespace views |
| OLD | NEW |