OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/resources/picture_layer_tiling.h" | 5 #include "cc/resources/picture_layer_tiling.h" |
6 | 6 |
7 #include "cc/test/fake_picture_layer_tiling_client.h" | 7 #include "cc/test/fake_picture_layer_tiling_client.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "ui/gfx/rect_conversions.h" | 9 #include "ui/gfx/rect_conversions.h" |
10 #include "ui/gfx/size_conversions.h" | 10 #include "ui/gfx/size_conversions.h" |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 gfx::Rect out = PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy( | 431 gfx::Rect out = PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy( |
432 in, target_area, bounds); | 432 in, target_area, bounds); |
433 EXPECT_EQ(bounds.right(), out.right()); | 433 EXPECT_EQ(bounds.right(), out.right()); |
434 EXPECT_EQ(bounds.bottom(), out.bottom()); | 434 EXPECT_EQ(bounds.bottom(), out.bottom()); |
435 EXPECT_LE(out.width() * out.height(), target_area); | 435 EXPECT_LE(out.width() * out.height(), target_area); |
436 EXPECT_GT(out.width() * out.height(), | 436 EXPECT_GT(out.width() * out.height(), |
437 target_area - out.width() - out.height()); | 437 target_area - out.width() - out.height()); |
438 EXPECT_TRUE(bounds.Contains(out)); | 438 EXPECT_TRUE(bounds.Contains(out)); |
439 } | 439 } |
440 | 440 |
| 441 TEST(PictureLayerTilingTest, ShrinkRectContainingBounds) { |
| 442 gfx::Rect in(0, 0, 600, 600); |
| 443 gfx::Rect bounds(0, 0, 10, 10); |
| 444 int64 target_area = 20 * 20; |
| 445 gfx::Rect out = PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy( |
| 446 in, target_area, bounds); |
| 447 EXPECT_EQ(bounds.ToString(), out.ToString()); |
| 448 } |
| 449 |
441 TEST(PictureLayerTilingTest, EmptyStartingRect) { | 450 TEST(PictureLayerTilingTest, EmptyStartingRect) { |
442 // If a layer has a non-invertible transform, then the starting rect | 451 // If a layer has a non-invertible transform, then the starting rect |
443 // for the layer would be empty. | 452 // for the layer would be empty. |
444 gfx::Rect in(40, 40, 0, 0); | 453 gfx::Rect in(40, 40, 0, 0); |
445 gfx::Rect bounds(0, 0, 10, 10); | 454 gfx::Rect bounds(0, 0, 10, 10); |
446 int64 target_area = 400 * 400; | 455 int64 target_area = 400 * 400; |
447 gfx::Rect out = PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy( | 456 gfx::Rect out = PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy( |
448 in, target_area, bounds); | 457 in, target_area, bounds); |
449 EXPECT_TRUE(out.IsEmpty()); | 458 EXPECT_TRUE(out.IsEmpty()); |
450 } | 459 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 gfx::Transform(), // current screen transform | 498 gfx::Transform(), // current screen transform |
490 2, // current frame number | 499 2, // current frame number |
491 2.0, // current frame time | 500 2.0, // current frame time |
492 false, // store screen space quads on tiles | 501 false, // store screen space quads on tiles |
493 10000); // max tiles in tile manager | 502 10000); // max tiles in tile manager |
494 VerifyTiles(1.f, gfx::Rect(), base::Bind(&TileExists, false)); | 503 VerifyTiles(1.f, gfx::Rect(), base::Bind(&TileExists, false)); |
495 } | 504 } |
496 | 505 |
497 } // namespace | 506 } // namespace |
498 } // namespace cc | 507 } // namespace cc |
OLD | NEW |