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

Side by Side Diff: cc/resources/picture_layer_tiling_unittest.cc

Issue 723343002: Update from https://crrev.com/304121 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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/resources/picture_layer_tiling_set.cc ('k') | cc/resources/picture_pile.h » ('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/resources/picture_layer_tiling.h" 5 #include "cc/resources/picture_layer_tiling.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <set> 8 #include <set>
9 9
10 #include "cc/base/math_util.h" 10 #include "cc/base/math_util.h"
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 SetLiveRectAndVerifyTiles(gfx::Rect(original_layer_size)); 204 SetLiveRectAndVerifyTiles(gfx::Rect(original_layer_size));
205 205
206 // Tiling only has one tile, since its total size is less than one. 206 // Tiling only has one tile, since its total size is less than one.
207 EXPECT_TRUE(tiling_->TileAt(0, 0)); 207 EXPECT_TRUE(tiling_->TileAt(0, 0));
208 208
209 // Stop creating tiles so that any invalidations are left as holes. 209 // Stop creating tiles so that any invalidations are left as holes.
210 client_.set_allow_create_tile(false); 210 client_.set_allow_create_tile(false);
211 211
212 Region invalidation = 212 Region invalidation =
213 SubtractRegions(gfx::Rect(tile_size), gfx::Rect(original_layer_size)); 213 SubtractRegions(gfx::Rect(tile_size), gfx::Rect(original_layer_size));
214 tiling_->UpdateTilesToCurrentPile(invalidation, gfx::Size(200, 200)); 214 tiling_->UpdateTilesToCurrentRasterSource(invalidation, gfx::Size(200, 200));
215 EXPECT_FALSE(tiling_->TileAt(0, 0)); 215 EXPECT_FALSE(tiling_->TileAt(0, 0));
216 } 216 }
217 217
218 TEST_F(PictureLayerTilingIteratorTest, CreateMissingTilesStaysInsideLiveRect) { 218 TEST_F(PictureLayerTilingIteratorTest, CreateMissingTilesStaysInsideLiveRect) {
219 // The tiling has three rows and columns. 219 // The tiling has three rows and columns.
220 Initialize(gfx::Size(100, 100), 1, gfx::Size(250, 250)); 220 Initialize(gfx::Size(100, 100), 1, gfx::Size(250, 250));
221 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_x()); 221 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_x());
222 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_y()); 222 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_y());
223 223
224 // The live tiles rect is at the very edge of the right-most and 224 // The live tiles rect is at the very edge of the right-most and
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 EXPECT_TRUE(tiling_->TileAt(2, 3)); 259 EXPECT_TRUE(tiling_->TileAt(2, 3));
260 EXPECT_TRUE(tiling_->TileAt(1, 3)); 260 EXPECT_TRUE(tiling_->TileAt(1, 3));
261 EXPECT_TRUE(tiling_->TileAt(0, 3)); 261 EXPECT_TRUE(tiling_->TileAt(0, 3));
262 262
263 int right = tiling_->TilingDataForTesting().TileBounds(2, 2).x(); 263 int right = tiling_->TilingDataForTesting().TileBounds(2, 2).x();
264 int bottom = tiling_->TilingDataForTesting().TileBounds(2, 3).y(); 264 int bottom = tiling_->TilingDataForTesting().TileBounds(2, 3).y();
265 265
266 // Shrink the tiling so that the last tile row/column is entirely in the 266 // Shrink the tiling so that the last tile row/column is entirely in the
267 // border pixels of the interior tiles. That row/column is removed. 267 // border pixels of the interior tiles. That row/column is removed.
268 Region invalidation; 268 Region invalidation;
269 tiling_->UpdateTilesToCurrentPile(invalidation, 269 tiling_->UpdateTilesToCurrentRasterSource(invalidation,
270 gfx::Size(right + 1, bottom + 1)); 270 gfx::Size(right + 1, bottom + 1));
271 EXPECT_EQ(2, tiling_->TilingDataForTesting().num_tiles_x()); 271 EXPECT_EQ(2, tiling_->TilingDataForTesting().num_tiles_x());
272 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_y()); 272 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_y());
273 273
274 // The live tiles rect was clamped to the pile size. 274 // The live tiles rect was clamped to the pile size.
275 EXPECT_EQ(gfx::Rect(right + 1, bottom + 1), tiling_->live_tiles_rect()); 275 EXPECT_EQ(gfx::Rect(right + 1, bottom + 1), tiling_->live_tiles_rect());
276 276
277 // Since the row/column is gone, the tiles should be gone too. 277 // Since the row/column is gone, the tiles should be gone too.
278 EXPECT_FALSE(tiling_->TileAt(2, 0)); 278 EXPECT_FALSE(tiling_->TileAt(2, 0));
279 EXPECT_FALSE(tiling_->TileAt(2, 1)); 279 EXPECT_FALSE(tiling_->TileAt(2, 1));
280 EXPECT_FALSE(tiling_->TileAt(2, 2)); 280 EXPECT_FALSE(tiling_->TileAt(2, 2));
281 EXPECT_FALSE(tiling_->TileAt(2, 3)); 281 EXPECT_FALSE(tiling_->TileAt(2, 3));
282 EXPECT_FALSE(tiling_->TileAt(1, 3)); 282 EXPECT_FALSE(tiling_->TileAt(1, 3));
283 EXPECT_FALSE(tiling_->TileAt(0, 3)); 283 EXPECT_FALSE(tiling_->TileAt(0, 3));
284 284
285 // Growing outside the current right/bottom tiles border pixels should create 285 // Growing outside the current right/bottom tiles border pixels should create
286 // the tiles again, even though the live rect has not changed size. 286 // the tiles again, even though the live rect has not changed size.
287 tiling_->UpdateTilesToCurrentPile(invalidation, 287 tiling_->UpdateTilesToCurrentRasterSource(invalidation,
288 gfx::Size(right + 2, bottom + 2)); 288 gfx::Size(right + 2, bottom + 2));
289 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_x()); 289 EXPECT_EQ(3, tiling_->TilingDataForTesting().num_tiles_x());
290 EXPECT_EQ(4, tiling_->TilingDataForTesting().num_tiles_y()); 290 EXPECT_EQ(4, tiling_->TilingDataForTesting().num_tiles_y());
291 291
292 // Not changed. 292 // Not changed.
293 EXPECT_EQ(gfx::Rect(right + 1, bottom + 1), tiling_->live_tiles_rect()); 293 EXPECT_EQ(gfx::Rect(right + 1, bottom + 1), tiling_->live_tiles_rect());
294 294
295 // The last row/column tiles are inside the live tiles rect. 295 // The last row/column tiles are inside the live tiles rect.
296 EXPECT_TRUE(gfx::Rect(right + 1, bottom + 1).Intersects( 296 EXPECT_TRUE(gfx::Rect(right + 1, bottom + 1).Intersects(
297 tiling_->TilingDataForTesting().TileBounds(2, 0))); 297 tiling_->TilingDataForTesting().TileBounds(2, 0)));
298 EXPECT_TRUE(gfx::Rect(right + 1, bottom + 1).Intersects( 298 EXPECT_TRUE(gfx::Rect(right + 1, bottom + 1).Intersects(
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 SetLiveRectAndVerifyTiles(gfx::Rect(original_layer_size)); 414 SetLiveRectAndVerifyTiles(gfx::Rect(original_layer_size));
415 415
416 // Tiling only has one tile, since its total size is less than one. 416 // Tiling only has one tile, since its total size is less than one.
417 EXPECT_TRUE(tiling_->TileAt(0, 0)); 417 EXPECT_TRUE(tiling_->TileAt(0, 0));
418 418
419 // Stop creating tiles so that any invalidations are left as holes. 419 // Stop creating tiles so that any invalidations are left as holes.
420 client_.set_allow_create_tile(false); 420 client_.set_allow_create_tile(false);
421 421
422 Region invalidation = 422 Region invalidation =
423 SubtractRegions(gfx::Rect(tile_size), gfx::Rect(original_layer_size)); 423 SubtractRegions(gfx::Rect(tile_size), gfx::Rect(original_layer_size));
424 tiling_->UpdateTilesToCurrentPile(invalidation, gfx::Size(200, 200)); 424 tiling_->UpdateTilesToCurrentRasterSource(invalidation, gfx::Size(200, 200));
425 EXPECT_FALSE(tiling_->TileAt(0, 0)); 425 EXPECT_FALSE(tiling_->TileAt(0, 0));
426 426
427 // The original tile was the same size after resize, but it would include new 427 // The original tile was the same size after resize, but it would include new
428 // border pixels. 428 // border pixels.
429 EXPECT_EQ(gfx::Rect(original_layer_size), 429 EXPECT_EQ(gfx::Rect(original_layer_size),
430 tiling_->TilingDataForTesting().TileBounds(0, 0)); 430 tiling_->TilingDataForTesting().TileBounds(0, 0));
431 } 431 }
432 432
433 TEST_F(PictureLayerTilingIteratorTest, LiveTilesExactlyCoverLiveTileRect) { 433 TEST_F(PictureLayerTilingIteratorTest, LiveTilesExactlyCoverLiveTileRect) {
434 Initialize(gfx::Size(100, 100), 1, gfx::Size(1099, 801)); 434 Initialize(gfx::Size(100, 100), 1, gfx::Size(1099, 801));
(...skipping 1736 matching lines...) Expand 10 before | Expand all | Expand 10 after
2171 EXPECT_TRUE(active_tiling->TileAt(0, 0)); 2171 EXPECT_TRUE(active_tiling->TileAt(0, 0));
2172 EXPECT_TRUE(recycle_tiling->TileAt(0, 0)); 2172 EXPECT_TRUE(recycle_tiling->TileAt(0, 0));
2173 EXPECT_EQ(active_tiling->TileAt(0, 0), recycle_tiling->TileAt(0, 0)); 2173 EXPECT_EQ(active_tiling->TileAt(0, 0), recycle_tiling->TileAt(0, 0));
2174 2174
2175 // Reset the active tiling. The recycle tiles should be released too. 2175 // Reset the active tiling. The recycle tiles should be released too.
2176 active_tiling->Reset(); 2176 active_tiling->Reset();
2177 EXPECT_FALSE(active_tiling->TileAt(0, 0)); 2177 EXPECT_FALSE(active_tiling->TileAt(0, 0));
2178 EXPECT_FALSE(recycle_tiling->TileAt(0, 0)); 2178 EXPECT_FALSE(recycle_tiling->TileAt(0, 0));
2179 } 2179 }
2180 2180
2181 TEST_F(PictureLayerTilingIteratorTest, ResizeTilesAndUpdateToCurrent) {
2182 // The tiling has four rows and three columns.
2183 Initialize(gfx::Size(150, 100), 1, gfx::Size(250, 150));
2184 tiling_->CreateAllTilesForTesting();
2185 EXPECT_EQ(150, tiling_->TilingDataForTesting().max_texture_size().width());
2186 EXPECT_EQ(100, tiling_->TilingDataForTesting().max_texture_size().height());
2187 EXPECT_EQ(4u, tiling_->AllRefTilesForTesting().size());
2188
2189 client_.SetTileSize(gfx::Size(250, 200));
2190 client_.set_tree(PENDING_TREE);
2191
2192 // Tile size in the tiling should still be 150x100.
2193 EXPECT_EQ(150, tiling_->TilingDataForTesting().max_texture_size().width());
2194 EXPECT_EQ(100, tiling_->TilingDataForTesting().max_texture_size().height());
2195
2196 Region invalidation;
2197 tiling_->UpdateTilesToCurrentRasterSource(invalidation, gfx::Size(250, 150));
2198
2199 // Tile size in the tiling should be resized to 250x200.
2200 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width());
2201 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height());
2202 EXPECT_EQ(0u, tiling_->AllRefTilesForTesting().size());
2203 }
2204
2181 } // namespace 2205 } // namespace
2182 } // namespace cc 2206 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/picture_layer_tiling_set.cc ('k') | cc/resources/picture_pile.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698