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. |
| 113 EXPECT_GT(pile_->tiling().num_tiles_x(), 2); |
| 114 EXPECT_GT(pile_->tiling().num_tiles_y(), 2); |
| 115 |
| 116 // Record everything. |
| 117 Region invalidation(tiling_rect()); |
| 118 UpdateAndExpandInvalidation(&invalidation, tiling_size(), tiling_rect()); |
| 119 |
| 120 // +----------+-----------------+-----------+ |
| 121 // | | VVVV 1,0| | |
| 122 // | | VVVV | | |
| 123 // | | VVVV | | |
| 124 // | ...|.................|... | |
| 125 // | ...|.................|... | |
| 126 // +----------+-----------------+-----------+ |
| 127 // | ...| |... | |
| 128 // | ...| |... | |
| 129 // | ...| |... | |
| 130 // | ...| |... | |
| 131 // | ...| 1,1|... | |
| 132 // +----------+-----------------+-----------+ |
| 133 // | ...|.................|... | |
| 134 // | ...|.................|... | |
| 135 // +----------+-----------------+-----------+ |
| 136 // |
| 137 // .. = border pixels for tile 1,1 |
| 138 // VV = interest rect (what we will record) |
| 139 // |
| 140 // The first invalidation is inside VV, so it does not touch border pixels of |
| 141 // tile 1,1. |
| 142 // |
| 143 // The second invalidation goes below VV into the .. border pixels of 1,1. |
| 144 |
| 145 // This is the VV interest rect which will be entirely inside 1,0 and not |
| 146 // touch the border of 1,1. |
| 147 gfx::Rect interest_rect( |
| 148 pile_->tiling().TilePositionX(1) + pile_->tiling().border_texels(), |
| 149 0, |
| 150 10, |
| 151 pile_->tiling().TileSizeY(0) - pile_->tiling().border_texels()); |
| 152 |
| 153 // Invalidate tile 1,0 only. This is a rect that avoids the borders of any |
| 154 // other tiles. |
| 155 gfx::Rect invalidate_tile = interest_rect; |
| 156 // This should cause the tile 1,0 to be invalidated and re-recorded. The |
| 157 // invalidation did not need to be expanded. |
| 158 invalidation = invalidate_tile; |
| 159 UpdateAndExpandInvalidation(&invalidation, tiling_size(), interest_rect); |
| 160 EXPECT_EQ(invalidate_tile, invalidation); |
| 161 |
| 162 // Invalidate tile 1,0 and 1,1 by invalidating something that only touches the |
| 163 // border of 1,1 (and is inside the tile bounds of 1,0). This is a 10px wide |
| 164 // strip from the top of the tiling onto the border pixels of tile 1,1 that |
| 165 // avoids border pixels of any other tiles. |
| 166 gfx::Rect invalidate_border = interest_rect; |
| 167 invalidate_border.Inset(0, 0, 0, -1); |
| 168 // This should cause the tile 1,0 and 1,1 to be invalidated. The 1,1 tile will |
| 169 // not be re-recorded since it does not touch the interest rect, so the |
| 170 // invalidation should be expanded to cover all of 1,1. |
| 171 invalidation = invalidate_border; |
| 172 UpdateAndExpandInvalidation(&invalidation, tiling_size(), interest_rect); |
| 173 Region expected_invalidation = invalidate_border; |
| 174 expected_invalidation.Union(pile_->tiling().TileBounds(1, 1)); |
| 175 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); |
| 176 } |
| 177 |
102 TEST_F(PicturePileTest, SmallInvalidateInflated) { | 178 TEST_F(PicturePileTest, SmallInvalidateInflated) { |
103 // Invalidate something inside a tile. | 179 // Invalidate something inside a tile. |
104 Region invalidate_rect(gfx::Rect(50, 50, 1, 1)); | 180 Region invalidate_rect(gfx::Rect(50, 50, 1, 1)); |
105 UpdateAndExpandInvalidation(&invalidate_rect, tiling_size(), tiling_rect()); | 181 UpdateAndExpandInvalidation(&invalidate_rect, tiling_size(), tiling_rect()); |
106 EXPECT_EQ(gfx::Rect(50, 50, 1, 1).ToString(), invalidate_rect.ToString()); | 182 EXPECT_EQ(gfx::Rect(50, 50, 1, 1).ToString(), invalidate_rect.ToString()); |
107 | 183 |
108 EXPECT_EQ(1, pile_->tiling().num_tiles_x()); | 184 EXPECT_EQ(1, pile_->tiling().num_tiles_x()); |
109 EXPECT_EQ(1, pile_->tiling().num_tiles_y()); | 185 EXPECT_EQ(1, pile_->tiling().num_tiles_y()); |
110 | 186 |
111 TestPicturePile::PictureInfo& picture_info = | 187 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); | 1429 client_.add_draw_rect(tiling_rect(), paint); |
1354 client_.add_draw_rect(tiling_rect(), paint); | 1430 client_.add_draw_rect(tiling_rect(), paint); |
1355 client_.add_draw_rect(tiling_rect(), paint); | 1431 client_.add_draw_rect(tiling_rect(), paint); |
1356 Region invalidation5(tiling_rect()); | 1432 Region invalidation5(tiling_rect()); |
1357 UpdateAndExpandInvalidation(&invalidation5, tiling_size(), tiling_rect()); | 1433 UpdateAndExpandInvalidation(&invalidation5, tiling_size(), tiling_rect()); |
1358 EXPECT_FALSE(pile_->is_solid_color()); | 1434 EXPECT_FALSE(pile_->is_solid_color()); |
1359 } | 1435 } |
1360 | 1436 |
1361 } // namespace | 1437 } // namespace |
1362 } // namespace cc | 1438 } // namespace cc |
OLD | NEW |