Chromium Code Reviews| 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 scoped_refptr<RasterSource> raster_source, | 69 scoped_refptr<RasterSource> raster_source, |
| 70 PictureLayerTilingClient* client, | 70 PictureLayerTilingClient* client, |
| 71 size_t tiling_interest_area_padding, | 71 size_t tiling_interest_area_padding, |
| 72 float skewport_target_time, | 72 float skewport_target_time, |
| 73 int skewport_extrapolation_limit) | 73 int skewport_extrapolation_limit) |
| 74 : PictureLayerTiling(tree, contents_scale, raster_source, client) {} | 74 : PictureLayerTiling(tree, contents_scale, raster_source, client) {} |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 class PictureLayerTilingIteratorTest : public testing::Test { | 77 class PictureLayerTilingIteratorTest : public testing::Test { |
| 78 public: | 78 public: |
| 79 PictureLayerTilingIteratorTest() {} | 79 PictureLayerTilingIteratorTest() : loose_texel_extent_check_(false) {} |
| 80 ~PictureLayerTilingIteratorTest() override {} | 80 ~PictureLayerTilingIteratorTest() override {} |
| 81 | 81 |
| 82 void Initialize(const gfx::Size& tile_size, | 82 void Initialize(const gfx::Size& tile_size, |
| 83 float contents_scale, | 83 float contents_scale, |
| 84 const gfx::Size& layer_bounds) { | 84 const gfx::Size& layer_bounds) { |
| 85 client_.SetTileSize(tile_size); | 85 client_.SetTileSize(tile_size); |
| 86 scoped_refptr<FakeRasterSource> raster_source = | 86 scoped_refptr<FakeRasterSource> raster_source = |
| 87 FakeRasterSource::CreateFilled(layer_bounds); | 87 FakeRasterSource::CreateFilled(layer_bounds); |
| 88 tiling_ = TestablePictureLayerTiling::Create(PENDING_TREE, contents_scale, | 88 tiling_ = TestablePictureLayerTiling::Create(PENDING_TREE, contents_scale, |
| 89 raster_source, &client_, | 89 raster_source, &client_, |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 113 EXPECT_TRUE(live_tiles_rect.Intersects((*iter)->content_rect())); | 113 EXPECT_TRUE(live_tiles_rect.Intersects((*iter)->content_rect())); |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 | 116 |
| 117 void VerifyTilesExactlyCoverRect( | 117 void VerifyTilesExactlyCoverRect( |
| 118 float rect_scale, | 118 float rect_scale, |
| 119 const gfx::Rect& request_rect, | 119 const gfx::Rect& request_rect, |
| 120 const gfx::Rect& expect_rect) { | 120 const gfx::Rect& expect_rect) { |
| 121 EXPECT_TRUE(request_rect.Contains(expect_rect)); | 121 EXPECT_TRUE(request_rect.Contains(expect_rect)); |
| 122 | 122 |
| 123 // Iterators are not valid if this ratio is too large (i.e. the | 123 // Iterators are not valid if the destination scale is smaller than the |
| 124 // tiling is too high-res for a low-res destination rect.) This is an | 124 // tiling scale. This is because coverage computation is done in integer |
| 125 // artifact of snapping geometry to integer coordinates and then mapping | 125 // grids in the dest space, and the overlap between tiles may not guarantee |
| 126 // back to floating point texture coordinates. | 126 // to enclose an integer grid line to round to if scaled down. |
| 127 float dest_to_contents_scale = tiling_->contents_scale() / rect_scale; | 127 ASSERT_GE(rect_scale, tiling_->contents_scale()); |
| 128 ASSERT_LE(dest_to_contents_scale, 2.0); | |
| 129 | 128 |
| 130 Region remaining = expect_rect; | 129 Region remaining = expect_rect; |
| 131 for (PictureLayerTiling::CoverageIterator | 130 for (PictureLayerTiling::CoverageIterator |
| 132 iter(tiling_.get(), rect_scale, request_rect); | 131 iter(tiling_.get(), rect_scale, request_rect); |
| 133 iter; | 132 iter; |
| 134 ++iter) { | 133 ++iter) { |
| 135 // Geometry cannot overlap previous geometry at all | 134 // Geometry cannot overlap previous geometry at all |
| 136 gfx::Rect geometry = iter.geometry_rect(); | 135 gfx::Rect geometry = iter.geometry_rect(); |
| 137 EXPECT_TRUE(expect_rect.Contains(geometry)); | 136 EXPECT_TRUE(expect_rect.Contains(geometry)); |
| 138 EXPECT_TRUE(remaining.Contains(geometry)); | 137 EXPECT_TRUE(remaining.Contains(geometry)); |
| 139 remaining.Subtract(geometry); | 138 remaining.Subtract(geometry); |
| 140 | 139 |
| 141 // Sanity check that texture coords are within the texture rect. | 140 // Sanity check that texture coords are within the texture rect. |
| 141 // Skip check for external edges because they do overhang. | |
|
enne (OOO)
2016/09/09 21:46:34
As I said earlier, I'd prefer that external edges
trchen
2016/09/09 23:39:19
They still overhang because dest point (0, 0) maps
| |
| 142 // For internal edges there is an inset of 0.5 texels because the sample | |
| 143 // points are at the center of the texels. An extra 1/1024 tolerance | |
| 144 // is allowed for numerical errors. | |
| 145 // Refer to picture_layer_tiling.cc for detailed analysis. | |
| 146 const float inset = loose_texel_extent_check_ ? 0 : (0.5f - 1.f / 1024.f); | |
| 142 gfx::RectF texture_rect = iter.texture_rect(); | 147 gfx::RectF texture_rect = iter.texture_rect(); |
| 143 EXPECT_GE(texture_rect.x(), 0); | 148 if (iter.i()) |
| 144 EXPECT_GE(texture_rect.y(), 0); | 149 EXPECT_GE(texture_rect.x(), inset); |
| 145 EXPECT_LE(texture_rect.right(), client_.TileSize().width()); | 150 if (iter.j()) |
| 146 EXPECT_LE(texture_rect.bottom(), client_.TileSize().height()); | 151 EXPECT_GE(texture_rect.y(), inset); |
| 152 if (iter.i() != tiling_->tiling_data()->num_tiles_x() - 1) | |
| 153 EXPECT_LE(texture_rect.right(), client_.TileSize().width() - inset); | |
| 154 if (iter.j() != tiling_->tiling_data()->num_tiles_y() - 1) | |
| 155 EXPECT_LE(texture_rect.bottom(), client_.TileSize().height() - inset); | |
| 147 } | 156 } |
| 148 | 157 |
| 149 // The entire rect must be filled by geometry from the tiling. | 158 // The entire rect must be filled by geometry from the tiling. |
| 150 EXPECT_TRUE(remaining.IsEmpty()); | 159 EXPECT_TRUE(remaining.IsEmpty()); |
| 151 } | 160 } |
| 152 | 161 |
| 153 void VerifyTilesExactlyCoverRect(float rect_scale, const gfx::Rect& rect) { | 162 void VerifyTilesExactlyCoverRect(float rect_scale, const gfx::Rect& rect) { |
| 154 VerifyTilesExactlyCoverRect(rect_scale, rect, rect); | 163 VerifyTilesExactlyCoverRect(rect_scale, rect, rect); |
| 155 } | 164 } |
| 156 | 165 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 186 float dest_to_contents_scale = tiling_->contents_scale() / rect_scale; | 195 float dest_to_contents_scale = tiling_->contents_scale() / rect_scale; |
| 187 gfx::Rect clamped_rect = gfx::ScaleToEnclosingRect( | 196 gfx::Rect clamped_rect = gfx::ScaleToEnclosingRect( |
| 188 gfx::Rect(tiling_->tiling_size()), 1.f / dest_to_contents_scale); | 197 gfx::Rect(tiling_->tiling_size()), 1.f / dest_to_contents_scale); |
| 189 clamped_rect.Intersect(dest_rect); | 198 clamped_rect.Intersect(dest_rect); |
| 190 VerifyTilesExactlyCoverRect(rect_scale, dest_rect, clamped_rect); | 199 VerifyTilesExactlyCoverRect(rect_scale, dest_rect, clamped_rect); |
| 191 } | 200 } |
| 192 | 201 |
| 193 protected: | 202 protected: |
| 194 FakePictureLayerTilingClient client_; | 203 FakePictureLayerTilingClient client_; |
| 195 std::unique_ptr<TestablePictureLayerTiling> tiling_; | 204 std::unique_ptr<TestablePictureLayerTiling> tiling_; |
| 205 bool loose_texel_extent_check_; | |
|
enne (OOO)
2016/09/09 21:46:34
Just initialize this here instead of the ctor.
trchen
2016/09/09 23:39:19
Done.
| |
| 196 | 206 |
| 197 private: | 207 private: |
| 198 DISALLOW_COPY_AND_ASSIGN(PictureLayerTilingIteratorTest); | 208 DISALLOW_COPY_AND_ASSIGN(PictureLayerTilingIteratorTest); |
| 199 }; | 209 }; |
| 200 | 210 |
| 201 TEST_F(PictureLayerTilingIteratorTest, ResizeDeletesTiles) { | 211 TEST_F(PictureLayerTilingIteratorTest, ResizeDeletesTiles) { |
| 202 // Verifies that a resize with invalidation for newly exposed pixels will | 212 // Verifies that a resize with invalidation for newly exposed pixels will |
| 203 // deletes tiles that intersect that invalidation. | 213 // deletes tiles that intersect that invalidation. |
| 204 gfx::Size tile_size(100, 100); | 214 gfx::Size tile_size(100, 100); |
| 205 gfx::Size original_layer_size(10, 10); | 215 gfx::Size original_layer_size(10, 10); |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 524 // With borders, a size of 3x3 = 1 pixel of content. | 534 // With borders, a size of 3x3 = 1 pixel of content. |
| 525 Initialize(gfx::Size(3, 3), 1.f, gfx::Size(10, 10)); | 535 Initialize(gfx::Size(3, 3), 1.f, gfx::Size(10, 10)); |
| 526 VerifyTilesExactlyCoverRect(1, gfx::Rect(0, 0, 1, 1)); | 536 VerifyTilesExactlyCoverRect(1, gfx::Rect(0, 0, 1, 1)); |
| 527 VerifyTilesExactlyCoverRect(1, gfx::Rect(0, 0, 2, 2)); | 537 VerifyTilesExactlyCoverRect(1, gfx::Rect(0, 0, 2, 2)); |
| 528 VerifyTilesExactlyCoverRect(1, gfx::Rect(1, 1, 2, 2)); | 538 VerifyTilesExactlyCoverRect(1, gfx::Rect(1, 1, 2, 2)); |
| 529 VerifyTilesExactlyCoverRect(1, gfx::Rect(3, 2, 5, 2)); | 539 VerifyTilesExactlyCoverRect(1, gfx::Rect(3, 2, 5, 2)); |
| 530 } | 540 } |
| 531 | 541 |
| 532 TEST_F(PictureLayerTilingIteratorTest, IteratorCoversLayerBoundsTilingScale) { | 542 TEST_F(PictureLayerTilingIteratorTest, IteratorCoversLayerBoundsTilingScale) { |
| 533 Initialize(gfx::Size(200, 100), 2.0f, gfx::Size(1005, 2010)); | 543 Initialize(gfx::Size(200, 100), 2.0f, gfx::Size(1005, 2010)); |
| 534 VerifyTilesExactlyCoverRect(1, gfx::Rect()); | 544 VerifyTilesExactlyCoverRect(2, gfx::Rect()); |
| 535 VerifyTilesExactlyCoverRect(1, gfx::Rect(0, 0, 1005, 2010)); | 545 VerifyTilesExactlyCoverRect(2, gfx::Rect(0, 0, 2010, 4020)); |
| 536 VerifyTilesExactlyCoverRect(1, gfx::Rect(50, 112, 512, 381)); | 546 VerifyTilesExactlyCoverRect(2, gfx::Rect(100, 224, 1024, 762)); |
| 537 | 547 |
| 538 Initialize(gfx::Size(3, 3), 2.0f, gfx::Size(10, 10)); | 548 Initialize(gfx::Size(3, 3), 2.0f, gfx::Size(10, 10)); |
| 539 VerifyTilesExactlyCoverRect(1, gfx::Rect()); | 549 VerifyTilesExactlyCoverRect(2, gfx::Rect()); |
| 540 VerifyTilesExactlyCoverRect(1, gfx::Rect(0, 0, 1, 1)); | 550 VerifyTilesExactlyCoverRect(2, gfx::Rect(0, 0, 1, 1)); |
| 541 VerifyTilesExactlyCoverRect(1, gfx::Rect(0, 0, 2, 2)); | 551 VerifyTilesExactlyCoverRect(2, gfx::Rect(0, 0, 2, 2)); |
| 542 VerifyTilesExactlyCoverRect(1, gfx::Rect(1, 1, 2, 2)); | 552 VerifyTilesExactlyCoverRect(2, gfx::Rect(1, 1, 2, 2)); |
| 543 VerifyTilesExactlyCoverRect(1, gfx::Rect(3, 2, 5, 2)); | 553 VerifyTilesExactlyCoverRect(2, gfx::Rect(3, 2, 5, 2)); |
| 544 | 554 |
| 545 Initialize(gfx::Size(100, 200), 0.5f, gfx::Size(1005, 2010)); | 555 Initialize(gfx::Size(100, 200), 0.5f, gfx::Size(1005, 2010)); |
| 546 VerifyTilesExactlyCoverRect(1, gfx::Rect(0, 0, 1005, 2010)); | 556 VerifyTilesExactlyCoverRect(1, gfx::Rect(0, 0, 1005, 2010)); |
| 547 VerifyTilesExactlyCoverRect(1, gfx::Rect(50, 112, 512, 381)); | 557 VerifyTilesExactlyCoverRect(1, gfx::Rect(50, 112, 512, 381)); |
| 548 | 558 |
| 549 Initialize(gfx::Size(150, 250), 0.37f, gfx::Size(1005, 2010)); | 559 Initialize(gfx::Size(150, 250), 0.37f, gfx::Size(1005, 2010)); |
| 550 VerifyTilesExactlyCoverRect(1, gfx::Rect(0, 0, 1005, 2010)); | 560 VerifyTilesExactlyCoverRect(1, gfx::Rect(0, 0, 1005, 2010)); |
| 551 VerifyTilesExactlyCoverRect(1, gfx::Rect(50, 112, 512, 381)); | 561 VerifyTilesExactlyCoverRect(1, gfx::Rect(50, 112, 512, 381)); |
| 552 | 562 |
| 553 Initialize(gfx::Size(312, 123), 0.01f, gfx::Size(1005, 2010)); | 563 Initialize(gfx::Size(312, 123), 0.01f, gfx::Size(1005, 2010)); |
| 554 VerifyTilesExactlyCoverRect(1, gfx::Rect(0, 0, 1005, 2010)); | 564 VerifyTilesExactlyCoverRect(1, gfx::Rect(0, 0, 1005, 2010)); |
| 555 VerifyTilesExactlyCoverRect(1, gfx::Rect(50, 112, 512, 381)); | 565 VerifyTilesExactlyCoverRect(1, gfx::Rect(50, 112, 512, 381)); |
| 556 } | 566 } |
| 557 | 567 |
| 558 TEST_F(PictureLayerTilingIteratorTest, IteratorCoversLayerBoundsBothScale) { | 568 TEST_F(PictureLayerTilingIteratorTest, IteratorCoversLayerBoundsBothScale) { |
| 559 Initialize(gfx::Size(50, 50), 4.0f, gfx::Size(800, 600)); | 569 Initialize(gfx::Size(50, 50), 4.0f, gfx::Size(800, 600)); |
| 560 VerifyTilesExactlyCoverRect(2.0f, gfx::Rect()); | 570 VerifyTilesExactlyCoverRect(4.0f, gfx::Rect()); |
| 561 VerifyTilesExactlyCoverRect(2.0f, gfx::Rect(0, 0, 1600, 1200)); | 571 VerifyTilesExactlyCoverRect(4.0f, gfx::Rect(0, 0, 3200, 2400)); |
| 562 VerifyTilesExactlyCoverRect(2.0f, gfx::Rect(512, 365, 253, 182)); | 572 VerifyTilesExactlyCoverRect(4.0f, gfx::Rect(1024, 730, 506, 364)); |
| 563 | 573 |
| 564 float scale = 6.7f; | 574 float scale = 6.7f; |
| 565 gfx::Size bounds(800, 600); | 575 gfx::Size bounds(800, 600); |
| 566 gfx::Rect full_rect(gfx::ScaleToCeiledSize(bounds, scale)); | 576 gfx::Rect full_rect(gfx::ScaleToCeiledSize(bounds, scale)); |
| 567 Initialize(gfx::Size(256, 512), 5.2f, bounds); | 577 Initialize(gfx::Size(256, 512), 5.2f, bounds); |
| 568 VerifyTilesExactlyCoverRect(scale, full_rect); | 578 VerifyTilesExactlyCoverRect(scale, full_rect); |
| 569 VerifyTilesExactlyCoverRect(scale, gfx::Rect(2014, 1579, 867, 1033)); | 579 VerifyTilesExactlyCoverRect(scale, gfx::Rect(2014, 1579, 867, 1033)); |
| 570 } | 580 } |
| 571 | 581 |
| 572 TEST_F(PictureLayerTilingIteratorTest, IteratorEmptyRect) { | 582 TEST_F(PictureLayerTilingIteratorTest, IteratorEmptyRect) { |
| 573 Initialize(gfx::Size(100, 100), 1.0f, gfx::Size(800, 600)); | 583 Initialize(gfx::Size(100, 100), 1.0f, gfx::Size(800, 600)); |
| 574 | 584 |
| 575 gfx::Rect empty; | 585 gfx::Rect empty; |
| 576 PictureLayerTiling::CoverageIterator iter(tiling_.get(), 1.0f, empty); | 586 PictureLayerTiling::CoverageIterator iter(tiling_.get(), 1.0f, empty); |
| 577 EXPECT_FALSE(iter); | 587 EXPECT_FALSE(iter); |
| 578 } | 588 } |
| 579 | 589 |
| 580 TEST_F(PictureLayerTilingIteratorTest, NonIntersectingRect) { | 590 TEST_F(PictureLayerTilingIteratorTest, NonIntersectingRect) { |
| 581 Initialize(gfx::Size(100, 100), 1.0f, gfx::Size(800, 600)); | 591 Initialize(gfx::Size(100, 100), 1.0f, gfx::Size(800, 600)); |
| 582 gfx::Rect non_intersecting(1000, 1000, 50, 50); | 592 gfx::Rect non_intersecting(1000, 1000, 50, 50); |
| 583 PictureLayerTiling::CoverageIterator iter(tiling_.get(), 1, non_intersecting); | 593 PictureLayerTiling::CoverageIterator iter(tiling_.get(), 1, non_intersecting); |
| 584 EXPECT_FALSE(iter); | 594 EXPECT_FALSE(iter); |
| 585 } | 595 } |
| 586 | 596 |
| 587 TEST_F(PictureLayerTilingIteratorTest, LayerEdgeTextureCoordinates) { | 597 TEST_F(PictureLayerTilingIteratorTest, LayerEdgeTextureCoordinates) { |
| 588 Initialize(gfx::Size(300, 300), 1.0f, gfx::Size(256, 256)); | 598 Initialize(gfx::Size(300, 300), 1.0f, gfx::Size(256, 256)); |
| 589 // All of these sizes are 256x256, scaled and ceiled. | 599 // All of these sizes are 256x256, scaled and ceiled. |
| 590 VerifyTilesExactlyCoverRect(1.0f, gfx::Rect(0, 0, 256, 256)); | 600 VerifyTilesExactlyCoverRect(1.0f, gfx::Rect(0, 0, 256, 256)); |
| 591 VerifyTilesExactlyCoverRect(0.8f, gfx::Rect(0, 0, 205, 205)); | |
| 592 VerifyTilesExactlyCoverRect(1.2f, gfx::Rect(0, 0, 308, 308)); | 601 VerifyTilesExactlyCoverRect(1.2f, gfx::Rect(0, 0, 308, 308)); |
| 593 } | 602 } |
| 594 | 603 |
| 595 TEST_F(PictureLayerTilingIteratorTest, NonContainedDestRect) { | 604 TEST_F(PictureLayerTilingIteratorTest, NonContainedDestRect) { |
| 596 Initialize(gfx::Size(100, 100), 1.0f, gfx::Size(400, 400)); | 605 Initialize(gfx::Size(100, 100), 1.0f, gfx::Size(400, 400)); |
| 597 | 606 |
| 598 // Too large in all dimensions | 607 // Too large in all dimensions |
| 599 VerifyTilesCoverNonContainedRect(1.0f, gfx::Rect(-1000, -1000, 2000, 2000)); | 608 VerifyTilesCoverNonContainedRect(1.0f, gfx::Rect(-1000, -1000, 2000, 2000)); |
| 600 VerifyTilesCoverNonContainedRect(1.5f, gfx::Rect(-1000, -1000, 2000, 2000)); | 609 VerifyTilesCoverNonContainedRect(1.5f, gfx::Rect(-1000, -1000, 2000, 2000)); |
| 601 VerifyTilesCoverNonContainedRect(0.5f, gfx::Rect(-1000, -1000, 2000, 2000)); | |
| 602 | 610 |
| 603 // Partially covering content, but too large | 611 // Partially covering content, but too large |
| 604 VerifyTilesCoverNonContainedRect(1.0f, gfx::Rect(-1000, 100, 2000, 100)); | 612 VerifyTilesCoverNonContainedRect(1.0f, gfx::Rect(-1000, 100, 2000, 100)); |
| 605 VerifyTilesCoverNonContainedRect(1.5f, gfx::Rect(-1000, 100, 2000, 100)); | 613 VerifyTilesCoverNonContainedRect(1.5f, gfx::Rect(-1000, 100, 2000, 100)); |
| 606 VerifyTilesCoverNonContainedRect(0.5f, gfx::Rect(-1000, 100, 2000, 100)); | |
| 607 } | 614 } |
| 608 | 615 |
| 609 static void TileExists(bool exists, Tile* tile, | 616 static void TileExists(bool exists, Tile* tile, |
| 610 const gfx::Rect& geometry_rect) { | 617 const gfx::Rect& geometry_rect) { |
| 611 EXPECT_EQ(exists, tile != NULL) << geometry_rect.ToString(); | 618 EXPECT_EQ(exists, tile != NULL) << geometry_rect.ToString(); |
| 612 } | 619 } |
| 613 | 620 |
| 614 TEST_F(PictureLayerTilingIteratorTest, TilesExist) { | 621 TEST_F(PictureLayerTilingIteratorTest, TilesExist) { |
| 615 gfx::Size layer_bounds(1099, 801); | 622 gfx::Size layer_bounds(1099, 801); |
| 616 Initialize(gfx::Size(100, 100), 1.f, layer_bounds); | 623 Initialize(gfx::Size(100, 100), 1.f, layer_bounds); |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 959 tiling_->SetRasterSourceAndResize(raster_source); | 966 tiling_->SetRasterSourceAndResize(raster_source); |
| 960 | 967 |
| 961 // Tile size in the tiling should be resized to 250x200. | 968 // Tile size in the tiling should be resized to 250x200. |
| 962 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width()); | 969 EXPECT_EQ(250, tiling_->TilingDataForTesting().max_texture_size().width()); |
| 963 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height()); | 970 EXPECT_EQ(200, tiling_->TilingDataForTesting().max_texture_size().height()); |
| 964 EXPECT_EQ(0u, tiling_->AllTilesForTesting().size()); | 971 EXPECT_EQ(0u, tiling_->AllTilesForTesting().size()); |
| 965 } | 972 } |
| 966 | 973 |
| 967 // This test runs into floating point issues because of big numbers. | 974 // This test runs into floating point issues because of big numbers. |
| 968 TEST_F(PictureLayerTilingIteratorTest, GiantRect) { | 975 TEST_F(PictureLayerTilingIteratorTest, GiantRect) { |
| 976 loose_texel_extent_check_ = true; | |
| 977 | |
| 969 gfx::Size tile_size(256, 256); | 978 gfx::Size tile_size(256, 256); |
| 970 gfx::Size layer_size(33554432, 33554432); | 979 gfx::Size layer_size(33554432, 33554432); |
| 971 float contents_scale = 1.f; | 980 float contents_scale = 1.f; |
| 972 | 981 |
| 973 client_.SetTileSize(tile_size); | 982 client_.SetTileSize(tile_size); |
| 974 scoped_refptr<FakeRasterSource> raster_source = | 983 scoped_refptr<FakeRasterSource> raster_source = |
| 975 FakeRasterSource::CreateEmpty(layer_size); | 984 FakeRasterSource::CreateEmpty(layer_size); |
| 976 tiling_ = TestablePictureLayerTiling::Create(PENDING_TREE, contents_scale, | 985 tiling_ = TestablePictureLayerTiling::Create(PENDING_TREE, contents_scale, |
| 977 raster_source, &client_, | 986 raster_source, &client_, |
| 978 LayerTreeSettings()); | 987 LayerTreeSettings()); |
| 979 | 988 |
| 980 gfx::Rect content_rect(25554432, 25554432, 950, 860); | 989 gfx::Rect content_rect(25554432, 25554432, 950, 860); |
| 981 VerifyTilesExactlyCoverRect(contents_scale, content_rect); | 990 VerifyTilesExactlyCoverRect(contents_scale, content_rect); |
| 982 } | 991 } |
| 983 | 992 |
| 993 TEST_F(PictureLayerTilingIteratorTest, QuadShouldNotUseLastHalfTexel) { | |
|
enne (OOO)
2016/09/09 21:46:34
This is the real test for issue 643464, right?
trchen
2016/09/09 23:39:19
Yep!
| |
| 994 Initialize(gfx::Size(100, 100), 1.f, gfx::Size(198, 198)); | |
| 995 // Creates a situation that tile bounds get rounded up by almost 1px in the | |
| 996 // dest space. This test verifies that even in such situation the coverage | |
| 997 // iterator won't generate a texture rect that can potentially get clamped. | |
| 998 VerifyTilesExactlyCoverRect(1.000005f, gfx::Rect(199, 199)); | |
| 999 } | |
| 1000 | |
| 1001 static void TileHasGeometryRect(const gfx::Rect& expected_rect, | |
| 1002 Tile* tile, | |
| 1003 const gfx::Rect& geometry_rect) { | |
| 1004 EXPECT_EQ(expected_rect, geometry_rect); | |
| 1005 } | |
| 1006 | |
| 1007 TEST_F(PictureLayerTilingIteratorTest, UseLeastTilesToCover) { | |
| 1008 // This test verifies that when a dest pixel can be covered by more than | |
|
enne (OOO)
2016/09/09 21:46:34
Can you also DCHECK via TilingData that both tiles
trchen
2016/09/09 23:39:19
Done.
| |
| 1009 // one tiles, least number of tiles gets emitted. | |
| 1010 Initialize(gfx::Size(100, 100), 1.f, gfx::Size(1000, 1000)); | |
| 1011 VerifyTilesExactlyCoverRect(2.f, gfx::Rect(199, 199)); | |
| 1012 VerifyTiles(2.f, gfx::Rect(199, 199), | |
| 1013 base::Bind(&TileHasGeometryRect, gfx::Rect(199, 199))); | |
| 1014 } | |
| 1015 | |
| 1016 TEST_F(PictureLayerTilingIteratorTest, UseLeastTilesToCover2) { | |
| 1017 // Similar to above test, but with an internal tile. | |
|
enne (OOO)
2016/09/09 21:46:34
Ditto here.
trchen
2016/09/09 23:39:19
Done.
| |
| 1018 Initialize(gfx::Size(100, 100), 1.f, gfx::Size(1000, 1000)); | |
| 1019 gfx::Rect dest_rect(197, 393, 198, 198); | |
| 1020 VerifyTilesExactlyCoverRect(2.f, dest_rect); | |
| 1021 VerifyTiles(2.f, dest_rect, base::Bind(&TileHasGeometryRect, dest_rect)); | |
| 1022 } | |
| 1023 | |
| 1024 TEST_F(PictureLayerTilingIteratorTest, TightCover) { | |
| 1025 // This test verifies that the whole dest rect is still fully covered when | |
| 1026 // numerical condition is tight. | |
| 1027 // In this test, the right edge of tile #37 almost (but failed to) covered | |
| 1028 // grid line x = 9654. Tile #38 needs to reach hard to x = 9653 to make up | |
| 1029 // for this. | |
| 1030 Initialize(gfx::Size(256, 256), 1.f, gfx::Size(10000, 1)); | |
| 1031 float dest_scale = 16778082.f / 16777216.f; // 0b1.00000000 00000011 01100010 | |
| 1032 VerifyTilesExactlyCoverRect(dest_scale, gfx::Rect(10001, 2)); | |
| 1033 } | |
| 1034 | |
| 1035 TEST_F(PictureLayerTilingIteratorTest, TightCover2) { | |
| 1036 // In this test, the left edge of tile #38 almost (but failed to) covered | |
| 1037 // grid line x = 9653. Tile #37 needs to reach hard to x = 9654 to make up | |
| 1038 // for this. | |
| 1039 Initialize(gfx::Size(256, 256), 1.f, gfx::Size(10000, 1)); | |
| 1040 float dest_scale = 16778088.f / 16777216.f; // 0b1.00000000 00000011 01101000 | |
| 1041 VerifyTilesExactlyCoverRect(dest_scale, gfx::Rect(10001, 2)); | |
| 1042 } | |
| 1043 | |
| 984 } // namespace | 1044 } // namespace |
| 985 } // namespace cc | 1045 } // namespace cc |
| OLD | NEW |