| 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_picture_pile.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "ui/gfx/geometry/rect_conversions.h" | 12 #include "ui/gfx/geometry/rect_conversions.h" |
| 12 #include "ui/gfx/geometry/size_conversions.h" | 13 #include "ui/gfx/geometry/size_conversions.h" |
| 13 | 14 |
| 14 namespace cc { | 15 namespace cc { |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| 17 class TestPicturePile : public PicturePile { | |
| 18 public: | |
| 19 ~TestPicturePile() override {} | |
| 20 | |
| 21 using PicturePile::buffer_pixels; | |
| 22 using PicturePile::CanRasterSlowTileCheck; | |
| 23 using PicturePile::Clear; | |
| 24 | |
| 25 PictureMap& picture_map() { return picture_map_; } | |
| 26 const gfx::Rect& recorded_viewport() const { return recorded_viewport_; } | |
| 27 | |
| 28 bool CanRasterLayerRect(gfx::Rect layer_rect) { | |
| 29 layer_rect.Intersect(gfx::Rect(tiling_.tiling_size())); | |
| 30 if (recorded_viewport_.Contains(layer_rect)) | |
| 31 return true; | |
| 32 return CanRasterSlowTileCheck(layer_rect); | |
| 33 } | |
| 34 | |
| 35 bool HasRecordings() const { return has_any_recordings_; } | |
| 36 | |
| 37 typedef PicturePile::PictureInfo PictureInfo; | |
| 38 typedef PicturePile::PictureMapKey PictureMapKey; | |
| 39 typedef PicturePile::PictureMap PictureMap; | |
| 40 }; | |
| 41 | |
| 42 class PicturePileTestBase { | 18 class PicturePileTestBase { |
| 43 public: | 19 public: |
| 44 PicturePileTestBase() | 20 PicturePileTestBase() |
| 45 : background_color_(SK_ColorBLUE), | 21 : background_color_(SK_ColorBLUE), |
| 46 min_scale_(0.125), | 22 min_scale_(0.125), |
| 47 frame_number_(0), | 23 frame_number_(0), |
| 48 contents_opaque_(false) {} | 24 contents_opaque_(false) {} |
| 49 | 25 |
| 50 void InitializeData() { | 26 void InitializeData() { |
| 51 pile_.SetTileGridSize(gfx::Size(1000, 1000)); | 27 pile_.SetTileGridSize(gfx::Size(1000, 1000)); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 75 | 51 |
| 76 bool UpdateWholePile() { | 52 bool UpdateWholePile() { |
| 77 Region invalidation = tiling_rect(); | 53 Region invalidation = tiling_rect(); |
| 78 bool result = UpdateAndExpandInvalidation(&invalidation, tiling_size(), | 54 bool result = UpdateAndExpandInvalidation(&invalidation, tiling_size(), |
| 79 tiling_rect()); | 55 tiling_rect()); |
| 80 EXPECT_EQ(tiling_rect().ToString(), invalidation.ToString()); | 56 EXPECT_EQ(tiling_rect().ToString(), invalidation.ToString()); |
| 81 return result; | 57 return result; |
| 82 } | 58 } |
| 83 | 59 |
| 84 FakeContentLayerClient client_; | 60 FakeContentLayerClient client_; |
| 85 TestPicturePile pile_; | 61 FakePicturePile pile_; |
| 86 SkColor background_color_; | 62 SkColor background_color_; |
| 87 float min_scale_; | 63 float min_scale_; |
| 88 int frame_number_; | 64 int frame_number_; |
| 89 bool contents_opaque_; | 65 bool contents_opaque_; |
| 90 }; | 66 }; |
| 91 | 67 |
| 92 class PicturePileTest : public PicturePileTestBase, public testing::Test { | 68 class PicturePileTest : public PicturePileTestBase, public testing::Test { |
| 93 public: | 69 public: |
| 94 virtual void SetUp() override { InitializeData(); } | 70 virtual void SetUp() override { InitializeData(); } |
| 95 }; | 71 }; |
| 96 | 72 |
| 97 TEST_F(PicturePileTest, InvalidationOnTileBorderOutsideInterestRect) { | 73 TEST_F(PicturePileTest, InvalidationOnTileBorderOutsideInterestRect) { |
| 98 // Don't expand the interest rect past what we invalidate. | 74 // Don't expand the interest rect past what we invalidate. |
| 99 pile_.SetPixelRecordDistanceForTesting(0); | 75 pile_.SetPixelRecordDistance(0); |
| 100 | 76 |
| 101 gfx::Size tile_size(100, 100); | 77 gfx::Size tile_size(100, 100); |
| 102 pile_.tiling().SetMaxTextureSize(tile_size); | 78 pile_.tiling().SetMaxTextureSize(tile_size); |
| 103 | 79 |
| 104 gfx::Size pile_size(400, 400); | 80 gfx::Size pile_size(400, 400); |
| 105 SetTilingSize(pile_size); | 81 SetTilingSize(pile_size); |
| 106 | 82 |
| 107 // We have multiple tiles. | 83 // We have multiple tiles. |
| 108 EXPECT_GT(pile_.tiling().num_tiles_x(), 2); | 84 EXPECT_GT(pile_.tiling().num_tiles_x(), 2); |
| 109 EXPECT_GT(pile_.tiling().num_tiles_y(), 2); | 85 EXPECT_GT(pile_.tiling().num_tiles_y(), 2); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 148 |
| 173 TEST_F(PicturePileTest, SmallInvalidateInflated) { | 149 TEST_F(PicturePileTest, SmallInvalidateInflated) { |
| 174 // Invalidate something inside a tile. | 150 // Invalidate something inside a tile. |
| 175 Region invalidate_rect(gfx::Rect(50, 50, 1, 1)); | 151 Region invalidate_rect(gfx::Rect(50, 50, 1, 1)); |
| 176 UpdateAndExpandInvalidation(&invalidate_rect, tiling_size(), tiling_rect()); | 152 UpdateAndExpandInvalidation(&invalidate_rect, tiling_size(), tiling_rect()); |
| 177 EXPECT_EQ(gfx::Rect(50, 50, 1, 1).ToString(), invalidate_rect.ToString()); | 153 EXPECT_EQ(gfx::Rect(50, 50, 1, 1).ToString(), invalidate_rect.ToString()); |
| 178 | 154 |
| 179 EXPECT_EQ(1, pile_.tiling().num_tiles_x()); | 155 EXPECT_EQ(1, pile_.tiling().num_tiles_x()); |
| 180 EXPECT_EQ(1, pile_.tiling().num_tiles_y()); | 156 EXPECT_EQ(1, pile_.tiling().num_tiles_y()); |
| 181 | 157 |
| 182 TestPicturePile::PictureInfo& picture_info = | 158 FakePicturePile::PictureInfo& picture_info = |
| 183 pile_.picture_map().find(TestPicturePile::PictureMapKey(0, 0))->second; | 159 pile_.picture_map().find(FakePicturePile::PictureMapKey(0, 0))->second; |
| 184 // We should have a picture. | 160 // We should have a picture. |
| 185 EXPECT_TRUE(!!picture_info.GetPicture()); | 161 EXPECT_TRUE(!!picture_info.GetPicture()); |
| 186 gfx::Rect picture_rect = gfx::ScaleToEnclosedRect( | 162 gfx::Rect picture_rect = gfx::ScaleToEnclosedRect( |
| 187 picture_info.GetPicture()->LayerRect(), min_scale_); | 163 picture_info.GetPicture()->LayerRect(), min_scale_); |
| 188 | 164 |
| 189 // The the picture should be large enough that scaling it never makes a rect | 165 // The the picture should be large enough that scaling it never makes a rect |
| 190 // smaller than 1 px wide or tall. | 166 // smaller than 1 px wide or tall. |
| 191 EXPECT_FALSE(picture_rect.IsEmpty()) << "Picture rect " << | 167 EXPECT_FALSE(picture_rect.IsEmpty()) << "Picture rect " << |
| 192 picture_rect.ToString(); | 168 picture_rect.ToString(); |
| 193 } | 169 } |
| 194 | 170 |
| 195 TEST_F(PicturePileTest, LargeInvalidateInflated) { | 171 TEST_F(PicturePileTest, LargeInvalidateInflated) { |
| 196 // Invalidate something inside a tile. | 172 // Invalidate something inside a tile. |
| 197 Region invalidate_rect(gfx::Rect(50, 50, 100, 100)); | 173 Region invalidate_rect(gfx::Rect(50, 50, 100, 100)); |
| 198 UpdateAndExpandInvalidation(&invalidate_rect, tiling_size(), tiling_rect()); | 174 UpdateAndExpandInvalidation(&invalidate_rect, tiling_size(), tiling_rect()); |
| 199 EXPECT_EQ(gfx::Rect(50, 50, 100, 100).ToString(), invalidate_rect.ToString()); | 175 EXPECT_EQ(gfx::Rect(50, 50, 100, 100).ToString(), invalidate_rect.ToString()); |
| 200 | 176 |
| 201 EXPECT_EQ(1, pile_.tiling().num_tiles_x()); | 177 EXPECT_EQ(1, pile_.tiling().num_tiles_x()); |
| 202 EXPECT_EQ(1, pile_.tiling().num_tiles_y()); | 178 EXPECT_EQ(1, pile_.tiling().num_tiles_y()); |
| 203 | 179 |
| 204 TestPicturePile::PictureInfo& picture_info = | 180 FakePicturePile::PictureInfo& picture_info = |
| 205 pile_.picture_map().find(TestPicturePile::PictureMapKey(0, 0))->second; | 181 pile_.picture_map().find(FakePicturePile::PictureMapKey(0, 0))->second; |
| 206 EXPECT_TRUE(!!picture_info.GetPicture()); | 182 EXPECT_TRUE(!!picture_info.GetPicture()); |
| 207 | 183 |
| 208 int expected_inflation = pile_.buffer_pixels(); | 184 int expected_inflation = pile_.buffer_pixels(); |
| 209 | 185 |
| 210 const Picture* base_picture = picture_info.GetPicture(); | 186 const Picture* base_picture = picture_info.GetPicture(); |
| 211 gfx::Rect base_picture_rect(tiling_size()); | 187 gfx::Rect base_picture_rect(tiling_size()); |
| 212 base_picture_rect.Inset(-expected_inflation, -expected_inflation); | 188 base_picture_rect.Inset(-expected_inflation, -expected_inflation); |
| 213 EXPECT_EQ(base_picture_rect.ToString(), | 189 EXPECT_EQ(base_picture_rect.ToString(), |
| 214 base_picture->LayerRect().ToString()); | 190 base_picture->LayerRect().ToString()); |
| 215 } | 191 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 237 gfx::Rect(pile_.tiling().TileBoundsWithBorder(0, 0).right(), | 213 gfx::Rect(pile_.tiling().TileBoundsWithBorder(0, 0).right(), |
| 238 pile_.tiling().TileBoundsWithBorder(0, 0).bottom() - 1, | 214 pile_.tiling().TileBoundsWithBorder(0, 0).bottom() - 1, |
| 239 50, | 215 50, |
| 240 50)); | 216 50)); |
| 241 Region expected_invalidation = invalidate_rect; | 217 Region expected_invalidation = invalidate_rect; |
| 242 UpdateAndExpandInvalidation(&invalidate_rect, tiling_size(), tiling_rect()); | 218 UpdateAndExpandInvalidation(&invalidate_rect, tiling_size(), tiling_rect()); |
| 243 EXPECT_EQ(expected_invalidation.ToString(), invalidate_rect.ToString()); | 219 EXPECT_EQ(expected_invalidation.ToString(), invalidate_rect.ToString()); |
| 244 | 220 |
| 245 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { | 221 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { |
| 246 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { | 222 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { |
| 247 TestPicturePile::PictureInfo& picture_info = | 223 FakePicturePile::PictureInfo& picture_info = |
| 248 pile_.picture_map() | 224 pile_.picture_map() |
| 249 .find(TestPicturePile::PictureMapKey(i, j)) | 225 .find(FakePicturePile::PictureMapKey(i, j)) |
| 250 ->second; | 226 ->second; |
| 251 | 227 |
| 252 // Expect (1, 1) and (1, 0) to be invalidated once more | 228 // Expect (1, 1) and (1, 0) to be invalidated once more |
| 253 // than the rest of the tiles. | 229 // than the rest of the tiles. |
| 254 if (i == 1 && (j == 0 || j == 1)) { | 230 if (i == 1 && (j == 0 || j == 1)) { |
| 255 EXPECT_FLOAT_EQ( | 231 EXPECT_FLOAT_EQ( |
| 256 2.0f / TestPicturePile::PictureInfo::INVALIDATION_FRAMES_TRACKED, | 232 2.0f / FakePicturePile::PictureInfo::INVALIDATION_FRAMES_TRACKED, |
| 257 picture_info.GetInvalidationFrequencyForTesting()); | 233 picture_info.GetInvalidationFrequencyForTesting()); |
| 258 } else { | 234 } else { |
| 259 EXPECT_FLOAT_EQ( | 235 EXPECT_FLOAT_EQ( |
| 260 1.0f / TestPicturePile::PictureInfo::INVALIDATION_FRAMES_TRACKED, | 236 1.0f / FakePicturePile::PictureInfo::INVALIDATION_FRAMES_TRACKED, |
| 261 picture_info.GetInvalidationFrequencyForTesting()); | 237 picture_info.GetInvalidationFrequencyForTesting()); |
| 262 } | 238 } |
| 263 } | 239 } |
| 264 } | 240 } |
| 265 } | 241 } |
| 266 | 242 |
| 267 TEST_F(PicturePileTest, InvalidateOnFullLayer) { | 243 TEST_F(PicturePileTest, InvalidateOnFullLayer) { |
| 268 UpdateWholePile(); | 244 UpdateWholePile(); |
| 269 | 245 |
| 270 // Everything was invalidated once so far. | 246 // Everything was invalidated once so far. |
| 271 for (auto& it : pile_.picture_map()) { | 247 for (auto& it : pile_.picture_map()) { |
| 272 EXPECT_FLOAT_EQ( | 248 EXPECT_FLOAT_EQ( |
| 273 1.0f / TestPicturePile::PictureInfo::INVALIDATION_FRAMES_TRACKED, | 249 1.0f / FakePicturePile::PictureInfo::INVALIDATION_FRAMES_TRACKED, |
| 274 it.second.GetInvalidationFrequencyForTesting()); | 250 it.second.GetInvalidationFrequencyForTesting()); |
| 275 } | 251 } |
| 276 | 252 |
| 277 // Invalidate everything, | 253 // Invalidate everything, |
| 278 Region invalidation = tiling_rect(); | 254 Region invalidation = tiling_rect(); |
| 279 UpdateAndExpandInvalidation(&invalidation, tiling_size(), tiling_rect()); | 255 UpdateAndExpandInvalidation(&invalidation, tiling_size(), tiling_rect()); |
| 280 | 256 |
| 281 // Everything was invalidated again. | 257 // Everything was invalidated again. |
| 282 for (auto& it : pile_.picture_map()) { | 258 for (auto& it : pile_.picture_map()) { |
| 283 EXPECT_FLOAT_EQ( | 259 EXPECT_FLOAT_EQ( |
| 284 2.0f / TestPicturePile::PictureInfo::INVALIDATION_FRAMES_TRACKED, | 260 2.0f / FakePicturePile::PictureInfo::INVALIDATION_FRAMES_TRACKED, |
| 285 it.second.GetInvalidationFrequencyForTesting()); | 261 it.second.GetInvalidationFrequencyForTesting()); |
| 286 } | 262 } |
| 287 } | 263 } |
| 288 | 264 |
| 289 TEST_F(PicturePileTest, StopRecordingOffscreenInvalidations) { | 265 TEST_F(PicturePileTest, StopRecordingOffscreenInvalidations) { |
| 290 gfx::Size new_tiling_size = | 266 gfx::Size new_tiling_size = |
| 291 gfx::ToCeiledSize(gfx::ScaleSize(tiling_size(), 4.f)); | 267 gfx::ToCeiledSize(gfx::ScaleSize(tiling_size(), 4.f)); |
| 292 SetTilingSize(new_tiling_size); | 268 SetTilingSize(new_tiling_size); |
| 293 | 269 |
| 294 gfx::Rect viewport(tiling_size().width(), 1); | 270 gfx::Rect viewport(tiling_size().width(), 1); |
| 295 | 271 |
| 296 // Update the whole pile until the invalidation frequency is high. | 272 // Update the whole pile until the invalidation frequency is high. |
| 297 for (int frame = 0; frame < 33; ++frame) { | 273 for (int frame = 0; frame < 33; ++frame) { |
| 298 UpdateWholePile(); | 274 UpdateWholePile(); |
| 299 } | 275 } |
| 300 | 276 |
| 301 // Make sure we have a high invalidation frequency. | 277 // Make sure we have a high invalidation frequency. |
| 302 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { | 278 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { |
| 303 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { | 279 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { |
| 304 TestPicturePile::PictureInfo& picture_info = | 280 FakePicturePile::PictureInfo& picture_info = |
| 305 pile_.picture_map() | 281 pile_.picture_map() |
| 306 .find(TestPicturePile::PictureMapKey(i, j)) | 282 .find(FakePicturePile::PictureMapKey(i, j)) |
| 307 ->second; | 283 ->second; |
| 308 EXPECT_FLOAT_EQ(1.0f, picture_info.GetInvalidationFrequencyForTesting()) | 284 EXPECT_FLOAT_EQ(1.0f, picture_info.GetInvalidationFrequencyForTesting()) |
| 309 << "i " << i << " j " << j; | 285 << "i " << i << " j " << j; |
| 310 } | 286 } |
| 311 } | 287 } |
| 312 | 288 |
| 313 // Update once more with a small viewport. | 289 // Update once more with a small viewport. |
| 314 Region invalidation(tiling_rect()); | 290 Region invalidation(tiling_rect()); |
| 315 UpdateAndExpandInvalidation(&invalidation, tiling_size(), viewport); | 291 UpdateAndExpandInvalidation(&invalidation, tiling_size(), viewport); |
| 316 EXPECT_EQ(tiling_rect().ToString(), invalidation.ToString()); | 292 EXPECT_EQ(tiling_rect().ToString(), invalidation.ToString()); |
| 317 | 293 |
| 318 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { | 294 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { |
| 319 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { | 295 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { |
| 320 TestPicturePile::PictureInfo& picture_info = | 296 FakePicturePile::PictureInfo& picture_info = |
| 321 pile_.picture_map() | 297 pile_.picture_map() |
| 322 .find(TestPicturePile::PictureMapKey(i, j)) | 298 .find(FakePicturePile::PictureMapKey(i, j)) |
| 323 ->second; | 299 ->second; |
| 324 EXPECT_FLOAT_EQ(1.0f, picture_info.GetInvalidationFrequencyForTesting()); | 300 EXPECT_FLOAT_EQ(1.0f, picture_info.GetInvalidationFrequencyForTesting()); |
| 325 | 301 |
| 326 // If the y far enough away we expect to find no picture (no re-recording | 302 // If the y far enough away we expect to find no picture (no re-recording |
| 327 // happened). For close y, the picture should change. | 303 // happened). For close y, the picture should change. |
| 328 if (j >= 2) | 304 if (j >= 2) |
| 329 EXPECT_FALSE(picture_info.GetPicture()) << "i " << i << " j " << j; | 305 EXPECT_FALSE(picture_info.GetPicture()) << "i " << i << " j " << j; |
| 330 else | 306 else |
| 331 EXPECT_TRUE(picture_info.GetPicture()) << "i " << i << " j " << j; | 307 EXPECT_TRUE(picture_info.GetPicture()) << "i " << i << " j " << j; |
| 332 } | 308 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 345 << small_invalidation.ToString(); | 321 << small_invalidation.ToString(); |
| 346 | 322 |
| 347 // Now update with no invalidation and full viewport | 323 // Now update with no invalidation and full viewport |
| 348 Region empty_invalidation; | 324 Region empty_invalidation; |
| 349 UpdateAndExpandInvalidation(&empty_invalidation, tiling_size(), | 325 UpdateAndExpandInvalidation(&empty_invalidation, tiling_size(), |
| 350 tiling_rect()); | 326 tiling_rect()); |
| 351 EXPECT_EQ(Region().ToString(), empty_invalidation.ToString()); | 327 EXPECT_EQ(Region().ToString(), empty_invalidation.ToString()); |
| 352 | 328 |
| 353 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { | 329 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { |
| 354 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { | 330 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { |
| 355 TestPicturePile::PictureInfo& picture_info = | 331 FakePicturePile::PictureInfo& picture_info = |
| 356 pile_.picture_map() | 332 pile_.picture_map() |
| 357 .find(TestPicturePile::PictureMapKey(i, j)) | 333 .find(FakePicturePile::PictureMapKey(i, j)) |
| 358 ->second; | 334 ->second; |
| 359 // Expect the invalidation frequency to be less than 1, since we just | 335 // Expect the invalidation frequency to be less than 1, since we just |
| 360 // updated with no invalidations. | 336 // updated with no invalidations. |
| 361 EXPECT_LT(picture_info.GetInvalidationFrequencyForTesting(), 1.f); | 337 EXPECT_LT(picture_info.GetInvalidationFrequencyForTesting(), 1.f); |
| 362 | 338 |
| 363 // We expect that there are pictures everywhere now. | 339 // We expect that there are pictures everywhere now. |
| 364 EXPECT_TRUE(picture_info.GetPicture()) << "i " << i << " j " << j; | 340 EXPECT_TRUE(picture_info.GetPicture()) << "i " << i << " j " << j; |
| 365 } | 341 } |
| 366 } | 342 } |
| 367 } | 343 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 } | 388 } |
| 413 | 389 |
| 414 // Update once more with a small viewport. | 390 // Update once more with a small viewport. |
| 415 gfx::Rect viewport(tiling_size().width(), 1); | 391 gfx::Rect viewport(tiling_size().width(), 1); |
| 416 Region invalidation(tiling_rect()); | 392 Region invalidation(tiling_rect()); |
| 417 UpdateAndExpandInvalidation(&invalidation, tiling_size(), viewport); | 393 UpdateAndExpandInvalidation(&invalidation, tiling_size(), viewport); |
| 418 EXPECT_EQ(tiling_rect().ToString(), invalidation.ToString()); | 394 EXPECT_EQ(tiling_rect().ToString(), invalidation.ToString()); |
| 419 | 395 |
| 420 // Sanity check some pictures exist and others don't. | 396 // Sanity check some pictures exist and others don't. |
| 421 EXPECT_TRUE(pile_.picture_map() | 397 EXPECT_TRUE(pile_.picture_map() |
| 422 .find(TestPicturePile::PictureMapKey(0, 1)) | 398 .find(FakePicturePile::PictureMapKey(0, 1)) |
| 423 ->second.GetPicture()); | 399 ->second.GetPicture()); |
| 424 EXPECT_FALSE(pile_.picture_map() | 400 EXPECT_FALSE(pile_.picture_map() |
| 425 .find(TestPicturePile::PictureMapKey(0, 2)) | 401 .find(FakePicturePile::PictureMapKey(0, 2)) |
| 426 ->second.GetPicture()); | 402 ->second.GetPicture()); |
| 427 | 403 |
| 428 EXPECT_TRUE(pile_.CanRasterLayerRect(tile01_noborders)); | 404 EXPECT_TRUE(pile_.CanRasterLayerRect(tile01_noborders)); |
| 429 EXPECT_TRUE(pile_.CanRasterSlowTileCheck(tile01_noborders)); | 405 EXPECT_TRUE(pile_.CanRasterSlowTileCheck(tile01_noborders)); |
| 430 EXPECT_FALSE(pile_.CanRasterLayerRect(tile02_noborders)); | 406 EXPECT_FALSE(pile_.CanRasterLayerRect(tile02_noborders)); |
| 431 EXPECT_FALSE(pile_.CanRasterSlowTileCheck(tile02_noborders)); | 407 EXPECT_FALSE(pile_.CanRasterSlowTileCheck(tile02_noborders)); |
| 432 } | 408 } |
| 433 | 409 |
| 434 TEST_F(PicturePileTest, NoInvalidationValidViewport) { | 410 TEST_F(PicturePileTest, NoInvalidationValidViewport) { |
| 435 // This test validates that the recorded_viewport cache of full tiles | 411 // This test validates that the recorded_viewport cache of full tiles |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 Region expected_invalidation; | 570 Region expected_invalidation; |
| 595 | 571 |
| 596 pile_.tiling().SetMaxTextureSize(gfx::Size(tile_size, tile_size)); | 572 pile_.tiling().SetMaxTextureSize(gfx::Size(tile_size, tile_size)); |
| 597 SetTilingSize(base_tiling_size); | 573 SetTilingSize(base_tiling_size); |
| 598 | 574 |
| 599 // We should have a recording for every tile. | 575 // We should have a recording for every tile. |
| 600 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); | 576 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); |
| 601 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); | 577 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); |
| 602 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { | 578 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { |
| 603 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { | 579 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { |
| 604 TestPicturePile::PictureMapKey key(i, j); | 580 FakePicturePile::PictureMapKey key(i, j); |
| 605 TestPicturePile::PictureMap& map = pile_.picture_map(); | 581 FakePicturePile::PictureMap& map = pile_.picture_map(); |
| 606 TestPicturePile::PictureMap::iterator it = map.find(key); | 582 FakePicturePile::PictureMap::iterator it = map.find(key); |
| 607 EXPECT_TRUE(it != map.end() && it->second.GetPicture()); | 583 EXPECT_TRUE(it != map.end() && it->second.GetPicture()); |
| 608 } | 584 } |
| 609 } | 585 } |
| 610 | 586 |
| 611 UpdateAndExpandInvalidation( | 587 UpdateAndExpandInvalidation( |
| 612 &invalidation, | 588 &invalidation, |
| 613 grow_down_tiling_size, | 589 grow_down_tiling_size, |
| 614 CornerSinglePixelRect(corner, grow_down_tiling_size)); | 590 CornerSinglePixelRect(corner, grow_down_tiling_size)); |
| 615 | 591 |
| 616 // We should have lost all of the recordings in the bottom row as none of them | 592 // We should have lost all of the recordings in the bottom row as none of them |
| 617 // are in the current interest rect (which is either the above or below it). | 593 // are in the current interest rect (which is either the above or below it). |
| 618 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); | 594 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); |
| 619 EXPECT_EQ(8, pile_.tiling().num_tiles_y()); | 595 EXPECT_EQ(8, pile_.tiling().num_tiles_y()); |
| 620 for (int i = 0; i < 6; ++i) { | 596 for (int i = 0; i < 6; ++i) { |
| 621 for (int j = 0; j < 6; ++j) { | 597 for (int j = 0; j < 6; ++j) { |
| 622 TestPicturePile::PictureMapKey key(i, j); | 598 FakePicturePile::PictureMapKey key(i, j); |
| 623 TestPicturePile::PictureMap& map = pile_.picture_map(); | 599 FakePicturePile::PictureMap& map = pile_.picture_map(); |
| 624 TestPicturePile::PictureMap::iterator it = map.find(key); | 600 FakePicturePile::PictureMap::iterator it = map.find(key); |
| 625 EXPECT_EQ(j < 5, it != map.end() && it->second.GetPicture()); | 601 EXPECT_EQ(j < 5, it != map.end() && it->second.GetPicture()); |
| 626 } | 602 } |
| 627 } | 603 } |
| 628 | 604 |
| 629 // We invalidated all new pixels in the recording. | 605 // We invalidated all new pixels in the recording. |
| 630 expected_invalidation = SubtractRegions(gfx::Rect(grow_down_tiling_size), | 606 expected_invalidation = SubtractRegions(gfx::Rect(grow_down_tiling_size), |
| 631 gfx::Rect(base_tiling_size)); | 607 gfx::Rect(base_tiling_size)); |
| 632 // But the new pixels don't cover the whole bottom row. | 608 // But the new pixels don't cover the whole bottom row. |
| 633 gfx::Rect bottom_row = gfx::UnionRects(pile_.tiling().TileBounds(0, 5), | 609 gfx::Rect bottom_row = gfx::UnionRects(pile_.tiling().TileBounds(0, 5), |
| 634 pile_.tiling().TileBounds(5, 5)); | 610 pile_.tiling().TileBounds(5, 5)); |
| 635 EXPECT_FALSE(expected_invalidation.Contains(bottom_row)); | 611 EXPECT_FALSE(expected_invalidation.Contains(bottom_row)); |
| 636 // We invalidated the entire old bottom row. | 612 // We invalidated the entire old bottom row. |
| 637 expected_invalidation.Union(bottom_row); | 613 expected_invalidation.Union(bottom_row); |
| 638 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); | 614 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); |
| 639 invalidation.Clear(); | 615 invalidation.Clear(); |
| 640 | 616 |
| 641 UpdateWholePile(); | 617 UpdateWholePile(); |
| 642 UpdateAndExpandInvalidation(&invalidation, | 618 UpdateAndExpandInvalidation(&invalidation, |
| 643 base_tiling_size, | 619 base_tiling_size, |
| 644 CornerSinglePixelRect(corner, base_tiling_size)); | 620 CornerSinglePixelRect(corner, base_tiling_size)); |
| 645 | 621 |
| 646 // When shrinking, we should have lost all the recordings in the bottom row | 622 // When shrinking, we should have lost all the recordings in the bottom row |
| 647 // not touching the interest rect. | 623 // not touching the interest rect. |
| 648 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); | 624 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); |
| 649 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); | 625 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); |
| 650 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { | 626 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { |
| 651 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { | 627 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { |
| 652 TestPicturePile::PictureMapKey key(i, j); | 628 FakePicturePile::PictureMapKey key(i, j); |
| 653 TestPicturePile::PictureMap& map = pile_.picture_map(); | 629 FakePicturePile::PictureMap& map = pile_.picture_map(); |
| 654 TestPicturePile::PictureMap::iterator it = map.find(key); | 630 FakePicturePile::PictureMap::iterator it = map.find(key); |
| 655 bool expect_tile; | 631 bool expect_tile; |
| 656 switch (corner) { | 632 switch (corner) { |
| 657 case TOP_LEFT: | 633 case TOP_LEFT: |
| 658 case TOP_RIGHT: | 634 case TOP_RIGHT: |
| 659 expect_tile = j < 5; | 635 expect_tile = j < 5; |
| 660 break; | 636 break; |
| 661 case BOTTOM_LEFT: | 637 case BOTTOM_LEFT: |
| 662 // The interest rect in the bottom left tile means we'll record it. | 638 // The interest rect in the bottom left tile means we'll record it. |
| 663 expect_tile = j < 5 || (j == 5 && i == 0); | 639 expect_tile = j < 5 || (j == 5 && i == 0); |
| 664 break; | 640 break; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 grow_right_tiling_size, | 680 grow_right_tiling_size, |
| 705 CornerSinglePixelRect(corner, grow_right_tiling_size)); | 681 CornerSinglePixelRect(corner, grow_right_tiling_size)); |
| 706 | 682 |
| 707 // We should have lost all of the recordings in the right column as none of | 683 // We should have lost all of the recordings in the right column as none of |
| 708 // them are in the current interest rect (which is either entirely left or | 684 // them are in the current interest rect (which is either entirely left or |
| 709 // right of it). | 685 // right of it). |
| 710 EXPECT_EQ(8, pile_.tiling().num_tiles_x()); | 686 EXPECT_EQ(8, pile_.tiling().num_tiles_x()); |
| 711 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); | 687 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); |
| 712 for (int i = 0; i < 6; ++i) { | 688 for (int i = 0; i < 6; ++i) { |
| 713 for (int j = 0; j < 6; ++j) { | 689 for (int j = 0; j < 6; ++j) { |
| 714 TestPicturePile::PictureMapKey key(i, j); | 690 FakePicturePile::PictureMapKey key(i, j); |
| 715 TestPicturePile::PictureMap& map = pile_.picture_map(); | 691 FakePicturePile::PictureMap& map = pile_.picture_map(); |
| 716 TestPicturePile::PictureMap::iterator it = map.find(key); | 692 FakePicturePile::PictureMap::iterator it = map.find(key); |
| 717 EXPECT_EQ(i < 5, it != map.end() && it->second.GetPicture()); | 693 EXPECT_EQ(i < 5, it != map.end() && it->second.GetPicture()); |
| 718 } | 694 } |
| 719 } | 695 } |
| 720 | 696 |
| 721 // We invalidated all new pixels in the recording. | 697 // We invalidated all new pixels in the recording. |
| 722 expected_invalidation = SubtractRegions(gfx::Rect(grow_right_tiling_size), | 698 expected_invalidation = SubtractRegions(gfx::Rect(grow_right_tiling_size), |
| 723 gfx::Rect(base_tiling_size)); | 699 gfx::Rect(base_tiling_size)); |
| 724 // But the new pixels don't cover the whole right_column. | 700 // But the new pixels don't cover the whole right_column. |
| 725 gfx::Rect right_column = gfx::UnionRects(pile_.tiling().TileBounds(5, 0), | 701 gfx::Rect right_column = gfx::UnionRects(pile_.tiling().TileBounds(5, 0), |
| 726 pile_.tiling().TileBounds(5, 5)); | 702 pile_.tiling().TileBounds(5, 5)); |
| 727 EXPECT_FALSE(expected_invalidation.Contains(right_column)); | 703 EXPECT_FALSE(expected_invalidation.Contains(right_column)); |
| 728 // We invalidated the entire old right column. | 704 // We invalidated the entire old right column. |
| 729 expected_invalidation.Union(right_column); | 705 expected_invalidation.Union(right_column); |
| 730 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); | 706 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); |
| 731 invalidation.Clear(); | 707 invalidation.Clear(); |
| 732 | 708 |
| 733 UpdateWholePile(); | 709 UpdateWholePile(); |
| 734 UpdateAndExpandInvalidation(&invalidation, | 710 UpdateAndExpandInvalidation(&invalidation, |
| 735 base_tiling_size, | 711 base_tiling_size, |
| 736 CornerSinglePixelRect(corner, base_tiling_size)); | 712 CornerSinglePixelRect(corner, base_tiling_size)); |
| 737 | 713 |
| 738 // When shrinking, we should have lost all the recordings in the right column | 714 // When shrinking, we should have lost all the recordings in the right column |
| 739 // not touching the interest rect. | 715 // not touching the interest rect. |
| 740 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); | 716 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); |
| 741 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); | 717 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); |
| 742 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { | 718 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { |
| 743 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { | 719 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { |
| 744 TestPicturePile::PictureMapKey key(i, j); | 720 FakePicturePile::PictureMapKey key(i, j); |
| 745 TestPicturePile::PictureMap& map = pile_.picture_map(); | 721 FakePicturePile::PictureMap& map = pile_.picture_map(); |
| 746 TestPicturePile::PictureMap::iterator it = map.find(key); | 722 FakePicturePile::PictureMap::iterator it = map.find(key); |
| 747 bool expect_tile; | 723 bool expect_tile; |
| 748 switch (corner) { | 724 switch (corner) { |
| 749 case TOP_LEFT: | 725 case TOP_LEFT: |
| 750 case BOTTOM_LEFT: | 726 case BOTTOM_LEFT: |
| 751 // No tiles are kept in the changed region because it doesn't | 727 // No tiles are kept in the changed region because it doesn't |
| 752 // intersect with the interest rect. | 728 // intersect with the interest rect. |
| 753 expect_tile = i < 5; | 729 expect_tile = i < 5; |
| 754 break; | 730 break; |
| 755 case TOP_RIGHT: | 731 case TOP_RIGHT: |
| 756 // The interest rect in the top right tile means we'll record it. | 732 // The interest rect in the top right tile means we'll record it. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 UpdateAndExpandInvalidation( | 769 UpdateAndExpandInvalidation( |
| 794 &invalidation, | 770 &invalidation, |
| 795 grow_both_tiling_size, | 771 grow_both_tiling_size, |
| 796 CornerSinglePixelRect(corner, grow_both_tiling_size)); | 772 CornerSinglePixelRect(corner, grow_both_tiling_size)); |
| 797 | 773 |
| 798 // We should have lost the recordings in the right column and bottom row. | 774 // We should have lost the recordings in the right column and bottom row. |
| 799 EXPECT_EQ(8, pile_.tiling().num_tiles_x()); | 775 EXPECT_EQ(8, pile_.tiling().num_tiles_x()); |
| 800 EXPECT_EQ(8, pile_.tiling().num_tiles_y()); | 776 EXPECT_EQ(8, pile_.tiling().num_tiles_y()); |
| 801 for (int i = 0; i < 6; ++i) { | 777 for (int i = 0; i < 6; ++i) { |
| 802 for (int j = 0; j < 6; ++j) { | 778 for (int j = 0; j < 6; ++j) { |
| 803 TestPicturePile::PictureMapKey key(i, j); | 779 FakePicturePile::PictureMapKey key(i, j); |
| 804 TestPicturePile::PictureMap& map = pile_.picture_map(); | 780 FakePicturePile::PictureMap& map = pile_.picture_map(); |
| 805 TestPicturePile::PictureMap::iterator it = map.find(key); | 781 FakePicturePile::PictureMap::iterator it = map.find(key); |
| 806 EXPECT_EQ(i < 5 && j < 5, it != map.end() && it->second.GetPicture()); | 782 EXPECT_EQ(i < 5 && j < 5, it != map.end() && it->second.GetPicture()); |
| 807 } | 783 } |
| 808 } | 784 } |
| 809 | 785 |
| 810 // We invalidated all new pixels in the recording. | 786 // We invalidated all new pixels in the recording. |
| 811 expected_invalidation = SubtractRegions(gfx::Rect(grow_both_tiling_size), | 787 expected_invalidation = SubtractRegions(gfx::Rect(grow_both_tiling_size), |
| 812 gfx::Rect(base_tiling_size)); | 788 gfx::Rect(base_tiling_size)); |
| 813 // But the new pixels don't cover the whole right column or bottom row. | 789 // But the new pixels don't cover the whole right column or bottom row. |
| 814 Region right_column_and_bottom_row = | 790 Region right_column_and_bottom_row = |
| 815 UnionRegions(gfx::UnionRects(pile_.tiling().TileBounds(5, 0), | 791 UnionRegions(gfx::UnionRects(pile_.tiling().TileBounds(5, 0), |
| 816 pile_.tiling().TileBounds(5, 5)), | 792 pile_.tiling().TileBounds(5, 5)), |
| 817 gfx::UnionRects(pile_.tiling().TileBounds(0, 5), | 793 gfx::UnionRects(pile_.tiling().TileBounds(0, 5), |
| 818 pile_.tiling().TileBounds(5, 5))); | 794 pile_.tiling().TileBounds(5, 5))); |
| 819 EXPECT_FALSE(expected_invalidation.Contains(right_column_and_bottom_row)); | 795 EXPECT_FALSE(expected_invalidation.Contains(right_column_and_bottom_row)); |
| 820 // We invalidated the entire old right column and the old bottom row. | 796 // We invalidated the entire old right column and the old bottom row. |
| 821 expected_invalidation.Union(right_column_and_bottom_row); | 797 expected_invalidation.Union(right_column_and_bottom_row); |
| 822 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); | 798 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); |
| 823 invalidation.Clear(); | 799 invalidation.Clear(); |
| 824 | 800 |
| 825 UpdateWholePile(); | 801 UpdateWholePile(); |
| 826 UpdateAndExpandInvalidation(&invalidation, base_tiling_size, | 802 UpdateAndExpandInvalidation(&invalidation, base_tiling_size, |
| 827 CornerSinglePixelRect(corner, base_tiling_size)); | 803 CornerSinglePixelRect(corner, base_tiling_size)); |
| 828 | 804 |
| 829 // We should have lost the recordings in the right column and bottom row, | 805 // We should have lost the recordings in the right column and bottom row, |
| 830 // except where it intersects the interest rect. | 806 // except where it intersects the interest rect. |
| 831 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); | 807 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); |
| 832 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); | 808 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); |
| 833 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { | 809 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { |
| 834 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { | 810 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { |
| 835 TestPicturePile::PictureMapKey key(i, j); | 811 FakePicturePile::PictureMapKey key(i, j); |
| 836 TestPicturePile::PictureMap& map = pile_.picture_map(); | 812 FakePicturePile::PictureMap& map = pile_.picture_map(); |
| 837 TestPicturePile::PictureMap::iterator it = map.find(key); | 813 FakePicturePile::PictureMap::iterator it = map.find(key); |
| 838 bool expect_tile; | 814 bool expect_tile; |
| 839 switch (corner) { | 815 switch (corner) { |
| 840 case TOP_LEFT: | 816 case TOP_LEFT: |
| 841 expect_tile = i < 5 && j < 5; | 817 expect_tile = i < 5 && j < 5; |
| 842 break; | 818 break; |
| 843 case TOP_RIGHT: | 819 case TOP_RIGHT: |
| 844 // The interest rect in the top right tile means we'll record it. | 820 // The interest rect in the top right tile means we'll record it. |
| 845 expect_tile = (i < 5 && j < 5) || (j == 0 && i == 5); | 821 expect_tile = (i < 5 && j < 5) || (j == 0 && i == 5); |
| 846 break; | 822 break; |
| 847 case BOTTOM_LEFT: | 823 case BOTTOM_LEFT: |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 Region expected_invalidation; | 884 Region expected_invalidation; |
| 909 | 885 |
| 910 pile_.tiling().SetMaxTextureSize(gfx::Size(tile_size, tile_size)); | 886 pile_.tiling().SetMaxTextureSize(gfx::Size(tile_size, tile_size)); |
| 911 SetTilingSize(base_tiling_size); | 887 SetTilingSize(base_tiling_size); |
| 912 | 888 |
| 913 // We should have a recording for every tile. | 889 // We should have a recording for every tile. |
| 914 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); | 890 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); |
| 915 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); | 891 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); |
| 916 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { | 892 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { |
| 917 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { | 893 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { |
| 918 TestPicturePile::PictureMapKey key(i, j); | 894 FakePicturePile::PictureMapKey key(i, j); |
| 919 TestPicturePile::PictureMap& map = pile_.picture_map(); | 895 FakePicturePile::PictureMap& map = pile_.picture_map(); |
| 920 TestPicturePile::PictureMap::iterator it = map.find(key); | 896 FakePicturePile::PictureMap::iterator it = map.find(key); |
| 921 EXPECT_TRUE(it != map.end() && it->second.GetPicture()); | 897 EXPECT_TRUE(it != map.end() && it->second.GetPicture()); |
| 922 } | 898 } |
| 923 } | 899 } |
| 924 | 900 |
| 925 // In this test (unlike the large resize test), as all growing and shrinking | 901 // In this test (unlike the large resize test), as all growing and shrinking |
| 926 // happens within tiles, the resulting invalidation is symmetrical, so use | 902 // happens within tiles, the resulting invalidation is symmetrical, so use |
| 927 // this enum to repeat the test both ways. | 903 // this enum to repeat the test both ways. |
| 928 enum ChangeDirection { GROW, SHRINK, LAST_DIRECTION = SHRINK }; | 904 enum ChangeDirection { GROW, SHRINK, LAST_DIRECTION = SHRINK }; |
| 929 | 905 |
| 930 // Grow downward. | 906 // Grow downward. |
| 931 for (int dir = 0; dir <= LAST_DIRECTION; ++dir) { | 907 for (int dir = 0; dir <= LAST_DIRECTION; ++dir) { |
| 932 gfx::Size new_tiling_size = | 908 gfx::Size new_tiling_size = |
| 933 dir == GROW ? grow_down_tiling_size : base_tiling_size; | 909 dir == GROW ? grow_down_tiling_size : base_tiling_size; |
| 934 UpdateWholePile(); | 910 UpdateWholePile(); |
| 935 UpdateAndExpandInvalidation(&invalidation, new_tiling_size, | 911 UpdateAndExpandInvalidation(&invalidation, new_tiling_size, |
| 936 CornerSinglePixelRect(corner, new_tiling_size)); | 912 CornerSinglePixelRect(corner, new_tiling_size)); |
| 937 | 913 |
| 938 // We should have lost the recordings in the bottom row that do not | 914 // We should have lost the recordings in the bottom row that do not |
| 939 // intersect the interest rect. | 915 // intersect the interest rect. |
| 940 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); | 916 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); |
| 941 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); | 917 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); |
| 942 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { | 918 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { |
| 943 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { | 919 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { |
| 944 TestPicturePile::PictureMapKey key(i, j); | 920 FakePicturePile::PictureMapKey key(i, j); |
| 945 TestPicturePile::PictureMap& map = pile_.picture_map(); | 921 FakePicturePile::PictureMap& map = pile_.picture_map(); |
| 946 TestPicturePile::PictureMap::iterator it = map.find(key); | 922 FakePicturePile::PictureMap::iterator it = map.find(key); |
| 947 bool expect_tile; | 923 bool expect_tile; |
| 948 switch (corner) { | 924 switch (corner) { |
| 949 case TOP_LEFT: | 925 case TOP_LEFT: |
| 950 case TOP_RIGHT: | 926 case TOP_RIGHT: |
| 951 expect_tile = j < 5; | 927 expect_tile = j < 5; |
| 952 break; | 928 break; |
| 953 case BOTTOM_LEFT: | 929 case BOTTOM_LEFT: |
| 954 // The interest rect in the bottom left tile means we'll record it. | 930 // The interest rect in the bottom left tile means we'll record it. |
| 955 expect_tile = j < 5 || (j == 5 && i == 0); | 931 expect_tile = j < 5 || (j == 5 && i == 0); |
| 956 break; | 932 break; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1000 dir == GROW ? grow_right_tiling_size : base_tiling_size; | 976 dir == GROW ? grow_right_tiling_size : base_tiling_size; |
| 1001 UpdateWholePile(); | 977 UpdateWholePile(); |
| 1002 UpdateAndExpandInvalidation(&invalidation, new_tiling_size, | 978 UpdateAndExpandInvalidation(&invalidation, new_tiling_size, |
| 1003 CornerSinglePixelRect(corner, new_tiling_size)); | 979 CornerSinglePixelRect(corner, new_tiling_size)); |
| 1004 | 980 |
| 1005 // We should have lost the recordings in the right column. | 981 // We should have lost the recordings in the right column. |
| 1006 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); | 982 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); |
| 1007 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); | 983 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); |
| 1008 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { | 984 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { |
| 1009 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { | 985 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { |
| 1010 TestPicturePile::PictureMapKey key(i, j); | 986 FakePicturePile::PictureMapKey key(i, j); |
| 1011 TestPicturePile::PictureMap& map = pile_.picture_map(); | 987 FakePicturePile::PictureMap& map = pile_.picture_map(); |
| 1012 TestPicturePile::PictureMap::iterator it = map.find(key); | 988 FakePicturePile::PictureMap::iterator it = map.find(key); |
| 1013 bool expect_tile; | 989 bool expect_tile; |
| 1014 switch (corner) { | 990 switch (corner) { |
| 1015 case TOP_LEFT: | 991 case TOP_LEFT: |
| 1016 case BOTTOM_LEFT: | 992 case BOTTOM_LEFT: |
| 1017 expect_tile = i < 5; | 993 expect_tile = i < 5; |
| 1018 break; | 994 break; |
| 1019 case TOP_RIGHT: | 995 case TOP_RIGHT: |
| 1020 // The interest rect in the top right tile means we'll record it. | 996 // The interest rect in the top right tile means we'll record it. |
| 1021 expect_tile = i < 5 || (j == 0 && i == 5); | 997 expect_tile = i < 5 || (j == 0 && i == 5); |
| 1022 break; | 998 break; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1066 UpdateAndExpandInvalidation(&invalidation, new_tiling_size, | 1042 UpdateAndExpandInvalidation(&invalidation, new_tiling_size, |
| 1067 CornerSinglePixelRect(corner, new_tiling_size)); | 1043 CornerSinglePixelRect(corner, new_tiling_size)); |
| 1068 | 1044 |
| 1069 // We should have lost the recordings in the right column and bottom row. | 1045 // We should have lost the recordings in the right column and bottom row. |
| 1070 // The tile that insects the interest rect in invalidated only on its new | 1046 // The tile that insects the interest rect in invalidated only on its new |
| 1071 // or previously exposed pixels. | 1047 // or previously exposed pixels. |
| 1072 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); | 1048 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); |
| 1073 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); | 1049 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); |
| 1074 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { | 1050 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { |
| 1075 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { | 1051 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { |
| 1076 TestPicturePile::PictureMapKey key(i, j); | 1052 FakePicturePile::PictureMapKey key(i, j); |
| 1077 TestPicturePile::PictureMap& map = pile_.picture_map(); | 1053 FakePicturePile::PictureMap& map = pile_.picture_map(); |
| 1078 TestPicturePile::PictureMap::iterator it = map.find(key); | 1054 FakePicturePile::PictureMap::iterator it = map.find(key); |
| 1079 bool expect_tile; | 1055 bool expect_tile; |
| 1080 switch (corner) { | 1056 switch (corner) { |
| 1081 case TOP_LEFT: | 1057 case TOP_LEFT: |
| 1082 expect_tile = i < 5 && j < 5; | 1058 expect_tile = i < 5 && j < 5; |
| 1083 break; | 1059 break; |
| 1084 case TOP_RIGHT: | 1060 case TOP_RIGHT: |
| 1085 // The interest rect in the top right tile means we'll record it. | 1061 // The interest rect in the top right tile means we'll record it. |
| 1086 expect_tile = (i < 5 && j < 5) || (j == 0 && i == 5); | 1062 expect_tile = (i < 5 && j < 5) || (j == 0 && i == 5); |
| 1087 break; | 1063 break; |
| 1088 case BOTTOM_LEFT: | 1064 case BOTTOM_LEFT: |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1165 Region expected_invalidation; | 1141 Region expected_invalidation; |
| 1166 | 1142 |
| 1167 pile_.tiling().SetMaxTextureSize(gfx::Size(tile_size, tile_size)); | 1143 pile_.tiling().SetMaxTextureSize(gfx::Size(tile_size, tile_size)); |
| 1168 SetTilingSize(base_tiling_size); | 1144 SetTilingSize(base_tiling_size); |
| 1169 | 1145 |
| 1170 // We should have a recording for every tile. | 1146 // We should have a recording for every tile. |
| 1171 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); | 1147 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); |
| 1172 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); | 1148 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); |
| 1173 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { | 1149 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { |
| 1174 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { | 1150 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { |
| 1175 TestPicturePile::PictureMapKey key(i, j); | 1151 FakePicturePile::PictureMapKey key(i, j); |
| 1176 TestPicturePile::PictureMap& map = pile_.picture_map(); | 1152 FakePicturePile::PictureMap& map = pile_.picture_map(); |
| 1177 TestPicturePile::PictureMap::iterator it = map.find(key); | 1153 FakePicturePile::PictureMap::iterator it = map.find(key); |
| 1178 EXPECT_TRUE(it != map.end() && it->second.GetPicture()); | 1154 EXPECT_TRUE(it != map.end() && it->second.GetPicture()); |
| 1179 } | 1155 } |
| 1180 } | 1156 } |
| 1181 | 1157 |
| 1182 UpdateAndExpandInvalidation( | 1158 UpdateAndExpandInvalidation( |
| 1183 &invalidation, grow_down_tiling_size, gfx::Rect(1, 1)); | 1159 &invalidation, grow_down_tiling_size, gfx::Rect(1, 1)); |
| 1184 | 1160 |
| 1185 // We should have a recording for every tile. | 1161 // We should have a recording for every tile. |
| 1186 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); | 1162 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); |
| 1187 EXPECT_EQ(8, pile_.tiling().num_tiles_y()); | 1163 EXPECT_EQ(8, pile_.tiling().num_tiles_y()); |
| 1188 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { | 1164 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { |
| 1189 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { | 1165 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { |
| 1190 TestPicturePile::PictureMapKey key(i, j); | 1166 FakePicturePile::PictureMapKey key(i, j); |
| 1191 TestPicturePile::PictureMap& map = pile_.picture_map(); | 1167 FakePicturePile::PictureMap& map = pile_.picture_map(); |
| 1192 TestPicturePile::PictureMap::iterator it = map.find(key); | 1168 FakePicturePile::PictureMap::iterator it = map.find(key); |
| 1193 EXPECT_TRUE(it != map.end() && it->second.GetPicture()); | 1169 EXPECT_TRUE(it != map.end() && it->second.GetPicture()); |
| 1194 } | 1170 } |
| 1195 } | 1171 } |
| 1196 | 1172 |
| 1197 // We invalidated the newly exposed pixels on the bottom row of tiles. | 1173 // We invalidated the newly exposed pixels on the bottom row of tiles. |
| 1198 expected_invalidation = SubtractRegions(gfx::Rect(grow_down_tiling_size), | 1174 expected_invalidation = SubtractRegions(gfx::Rect(grow_down_tiling_size), |
| 1199 gfx::Rect(base_tiling_size)); | 1175 gfx::Rect(base_tiling_size)); |
| 1200 Region bottom_row_new_pixels = | 1176 Region bottom_row_new_pixels = |
| 1201 SubtractRegions(gfx::UnionRects(pile_.tiling().TileBounds(0, 5), | 1177 SubtractRegions(gfx::UnionRects(pile_.tiling().TileBounds(0, 5), |
| 1202 pile_.tiling().TileBounds(5, 5)), | 1178 pile_.tiling().TileBounds(5, 5)), |
| 1203 gfx::Rect(base_tiling_size)); | 1179 gfx::Rect(base_tiling_size)); |
| 1204 EXPECT_TRUE(expected_invalidation.Contains(bottom_row_new_pixels)); | 1180 EXPECT_TRUE(expected_invalidation.Contains(bottom_row_new_pixels)); |
| 1205 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); | 1181 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); |
| 1206 invalidation.Clear(); | 1182 invalidation.Clear(); |
| 1207 | 1183 |
| 1208 UpdateWholePile(); | 1184 UpdateWholePile(); |
| 1209 UpdateAndExpandInvalidation(&invalidation, base_tiling_size, gfx::Rect(1, 1)); | 1185 UpdateAndExpandInvalidation(&invalidation, base_tiling_size, gfx::Rect(1, 1)); |
| 1210 | 1186 |
| 1211 // We should have a recording for every tile. | 1187 // We should have a recording for every tile. |
| 1212 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); | 1188 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); |
| 1213 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); | 1189 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); |
| 1214 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { | 1190 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { |
| 1215 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { | 1191 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { |
| 1216 TestPicturePile::PictureMapKey key(i, j); | 1192 FakePicturePile::PictureMapKey key(i, j); |
| 1217 TestPicturePile::PictureMap& map = pile_.picture_map(); | 1193 FakePicturePile::PictureMap& map = pile_.picture_map(); |
| 1218 TestPicturePile::PictureMap::iterator it = map.find(key); | 1194 FakePicturePile::PictureMap::iterator it = map.find(key); |
| 1219 EXPECT_TRUE(it != map.end() && it->second.GetPicture()); | 1195 EXPECT_TRUE(it != map.end() && it->second.GetPicture()); |
| 1220 } | 1196 } |
| 1221 } | 1197 } |
| 1222 | 1198 |
| 1223 // We invalidated the previously exposed pixels on the bottom row of tiles. | 1199 // We invalidated the previously exposed pixels on the bottom row of tiles. |
| 1224 expected_invalidation = SubtractRegions(gfx::Rect(grow_down_tiling_size), | 1200 expected_invalidation = SubtractRegions(gfx::Rect(grow_down_tiling_size), |
| 1225 gfx::Rect(base_tiling_size)); | 1201 gfx::Rect(base_tiling_size)); |
| 1226 EXPECT_TRUE(expected_invalidation.Contains(bottom_row_new_pixels)); | 1202 EXPECT_TRUE(expected_invalidation.Contains(bottom_row_new_pixels)); |
| 1227 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); | 1203 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); |
| 1228 invalidation.Clear(); | 1204 invalidation.Clear(); |
| 1229 | 1205 |
| 1230 UpdateWholePile(); | 1206 UpdateWholePile(); |
| 1231 UpdateAndExpandInvalidation( | 1207 UpdateAndExpandInvalidation( |
| 1232 &invalidation, grow_right_tiling_size, gfx::Rect(1, 1)); | 1208 &invalidation, grow_right_tiling_size, gfx::Rect(1, 1)); |
| 1233 | 1209 |
| 1234 // We should have a recording for every tile. | 1210 // We should have a recording for every tile. |
| 1235 EXPECT_EQ(8, pile_.tiling().num_tiles_x()); | 1211 EXPECT_EQ(8, pile_.tiling().num_tiles_x()); |
| 1236 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); | 1212 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); |
| 1237 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { | 1213 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { |
| 1238 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { | 1214 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { |
| 1239 TestPicturePile::PictureMapKey key(i, j); | 1215 FakePicturePile::PictureMapKey key(i, j); |
| 1240 TestPicturePile::PictureMap& map = pile_.picture_map(); | 1216 FakePicturePile::PictureMap& map = pile_.picture_map(); |
| 1241 TestPicturePile::PictureMap::iterator it = map.find(key); | 1217 FakePicturePile::PictureMap::iterator it = map.find(key); |
| 1242 EXPECT_TRUE(it != map.end() && it->second.GetPicture()); | 1218 EXPECT_TRUE(it != map.end() && it->second.GetPicture()); |
| 1243 } | 1219 } |
| 1244 } | 1220 } |
| 1245 | 1221 |
| 1246 // We invalidated the newly exposed pixels on the right column of tiles. | 1222 // We invalidated the newly exposed pixels on the right column of tiles. |
| 1247 expected_invalidation = SubtractRegions(gfx::Rect(grow_right_tiling_size), | 1223 expected_invalidation = SubtractRegions(gfx::Rect(grow_right_tiling_size), |
| 1248 gfx::Rect(base_tiling_size)); | 1224 gfx::Rect(base_tiling_size)); |
| 1249 Region right_column_new_pixels = | 1225 Region right_column_new_pixels = |
| 1250 SubtractRegions(gfx::UnionRects(pile_.tiling().TileBounds(5, 0), | 1226 SubtractRegions(gfx::UnionRects(pile_.tiling().TileBounds(5, 0), |
| 1251 pile_.tiling().TileBounds(5, 5)), | 1227 pile_.tiling().TileBounds(5, 5)), |
| 1252 gfx::Rect(base_tiling_size)); | 1228 gfx::Rect(base_tiling_size)); |
| 1253 EXPECT_TRUE(expected_invalidation.Contains(right_column_new_pixels)); | 1229 EXPECT_TRUE(expected_invalidation.Contains(right_column_new_pixels)); |
| 1254 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); | 1230 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); |
| 1255 invalidation.Clear(); | 1231 invalidation.Clear(); |
| 1256 | 1232 |
| 1257 UpdateWholePile(); | 1233 UpdateWholePile(); |
| 1258 UpdateAndExpandInvalidation(&invalidation, base_tiling_size, gfx::Rect(1, 1)); | 1234 UpdateAndExpandInvalidation(&invalidation, base_tiling_size, gfx::Rect(1, 1)); |
| 1259 | 1235 |
| 1260 // We should have lost the recordings that are now outside the tiling only. | 1236 // We should have lost the recordings that are now outside the tiling only. |
| 1261 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); | 1237 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); |
| 1262 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); | 1238 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); |
| 1263 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { | 1239 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { |
| 1264 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { | 1240 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { |
| 1265 TestPicturePile::PictureMapKey key(i, j); | 1241 FakePicturePile::PictureMapKey key(i, j); |
| 1266 TestPicturePile::PictureMap& map = pile_.picture_map(); | 1242 FakePicturePile::PictureMap& map = pile_.picture_map(); |
| 1267 TestPicturePile::PictureMap::iterator it = map.find(key); | 1243 FakePicturePile::PictureMap::iterator it = map.find(key); |
| 1268 EXPECT_TRUE(it != map.end() && it->second.GetPicture()); | 1244 EXPECT_TRUE(it != map.end() && it->second.GetPicture()); |
| 1269 } | 1245 } |
| 1270 } | 1246 } |
| 1271 | 1247 |
| 1272 // We invalidated the previously exposed pixels on the right column of tiles. | 1248 // We invalidated the previously exposed pixels on the right column of tiles. |
| 1273 expected_invalidation = SubtractRegions(gfx::Rect(grow_right_tiling_size), | 1249 expected_invalidation = SubtractRegions(gfx::Rect(grow_right_tiling_size), |
| 1274 gfx::Rect(base_tiling_size)); | 1250 gfx::Rect(base_tiling_size)); |
| 1275 EXPECT_TRUE(expected_invalidation.Contains(right_column_new_pixels)); | 1251 EXPECT_TRUE(expected_invalidation.Contains(right_column_new_pixels)); |
| 1276 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); | 1252 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); |
| 1277 invalidation.Clear(); | 1253 invalidation.Clear(); |
| 1278 | 1254 |
| 1279 UpdateWholePile(); | 1255 UpdateWholePile(); |
| 1280 UpdateAndExpandInvalidation( | 1256 UpdateAndExpandInvalidation( |
| 1281 &invalidation, grow_both_tiling_size, gfx::Rect(1, 1)); | 1257 &invalidation, grow_both_tiling_size, gfx::Rect(1, 1)); |
| 1282 | 1258 |
| 1283 // We should have a recording for every tile. | 1259 // We should have a recording for every tile. |
| 1284 EXPECT_EQ(8, pile_.tiling().num_tiles_x()); | 1260 EXPECT_EQ(8, pile_.tiling().num_tiles_x()); |
| 1285 EXPECT_EQ(8, pile_.tiling().num_tiles_y()); | 1261 EXPECT_EQ(8, pile_.tiling().num_tiles_y()); |
| 1286 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { | 1262 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { |
| 1287 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { | 1263 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { |
| 1288 TestPicturePile::PictureMapKey key(i, j); | 1264 FakePicturePile::PictureMapKey key(i, j); |
| 1289 TestPicturePile::PictureMap& map = pile_.picture_map(); | 1265 FakePicturePile::PictureMap& map = pile_.picture_map(); |
| 1290 TestPicturePile::PictureMap::iterator it = map.find(key); | 1266 FakePicturePile::PictureMap::iterator it = map.find(key); |
| 1291 EXPECT_TRUE(it != map.end() && it->second.GetPicture()); | 1267 EXPECT_TRUE(it != map.end() && it->second.GetPicture()); |
| 1292 } | 1268 } |
| 1293 } | 1269 } |
| 1294 | 1270 |
| 1295 // We invalidated the newly exposed pixels on the bottom row and right column | 1271 // We invalidated the newly exposed pixels on the bottom row and right column |
| 1296 // of tiles. | 1272 // of tiles. |
| 1297 expected_invalidation = SubtractRegions(gfx::Rect(grow_both_tiling_size), | 1273 expected_invalidation = SubtractRegions(gfx::Rect(grow_both_tiling_size), |
| 1298 gfx::Rect(base_tiling_size)); | 1274 gfx::Rect(base_tiling_size)); |
| 1299 Region bottom_row_and_right_column_new_pixels = SubtractRegions( | 1275 Region bottom_row_and_right_column_new_pixels = SubtractRegions( |
| 1300 UnionRegions(gfx::UnionRects(pile_.tiling().TileBounds(0, 5), | 1276 UnionRegions(gfx::UnionRects(pile_.tiling().TileBounds(0, 5), |
| 1301 pile_.tiling().TileBounds(5, 5)), | 1277 pile_.tiling().TileBounds(5, 5)), |
| 1302 gfx::UnionRects(pile_.tiling().TileBounds(5, 0), | 1278 gfx::UnionRects(pile_.tiling().TileBounds(5, 0), |
| 1303 pile_.tiling().TileBounds(5, 5))), | 1279 pile_.tiling().TileBounds(5, 5))), |
| 1304 gfx::Rect(base_tiling_size)); | 1280 gfx::Rect(base_tiling_size)); |
| 1305 EXPECT_TRUE( | 1281 EXPECT_TRUE( |
| 1306 expected_invalidation.Contains(bottom_row_and_right_column_new_pixels)); | 1282 expected_invalidation.Contains(bottom_row_and_right_column_new_pixels)); |
| 1307 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); | 1283 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); |
| 1308 invalidation.Clear(); | 1284 invalidation.Clear(); |
| 1309 | 1285 |
| 1310 UpdateWholePile(); | 1286 UpdateWholePile(); |
| 1311 UpdateAndExpandInvalidation(&invalidation, base_tiling_size, gfx::Rect()); | 1287 UpdateAndExpandInvalidation(&invalidation, base_tiling_size, gfx::Rect()); |
| 1312 | 1288 |
| 1313 // We should have lost the recordings that are now outside the tiling only. | 1289 // We should have lost the recordings that are now outside the tiling only. |
| 1314 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); | 1290 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); |
| 1315 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); | 1291 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); |
| 1316 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { | 1292 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { |
| 1317 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { | 1293 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { |
| 1318 TestPicturePile::PictureMapKey key(i, j); | 1294 FakePicturePile::PictureMapKey key(i, j); |
| 1319 TestPicturePile::PictureMap& map = pile_.picture_map(); | 1295 FakePicturePile::PictureMap& map = pile_.picture_map(); |
| 1320 TestPicturePile::PictureMap::iterator it = map.find(key); | 1296 FakePicturePile::PictureMap::iterator it = map.find(key); |
| 1321 EXPECT_TRUE(it != map.end() && it->second.GetPicture()); | 1297 EXPECT_TRUE(it != map.end() && it->second.GetPicture()); |
| 1322 } | 1298 } |
| 1323 } | 1299 } |
| 1324 | 1300 |
| 1325 // We invalidated the previously exposed pixels on the bottom row and right | 1301 // We invalidated the previously exposed pixels on the bottom row and right |
| 1326 // column of tiles. | 1302 // column of tiles. |
| 1327 expected_invalidation = SubtractRegions(gfx::Rect(grow_both_tiling_size), | 1303 expected_invalidation = SubtractRegions(gfx::Rect(grow_both_tiling_size), |
| 1328 gfx::Rect(base_tiling_size)); | 1304 gfx::Rect(base_tiling_size)); |
| 1329 EXPECT_TRUE( | 1305 EXPECT_TRUE( |
| 1330 expected_invalidation.Contains(bottom_row_and_right_column_new_pixels)); | 1306 expected_invalidation.Contains(bottom_row_and_right_column_new_pixels)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1346 Region expected_invalidation; | 1322 Region expected_invalidation; |
| 1347 | 1323 |
| 1348 pile_.tiling().SetMaxTextureSize(gfx::Size(tile_size, tile_size)); | 1324 pile_.tiling().SetMaxTextureSize(gfx::Size(tile_size, tile_size)); |
| 1349 SetTilingSize(base_tiling_size); | 1325 SetTilingSize(base_tiling_size); |
| 1350 | 1326 |
| 1351 // We should have a recording for every tile. | 1327 // We should have a recording for every tile. |
| 1352 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); | 1328 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); |
| 1353 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); | 1329 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); |
| 1354 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { | 1330 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { |
| 1355 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { | 1331 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { |
| 1356 TestPicturePile::PictureMapKey key(i, j); | 1332 FakePicturePile::PictureMapKey key(i, j); |
| 1357 TestPicturePile::PictureMap& map = pile_.picture_map(); | 1333 FakePicturePile::PictureMap& map = pile_.picture_map(); |
| 1358 TestPicturePile::PictureMap::iterator it = map.find(key); | 1334 FakePicturePile::PictureMap::iterator it = map.find(key); |
| 1359 EXPECT_TRUE(it != map.end() && it->second.GetPicture()); | 1335 EXPECT_TRUE(it != map.end() && it->second.GetPicture()); |
| 1360 } | 1336 } |
| 1361 } | 1337 } |
| 1362 | 1338 |
| 1363 UpdateAndExpandInvalidation( | 1339 UpdateAndExpandInvalidation( |
| 1364 &invalidation, grow_down_tiling_size, gfx::Rect(1, 1)); | 1340 &invalidation, grow_down_tiling_size, gfx::Rect(1, 1)); |
| 1365 | 1341 |
| 1366 // We should have a recording for every tile. | 1342 // We should have a recording for every tile. |
| 1367 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); | 1343 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); |
| 1368 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); | 1344 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); |
| 1369 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { | 1345 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { |
| 1370 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { | 1346 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { |
| 1371 TestPicturePile::PictureMapKey key(i, j); | 1347 FakePicturePile::PictureMapKey key(i, j); |
| 1372 TestPicturePile::PictureMap& map = pile_.picture_map(); | 1348 FakePicturePile::PictureMap& map = pile_.picture_map(); |
| 1373 TestPicturePile::PictureMap::iterator it = map.find(key); | 1349 FakePicturePile::PictureMap::iterator it = map.find(key); |
| 1374 EXPECT_TRUE(it != map.end() && it->second.GetPicture()); | 1350 EXPECT_TRUE(it != map.end() && it->second.GetPicture()); |
| 1375 } | 1351 } |
| 1376 } | 1352 } |
| 1377 | 1353 |
| 1378 // We invalidated the newly exposed pixels. | 1354 // We invalidated the newly exposed pixels. |
| 1379 expected_invalidation = SubtractRegions(gfx::Rect(grow_down_tiling_size), | 1355 expected_invalidation = SubtractRegions(gfx::Rect(grow_down_tiling_size), |
| 1380 gfx::Rect(base_tiling_size)); | 1356 gfx::Rect(base_tiling_size)); |
| 1381 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); | 1357 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); |
| 1382 invalidation.Clear(); | 1358 invalidation.Clear(); |
| 1383 | 1359 |
| 1384 UpdateWholePile(); | 1360 UpdateWholePile(); |
| 1385 UpdateAndExpandInvalidation(&invalidation, base_tiling_size, gfx::Rect(1, 1)); | 1361 UpdateAndExpandInvalidation(&invalidation, base_tiling_size, gfx::Rect(1, 1)); |
| 1386 | 1362 |
| 1387 // We should have a recording for every tile. | 1363 // We should have a recording for every tile. |
| 1388 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); | 1364 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); |
| 1389 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); | 1365 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); |
| 1390 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { | 1366 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { |
| 1391 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { | 1367 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { |
| 1392 TestPicturePile::PictureMapKey key(i, j); | 1368 FakePicturePile::PictureMapKey key(i, j); |
| 1393 TestPicturePile::PictureMap& map = pile_.picture_map(); | 1369 FakePicturePile::PictureMap& map = pile_.picture_map(); |
| 1394 TestPicturePile::PictureMap::iterator it = map.find(key); | 1370 FakePicturePile::PictureMap::iterator it = map.find(key); |
| 1395 EXPECT_TRUE(it != map.end() && it->second.GetPicture()); | 1371 EXPECT_TRUE(it != map.end() && it->second.GetPicture()); |
| 1396 } | 1372 } |
| 1397 } | 1373 } |
| 1398 | 1374 |
| 1399 // We invalidated the previously exposed pixels. | 1375 // We invalidated the previously exposed pixels. |
| 1400 expected_invalidation = SubtractRegions(gfx::Rect(grow_down_tiling_size), | 1376 expected_invalidation = SubtractRegions(gfx::Rect(grow_down_tiling_size), |
| 1401 gfx::Rect(base_tiling_size)); | 1377 gfx::Rect(base_tiling_size)); |
| 1402 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); | 1378 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); |
| 1403 invalidation.Clear(); | 1379 invalidation.Clear(); |
| 1404 | 1380 |
| 1405 UpdateWholePile(); | 1381 UpdateWholePile(); |
| 1406 UpdateAndExpandInvalidation( | 1382 UpdateAndExpandInvalidation( |
| 1407 &invalidation, grow_right_tiling_size, gfx::Rect(1, 1)); | 1383 &invalidation, grow_right_tiling_size, gfx::Rect(1, 1)); |
| 1408 | 1384 |
| 1409 // We should have a recording for every tile. | 1385 // We should have a recording for every tile. |
| 1410 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); | 1386 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); |
| 1411 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); | 1387 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); |
| 1412 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { | 1388 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { |
| 1413 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { | 1389 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { |
| 1414 TestPicturePile::PictureMapKey key(i, j); | 1390 FakePicturePile::PictureMapKey key(i, j); |
| 1415 TestPicturePile::PictureMap& map = pile_.picture_map(); | 1391 FakePicturePile::PictureMap& map = pile_.picture_map(); |
| 1416 TestPicturePile::PictureMap::iterator it = map.find(key); | 1392 FakePicturePile::PictureMap::iterator it = map.find(key); |
| 1417 EXPECT_TRUE(it != map.end() && it->second.GetPicture()); | 1393 EXPECT_TRUE(it != map.end() && it->second.GetPicture()); |
| 1418 } | 1394 } |
| 1419 } | 1395 } |
| 1420 | 1396 |
| 1421 // We invalidated the newly exposed pixels. | 1397 // We invalidated the newly exposed pixels. |
| 1422 expected_invalidation = SubtractRegions(gfx::Rect(grow_right_tiling_size), | 1398 expected_invalidation = SubtractRegions(gfx::Rect(grow_right_tiling_size), |
| 1423 gfx::Rect(base_tiling_size)); | 1399 gfx::Rect(base_tiling_size)); |
| 1424 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); | 1400 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); |
| 1425 invalidation.Clear(); | 1401 invalidation.Clear(); |
| 1426 | 1402 |
| 1427 UpdateWholePile(); | 1403 UpdateWholePile(); |
| 1428 UpdateAndExpandInvalidation(&invalidation, base_tiling_size, gfx::Rect(1, 1)); | 1404 UpdateAndExpandInvalidation(&invalidation, base_tiling_size, gfx::Rect(1, 1)); |
| 1429 | 1405 |
| 1430 // We should have lost the recordings that are now outside the tiling only. | 1406 // We should have lost the recordings that are now outside the tiling only. |
| 1431 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); | 1407 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); |
| 1432 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); | 1408 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); |
| 1433 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { | 1409 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { |
| 1434 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { | 1410 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { |
| 1435 TestPicturePile::PictureMapKey key(i, j); | 1411 FakePicturePile::PictureMapKey key(i, j); |
| 1436 TestPicturePile::PictureMap& map = pile_.picture_map(); | 1412 FakePicturePile::PictureMap& map = pile_.picture_map(); |
| 1437 TestPicturePile::PictureMap::iterator it = map.find(key); | 1413 FakePicturePile::PictureMap::iterator it = map.find(key); |
| 1438 EXPECT_TRUE(it != map.end() && it->second.GetPicture()); | 1414 EXPECT_TRUE(it != map.end() && it->second.GetPicture()); |
| 1439 } | 1415 } |
| 1440 } | 1416 } |
| 1441 | 1417 |
| 1442 // We invalidated the previously exposed pixels. | 1418 // We invalidated the previously exposed pixels. |
| 1443 expected_invalidation = SubtractRegions(gfx::Rect(grow_right_tiling_size), | 1419 expected_invalidation = SubtractRegions(gfx::Rect(grow_right_tiling_size), |
| 1444 gfx::Rect(base_tiling_size)); | 1420 gfx::Rect(base_tiling_size)); |
| 1445 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); | 1421 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); |
| 1446 invalidation.Clear(); | 1422 invalidation.Clear(); |
| 1447 | 1423 |
| 1448 UpdateWholePile(); | 1424 UpdateWholePile(); |
| 1449 UpdateAndExpandInvalidation( | 1425 UpdateAndExpandInvalidation( |
| 1450 &invalidation, grow_both_tiling_size, gfx::Rect(1, 1)); | 1426 &invalidation, grow_both_tiling_size, gfx::Rect(1, 1)); |
| 1451 | 1427 |
| 1452 // We should have a recording for every tile. | 1428 // We should have a recording for every tile. |
| 1453 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); | 1429 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); |
| 1454 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); | 1430 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); |
| 1455 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { | 1431 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { |
| 1456 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { | 1432 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { |
| 1457 TestPicturePile::PictureMapKey key(i, j); | 1433 FakePicturePile::PictureMapKey key(i, j); |
| 1458 TestPicturePile::PictureMap& map = pile_.picture_map(); | 1434 FakePicturePile::PictureMap& map = pile_.picture_map(); |
| 1459 TestPicturePile::PictureMap::iterator it = map.find(key); | 1435 FakePicturePile::PictureMap::iterator it = map.find(key); |
| 1460 EXPECT_TRUE(it != map.end() && it->second.GetPicture()); | 1436 EXPECT_TRUE(it != map.end() && it->second.GetPicture()); |
| 1461 } | 1437 } |
| 1462 } | 1438 } |
| 1463 | 1439 |
| 1464 // We invalidated the newly exposed pixels. | 1440 // We invalidated the newly exposed pixels. |
| 1465 expected_invalidation = SubtractRegions(gfx::Rect(grow_both_tiling_size), | 1441 expected_invalidation = SubtractRegions(gfx::Rect(grow_both_tiling_size), |
| 1466 gfx::Rect(base_tiling_size)); | 1442 gfx::Rect(base_tiling_size)); |
| 1467 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); | 1443 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); |
| 1468 invalidation.Clear(); | 1444 invalidation.Clear(); |
| 1469 | 1445 |
| 1470 UpdateWholePile(); | 1446 UpdateWholePile(); |
| 1471 UpdateAndExpandInvalidation(&invalidation, base_tiling_size, gfx::Rect()); | 1447 UpdateAndExpandInvalidation(&invalidation, base_tiling_size, gfx::Rect()); |
| 1472 | 1448 |
| 1473 // We should have lost the recordings that are now outside the tiling only. | 1449 // We should have lost the recordings that are now outside the tiling only. |
| 1474 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); | 1450 EXPECT_EQ(6, pile_.tiling().num_tiles_x()); |
| 1475 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); | 1451 EXPECT_EQ(6, pile_.tiling().num_tiles_y()); |
| 1476 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { | 1452 for (int i = 0; i < pile_.tiling().num_tiles_x(); ++i) { |
| 1477 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { | 1453 for (int j = 0; j < pile_.tiling().num_tiles_y(); ++j) { |
| 1478 TestPicturePile::PictureMapKey key(i, j); | 1454 FakePicturePile::PictureMapKey key(i, j); |
| 1479 TestPicturePile::PictureMap& map = pile_.picture_map(); | 1455 FakePicturePile::PictureMap& map = pile_.picture_map(); |
| 1480 TestPicturePile::PictureMap::iterator it = map.find(key); | 1456 FakePicturePile::PictureMap::iterator it = map.find(key); |
| 1481 EXPECT_TRUE(it != map.end() && it->second.GetPicture()); | 1457 EXPECT_TRUE(it != map.end() && it->second.GetPicture()); |
| 1482 } | 1458 } |
| 1483 } | 1459 } |
| 1484 | 1460 |
| 1485 // We invalidated the previously exposed pixels. | 1461 // We invalidated the previously exposed pixels. |
| 1486 expected_invalidation = SubtractRegions(gfx::Rect(grow_both_tiling_size), | 1462 expected_invalidation = SubtractRegions(gfx::Rect(grow_both_tiling_size), |
| 1487 gfx::Rect(base_tiling_size)); | 1463 gfx::Rect(base_tiling_size)); |
| 1488 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); | 1464 EXPECT_EQ(expected_invalidation.ToString(), invalidation.ToString()); |
| 1489 invalidation.Clear(); | 1465 invalidation.Clear(); |
| 1490 } | 1466 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1566 EXPECT_TRUE(pile_.HasRecordings()); | 1542 EXPECT_TRUE(pile_.HasRecordings()); |
| 1567 pile_.SetEmptyBounds(); | 1543 pile_.SetEmptyBounds(); |
| 1568 EXPECT_FALSE(pile_.is_solid_color()); | 1544 EXPECT_FALSE(pile_.is_solid_color()); |
| 1569 EXPECT_TRUE(pile_.GetSize().IsEmpty()); | 1545 EXPECT_TRUE(pile_.GetSize().IsEmpty()); |
| 1570 EXPECT_TRUE(pile_.picture_map().empty()); | 1546 EXPECT_TRUE(pile_.picture_map().empty()); |
| 1571 EXPECT_FALSE(pile_.HasRecordings()); | 1547 EXPECT_FALSE(pile_.HasRecordings()); |
| 1572 } | 1548 } |
| 1573 | 1549 |
| 1574 } // namespace | 1550 } // namespace |
| 1575 } // namespace cc | 1551 } // namespace cc |
| OLD | NEW |