Chromium Code Reviews| 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 <map> | 5 #include <map> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "cc/resources/picture_pile.h" | 8 #include "cc/resources/picture_pile.h" |
| 9 #include "cc/test/fake_content_layer_client.h" | 9 #include "cc/test/fake_content_layer_client.h" |
| 10 #include "cc/test/fake_rendering_stats_instrumentation.h" | 10 #include "cc/test/fake_rendering_stats_instrumentation.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 float min_scale_; | 92 float min_scale_; |
| 93 int frame_number_; | 93 int frame_number_; |
| 94 bool contents_opaque_; | 94 bool contents_opaque_; |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 class PicturePileTest : public PicturePileTestBase, public testing::Test { | 97 class PicturePileTest : public PicturePileTestBase, public testing::Test { |
| 98 public: | 98 public: |
| 99 virtual void SetUp() override { InitializeData(); } | 99 virtual void SetUp() override { InitializeData(); } |
| 100 }; | 100 }; |
| 101 | 101 |
| 102 TEST_F(PicturePileTest, InvalidationOnTileBorderOutsideInterestRect) { | |
| 103 // Don't expand the interest rect past what we invalidate. | |
| 104 pile_->SetPixelRecordDistanceForTesting(0); | |
| 105 | |
| 106 gfx::Size tile_size(100, 100); | |
| 107 pile_->tiling().SetMaxTextureSize(tile_size); | |
| 108 | |
| 109 gfx::Size pile_size(400, 400); | |
| 110 SetTilingSize(pile_size); | |
| 111 | |
| 112 // We have multiple tiles. | |
|
vmpstr
2014/10/15 19:00:20
Can you explain in the comment why 5 not 4?
danakj
2014/10/15 19:06:27
Cuz borders :D I could just > 1 instead.. maybe th
| |
| 113 EXPECT_EQ(5, pile_->tiling().num_tiles_x()); | |
| 114 EXPECT_EQ(5, pile_->tiling().num_tiles_y()); | |
| 115 | |
| 116 // Record everything. | |
| 117 Region invalidation(tiling_rect()); | |
| 118 UpdateAndExpandInvalidation(&invalidation, tiling_size(), tiling_rect()); | |
| 119 | |
| 120 // The interest rect will be entirely inside 1,0 and not touch the border of | |
| 121 // 1,1. | |
| 122 gfx::Rect interest_rect( | |
| 123 pile_->tiling().TilePositionX(1) + pile_->tiling().border_texels(), | |
| 124 0, | |
| 125 10, | |
| 126 pile_->tiling().TileSizeY(0) - pile_->tiling().border_texels()); | |
| 127 | |
| 128 // Invalidate tile 1,0 only. This is a rect that avoids the borders of any | |
| 129 // other tiles. | |
| 130 gfx::Rect invalidate_tile = interest_rect; | |
| 131 // This should cause the tile 1,0 to be invalidated and re-recorded. The | |
| 132 // invalidation did not need to be expanded. | |
| 133 invalidation = invalidate_tile; | |
| 134 UpdateAndExpandInvalidation(&invalidation, tiling_size(), interest_rect); | |
| 135 EXPECT_EQ(invalidate_tile, invalidation); | |
| 136 | |
| 137 // Invalidate tile 1,0 and 1,1 by invalidating something that only touches the | |
| 138 // border of 1,1 (and is inside the tile bounds of 1,0). This is a 10px wide | |
| 139 // strip from the top of the tiling onto the border pixels of tile 1,1 that | |
| 140 // avoids border pixels of any other tiles. | |
| 141 gfx::Rect invalidate_border(pile_->tiling().TilePositionX(1) + 10, | |
| 142 0, | |
| 143 10, | |
| 144 pile_->tiling().TileSizeY(0)); | |
|
vmpstr
2014/10/15 19:00:20
Can you assert somewhere that pile_->tiling().bord
danakj
2014/10/15 19:06:27
It's not 1. The recording border pixels are more.
| |
| 145 // This should cause the tile 1,0 and 1,1 to be invalidated, and 1,1 will not | |
|
vmpstr
2014/10/15 19:00:20
"and 1,1 will not be re-recorded" Can you elaborat
danakj
2014/10/15 19:06:27
It's because the interest rect doesn't touch it. I
| |
| 146 // be re-recorded. So the invalidation should be expanded to cover all of 1,1. | |
| 147 invalidation = invalidate_border; | |
| 148 UpdateAndExpandInvalidation(&invalidation, tiling_size(), interest_rect); | |
| 149 Region expected_invalidation = invalidate_border; | |
| 150 expected_invalidation.Union(pile_->tiling().TileBounds(1, 1)); | |
| 151 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); | |
| 152 } | |
| 153 | |
| 102 TEST_F(PicturePileTest, SmallInvalidateInflated) { | 154 TEST_F(PicturePileTest, SmallInvalidateInflated) { |
| 103 // Invalidate something inside a tile. | 155 // Invalidate something inside a tile. |
| 104 Region invalidate_rect(gfx::Rect(50, 50, 1, 1)); | 156 Region invalidate_rect(gfx::Rect(50, 50, 1, 1)); |
| 105 UpdateAndExpandInvalidation(&invalidate_rect, tiling_size(), tiling_rect()); | 157 UpdateAndExpandInvalidation(&invalidate_rect, tiling_size(), tiling_rect()); |
| 106 EXPECT_EQ(gfx::Rect(50, 50, 1, 1).ToString(), invalidate_rect.ToString()); | 158 EXPECT_EQ(gfx::Rect(50, 50, 1, 1).ToString(), invalidate_rect.ToString()); |
| 107 | 159 |
| 108 EXPECT_EQ(1, pile_->tiling().num_tiles_x()); | 160 EXPECT_EQ(1, pile_->tiling().num_tiles_x()); |
| 109 EXPECT_EQ(1, pile_->tiling().num_tiles_y()); | 161 EXPECT_EQ(1, pile_->tiling().num_tiles_y()); |
| 110 | 162 |
| 111 TestPicturePile::PictureInfo& picture_info = | 163 TestPicturePile::PictureInfo& picture_info = |
| (...skipping 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1353 client_.add_draw_rect(tiling_rect(), paint); | 1405 client_.add_draw_rect(tiling_rect(), paint); |
| 1354 client_.add_draw_rect(tiling_rect(), paint); | 1406 client_.add_draw_rect(tiling_rect(), paint); |
| 1355 client_.add_draw_rect(tiling_rect(), paint); | 1407 client_.add_draw_rect(tiling_rect(), paint); |
| 1356 Region invalidation5(tiling_rect()); | 1408 Region invalidation5(tiling_rect()); |
| 1357 UpdateAndExpandInvalidation(&invalidation5, tiling_size(), tiling_rect()); | 1409 UpdateAndExpandInvalidation(&invalidation5, tiling_size(), tiling_rect()); |
| 1358 EXPECT_FALSE(pile_->is_solid_color()); | 1410 EXPECT_FALSE(pile_->is_solid_color()); |
| 1359 } | 1411 } |
| 1360 | 1412 |
| 1361 } // namespace | 1413 } // namespace |
| 1362 } // namespace cc | 1414 } // namespace cc |
| OLD | NEW |