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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 picture_info.GetInvalidationFrequencyForTesting()); | 186 picture_info.GetInvalidationFrequencyForTesting()); |
187 } else { | 187 } else { |
188 EXPECT_FLOAT_EQ( | 188 EXPECT_FLOAT_EQ( |
189 1.0f / TestPicturePile::PictureInfo::INVALIDATION_FRAMES_TRACKED, | 189 1.0f / TestPicturePile::PictureInfo::INVALIDATION_FRAMES_TRACKED, |
190 picture_info.GetInvalidationFrequencyForTesting()); | 190 picture_info.GetInvalidationFrequencyForTesting()); |
191 } | 191 } |
192 } | 192 } |
193 } | 193 } |
194 } | 194 } |
195 | 195 |
| 196 TEST_F(PicturePileTest, InvalidateOnFullLayer) { |
| 197 UpdateWholePile(); |
| 198 |
| 199 // Everything was invalidated once so far. |
| 200 for (auto& it : pile_->picture_map()) { |
| 201 EXPECT_FLOAT_EQ( |
| 202 1.0f / TestPicturePile::PictureInfo::INVALIDATION_FRAMES_TRACKED, |
| 203 it.second.GetInvalidationFrequencyForTesting()); |
| 204 } |
| 205 |
| 206 // Invalidate everything, |
| 207 Region invalidation = tiling_rect(); |
| 208 UpdateAndExpandInvalidation(&invalidation, tiling_size(), tiling_rect()); |
| 209 |
| 210 // Everything was invalidated again. |
| 211 for (auto& it : pile_->picture_map()) { |
| 212 EXPECT_FLOAT_EQ( |
| 213 2.0f / TestPicturePile::PictureInfo::INVALIDATION_FRAMES_TRACKED, |
| 214 it.second.GetInvalidationFrequencyForTesting()); |
| 215 } |
| 216 } |
| 217 |
196 TEST_F(PicturePileTest, StopRecordingOffscreenInvalidations) { | 218 TEST_F(PicturePileTest, StopRecordingOffscreenInvalidations) { |
197 gfx::Size new_tiling_size = | 219 gfx::Size new_tiling_size = |
198 gfx::ToCeiledSize(gfx::ScaleSize(pile_->tiling_size(), 4.f)); | 220 gfx::ToCeiledSize(gfx::ScaleSize(pile_->tiling_size(), 4.f)); |
199 SetTilingSize(new_tiling_size); | 221 SetTilingSize(new_tiling_size); |
200 | 222 |
201 gfx::Rect viewport(tiling_size().width(), 1); | 223 gfx::Rect viewport(tiling_size().width(), 1); |
202 | 224 |
203 // Update the whole pile until the invalidation frequency is high. | 225 // Update the whole pile until the invalidation frequency is high. |
204 for (int frame = 0; frame < 33; ++frame) { | 226 for (int frame = 0; frame < 33; ++frame) { |
205 UpdateWholePile(); | 227 UpdateWholePile(); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 EXPECT_EQ(gfx::Rect(0, 0, 1, 1).ToString(), invalidation.ToString()); | 379 EXPECT_EQ(gfx::Rect(0, 0, 1, 1).ToString(), invalidation.ToString()); |
358 | 380 |
359 // No invalidation, changing viewport. | 381 // No invalidation, changing viewport. |
360 invalidation = Region(); | 382 invalidation = Region(); |
361 UpdateAndExpandInvalidation( | 383 UpdateAndExpandInvalidation( |
362 &invalidation, tiling_size(), gfx::Rect(5, 5, 5, 5)); | 384 &invalidation, tiling_size(), gfx::Rect(5, 5, 5, 5)); |
363 EXPECT_TRUE(!pile_->recorded_viewport().IsEmpty()); | 385 EXPECT_TRUE(!pile_->recorded_viewport().IsEmpty()); |
364 EXPECT_EQ(Region().ToString(), invalidation.ToString()); | 386 EXPECT_EQ(Region().ToString(), invalidation.ToString()); |
365 } | 387 } |
366 | 388 |
| 389 TEST_F(PicturePileTest, BigFullLayerInvalidation) { |
| 390 gfx::Size huge_layer_size(100000000, 100000000); |
| 391 gfx::Rect viewport(300000, 400000, 5000, 6000); |
| 392 |
| 393 // Resize the pile. |
| 394 Region invalidation; |
| 395 UpdateAndExpandInvalidation(&invalidation, huge_layer_size, viewport); |
| 396 |
| 397 // Invalidating a huge layer should be fast. |
| 398 base::TimeTicks start = base::TimeTicks::Now(); |
| 399 invalidation = gfx::Rect(huge_layer_size); |
| 400 UpdateAndExpandInvalidation(&invalidation, huge_layer_size, viewport); |
| 401 base::TimeTicks end = base::TimeTicks::Now(); |
| 402 base::TimeDelta length = end - start; |
| 403 // This is verrrry generous to avoid flake. |
| 404 EXPECT_LT(length.InSeconds(), 5); |
| 405 } |
| 406 |
| 407 TEST_F(PicturePileTest, BigFullLayerInvalidationWithResizeGrow) { |
| 408 gfx::Size huge_layer_size(100000000, 100000000); |
| 409 gfx::Rect viewport(300000, 400000, 5000, 6000); |
| 410 |
| 411 // Resize the pile. |
| 412 Region invalidation; |
| 413 UpdateAndExpandInvalidation(&invalidation, huge_layer_size, viewport); |
| 414 |
| 415 // Resize the pile even larger, while invalidating everything in the old size. |
| 416 // Invalidating the whole thing should be fast. |
| 417 base::TimeTicks start = base::TimeTicks::Now(); |
| 418 gfx::Size bigger_layer_size(huge_layer_size.width() * 2, |
| 419 huge_layer_size.height() * 2); |
| 420 invalidation = gfx::Rect(huge_layer_size); |
| 421 UpdateAndExpandInvalidation(&invalidation, bigger_layer_size, viewport); |
| 422 base::TimeTicks end = base::TimeTicks::Now(); |
| 423 base::TimeDelta length = end - start; |
| 424 // This is verrrry generous to avoid flake. |
| 425 EXPECT_LT(length.InSeconds(), 5); |
| 426 } |
| 427 |
| 428 TEST_F(PicturePileTest, BigFullLayerInvalidationWithResizeShrink) { |
| 429 gfx::Size huge_layer_size(100000000, 100000000); |
| 430 gfx::Rect viewport(300000, 400000, 5000, 6000); |
| 431 |
| 432 // Resize the pile. |
| 433 Region invalidation; |
| 434 UpdateAndExpandInvalidation(&invalidation, huge_layer_size, viewport); |
| 435 |
| 436 // Resize the pile smaller, while invalidating everything in the new size. |
| 437 // Invalidating the whole thing should be fast. |
| 438 base::TimeTicks start = base::TimeTicks::Now(); |
| 439 gfx::Size smaller_layer_size(huge_layer_size.width() - 1000, |
| 440 huge_layer_size.height() - 1000); |
| 441 invalidation = gfx::Rect(smaller_layer_size); |
| 442 UpdateAndExpandInvalidation(&invalidation, smaller_layer_size, viewport); |
| 443 base::TimeTicks end = base::TimeTicks::Now(); |
| 444 base::TimeDelta length = end - start; |
| 445 // This is verrrry generous to avoid flake. |
| 446 EXPECT_LT(length.InSeconds(), 5); |
| 447 } |
| 448 |
367 TEST_F(PicturePileTest, InvalidationOutsideRecordingRect) { | 449 TEST_F(PicturePileTest, InvalidationOutsideRecordingRect) { |
368 gfx::Size huge_layer_size(10000000, 20000000); | 450 gfx::Size huge_layer_size(10000000, 20000000); |
369 gfx::Rect viewport(300000, 400000, 5000, 6000); | 451 gfx::Rect viewport(300000, 400000, 5000, 6000); |
370 | 452 |
371 // Resize the pile and set up the interest rect. | 453 // Resize the pile and set up the interest rect. |
372 Region invalidation; | 454 Region invalidation; |
373 UpdateAndExpandInvalidation(&invalidation, huge_layer_size, viewport); | 455 UpdateAndExpandInvalidation(&invalidation, huge_layer_size, viewport); |
374 | 456 |
375 // Invalidation inside the recording rect does not need to be expanded. | 457 // Invalidation inside the recording rect does not need to be expanded. |
376 invalidation = viewport; | 458 invalidation = viewport; |
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1271 client_.add_draw_rect(tiling_rect(), paint); | 1353 client_.add_draw_rect(tiling_rect(), paint); |
1272 client_.add_draw_rect(tiling_rect(), paint); | 1354 client_.add_draw_rect(tiling_rect(), paint); |
1273 client_.add_draw_rect(tiling_rect(), paint); | 1355 client_.add_draw_rect(tiling_rect(), paint); |
1274 Region invalidation5(tiling_rect()); | 1356 Region invalidation5(tiling_rect()); |
1275 UpdateAndExpandInvalidation(&invalidation5, tiling_size(), tiling_rect()); | 1357 UpdateAndExpandInvalidation(&invalidation5, tiling_size(), tiling_rect()); |
1276 EXPECT_FALSE(pile_->is_solid_color()); | 1358 EXPECT_FALSE(pile_->is_solid_color()); |
1277 } | 1359 } |
1278 | 1360 |
1279 } // namespace | 1361 } // namespace |
1280 } // namespace cc | 1362 } // namespace cc |
OLD | NEW |