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/picture_layer_tiling.h" | 5 #include "cc/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 24 matching lines...) Expand all Loading... |
35 // Iterators are not valid if this ratio is too large (i.e. the | 35 // Iterators are not valid if this ratio is too large (i.e. the |
36 // tiling is too high-res for a low-res destination rect.) This is an | 36 // tiling is too high-res for a low-res destination rect.) This is an |
37 // artifact of snapping geometry to integer coordinates and then mapping | 37 // artifact of snapping geometry to integer coordinates and then mapping |
38 // back to floating point texture coordinates. | 38 // back to floating point texture coordinates. |
39 float dest_to_contents_scale = tiling_->contents_scale() / rect_scale; | 39 float dest_to_contents_scale = tiling_->contents_scale() / rect_scale; |
40 ASSERT_LE(dest_to_contents_scale, 2.0); | 40 ASSERT_LE(dest_to_contents_scale, 2.0); |
41 | 41 |
42 Region remaining = expect_rect; | 42 Region remaining = expect_rect; |
43 for (PictureLayerTiling::Iterator iter(tiling_.get(), | 43 for (PictureLayerTiling::Iterator iter(tiling_.get(), |
44 rect_scale, | 44 rect_scale, |
45 request_rect); | 45 request_rect, |
| 46 PictureLayerTiling::LayerDeviceAlignm
entUnknown); |
46 iter; | 47 iter; |
47 ++iter) { | 48 ++iter) { |
48 | 49 |
49 // Geometry cannot overlap previous geometry at all | 50 // Geometry cannot overlap previous geometry at all |
50 gfx::Rect geometry = iter.geometry_rect(); | 51 gfx::Rect geometry = iter.geometry_rect(); |
51 EXPECT_TRUE(expect_rect.Contains(geometry)); | 52 EXPECT_TRUE(expect_rect.Contains(geometry)); |
52 EXPECT_TRUE(remaining.Contains(geometry)); | 53 EXPECT_TRUE(remaining.Contains(geometry)); |
53 remaining.Subtract(geometry); | 54 remaining.Subtract(geometry); |
54 | 55 |
55 // Sanity check that texture coords are within the texture rect. | 56 // Sanity check that texture coords are within the texture rect. |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 gfx::Rect full_rect(gfx::ToCeiledSize(gfx::ScaleSize(bounds, scale))); | 137 gfx::Rect full_rect(gfx::ToCeiledSize(gfx::ScaleSize(bounds, scale))); |
137 Initialize(gfx::Size(256, 512), 5.2f, bounds); | 138 Initialize(gfx::Size(256, 512), 5.2f, bounds); |
138 VerifyTilesExactlyCoverRect(scale, full_rect); | 139 VerifyTilesExactlyCoverRect(scale, full_rect); |
139 VerifyTilesExactlyCoverRect(scale, gfx::Rect(2014, 1579, 867, 1033)); | 140 VerifyTilesExactlyCoverRect(scale, gfx::Rect(2014, 1579, 867, 1033)); |
140 } | 141 } |
141 | 142 |
142 TEST_F(PictureLayerTilingIteratorTest, IteratorEmptyRect) { | 143 TEST_F(PictureLayerTilingIteratorTest, IteratorEmptyRect) { |
143 Initialize(gfx::Size(100, 100), 1.0f, gfx::Size(800, 600)); | 144 Initialize(gfx::Size(100, 100), 1.0f, gfx::Size(800, 600)); |
144 | 145 |
145 gfx::Rect empty; | 146 gfx::Rect empty; |
146 PictureLayerTiling::Iterator iter(tiling_.get(), 1.0f, empty); | 147 PictureLayerTiling::Iterator iter(tiling_.get(), 1.0f, empty, |
| 148 PictureLayerTiling::LayerDeviceAlignmentUnkn
own); |
147 EXPECT_FALSE(iter); | 149 EXPECT_FALSE(iter); |
148 } | 150 } |
149 | 151 |
150 TEST_F(PictureLayerTilingIteratorTest, NonIntersectingRect) { | 152 TEST_F(PictureLayerTilingIteratorTest, NonIntersectingRect) { |
151 Initialize(gfx::Size(100, 100), 1.0f, gfx::Size(800, 600)); | 153 Initialize(gfx::Size(100, 100), 1.0f, gfx::Size(800, 600)); |
152 gfx::Rect non_intersecting(1000, 1000, 50, 50); | 154 gfx::Rect non_intersecting(1000, 1000, 50, 50); |
153 PictureLayerTiling::Iterator iter(tiling_.get(), 1, non_intersecting); | 155 PictureLayerTiling::Iterator iter(tiling_.get(), 1, non_intersecting, |
| 156 PictureLayerTiling::LayerDeviceAlignmentUnkn
own); |
154 EXPECT_FALSE(iter); | 157 EXPECT_FALSE(iter); |
155 } | 158 } |
156 | 159 |
157 TEST_F(PictureLayerTilingIteratorTest, LayerEdgeTextureCoordinates) { | 160 TEST_F(PictureLayerTilingIteratorTest, LayerEdgeTextureCoordinates) { |
158 Initialize(gfx::Size(300, 300), 1.0f, gfx::Size(256, 256)); | 161 Initialize(gfx::Size(300, 300), 1.0f, gfx::Size(256, 256)); |
159 // All of these sizes are 256x256, scaled and ceiled. | 162 // All of these sizes are 256x256, scaled and ceiled. |
160 VerifyTilesExactlyCoverRect(1.0f, gfx::Rect(gfx::Size(256, 256))); | 163 VerifyTilesExactlyCoverRect(1.0f, gfx::Rect(gfx::Size(256, 256))); |
161 VerifyTilesExactlyCoverRect(0.8f, gfx::Rect(gfx::Size(205, 205))); | 164 VerifyTilesExactlyCoverRect(0.8f, gfx::Rect(gfx::Size(205, 205))); |
162 VerifyTilesExactlyCoverRect(1.2f, gfx::Rect(gfx::Size(308, 308))); | 165 VerifyTilesExactlyCoverRect(1.2f, gfx::Rect(gfx::Size(308, 308))); |
163 } | 166 } |
164 | 167 |
165 TEST_F(PictureLayerTilingIteratorTest, NonContainedDestRect) { | 168 TEST_F(PictureLayerTilingIteratorTest, NonContainedDestRect) { |
166 Initialize(gfx::Size(100, 100), 1.0f, gfx::Size(400, 400)); | 169 Initialize(gfx::Size(100, 100), 1.0f, gfx::Size(400, 400)); |
167 | 170 |
168 // Too large in all dimensions | 171 // Too large in all dimensions |
169 VerifyTilesCoverNonContainedRect(1.0f, gfx::Rect(-1000, -1000, 2000, 2000)); | 172 VerifyTilesCoverNonContainedRect(1.0f, gfx::Rect(-1000, -1000, 2000, 2000)); |
170 VerifyTilesCoverNonContainedRect(1.5f, gfx::Rect(-1000, -1000, 2000, 2000)); | 173 VerifyTilesCoverNonContainedRect(1.5f, gfx::Rect(-1000, -1000, 2000, 2000)); |
171 VerifyTilesCoverNonContainedRect(0.5f, gfx::Rect(-1000, -1000, 2000, 2000)); | 174 VerifyTilesCoverNonContainedRect(0.5f, gfx::Rect(-1000, -1000, 2000, 2000)); |
172 | 175 |
173 // Partially covering content, but too large | 176 // Partially covering content, but too large |
174 VerifyTilesCoverNonContainedRect(1.0f, gfx::Rect(-1000, 100, 2000, 100)); | 177 VerifyTilesCoverNonContainedRect(1.0f, gfx::Rect(-1000, 100, 2000, 100)); |
175 VerifyTilesCoverNonContainedRect(1.5f, gfx::Rect(-1000, 100, 2000, 100)); | 178 VerifyTilesCoverNonContainedRect(1.5f, gfx::Rect(-1000, 100, 2000, 100)); |
176 VerifyTilesCoverNonContainedRect(0.5f, gfx::Rect(-1000, 100, 2000, 100)); | 179 VerifyTilesCoverNonContainedRect(0.5f, gfx::Rect(-1000, 100, 2000, 100)); |
177 } | 180 } |
178 | 181 |
179 } // namespace | 182 } // namespace |
180 } // namespace cc | 183 } // namespace cc |
OLD | NEW |