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/tiles/picture_layer_tiling.h" | 5 #include "cc/tiles/picture_layer_tiling.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <limits> | 9 #include <limits> |
10 #include <set> | 10 #include <set> |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 TestablePictureLayerTiling(WhichTree tree, | 69 TestablePictureLayerTiling(WhichTree tree, |
70 float contents_scale, | 70 float contents_scale, |
71 scoped_refptr<RasterSource> raster_source, | 71 scoped_refptr<RasterSource> raster_source, |
72 PictureLayerTilingClient* client, | 72 PictureLayerTilingClient* client, |
73 size_t tiling_interest_area_padding, | 73 size_t tiling_interest_area_padding, |
74 float skewport_target_time, | 74 float skewport_target_time, |
75 int skewport_extrapolation_limit, | 75 int skewport_extrapolation_limit, |
76 float min_preraster_distance, | 76 float min_preraster_distance, |
77 float max_preraster_distance) | 77 float max_preraster_distance) |
78 : PictureLayerTiling(tree, | 78 : PictureLayerTiling(tree, |
79 gfx::SizeF(contents_scale, contents_scale), | 79 contents_scale, |
80 raster_source, | 80 raster_source, |
81 client, | 81 client, |
82 min_preraster_distance, | 82 min_preraster_distance, |
83 max_preraster_distance) {} | 83 max_preraster_distance) {} |
84 }; | 84 }; |
85 | 85 |
86 class PictureLayerTilingIteratorTest : public testing::Test { | 86 class PictureLayerTilingIteratorTest : public testing::Test { |
87 public: | 87 public: |
88 PictureLayerTilingIteratorTest() {} | 88 PictureLayerTilingIteratorTest() {} |
89 ~PictureLayerTilingIteratorTest() override {} | 89 ~PictureLayerTilingIteratorTest() override {} |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 void VerifyTilesExactlyCoverRect( | 126 void VerifyTilesExactlyCoverRect( |
127 float rect_scale, | 127 float rect_scale, |
128 const gfx::Rect& request_rect, | 128 const gfx::Rect& request_rect, |
129 const gfx::Rect& expect_rect) { | 129 const gfx::Rect& expect_rect) { |
130 EXPECT_TRUE(request_rect.Contains(expect_rect)); | 130 EXPECT_TRUE(request_rect.Contains(expect_rect)); |
131 | 131 |
132 // Iterators are not valid if the destination scale is smaller than the | 132 // Iterators are not valid if the destination scale is smaller than the |
133 // tiling scale. This is because coverage computation is done in integer | 133 // tiling scale. This is because coverage computation is done in integer |
134 // grids in the dest space, and the overlap between tiles may not guarantee | 134 // grids in the dest space, and the overlap between tiles may not guarantee |
135 // to enclose an integer grid line to round to if scaled down. | 135 // to enclose an integer grid line to round to if scaled down. |
136 ASSERT_GE(rect_scale, tiling_->contents_scale_key()); | 136 ASSERT_GE(rect_scale, tiling_->contents_scale()); |
137 | 137 |
138 Region remaining = expect_rect; | 138 Region remaining = expect_rect; |
139 for (PictureLayerTiling::CoverageIterator | 139 for (PictureLayerTiling::CoverageIterator |
140 iter(tiling_.get(), rect_scale, request_rect); | 140 iter(tiling_.get(), rect_scale, request_rect); |
141 iter; | 141 iter; |
142 ++iter) { | 142 ++iter) { |
143 // Geometry cannot overlap previous geometry at all | 143 // Geometry cannot overlap previous geometry at all |
144 gfx::Rect geometry = iter.geometry_rect(); | 144 gfx::Rect geometry = iter.geometry_rect(); |
145 EXPECT_TRUE(expect_rect.Contains(geometry)); | 145 EXPECT_TRUE(expect_rect.Contains(geometry)); |
146 EXPECT_TRUE(remaining.Contains(geometry)); | 146 EXPECT_TRUE(remaining.Contains(geometry)); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 iter; | 194 iter; |
195 ++iter) { | 195 ++iter) { |
196 remaining.Subtract(iter.geometry_rect()); | 196 remaining.Subtract(iter.geometry_rect()); |
197 callback.Run(*iter, iter.geometry_rect()); | 197 callback.Run(*iter, iter.geometry_rect()); |
198 } | 198 } |
199 EXPECT_TRUE(remaining.IsEmpty()); | 199 EXPECT_TRUE(remaining.IsEmpty()); |
200 } | 200 } |
201 | 201 |
202 void VerifyTilesCoverNonContainedRect(float rect_scale, | 202 void VerifyTilesCoverNonContainedRect(float rect_scale, |
203 const gfx::Rect& dest_rect) { | 203 const gfx::Rect& dest_rect) { |
204 float dest_to_contents_scale = tiling_->contents_scale_key() / rect_scale; | 204 float dest_to_contents_scale = tiling_->contents_scale() / rect_scale; |
205 gfx::Rect clamped_rect = gfx::ScaleToEnclosingRect( | 205 gfx::Rect clamped_rect = gfx::ScaleToEnclosingRect( |
206 gfx::Rect(tiling_->tiling_size()), 1.f / dest_to_contents_scale); | 206 gfx::Rect(tiling_->tiling_size()), 1.f / dest_to_contents_scale); |
207 clamped_rect.Intersect(dest_rect); | 207 clamped_rect.Intersect(dest_rect); |
208 VerifyTilesExactlyCoverRect(rect_scale, dest_rect, clamped_rect); | 208 VerifyTilesExactlyCoverRect(rect_scale, dest_rect, clamped_rect); |
209 } | 209 } |
210 | 210 |
211 protected: | 211 protected: |
212 FakePictureLayerTilingClient client_; | 212 FakePictureLayerTilingClient client_; |
213 std::unique_ptr<TestablePictureLayerTiling> tiling_; | 213 std::unique_ptr<TestablePictureLayerTiling> tiling_; |
214 bool loose_texel_extent_check_ = false; | 214 bool loose_texel_extent_check_ = false; |
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1084 | 1084 |
1085 active_tiling->TakeTilesAndPropertiesFrom(tiling_.get(), | 1085 active_tiling->TakeTilesAndPropertiesFrom(tiling_.get(), |
1086 Region(gfx::Rect(bounds))); | 1086 Region(gfx::Rect(bounds))); |
1087 for (const auto* tile : tiles) { | 1087 for (const auto* tile : tiles) { |
1088 EXPECT_EQ(tile->tiling(), active_tiling.get()); | 1088 EXPECT_EQ(tile->tiling(), active_tiling.get()); |
1089 } | 1089 } |
1090 } | 1090 } |
1091 | 1091 |
1092 } // namespace | 1092 } // namespace |
1093 } // namespace cc | 1093 } // namespace cc |
OLD | NEW |