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

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

Issue 2295343005: Improve PictureLayerTiling::CoverageIterator to handle rounding more precisely (Closed)
Patch Set: remove the 1.5 Created 4 years, 3 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.cc ('k') | no next file » | 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.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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 EXPECT_TRUE(live_tiles_rect.Intersects((*iter)->content_rect())); 122 EXPECT_TRUE(live_tiles_rect.Intersects((*iter)->content_rect()));
123 } 123 }
124 } 124 }
125 125
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 this ratio is too large (i.e. the 132 // Iterators are not valid if the destination scale is smaller than the
133 // tiling is too high-res for a low-res destination rect.) This is an 133 // tiling scale. This is because coverage computation is done in integer
134 // artifact of snapping geometry to integer coordinates and then mapping 134 // grids in the dest space, and the overlap between tiles may not guarantee
135 // back to floating point texture coordinates. 135 // to enclose an integer grid line to round to if scaled down.
136 float dest_to_contents_scale = tiling_->contents_scale() / rect_scale; 136 ASSERT_GE(rect_scale, tiling_->contents_scale());
137 ASSERT_LE(dest_to_contents_scale, 2.0);
138 137
139 Region remaining = expect_rect; 138 Region remaining = expect_rect;
140 for (PictureLayerTiling::CoverageIterator 139 for (PictureLayerTiling::CoverageIterator
141 iter(tiling_.get(), rect_scale, request_rect); 140 iter(tiling_.get(), rect_scale, request_rect);
142 iter; 141 iter;
143 ++iter) { 142 ++iter) {
144 // Geometry cannot overlap previous geometry at all 143 // Geometry cannot overlap previous geometry at all
145 gfx::Rect geometry = iter.geometry_rect(); 144 gfx::Rect geometry = iter.geometry_rect();
146 EXPECT_TRUE(expect_rect.Contains(geometry)); 145 EXPECT_TRUE(expect_rect.Contains(geometry));
147 EXPECT_TRUE(remaining.Contains(geometry)); 146 EXPECT_TRUE(remaining.Contains(geometry));
148 remaining.Subtract(geometry); 147 remaining.Subtract(geometry);
149 148
150 // Sanity check that texture coords are within the texture rect. 149 // Sanity check that texture coords are within the texture rect.
150 // Skip check for external edges because they do overhang.
151 // For internal edges there is an inset of 0.5 texels because the sample
152 // points are at the center of the texels. An extra 1/1024 tolerance
153 // is allowed for numerical errors.
154 // Refer to picture_layer_tiling.cc for detailed analysis.
155 const float inset = loose_texel_extent_check_ ? 0 : (0.5f - 1.f / 1024.f);
151 gfx::RectF texture_rect = iter.texture_rect(); 156 gfx::RectF texture_rect = iter.texture_rect();
152 EXPECT_GE(texture_rect.x(), 0); 157 if (iter.i())
153 EXPECT_GE(texture_rect.y(), 0); 158 EXPECT_GE(texture_rect.x(), inset);
154 EXPECT_LE(texture_rect.right(), client_.TileSize().width()); 159 if (iter.j())
155 EXPECT_LE(texture_rect.bottom(), client_.TileSize().height()); 160 EXPECT_GE(texture_rect.y(), inset);
161 if (iter.i() != tiling_->tiling_data()->num_tiles_x() - 1)
162 EXPECT_LE(texture_rect.right(), client_.TileSize().width() - inset);
163 if (iter.j() != tiling_->tiling_data()->num_tiles_y() - 1)
164 EXPECT_LE(texture_rect.bottom(), client_.TileSize().height() - inset);
156 } 165 }
157 166
158 // The entire rect must be filled by geometry from the tiling. 167 // The entire rect must be filled by geometry from the tiling.
159 EXPECT_TRUE(remaining.IsEmpty()); 168 EXPECT_TRUE(remaining.IsEmpty());
160 } 169 }
161 170
162 void VerifyTilesExactlyCoverRect(float rect_scale, const gfx::Rect& rect) { 171 void VerifyTilesExactlyCoverRect(float rect_scale, const gfx::Rect& rect) {
163 VerifyTilesExactlyCoverRect(rect_scale, rect, rect); 172 VerifyTilesExactlyCoverRect(rect_scale, rect, rect);
164 } 173 }
165 174
(...skipping 29 matching lines...) Expand all
195 float dest_to_contents_scale = tiling_->contents_scale() / rect_scale; 204 float dest_to_contents_scale = tiling_->contents_scale() / rect_scale;
196 gfx::Rect clamped_rect = gfx::ScaleToEnclosingRect( 205 gfx::Rect clamped_rect = gfx::ScaleToEnclosingRect(
197 gfx::Rect(tiling_->tiling_size()), 1.f / dest_to_contents_scale); 206 gfx::Rect(tiling_->tiling_size()), 1.f / dest_to_contents_scale);
198 clamped_rect.Intersect(dest_rect); 207 clamped_rect.Intersect(dest_rect);
199 VerifyTilesExactlyCoverRect(rect_scale, dest_rect, clamped_rect); 208 VerifyTilesExactlyCoverRect(rect_scale, dest_rect, clamped_rect);
200 } 209 }
201 210
202 protected: 211 protected:
203 FakePictureLayerTilingClient client_; 212 FakePictureLayerTilingClient client_;
204 std::unique_ptr<TestablePictureLayerTiling> tiling_; 213 std::unique_ptr<TestablePictureLayerTiling> tiling_;
214 bool loose_texel_extent_check_ = false;
205 215
206 private: 216 private:
207 DISALLOW_COPY_AND_ASSIGN(PictureLayerTilingIteratorTest); 217 DISALLOW_COPY_AND_ASSIGN(PictureLayerTilingIteratorTest);
208 }; 218 };
209 219
210 TEST_F(PictureLayerTilingIteratorTest, ResizeDeletesTiles) { 220 TEST_F(PictureLayerTilingIteratorTest, ResizeDeletesTiles) {
211 // Verifies that a resize with invalidation for newly exposed pixels will 221 // Verifies that a resize with invalidation for newly exposed pixels will
212 // deletes tiles that intersect that invalidation. 222 // deletes tiles that intersect that invalidation.
213 gfx::Size tile_size(100, 100); 223 gfx::Size tile_size(100, 100);
214 gfx::Size original_layer_size(10, 10); 224 gfx::Size original_layer_size(10, 10);
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 // With borders, a size of 3x3 = 1 pixel of content. 543 // With borders, a size of 3x3 = 1 pixel of content.
534 Initialize(gfx::Size(3, 3), 1.f, gfx::Size(10, 10)); 544 Initialize(gfx::Size(3, 3), 1.f, gfx::Size(10, 10));
535 VerifyTilesExactlyCoverRect(1, gfx::Rect(0, 0, 1, 1)); 545 VerifyTilesExactlyCoverRect(1, gfx::Rect(0, 0, 1, 1));
536 VerifyTilesExactlyCoverRect(1, gfx::Rect(0, 0, 2, 2)); 546 VerifyTilesExactlyCoverRect(1, gfx::Rect(0, 0, 2, 2));
537 VerifyTilesExactlyCoverRect(1, gfx::Rect(1, 1, 2, 2)); 547 VerifyTilesExactlyCoverRect(1, gfx::Rect(1, 1, 2, 2));
538 VerifyTilesExactlyCoverRect(1, gfx::Rect(3, 2, 5, 2)); 548 VerifyTilesExactlyCoverRect(1, gfx::Rect(3, 2, 5, 2));
539 } 549 }
540 550
541 TEST_F(PictureLayerTilingIteratorTest, IteratorCoversLayerBoundsTilingScale) { 551 TEST_F(PictureLayerTilingIteratorTest, IteratorCoversLayerBoundsTilingScale) {
542 Initialize(gfx::Size(200, 100), 2.0f, gfx::Size(1005, 2010)); 552 Initialize(gfx::Size(200, 100), 2.0f, gfx::Size(1005, 2010));
543 VerifyTilesExactlyCoverRect(1, gfx::Rect()); 553 VerifyTilesExactlyCoverRect(2, gfx::Rect());
544 VerifyTilesExactlyCoverRect(1, gfx::Rect(0, 0, 1005, 2010)); 554 VerifyTilesExactlyCoverRect(2, gfx::Rect(0, 0, 2010, 4020));
545 VerifyTilesExactlyCoverRect(1, gfx::Rect(50, 112, 512, 381)); 555 VerifyTilesExactlyCoverRect(2, gfx::Rect(100, 224, 1024, 762));
546 556
547 Initialize(gfx::Size(3, 3), 2.0f, gfx::Size(10, 10)); 557 Initialize(gfx::Size(3, 3), 2.0f, gfx::Size(10, 10));
548 VerifyTilesExactlyCoverRect(1, gfx::Rect()); 558 VerifyTilesExactlyCoverRect(2, gfx::Rect());
549 VerifyTilesExactlyCoverRect(1, gfx::Rect(0, 0, 1, 1)); 559 VerifyTilesExactlyCoverRect(2, gfx::Rect(0, 0, 1, 1));
550 VerifyTilesExactlyCoverRect(1, gfx::Rect(0, 0, 2, 2)); 560 VerifyTilesExactlyCoverRect(2, gfx::Rect(0, 0, 2, 2));
551 VerifyTilesExactlyCoverRect(1, gfx::Rect(1, 1, 2, 2)); 561 VerifyTilesExactlyCoverRect(2, gfx::Rect(1, 1, 2, 2));
552 VerifyTilesExactlyCoverRect(1, gfx::Rect(3, 2, 5, 2)); 562 VerifyTilesExactlyCoverRect(2, gfx::Rect(3, 2, 5, 2));
553 563
554 Initialize(gfx::Size(100, 200), 0.5f, gfx::Size(1005, 2010)); 564 Initialize(gfx::Size(100, 200), 0.5f, gfx::Size(1005, 2010));
555 VerifyTilesExactlyCoverRect(1, gfx::Rect(0, 0, 1005, 2010)); 565 VerifyTilesExactlyCoverRect(1, gfx::Rect(0, 0, 1005, 2010));
556 VerifyTilesExactlyCoverRect(1, gfx::Rect(50, 112, 512, 381)); 566 VerifyTilesExactlyCoverRect(1, gfx::Rect(50, 112, 512, 381));
557 567
558 Initialize(gfx::Size(150, 250), 0.37f, gfx::Size(1005, 2010)); 568 Initialize(gfx::Size(150, 250), 0.37f, gfx::Size(1005, 2010));
559 VerifyTilesExactlyCoverRect(1, gfx::Rect(0, 0, 1005, 2010)); 569 VerifyTilesExactlyCoverRect(1, gfx::Rect(0, 0, 1005, 2010));
560 VerifyTilesExactlyCoverRect(1, gfx::Rect(50, 112, 512, 381)); 570 VerifyTilesExactlyCoverRect(1, gfx::Rect(50, 112, 512, 381));
561 571
562 Initialize(gfx::Size(312, 123), 0.01f, gfx::Size(1005, 2010)); 572 Initialize(gfx::Size(312, 123), 0.01f, gfx::Size(1005, 2010));
563 VerifyTilesExactlyCoverRect(1, gfx::Rect(0, 0, 1005, 2010)); 573 VerifyTilesExactlyCoverRect(1, gfx::Rect(0, 0, 1005, 2010));
564 VerifyTilesExactlyCoverRect(1, gfx::Rect(50, 112, 512, 381)); 574 VerifyTilesExactlyCoverRect(1, gfx::Rect(50, 112, 512, 381));
565 } 575 }
566 576
567 TEST_F(PictureLayerTilingIteratorTest, IteratorCoversLayerBoundsBothScale) { 577 TEST_F(PictureLayerTilingIteratorTest, IteratorCoversLayerBoundsBothScale) {
568 Initialize(gfx::Size(50, 50), 4.0f, gfx::Size(800, 600)); 578 Initialize(gfx::Size(50, 50), 4.0f, gfx::Size(800, 600));
569 VerifyTilesExactlyCoverRect(2.0f, gfx::Rect()); 579 VerifyTilesExactlyCoverRect(4.0f, gfx::Rect());
570 VerifyTilesExactlyCoverRect(2.0f, gfx::Rect(0, 0, 1600, 1200)); 580 VerifyTilesExactlyCoverRect(4.0f, gfx::Rect(0, 0, 3200, 2400));
571 VerifyTilesExactlyCoverRect(2.0f, gfx::Rect(512, 365, 253, 182)); 581 VerifyTilesExactlyCoverRect(4.0f, gfx::Rect(1024, 730, 506, 364));
572 582
573 float scale = 6.7f; 583 float scale = 6.7f;
574 gfx::Size bounds(800, 600); 584 gfx::Size bounds(800, 600);
575 gfx::Rect full_rect(gfx::ScaleToCeiledSize(bounds, scale)); 585 gfx::Rect full_rect(gfx::ScaleToCeiledSize(bounds, scale));
576 Initialize(gfx::Size(256, 512), 5.2f, bounds); 586 Initialize(gfx::Size(256, 512), 5.2f, bounds);
577 VerifyTilesExactlyCoverRect(scale, full_rect); 587 VerifyTilesExactlyCoverRect(scale, full_rect);
578 VerifyTilesExactlyCoverRect(scale, gfx::Rect(2014, 1579, 867, 1033)); 588 VerifyTilesExactlyCoverRect(scale, gfx::Rect(2014, 1579, 867, 1033));
579 } 589 }
580 590
581 TEST_F(PictureLayerTilingIteratorTest, IteratorEmptyRect) { 591 TEST_F(PictureLayerTilingIteratorTest, IteratorEmptyRect) {
582 Initialize(gfx::Size(100, 100), 1.0f, gfx::Size(800, 600)); 592 Initialize(gfx::Size(100, 100), 1.0f, gfx::Size(800, 600));
583 593
584 gfx::Rect empty; 594 gfx::Rect empty;
585 PictureLayerTiling::CoverageIterator iter(tiling_.get(), 1.0f, empty); 595 PictureLayerTiling::CoverageIterator iter(tiling_.get(), 1.0f, empty);
586 EXPECT_FALSE(iter); 596 EXPECT_FALSE(iter);
587 } 597 }
588 598
589 TEST_F(PictureLayerTilingIteratorTest, NonIntersectingRect) { 599 TEST_F(PictureLayerTilingIteratorTest, NonIntersectingRect) {
590 Initialize(gfx::Size(100, 100), 1.0f, gfx::Size(800, 600)); 600 Initialize(gfx::Size(100, 100), 1.0f, gfx::Size(800, 600));
591 gfx::Rect non_intersecting(1000, 1000, 50, 50); 601 gfx::Rect non_intersecting(1000, 1000, 50, 50);
592 PictureLayerTiling::CoverageIterator iter(tiling_.get(), 1, non_intersecting); 602 PictureLayerTiling::CoverageIterator iter(tiling_.get(), 1, non_intersecting);
593 EXPECT_FALSE(iter); 603 EXPECT_FALSE(iter);
594 } 604 }
595 605
596 TEST_F(PictureLayerTilingIteratorTest, LayerEdgeTextureCoordinates) { 606 TEST_F(PictureLayerTilingIteratorTest, LayerEdgeTextureCoordinates) {
597 Initialize(gfx::Size(300, 300), 1.0f, gfx::Size(256, 256)); 607 Initialize(gfx::Size(300, 300), 1.0f, gfx::Size(256, 256));
598 // All of these sizes are 256x256, scaled and ceiled. 608 // All of these sizes are 256x256, scaled and ceiled.
599 VerifyTilesExactlyCoverRect(1.0f, gfx::Rect(0, 0, 256, 256)); 609 VerifyTilesExactlyCoverRect(1.0f, gfx::Rect(0, 0, 256, 256));
600 VerifyTilesExactlyCoverRect(0.8f, gfx::Rect(0, 0, 205, 205));
601 VerifyTilesExactlyCoverRect(1.2f, gfx::Rect(0, 0, 308, 308)); 610 VerifyTilesExactlyCoverRect(1.2f, gfx::Rect(0, 0, 308, 308));
602 } 611 }
603 612
604 TEST_F(PictureLayerTilingIteratorTest, NonContainedDestRect) { 613 TEST_F(PictureLayerTilingIteratorTest, NonContainedDestRect) {
605 Initialize(gfx::Size(100, 100), 1.0f, gfx::Size(400, 400)); 614 Initialize(gfx::Size(100, 100), 1.0f, gfx::Size(400, 400));
606 615
607 // Too large in all dimensions 616 // Too large in all dimensions
608 VerifyTilesCoverNonContainedRect(1.0f, gfx::Rect(-1000, -1000, 2000, 2000)); 617 VerifyTilesCoverNonContainedRect(1.0f, gfx::Rect(-1000, -1000, 2000, 2000));
609 VerifyTilesCoverNonContainedRect(1.5f, gfx::Rect(-1000, -1000, 2000, 2000)); 618 VerifyTilesCoverNonContainedRect(1.5f, gfx::Rect(-1000, -1000, 2000, 2000));
610 VerifyTilesCoverNonContainedRect(0.5f, gfx::Rect(-1000, -1000, 2000, 2000));
611 619
612 // Partially covering content, but too large 620 // Partially covering content, but too large
613 VerifyTilesCoverNonContainedRect(1.0f, gfx::Rect(-1000, 100, 2000, 100)); 621 VerifyTilesCoverNonContainedRect(1.0f, gfx::Rect(-1000, 100, 2000, 100));
614 VerifyTilesCoverNonContainedRect(1.5f, gfx::Rect(-1000, 100, 2000, 100)); 622 VerifyTilesCoverNonContainedRect(1.5f, gfx::Rect(-1000, 100, 2000, 100));
615 VerifyTilesCoverNonContainedRect(0.5f, gfx::Rect(-1000, 100, 2000, 100));
616 } 623 }
617 624
618 static void TileExists(bool exists, Tile* tile, 625 static void TileExists(bool exists, Tile* tile,
619 const gfx::Rect& geometry_rect) { 626 const gfx::Rect& geometry_rect) {
620 EXPECT_EQ(exists, tile != NULL) << geometry_rect.ToString(); 627 EXPECT_EQ(exists, tile != NULL) << geometry_rect.ToString();
621 } 628 }
622 629
623 TEST_F(PictureLayerTilingIteratorTest, TilesExist) { 630 TEST_F(PictureLayerTilingIteratorTest, TilesExist) {
624 gfx::Size layer_bounds(1099, 801); 631 gfx::Size layer_bounds(1099, 801);
625 Initialize(gfx::Size(100, 100), 1.f, layer_bounds); 632 Initialize(gfx::Size(100, 100), 1.f, layer_bounds);
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 tiling_->SetRasterSourceAndResize(raster_source); 975 tiling_->SetRasterSourceAndResize(raster_source);
969 976
970 // Tile size in the tiling should be resized to 250x200. 977 // Tile size in the tiling should be resized to 250x200.
971 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width()); 978 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width());
972 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height()); 979 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height());
973 EXPECT_EQ(0u, tiling_->AllTilesForTesting().size()); 980 EXPECT_EQ(0u, tiling_->AllTilesForTesting().size());
974 } 981 }
975 982
976 // This test runs into floating point issues because of big numbers. 983 // This test runs into floating point issues because of big numbers.
977 TEST_F(PictureLayerTilingIteratorTest, GiantRect) { 984 TEST_F(PictureLayerTilingIteratorTest, GiantRect) {
985 loose_texel_extent_check_ = true;
986
978 gfx::Size tile_size(256, 256); 987 gfx::Size tile_size(256, 256);
979 gfx::Size layer_size(33554432, 33554432); 988 gfx::Size layer_size(33554432, 33554432);
980 float contents_scale = 1.f; 989 float contents_scale = 1.f;
981 990
982 client_.SetTileSize(tile_size); 991 client_.SetTileSize(tile_size);
983 scoped_refptr<FakeRasterSource> raster_source = 992 scoped_refptr<FakeRasterSource> raster_source =
984 FakeRasterSource::CreateEmpty(layer_size); 993 FakeRasterSource::CreateEmpty(layer_size);
985 tiling_ = TestablePictureLayerTiling::Create(PENDING_TREE, contents_scale, 994 tiling_ = TestablePictureLayerTiling::Create(PENDING_TREE, contents_scale,
986 raster_source, &client_, 995 raster_source, &client_,
987 LayerTreeSettings()); 996 LayerTreeSettings());
988 997
989 gfx::Rect content_rect(25554432, 25554432, 950, 860); 998 gfx::Rect content_rect(25554432, 25554432, 950, 860);
990 VerifyTilesExactlyCoverRect(contents_scale, content_rect); 999 VerifyTilesExactlyCoverRect(contents_scale, content_rect);
991 } 1000 }
992 1001
1002 TEST_F(PictureLayerTilingIteratorTest, QuadShouldNotUseLastHalfTexel) {
1003 Initialize(gfx::Size(100, 100), 1.f, gfx::Size(198, 198));
1004 // Creates a situation that tile bounds get rounded up by almost 1px in the
1005 // dest space. This test verifies that even in such situation the coverage
1006 // iterator won't generate a texture rect that can potentially get clamped.
1007 VerifyTilesExactlyCoverRect(1.000005f, gfx::Rect(199, 199));
1008 }
1009
1010 static void TileHasGeometryRect(const gfx::Rect& expected_rect,
1011 Tile* tile,
1012 const gfx::Rect& geometry_rect) {
1013 EXPECT_EQ(expected_rect, geometry_rect);
1014 }
1015
1016 TEST_F(PictureLayerTilingIteratorTest, UseLeastTilesToCover) {
1017 // This test verifies that when a dest pixel can be covered by more than
1018 // one tiles, least number of tiles gets emitted.
1019 Initialize(gfx::Size(100, 100), 1.f, gfx::Size(1000, 1000));
1020 gfx::RectF overlaped =
1021 gfx::ScaleRect(gfx::RectF(198.f, 198.f, 1.f, 1.f), 1.f / 2.f);
1022 ASSERT_TRUE(tiling_->tiling_data()->TexelExtent(0, 0).Contains(overlaped));
1023 ASSERT_TRUE(tiling_->tiling_data()->TexelExtent(1, 0).Contains(overlaped));
1024 ASSERT_TRUE(tiling_->tiling_data()->TexelExtent(0, 1).Contains(overlaped));
1025 ASSERT_TRUE(tiling_->tiling_data()->TexelExtent(1, 1).Contains(overlaped));
1026 VerifyTilesExactlyCoverRect(2.f, gfx::Rect(199, 199));
1027 VerifyTiles(2.f, gfx::Rect(199, 199),
1028 base::Bind(&TileHasGeometryRect, gfx::Rect(199, 199)));
1029 }
1030
1031 TEST_F(PictureLayerTilingIteratorTest, UseLeastTilesToCover2) {
1032 // Similar to above test, but with an internal tile.
1033 Initialize(gfx::Size(100, 100), 1.f, gfx::Size(1000, 1000));
1034 gfx::RectF overlaped =
1035 gfx::ScaleRect(gfx::RectF(197.f, 393.f, 1.f, 1.f), 1.f / 2.f);
1036 ASSERT_TRUE(tiling_->tiling_data()->TexelExtent(0, 1).Contains(overlaped));
1037 ASSERT_TRUE(tiling_->tiling_data()->TexelExtent(1, 1).Contains(overlaped));
1038 ASSERT_TRUE(tiling_->tiling_data()->TexelExtent(0, 2).Contains(overlaped));
1039 ASSERT_TRUE(tiling_->tiling_data()->TexelExtent(1, 2).Contains(overlaped));
1040 gfx::Rect dest_rect(197, 393, 198, 198);
1041 VerifyTilesExactlyCoverRect(2.f, dest_rect);
1042 VerifyTiles(2.f, dest_rect, base::Bind(&TileHasGeometryRect, dest_rect));
1043 }
1044
1045 TEST_F(PictureLayerTilingIteratorTest, TightCover) {
1046 // This test verifies that the whole dest rect is still fully covered when
1047 // numerical condition is tight.
1048 // In this test, the right edge of tile #37 almost (but failed to) covered
1049 // grid line x = 9654. Tile #38 needs to reach hard to x = 9653 to make up
1050 // for this.
1051 Initialize(gfx::Size(256, 256), 1.f, gfx::Size(10000, 1));
1052 float dest_scale = 16778082.f / 16777216.f; // 0b1.00000000 00000011 01100010
1053 VerifyTilesExactlyCoverRect(dest_scale, gfx::Rect(10001, 2));
1054 }
1055
1056 TEST_F(PictureLayerTilingIteratorTest, TightCover2) {
1057 // In this test, the left edge of tile #38 almost (but failed to) covered
1058 // grid line x = 9653. Tile #37 needs to reach hard to x = 9654 to make up
1059 // for this.
1060 Initialize(gfx::Size(256, 256), 1.f, gfx::Size(10000, 1));
1061 float dest_scale = 16778088.f / 16777216.f; // 0b1.00000000 00000011 01101000
1062 VerifyTilesExactlyCoverRect(dest_scale, gfx::Rect(10001, 2));
1063 }
1064
993 } // namespace 1065 } // namespace
994 } // namespace cc 1066 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiles/picture_layer_tiling.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698