| 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 float maximum_animation_contents_scale, | 233 float maximum_animation_contents_scale, |
| 234 bool animating_transform_to_screen) { | 234 bool animating_transform_to_screen) { |
| 235 layer->draw_properties().ideal_contents_scale = ideal_contents_scale; | 235 layer->draw_properties().ideal_contents_scale = ideal_contents_scale; |
| 236 layer->draw_properties().device_scale_factor = device_scale_factor; | 236 layer->draw_properties().device_scale_factor = device_scale_factor; |
| 237 layer->draw_properties().page_scale_factor = page_scale_factor; | 237 layer->draw_properties().page_scale_factor = page_scale_factor; |
| 238 layer->draw_properties().maximum_animation_contents_scale = | 238 layer->draw_properties().maximum_animation_contents_scale = |
| 239 maximum_animation_contents_scale; | 239 maximum_animation_contents_scale; |
| 240 layer->draw_properties().screen_space_transform_is_animating = | 240 layer->draw_properties().screen_space_transform_is_animating = |
| 241 animating_transform_to_screen; | 241 animating_transform_to_screen; |
| 242 bool resourceless_software_draw = false; | 242 bool resourceless_software_draw = false; |
| 243 layer->UpdateTiles(Occlusion(), resourceless_software_draw); | 243 layer->UpdateTiles(resourceless_software_draw); |
| 244 } | 244 } |
| 245 static void VerifyAllTilesExistAndHavePile( | 245 static void VerifyAllTilesExistAndHavePile( |
| 246 const PictureLayerTiling* tiling, | 246 const PictureLayerTiling* tiling, |
| 247 PicturePileImpl* pile) { | 247 PicturePileImpl* pile) { |
| 248 for (PictureLayerTiling::CoverageIterator iter( | 248 for (PictureLayerTiling::CoverageIterator iter( |
| 249 tiling, | 249 tiling, |
| 250 tiling->contents_scale(), | 250 tiling->contents_scale(), |
| 251 gfx::Rect(tiling->tiling_size())); | 251 gfx::Rect(tiling->tiling_size())); |
| 252 iter; | 252 iter; |
| 253 ++iter) { | 253 ++iter) { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 }; | 325 }; |
| 326 | 326 |
| 327 TEST_F(PictureLayerImplTest, TileGridAlignment) { | 327 TEST_F(PictureLayerImplTest, TileGridAlignment) { |
| 328 // Layer to span 4 raster tiles in x and in y | 328 // Layer to span 4 raster tiles in x and in y |
| 329 ImplSidePaintingSettings settings; | 329 ImplSidePaintingSettings settings; |
| 330 gfx::Size layer_size(settings.default_tile_size.width() * 7 / 2, | 330 gfx::Size layer_size(settings.default_tile_size.width() * 7 / 2, |
| 331 settings.default_tile_size.height() * 7 / 2); | 331 settings.default_tile_size.height() * 7 / 2); |
| 332 | 332 |
| 333 scoped_refptr<FakePicturePileImpl> pending_pile = | 333 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 334 FakePicturePileImpl::CreateFilledPile(layer_size, layer_size); | 334 FakePicturePileImpl::CreateFilledPile(layer_size, layer_size); |
| 335 |
| 336 scoped_ptr<FakePicturePile> active_recording = |
| 337 FakePicturePile::CreateFilledPile(layer_size, layer_size); |
| 335 scoped_refptr<FakePicturePileImpl> active_pile = | 338 scoped_refptr<FakePicturePileImpl> active_pile = |
| 336 FakePicturePileImpl::CreateFilledPile(layer_size, layer_size); | 339 FakePicturePileImpl::CreateFromPile(active_recording.get(), nullptr); |
| 337 | 340 |
| 338 SetupTrees(pending_pile, active_pile); | 341 SetupTrees(pending_pile, active_pile); |
| 339 | 342 |
| 340 // Add 1x1 rects at the centers of each tile, then re-record pile contents | 343 // Add 1x1 rects at the centers of each tile, then re-record pile contents |
| 341 active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); | 344 active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
| 342 std::vector<Tile*> tiles = | 345 std::vector<Tile*> tiles = |
| 343 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); | 346 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); |
| 344 EXPECT_EQ(16u, tiles.size()); | 347 EXPECT_EQ(16u, tiles.size()); |
| 345 std::vector<SkRect> rects; | 348 std::vector<SkRect> rects; |
| 346 std::vector<Tile*>::const_iterator tile_iter; | 349 std::vector<Tile*>::const_iterator tile_iter; |
| 347 for (tile_iter = tiles.begin(); tile_iter < tiles.end(); tile_iter++) { | 350 for (tile_iter = tiles.begin(); tile_iter < tiles.end(); tile_iter++) { |
| 348 gfx::Point tile_center = (*tile_iter)->content_rect().CenterPoint(); | 351 gfx::Point tile_center = (*tile_iter)->content_rect().CenterPoint(); |
| 349 gfx::Rect rect(tile_center.x(), tile_center.y(), 1, 1); | 352 gfx::Rect rect(tile_center.x(), tile_center.y(), 1, 1); |
| 350 active_pile->add_draw_rect(rect); | 353 active_recording->add_draw_rect(rect); |
| 351 rects.push_back(SkRect::MakeXYWH(rect.x(), rect.y(), 1, 1)); | 354 rects.push_back(SkRect::MakeXYWH(rect.x(), rect.y(), 1, 1)); |
| 352 } | 355 } |
| 356 |
| 353 // Force re-raster with newly injected content | 357 // Force re-raster with newly injected content |
| 354 active_pile->RemoveRecordingAt(0, 0); | 358 active_recording->RemoveRecordingAt(0, 0); |
| 355 active_pile->AddRecordingAt(0, 0); | 359 active_recording->AddRecordingAt(0, 0); |
| 360 |
| 361 scoped_refptr<FakePicturePileImpl> updated_active_pile = |
| 362 FakePicturePileImpl::CreateFromPile(active_recording.get(), nullptr); |
| 356 | 363 |
| 357 std::vector<SkRect>::const_iterator rect_iter = rects.begin(); | 364 std::vector<SkRect>::const_iterator rect_iter = rects.begin(); |
| 358 for (tile_iter = tiles.begin(); tile_iter < tiles.end(); tile_iter++) { | 365 for (tile_iter = tiles.begin(); tile_iter < tiles.end(); tile_iter++) { |
| 359 MockCanvas mock_canvas(1000, 1000); | 366 MockCanvas mock_canvas(1000, 1000); |
| 360 active_pile->PlaybackToSharedCanvas(&mock_canvas, | 367 updated_active_pile->PlaybackToSharedCanvas( |
| 361 (*tile_iter)->content_rect(), 1.0f); | 368 &mock_canvas, (*tile_iter)->content_rect(), 1.0f); |
| 362 | 369 |
| 363 // This test verifies that when drawing the contents of a specific tile | 370 // This test verifies that when drawing the contents of a specific tile |
| 364 // at content scale 1.0, the playback canvas never receives content from | 371 // at content scale 1.0, the playback canvas never receives content from |
| 365 // neighboring tiles which indicates that the tile grid embedded in | 372 // neighboring tiles which indicates that the tile grid embedded in |
| 366 // SkPicture is perfectly aligned with the compositor's tiles. | 373 // SkPicture is perfectly aligned with the compositor's tiles. |
| 367 EXPECT_EQ(1u, mock_canvas.rects_.size()); | 374 EXPECT_EQ(1u, mock_canvas.rects_.size()); |
| 368 EXPECT_EQ(*rect_iter, mock_canvas.rects_[0]); | 375 EXPECT_EQ(*rect_iter, mock_canvas.rects_[0]); |
| 369 rect_iter++; | 376 rect_iter++; |
| 370 } | 377 } |
| 371 } | 378 } |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 gfx::Rect viewport = gfx::Rect(layer_bounds); | 516 gfx::Rect viewport = gfx::Rect(layer_bounds); |
| 510 gfx::Transform transform; | 517 gfx::Transform transform; |
| 511 host_impl_.SetExternalDrawConstraints(transform, | 518 host_impl_.SetExternalDrawConstraints(transform, |
| 512 viewport, | 519 viewport, |
| 513 viewport, | 520 viewport, |
| 514 viewport, | 521 viewport, |
| 515 transform, | 522 transform, |
| 516 resourceless_software_draw); | 523 resourceless_software_draw); |
| 517 active_layer_->draw_properties().visible_content_rect = viewport; | 524 active_layer_->draw_properties().visible_content_rect = viewport; |
| 518 active_layer_->draw_properties().screen_space_transform = transform; | 525 active_layer_->draw_properties().screen_space_transform = transform; |
| 519 active_layer_->UpdateTiles(Occlusion(), resourceless_software_draw); | 526 active_layer_->UpdateTiles(resourceless_software_draw); |
| 520 | 527 |
| 521 gfx::Rect visible_rect_for_tile_priority = | 528 gfx::Rect visible_rect_for_tile_priority = |
| 522 active_layer_->visible_rect_for_tile_priority(); | 529 active_layer_->visible_rect_for_tile_priority(); |
| 523 EXPECT_FALSE(visible_rect_for_tile_priority.IsEmpty()); | 530 EXPECT_FALSE(visible_rect_for_tile_priority.IsEmpty()); |
| 524 gfx::Transform screen_space_transform_for_tile_priority = | 531 gfx::Transform screen_space_transform_for_tile_priority = |
| 525 active_layer_->screen_space_transform(); | 532 active_layer_->screen_space_transform(); |
| 526 | 533 |
| 527 // Expand viewport and set it as invalid for prioritizing tiles. | 534 // Expand viewport and set it as invalid for prioritizing tiles. |
| 528 // Should update viewport and transform, but not update visible rect. | 535 // Should update viewport and transform, but not update visible rect. |
| 529 time_ticks += base::TimeDelta::FromMilliseconds(200); | 536 time_ticks += base::TimeDelta::FromMilliseconds(200); |
| 530 host_impl_.SetCurrentBeginFrameArgs( | 537 host_impl_.SetCurrentBeginFrameArgs( |
| 531 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 538 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 532 resourceless_software_draw = true; | 539 resourceless_software_draw = true; |
| 533 viewport = gfx::ScaleToEnclosingRect(viewport, 2); | 540 viewport = gfx::ScaleToEnclosingRect(viewport, 2); |
| 534 transform.Translate(1.f, 1.f); | 541 transform.Translate(1.f, 1.f); |
| 535 active_layer_->draw_properties().visible_content_rect = viewport; | 542 active_layer_->draw_properties().visible_content_rect = viewport; |
| 536 active_layer_->draw_properties().screen_space_transform = transform; | 543 active_layer_->draw_properties().screen_space_transform = transform; |
| 537 host_impl_.SetExternalDrawConstraints(transform, | 544 host_impl_.SetExternalDrawConstraints(transform, |
| 538 viewport, | 545 viewport, |
| 539 viewport, | 546 viewport, |
| 540 viewport, | 547 viewport, |
| 541 transform, | 548 transform, |
| 542 resourceless_software_draw); | 549 resourceless_software_draw); |
| 543 active_layer_->UpdateTiles(Occlusion(), resourceless_software_draw); | 550 active_layer_->UpdateTiles(resourceless_software_draw); |
| 544 | 551 |
| 545 // Transform for tile priority is updated. | 552 // Transform for tile priority is updated. |
| 546 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, | 553 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, |
| 547 active_layer_->screen_space_transform()); | 554 active_layer_->screen_space_transform()); |
| 548 // Visible rect for tile priority retains old value. | 555 // Visible rect for tile priority retains old value. |
| 549 EXPECT_EQ(visible_rect_for_tile_priority, | 556 EXPECT_EQ(visible_rect_for_tile_priority, |
| 550 active_layer_->visible_rect_for_tile_priority()); | 557 active_layer_->visible_rect_for_tile_priority()); |
| 551 | 558 |
| 552 // Keep expanded viewport but mark it valid. Should update tile viewport. | 559 // Keep expanded viewport but mark it valid. Should update tile viewport. |
| 553 time_ticks += base::TimeDelta::FromMilliseconds(200); | 560 time_ticks += base::TimeDelta::FromMilliseconds(200); |
| 554 host_impl_.SetCurrentBeginFrameArgs( | 561 host_impl_.SetCurrentBeginFrameArgs( |
| 555 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 562 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 556 resourceless_software_draw = false; | 563 resourceless_software_draw = false; |
| 557 host_impl_.SetExternalDrawConstraints(transform, | 564 host_impl_.SetExternalDrawConstraints(transform, |
| 558 viewport, | 565 viewport, |
| 559 viewport, | 566 viewport, |
| 560 viewport, | 567 viewport, |
| 561 transform, | 568 transform, |
| 562 resourceless_software_draw); | 569 resourceless_software_draw); |
| 563 active_layer_->UpdateTiles(Occlusion(), resourceless_software_draw); | 570 active_layer_->UpdateTiles(resourceless_software_draw); |
| 564 | 571 |
| 565 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, | 572 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, |
| 566 active_layer_->screen_space_transform()); | 573 active_layer_->screen_space_transform()); |
| 567 EXPECT_EQ(viewport, active_layer_->visible_rect_for_tile_priority()); | 574 EXPECT_EQ(viewport, active_layer_->visible_rect_for_tile_priority()); |
| 568 } | 575 } |
| 569 | 576 |
| 570 TEST_F(PictureLayerImplTest, ViewportRectForTilePriorityIsCached) { | 577 TEST_F(PictureLayerImplTest, ViewportRectForTilePriorityIsCached) { |
| 571 base::TimeTicks time_ticks; | 578 base::TimeTicks time_ticks; |
| 572 time_ticks += base::TimeDelta::FromMilliseconds(1); | 579 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| 573 host_impl_.SetCurrentBeginFrameArgs( | 580 host_impl_.SetCurrentBeginFrameArgs( |
| (...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1609 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1616 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1610 | 1617 |
| 1611 gfx::Rect layer_invalidation(150, 200, 30, 180); | 1618 gfx::Rect layer_invalidation(150, 200, 30, 180); |
| 1612 SetupTreesWithInvalidation(pending_pile, active_pile, layer_invalidation); | 1619 SetupTreesWithInvalidation(pending_pile, active_pile, layer_invalidation); |
| 1613 | 1620 |
| 1614 active_layer_->draw_properties().visible_content_rect = | 1621 active_layer_->draw_properties().visible_content_rect = |
| 1615 gfx::Rect(layer_bounds); | 1622 gfx::Rect(layer_bounds); |
| 1616 | 1623 |
| 1617 AppendQuadsData data; | 1624 AppendQuadsData data; |
| 1618 active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, nullptr); | 1625 active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, nullptr); |
| 1619 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data); | 1626 active_layer_->AppendQuads(render_pass.get(), &data); |
| 1620 active_layer_->DidDraw(nullptr); | 1627 active_layer_->DidDraw(nullptr); |
| 1621 | 1628 |
| 1622 ASSERT_EQ(1U, render_pass->quad_list.size()); | 1629 ASSERT_EQ(1U, render_pass->quad_list.size()); |
| 1623 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, | 1630 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, |
| 1624 render_pass->quad_list.front()->material); | 1631 render_pass->quad_list.front()->material); |
| 1625 } | 1632 } |
| 1626 | 1633 |
| 1627 TEST_F(PictureLayerImplTest, SolidColorLayerHasVisibleFullCoverage) { | 1634 TEST_F(PictureLayerImplTest, SolidColorLayerHasVisibleFullCoverage) { |
| 1628 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 1635 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 1629 | 1636 |
| 1630 gfx::Size tile_size(1000, 1000); | 1637 gfx::Size tile_size(1000, 1000); |
| 1631 gfx::Size layer_bounds(1500, 1500); | 1638 gfx::Size layer_bounds(1500, 1500); |
| 1632 gfx::Rect visible_rect(250, 250, 1000, 1000); | 1639 gfx::Rect visible_rect(250, 250, 1000, 1000); |
| 1633 | 1640 |
| 1641 scoped_ptr<FakePicturePile> empty_recording = |
| 1642 FakePicturePile::CreateEmptyPile(tile_size, layer_bounds); |
| 1643 empty_recording->SetIsSolidColor(true); |
| 1644 |
| 1634 scoped_refptr<FakePicturePileImpl> pending_pile = | 1645 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 1635 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); | 1646 FakePicturePileImpl::CreateFromPile(empty_recording.get(), nullptr); |
| 1636 scoped_refptr<FakePicturePileImpl> active_pile = | 1647 scoped_refptr<FakePicturePileImpl> active_pile = |
| 1637 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); | 1648 FakePicturePileImpl::CreateFromPile(empty_recording.get(), nullptr); |
| 1638 | |
| 1639 pending_pile->set_is_solid_color(true); | |
| 1640 active_pile->set_is_solid_color(true); | |
| 1641 | 1649 |
| 1642 SetupTrees(pending_pile, active_pile); | 1650 SetupTrees(pending_pile, active_pile); |
| 1643 | 1651 |
| 1644 active_layer_->draw_properties().visible_content_rect = visible_rect; | 1652 active_layer_->draw_properties().visible_content_rect = visible_rect; |
| 1645 | 1653 |
| 1646 AppendQuadsData data; | 1654 AppendQuadsData data; |
| 1647 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); | 1655 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); |
| 1648 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data); | 1656 active_layer_->AppendQuads(render_pass.get(), &data); |
| 1649 active_layer_->DidDraw(nullptr); | 1657 active_layer_->DidDraw(nullptr); |
| 1650 | 1658 |
| 1651 Region remaining = visible_rect; | 1659 Region remaining = visible_rect; |
| 1652 for (const auto& quad : render_pass->quad_list) { | 1660 for (const auto& quad : render_pass->quad_list) { |
| 1653 EXPECT_TRUE(visible_rect.Contains(quad->rect)); | 1661 EXPECT_TRUE(visible_rect.Contains(quad->rect)); |
| 1654 EXPECT_TRUE(remaining.Contains(quad->rect)); | 1662 EXPECT_TRUE(remaining.Contains(quad->rect)); |
| 1655 remaining.Subtract(quad->rect); | 1663 remaining.Subtract(quad->rect); |
| 1656 } | 1664 } |
| 1657 | 1665 |
| 1658 EXPECT_TRUE(remaining.IsEmpty()); | 1666 EXPECT_TRUE(remaining.IsEmpty()); |
| 1659 } | 1667 } |
| 1660 | 1668 |
| 1661 TEST_F(PictureLayerImplTest, TileScalesWithSolidColorPile) { | 1669 TEST_F(PictureLayerImplTest, TileScalesWithSolidColorPile) { |
| 1662 gfx::Size layer_bounds(200, 200); | 1670 gfx::Size layer_bounds(200, 200); |
| 1663 gfx::Size tile_size(host_impl_.settings().default_tile_size); | 1671 gfx::Size tile_size(host_impl_.settings().default_tile_size); |
| 1664 scoped_refptr<FakePicturePileImpl> pending_pile = | 1672 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 1665 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( | 1673 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( |
| 1666 tile_size, layer_bounds); | 1674 tile_size, layer_bounds, false); |
| 1667 scoped_refptr<FakePicturePileImpl> active_pile = | 1675 scoped_refptr<FakePicturePileImpl> active_pile = |
| 1668 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( | 1676 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( |
| 1669 tile_size, layer_bounds); | 1677 tile_size, layer_bounds, true); |
| 1670 | 1678 |
| 1671 pending_pile->set_is_solid_color(false); | |
| 1672 active_pile->set_is_solid_color(true); | |
| 1673 SetupTrees(pending_pile, active_pile); | 1679 SetupTrees(pending_pile, active_pile); |
| 1674 // Solid color pile should not allow tilings at any scale. | 1680 // Solid color pile should not allow tilings at any scale. |
| 1675 EXPECT_FALSE(active_layer_->CanHaveTilings()); | 1681 EXPECT_FALSE(active_layer_->CanHaveTilings()); |
| 1676 EXPECT_EQ(0.f, active_layer_->ideal_contents_scale()); | 1682 EXPECT_EQ(0.f, active_layer_->ideal_contents_scale()); |
| 1677 | 1683 |
| 1678 // Activate non-solid-color pending pile makes active layer can have tilings. | 1684 // Activate non-solid-color pending pile makes active layer can have tilings. |
| 1679 ActivateTree(); | 1685 ActivateTree(); |
| 1680 EXPECT_TRUE(active_layer_->CanHaveTilings()); | 1686 EXPECT_TRUE(active_layer_->CanHaveTilings()); |
| 1681 EXPECT_GT(active_layer_->ideal_contents_scale(), 0.f); | 1687 EXPECT_GT(active_layer_->ideal_contents_scale(), 0.f); |
| 1682 } | 1688 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1700 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1706 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1701 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); | 1707 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); |
| 1702 | 1708 |
| 1703 EXPECT_EQ(1u, pending_layer_->num_tilings()); | 1709 EXPECT_EQ(1u, pending_layer_->num_tilings()); |
| 1704 EXPECT_EQ(viewport, pending_layer_->visible_rect_for_tile_priority()); | 1710 EXPECT_EQ(viewport, pending_layer_->visible_rect_for_tile_priority()); |
| 1705 | 1711 |
| 1706 base::TimeTicks time_ticks; | 1712 base::TimeTicks time_ticks; |
| 1707 time_ticks += base::TimeDelta::FromMilliseconds(1); | 1713 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| 1708 host_impl_.SetCurrentBeginFrameArgs( | 1714 host_impl_.SetCurrentBeginFrameArgs( |
| 1709 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 1715 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 1710 pending_layer_->UpdateTiles(Occlusion(), resourceless_software_draw); | 1716 pending_layer_->UpdateTiles(resourceless_software_draw); |
| 1711 | 1717 |
| 1712 int num_visible = 0; | 1718 int num_visible = 0; |
| 1713 int num_offscreen = 0; | 1719 int num_offscreen = 0; |
| 1714 | 1720 |
| 1715 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( | 1721 scoped_ptr<TilingSetRasterQueueAll> queue(new TilingSetRasterQueueAll( |
| 1716 pending_layer_->picture_layer_tiling_set(), false)); | 1722 pending_layer_->picture_layer_tiling_set(), false)); |
| 1717 for (; !queue->IsEmpty(); queue->Pop()) { | 1723 for (; !queue->IsEmpty(); queue->Pop()) { |
| 1718 const Tile* tile = queue->Top(); | 1724 const Tile* tile = queue->Top(); |
| 1719 DCHECK(tile); | 1725 DCHECK(tile); |
| 1720 if (tile->priority(PENDING_TREE).distance_to_visible == 0.f) { | 1726 if (tile->priority(PENDING_TREE).distance_to_visible == 0.f) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1766 host_impl_.SetCurrentBeginFrameArgs( | 1772 host_impl_.SetCurrentBeginFrameArgs( |
| 1767 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 1773 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 1768 host_impl_.pending_tree()->UpdateDrawProperties(); | 1774 host_impl_.pending_tree()->UpdateDrawProperties(); |
| 1769 | 1775 |
| 1770 // Set visible content rect that is different from | 1776 // Set visible content rect that is different from |
| 1771 // external_viewport_for_tile_priority. | 1777 // external_viewport_for_tile_priority. |
| 1772 pending_layer_->draw_properties().visible_content_rect = visible_content_rect; | 1778 pending_layer_->draw_properties().visible_content_rect = visible_content_rect; |
| 1773 time_ticks += base::TimeDelta::FromMilliseconds(200); | 1779 time_ticks += base::TimeDelta::FromMilliseconds(200); |
| 1774 host_impl_.SetCurrentBeginFrameArgs( | 1780 host_impl_.SetCurrentBeginFrameArgs( |
| 1775 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 1781 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 1776 pending_layer_->UpdateTiles(Occlusion(), resourceless_software_draw); | 1782 pending_layer_->UpdateTiles(resourceless_software_draw); |
| 1777 | 1783 |
| 1778 // Intersect the two rects. Any tile outside should not be required for | 1784 // Intersect the two rects. Any tile outside should not be required for |
| 1779 // activation. | 1785 // activation. |
| 1780 gfx::Rect viewport_for_tile_priority = | 1786 gfx::Rect viewport_for_tile_priority = |
| 1781 pending_layer_->viewport_rect_for_tile_priority_in_content_space(); | 1787 pending_layer_->viewport_rect_for_tile_priority_in_content_space(); |
| 1782 viewport_for_tile_priority.Intersect(pending_layer_->visible_content_rect()); | 1788 viewport_for_tile_priority.Intersect(pending_layer_->visible_content_rect()); |
| 1783 | 1789 |
| 1784 int num_inside = 0; | 1790 int num_inside = 0; |
| 1785 int num_outside = 0; | 1791 int num_outside = 0; |
| 1786 for (PictureLayerTiling::CoverageIterator iter( | 1792 for (PictureLayerTiling::CoverageIterator iter( |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1804 EXPECT_GT(num_outside, 0); | 1810 EXPECT_GT(num_outside, 0); |
| 1805 | 1811 |
| 1806 // Activate and draw active layer. | 1812 // Activate and draw active layer. |
| 1807 host_impl_.ActivateSyncTree(); | 1813 host_impl_.ActivateSyncTree(); |
| 1808 host_impl_.active_tree()->UpdateDrawProperties(); | 1814 host_impl_.active_tree()->UpdateDrawProperties(); |
| 1809 active_layer_->draw_properties().visible_content_rect = visible_content_rect; | 1815 active_layer_->draw_properties().visible_content_rect = visible_content_rect; |
| 1810 | 1816 |
| 1811 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 1817 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 1812 AppendQuadsData data; | 1818 AppendQuadsData data; |
| 1813 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); | 1819 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); |
| 1814 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data); | 1820 active_layer_->AppendQuads(render_pass.get(), &data); |
| 1815 active_layer_->DidDraw(nullptr); | 1821 active_layer_->DidDraw(nullptr); |
| 1816 | 1822 |
| 1817 // All tiles in activation rect is ready to draw. | 1823 // All tiles in activation rect is ready to draw. |
| 1818 EXPECT_EQ(0u, data.num_missing_tiles); | 1824 EXPECT_EQ(0u, data.num_missing_tiles); |
| 1819 EXPECT_EQ(0u, data.num_incomplete_tiles); | 1825 EXPECT_EQ(0u, data.num_incomplete_tiles); |
| 1820 EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads()); | 1826 EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads()); |
| 1821 } | 1827 } |
| 1822 | 1828 |
| 1823 TEST_F(PictureLayerImplTest, HighResTileIsComplete) { | 1829 TEST_F(PictureLayerImplTest, HighResTileIsComplete) { |
| 1824 base::TimeTicks time_ticks; | 1830 base::TimeTicks time_ticks; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1836 ActivateTree(); | 1842 ActivateTree(); |
| 1837 | 1843 |
| 1838 // All high res tiles have resources. | 1844 // All high res tiles have resources. |
| 1839 std::vector<Tile*> tiles = | 1845 std::vector<Tile*> tiles = |
| 1840 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); | 1846 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); |
| 1841 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); | 1847 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); |
| 1842 | 1848 |
| 1843 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 1849 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 1844 AppendQuadsData data; | 1850 AppendQuadsData data; |
| 1845 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); | 1851 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); |
| 1846 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data); | 1852 active_layer_->AppendQuads(render_pass.get(), &data); |
| 1847 active_layer_->DidDraw(nullptr); | 1853 active_layer_->DidDraw(nullptr); |
| 1848 | 1854 |
| 1849 // All high res tiles drew, nothing was incomplete. | 1855 // All high res tiles drew, nothing was incomplete. |
| 1850 EXPECT_EQ(9u, render_pass->quad_list.size()); | 1856 EXPECT_EQ(9u, render_pass->quad_list.size()); |
| 1851 EXPECT_EQ(0u, data.num_missing_tiles); | 1857 EXPECT_EQ(0u, data.num_missing_tiles); |
| 1852 EXPECT_EQ(0u, data.num_incomplete_tiles); | 1858 EXPECT_EQ(0u, data.num_incomplete_tiles); |
| 1853 EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads()); | 1859 EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads()); |
| 1854 } | 1860 } |
| 1855 | 1861 |
| 1856 TEST_F(PictureLayerImplTest, HighResTileIsIncomplete) { | 1862 TEST_F(PictureLayerImplTest, HighResTileIsIncomplete) { |
| 1857 base::TimeTicks time_ticks; | 1863 base::TimeTicks time_ticks; |
| 1858 time_ticks += base::TimeDelta::FromMilliseconds(1); | 1864 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| 1859 host_impl_.SetCurrentBeginFrameArgs( | 1865 host_impl_.SetCurrentBeginFrameArgs( |
| 1860 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 1866 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 1861 | 1867 |
| 1862 gfx::Size tile_size(100, 100); | 1868 gfx::Size tile_size(100, 100); |
| 1863 gfx::Size layer_bounds(200, 200); | 1869 gfx::Size layer_bounds(200, 200); |
| 1864 | 1870 |
| 1865 scoped_refptr<FakePicturePileImpl> pending_pile = | 1871 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 1866 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1872 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1867 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); | 1873 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); |
| 1868 ActivateTree(); | 1874 ActivateTree(); |
| 1869 | 1875 |
| 1870 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 1876 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 1871 AppendQuadsData data; | 1877 AppendQuadsData data; |
| 1872 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); | 1878 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); |
| 1873 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data); | 1879 active_layer_->AppendQuads(render_pass.get(), &data); |
| 1874 active_layer_->DidDraw(nullptr); | 1880 active_layer_->DidDraw(nullptr); |
| 1875 | 1881 |
| 1876 EXPECT_EQ(1u, render_pass->quad_list.size()); | 1882 EXPECT_EQ(1u, render_pass->quad_list.size()); |
| 1877 EXPECT_EQ(1u, data.num_missing_tiles); | 1883 EXPECT_EQ(1u, data.num_missing_tiles); |
| 1878 EXPECT_EQ(0u, data.num_incomplete_tiles); | 1884 EXPECT_EQ(0u, data.num_incomplete_tiles); |
| 1879 EXPECT_TRUE(active_layer_->only_used_low_res_last_append_quads()); | 1885 EXPECT_TRUE(active_layer_->only_used_low_res_last_append_quads()); |
| 1880 } | 1886 } |
| 1881 | 1887 |
| 1882 TEST_F(PictureLayerImplTest, HighResTileIsIncompleteLowResComplete) { | 1888 TEST_F(PictureLayerImplTest, HighResTileIsIncompleteLowResComplete) { |
| 1883 base::TimeTicks time_ticks; | 1889 base::TimeTicks time_ticks; |
| 1884 time_ticks += base::TimeDelta::FromMilliseconds(1); | 1890 time_ticks += base::TimeDelta::FromMilliseconds(1); |
| 1885 host_impl_.SetCurrentBeginFrameArgs( | 1891 host_impl_.SetCurrentBeginFrameArgs( |
| 1886 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 1892 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 1887 | 1893 |
| 1888 gfx::Size tile_size(100, 100); | 1894 gfx::Size tile_size(100, 100); |
| 1889 gfx::Size layer_bounds(200, 200); | 1895 gfx::Size layer_bounds(200, 200); |
| 1890 | 1896 |
| 1891 scoped_refptr<FakePicturePileImpl> pending_pile = | 1897 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 1892 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 1898 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 1893 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); | 1899 SetupPendingTreeWithFixedTileSize(pending_pile, tile_size, Region()); |
| 1894 ActivateTree(); | 1900 ActivateTree(); |
| 1895 | 1901 |
| 1896 std::vector<Tile*> low_tiles = | 1902 std::vector<Tile*> low_tiles = |
| 1897 active_layer_->tilings()->tiling_at(1)->AllTilesForTesting(); | 1903 active_layer_->tilings()->tiling_at(1)->AllTilesForTesting(); |
| 1898 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(low_tiles); | 1904 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(low_tiles); |
| 1899 | 1905 |
| 1900 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 1906 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 1901 AppendQuadsData data; | 1907 AppendQuadsData data; |
| 1902 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); | 1908 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); |
| 1903 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data); | 1909 active_layer_->AppendQuads(render_pass.get(), &data); |
| 1904 active_layer_->DidDraw(nullptr); | 1910 active_layer_->DidDraw(nullptr); |
| 1905 | 1911 |
| 1906 EXPECT_EQ(1u, render_pass->quad_list.size()); | 1912 EXPECT_EQ(1u, render_pass->quad_list.size()); |
| 1907 EXPECT_EQ(0u, data.num_missing_tiles); | 1913 EXPECT_EQ(0u, data.num_missing_tiles); |
| 1908 EXPECT_EQ(1u, data.num_incomplete_tiles); | 1914 EXPECT_EQ(1u, data.num_incomplete_tiles); |
| 1909 EXPECT_TRUE(active_layer_->only_used_low_res_last_append_quads()); | 1915 EXPECT_TRUE(active_layer_->only_used_low_res_last_append_quads()); |
| 1910 } | 1916 } |
| 1911 | 1917 |
| 1912 TEST_F(PictureLayerImplTest, LowResTileIsIncomplete) { | 1918 TEST_F(PictureLayerImplTest, LowResTileIsIncomplete) { |
| 1913 base::TimeTicks time_ticks; | 1919 base::TimeTicks time_ticks; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1930 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(high_tiles); | 1936 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(high_tiles); |
| 1931 | 1937 |
| 1932 // All low res tiles have resources. | 1938 // All low res tiles have resources. |
| 1933 std::vector<Tile*> low_tiles = | 1939 std::vector<Tile*> low_tiles = |
| 1934 active_layer_->tilings()->tiling_at(1)->AllTilesForTesting(); | 1940 active_layer_->tilings()->tiling_at(1)->AllTilesForTesting(); |
| 1935 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(low_tiles); | 1941 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(low_tiles); |
| 1936 | 1942 |
| 1937 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 1943 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 1938 AppendQuadsData data; | 1944 AppendQuadsData data; |
| 1939 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); | 1945 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); |
| 1940 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data); | 1946 active_layer_->AppendQuads(render_pass.get(), &data); |
| 1941 active_layer_->DidDraw(nullptr); | 1947 active_layer_->DidDraw(nullptr); |
| 1942 | 1948 |
| 1943 // The missing high res tile was replaced by a low res tile. | 1949 // The missing high res tile was replaced by a low res tile. |
| 1944 EXPECT_EQ(9u, render_pass->quad_list.size()); | 1950 EXPECT_EQ(9u, render_pass->quad_list.size()); |
| 1945 EXPECT_EQ(0u, data.num_missing_tiles); | 1951 EXPECT_EQ(0u, data.num_missing_tiles); |
| 1946 EXPECT_EQ(1u, data.num_incomplete_tiles); | 1952 EXPECT_EQ(1u, data.num_incomplete_tiles); |
| 1947 EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads()); | 1953 EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads()); |
| 1948 } | 1954 } |
| 1949 | 1955 |
| 1950 TEST_F(PictureLayerImplTest, | 1956 TEST_F(PictureLayerImplTest, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1988 EXPECT_EQ(1.f, active_layer_->tilings()->tiling_at(1)->contents_scale()); | 1994 EXPECT_EQ(1.f, active_layer_->tilings()->tiling_at(1)->contents_scale()); |
| 1989 | 1995 |
| 1990 // All high res tiles have resources. | 1996 // All high res tiles have resources. |
| 1991 std::vector<Tile*> high_tiles = | 1997 std::vector<Tile*> high_tiles = |
| 1992 active_layer_->HighResTiling()->AllTilesForTesting(); | 1998 active_layer_->HighResTiling()->AllTilesForTesting(); |
| 1993 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(high_tiles); | 1999 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(high_tiles); |
| 1994 | 2000 |
| 1995 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 2001 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 1996 AppendQuadsData data; | 2002 AppendQuadsData data; |
| 1997 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); | 2003 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); |
| 1998 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data); | 2004 active_layer_->AppendQuads(render_pass.get(), &data); |
| 1999 active_layer_->DidDraw(nullptr); | 2005 active_layer_->DidDraw(nullptr); |
| 2000 | 2006 |
| 2001 // All high res tiles drew, and the one ideal res tile drew. | 2007 // All high res tiles drew, and the one ideal res tile drew. |
| 2002 ASSERT_GT(render_pass->quad_list.size(), 9u); | 2008 ASSERT_GT(render_pass->quad_list.size(), 9u); |
| 2003 EXPECT_EQ(gfx::SizeF(99.f, 99.f), | 2009 EXPECT_EQ(gfx::SizeF(99.f, 99.f), |
| 2004 TileDrawQuad::MaterialCast(render_pass->quad_list.front()) | 2010 TileDrawQuad::MaterialCast(render_pass->quad_list.front()) |
| 2005 ->tex_coord_rect.size()); | 2011 ->tex_coord_rect.size()); |
| 2006 EXPECT_EQ(gfx::SizeF(49.5f, 49.5f), | 2012 EXPECT_EQ(gfx::SizeF(49.5f, 49.5f), |
| 2007 TileDrawQuad::MaterialCast(render_pass->quad_list.ElementAt(1)) | 2013 TileDrawQuad::MaterialCast(render_pass->quad_list.ElementAt(1)) |
| 2008 ->tex_coord_rect.size()); | 2014 ->tex_coord_rect.size()); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2098 TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { | 2104 TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { |
| 2099 gfx::Size layer_bounds(400, 400); | 2105 gfx::Size layer_bounds(400, 400); |
| 2100 gfx::Size tile_size(100, 100); | 2106 gfx::Size tile_size(100, 100); |
| 2101 | 2107 |
| 2102 scoped_refptr<FakePicturePileImpl> pending_pile = | 2108 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 2103 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 2109 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 2104 // This pile will create tilings, but has no recordings so will not create any | 2110 // This pile will create tilings, but has no recordings so will not create any |
| 2105 // tiles. This is attempting to simulate scrolling past the end of recorded | 2111 // tiles. This is attempting to simulate scrolling past the end of recorded |
| 2106 // content on the active layer, where the recordings are so far away that | 2112 // content on the active layer, where the recordings are so far away that |
| 2107 // no tiles are created. | 2113 // no tiles are created. |
| 2114 bool is_solid_color = false; |
| 2108 scoped_refptr<FakePicturePileImpl> active_pile = | 2115 scoped_refptr<FakePicturePileImpl> active_pile = |
| 2109 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( | 2116 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( |
| 2110 tile_size, layer_bounds); | 2117 tile_size, layer_bounds, is_solid_color); |
| 2111 | 2118 |
| 2112 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, Region()); | 2119 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, Region()); |
| 2113 | 2120 |
| 2114 // Active layer has tilings, but no tiles due to missing recordings. | 2121 // Active layer has tilings, but no tiles due to missing recordings. |
| 2115 EXPECT_TRUE(active_layer_->CanHaveTilings()); | 2122 EXPECT_TRUE(active_layer_->CanHaveTilings()); |
| 2116 EXPECT_EQ(active_layer_->tilings()->num_tilings(), 2u); | 2123 EXPECT_EQ(active_layer_->tilings()->num_tilings(), 2u); |
| 2117 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); | 2124 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); |
| 2118 | 2125 |
| 2119 // Since the active layer has no tiles at all, the pending layer doesn't | 2126 // Since the active layer has no tiles at all, the pending layer doesn't |
| 2120 // need content in order to activate. | 2127 // need content in order to activate. |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2590 // not having this update will cause a crash. | 2597 // not having this update will cause a crash. |
| 2591 TEST_F(DeferredInitPictureLayerImplTest, PreventUpdateTilesDuringLostContext) { | 2598 TEST_F(DeferredInitPictureLayerImplTest, PreventUpdateTilesDuringLostContext) { |
| 2592 host_impl_.pending_tree()->UpdateDrawProperties(); | 2599 host_impl_.pending_tree()->UpdateDrawProperties(); |
| 2593 host_impl_.active_tree()->UpdateDrawProperties(); | 2600 host_impl_.active_tree()->UpdateDrawProperties(); |
| 2594 EXPECT_FALSE(host_impl_.pending_tree()->needs_update_draw_properties()); | 2601 EXPECT_FALSE(host_impl_.pending_tree()->needs_update_draw_properties()); |
| 2595 EXPECT_FALSE(host_impl_.active_tree()->needs_update_draw_properties()); | 2602 EXPECT_FALSE(host_impl_.active_tree()->needs_update_draw_properties()); |
| 2596 | 2603 |
| 2597 FakeOutputSurface* fake_output_surface = | 2604 FakeOutputSurface* fake_output_surface = |
| 2598 static_cast<FakeOutputSurface*>(host_impl_.output_surface()); | 2605 static_cast<FakeOutputSurface*>(host_impl_.output_surface()); |
| 2599 ASSERT_TRUE(fake_output_surface->InitializeAndSetContext3d( | 2606 ASSERT_TRUE(fake_output_surface->InitializeAndSetContext3d( |
| 2600 TestContextProvider::Create())); | 2607 TestContextProvider::Create(), TestContextProvider::Create())); |
| 2601 | 2608 |
| 2602 // These will crash PictureLayerImpl if this is not true. | 2609 // These will crash PictureLayerImpl if this is not true. |
| 2603 ASSERT_TRUE(host_impl_.pending_tree()->needs_update_draw_properties()); | 2610 ASSERT_TRUE(host_impl_.pending_tree()->needs_update_draw_properties()); |
| 2604 ASSERT_TRUE(host_impl_.active_tree()->needs_update_draw_properties()); | 2611 ASSERT_TRUE(host_impl_.active_tree()->needs_update_draw_properties()); |
| 2605 host_impl_.active_tree()->UpdateDrawProperties(); | 2612 host_impl_.active_tree()->UpdateDrawProperties(); |
| 2606 } | 2613 } |
| 2607 | 2614 |
| 2608 TEST_F(PictureLayerImplTest, HighResTilingDuringAnimationForCpuRasterization) { | 2615 TEST_F(PictureLayerImplTest, HighResTilingDuringAnimationForCpuRasterization) { |
| 2609 gfx::Size viewport_size(1000, 1000); | 2616 gfx::Size viewport_size(1000, 1000); |
| 2610 host_impl_.SetViewportSize(viewport_size); | 2617 host_impl_.SetViewportSize(viewport_size); |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2921 EXPECT_EQ(high_res_now_tiles, required_for_activation_count); | 2928 EXPECT_EQ(high_res_now_tiles, required_for_activation_count); |
| 2922 | 2929 |
| 2923 // No NOW tiles. | 2930 // No NOW tiles. |
| 2924 time_ticks += base::TimeDelta::FromMilliseconds(200); | 2931 time_ticks += base::TimeDelta::FromMilliseconds(200); |
| 2925 host_impl_.SetCurrentBeginFrameArgs( | 2932 host_impl_.SetCurrentBeginFrameArgs( |
| 2926 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 2933 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 2927 | 2934 |
| 2928 pending_layer_->draw_properties().visible_content_rect = | 2935 pending_layer_->draw_properties().visible_content_rect = |
| 2929 gfx::Rect(1100, 1100, 500, 500); | 2936 gfx::Rect(1100, 1100, 500, 500); |
| 2930 bool resourceless_software_draw = false; | 2937 bool resourceless_software_draw = false; |
| 2931 pending_layer_->UpdateTiles(Occlusion(), resourceless_software_draw); | 2938 pending_layer_->UpdateTiles(resourceless_software_draw); |
| 2932 | 2939 |
| 2933 unique_tiles.clear(); | 2940 unique_tiles.clear(); |
| 2934 high_res_tile_count = 0u; | 2941 high_res_tile_count = 0u; |
| 2935 queue.reset(new TilingSetRasterQueueAll( | 2942 queue.reset(new TilingSetRasterQueueAll( |
| 2936 pending_layer_->picture_layer_tiling_set(), false)); | 2943 pending_layer_->picture_layer_tiling_set(), false)); |
| 2937 while (!queue->IsEmpty()) { | 2944 while (!queue->IsEmpty()) { |
| 2938 Tile* tile = queue->Top(); | 2945 Tile* tile = queue->Top(); |
| 2939 TilePriority priority = tile->priority(PENDING_TREE); | 2946 TilePriority priority = tile->priority(PENDING_TREE); |
| 2940 | 2947 |
| 2941 EXPECT_TRUE(tile); | 2948 EXPECT_TRUE(tile); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2952 | 2959 |
| 2953 EXPECT_EQ(16, high_res_tile_count); | 2960 EXPECT_EQ(16, high_res_tile_count); |
| 2954 EXPECT_EQ(high_res_tile_count, static_cast<int>(unique_tiles.size())); | 2961 EXPECT_EQ(high_res_tile_count, static_cast<int>(unique_tiles.size())); |
| 2955 | 2962 |
| 2956 time_ticks += base::TimeDelta::FromMilliseconds(200); | 2963 time_ticks += base::TimeDelta::FromMilliseconds(200); |
| 2957 host_impl_.SetCurrentBeginFrameArgs( | 2964 host_impl_.SetCurrentBeginFrameArgs( |
| 2958 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 2965 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 2959 | 2966 |
| 2960 pending_layer_->draw_properties().visible_content_rect = | 2967 pending_layer_->draw_properties().visible_content_rect = |
| 2961 gfx::Rect(0, 0, 500, 500); | 2968 gfx::Rect(0, 0, 500, 500); |
| 2962 pending_layer_->UpdateTiles(Occlusion(), resourceless_software_draw); | 2969 pending_layer_->UpdateTiles(resourceless_software_draw); |
| 2963 | 2970 |
| 2964 std::vector<Tile*> high_res_tiles = | 2971 std::vector<Tile*> high_res_tiles = |
| 2965 pending_layer_->HighResTiling()->AllTilesForTesting(); | 2972 pending_layer_->HighResTiling()->AllTilesForTesting(); |
| 2966 for (std::vector<Tile*>::iterator tile_it = high_res_tiles.begin(); | 2973 for (std::vector<Tile*>::iterator tile_it = high_res_tiles.begin(); |
| 2967 tile_it != high_res_tiles.end(); | 2974 tile_it != high_res_tiles.end(); |
| 2968 ++tile_it) { | 2975 ++tile_it) { |
| 2969 Tile* tile = *tile_it; | 2976 Tile* tile = *tile_it; |
| 2970 TileDrawInfo& draw_info = tile->draw_info(); | 2977 TileDrawInfo& draw_info = tile->draw_info(); |
| 2971 draw_info.SetSolidColorForTesting(SK_ColorRED); | 2978 draw_info.SetSolidColorForTesting(SK_ColorRED); |
| 2972 } | 2979 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3023 queue->Pop(); | 3030 queue->Pop(); |
| 3024 } | 3031 } |
| 3025 | 3032 |
| 3026 queue.reset(new TilingSetRasterQueueRequired( | 3033 queue.reset(new TilingSetRasterQueueRequired( |
| 3027 active_layer_->picture_layer_tiling_set(), | 3034 active_layer_->picture_layer_tiling_set(), |
| 3028 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION)); | 3035 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION)); |
| 3029 EXPECT_TRUE(queue->IsEmpty()); | 3036 EXPECT_TRUE(queue->IsEmpty()); |
| 3030 } | 3037 } |
| 3031 | 3038 |
| 3032 TEST_F(PictureLayerImplTest, TilingSetRasterQueueRequiredNoHighRes) { | 3039 TEST_F(PictureLayerImplTest, TilingSetRasterQueueRequiredNoHighRes) { |
| 3040 scoped_ptr<FakePicturePile> empty_recording = |
| 3041 FakePicturePile::CreateEmptyPile(gfx::Size(256, 256), |
| 3042 gfx::Size(1024, 1024)); |
| 3043 empty_recording->SetIsSolidColor(true); |
| 3044 |
| 3033 scoped_refptr<FakePicturePileImpl> pending_pile = | 3045 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 3034 FakePicturePileImpl::CreateEmptyPile(gfx::Size(256, 256), | 3046 FakePicturePileImpl::CreateFromPile(empty_recording.get(), nullptr); |
| 3035 gfx::Size(1024, 1024)); | |
| 3036 pending_pile->set_is_solid_color(true); | |
| 3037 | 3047 |
| 3038 SetupPendingTree(pending_pile); | 3048 SetupPendingTree(pending_pile); |
| 3039 EXPECT_FALSE( | 3049 EXPECT_FALSE( |
| 3040 pending_layer_->picture_layer_tiling_set()->FindTilingWithResolution( | 3050 pending_layer_->picture_layer_tiling_set()->FindTilingWithResolution( |
| 3041 HIGH_RESOLUTION)); | 3051 HIGH_RESOLUTION)); |
| 3042 | 3052 |
| 3043 scoped_ptr<TilingSetRasterQueueRequired> queue( | 3053 scoped_ptr<TilingSetRasterQueueRequired> queue( |
| 3044 new TilingSetRasterQueueRequired( | 3054 new TilingSetRasterQueueRequired( |
| 3045 pending_layer_->picture_layer_tiling_set(), | 3055 pending_layer_->picture_layer_tiling_set(), |
| 3046 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION)); | 3056 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION)); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3137 std::numeric_limits<float>::epsilon()) { | 3147 std::numeric_limits<float>::epsilon()) { |
| 3138 ++scale_index; | 3148 ++scale_index; |
| 3139 ASSERT_LT(scale_index, arraysize(expected_scales)); | 3149 ASSERT_LT(scale_index, arraysize(expected_scales)); |
| 3140 } | 3150 } |
| 3141 | 3151 |
| 3142 EXPECT_FLOAT_EQ(tile->contents_scale(), expected_scales[scale_index]); | 3152 EXPECT_FLOAT_EQ(tile->contents_scale(), expected_scales[scale_index]); |
| 3143 unique_tiles.insert(tile); | 3153 unique_tiles.insert(tile); |
| 3144 | 3154 |
| 3145 if (tile->required_for_activation() == | 3155 if (tile->required_for_activation() == |
| 3146 last_tile->required_for_activation() && | 3156 last_tile->required_for_activation() && |
| 3147 priority.priority_bin == | |
| 3148 last_tile->priority(PENDING_TREE).priority_bin && | |
| 3149 std::abs(tile->contents_scale() - last_tile->contents_scale()) < | 3157 std::abs(tile->contents_scale() - last_tile->contents_scale()) < |
| 3150 std::numeric_limits<float>::epsilon()) { | 3158 std::numeric_limits<float>::epsilon()) { |
| 3151 if (priority.distance_to_visible <= | 3159 if (priority.distance_to_visible <= |
| 3152 last_tile->priority(PENDING_TREE).distance_to_visible) | 3160 last_tile->priority(PENDING_TREE).distance_to_visible) |
| 3153 ++distance_decreasing; | 3161 ++distance_decreasing; |
| 3154 else | 3162 else |
| 3155 ++distance_increasing; | 3163 ++distance_increasing; |
| 3156 } | 3164 } |
| 3157 | 3165 |
| 3158 last_tile = tile; | 3166 last_tile = tile; |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3516 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { | 3524 TEST_F(NoLowResPictureLayerImplTest, NothingRequiredIfActiveMissingTiles) { |
| 3517 gfx::Size layer_bounds(400, 400); | 3525 gfx::Size layer_bounds(400, 400); |
| 3518 gfx::Size tile_size(100, 100); | 3526 gfx::Size tile_size(100, 100); |
| 3519 | 3527 |
| 3520 scoped_refptr<FakePicturePileImpl> pending_pile = | 3528 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 3521 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 3529 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 3522 // This pile will create tilings, but has no recordings so will not create any | 3530 // This pile will create tilings, but has no recordings so will not create any |
| 3523 // tiles. This is attempting to simulate scrolling past the end of recorded | 3531 // tiles. This is attempting to simulate scrolling past the end of recorded |
| 3524 // content on the active layer, where the recordings are so far away that | 3532 // content on the active layer, where the recordings are so far away that |
| 3525 // no tiles are created. | 3533 // no tiles are created. |
| 3534 bool is_solid_color = false; |
| 3526 scoped_refptr<FakePicturePileImpl> active_pile = | 3535 scoped_refptr<FakePicturePileImpl> active_pile = |
| 3527 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( | 3536 FakePicturePileImpl::CreateEmptyPileThatThinksItHasRecordings( |
| 3528 tile_size, layer_bounds); | 3537 tile_size, layer_bounds, is_solid_color); |
| 3529 | 3538 |
| 3530 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, Region()); | 3539 SetupTreesWithFixedTileSize(pending_pile, active_pile, tile_size, Region()); |
| 3531 | 3540 |
| 3532 // Active layer has tilings, but no tiles due to missing recordings. | 3541 // Active layer has tilings, but no tiles due to missing recordings. |
| 3533 EXPECT_TRUE(active_layer_->CanHaveTilings()); | 3542 EXPECT_TRUE(active_layer_->CanHaveTilings()); |
| 3534 EXPECT_EQ(active_layer_->tilings()->num_tilings(), | 3543 EXPECT_EQ(active_layer_->tilings()->num_tilings(), |
| 3535 host_impl_.settings().create_low_res_tiling ? 2u : 1u); | 3544 host_impl_.settings().create_low_res_tiling ? 2u : 1u); |
| 3536 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); | 3545 EXPECT_EQ(active_layer_->HighResTiling()->AllTilesForTesting().size(), 0u); |
| 3537 | 3546 |
| 3538 // Since the active layer has no tiles at all, the pending layer doesn't | 3547 // Since the active layer has no tiles at all, the pending layer doesn't |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3571 gfx::Rect viewport = gfx::Rect(layer_bounds); | 3580 gfx::Rect viewport = gfx::Rect(layer_bounds); |
| 3572 gfx::Transform transform; | 3581 gfx::Transform transform; |
| 3573 host_impl_.SetExternalDrawConstraints(transform, | 3582 host_impl_.SetExternalDrawConstraints(transform, |
| 3574 viewport, | 3583 viewport, |
| 3575 viewport, | 3584 viewport, |
| 3576 viewport, | 3585 viewport, |
| 3577 transform, | 3586 transform, |
| 3578 resourceless_software_draw); | 3587 resourceless_software_draw); |
| 3579 active_layer_->draw_properties().visible_content_rect = viewport; | 3588 active_layer_->draw_properties().visible_content_rect = viewport; |
| 3580 active_layer_->draw_properties().screen_space_transform = transform; | 3589 active_layer_->draw_properties().screen_space_transform = transform; |
| 3581 active_layer_->UpdateTiles(Occlusion(), resourceless_software_draw); | 3590 active_layer_->UpdateTiles(resourceless_software_draw); |
| 3582 | 3591 |
| 3583 gfx::Rect visible_rect_for_tile_priority = | 3592 gfx::Rect visible_rect_for_tile_priority = |
| 3584 active_layer_->visible_rect_for_tile_priority(); | 3593 active_layer_->visible_rect_for_tile_priority(); |
| 3585 EXPECT_FALSE(visible_rect_for_tile_priority.IsEmpty()); | 3594 EXPECT_FALSE(visible_rect_for_tile_priority.IsEmpty()); |
| 3586 gfx::Transform screen_space_transform_for_tile_priority = | 3595 gfx::Transform screen_space_transform_for_tile_priority = |
| 3587 active_layer_->screen_space_transform(); | 3596 active_layer_->screen_space_transform(); |
| 3588 | 3597 |
| 3589 // Expand viewport and set it as invalid for prioritizing tiles. | 3598 // Expand viewport and set it as invalid for prioritizing tiles. |
| 3590 // Should update viewport and transform, but not update visible rect. | 3599 // Should update viewport and transform, but not update visible rect. |
| 3591 time_ticks += base::TimeDelta::FromMilliseconds(200); | 3600 time_ticks += base::TimeDelta::FromMilliseconds(200); |
| 3592 host_impl_.SetCurrentBeginFrameArgs( | 3601 host_impl_.SetCurrentBeginFrameArgs( |
| 3593 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 3602 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 3594 resourceless_software_draw = true; | 3603 resourceless_software_draw = true; |
| 3595 viewport = gfx::ScaleToEnclosingRect(viewport, 2); | 3604 viewport = gfx::ScaleToEnclosingRect(viewport, 2); |
| 3596 transform.Translate(1.f, 1.f); | 3605 transform.Translate(1.f, 1.f); |
| 3597 active_layer_->draw_properties().visible_content_rect = viewport; | 3606 active_layer_->draw_properties().visible_content_rect = viewport; |
| 3598 active_layer_->draw_properties().screen_space_transform = transform; | 3607 active_layer_->draw_properties().screen_space_transform = transform; |
| 3599 host_impl_.SetExternalDrawConstraints(transform, | 3608 host_impl_.SetExternalDrawConstraints(transform, |
| 3600 viewport, | 3609 viewport, |
| 3601 viewport, | 3610 viewport, |
| 3602 viewport, | 3611 viewport, |
| 3603 transform, | 3612 transform, |
| 3604 resourceless_software_draw); | 3613 resourceless_software_draw); |
| 3605 active_layer_->UpdateTiles(Occlusion(), resourceless_software_draw); | 3614 active_layer_->UpdateTiles(resourceless_software_draw); |
| 3606 | 3615 |
| 3607 // Transform for tile priority is updated. | 3616 // Transform for tile priority is updated. |
| 3608 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, | 3617 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, |
| 3609 active_layer_->screen_space_transform()); | 3618 active_layer_->screen_space_transform()); |
| 3610 // Visible rect for tile priority retains old value. | 3619 // Visible rect for tile priority retains old value. |
| 3611 EXPECT_EQ(visible_rect_for_tile_priority, | 3620 EXPECT_EQ(visible_rect_for_tile_priority, |
| 3612 active_layer_->visible_rect_for_tile_priority()); | 3621 active_layer_->visible_rect_for_tile_priority()); |
| 3613 | 3622 |
| 3614 // Keep expanded viewport but mark it valid. Should update tile viewport. | 3623 // Keep expanded viewport but mark it valid. Should update tile viewport. |
| 3615 time_ticks += base::TimeDelta::FromMilliseconds(200); | 3624 time_ticks += base::TimeDelta::FromMilliseconds(200); |
| 3616 host_impl_.SetCurrentBeginFrameArgs( | 3625 host_impl_.SetCurrentBeginFrameArgs( |
| 3617 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); | 3626 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, time_ticks)); |
| 3618 resourceless_software_draw = false; | 3627 resourceless_software_draw = false; |
| 3619 host_impl_.SetExternalDrawConstraints(transform, | 3628 host_impl_.SetExternalDrawConstraints(transform, |
| 3620 viewport, | 3629 viewport, |
| 3621 viewport, | 3630 viewport, |
| 3622 viewport, | 3631 viewport, |
| 3623 transform, | 3632 transform, |
| 3624 resourceless_software_draw); | 3633 resourceless_software_draw); |
| 3625 active_layer_->UpdateTiles(Occlusion(), resourceless_software_draw); | 3634 active_layer_->UpdateTiles(resourceless_software_draw); |
| 3626 | 3635 |
| 3627 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, | 3636 EXPECT_TRANSFORMATION_MATRIX_EQ(transform, |
| 3628 active_layer_->screen_space_transform()); | 3637 active_layer_->screen_space_transform()); |
| 3629 EXPECT_EQ(viewport, active_layer_->visible_rect_for_tile_priority()); | 3638 EXPECT_EQ(viewport, active_layer_->visible_rect_for_tile_priority()); |
| 3630 } | 3639 } |
| 3631 | 3640 |
| 3632 TEST_F(NoLowResPictureLayerImplTest, CleanUpTilings) { | 3641 TEST_F(NoLowResPictureLayerImplTest, CleanUpTilings) { |
| 3633 gfx::Size tile_size(400, 400); | 3642 gfx::Size tile_size(400, 400); |
| 3634 gfx::Size layer_bounds(1300, 1900); | 3643 gfx::Size layer_bounds(1300, 1900); |
| 3635 | 3644 |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3796 SetupDrawPropertiesAndUpdateTiles(active_layer_, 2.5f, 1.f, 1.f, 1.f, false); | 3805 SetupDrawPropertiesAndUpdateTiles(active_layer_, 2.5f, 1.f, 1.f, 1.f, false); |
| 3797 | 3806 |
| 3798 float max_contents_scale = active_layer_->MaximumTilingContentsScale(); | 3807 float max_contents_scale = active_layer_->MaximumTilingContentsScale(); |
| 3799 EXPECT_EQ(2.5f, max_contents_scale); | 3808 EXPECT_EQ(2.5f, max_contents_scale); |
| 3800 | 3809 |
| 3801 gfx::Transform scaled_draw_transform = active_layer_->draw_transform(); | 3810 gfx::Transform scaled_draw_transform = active_layer_->draw_transform(); |
| 3802 scaled_draw_transform.Scale(SK_MScalar1 / max_contents_scale, | 3811 scaled_draw_transform.Scale(SK_MScalar1 / max_contents_scale, |
| 3803 SK_MScalar1 / max_contents_scale); | 3812 SK_MScalar1 / max_contents_scale); |
| 3804 | 3813 |
| 3805 AppendQuadsData data; | 3814 AppendQuadsData data; |
| 3806 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data); | 3815 active_layer_->AppendQuads(render_pass.get(), &data); |
| 3807 | 3816 |
| 3808 // SharedQuadState should have be of size 1, as we are doing AppenQuad once. | 3817 // SharedQuadState should have be of size 1, as we are doing AppenQuad once. |
| 3809 EXPECT_EQ(1u, render_pass->shared_quad_state_list.size()); | 3818 EXPECT_EQ(1u, render_pass->shared_quad_state_list.size()); |
| 3810 // The content_to_target_transform should be scaled by the | 3819 // The content_to_target_transform should be scaled by the |
| 3811 // MaximumTilingContentsScale on the layer. | 3820 // MaximumTilingContentsScale on the layer. |
| 3812 EXPECT_EQ(scaled_draw_transform.ToString(), | 3821 EXPECT_EQ(scaled_draw_transform.ToString(), |
| 3813 render_pass->shared_quad_state_list.front() | 3822 render_pass->shared_quad_state_list.front() |
| 3814 ->content_to_target_transform.ToString()); | 3823 ->content_to_target_transform.ToString()); |
| 3815 // The content_bounds should be scaled by the | 3824 // The content_bounds should be scaled by the |
| 3816 // MaximumTilingContentsScale on the layer. | 3825 // MaximumTilingContentsScale on the layer. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3862 ManagedMemoryPolicy policy(memory_limit, | 3871 ManagedMemoryPolicy policy(memory_limit, |
| 3863 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, | 3872 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, |
| 3864 resource_limit); | 3873 resource_limit); |
| 3865 host_impl_.SetMemoryPolicy(policy); | 3874 host_impl_.SetMemoryPolicy(policy); |
| 3866 host_impl_.SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); | 3875 host_impl_.SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); |
| 3867 host_impl_.PrepareTiles(); | 3876 host_impl_.PrepareTiles(); |
| 3868 | 3877 |
| 3869 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 3878 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 3870 AppendQuadsData data; | 3879 AppendQuadsData data; |
| 3871 active_layer_->WillDraw(DRAW_MODE_HARDWARE, nullptr); | 3880 active_layer_->WillDraw(DRAW_MODE_HARDWARE, nullptr); |
| 3872 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data); | 3881 active_layer_->AppendQuads(render_pass.get(), &data); |
| 3873 active_layer_->DidDraw(nullptr); | 3882 active_layer_->DidDraw(nullptr); |
| 3874 | 3883 |
| 3875 // Even when OOM, quads should be produced, and should be different material | 3884 // Even when OOM, quads should be produced, and should be different material |
| 3876 // from quads with resource. | 3885 // from quads with resource. |
| 3877 EXPECT_LT(max_tiles, render_pass->quad_list.size()); | 3886 EXPECT_LT(max_tiles, render_pass->quad_list.size()); |
| 3878 EXPECT_EQ(DrawQuad::Material::TILED_CONTENT, | 3887 EXPECT_EQ(DrawQuad::Material::TILED_CONTENT, |
| 3879 render_pass->quad_list.front()->material); | 3888 render_pass->quad_list.front()->material); |
| 3880 EXPECT_EQ(DrawQuad::Material::SOLID_COLOR, | 3889 EXPECT_EQ(DrawQuad::Material::SOLID_COLOR, |
| 3881 render_pass->quad_list.back()->material); | 3890 render_pass->quad_list.back()->material); |
| 3882 } | 3891 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3964 EXPECT_LT(priority_for_tree_priority.priority_bin, | 3973 EXPECT_LT(priority_for_tree_priority.priority_bin, |
| 3965 priority.priority_bin); | 3974 priority.priority_bin); |
| 3966 EXPECT_EQ(priority_for_tree_priority.priority_bin, | 3975 EXPECT_EQ(priority_for_tree_priority.priority_bin, |
| 3967 twin_priority.priority_bin); | 3976 twin_priority.priority_bin); |
| 3968 EXPECT_TRUE(priority_for_tree_priority.priority_bin < | 3977 EXPECT_TRUE(priority_for_tree_priority.priority_bin < |
| 3969 priority.priority_bin); | 3978 priority.priority_bin); |
| 3970 } else if (tile->is_occluded(tree) != | 3979 } else if (tile->is_occluded(tree) != |
| 3971 tile->is_occluded(twin_tree)) { | 3980 tile->is_occluded(twin_tree)) { |
| 3972 EXPECT_TRUE(tile->is_occluded(tree)); | 3981 EXPECT_TRUE(tile->is_occluded(tree)); |
| 3973 EXPECT_FALSE(tile->is_occluded(twin_tree)); | 3982 EXPECT_FALSE(tile->is_occluded(twin_tree)); |
| 3974 EXPECT_FALSE( | 3983 EXPECT_FALSE(tile->is_occluded_combined()); |
| 3975 tile->is_occluded_for_tree_priority(tree_priority)); | |
| 3976 } else if (priority.distance_to_visible != | 3984 } else if (priority.distance_to_visible != |
| 3977 twin_priority.distance_to_visible) { | 3985 twin_priority.distance_to_visible) { |
| 3978 EXPECT_LT(priority_for_tree_priority.distance_to_visible, | 3986 EXPECT_LT(priority_for_tree_priority.distance_to_visible, |
| 3979 priority.distance_to_visible); | 3987 priority.distance_to_visible); |
| 3980 EXPECT_EQ(priority_for_tree_priority.distance_to_visible, | 3988 EXPECT_EQ(priority_for_tree_priority.distance_to_visible, |
| 3981 twin_priority.distance_to_visible); | 3989 twin_priority.distance_to_visible); |
| 3982 EXPECT_TRUE(priority_for_tree_priority.distance_to_visible < | 3990 EXPECT_TRUE(priority_for_tree_priority.distance_to_visible < |
| 3983 priority.distance_to_visible); | 3991 priority.distance_to_visible); |
| 3984 } else { | 3992 } else { |
| 3985 // Shared tiles having the same active and pending priorities | 3993 // Shared tiles having the same active and pending priorities |
| (...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4678 ASSERT_GT(active_layer_->tilings()->num_tilings(), 0u); | 4686 ASSERT_GT(active_layer_->tilings()->num_tilings(), 0u); |
| 4679 std::vector<Tile*> tiles = | 4687 std::vector<Tile*> tiles = |
| 4680 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); | 4688 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); |
| 4681 EXPECT_FALSE(tiles.empty()); | 4689 EXPECT_FALSE(tiles.empty()); |
| 4682 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); | 4690 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); |
| 4683 } | 4691 } |
| 4684 | 4692 |
| 4685 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); | 4693 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 4686 AppendQuadsData data; | 4694 AppendQuadsData data; |
| 4687 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); | 4695 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr); |
| 4688 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data); | 4696 active_layer_->AppendQuads(render_pass.get(), &data); |
| 4689 active_layer_->DidDraw(nullptr); | 4697 active_layer_->DidDraw(nullptr); |
| 4690 | 4698 |
| 4691 DrawQuad::Material expected = test_for_solid | 4699 DrawQuad::Material expected = test_for_solid |
| 4692 ? DrawQuad::Material::SOLID_COLOR | 4700 ? DrawQuad::Material::SOLID_COLOR |
| 4693 : DrawQuad::Material::TILED_CONTENT; | 4701 : DrawQuad::Material::TILED_CONTENT; |
| 4694 EXPECT_EQ(expected, render_pass->quad_list.front()->material); | 4702 EXPECT_EQ(expected, render_pass->quad_list.front()->material); |
| 4695 } | 4703 } |
| 4696 | 4704 |
| 4697 TEST_F(PictureLayerImplTest, DrawSolidQuads) { | 4705 TEST_F(PictureLayerImplTest, DrawSolidQuads) { |
| 4698 TestQuadsForSolidColor(true); | 4706 TestQuadsForSolidColor(true); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4815 // Ensure we can activate. | 4823 // Ensure we can activate. |
| 4816 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); | 4824 EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate()); |
| 4817 } | 4825 } |
| 4818 | 4826 |
| 4819 TEST_F(PictureLayerImplTest, CloneMissingRecordings) { | 4827 TEST_F(PictureLayerImplTest, CloneMissingRecordings) { |
| 4820 gfx::Size tile_size(100, 100); | 4828 gfx::Size tile_size(100, 100); |
| 4821 gfx::Size layer_bounds(400, 400); | 4829 gfx::Size layer_bounds(400, 400); |
| 4822 | 4830 |
| 4823 scoped_refptr<FakePicturePileImpl> filled_pile = | 4831 scoped_refptr<FakePicturePileImpl> filled_pile = |
| 4824 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 4832 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 4833 |
| 4834 scoped_ptr<FakePicturePile> partial_recording = |
| 4835 FakePicturePile::CreateEmptyPile(tile_size, layer_bounds); |
| 4836 for (int i = 1; i < partial_recording->tiling().num_tiles_x(); ++i) { |
| 4837 for (int j = 1; j < partial_recording->tiling().num_tiles_y(); ++j) |
| 4838 partial_recording->AddRecordingAt(i, j); |
| 4839 } |
| 4825 scoped_refptr<FakePicturePileImpl> partial_pile = | 4840 scoped_refptr<FakePicturePileImpl> partial_pile = |
| 4826 FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); | 4841 FakePicturePileImpl::CreateFromPile(partial_recording.get(), nullptr); |
| 4827 for (int i = 1; i < partial_pile->tiling().num_tiles_x(); ++i) { | |
| 4828 for (int j = 1; j < partial_pile->tiling().num_tiles_y(); ++j) | |
| 4829 partial_pile->AddRecordingAt(i, j); | |
| 4830 } | |
| 4831 | 4842 |
| 4832 SetupPendingTreeWithFixedTileSize(filled_pile, tile_size, Region()); | 4843 SetupPendingTreeWithFixedTileSize(filled_pile, tile_size, Region()); |
| 4833 ActivateTree(); | 4844 ActivateTree(); |
| 4834 | 4845 |
| 4835 PictureLayerTiling* pending_tiling = old_pending_layer_->HighResTiling(); | 4846 PictureLayerTiling* pending_tiling = old_pending_layer_->HighResTiling(); |
| 4836 PictureLayerTiling* active_tiling = active_layer_->HighResTiling(); | 4847 PictureLayerTiling* active_tiling = active_layer_->HighResTiling(); |
| 4837 | 4848 |
| 4838 // We should have all tiles in both tile sets. | 4849 // We should have all tiles in both tile sets. |
| 4839 EXPECT_EQ(5u * 5u, pending_tiling->AllTilesForTesting().size()); | 4850 EXPECT_EQ(5u * 5u, pending_tiling->AllTilesForTesting().size()); |
| 4840 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size()); | 4851 EXPECT_EQ(5u * 5u, active_tiling->AllTilesForTesting().size()); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4936 result = layer->CalculateTileSize(gfx::Size(447, 400)); | 4947 result = layer->CalculateTileSize(gfx::Size(447, 400)); |
| 4937 EXPECT_EQ(result.width(), 448); | 4948 EXPECT_EQ(result.width(), 448); |
| 4938 EXPECT_EQ(result.height(), 448); | 4949 EXPECT_EQ(result.height(), 448); |
| 4939 result = layer->CalculateTileSize(gfx::Size(500, 499)); | 4950 result = layer->CalculateTileSize(gfx::Size(500, 499)); |
| 4940 EXPECT_EQ(result.width(), 512); | 4951 EXPECT_EQ(result.width(), 512); |
| 4941 EXPECT_EQ(result.height(), 500 + 2); | 4952 EXPECT_EQ(result.height(), 500 + 2); |
| 4942 } | 4953 } |
| 4943 | 4954 |
| 4944 } // namespace | 4955 } // namespace |
| 4945 } // namespace cc | 4956 } // namespace cc |
| OLD | NEW |