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

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

Issue 13820002: cc: Don't DCHECK for layers with non-invertible transforms. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « cc/resources/picture_layer_tiling.cc ('k') | cc/trees/layer_tree_host_common.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/resources/picture_layer_tiling.h" 5 #include "cc/resources/picture_layer_tiling.h"
6 6
7 #include "cc/test/fake_picture_layer_tiling_client.h" 7 #include "cc/test/fake_picture_layer_tiling_client.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/gfx/rect_conversions.h" 9 #include "ui/gfx/rect_conversions.h"
10 #include "ui/gfx/size_conversions.h" 10 #include "ui/gfx/size_conversions.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 } 61 }
62 62
63 // The entire rect must be filled by geometry from the tiling. 63 // The entire rect must be filled by geometry from the tiling.
64 EXPECT_TRUE(remaining.IsEmpty()); 64 EXPECT_TRUE(remaining.IsEmpty());
65 } 65 }
66 66
67 void VerifyTilesExactlyCoverRect(float rect_scale, gfx::Rect rect) { 67 void VerifyTilesExactlyCoverRect(float rect_scale, gfx::Rect rect) {
68 VerifyTilesExactlyCoverRect(rect_scale, rect, rect); 68 VerifyTilesExactlyCoverRect(rect_scale, rect, rect);
69 } 69 }
70 70
71 void VerifyTiles(float rect_scale,
72 gfx::Rect rect,
73 base::Callback<void(Tile*)> callback) {
74 Region remaining = rect;
75 for (PictureLayerTiling::CoverageIterator iter(
76 tiling_.get(), rect_scale, rect);
77 iter;
78 ++iter) {
79 remaining.Subtract(iter.geometry_rect());
80 callback.Run(*iter);
81 }
82 EXPECT_TRUE(remaining.IsEmpty());
83 }
84
71 void VerifyTilesCoverNonContainedRect(float rect_scale, gfx::Rect dest_rect) { 85 void VerifyTilesCoverNonContainedRect(float rect_scale, gfx::Rect dest_rect) {
72 float dest_to_contents_scale = tiling_->contents_scale() / rect_scale; 86 float dest_to_contents_scale = tiling_->contents_scale() / rect_scale;
73 gfx::Rect clamped_rect(gfx::ToEnclosingRect(gfx::ScaleRect( 87 gfx::Rect clamped_rect(gfx::ToEnclosingRect(gfx::ScaleRect(
74 tiling_->ContentRect(), 1 / dest_to_contents_scale))); 88 tiling_->ContentRect(), 1 / dest_to_contents_scale)));
75 clamped_rect.Intersect(dest_rect); 89 clamped_rect.Intersect(dest_rect);
76 VerifyTilesExactlyCoverRect(rect_scale, dest_rect, clamped_rect); 90 VerifyTilesExactlyCoverRect(rect_scale, dest_rect, clamped_rect);
77 } 91 }
78 92
79 protected: 93 protected:
80 FakePictureLayerTilingClient client_; 94 FakePictureLayerTilingClient client_;
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 365
352 TEST(PictureLayerTilingTest, ExpandRectOutOfBounds) { 366 TEST(PictureLayerTilingTest, ExpandRectOutOfBounds) {
353 gfx::Rect in(40, 50, 100, 200); 367 gfx::Rect in(40, 50, 100, 200);
354 gfx::Rect bounds(0, 0, 10, 10); 368 gfx::Rect bounds(0, 0, 10, 10);
355 int64 target_area = 400 * 400; 369 int64 target_area = 400 * 400;
356 gfx::Rect out = PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy( 370 gfx::Rect out = PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy(
357 in, target_area, bounds); 371 in, target_area, bounds);
358 EXPECT_TRUE(out.IsEmpty()); 372 EXPECT_TRUE(out.IsEmpty());
359 } 373 }
360 374
375 TEST(PictureLayerTilingTest, EmptyStartingRect) {
376 // If a layer has a non-invertible transform, then the starting rect
377 // for the layer would be empty.
378 gfx::Rect in(40, 40, 0, 0);
379 gfx::Rect bounds(0, 0, 10, 10);
380 int64 target_area = 400 * 400;
381 gfx::Rect out = PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy(
382 in, target_area, bounds);
383 EXPECT_TRUE(out.IsEmpty());
384 }
385
386 static void TileExists(bool live, Tile* tile) {
387 ASSERT_TRUE(tile != NULL);
388 EXPECT_EQ(live, tile->priority(ACTIVE_TREE).is_live);
389 }
390
391 TEST_F(PictureLayerTilingIteratorTest, TilesExist) {
392 gfx::Size layer_bounds(1099, 801);
393 Initialize(gfx::Size(100, 100), 1.f, layer_bounds);
394 VerifyTilesExactlyCoverRect(1.f, gfx::Rect(layer_bounds));
395 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false));
396
397 tiling_->UpdateTilePriorities(
398 ACTIVE_TREE,
399 layer_bounds, // device viewport
400 gfx::Rect(layer_bounds), // viewport in layer space
401 layer_bounds, // last layer bounds
402 layer_bounds, // current layer bounds
403 1.f, // last contents scale
404 1.f, // current contents scale
405 gfx::Transform(), // last screen transform
406 gfx::Transform(), // current screen transform
407 1, // current frame number
408 1.0, // current frame time
409 false, // store screen space quads on tiles
410 10000); // max tiles in tile manager
411 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, true));
412
413 // Make the viewport rect empty. All tiles are killed and become zombies.
414 tiling_->UpdateTilePriorities(
415 ACTIVE_TREE,
416 layer_bounds, // device viewport
417 gfx::Rect(), // viewport in layer space
418 layer_bounds, // last layer bounds
419 layer_bounds, // current layer bounds
420 1.f, // last contents scale
421 1.f, // current contents scale
422 gfx::Transform(), // last screen transform
423 gfx::Transform(), // current screen transform
424 2, // current frame number
425 2.0, // current frame time
426 false, // store screen space quads on tiles
427 10000); // max tiles in tile manager
428 VerifyTiles(1.f, gfx::Rect(layer_bounds), base::Bind(&TileExists, false));
429 }
430
361 } // namespace 431 } // namespace
362 } // namespace cc 432 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/picture_layer_tiling.cc ('k') | cc/trees/layer_tree_host_common.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698