Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: cc/layers/picture_layer_impl_unittest.cc

Issue 643583003: [C++11 Allowed Features] Declares a type-safe null pointer converting from NULL to nullptr in src/… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 public: 52 public:
53 LowResTilingsSettings() { create_low_res_tiling = true; } 53 LowResTilingsSettings() { create_low_res_tiling = true; }
54 }; 54 };
55 55
56 class PictureLayerImplTest : public testing::Test { 56 class PictureLayerImplTest : public testing::Test {
57 public: 57 public:
58 PictureLayerImplTest() 58 PictureLayerImplTest()
59 : proxy_(base::MessageLoopProxy::current()), 59 : proxy_(base::MessageLoopProxy::current()),
60 host_impl_(LowResTilingsSettings(), &proxy_, &shared_bitmap_manager_), 60 host_impl_(LowResTilingsSettings(), &proxy_, &shared_bitmap_manager_),
61 id_(7), 61 id_(7),
62 pending_layer_(NULL), 62 pending_layer_(nullptr),
63 old_pending_layer_(NULL), 63 old_pending_layer_(nullptr),
64 active_layer_(NULL) {} 64 active_layer_(nullptr) {}
65 65
66 explicit PictureLayerImplTest(const LayerTreeSettings& settings) 66 explicit PictureLayerImplTest(const LayerTreeSettings& settings)
67 : proxy_(base::MessageLoopProxy::current()), 67 : proxy_(base::MessageLoopProxy::current()),
68 host_impl_(settings, &proxy_, &shared_bitmap_manager_), 68 host_impl_(settings, &proxy_, &shared_bitmap_manager_),
69 id_(7) {} 69 id_(7) {}
70 70
71 virtual ~PictureLayerImplTest() { 71 virtual ~PictureLayerImplTest() {
72 } 72 }
73 73
74 virtual void SetUp() override { 74 virtual void SetUp() override {
(...skipping 13 matching lines...) Expand all
88 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 88 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
89 89
90 SetupTrees(pending_pile, active_pile); 90 SetupTrees(pending_pile, active_pile);
91 } 91 }
92 92
93 void ActivateTree() { 93 void ActivateTree() {
94 host_impl_.ActivateSyncTree(); 94 host_impl_.ActivateSyncTree();
95 CHECK(!host_impl_.pending_tree()); 95 CHECK(!host_impl_.pending_tree());
96 CHECK(host_impl_.recycle_tree()); 96 CHECK(host_impl_.recycle_tree());
97 old_pending_layer_ = pending_layer_; 97 old_pending_layer_ = pending_layer_;
98 pending_layer_ = NULL; 98 pending_layer_ = nullptr;
99 active_layer_ = static_cast<FakePictureLayerImpl*>( 99 active_layer_ = static_cast<FakePictureLayerImpl*>(
100 host_impl_.active_tree()->LayerById(id_)); 100 host_impl_.active_tree()->LayerById(id_));
101 } 101 }
102 102
103 void SetupDefaultTreesWithFixedTileSize(const gfx::Size& layer_bounds, 103 void SetupDefaultTreesWithFixedTileSize(const gfx::Size& layer_bounds,
104 const gfx::Size& tile_size) { 104 const gfx::Size& tile_size) {
105 SetupDefaultTrees(layer_bounds); 105 SetupDefaultTrees(layer_bounds);
106 pending_layer_->set_fixed_tile_size(tile_size); 106 pending_layer_->set_fixed_tile_size(tile_size);
107 active_layer_->set_fixed_tile_size(tile_size); 107 active_layer_->set_fixed_tile_size(tile_size);
108 } 108 }
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 rects.push_back(SkRect::MakeXYWH(rect.x(), rect.y(), 1, 1)); 251 rects.push_back(SkRect::MakeXYWH(rect.x(), rect.y(), 1, 1));
252 } 252 }
253 // Force re-record with newly injected content 253 // Force re-record with newly injected content
254 active_pile->RemoveRecordingAt(0, 0); 254 active_pile->RemoveRecordingAt(0, 0);
255 active_pile->AddRecordingAt(0, 0); 255 active_pile->AddRecordingAt(0, 0);
256 256
257 std::vector<SkRect>::const_iterator rect_iter = rects.begin(); 257 std::vector<SkRect>::const_iterator rect_iter = rects.begin();
258 for (tile_iter = tiles.begin(); tile_iter < tiles.end(); tile_iter++) { 258 for (tile_iter = tiles.begin(); tile_iter < tiles.end(); tile_iter++) {
259 MockCanvas mock_canvas(1000, 1000); 259 MockCanvas mock_canvas(1000, 1000);
260 active_pile->RasterDirect( 260 active_pile->RasterDirect(
261 &mock_canvas, (*tile_iter)->content_rect(), 1.0f, NULL); 261 &mock_canvas, (*tile_iter)->content_rect(), 1.0f, nullptr);
262 262
263 // This test verifies that when drawing the contents of a specific tile 263 // This test verifies that when drawing the contents of a specific tile
264 // at content scale 1.0, the playback canvas never receives content from 264 // at content scale 1.0, the playback canvas never receives content from
265 // neighboring tiles which indicates that the tile grid embedded in 265 // neighboring tiles which indicates that the tile grid embedded in
266 // SkPicture is perfectly aligned with the compositor's tiles. 266 // SkPicture is perfectly aligned with the compositor's tiles.
267 EXPECT_EQ(1u, mock_canvas.rects_.size()); 267 EXPECT_EQ(1u, mock_canvas.rects_.size());
268 EXPECT_EQ(*rect_iter, mock_canvas.rects_[0]); 268 EXPECT_EQ(*rect_iter, mock_canvas.rects_[0]);
269 rect_iter++; 269 rect_iter++;
270 } 270 }
271 } 271 }
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1374 SetupTrees(pending_pile, active_pile); 1374 SetupTrees(pending_pile, active_pile);
1375 1375
1376 active_layer_->draw_properties().visible_content_rect = 1376 active_layer_->draw_properties().visible_content_rect =
1377 gfx::Rect(layer_bounds); 1377 gfx::Rect(layer_bounds);
1378 1378
1379 gfx::Rect layer_invalidation(150, 200, 30, 180); 1379 gfx::Rect layer_invalidation(150, 200, 30, 180);
1380 Region invalidation(layer_invalidation); 1380 Region invalidation(layer_invalidation);
1381 AddDefaultTilingsWithInvalidation(invalidation); 1381 AddDefaultTilingsWithInvalidation(invalidation);
1382 1382
1383 AppendQuadsData data; 1383 AppendQuadsData data;
1384 active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, NULL); 1384 active_layer_->WillDraw(DRAW_MODE_RESOURCELESS_SOFTWARE, nullptr);
1385 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data); 1385 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data);
1386 active_layer_->DidDraw(NULL); 1386 active_layer_->DidDraw(nullptr);
1387 1387
1388 ASSERT_EQ(1U, render_pass->quad_list.size()); 1388 ASSERT_EQ(1U, render_pass->quad_list.size());
1389 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, 1389 EXPECT_EQ(DrawQuad::PICTURE_CONTENT,
1390 render_pass->quad_list.front()->material); 1390 render_pass->quad_list.front()->material);
1391 } 1391 }
1392 1392
1393 TEST_F(PictureLayerImplTest, MarkRequiredNullTiles) { 1393 TEST_F(PictureLayerImplTest, MarkRequiredNullTiles) {
1394 gfx::Size tile_size(100, 100); 1394 gfx::Size tile_size(100, 100);
1395 gfx::Size layer_bounds(1000, 1000); 1395 gfx::Size layer_bounds(1000, 1000);
1396 1396
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1558 EXPECT_GT(num_inside, 0); 1558 EXPECT_GT(num_inside, 0);
1559 EXPECT_GT(num_outside, 0); 1559 EXPECT_GT(num_outside, 0);
1560 1560
1561 // Activate and draw active layer. 1561 // Activate and draw active layer.
1562 host_impl_.ActivateSyncTree(); 1562 host_impl_.ActivateSyncTree();
1563 host_impl_.active_tree()->UpdateDrawProperties(); 1563 host_impl_.active_tree()->UpdateDrawProperties();
1564 active_layer_->draw_properties().visible_content_rect = visible_content_rect; 1564 active_layer_->draw_properties().visible_content_rect = visible_content_rect;
1565 1565
1566 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 1566 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
1567 AppendQuadsData data; 1567 AppendQuadsData data;
1568 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, NULL); 1568 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr);
1569 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data); 1569 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data);
1570 active_layer_->DidDraw(NULL); 1570 active_layer_->DidDraw(nullptr);
1571 1571
1572 // All tiles in activation rect is ready to draw. 1572 // All tiles in activation rect is ready to draw.
1573 EXPECT_EQ(0u, data.num_missing_tiles); 1573 EXPECT_EQ(0u, data.num_missing_tiles);
1574 EXPECT_EQ(0u, data.num_incomplete_tiles); 1574 EXPECT_EQ(0u, data.num_incomplete_tiles);
1575 } 1575 }
1576 1576
1577 TEST_F(PictureLayerImplTest, HighResTileIsComplete) { 1577 TEST_F(PictureLayerImplTest, HighResTileIsComplete) {
1578 base::TimeTicks time_ticks; 1578 base::TimeTicks time_ticks;
1579 time_ticks += base::TimeDelta::FromMilliseconds(1); 1579 time_ticks += base::TimeDelta::FromMilliseconds(1);
1580 host_impl_.SetCurrentBeginFrameArgs( 1580 host_impl_.SetCurrentBeginFrameArgs(
(...skipping 11 matching lines...) Expand all
1592 1592
1593 // All high res tiles have resources. 1593 // All high res tiles have resources.
1594 active_layer_->set_fixed_tile_size(tile_size); 1594 active_layer_->set_fixed_tile_size(tile_size);
1595 host_impl_.active_tree()->UpdateDrawProperties(); 1595 host_impl_.active_tree()->UpdateDrawProperties();
1596 std::vector<Tile*> tiles = 1596 std::vector<Tile*> tiles =
1597 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); 1597 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting();
1598 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); 1598 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles);
1599 1599
1600 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 1600 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
1601 AppendQuadsData data; 1601 AppendQuadsData data;
1602 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, NULL); 1602 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr);
1603 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data); 1603 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data);
1604 active_layer_->DidDraw(NULL); 1604 active_layer_->DidDraw(nullptr);
1605 1605
1606 // All high res tiles drew, nothing was incomplete. 1606 // All high res tiles drew, nothing was incomplete.
1607 EXPECT_EQ(9u, render_pass->quad_list.size()); 1607 EXPECT_EQ(9u, render_pass->quad_list.size());
1608 EXPECT_EQ(0u, data.num_missing_tiles); 1608 EXPECT_EQ(0u, data.num_missing_tiles);
1609 EXPECT_EQ(0u, data.num_incomplete_tiles); 1609 EXPECT_EQ(0u, data.num_incomplete_tiles);
1610 } 1610 }
1611 1611
1612 TEST_F(PictureLayerImplTest, LowResTileIsIncomplete) { 1612 TEST_F(PictureLayerImplTest, LowResTileIsIncomplete) {
1613 base::TimeTicks time_ticks; 1613 base::TimeTicks time_ticks;
1614 time_ticks += base::TimeDelta::FromMilliseconds(1); 1614 time_ticks += base::TimeDelta::FromMilliseconds(1);
(...skipping 18 matching lines...) Expand all
1633 high_tiles.erase(high_tiles.begin()); 1633 high_tiles.erase(high_tiles.begin());
1634 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(high_tiles); 1634 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(high_tiles);
1635 1635
1636 // All low res tiles have resources. 1636 // All low res tiles have resources.
1637 std::vector<Tile*> low_tiles = 1637 std::vector<Tile*> low_tiles =
1638 active_layer_->tilings()->tiling_at(1)->AllTilesForTesting(); 1638 active_layer_->tilings()->tiling_at(1)->AllTilesForTesting();
1639 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(low_tiles); 1639 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(low_tiles);
1640 1640
1641 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 1641 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
1642 AppendQuadsData data; 1642 AppendQuadsData data;
1643 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, NULL); 1643 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr);
1644 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data); 1644 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data);
1645 active_layer_->DidDraw(NULL); 1645 active_layer_->DidDraw(nullptr);
1646 1646
1647 // The missing high res tile was replaced by a low res tile. 1647 // The missing high res tile was replaced by a low res tile.
1648 EXPECT_EQ(9u, render_pass->quad_list.size()); 1648 EXPECT_EQ(9u, render_pass->quad_list.size());
1649 EXPECT_EQ(0u, data.num_missing_tiles); 1649 EXPECT_EQ(0u, data.num_missing_tiles);
1650 EXPECT_EQ(1u, data.num_incomplete_tiles); 1650 EXPECT_EQ(1u, data.num_incomplete_tiles);
1651 } 1651 }
1652 1652
1653 TEST_F(PictureLayerImplTest, 1653 TEST_F(PictureLayerImplTest,
1654 HighResAndIdealResTileIsCompleteWhenRasterScaleIsNotIdeal) { 1654 HighResAndIdealResTileIsCompleteWhenRasterScaleIsNotIdeal) {
1655 base::TimeTicks time_ticks; 1655 base::TimeTicks time_ticks;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1694 EXPECT_EQ(2.f, active_layer_->tilings()->tiling_at(0)->contents_scale()); 1694 EXPECT_EQ(2.f, active_layer_->tilings()->tiling_at(0)->contents_scale());
1695 EXPECT_EQ(1.f, active_layer_->tilings()->tiling_at(1)->contents_scale()); 1695 EXPECT_EQ(1.f, active_layer_->tilings()->tiling_at(1)->contents_scale());
1696 1696
1697 // All high res tiles have resources. 1697 // All high res tiles have resources.
1698 std::vector<Tile*> high_tiles = 1698 std::vector<Tile*> high_tiles =
1699 active_layer_->HighResTiling()->AllTilesForTesting(); 1699 active_layer_->HighResTiling()->AllTilesForTesting();
1700 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(high_tiles); 1700 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(high_tiles);
1701 1701
1702 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 1702 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
1703 AppendQuadsData data; 1703 AppendQuadsData data;
1704 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, NULL); 1704 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr);
1705 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data); 1705 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data);
1706 active_layer_->DidDraw(NULL); 1706 active_layer_->DidDraw(nullptr);
1707 1707
1708 // All high res tiles drew, and the one ideal res tile drew. 1708 // All high res tiles drew, and the one ideal res tile drew.
1709 ASSERT_GT(render_pass->quad_list.size(), 9u); 1709 ASSERT_GT(render_pass->quad_list.size(), 9u);
1710 EXPECT_EQ(gfx::SizeF(99.f, 99.f), 1710 EXPECT_EQ(gfx::SizeF(99.f, 99.f),
1711 TileDrawQuad::MaterialCast(render_pass->quad_list.front()) 1711 TileDrawQuad::MaterialCast(render_pass->quad_list.front())
1712 ->tex_coord_rect.size()); 1712 ->tex_coord_rect.size());
1713 EXPECT_EQ(gfx::SizeF(49.5f, 49.5f), 1713 EXPECT_EQ(gfx::SizeF(49.5f, 49.5f),
1714 TileDrawQuad::MaterialCast(render_pass->quad_list.ElementAt(1)) 1714 TileDrawQuad::MaterialCast(render_pass->quad_list.ElementAt(1))
1715 ->tex_coord_rect.size()); 1715 ->tex_coord_rect.size());
1716 1716
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
2097 // Sanity checks. 2097 // Sanity checks.
2098 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); 2098 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings());
2099 ASSERT_EQ(tiling, active_layer_->tilings()->TilingAtScale(0.5f)); 2099 ASSERT_EQ(tiling, active_layer_->tilings()->TilingAtScale(0.5f));
2100 2100
2101 // Now, set the bounds to be 1x1 (so that minimum contents scale becomes 2101 // Now, set the bounds to be 1x1 (so that minimum contents scale becomes
2102 // 1.0f). Note that we should also ensure that the pending layer needs post 2102 // 1.0f). Note that we should also ensure that the pending layer needs post
2103 // commit initialization, since this is what would happen during commit. In 2103 // commit initialization, since this is what would happen during commit. In
2104 // other words we want the pending layer to sync from the active layer. 2104 // other words we want the pending layer to sync from the active layer.
2105 pending_layer_->SetBounds(gfx::Size(1, 1)); 2105 pending_layer_->SetBounds(gfx::Size(1, 1));
2106 pending_layer_->SetNeedsPostCommitInitialization(); 2106 pending_layer_->SetNeedsPostCommitInitialization();
2107 pending_layer_->set_twin_layer(NULL); 2107 pending_layer_->set_twin_layer(nullptr);
2108 active_layer_->set_twin_layer(NULL); 2108 active_layer_->set_twin_layer(nullptr);
2109 EXPECT_TRUE(pending_layer_->needs_post_commit_initialization()); 2109 EXPECT_TRUE(pending_layer_->needs_post_commit_initialization());
2110 2110
2111 // Update the draw properties: sync from active tree should happen here. 2111 // Update the draw properties: sync from active tree should happen here.
2112 host_impl_.pending_tree()->UpdateDrawProperties(); 2112 host_impl_.pending_tree()->UpdateDrawProperties();
2113 2113
2114 // Another sanity check. 2114 // Another sanity check.
2115 ASSERT_EQ(1.f, pending_layer_->MinimumContentsScale()); 2115 ASSERT_EQ(1.f, pending_layer_->MinimumContentsScale());
2116 2116
2117 // Now we should've synced 1.5f tiling, since that's the only one that doesn't 2117 // Now we should've synced 1.5f tiling, since that's the only one that doesn't
2118 // violate minimum contents scale. At the same time, we should've created a 2118 // violate minimum contents scale. At the same time, we should've created a
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
2717 it = PictureLayerImpl::LayerEvictionTileIterator( 2717 it = PictureLayerImpl::LayerEvictionTileIterator(
2718 pending_layer_, SAME_PRIORITY_FOR_BOTH_TREES); 2718 pending_layer_, SAME_PRIORITY_FOR_BOTH_TREES);
2719 EXPECT_FALSE(it); 2719 EXPECT_FALSE(it);
2720 2720
2721 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); 2721 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles);
2722 2722
2723 std::set<Tile*> unique_tiles; 2723 std::set<Tile*> unique_tiles;
2724 float expected_scales[] = {2.0f, 0.3f, 0.7f, low_res_factor, 1.0f}; 2724 float expected_scales[] = {2.0f, 0.3f, 0.7f, low_res_factor, 1.0f};
2725 size_t scale_index = 0; 2725 size_t scale_index = 0;
2726 bool reached_visible = false; 2726 bool reached_visible = false;
2727 Tile* last_tile = NULL; 2727 Tile* last_tile = nullptr;
2728 for (it = PictureLayerImpl::LayerEvictionTileIterator( 2728 for (it = PictureLayerImpl::LayerEvictionTileIterator(
2729 pending_layer_, SAME_PRIORITY_FOR_BOTH_TREES); 2729 pending_layer_, SAME_PRIORITY_FOR_BOTH_TREES);
2730 it; 2730 it;
2731 ++it) { 2731 ++it) {
2732 Tile* tile = *it; 2732 Tile* tile = *it;
2733 if (!last_tile) 2733 if (!last_tile)
2734 last_tile = tile; 2734 last_tile = tile;
2735 2735
2736 EXPECT_TRUE(tile); 2736 EXPECT_TRUE(tile);
2737 2737
(...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after
3568 size_t resource_limit = max_tiles; 3568 size_t resource_limit = max_tiles;
3569 ManagedMemoryPolicy policy(memory_limit, 3569 ManagedMemoryPolicy policy(memory_limit,
3570 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, 3570 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING,
3571 resource_limit); 3571 resource_limit);
3572 host_impl_.SetMemoryPolicy(policy); 3572 host_impl_.SetMemoryPolicy(policy);
3573 host_impl_.SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); 3573 host_impl_.SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES);
3574 host_impl_.ManageTiles(); 3574 host_impl_.ManageTiles();
3575 3575
3576 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 3576 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
3577 AppendQuadsData data; 3577 AppendQuadsData data;
3578 active_layer_->WillDraw(DRAW_MODE_HARDWARE, NULL); 3578 active_layer_->WillDraw(DRAW_MODE_HARDWARE, nullptr);
3579 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data); 3579 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data);
3580 active_layer_->DidDraw(NULL); 3580 active_layer_->DidDraw(nullptr);
3581 3581
3582 // Even when OOM, quads should be produced, and should be different material 3582 // Even when OOM, quads should be produced, and should be different material
3583 // from quads with resource. 3583 // from quads with resource.
3584 EXPECT_LT(max_tiles, render_pass->quad_list.size()); 3584 EXPECT_LT(max_tiles, render_pass->quad_list.size());
3585 EXPECT_EQ(DrawQuad::Material::TILED_CONTENT, 3585 EXPECT_EQ(DrawQuad::Material::TILED_CONTENT,
3586 render_pass->quad_list.front()->material); 3586 render_pass->quad_list.front()->material);
3587 EXPECT_EQ(DrawQuad::Material::SOLID_COLOR, 3587 EXPECT_EQ(DrawQuad::Material::SOLID_COLOR,
3588 render_pass->quad_list.back()->material); 3588 render_pass->quad_list.back()->material);
3589 } 3589 }
3590 3590
3591 class OcclusionTrackingSettings : public LowResTilingsSettings { 3591 class OcclusionTrackingSettings : public LowResTilingsSettings {
3592 public: 3592 public:
3593 OcclusionTrackingSettings() { use_occlusion_for_tile_prioritization = true; } 3593 OcclusionTrackingSettings() { use_occlusion_for_tile_prioritization = true; }
3594 }; 3594 };
3595 3595
3596 class OcclusionTrackingPictureLayerImplTest : public PictureLayerImplTest { 3596 class OcclusionTrackingPictureLayerImplTest : public PictureLayerImplTest {
3597 public: 3597 public:
3598 OcclusionTrackingPictureLayerImplTest() 3598 OcclusionTrackingPictureLayerImplTest()
3599 : PictureLayerImplTest(OcclusionTrackingSettings()) {} 3599 : PictureLayerImplTest(OcclusionTrackingSettings()) {}
3600 3600
3601 void VerifyEvictionConsidersOcclusion( 3601 void VerifyEvictionConsidersOcclusion(
3602 PictureLayerImpl* layer, 3602 PictureLayerImpl* layer,
3603 size_t expected_occluded_tile_count[NUM_TREE_PRIORITIES]) { 3603 size_t expected_occluded_tile_count[NUM_TREE_PRIORITIES]) {
3604 for (int priority_count = 0; priority_count < NUM_TREE_PRIORITIES; 3604 for (int priority_count = 0; priority_count < NUM_TREE_PRIORITIES;
3605 ++priority_count) { 3605 ++priority_count) {
3606 TreePriority tree_priority = static_cast<TreePriority>(priority_count); 3606 TreePriority tree_priority = static_cast<TreePriority>(priority_count);
3607 size_t occluded_tile_count = 0u; 3607 size_t occluded_tile_count = 0u;
3608 Tile* last_tile = NULL; 3608 Tile* last_tile = nullptr;
3609 3609
3610 for (PictureLayerImpl::LayerEvictionTileIterator it = 3610 for (PictureLayerImpl::LayerEvictionTileIterator it =
3611 PictureLayerImpl::LayerEvictionTileIterator(layer, 3611 PictureLayerImpl::LayerEvictionTileIterator(layer,
3612 tree_priority); 3612 tree_priority);
3613 it; 3613 it;
3614 ++it) { 3614 ++it) {
3615 Tile* tile = *it; 3615 Tile* tile = *it;
3616 if (!last_tile) 3616 if (!last_tile)
3617 last_tile = tile; 3617 last_tile = tile;
3618 3618
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
4278 host_impl_.active_tree()->UpdateDrawProperties(); 4278 host_impl_.active_tree()->UpdateDrawProperties();
4279 ASSERT_GT(active_layer_->tilings()->num_tilings(), 0u); 4279 ASSERT_GT(active_layer_->tilings()->num_tilings(), 0u);
4280 std::vector<Tile*> tiles = 4280 std::vector<Tile*> tiles =
4281 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); 4281 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting();
4282 EXPECT_FALSE(tiles.empty()); 4282 EXPECT_FALSE(tiles.empty());
4283 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); 4283 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles);
4284 } 4284 }
4285 4285
4286 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 4286 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
4287 AppendQuadsData data; 4287 AppendQuadsData data;
4288 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, NULL); 4288 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr);
4289 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data); 4289 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data);
4290 active_layer_->DidDraw(NULL); 4290 active_layer_->DidDraw(nullptr);
4291 4291
4292 DrawQuad::Material expected = test_for_solid 4292 DrawQuad::Material expected = test_for_solid
4293 ? DrawQuad::Material::SOLID_COLOR 4293 ? DrawQuad::Material::SOLID_COLOR
4294 : DrawQuad::Material::TILED_CONTENT; 4294 : DrawQuad::Material::TILED_CONTENT;
4295 EXPECT_EQ(expected, render_pass->quad_list.front()->material); 4295 EXPECT_EQ(expected, render_pass->quad_list.front()->material);
4296 } 4296 }
4297 4297
4298 TEST_F(PictureLayerImplTest, DrawSolidQuads) { 4298 TEST_F(PictureLayerImplTest, DrawSolidQuads) {
4299 TestQuadsForSolidColor(true); 4299 TestQuadsForSolidColor(true);
4300 } 4300 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
4370 SetupPendingTree(pending_pile2); 4370 SetupPendingTree(pending_pile2);
4371 ActivateTree(); 4371 ActivateTree();
4372 4372
4373 // We've switched to a solid color, so we should end up with no tilings. 4373 // We've switched to a solid color, so we should end up with no tilings.
4374 ASSERT_TRUE(active_layer_->tilings()); 4374 ASSERT_TRUE(active_layer_->tilings());
4375 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); 4375 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings());
4376 } 4376 }
4377 4377
4378 } // namespace 4378 } // namespace
4379 } // namespace cc 4379 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698