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 <limits> | 5 #include <limits> |
6 #include <set> | 6 #include <set> |
7 | 7 |
8 #include "cc/base/math_util.h" | 8 #include "cc/base/math_util.h" |
9 #include "cc/test/fake_display_list_raster_source.h" | 9 #include "cc/test/fake_display_list_raster_source.h" |
10 #include "cc/test/fake_output_surface.h" | 10 #include "cc/test/fake_output_surface.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 namespace { | 24 namespace { |
25 | 25 |
26 static gfx::Rect ViewportInLayerSpace( | 26 static gfx::Rect ViewportInLayerSpace( |
27 const gfx::Transform& transform, | 27 const gfx::Transform& transform, |
28 const gfx::Size& device_viewport) { | 28 const gfx::Size& device_viewport) { |
29 | 29 |
30 gfx::Transform inverse; | 30 gfx::Transform inverse; |
31 if (!transform.GetInverse(&inverse)) | 31 if (!transform.GetInverse(&inverse)) |
32 return gfx::Rect(); | 32 return gfx::Rect(); |
33 | 33 |
34 gfx::RectF viewport_in_layer_space = MathUtil::ProjectClippedRect( | 34 return MathUtil::ProjectEnclosingClippedRect(inverse, |
35 inverse, gfx::RectF(gfx::Point(0, 0), device_viewport)); | 35 gfx::Rect(device_viewport)); |
36 return ToEnclosingRect(viewport_in_layer_space); | |
37 } | 36 } |
38 | 37 |
39 class TestablePictureLayerTiling : public PictureLayerTiling { | 38 class TestablePictureLayerTiling : public PictureLayerTiling { |
40 public: | 39 public: |
41 using PictureLayerTiling::SetLiveTilesRect; | 40 using PictureLayerTiling::SetLiveTilesRect; |
42 using PictureLayerTiling::TileAt; | 41 using PictureLayerTiling::TileAt; |
43 | 42 |
44 static scoped_ptr<TestablePictureLayerTiling> Create( | 43 static scoped_ptr<TestablePictureLayerTiling> Create( |
45 WhichTree tree, | 44 WhichTree tree, |
46 float contents_scale, | 45 float contents_scale, |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 } | 496 } |
498 | 497 |
499 TEST_F(PictureLayerTilingIteratorTest, IteratorCoversLayerBoundsBothScale) { | 498 TEST_F(PictureLayerTilingIteratorTest, IteratorCoversLayerBoundsBothScale) { |
500 Initialize(gfx::Size(50, 50), 4.0f, gfx::Size(800, 600)); | 499 Initialize(gfx::Size(50, 50), 4.0f, gfx::Size(800, 600)); |
501 VerifyTilesExactlyCoverRect(2.0f, gfx::Rect()); | 500 VerifyTilesExactlyCoverRect(2.0f, gfx::Rect()); |
502 VerifyTilesExactlyCoverRect(2.0f, gfx::Rect(0, 0, 1600, 1200)); | 501 VerifyTilesExactlyCoverRect(2.0f, gfx::Rect(0, 0, 1600, 1200)); |
503 VerifyTilesExactlyCoverRect(2.0f, gfx::Rect(512, 365, 253, 182)); | 502 VerifyTilesExactlyCoverRect(2.0f, gfx::Rect(512, 365, 253, 182)); |
504 | 503 |
505 float scale = 6.7f; | 504 float scale = 6.7f; |
506 gfx::Size bounds(800, 600); | 505 gfx::Size bounds(800, 600); |
507 gfx::Rect full_rect(gfx::ToCeiledSize(gfx::ScaleSize(bounds, scale))); | 506 gfx::Rect full_rect(gfx::ScaleToCeiledSize(bounds, scale)); |
508 Initialize(gfx::Size(256, 512), 5.2f, bounds); | 507 Initialize(gfx::Size(256, 512), 5.2f, bounds); |
509 VerifyTilesExactlyCoverRect(scale, full_rect); | 508 VerifyTilesExactlyCoverRect(scale, full_rect); |
510 VerifyTilesExactlyCoverRect(scale, gfx::Rect(2014, 1579, 867, 1033)); | 509 VerifyTilesExactlyCoverRect(scale, gfx::Rect(2014, 1579, 867, 1033)); |
511 } | 510 } |
512 | 511 |
513 TEST_F(PictureLayerTilingIteratorTest, IteratorEmptyRect) { | 512 TEST_F(PictureLayerTilingIteratorTest, IteratorEmptyRect) { |
514 Initialize(gfx::Size(100, 100), 1.0f, gfx::Size(800, 600)); | 513 Initialize(gfx::Size(100, 100), 1.0f, gfx::Size(800, 600)); |
515 | 514 |
516 gfx::Rect empty; | 515 gfx::Rect empty; |
517 PictureLayerTiling::CoverageIterator iter(tiling_.get(), 1.0f, empty); | 516 PictureLayerTiling::CoverageIterator iter(tiling_.get(), 1.0f, empty); |
(...skipping 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1792 tiling_ = TestablePictureLayerTiling::Create(PENDING_TREE, contents_scale, | 1791 tiling_ = TestablePictureLayerTiling::Create(PENDING_TREE, contents_scale, |
1793 raster_source, &client_, | 1792 raster_source, &client_, |
1794 LayerTreeSettings()); | 1793 LayerTreeSettings()); |
1795 | 1794 |
1796 gfx::Rect content_rect(25554432, 25554432, 950, 860); | 1795 gfx::Rect content_rect(25554432, 25554432, 950, 860); |
1797 VerifyTilesExactlyCoverRect(contents_scale, content_rect); | 1796 VerifyTilesExactlyCoverRect(contents_scale, content_rect); |
1798 } | 1797 } |
1799 | 1798 |
1800 } // namespace | 1799 } // namespace |
1801 } // namespace cc | 1800 } // namespace cc |
OLD | NEW |