Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(709)

Side by Side Diff: cc/tiles/picture_layer_tiling_set_unittest.cc

Issue 2566613002: [4/5] Add translated rasterization support for PictureLayerTilingSet & below (Closed)
Patch Set: still need that rebaseline Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/tiles/picture_layer_tiling_set.cc ('k') | cc/tiles/picture_layer_tiling_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_set.h" 5 #include "cc/tiles/picture_layer_tiling_set.h"
6 6
7 #include <map> 7 #include <map>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 TEST(PictureLayerTilingSetTest, NoResources) { 61 TEST(PictureLayerTilingSetTest, NoResources) {
62 FakePictureLayerTilingClient client; 62 FakePictureLayerTilingClient client;
63 gfx::Size layer_bounds(1000, 800); 63 gfx::Size layer_bounds(1000, 800);
64 std::unique_ptr<TestablePictureLayerTilingSet> set = CreateTilingSet(&client); 64 std::unique_ptr<TestablePictureLayerTilingSet> set = CreateTilingSet(&client);
65 client.SetTileSize(gfx::Size(256, 256)); 65 client.SetTileSize(gfx::Size(256, 256));
66 66
67 scoped_refptr<FakeRasterSource> raster_source = 67 scoped_refptr<FakeRasterSource> raster_source =
68 FakeRasterSource::CreateEmpty(layer_bounds); 68 FakeRasterSource::CreateEmpty(layer_bounds);
69 69
70 set->AddTiling(1.0, raster_source); 70 set->AddTiling(gfx::AxisTransform2d(), raster_source);
71 set->AddTiling(1.5, raster_source); 71 set->AddTiling(gfx::AxisTransform2d(1.5, gfx::Vector2dF()), raster_source);
72 set->AddTiling(2.0, raster_source); 72 set->AddTiling(gfx::AxisTransform2d(2.0, gfx::Vector2dF()), raster_source);
73 73
74 float contents_scale = 2.0; 74 float contents_scale = 2.0;
75 gfx::Size content_bounds( 75 gfx::Size content_bounds(
76 gfx::ScaleToCeiledSize(layer_bounds, contents_scale)); 76 gfx::ScaleToCeiledSize(layer_bounds, contents_scale));
77 gfx::Rect content_rect(content_bounds); 77 gfx::Rect content_rect(content_bounds);
78 78
79 Region remaining(content_rect); 79 Region remaining(content_rect);
80 PictureLayerTilingSet::CoverageIterator iter(set.get(), contents_scale, 80 PictureLayerTilingSet::CoverageIterator iter(set.get(), contents_scale,
81 content_rect, contents_scale); 81 content_rect, contents_scale);
82 for (; iter; ++iter) { 82 for (; iter; ++iter) {
(...skipping 16 matching lines...) Expand all
99 PictureLayerTilingSet::TilingRange between_high_and_low_res_range(0, 0); 99 PictureLayerTilingSet::TilingRange between_high_and_low_res_range(0, 0);
100 PictureLayerTilingSet::TilingRange low_res_range(0, 0); 100 PictureLayerTilingSet::TilingRange low_res_range(0, 0);
101 PictureLayerTilingSet::TilingRange lower_than_low_res_range(0, 0); 101 PictureLayerTilingSet::TilingRange lower_than_low_res_range(0, 0);
102 PictureLayerTiling* high_res_tiling; 102 PictureLayerTiling* high_res_tiling;
103 PictureLayerTiling* low_res_tiling; 103 PictureLayerTiling* low_res_tiling;
104 104
105 scoped_refptr<FakeRasterSource> raster_source = 105 scoped_refptr<FakeRasterSource> raster_source =
106 FakeRasterSource::CreateFilled(layer_bounds); 106 FakeRasterSource::CreateFilled(layer_bounds);
107 107
108 std::unique_ptr<TestablePictureLayerTilingSet> set = CreateTilingSet(&client); 108 std::unique_ptr<TestablePictureLayerTilingSet> set = CreateTilingSet(&client);
109 set->AddTiling(2.0, raster_source); 109 set->AddTiling(gfx::AxisTransform2d(2.0, gfx::Vector2dF()), raster_source);
110 high_res_tiling = set->AddTiling(1.0, raster_source); 110 high_res_tiling = set->AddTiling(gfx::AxisTransform2d(), raster_source);
111 high_res_tiling->set_resolution(HIGH_RESOLUTION); 111 high_res_tiling->set_resolution(HIGH_RESOLUTION);
112 set->AddTiling(0.5, raster_source); 112 set->AddTiling(gfx::AxisTransform2d(0.5, gfx::Vector2dF()), raster_source);
113 low_res_tiling = set->AddTiling(0.25, raster_source); 113 low_res_tiling = set->AddTiling(gfx::AxisTransform2d(0.25, gfx::Vector2dF()),
114 raster_source);
114 low_res_tiling->set_resolution(LOW_RESOLUTION); 115 low_res_tiling->set_resolution(LOW_RESOLUTION);
115 set->AddTiling(0.125, raster_source); 116 set->AddTiling(gfx::AxisTransform2d(0.125, gfx::Vector2dF()), raster_source);
116 117
117 higher_than_high_res_range = 118 higher_than_high_res_range =
118 set->GetTilingRange(PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); 119 set->GetTilingRange(PictureLayerTilingSet::HIGHER_THAN_HIGH_RES);
119 EXPECT_EQ(0u, higher_than_high_res_range.start); 120 EXPECT_EQ(0u, higher_than_high_res_range.start);
120 EXPECT_EQ(1u, higher_than_high_res_range.end); 121 EXPECT_EQ(1u, higher_than_high_res_range.end);
121 122
122 high_res_range = set->GetTilingRange(PictureLayerTilingSet::HIGH_RES); 123 high_res_range = set->GetTilingRange(PictureLayerTilingSet::HIGH_RES);
123 EXPECT_EQ(1u, high_res_range.start); 124 EXPECT_EQ(1u, high_res_range.start);
124 EXPECT_EQ(2u, high_res_range.end); 125 EXPECT_EQ(2u, high_res_range.end);
125 126
126 between_high_and_low_res_range = 127 between_high_and_low_res_range =
127 set->GetTilingRange(PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES); 128 set->GetTilingRange(PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES);
128 EXPECT_EQ(2u, between_high_and_low_res_range.start); 129 EXPECT_EQ(2u, between_high_and_low_res_range.start);
129 EXPECT_EQ(3u, between_high_and_low_res_range.end); 130 EXPECT_EQ(3u, between_high_and_low_res_range.end);
130 131
131 low_res_range = set->GetTilingRange(PictureLayerTilingSet::LOW_RES); 132 low_res_range = set->GetTilingRange(PictureLayerTilingSet::LOW_RES);
132 EXPECT_EQ(3u, low_res_range.start); 133 EXPECT_EQ(3u, low_res_range.start);
133 EXPECT_EQ(4u, low_res_range.end); 134 EXPECT_EQ(4u, low_res_range.end);
134 135
135 lower_than_low_res_range = 136 lower_than_low_res_range =
136 set->GetTilingRange(PictureLayerTilingSet::LOWER_THAN_LOW_RES); 137 set->GetTilingRange(PictureLayerTilingSet::LOWER_THAN_LOW_RES);
137 EXPECT_EQ(4u, lower_than_low_res_range.start); 138 EXPECT_EQ(4u, lower_than_low_res_range.start);
138 EXPECT_EQ(5u, lower_than_low_res_range.end); 139 EXPECT_EQ(5u, lower_than_low_res_range.end);
139 140
140 std::unique_ptr<TestablePictureLayerTilingSet> set_without_low_res = 141 std::unique_ptr<TestablePictureLayerTilingSet> set_without_low_res =
141 CreateTilingSet(&client); 142 CreateTilingSet(&client);
142 set_without_low_res->AddTiling(2.0, raster_source); 143 set_without_low_res->AddTiling(gfx::AxisTransform2d(2.0, gfx::Vector2dF()),
143 high_res_tiling = set_without_low_res->AddTiling(1.0, raster_source); 144 raster_source);
145 high_res_tiling =
146 set_without_low_res->AddTiling(gfx::AxisTransform2d(), raster_source);
144 high_res_tiling->set_resolution(HIGH_RESOLUTION); 147 high_res_tiling->set_resolution(HIGH_RESOLUTION);
145 set_without_low_res->AddTiling(0.5, raster_source); 148 set_without_low_res->AddTiling(gfx::AxisTransform2d(0.5, gfx::Vector2dF()),
146 set_without_low_res->AddTiling(0.25, raster_source); 149 raster_source);
150 set_without_low_res->AddTiling(gfx::AxisTransform2d(0.25, gfx::Vector2dF()),
151 raster_source);
147 152
148 higher_than_high_res_range = set_without_low_res->GetTilingRange( 153 higher_than_high_res_range = set_without_low_res->GetTilingRange(
149 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); 154 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES);
150 EXPECT_EQ(0u, higher_than_high_res_range.start); 155 EXPECT_EQ(0u, higher_than_high_res_range.start);
151 EXPECT_EQ(1u, higher_than_high_res_range.end); 156 EXPECT_EQ(1u, higher_than_high_res_range.end);
152 157
153 high_res_range = 158 high_res_range =
154 set_without_low_res->GetTilingRange(PictureLayerTilingSet::HIGH_RES); 159 set_without_low_res->GetTilingRange(PictureLayerTilingSet::HIGH_RES);
155 EXPECT_EQ(1u, high_res_range.start); 160 EXPECT_EQ(1u, high_res_range.start);
156 EXPECT_EQ(2u, high_res_range.end); 161 EXPECT_EQ(2u, high_res_range.end);
157 162
158 between_high_and_low_res_range = set_without_low_res->GetTilingRange( 163 between_high_and_low_res_range = set_without_low_res->GetTilingRange(
159 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES); 164 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES);
160 EXPECT_EQ(2u, between_high_and_low_res_range.start); 165 EXPECT_EQ(2u, between_high_and_low_res_range.start);
161 EXPECT_EQ(4u, between_high_and_low_res_range.end); 166 EXPECT_EQ(4u, between_high_and_low_res_range.end);
162 167
163 low_res_range = 168 low_res_range =
164 set_without_low_res->GetTilingRange(PictureLayerTilingSet::LOW_RES); 169 set_without_low_res->GetTilingRange(PictureLayerTilingSet::LOW_RES);
165 EXPECT_EQ(0u, low_res_range.end - low_res_range.start); 170 EXPECT_EQ(0u, low_res_range.end - low_res_range.start);
166 171
167 lower_than_low_res_range = set_without_low_res->GetTilingRange( 172 lower_than_low_res_range = set_without_low_res->GetTilingRange(
168 PictureLayerTilingSet::LOWER_THAN_LOW_RES); 173 PictureLayerTilingSet::LOWER_THAN_LOW_RES);
169 EXPECT_EQ(0u, lower_than_low_res_range.end - lower_than_low_res_range.start); 174 EXPECT_EQ(0u, lower_than_low_res_range.end - lower_than_low_res_range.start);
170 175
171 std::unique_ptr<TestablePictureLayerTilingSet> 176 std::unique_ptr<TestablePictureLayerTilingSet>
172 set_with_only_high_and_low_res = CreateTilingSet(&client); 177 set_with_only_high_and_low_res = CreateTilingSet(&client);
173 high_res_tiling = 178 high_res_tiling = set_with_only_high_and_low_res->AddTiling(
174 set_with_only_high_and_low_res->AddTiling(1.0, raster_source); 179 gfx::AxisTransform2d(), raster_source);
175 high_res_tiling->set_resolution(HIGH_RESOLUTION); 180 high_res_tiling->set_resolution(HIGH_RESOLUTION);
176 low_res_tiling = 181 low_res_tiling = set_with_only_high_and_low_res->AddTiling(
177 set_with_only_high_and_low_res->AddTiling(0.5, raster_source); 182 gfx::AxisTransform2d(0.5, gfx::Vector2dF()), raster_source);
178 low_res_tiling->set_resolution(LOW_RESOLUTION); 183 low_res_tiling->set_resolution(LOW_RESOLUTION);
179 184
180 higher_than_high_res_range = set_with_only_high_and_low_res->GetTilingRange( 185 higher_than_high_res_range = set_with_only_high_and_low_res->GetTilingRange(
181 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); 186 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES);
182 EXPECT_EQ(0u, 187 EXPECT_EQ(0u,
183 higher_than_high_res_range.end - higher_than_high_res_range.start); 188 higher_than_high_res_range.end - higher_than_high_res_range.start);
184 189
185 high_res_range = set_with_only_high_and_low_res->GetTilingRange( 190 high_res_range = set_with_only_high_and_low_res->GetTilingRange(
186 PictureLayerTilingSet::HIGH_RES); 191 PictureLayerTilingSet::HIGH_RES);
187 EXPECT_EQ(0u, high_res_range.start); 192 EXPECT_EQ(0u, high_res_range.start);
188 EXPECT_EQ(1u, high_res_range.end); 193 EXPECT_EQ(1u, high_res_range.end);
189 194
190 between_high_and_low_res_range = 195 between_high_and_low_res_range =
191 set_with_only_high_and_low_res->GetTilingRange( 196 set_with_only_high_and_low_res->GetTilingRange(
192 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES); 197 PictureLayerTilingSet::BETWEEN_HIGH_AND_LOW_RES);
193 EXPECT_EQ(0u, between_high_and_low_res_range.end - 198 EXPECT_EQ(0u, between_high_and_low_res_range.end -
194 between_high_and_low_res_range.start); 199 between_high_and_low_res_range.start);
195 200
196 low_res_range = set_with_only_high_and_low_res->GetTilingRange( 201 low_res_range = set_with_only_high_and_low_res->GetTilingRange(
197 PictureLayerTilingSet::LOW_RES); 202 PictureLayerTilingSet::LOW_RES);
198 EXPECT_EQ(1u, low_res_range.start); 203 EXPECT_EQ(1u, low_res_range.start);
199 EXPECT_EQ(2u, low_res_range.end); 204 EXPECT_EQ(2u, low_res_range.end);
200 205
201 lower_than_low_res_range = set_with_only_high_and_low_res->GetTilingRange( 206 lower_than_low_res_range = set_with_only_high_and_low_res->GetTilingRange(
202 PictureLayerTilingSet::LOWER_THAN_LOW_RES); 207 PictureLayerTilingSet::LOWER_THAN_LOW_RES);
203 EXPECT_EQ(0u, lower_than_low_res_range.end - lower_than_low_res_range.start); 208 EXPECT_EQ(0u, lower_than_low_res_range.end - lower_than_low_res_range.start);
204 209
205 std::unique_ptr<TestablePictureLayerTilingSet> set_with_only_high_res = 210 std::unique_ptr<TestablePictureLayerTilingSet> set_with_only_high_res =
206 CreateTilingSet(&client); 211 CreateTilingSet(&client);
207 high_res_tiling = set_with_only_high_res->AddTiling(1.0, raster_source); 212 high_res_tiling =
213 set_with_only_high_res->AddTiling(gfx::AxisTransform2d(), raster_source);
208 high_res_tiling->set_resolution(HIGH_RESOLUTION); 214 high_res_tiling->set_resolution(HIGH_RESOLUTION);
209 215
210 higher_than_high_res_range = set_with_only_high_res->GetTilingRange( 216 higher_than_high_res_range = set_with_only_high_res->GetTilingRange(
211 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES); 217 PictureLayerTilingSet::HIGHER_THAN_HIGH_RES);
212 EXPECT_EQ(0u, 218 EXPECT_EQ(0u,
213 higher_than_high_res_range.end - higher_than_high_res_range.start); 219 higher_than_high_res_range.end - higher_than_high_res_range.start);
214 220
215 high_res_range = 221 high_res_range =
216 set_with_only_high_res->GetTilingRange(PictureLayerTilingSet::HIGH_RES); 222 set_with_only_high_res->GetTilingRange(PictureLayerTilingSet::HIGH_RES);
217 EXPECT_EQ(0u, high_res_range.start); 223 EXPECT_EQ(0u, high_res_range.start);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 FakePictureLayerTilingClient client(resource_provider.get()); 255 FakePictureLayerTilingClient client(resource_provider.get());
250 client.SetTileSize(gfx::Size(256, 256)); 256 client.SetTileSize(gfx::Size(256, 256));
251 gfx::Size layer_bounds(1000, 800); 257 gfx::Size layer_bounds(1000, 800);
252 std::unique_ptr<TestablePictureLayerTilingSet> set = 258 std::unique_ptr<TestablePictureLayerTilingSet> set =
253 CreateTilingSet(&client); 259 CreateTilingSet(&client);
254 scoped_refptr<FakeRasterSource> raster_source = 260 scoped_refptr<FakeRasterSource> raster_source =
255 FakeRasterSource::CreateFilled(layer_bounds); 261 FakeRasterSource::CreateFilled(layer_bounds);
256 262
257 float scale = min_scale; 263 float scale = min_scale;
258 for (int i = 0; i < num_tilings; ++i, scale += scale_increment) { 264 for (int i = 0; i < num_tilings; ++i, scale += scale_increment) {
259 PictureLayerTiling* tiling = set->AddTiling(scale, raster_source); 265 PictureLayerTiling* tiling = set->AddTiling(
266 gfx::AxisTransform2d(scale, gfx::Vector2dF()), raster_source);
260 tiling->set_resolution(HIGH_RESOLUTION); 267 tiling->set_resolution(HIGH_RESOLUTION);
261 tiling->CreateAllTilesForTesting(); 268 tiling->CreateAllTilesForTesting();
262 std::vector<Tile*> tiles = tiling->AllTilesForTesting(); 269 std::vector<Tile*> tiles = tiling->AllTilesForTesting();
263 client.tile_manager()->InitializeTilesWithResourcesForTesting(tiles); 270 client.tile_manager()->InitializeTilesWithResourcesForTesting(tiles);
264 } 271 }
265 272
266 float max_contents_scale = scale; 273 float max_contents_scale = scale;
267 gfx::Size content_bounds( 274 gfx::Size content_bounds(
268 gfx::ScaleToCeiledSize(layer_bounds, max_contents_scale)); 275 gfx::ScaleToCeiledSize(layer_bounds, max_contents_scale));
269 gfx::Rect content_rect(content_bounds); 276 gfx::Rect content_rect(content_bounds);
270 277
271 Region remaining(content_rect); 278 Region remaining(content_rect);
272 PictureLayerTilingSet::CoverageIterator iter( 279 PictureLayerTilingSet::CoverageIterator iter(
273 set.get(), max_contents_scale, content_rect, ideal_contents_scale); 280 set.get(), max_contents_scale, content_rect, ideal_contents_scale);
274 for (; iter; ++iter) { 281 for (; iter; ++iter) {
275 gfx::Rect geometry_rect = iter.geometry_rect(); 282 gfx::Rect geometry_rect = iter.geometry_rect();
276 EXPECT_TRUE(content_rect.Contains(geometry_rect)); 283 EXPECT_TRUE(content_rect.Contains(geometry_rect));
277 ASSERT_TRUE(remaining.Contains(geometry_rect)); 284 ASSERT_TRUE(remaining.Contains(geometry_rect));
278 remaining.Subtract(geometry_rect); 285 remaining.Subtract(geometry_rect);
279 286
280 float scale = iter.CurrentTiling()->contents_scale(); 287 float scale = iter.CurrentTiling()->contents_scale_key();
281 EXPECT_EQ(expected_scale, scale); 288 EXPECT_EQ(expected_scale, scale);
282 289
283 if (num_tilings) 290 if (num_tilings)
284 EXPECT_TRUE(*iter); 291 EXPECT_TRUE(*iter);
285 else 292 else
286 EXPECT_FALSE(*iter); 293 EXPECT_FALSE(*iter);
287 } 294 }
288 EXPECT_TRUE(remaining.IsEmpty()); 295 EXPECT_TRUE(remaining.IsEmpty());
289 } 296 }
290 }; 297 };
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 341
335 gfx::Size layer_bounds(100, 100); 342 gfx::Size layer_bounds(100, 100);
336 scoped_refptr<FakeRasterSource> raster_source = 343 scoped_refptr<FakeRasterSource> raster_source =
337 FakeRasterSource::CreateFilled(layer_bounds); 344 FakeRasterSource::CreateFilled(layer_bounds);
338 345
339 gfx::Size tile_size1(10, 10); 346 gfx::Size tile_size1(10, 10);
340 gfx::Size tile_size2(30, 30); 347 gfx::Size tile_size2(30, 30);
341 gfx::Size tile_size3(20, 20); 348 gfx::Size tile_size3(20, 20);
342 349
343 pending_client.SetTileSize(tile_size1); 350 pending_client.SetTileSize(tile_size1);
344 pending_set->AddTiling(1.f, raster_source); 351 pending_set->AddTiling(gfx::AxisTransform2d(), raster_source);
345 // New tilings get the correct tile size. 352 // New tilings get the correct tile size.
346 EXPECT_EQ(tile_size1, pending_set->tiling_at(0)->tile_size()); 353 EXPECT_EQ(tile_size1, pending_set->tiling_at(0)->tile_size());
347 354
348 // Set some expected things for the tiling set to function. 355 // Set some expected things for the tiling set to function.
349 pending_set->tiling_at(0)->set_resolution(HIGH_RESOLUTION); 356 pending_set->tiling_at(0)->set_resolution(HIGH_RESOLUTION);
350 active_client.set_twin_tiling_set(pending_set.get()); 357 active_client.set_twin_tiling_set(pending_set.get());
351 358
352 // Set a priority rect so we get tiles. 359 // Set a priority rect so we get tiles.
353 pending_set->UpdateTilePriorities(gfx::Rect(layer_bounds), 1.f, 1.0, 360 pending_set->UpdateTilePriorities(gfx::Rect(layer_bounds), 1.f, 1.0,
354 Occlusion(), false); 361 Occlusion(), false);
355 EXPECT_EQ(tile_size1, pending_set->tiling_at(0)->tile_size()); 362 EXPECT_EQ(tile_size1, pending_set->tiling_at(0)->tile_size());
356 363
357 // The tiles should get the correct size. 364 // The tiles should get the correct size.
358 std::vector<Tile*> pending_tiles = 365 std::vector<Tile*> pending_tiles =
359 pending_set->tiling_at(0)->AllTilesForTesting(); 366 pending_set->tiling_at(0)->AllTilesForTesting();
360 EXPECT_GT(pending_tiles.size(), 0u); 367 EXPECT_GT(pending_tiles.size(), 0u);
361 for (auto* tile : pending_tiles) 368 for (auto* tile : pending_tiles)
362 EXPECT_EQ(tile_size1, tile->content_rect().size()); 369 EXPECT_EQ(tile_size1, tile->content_rect().size());
363 370
364 // Update to a new source frame with a new tile size. 371 // Update to a new source frame with a new tile size.
365 // Note that setting a new raster source can typically only happen after 372 // Note that setting a new raster source can typically only happen after
366 // activation, since we can't set the raster source twice on the pending tree 373 // activation, since we can't set the raster source twice on the pending tree
367 // without activating. For test, just remove and add a new tiling instead. 374 // without activating. For test, just remove and add a new tiling instead.
368 pending_set->RemoveAllTilings(); 375 pending_set->RemoveAllTilings();
369 pending_set->AddTiling(1.f, raster_source); 376 pending_set->AddTiling(gfx::AxisTransform2d(), raster_source);
370 pending_set->tiling_at(0)->set_resolution(HIGH_RESOLUTION); 377 pending_set->tiling_at(0)->set_resolution(HIGH_RESOLUTION);
371 pending_client.SetTileSize(tile_size2); 378 pending_client.SetTileSize(tile_size2);
372 pending_set->UpdateTilingsToCurrentRasterSourceForCommit(raster_source.get(), 379 pending_set->UpdateTilingsToCurrentRasterSourceForCommit(raster_source.get(),
373 Region(), 1.f, 1.f); 380 Region(), 1.f, 1.f);
374 // The tiling should get the correct tile size. 381 // The tiling should get the correct tile size.
375 EXPECT_EQ(tile_size2, pending_set->tiling_at(0)->tile_size()); 382 EXPECT_EQ(tile_size2, pending_set->tiling_at(0)->tile_size());
376 383
377 // Set a priority rect so we get tiles. 384 // Set a priority rect so we get tiles.
378 pending_set->UpdateTilePriorities(gfx::Rect(layer_bounds), 1.f, 2.0, 385 pending_set->UpdateTilePriorities(gfx::Rect(layer_bounds), 1.f, 2.0,
379 Occlusion(), false); 386 Occlusion(), false);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 1000, 1000.f); 446 1000, 1000.f);
440 std::unique_ptr<PictureLayerTilingSet> active_set = 447 std::unique_ptr<PictureLayerTilingSet> active_set =
441 PictureLayerTilingSet::Create(ACTIVE_TREE, &active_client, 1000, 1.f, 448 PictureLayerTilingSet::Create(ACTIVE_TREE, &active_client, 1000, 1.f,
442 1000, 1000.f); 449 1000, 1000.f);
443 450
444 gfx::Size layer_bounds(100, 105); 451 gfx::Size layer_bounds(100, 105);
445 scoped_refptr<FakeRasterSource> raster_source = 452 scoped_refptr<FakeRasterSource> raster_source =
446 FakeRasterSource::CreateEmpty(layer_bounds); 453 FakeRasterSource::CreateEmpty(layer_bounds);
447 454
448 // Tilings can be added of any scale, the tiling client can controls this. 455 // Tilings can be added of any scale, the tiling client can controls this.
449 pending_set->AddTiling(1.f, raster_source); 456 pending_set->AddTiling(gfx::AxisTransform2d(), raster_source);
450 pending_set->AddTiling(2.f, raster_source); 457 pending_set->AddTiling(gfx::AxisTransform2d(2.f, gfx::Vector2dF()),
451 pending_set->AddTiling(3.f, raster_source); 458 raster_source);
459 pending_set->AddTiling(gfx::AxisTransform2d(3.f, gfx::Vector2dF()),
460 raster_source);
452 461
453 // Set some expected things for the tiling set to function. 462 // Set some expected things for the tiling set to function.
454 pending_set->tiling_at(0)->set_resolution(HIGH_RESOLUTION); 463 pending_set->tiling_at(0)->set_resolution(HIGH_RESOLUTION);
455 active_client.set_twin_tiling_set(pending_set.get()); 464 active_client.set_twin_tiling_set(pending_set.get());
456 465
457 // Update to a new source frame with a max content scale that is larger than 466 // Update to a new source frame with a max content scale that is larger than
458 // everything. 467 // everything.
459 float max_content_scale = 3.f; 468 float max_content_scale = 3.f;
460 pending_set->UpdateTilingsToCurrentRasterSourceForCommit( 469 pending_set->UpdateTilingsToCurrentRasterSourceForCommit(
461 raster_source.get(), Region(), 1.f, max_content_scale); 470 raster_source.get(), Region(), 1.f, max_content_scale);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 LayerTreeSettings settings; 505 LayerTreeSettings settings;
497 settings.skewport_extrapolation_limit_in_screen_pixels = 75; 506 settings.skewport_extrapolation_limit_in_screen_pixels = 75;
498 settings.tiling_interest_area_padding = 1000000; 507 settings.tiling_interest_area_padding = 1000000;
499 508
500 scoped_refptr<FakeRasterSource> raster_source = 509 scoped_refptr<FakeRasterSource> raster_source =
501 FakeRasterSource::CreateFilled(layer_bounds); 510 FakeRasterSource::CreateFilled(layer_bounds);
502 std::unique_ptr<TestablePictureLayerTilingSet> tiling_set = 511 std::unique_ptr<TestablePictureLayerTilingSet> tiling_set =
503 CreateTilingSetWithSettings(&client, settings); 512 CreateTilingSetWithSettings(&client, settings);
504 513
505 EXPECT_FALSE(tiling_set->TilingsNeedUpdate(viewport, 1.0)); 514 EXPECT_FALSE(tiling_set->TilingsNeedUpdate(viewport, 1.0));
506 tiling_set->AddTiling(1.f, raster_source); 515 tiling_set->AddTiling(gfx::AxisTransform2d(), raster_source);
507 EXPECT_TRUE(tiling_set->TilingsNeedUpdate(viewport, 1.0)); 516 EXPECT_TRUE(tiling_set->TilingsNeedUpdate(viewport, 1.0));
508 517
509 tiling_set->UpdateTilePriorities(viewport, 1.f, 1.0, Occlusion(), true); 518 tiling_set->UpdateTilePriorities(viewport, 1.f, 1.0, Occlusion(), true);
510 519
511 // Move viewport down 50 pixels in 0.5 seconds. 520 // Move viewport down 50 pixels in 0.5 seconds.
512 gfx::Rect down_skewport = 521 gfx::Rect down_skewport =
513 tiling_set->ComputeSkewport(gfx::Rect(0, 50, 100, 100), 1.5, 1.f); 522 tiling_set->ComputeSkewport(gfx::Rect(0, 50, 100, 100), 1.5, 1.f);
514 523
515 EXPECT_EQ(0, down_skewport.x()); 524 EXPECT_EQ(0, down_skewport.x());
516 EXPECT_EQ(50, down_skewport.y()); 525 EXPECT_EQ(50, down_skewport.y());
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 FakePictureLayerTilingClient client; 591 FakePictureLayerTilingClient client;
583 592
584 gfx::Size layer_bounds(200, 200); 593 gfx::Size layer_bounds(200, 200);
585 client.SetTileSize(gfx::Size(100, 100)); 594 client.SetTileSize(gfx::Size(100, 100));
586 LayerTreeSettings settings; 595 LayerTreeSettings settings;
587 settings.tiling_interest_area_padding = 1000000000; 596 settings.tiling_interest_area_padding = 1000000000;
588 scoped_refptr<FakeRasterSource> raster_source = 597 scoped_refptr<FakeRasterSource> raster_source =
589 FakeRasterSource::CreateFilled(layer_bounds); 598 FakeRasterSource::CreateFilled(layer_bounds);
590 std::unique_ptr<TestablePictureLayerTilingSet> tiling_set = 599 std::unique_ptr<TestablePictureLayerTilingSet> tiling_set =
591 CreateTilingSetWithSettings(&client, settings); 600 CreateTilingSetWithSettings(&client, settings);
592 tiling_set->AddTiling(1.f, raster_source); 601 tiling_set->AddTiling(gfx::AxisTransform2d(), raster_source);
593 602
594 gfx::Rect viewport1(-1918, 255860, 4010, 2356); 603 gfx::Rect viewport1(-1918, 255860, 4010, 2356);
595 gfx::Rect viewport2(-7088, -91738, 14212, 8350); 604 gfx::Rect viewport2(-7088, -91738, 14212, 8350);
596 gfx::Rect viewport3(-12730024, -158883296, 24607540, 14454512); 605 gfx::Rect viewport3(-12730024, -158883296, 24607540, 14454512);
597 double time = 1.0; 606 double time = 1.0;
598 tiling_set->UpdateTilePriorities(viewport1, 1.f, time, Occlusion(), true); 607 tiling_set->UpdateTilePriorities(viewport1, 1.f, time, Occlusion(), true);
599 time += 0.016; 608 time += 0.016;
600 EXPECT_TRUE( 609 EXPECT_TRUE(
601 tiling_set->ComputeSkewport(viewport2, time, 1.f).Contains(viewport2)); 610 tiling_set->ComputeSkewport(viewport2, time, 1.f).Contains(viewport2));
602 tiling_set->UpdateTilePriorities(viewport2, 1.f, time, Occlusion(), true); 611 tiling_set->UpdateTilePriorities(viewport2, 1.f, time, Occlusion(), true);
603 time += 0.016; 612 time += 0.016;
604 EXPECT_TRUE( 613 EXPECT_TRUE(
605 tiling_set->ComputeSkewport(viewport3, time, 1.f).Contains(viewport3)); 614 tiling_set->ComputeSkewport(viewport3, time, 1.f).Contains(viewport3));
606 615
607 // Use a tiling with a large scale, so the viewport times the scale no longer 616 // Use a tiling with a large scale, so the viewport times the scale no longer
608 // fits into integers, and the viewport is not anywhere close to the tiling. 617 // fits into integers, and the viewport is not anywhere close to the tiling.
609 PictureLayerTiling* tiling = tiling_set->AddTiling(1000.f, raster_source); 618 PictureLayerTiling* tiling = tiling_set->AddTiling(
619 gfx::AxisTransform2d(1000.f, gfx::Vector2dF()), raster_source);
610 EXPECT_TRUE(tiling_set->TilingsNeedUpdate(viewport3, time)); 620 EXPECT_TRUE(tiling_set->TilingsNeedUpdate(viewport3, time));
611 tiling_set->UpdateTilePriorities(viewport3, 1.f, time, Occlusion(), true); 621 tiling_set->UpdateTilePriorities(viewport3, 1.f, time, Occlusion(), true);
612 EXPECT_TRUE(tiling->GetCurrentVisibleRectForTesting().IsEmpty()); 622 EXPECT_TRUE(tiling->GetCurrentVisibleRectForTesting().IsEmpty());
613 } 623 }
614 624
615 TEST(PictureLayerTilingSetTest, ComputeSkewport) { 625 TEST(PictureLayerTilingSetTest, ComputeSkewport) {
616 FakePictureLayerTilingClient client; 626 FakePictureLayerTilingClient client;
617 627
618 gfx::Rect viewport(0, 0, 100, 100); 628 gfx::Rect viewport(0, 0, 100, 100);
619 gfx::Size layer_bounds(200, 200); 629 gfx::Size layer_bounds(200, 200);
620 630
621 client.SetTileSize(gfx::Size(100, 100)); 631 client.SetTileSize(gfx::Size(100, 100));
622 632
623 scoped_refptr<FakeRasterSource> raster_source = 633 scoped_refptr<FakeRasterSource> raster_source =
624 FakeRasterSource::CreateFilled(layer_bounds); 634 FakeRasterSource::CreateFilled(layer_bounds);
625 std::unique_ptr<TestablePictureLayerTilingSet> tiling_set = 635 std::unique_ptr<TestablePictureLayerTilingSet> tiling_set =
626 CreateTilingSet(&client); 636 CreateTilingSet(&client);
627 tiling_set->AddTiling(1.f, raster_source); 637 tiling_set->AddTiling(gfx::AxisTransform2d(), raster_source);
628 638
629 tiling_set->UpdateTilePriorities(viewport, 1.f, 1.0, Occlusion(), true); 639 tiling_set->UpdateTilePriorities(viewport, 1.f, 1.0, Occlusion(), true);
630 640
631 // Move viewport down 50 pixels in 0.5 seconds. 641 // Move viewport down 50 pixels in 0.5 seconds.
632 gfx::Rect down_skewport = 642 gfx::Rect down_skewport =
633 tiling_set->ComputeSkewport(gfx::Rect(0, 50, 100, 100), 1.5, 1.f); 643 tiling_set->ComputeSkewport(gfx::Rect(0, 50, 100, 100), 1.5, 1.f);
634 644
635 EXPECT_EQ(0, down_skewport.x()); 645 EXPECT_EQ(0, down_skewport.x());
636 EXPECT_EQ(50, down_skewport.y()); 646 EXPECT_EQ(50, down_skewport.y());
637 EXPECT_EQ(100, down_skewport.width()); 647 EXPECT_EQ(100, down_skewport.width());
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 689
680 gfx::Rect viewport(0, 0, 100, 100); 690 gfx::Rect viewport(0, 0, 100, 100);
681 gfx::Size layer_bounds(200, 200); 691 gfx::Size layer_bounds(200, 200);
682 692
683 client.SetTileSize(gfx::Size(100, 100)); 693 client.SetTileSize(gfx::Size(100, 100));
684 694
685 scoped_refptr<FakeRasterSource> raster_source = 695 scoped_refptr<FakeRasterSource> raster_source =
686 FakeRasterSource::CreateFilled(layer_bounds); 696 FakeRasterSource::CreateFilled(layer_bounds);
687 std::unique_ptr<TestablePictureLayerTilingSet> tiling_set = 697 std::unique_ptr<TestablePictureLayerTilingSet> tiling_set =
688 CreateTilingSet(&client); 698 CreateTilingSet(&client);
689 tiling_set->AddTiling(1.f, raster_source); 699 tiling_set->AddTiling(gfx::AxisTransform2d(), raster_source);
690 700
691 tiling_set->UpdateTilePriorities(viewport, 1.f, 1.0, Occlusion(), true); 701 tiling_set->UpdateTilePriorities(viewport, 1.f, 1.0, Occlusion(), true);
692 702
693 // Move viewport down 50 pixels in 0.5 seconds. 703 // Move viewport down 50 pixels in 0.5 seconds.
694 gfx::Rect viewport_50 = gfx::Rect(0, 50, 100, 100); 704 gfx::Rect viewport_50 = gfx::Rect(0, 50, 100, 100);
695 gfx::Rect skewport_50 = tiling_set->ComputeSkewport(viewport_50, 1.5, 1.f); 705 gfx::Rect skewport_50 = tiling_set->ComputeSkewport(viewport_50, 1.5, 1.f);
696 706
697 EXPECT_EQ(gfx::Rect(0, 50, 100, 200), skewport_50); 707 EXPECT_EQ(gfx::Rect(0, 50, 100, 200), skewport_50);
698 tiling_set->UpdateTilePriorities(viewport_50, 1.f, 1.5, Occlusion(), true); 708 tiling_set->UpdateTilePriorities(viewport_50, 1.f, 1.5, Occlusion(), true);
699 709
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 763
754 // Tiling at 0.25 scale: this should create 47x47 tiles of size 10x10. 764 // Tiling at 0.25 scale: this should create 47x47 tiles of size 10x10.
755 // The reason is that each tile has a one pixel border, so tile at (1, 2) 765 // The reason is that each tile has a one pixel border, so tile at (1, 2)
756 // for instance begins at (8, 16) pixels. So tile at (46, 46) will begin at 766 // for instance begins at (8, 16) pixels. So tile at (46, 46) will begin at
757 // (368, 368) and extend to the end of 1500 * 0.25 = 375 edge of the 767 // (368, 368) and extend to the end of 1500 * 0.25 = 375 edge of the
758 // tiling. 768 // tiling.
759 scoped_refptr<FakeRasterSource> raster_source = 769 scoped_refptr<FakeRasterSource> raster_source =
760 FakeRasterSource::CreateFilled(layer_bounds); 770 FakeRasterSource::CreateFilled(layer_bounds);
761 std::unique_ptr<TestablePictureLayerTilingSet> tiling_set = 771 std::unique_ptr<TestablePictureLayerTilingSet> tiling_set =
762 CreateTilingSet(&client); 772 CreateTilingSet(&client);
763 auto* tiling = tiling_set->AddTiling(0.25f, raster_source); 773 auto* tiling = tiling_set->AddTiling(
774 gfx::AxisTransform2d(0.25f, gfx::Vector2dF()), raster_source);
764 tiling->set_resolution(HIGH_RESOLUTION); 775 tiling->set_resolution(HIGH_RESOLUTION);
765 gfx::Rect viewport_in_content_space = 776 gfx::Rect viewport_in_content_space =
766 gfx::ScaleToEnclosedRect(viewport, 0.25f); 777 gfx::ScaleToEnclosedRect(viewport, 0.25f);
767 778
768 tiling_set->UpdateTilePriorities(viewport, 1.f, 1.0, Occlusion(), true); 779 tiling_set->UpdateTilePriorities(viewport, 1.f, 1.0, Occlusion(), true);
769 auto prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); 780 auto prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting();
770 781
771 // Compute the soon border. 782 // Compute the soon border.
772 gfx::Rect soon_border_rect_in_content_space = 783 gfx::Rect soon_border_rect_in_content_space =
773 tiling_set->ComputeSoonBorderRect(viewport, 1.f); 784 tiling_set->ComputeSoonBorderRect(viewport, 1.f);
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 priority = prioritized_tiles[tiling->TileAt(5, 1)].priority(); 925 priority = prioritized_tiles[tiling->TileAt(5, 1)].priority();
915 EXPECT_FLOAT_EQ(136.f, priority.distance_to_visible); 926 EXPECT_FLOAT_EQ(136.f, priority.distance_to_visible);
916 927
917 priority = prioritized_tiles[tiling->TileAt(2, 5)].priority(); 928 priority = prioritized_tiles[tiling->TileAt(2, 5)].priority();
918 EXPECT_FLOAT_EQ(56.f, priority.distance_to_visible); 929 EXPECT_FLOAT_EQ(56.f, priority.distance_to_visible);
919 930
920 priority = prioritized_tiles[tiling->TileAt(3, 4)].priority(); 931 priority = prioritized_tiles[tiling->TileAt(3, 4)].priority();
921 EXPECT_FLOAT_EQ(8.f, priority.distance_to_visible); 932 EXPECT_FLOAT_EQ(8.f, priority.distance_to_visible);
922 933
923 // Test additional scales. 934 // Test additional scales.
924 tiling = tiling_set->AddTiling(0.2f, raster_source); 935 tiling = tiling_set->AddTiling(gfx::AxisTransform2d(0.2f, gfx::Vector2dF()),
936 raster_source);
925 tiling->set_resolution(HIGH_RESOLUTION); 937 tiling->set_resolution(HIGH_RESOLUTION);
926 tiling_set->UpdateTilePriorities(viewport, 1.0f, 4.0, Occlusion(), true); 938 tiling_set->UpdateTilePriorities(viewport, 1.0f, 4.0, Occlusion(), true);
927 prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting(); 939 prioritized_tiles = tiling->UpdateAndGetAllPrioritizedTilesForTesting();
928 940
929 priority = prioritized_tiles[tiling->TileAt(5, 1)].priority(); 941 priority = prioritized_tiles[tiling->TileAt(5, 1)].priority();
930 EXPECT_FLOAT_EQ(110.f, priority.distance_to_visible); 942 EXPECT_FLOAT_EQ(110.f, priority.distance_to_visible);
931 943
932 priority = prioritized_tiles[tiling->TileAt(2, 5)].priority(); 944 priority = prioritized_tiles[tiling->TileAt(2, 5)].priority();
933 EXPECT_FLOAT_EQ(70.f, priority.distance_to_visible); 945 EXPECT_FLOAT_EQ(70.f, priority.distance_to_visible);
934 946
(...skipping 14 matching lines...) Expand all
949 } 961 }
950 962
951 TEST(PictureLayerTilingTest, InvalidateAfterComputeTilePriorityRects) { 963 TEST(PictureLayerTilingTest, InvalidateAfterComputeTilePriorityRects) {
952 FakePictureLayerTilingClient pending_client; 964 FakePictureLayerTilingClient pending_client;
953 pending_client.SetTileSize(gfx::Size(100, 100)); 965 pending_client.SetTileSize(gfx::Size(100, 100));
954 966
955 scoped_refptr<FakeRasterSource> raster_source = 967 scoped_refptr<FakeRasterSource> raster_source =
956 FakeRasterSource::CreateFilled(gfx::Size(100, 100)); 968 FakeRasterSource::CreateFilled(gfx::Size(100, 100));
957 std::unique_ptr<TestablePictureLayerTilingSet> tiling_set = 969 std::unique_ptr<TestablePictureLayerTilingSet> tiling_set =
958 CreateTilingSet(&pending_client); 970 CreateTilingSet(&pending_client);
959 auto* pending_tiling = tiling_set->AddTiling(1.f, raster_source); 971 auto* pending_tiling =
972 tiling_set->AddTiling(gfx::AxisTransform2d(), raster_source);
960 pending_tiling->set_resolution(HIGH_RESOLUTION); 973 pending_tiling->set_resolution(HIGH_RESOLUTION);
961 974
962 // Ensure that we can compute tile priority rects, invalidate, and compute the 975 // Ensure that we can compute tile priority rects, invalidate, and compute the
963 // rects again. It is important that the second compute tile priority rects 976 // rects again. It is important that the second compute tile priority rects
964 // return true, indicating that things have changed (since invalidation has 977 // return true, indicating that things have changed (since invalidation has
965 // changed things). This causes PrepareTiles to be properly scheduled. If the 978 // changed things). This causes PrepareTiles to be properly scheduled. If the
966 // second ComputeTilePriorityRects returns false, then we assume that 979 // second ComputeTilePriorityRects returns false, then we assume that
967 // PrepareTiles isn't needed and we signal that we're ready to draw 980 // PrepareTiles isn't needed and we signal that we're ready to draw
968 // immediately, which can cause visual glitches. 981 // immediately, which can cause visual glitches.
969 // 982 //
(...skipping 22 matching lines...) Expand all
992 PictureLayerTilingSet::Create(PENDING_TREE, &pending_client, 1000, 1.f, 1005 PictureLayerTilingSet::Create(PENDING_TREE, &pending_client, 1000, 1.f,
993 1000, 1000.f); 1006 1000, 1000.f);
994 std::unique_ptr<PictureLayerTilingSet> active_set = 1007 std::unique_ptr<PictureLayerTilingSet> active_set =
995 PictureLayerTilingSet::Create(ACTIVE_TREE, &active_client, 1000, 1.f, 1008 PictureLayerTilingSet::Create(ACTIVE_TREE, &active_client, 1000, 1.f,
996 1000, 1000.f); 1009 1000, 1000.f);
997 1010
998 gfx::Size layer_bounds(100, 100); 1011 gfx::Size layer_bounds(100, 100);
999 scoped_refptr<FakeRasterSource> raster_source = 1012 scoped_refptr<FakeRasterSource> raster_source =
1000 FakeRasterSource::CreateFilled(layer_bounds); 1013 FakeRasterSource::CreateFilled(layer_bounds);
1001 1014
1002 auto* pending_tiling = pending_set->AddTiling(1.f, raster_source); 1015 auto* pending_tiling =
1016 pending_set->AddTiling(gfx::AxisTransform2d(), raster_source);
1003 pending_tiling->set_resolution(HIGH_RESOLUTION); 1017 pending_tiling->set_resolution(HIGH_RESOLUTION);
1004 active_client.set_twin_tiling_set(pending_set.get()); 1018 active_client.set_twin_tiling_set(pending_set.get());
1005 1019
1006 double time = 1.; 1020 double time = 1.;
1007 gfx::Rect viewport(0, 0, 100, 100); 1021 gfx::Rect viewport(0, 0, 100, 100);
1008 1022
1009 // The first commit will update the raster source for pending tilings. 1023 // The first commit will update the raster source for pending tilings.
1010 pending_set->UpdateTilingsToCurrentRasterSourceForCommit(raster_source, 1024 pending_set->UpdateTilingsToCurrentRasterSourceForCommit(raster_source,
1011 Region(), 1.f, 1.f); 1025 Region(), 1.f, 1.f);
1012 // UpdateTilePriorities for pending set gets called during UDP in commit. 1026 // UpdateTilePriorities for pending set gets called during UDP in commit.
(...skipping 18 matching lines...) Expand all
1031 pending_set->UpdateTilingsToCurrentRasterSourceForCommit(raster_source, 1045 pending_set->UpdateTilingsToCurrentRasterSourceForCommit(raster_source,
1032 Region(), 1.f, 1.f); 1046 Region(), 1.f, 1.f);
1033 // UpdateTilePriorities for pending set gets called during UDP in commit. 1047 // UpdateTilePriorities for pending set gets called during UDP in commit.
1034 EXPECT_TRUE(pending_set->UpdateTilePriorities(viewport, 1.f, time, 1048 EXPECT_TRUE(pending_set->UpdateTilePriorities(viewport, 1.f, time,
1035 Occlusion(), true)); 1049 Occlusion(), true));
1036 // No changes for active set until activation. 1050 // No changes for active set until activation.
1037 EXPECT_FALSE( 1051 EXPECT_FALSE(
1038 active_set->UpdateTilePriorities(viewport, 1.f, time, Occlusion(), true)); 1052 active_set->UpdateTilePriorities(viewport, 1.f, time, Occlusion(), true));
1039 } 1053 }
1040 1054
1055 TEST(PictureLayerTilingSetTest, TilingTranslationChanges) {
1056 gfx::Size tile_size(64, 64);
1057 FakePictureLayerTilingClient pending_client;
1058 FakePictureLayerTilingClient active_client;
1059 pending_client.SetTileSize(tile_size);
1060 active_client.SetTileSize(tile_size);
1061 std::unique_ptr<PictureLayerTilingSet> pending_set =
1062 PictureLayerTilingSet::Create(PENDING_TREE, &pending_client, 0, 1.f, 0,
1063 0.f);
1064 std::unique_ptr<PictureLayerTilingSet> active_set =
1065 PictureLayerTilingSet::Create(ACTIVE_TREE, &active_client, 0, 1.f, 0,
1066 0.f);
1067 active_client.set_twin_tiling_set(pending_set.get());
1068
1069 gfx::Size layer_bounds(100, 100);
1070 scoped_refptr<FakeRasterSource> raster_source =
1071 FakeRasterSource::CreateFilled(layer_bounds);
1072
1073 gfx::AxisTransform2d raster_transform1(1.f, gfx::Vector2dF(0.25f, 0.25f));
1074 pending_set->AddTiling(raster_transform1, raster_source);
1075 pending_set->tiling_at(0)->set_resolution(HIGH_RESOLUTION);
1076
1077 // Set a priority rect so we get tiles.
1078 pending_set->UpdateTilePriorities(gfx::Rect(layer_bounds), 1.f, 1.0,
1079 Occlusion(), false);
1080
1081 // Make sure all tiles are generated.
1082 EXPECT_EQ(4u, pending_set->tiling_at(0)->AllTilesForTesting().size());
1083
1084 // Clone from the pending to the active tree.
1085 active_set->UpdateTilingsToCurrentRasterSourceForActivation(
1086 raster_source.get(), pending_set.get(), Region(), 1.f, 1.f);
1087
1088 // Verifies active tree cloned the tiling correctly.
1089 ASSERT_EQ(1u, active_set->num_tilings());
1090 EXPECT_EQ(active_set->tiling_at(0)->raster_transform(), raster_transform1);
1091 EXPECT_EQ(4u, active_set->tiling_at(0)->AllTilesForTesting().size());
1092
1093 // Change raster translation on the pending set.
1094 gfx::AxisTransform2d raster_transform2(1.f, gfx::Vector2dF(0.75f, 0.75f));
1095 pending_set->RemoveAllTilings();
1096 pending_set->AddTiling(raster_transform2, raster_source);
1097 pending_set->tiling_at(0)->set_resolution(HIGH_RESOLUTION);
1098
1099 // Set a different priority rect to get one tile.
1100 pending_set->UpdateTilePriorities(gfx::Rect(1, 1), 1.f, 1.0, Occlusion(),
1101 false);
1102 EXPECT_EQ(1u, pending_set->tiling_at(0)->AllTilesForTesting().size());
1103
1104 // Commit the pending to the active tree again.
1105 active_set->UpdateTilingsToCurrentRasterSourceForActivation(
1106 raster_source.get(), pending_set.get(), Region(), 1.f, 1.f);
1107
1108 // Verifies the old tiling with a different translation is dropped.
1109 ASSERT_EQ(1u, active_set->num_tilings());
1110 EXPECT_EQ(active_set->tiling_at(0)->raster_transform(), raster_transform2);
1111 EXPECT_EQ(1u, active_set->tiling_at(0)->AllTilesForTesting().size());
1112 }
1113
1041 } // namespace 1114 } // namespace
1042 } // namespace cc 1115 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiles/picture_layer_tiling_set.cc ('k') | cc/tiles/picture_layer_tiling_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698