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

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: foramted. 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, MarkRequiredOffscreenTiles) { 1393 TEST_F(PictureLayerImplTest, MarkRequiredOffscreenTiles) {
1394 gfx::Size tile_size(100, 100); 1394 gfx::Size tile_size(100, 100);
1395 gfx::Size layer_bounds(200, 200); 1395 gfx::Size layer_bounds(200, 200);
1396 1396
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1514 EXPECT_GT(num_inside, 0); 1514 EXPECT_GT(num_inside, 0);
1515 EXPECT_GT(num_outside, 0); 1515 EXPECT_GT(num_outside, 0);
1516 1516
1517 // Activate and draw active layer. 1517 // Activate and draw active layer.
1518 host_impl_.ActivateSyncTree(); 1518 host_impl_.ActivateSyncTree();
1519 host_impl_.active_tree()->UpdateDrawProperties(); 1519 host_impl_.active_tree()->UpdateDrawProperties();
1520 active_layer_->draw_properties().visible_content_rect = visible_content_rect; 1520 active_layer_->draw_properties().visible_content_rect = visible_content_rect;
1521 1521
1522 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 1522 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
1523 AppendQuadsData data; 1523 AppendQuadsData data;
1524 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, NULL); 1524 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr);
1525 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data); 1525 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data);
1526 active_layer_->DidDraw(NULL); 1526 active_layer_->DidDraw(nullptr);
1527 1527
1528 // All tiles in activation rect is ready to draw. 1528 // All tiles in activation rect is ready to draw.
1529 EXPECT_EQ(0u, data.num_missing_tiles); 1529 EXPECT_EQ(0u, data.num_missing_tiles);
1530 EXPECT_EQ(0u, data.num_incomplete_tiles); 1530 EXPECT_EQ(0u, data.num_incomplete_tiles);
1531 EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads()); 1531 EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads());
1532 } 1532 }
1533 1533
1534 TEST_F(PictureLayerImplTest, HighResTileIsComplete) { 1534 TEST_F(PictureLayerImplTest, HighResTileIsComplete) {
1535 base::TimeTicks time_ticks; 1535 base::TimeTicks time_ticks;
1536 time_ticks += base::TimeDelta::FromMilliseconds(1); 1536 time_ticks += base::TimeDelta::FromMilliseconds(1);
(...skipping 12 matching lines...) Expand all
1549 1549
1550 // All high res tiles have resources. 1550 // All high res tiles have resources.
1551 active_layer_->set_fixed_tile_size(tile_size); 1551 active_layer_->set_fixed_tile_size(tile_size);
1552 host_impl_.active_tree()->UpdateDrawProperties(); 1552 host_impl_.active_tree()->UpdateDrawProperties();
1553 std::vector<Tile*> tiles = 1553 std::vector<Tile*> tiles =
1554 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); 1554 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting();
1555 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); 1555 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles);
1556 1556
1557 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 1557 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
1558 AppendQuadsData data; 1558 AppendQuadsData data;
1559 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, NULL); 1559 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr);
1560 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data); 1560 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data);
1561 active_layer_->DidDraw(NULL); 1561 active_layer_->DidDraw(nullptr);
1562 1562
1563 // All high res tiles drew, nothing was incomplete. 1563 // All high res tiles drew, nothing was incomplete.
1564 EXPECT_EQ(9u, render_pass->quad_list.size()); 1564 EXPECT_EQ(9u, render_pass->quad_list.size());
1565 EXPECT_EQ(0u, data.num_missing_tiles); 1565 EXPECT_EQ(0u, data.num_missing_tiles);
1566 EXPECT_EQ(0u, data.num_incomplete_tiles); 1566 EXPECT_EQ(0u, data.num_incomplete_tiles);
1567 EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads()); 1567 EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads());
1568 } 1568 }
1569 1569
1570 TEST_F(PictureLayerImplTest, HighResTileIsIncomplete) { 1570 TEST_F(PictureLayerImplTest, HighResTileIsIncomplete) {
1571 base::TimeTicks time_ticks; 1571 base::TimeTicks time_ticks;
1572 time_ticks += base::TimeDelta::FromMilliseconds(1); 1572 time_ticks += base::TimeDelta::FromMilliseconds(1);
1573 host_impl_.SetCurrentBeginFrameArgs( 1573 host_impl_.SetCurrentBeginFrameArgs(
1574 CreateBeginFrameArgsForTesting(time_ticks)); 1574 CreateBeginFrameArgsForTesting(time_ticks));
1575 1575
1576 gfx::Size tile_size(100, 100); 1576 gfx::Size tile_size(100, 100);
1577 gfx::Size layer_bounds(200, 200); 1577 gfx::Size layer_bounds(200, 200);
1578 1578
1579 host_impl_.SetViewportSize(layer_bounds); 1579 host_impl_.SetViewportSize(layer_bounds);
1580 1580
1581 scoped_refptr<FakePicturePileImpl> pending_pile = 1581 scoped_refptr<FakePicturePileImpl> pending_pile =
1582 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); 1582 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
1583 SetupPendingTree(pending_pile); 1583 SetupPendingTree(pending_pile);
1584 ActivateTree(); 1584 ActivateTree();
1585 1585
1586 active_layer_->set_fixed_tile_size(tile_size); 1586 active_layer_->set_fixed_tile_size(tile_size);
1587 host_impl_.active_tree()->UpdateDrawProperties(); 1587 host_impl_.active_tree()->UpdateDrawProperties();
1588 1588
1589 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 1589 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
1590 AppendQuadsData data; 1590 AppendQuadsData data;
1591 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, NULL); 1591 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr);
1592 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data); 1592 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data);
1593 active_layer_->DidDraw(NULL); 1593 active_layer_->DidDraw(nullptr);
1594 1594
1595 EXPECT_EQ(1u, render_pass->quad_list.size()); 1595 EXPECT_EQ(1u, render_pass->quad_list.size());
1596 EXPECT_EQ(1u, data.num_missing_tiles); 1596 EXPECT_EQ(1u, data.num_missing_tiles);
1597 EXPECT_EQ(0u, data.num_incomplete_tiles); 1597 EXPECT_EQ(0u, data.num_incomplete_tiles);
1598 EXPECT_TRUE(active_layer_->only_used_low_res_last_append_quads()); 1598 EXPECT_TRUE(active_layer_->only_used_low_res_last_append_quads());
1599 } 1599 }
1600 1600
1601 TEST_F(PictureLayerImplTest, HighResTileIsIncompleteLowResComplete) { 1601 TEST_F(PictureLayerImplTest, HighResTileIsIncompleteLowResComplete) {
1602 base::TimeTicks time_ticks; 1602 base::TimeTicks time_ticks;
1603 time_ticks += base::TimeDelta::FromMilliseconds(1); 1603 time_ticks += base::TimeDelta::FromMilliseconds(1);
(...skipping 11 matching lines...) Expand all
1615 ActivateTree(); 1615 ActivateTree();
1616 1616
1617 active_layer_->set_fixed_tile_size(tile_size); 1617 active_layer_->set_fixed_tile_size(tile_size);
1618 host_impl_.active_tree()->UpdateDrawProperties(); 1618 host_impl_.active_tree()->UpdateDrawProperties();
1619 std::vector<Tile*> low_tiles = 1619 std::vector<Tile*> low_tiles =
1620 active_layer_->tilings()->tiling_at(1)->AllTilesForTesting(); 1620 active_layer_->tilings()->tiling_at(1)->AllTilesForTesting();
1621 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(low_tiles); 1621 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(low_tiles);
1622 1622
1623 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 1623 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
1624 AppendQuadsData data; 1624 AppendQuadsData data;
1625 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, NULL); 1625 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr);
1626 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data); 1626 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data);
1627 active_layer_->DidDraw(NULL); 1627 active_layer_->DidDraw(nullptr);
1628 1628
1629 EXPECT_EQ(1u, render_pass->quad_list.size()); 1629 EXPECT_EQ(1u, render_pass->quad_list.size());
1630 EXPECT_EQ(0u, data.num_missing_tiles); 1630 EXPECT_EQ(0u, data.num_missing_tiles);
1631 EXPECT_EQ(1u, data.num_incomplete_tiles); 1631 EXPECT_EQ(1u, data.num_incomplete_tiles);
1632 EXPECT_TRUE(active_layer_->only_used_low_res_last_append_quads()); 1632 EXPECT_TRUE(active_layer_->only_used_low_res_last_append_quads());
1633 } 1633 }
1634 1634
1635 TEST_F(PictureLayerImplTest, LowResTileIsIncomplete) { 1635 TEST_F(PictureLayerImplTest, LowResTileIsIncomplete) {
1636 base::TimeTicks time_ticks; 1636 base::TimeTicks time_ticks;
1637 time_ticks += base::TimeDelta::FromMilliseconds(1); 1637 time_ticks += base::TimeDelta::FromMilliseconds(1);
(...skipping 18 matching lines...) Expand all
1656 high_tiles.erase(high_tiles.begin()); 1656 high_tiles.erase(high_tiles.begin());
1657 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(high_tiles); 1657 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(high_tiles);
1658 1658
1659 // All low res tiles have resources. 1659 // All low res tiles have resources.
1660 std::vector<Tile*> low_tiles = 1660 std::vector<Tile*> low_tiles =
1661 active_layer_->tilings()->tiling_at(1)->AllTilesForTesting(); 1661 active_layer_->tilings()->tiling_at(1)->AllTilesForTesting();
1662 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(low_tiles); 1662 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(low_tiles);
1663 1663
1664 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 1664 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
1665 AppendQuadsData data; 1665 AppendQuadsData data;
1666 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, NULL); 1666 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr);
1667 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data); 1667 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data);
1668 active_layer_->DidDraw(NULL); 1668 active_layer_->DidDraw(nullptr);
1669 1669
1670 // The missing high res tile was replaced by a low res tile. 1670 // The missing high res tile was replaced by a low res tile.
1671 EXPECT_EQ(9u, render_pass->quad_list.size()); 1671 EXPECT_EQ(9u, render_pass->quad_list.size());
1672 EXPECT_EQ(0u, data.num_missing_tiles); 1672 EXPECT_EQ(0u, data.num_missing_tiles);
1673 EXPECT_EQ(1u, data.num_incomplete_tiles); 1673 EXPECT_EQ(1u, data.num_incomplete_tiles);
1674 EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads()); 1674 EXPECT_FALSE(active_layer_->only_used_low_res_last_append_quads());
1675 } 1675 }
1676 1676
1677 TEST_F(PictureLayerImplTest, 1677 TEST_F(PictureLayerImplTest,
1678 HighResAndIdealResTileIsCompleteWhenRasterScaleIsNotIdeal) { 1678 HighResAndIdealResTileIsCompleteWhenRasterScaleIsNotIdeal) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1718 EXPECT_EQ(2.f, active_layer_->tilings()->tiling_at(0)->contents_scale()); 1718 EXPECT_EQ(2.f, active_layer_->tilings()->tiling_at(0)->contents_scale());
1719 EXPECT_EQ(1.f, active_layer_->tilings()->tiling_at(1)->contents_scale()); 1719 EXPECT_EQ(1.f, active_layer_->tilings()->tiling_at(1)->contents_scale());
1720 1720
1721 // All high res tiles have resources. 1721 // All high res tiles have resources.
1722 std::vector<Tile*> high_tiles = 1722 std::vector<Tile*> high_tiles =
1723 active_layer_->HighResTiling()->AllTilesForTesting(); 1723 active_layer_->HighResTiling()->AllTilesForTesting();
1724 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(high_tiles); 1724 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(high_tiles);
1725 1725
1726 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 1726 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
1727 AppendQuadsData data; 1727 AppendQuadsData data;
1728 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, NULL); 1728 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr);
1729 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data); 1729 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data);
1730 active_layer_->DidDraw(NULL); 1730 active_layer_->DidDraw(nullptr);
1731 1731
1732 // All high res tiles drew, and the one ideal res tile drew. 1732 // All high res tiles drew, and the one ideal res tile drew.
1733 ASSERT_GT(render_pass->quad_list.size(), 9u); 1733 ASSERT_GT(render_pass->quad_list.size(), 9u);
1734 EXPECT_EQ(gfx::SizeF(99.f, 99.f), 1734 EXPECT_EQ(gfx::SizeF(99.f, 99.f),
1735 TileDrawQuad::MaterialCast(render_pass->quad_list.front()) 1735 TileDrawQuad::MaterialCast(render_pass->quad_list.front())
1736 ->tex_coord_rect.size()); 1736 ->tex_coord_rect.size());
1737 EXPECT_EQ(gfx::SizeF(49.5f, 49.5f), 1737 EXPECT_EQ(gfx::SizeF(49.5f, 49.5f),
1738 TileDrawQuad::MaterialCast(render_pass->quad_list.ElementAt(1)) 1738 TileDrawQuad::MaterialCast(render_pass->quad_list.ElementAt(1))
1739 ->tex_coord_rect.size()); 1739 ->tex_coord_rect.size());
1740 1740
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
2162 // Sanity checks. 2162 // Sanity checks.
2163 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); 2163 ASSERT_EQ(3u, active_layer_->tilings()->num_tilings());
2164 ASSERT_EQ(tiling, active_layer_->tilings()->TilingAtScale(0.5f)); 2164 ASSERT_EQ(tiling, active_layer_->tilings()->TilingAtScale(0.5f));
2165 2165
2166 // Now, set the bounds to be 1x1 (so that minimum contents scale becomes 2166 // Now, set the bounds to be 1x1 (so that minimum contents scale becomes
2167 // 1.0f). Note that we should also ensure that the pending layer needs post 2167 // 1.0f). Note that we should also ensure that the pending layer needs post
2168 // commit initialization, since this is what would happen during commit. In 2168 // commit initialization, since this is what would happen during commit. In
2169 // other words we want the pending layer to sync from the active layer. 2169 // other words we want the pending layer to sync from the active layer.
2170 pending_layer_->SetBounds(gfx::Size(1, 1)); 2170 pending_layer_->SetBounds(gfx::Size(1, 1));
2171 pending_layer_->SetNeedsPostCommitInitialization(); 2171 pending_layer_->SetNeedsPostCommitInitialization();
2172 pending_layer_->set_twin_layer(NULL); 2172 pending_layer_->set_twin_layer(nullptr);
2173 active_layer_->set_twin_layer(NULL); 2173 active_layer_->set_twin_layer(nullptr);
2174 EXPECT_TRUE(pending_layer_->needs_post_commit_initialization()); 2174 EXPECT_TRUE(pending_layer_->needs_post_commit_initialization());
2175 2175
2176 // Update the draw properties: sync from active tree should happen here. 2176 // Update the draw properties: sync from active tree should happen here.
2177 host_impl_.pending_tree()->UpdateDrawProperties(); 2177 host_impl_.pending_tree()->UpdateDrawProperties();
2178 2178
2179 // Another sanity check. 2179 // Another sanity check.
2180 ASSERT_EQ(1.f, pending_layer_->MinimumContentsScale()); 2180 ASSERT_EQ(1.f, pending_layer_->MinimumContentsScale());
2181 2181
2182 // Now we should've synced 1.5f tiling, since that's the only one that doesn't 2182 // Now we should've synced 1.5f tiling, since that's the only one that doesn't
2183 // violate minimum contents scale. At the same time, we should've created a 2183 // 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
2782 it = PictureLayerImpl::LayerEvictionTileIterator( 2782 it = PictureLayerImpl::LayerEvictionTileIterator(
2783 pending_layer_, SAME_PRIORITY_FOR_BOTH_TREES); 2783 pending_layer_, SAME_PRIORITY_FOR_BOTH_TREES);
2784 EXPECT_FALSE(it); 2784 EXPECT_FALSE(it);
2785 2785
2786 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles); 2786 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(all_tiles);
2787 2787
2788 std::set<Tile*> unique_tiles; 2788 std::set<Tile*> unique_tiles;
2789 float expected_scales[] = {2.0f, 0.3f, 0.7f, low_res_factor, 1.0f}; 2789 float expected_scales[] = {2.0f, 0.3f, 0.7f, low_res_factor, 1.0f};
2790 size_t scale_index = 0; 2790 size_t scale_index = 0;
2791 bool reached_visible = false; 2791 bool reached_visible = false;
2792 Tile* last_tile = NULL; 2792 Tile* last_tile = nullptr;
2793 for (it = PictureLayerImpl::LayerEvictionTileIterator( 2793 for (it = PictureLayerImpl::LayerEvictionTileIterator(
2794 pending_layer_, SAME_PRIORITY_FOR_BOTH_TREES); 2794 pending_layer_, SAME_PRIORITY_FOR_BOTH_TREES);
2795 it; 2795 it;
2796 ++it) { 2796 ++it) {
2797 Tile* tile = *it; 2797 Tile* tile = *it;
2798 if (!last_tile) 2798 if (!last_tile)
2799 last_tile = tile; 2799 last_tile = tile;
2800 2800
2801 EXPECT_TRUE(tile); 2801 EXPECT_TRUE(tile);
2802 2802
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
3611 size_t resource_limit = max_tiles; 3611 size_t resource_limit = max_tiles;
3612 ManagedMemoryPolicy policy(memory_limit, 3612 ManagedMemoryPolicy policy(memory_limit,
3613 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, 3613 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING,
3614 resource_limit); 3614 resource_limit);
3615 host_impl_.SetMemoryPolicy(policy); 3615 host_impl_.SetMemoryPolicy(policy);
3616 host_impl_.SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES); 3616 host_impl_.SetTreePriority(SAME_PRIORITY_FOR_BOTH_TREES);
3617 host_impl_.ManageTiles(); 3617 host_impl_.ManageTiles();
3618 3618
3619 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 3619 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
3620 AppendQuadsData data; 3620 AppendQuadsData data;
3621 active_layer_->WillDraw(DRAW_MODE_HARDWARE, NULL); 3621 active_layer_->WillDraw(DRAW_MODE_HARDWARE, nullptr);
3622 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data); 3622 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data);
3623 active_layer_->DidDraw(NULL); 3623 active_layer_->DidDraw(nullptr);
3624 3624
3625 // Even when OOM, quads should be produced, and should be different material 3625 // Even when OOM, quads should be produced, and should be different material
3626 // from quads with resource. 3626 // from quads with resource.
3627 EXPECT_LT(max_tiles, render_pass->quad_list.size()); 3627 EXPECT_LT(max_tiles, render_pass->quad_list.size());
3628 EXPECT_EQ(DrawQuad::Material::TILED_CONTENT, 3628 EXPECT_EQ(DrawQuad::Material::TILED_CONTENT,
3629 render_pass->quad_list.front()->material); 3629 render_pass->quad_list.front()->material);
3630 EXPECT_EQ(DrawQuad::Material::SOLID_COLOR, 3630 EXPECT_EQ(DrawQuad::Material::SOLID_COLOR,
3631 render_pass->quad_list.back()->material); 3631 render_pass->quad_list.back()->material);
3632 } 3632 }
3633 3633
3634 class OcclusionTrackingSettings : public LowResTilingsSettings { 3634 class OcclusionTrackingSettings : public LowResTilingsSettings {
3635 public: 3635 public:
3636 OcclusionTrackingSettings() { use_occlusion_for_tile_prioritization = true; } 3636 OcclusionTrackingSettings() { use_occlusion_for_tile_prioritization = true; }
3637 }; 3637 };
3638 3638
3639 class OcclusionTrackingPictureLayerImplTest : public PictureLayerImplTest { 3639 class OcclusionTrackingPictureLayerImplTest : public PictureLayerImplTest {
3640 public: 3640 public:
3641 OcclusionTrackingPictureLayerImplTest() 3641 OcclusionTrackingPictureLayerImplTest()
3642 : PictureLayerImplTest(OcclusionTrackingSettings()) {} 3642 : PictureLayerImplTest(OcclusionTrackingSettings()) {}
3643 3643
3644 void VerifyEvictionConsidersOcclusion( 3644 void VerifyEvictionConsidersOcclusion(
3645 PictureLayerImpl* layer, 3645 PictureLayerImpl* layer,
3646 size_t expected_occluded_tile_count[NUM_TREE_PRIORITIES]) { 3646 size_t expected_occluded_tile_count[NUM_TREE_PRIORITIES]) {
3647 for (int priority_count = 0; priority_count < NUM_TREE_PRIORITIES; 3647 for (int priority_count = 0; priority_count < NUM_TREE_PRIORITIES;
3648 ++priority_count) { 3648 ++priority_count) {
3649 TreePriority tree_priority = static_cast<TreePriority>(priority_count); 3649 TreePriority tree_priority = static_cast<TreePriority>(priority_count);
3650 size_t occluded_tile_count = 0u; 3650 size_t occluded_tile_count = 0u;
3651 Tile* last_tile = NULL; 3651 Tile* last_tile = nullptr;
3652 3652
3653 for (PictureLayerImpl::LayerEvictionTileIterator it = 3653 for (PictureLayerImpl::LayerEvictionTileIterator it =
3654 PictureLayerImpl::LayerEvictionTileIterator(layer, 3654 PictureLayerImpl::LayerEvictionTileIterator(layer,
3655 tree_priority); 3655 tree_priority);
3656 it; 3656 it;
3657 ++it) { 3657 ++it) {
3658 Tile* tile = *it; 3658 Tile* tile = *it;
3659 if (!last_tile) 3659 if (!last_tile)
3660 last_tile = tile; 3660 last_tile = tile;
3661 3661
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
4327 host_impl_.active_tree()->UpdateDrawProperties(); 4327 host_impl_.active_tree()->UpdateDrawProperties();
4328 ASSERT_GT(active_layer_->tilings()->num_tilings(), 0u); 4328 ASSERT_GT(active_layer_->tilings()->num_tilings(), 0u);
4329 std::vector<Tile*> tiles = 4329 std::vector<Tile*> tiles =
4330 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting(); 4330 active_layer_->tilings()->tiling_at(0)->AllTilesForTesting();
4331 EXPECT_FALSE(tiles.empty()); 4331 EXPECT_FALSE(tiles.empty());
4332 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); 4332 host_impl_.tile_manager()->InitializeTilesWithResourcesForTesting(tiles);
4333 } 4333 }
4334 4334
4335 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); 4335 scoped_ptr<RenderPass> render_pass = RenderPass::Create();
4336 AppendQuadsData data; 4336 AppendQuadsData data;
4337 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, NULL); 4337 active_layer_->WillDraw(DRAW_MODE_SOFTWARE, nullptr);
4338 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data); 4338 active_layer_->AppendQuads(render_pass.get(), Occlusion(), &data);
4339 active_layer_->DidDraw(NULL); 4339 active_layer_->DidDraw(nullptr);
4340 4340
4341 DrawQuad::Material expected = test_for_solid 4341 DrawQuad::Material expected = test_for_solid
4342 ? DrawQuad::Material::SOLID_COLOR 4342 ? DrawQuad::Material::SOLID_COLOR
4343 : DrawQuad::Material::TILED_CONTENT; 4343 : DrawQuad::Material::TILED_CONTENT;
4344 EXPECT_EQ(expected, render_pass->quad_list.front()->material); 4344 EXPECT_EQ(expected, render_pass->quad_list.front()->material);
4345 } 4345 }
4346 4346
4347 TEST_F(PictureLayerImplTest, DrawSolidQuads) { 4347 TEST_F(PictureLayerImplTest, DrawSolidQuads) {
4348 TestQuadsForSolidColor(true); 4348 TestQuadsForSolidColor(true);
4349 } 4349 }
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
4487 result = layer->CalculateTileSize(gfx::Size(447, 400)); 4487 result = layer->CalculateTileSize(gfx::Size(447, 400));
4488 EXPECT_EQ(result.width(), 448); 4488 EXPECT_EQ(result.width(), 448);
4489 EXPECT_EQ(result.height(), 448); 4489 EXPECT_EQ(result.height(), 448);
4490 result = layer->CalculateTileSize(gfx::Size(500, 499)); 4490 result = layer->CalculateTileSize(gfx::Size(500, 499));
4491 EXPECT_EQ(result.width(), 512); 4491 EXPECT_EQ(result.width(), 512);
4492 EXPECT_EQ(result.height(), 500); 4492 EXPECT_EQ(result.height(), 500);
4493 } 4493 }
4494 4494
4495 } // namespace 4495 } // namespace
4496 } // namespace cc 4496 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698