| 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_output_surface.h" | 9 #include "cc/test/fake_output_surface.h" |
| 10 #include "cc/test/fake_output_surface_client.h" | 10 #include "cc/test/fake_output_surface_client.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 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 } | 493 } |
| 495 | 494 |
| 496 TEST_F(PictureLayerTilingIteratorTest, IteratorCoversLayerBoundsBothScale) { | 495 TEST_F(PictureLayerTilingIteratorTest, IteratorCoversLayerBoundsBothScale) { |
| 497 Initialize(gfx::Size(50, 50), 4.0f, gfx::Size(800, 600)); | 496 Initialize(gfx::Size(50, 50), 4.0f, gfx::Size(800, 600)); |
| 498 VerifyTilesExactlyCoverRect(2.0f, gfx::Rect()); | 497 VerifyTilesExactlyCoverRect(2.0f, gfx::Rect()); |
| 499 VerifyTilesExactlyCoverRect(2.0f, gfx::Rect(0, 0, 1600, 1200)); | 498 VerifyTilesExactlyCoverRect(2.0f, gfx::Rect(0, 0, 1600, 1200)); |
| 500 VerifyTilesExactlyCoverRect(2.0f, gfx::Rect(512, 365, 253, 182)); | 499 VerifyTilesExactlyCoverRect(2.0f, gfx::Rect(512, 365, 253, 182)); |
| 501 | 500 |
| 502 float scale = 6.7f; | 501 float scale = 6.7f; |
| 503 gfx::Size bounds(800, 600); | 502 gfx::Size bounds(800, 600); |
| 504 gfx::Rect full_rect(gfx::ToCeiledSize(gfx::ScaleSize(bounds, scale))); | 503 gfx::Rect full_rect(gfx::ScaleToCeiledSize(bounds, scale)); |
| 505 Initialize(gfx::Size(256, 512), 5.2f, bounds); | 504 Initialize(gfx::Size(256, 512), 5.2f, bounds); |
| 506 VerifyTilesExactlyCoverRect(scale, full_rect); | 505 VerifyTilesExactlyCoverRect(scale, full_rect); |
| 507 VerifyTilesExactlyCoverRect(scale, gfx::Rect(2014, 1579, 867, 1033)); | 506 VerifyTilesExactlyCoverRect(scale, gfx::Rect(2014, 1579, 867, 1033)); |
| 508 } | 507 } |
| 509 | 508 |
| 510 TEST_F(PictureLayerTilingIteratorTest, IteratorEmptyRect) { | 509 TEST_F(PictureLayerTilingIteratorTest, IteratorEmptyRect) { |
| 511 Initialize(gfx::Size(100, 100), 1.0f, gfx::Size(800, 600)); | 510 Initialize(gfx::Size(100, 100), 1.0f, gfx::Size(800, 600)); |
| 512 | 511 |
| 513 gfx::Rect empty; | 512 gfx::Rect empty; |
| 514 PictureLayerTiling::CoverageIterator iter(tiling_.get(), 1.0f, empty); | 513 PictureLayerTiling::CoverageIterator iter(tiling_.get(), 1.0f, empty); |
| (...skipping 1285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1800 tile_size, layer_size, gfx::Rect(), filled); | 1799 tile_size, layer_size, gfx::Rect(), filled); |
| 1801 tiling_ = TestablePictureLayerTiling::Create( | 1800 tiling_ = TestablePictureLayerTiling::Create( |
| 1802 PENDING_TREE, contents_scale, pile, &client_, LayerTreeSettings()); | 1801 PENDING_TREE, contents_scale, pile, &client_, LayerTreeSettings()); |
| 1803 | 1802 |
| 1804 gfx::Rect content_rect(25554432, 25554432, 950, 860); | 1803 gfx::Rect content_rect(25554432, 25554432, 950, 860); |
| 1805 VerifyTilesExactlyCoverRect(contents_scale, content_rect); | 1804 VerifyTilesExactlyCoverRect(contents_scale, content_rect); |
| 1806 } | 1805 } |
| 1807 | 1806 |
| 1808 } // namespace | 1807 } // namespace |
| 1809 } // namespace cc | 1808 } // namespace cc |
| OLD | NEW |