OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/layers/picture_layer_impl.h" | 5 #include "cc/layers/picture_layer_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 viewport_rect_for_tile_priority, | 421 viewport_rect_for_tile_priority, |
422 transform_for_tile_priority, | 422 transform_for_tile_priority, |
423 resourceless_software_draw); | 423 resourceless_software_draw); |
424 host_impl_.active_tree()->UpdateDrawProperties(); | 424 host_impl_.active_tree()->UpdateDrawProperties(); |
425 | 425 |
426 gfx::Rect viewport_rect_for_tile_priority_in_view_space = | 426 gfx::Rect viewport_rect_for_tile_priority_in_view_space = |
427 viewport_rect_for_tile_priority; | 427 viewport_rect_for_tile_priority; |
428 | 428 |
429 // Verify the viewport rect for tile priority is used in picture layer tiling. | 429 // Verify the viewport rect for tile priority is used in picture layer tiling. |
430 EXPECT_EQ(viewport_rect_for_tile_priority_in_view_space, | 430 EXPECT_EQ(viewport_rect_for_tile_priority_in_view_space, |
431 active_layer_->GetViewportForTilePriorityInContentSpace()); | 431 active_layer_->viewport_rect_for_tile_priority_in_content_space()); |
432 PictureLayerTilingSet* tilings = active_layer_->tilings(); | 432 PictureLayerTilingSet* tilings = active_layer_->tilings(); |
433 for (size_t i = 0; i < tilings->num_tilings(); i++) { | 433 for (size_t i = 0; i < tilings->num_tilings(); i++) { |
434 PictureLayerTiling* tiling = tilings->tiling_at(i); | 434 PictureLayerTiling* tiling = tilings->tiling_at(i); |
435 EXPECT_EQ( | 435 EXPECT_EQ( |
436 tiling->GetCurrentVisibleRectForTesting(), | 436 tiling->GetCurrentVisibleRectForTesting(), |
437 gfx::ScaleToEnclosingRect(viewport_rect_for_tile_priority_in_view_space, | 437 gfx::ScaleToEnclosingRect(viewport_rect_for_tile_priority_in_view_space, |
438 tiling->contents_scale())); | 438 tiling->contents_scale())); |
439 } | 439 } |
440 | 440 |
441 // Update tiles with viewport for tile priority as (200, 200, 100, 100) in | 441 // Update tiles with viewport for tile priority as (200, 200, 100, 100) in |
(...skipping 21 matching lines...) Expand all Loading... |
463 | 463 |
464 // Note that we don't clip this to the layer bounds, since it is expected that | 464 // Note that we don't clip this to the layer bounds, since it is expected that |
465 // the rect will sometimes be outside of the layer bounds. If we clip to | 465 // the rect will sometimes be outside of the layer bounds. If we clip to |
466 // bounds, then tile priorities will end up being incorrect in cases of fully | 466 // bounds, then tile priorities will end up being incorrect in cases of fully |
467 // offscreen layer. | 467 // offscreen layer. |
468 viewport_rect_for_tile_priority_in_view_space = | 468 viewport_rect_for_tile_priority_in_view_space = |
469 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( | 469 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( |
470 screen_to_view, viewport_rect_for_tile_priority)); | 470 screen_to_view, viewport_rect_for_tile_priority)); |
471 | 471 |
472 EXPECT_EQ(viewport_rect_for_tile_priority_in_view_space, | 472 EXPECT_EQ(viewport_rect_for_tile_priority_in_view_space, |
473 active_layer_->GetViewportForTilePriorityInContentSpace()); | 473 active_layer_->viewport_rect_for_tile_priority_in_content_space()); |
474 tilings = active_layer_->tilings(); | 474 tilings = active_layer_->tilings(); |
475 for (size_t i = 0; i < tilings->num_tilings(); i++) { | 475 for (size_t i = 0; i < tilings->num_tilings(); i++) { |
476 PictureLayerTiling* tiling = tilings->tiling_at(i); | 476 PictureLayerTiling* tiling = tilings->tiling_at(i); |
477 EXPECT_EQ( | 477 EXPECT_EQ( |
478 tiling->GetCurrentVisibleRectForTesting(), | 478 tiling->GetCurrentVisibleRectForTesting(), |
479 gfx::ScaleToEnclosingRect(viewport_rect_for_tile_priority_in_view_space, | 479 gfx::ScaleToEnclosingRect(viewport_rect_for_tile_priority_in_view_space, |
480 tiling->contents_scale())); | 480 tiling->contents_scale())); |
481 } | 481 } |
482 } | 482 } |
483 | 483 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 viewport, | 557 viewport, |
558 transform, | 558 transform, |
559 resourceless_software_draw); | 559 resourceless_software_draw); |
560 active_layer_->UpdateTiles(Occlusion(), resourceless_software_draw); | 560 active_layer_->UpdateTiles(Occlusion(), resourceless_software_draw); |
561 | 561 |
562 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, | 562 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, |
563 active_layer_->screen_space_transform()); | 563 active_layer_->screen_space_transform()); |
564 EXPECT_EQ(viewport, active_layer_->visible_rect_for_tile_priority()); | 564 EXPECT_EQ(viewport, active_layer_->visible_rect_for_tile_priority()); |
565 } | 565 } |
566 | 566 |
| 567 TEST_F(PictureLayerImplTest, ViewportRectForTilePriorityIsCached) { |
| 568 base::TimeTicks time_ticks; |
| 569 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| 570 host_impl_.SetCurrentBeginFrameArgs( |
| 571 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 572 gfx::Size tile_size(100, 100); |
| 573 gfx::Size layer_bounds(400, 400); |
| 574 |
| 575 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 576 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 577 scoped_refptr<FakePicturePileImpl> active_pile = |
| 578 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 579 |
| 580 SetupTreesWithInvalidation(pending_pile, active_pile, Region()); |
| 581 |
| 582 SetupDrawPropertiesAndUpdateTiles(active_layer_, 1.f, 1.f, 1.f, 1.f, false); |
| 583 |
| 584 time_ticks += base::TimeDelta::FromMilliseconds(200); |
| 585 host_impl_.SetCurrentBeginFrameArgs( |
| 586 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 587 |
| 588 bool resourceless_software_draw = false; |
| 589 gfx::Rect viewport = gfx::Rect(layer_bounds); |
| 590 gfx::Rect viewport_rect_for_tile_priority(0, 0, 100, 100); |
| 591 gfx::Transform transform, transform_for_tile_priority; |
| 592 |
| 593 host_impl_.SetExternalDrawConstraints( |
| 594 transform, viewport, viewport, viewport_rect_for_tile_priority, |
| 595 transform_for_tile_priority, resourceless_software_draw); |
| 596 host_impl_.active_tree()->UpdateDrawProperties(); |
| 597 |
| 598 EXPECT_EQ(viewport_rect_for_tile_priority, |
| 599 active_layer_->viewport_rect_for_tile_priority_in_content_space()); |
| 600 |
| 601 time_ticks += base::TimeDelta::FromMilliseconds(200); |
| 602 host_impl_.SetCurrentBeginFrameArgs( |
| 603 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 604 |
| 605 gfx::Rect another_viewport_rect_for_tile_priority(11, 11, 50, 50); |
| 606 host_impl_.SetExternalDrawConstraints( |
| 607 transform, viewport, viewport, another_viewport_rect_for_tile_priority, |
| 608 transform_for_tile_priority, resourceless_software_draw); |
| 609 |
| 610 // Didn't call UpdateDrawProperties yet. The viewport rect for tile priority |
| 611 // should remain to be the previously cached value. |
| 612 EXPECT_EQ(viewport_rect_for_tile_priority, |
| 613 active_layer_->viewport_rect_for_tile_priority_in_content_space()); |
| 614 host_impl_.active_tree()->UpdateDrawProperties(); |
| 615 |
| 616 // Now the UpdateDrawProperties is called. The viewport rect for tile |
| 617 // priority should be the latest value. |
| 618 EXPECT_EQ(another_viewport_rect_for_tile_priority, |
| 619 active_layer_->viewport_rect_for_tile_priority_in_content_space()); |
| 620 } |
| 621 |
567 TEST_F(PictureLayerImplTest, ClonePartialInvalidation) { | 622 TEST_F(PictureLayerImplTest, ClonePartialInvalidation) { |
568 gfx::Size tile_size(100, 100); | 623 gfx::Size tile_size(100, 100); |
569 gfx::Size layer_bounds(400, 400); | 624 gfx::Size layer_bounds(400, 400); |
570 gfx::Rect layer_invalidation(150, 200, 30, 180); | 625 gfx::Rect layer_invalidation(150, 200, 30, 180); |
571 | 626 |
572 scoped_refptr<FakePicturePileImpl> pending_pile = | 627 scoped_refptr<FakePicturePileImpl> pending_pile = |
573 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 628 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
574 scoped_refptr<FakePicturePileImpl> active_pile = | 629 scoped_refptr<FakePicturePileImpl> active_pile = |
575 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 630 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
576 scoped_refptr<FakePicturePileImpl> lost_pile = | 631 scoped_refptr<FakePicturePileImpl> lost_pile = |
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1674 // external_viewport_for_tile_priority. | 1729 // external_viewport_for_tile_priority. |
1675 pending_layer_->draw_properties().visible_content_rect = visible_content_rect; | 1730 pending_layer_->draw_properties().visible_content_rect = visible_content_rect; |
1676 time_ticks += base::TimeDelta::FromMilliseconds(200); | 1731 time_ticks += base::TimeDelta::FromMilliseconds(200); |
1677 host_impl_.SetCurrentBeginFrameArgs( | 1732 host_impl_.SetCurrentBeginFrameArgs( |
1678 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 1733 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
1679 pending_layer_->UpdateTiles(Occlusion(), resourceless_software_draw); | 1734 pending_layer_->UpdateTiles(Occlusion(), resourceless_software_draw); |
1680 | 1735 |
1681 // Intersect the two rects. Any tile outside should not be required for | 1736 // Intersect the two rects. Any tile outside should not be required for |
1682 // activation. | 1737 // activation. |
1683 gfx::Rect viewport_for_tile_priority = | 1738 gfx::Rect viewport_for_tile_priority = |
1684 pending_layer_->GetViewportForTilePriorityInContentSpace(); | 1739 pending_layer_->viewport_rect_for_tile_priority_in_content_space(); |
1685 viewport_for_tile_priority.Intersect(pending_layer_->visible_content_rect()); | 1740 viewport_for_tile_priority.Intersect(pending_layer_->visible_content_rect()); |
1686 | 1741 |
1687 int num_inside = 0; | 1742 int num_inside = 0; |
1688 int num_outside = 0; | 1743 int num_outside = 0; |
1689 for (PictureLayerTiling::CoverageIterator iter( | 1744 for (PictureLayerTiling::CoverageIterator iter( |
1690 pending_layer_->HighResTiling(), 1.f, gfx::Rect(layer_bounds)); | 1745 pending_layer_->HighResTiling(), 1.f, gfx::Rect(layer_bounds)); |
1691 iter; ++iter) { | 1746 iter; ++iter) { |
1692 if (!*iter) | 1747 if (!*iter) |
1693 continue; | 1748 continue; |
1694 Tile* tile = *iter; | 1749 Tile* tile = *iter; |
(...skipping 3129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4824 result = layer->CalculateTileSize(gfx::Size(447, 400)); | 4879 result = layer->CalculateTileSize(gfx::Size(447, 400)); |
4825 EXPECT_EQ(result.width(), 448); | 4880 EXPECT_EQ(result.width(), 448); |
4826 EXPECT_EQ(result.height(), 448); | 4881 EXPECT_EQ(result.height(), 448); |
4827 result = layer->CalculateTileSize(gfx::Size(500, 499)); | 4882 result = layer->CalculateTileSize(gfx::Size(500, 499)); |
4828 EXPECT_EQ(result.width(), 512); | 4883 EXPECT_EQ(result.width(), 512); |
4829 EXPECT_EQ(result.height(), 500 + 2); | 4884 EXPECT_EQ(result.height(), 500 + 2); |
4830 } | 4885 } |
4831 | 4886 |
4832 } // namespace | 4887 } // namespace |
4833 } // namespace cc | 4888 } // namespace cc |
OLD | NEW |