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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "cc/tiled_layer_impl.h" | 7 #include "cc/tiled_layer_impl.h" |
8 | 8 |
9 #include "cc/append_quads_data.h" | 9 #include "cc/append_quads_data.h" |
10 #include "cc/layer_tiling_data.h" | 10 #include "cc/layer_tiling_data.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 ResourceProvider::ResourceId resourceId = 1; | 39 ResourceProvider::ResourceId resourceId = 1; |
40 for (int i = 0; i < tiler->numTilesX(); ++i) | 40 for (int i = 0; i < tiler->numTilesX(); ++i) |
41 for (int j = 0; j < tiler->numTilesY(); ++j) | 41 for (int j = 0; j < tiler->numTilesY(); ++j) |
42 layer->pushTileProperties(i, j, resourceId++, gfx::Rect(0, 0, 1, 1),
false); | 42 layer->pushTileProperties(i, j, resourceId++, gfx::Rect(0, 0, 1, 1),
false); |
43 | 43 |
44 return layer.Pass(); | 44 return layer.Pass(); |
45 } | 45 } |
46 | 46 |
47 TEST(TiledLayerImplTest, emptyQuadList) | 47 TEST(TiledLayerImplTest, emptyQuadList) |
48 { | 48 { |
| 49 DebugScopedSetImplThread scopedImplThread; |
| 50 |
49 const gfx::Size tileSize(90, 90); | 51 const gfx::Size tileSize(90, 90); |
50 const int numTilesX = 8; | 52 const int numTilesX = 8; |
51 const int numTilesY = 4; | 53 const int numTilesY = 4; |
52 const gfx::Size layerSize(tileSize.width() * numTilesX, tileSize.height() *
numTilesY); | 54 const gfx::Size layerSize(tileSize.width() * numTilesX, tileSize.height() *
numTilesY); |
53 | 55 |
54 // Verify default layer does creates quads | 56 // Verify default layer does creates quads |
55 { | 57 { |
56 scoped_ptr<TiledLayerImpl> layer = createLayer(tileSize, layerSize, Laye
rTilingData::NoBorderTexels); | 58 scoped_ptr<TiledLayerImpl> layer = createLayer(tileSize, layerSize, Laye
rTilingData::NoBorderTexels); |
57 MockQuadCuller quadCuller; | 59 MockQuadCuller quadCuller; |
58 AppendQuadsData data; | 60 AppendQuadsData data; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 | 94 |
93 MockQuadCuller quadCuller; | 95 MockQuadCuller quadCuller; |
94 AppendQuadsData data; | 96 AppendQuadsData data; |
95 layer->appendQuads(quadCuller, data); | 97 layer->appendQuads(quadCuller, data); |
96 EXPECT_EQ(quadCuller.quadList().size(), 0u); | 98 EXPECT_EQ(quadCuller.quadList().size(), 0u); |
97 } | 99 } |
98 } | 100 } |
99 | 101 |
100 TEST(TiledLayerImplTest, checkerboarding) | 102 TEST(TiledLayerImplTest, checkerboarding) |
101 { | 103 { |
| 104 DebugScopedSetImplThread scopedImplThread; |
| 105 |
102 const gfx::Size tileSize(10, 10); | 106 const gfx::Size tileSize(10, 10); |
103 const int numTilesX = 2; | 107 const int numTilesX = 2; |
104 const int numTilesY = 2; | 108 const int numTilesY = 2; |
105 const gfx::Size layerSize(tileSize.width() * numTilesX, tileSize.height() *
numTilesY); | 109 const gfx::Size layerSize(tileSize.width() * numTilesX, tileSize.height() *
numTilesY); |
106 | 110 |
107 scoped_ptr<TiledLayerImpl> layer = createLayer(tileSize, layerSize, LayerTil
ingData::NoBorderTexels); | 111 scoped_ptr<TiledLayerImpl> layer = createLayer(tileSize, layerSize, LayerTil
ingData::NoBorderTexels); |
108 | 112 |
109 // No checkerboarding | 113 // No checkerboarding |
110 { | 114 { |
111 MockQuadCuller quadCuller; | 115 MockQuadCuller quadCuller; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 { \ | 155 { \ |
152 testFixtureName(LayerTilingData::NoBorderTexels); \ | 156 testFixtureName(LayerTilingData::NoBorderTexels); \ |
153 } \ | 157 } \ |
154 TEST(TiledLayerImplTest, testFixtureName##HasBorders) \ | 158 TEST(TiledLayerImplTest, testFixtureName##HasBorders) \ |
155 { \ | 159 { \ |
156 testFixtureName(LayerTilingData::HasBorderTexels);\ | 160 testFixtureName(LayerTilingData::HasBorderTexels);\ |
157 } | 161 } |
158 | 162 |
159 static void coverageVisibleRectOnTileBoundaries(LayerTilingData::BorderTexelOpti
on borders) | 163 static void coverageVisibleRectOnTileBoundaries(LayerTilingData::BorderTexelOpti
on borders) |
160 { | 164 { |
| 165 DebugScopedSetImplThread scopedImplThread; |
| 166 |
161 gfx::Size layerSize(1000, 1000); | 167 gfx::Size layerSize(1000, 1000); |
162 QuadList quads; | 168 QuadList quads; |
163 SharedQuadStateList sharedStates; | 169 SharedQuadStateList sharedStates; |
164 getQuads(quads, sharedStates, gfx::Size(100, 100), layerSize, borders, gfx::
Rect(gfx::Point(), layerSize)); | 170 getQuads(quads, sharedStates, gfx::Size(100, 100), layerSize, borders, gfx::
Rect(gfx::Point(), layerSize)); |
165 verifyQuadsExactlyCoverRect(quads, gfx::Rect(gfx::Point(), layerSize)); | 171 verifyQuadsExactlyCoverRect(quads, gfx::Rect(gfx::Point(), layerSize)); |
166 } | 172 } |
167 WITH_AND_WITHOUT_BORDER_TEST(coverageVisibleRectOnTileBoundaries); | 173 WITH_AND_WITHOUT_BORDER_TEST(coverageVisibleRectOnTileBoundaries); |
168 | 174 |
169 static void coverageVisibleRectIntersectsTiles(LayerTilingData::BorderTexelOptio
n borders) | 175 static void coverageVisibleRectIntersectsTiles(LayerTilingData::BorderTexelOptio
n borders) |
170 { | 176 { |
| 177 DebugScopedSetImplThread scopedImplThread; |
| 178 |
171 // This rect intersects the middle 3x3 of the 5x5 tiles. | 179 // This rect intersects the middle 3x3 of the 5x5 tiles. |
172 gfx::Point topLeft(65, 73); | 180 gfx::Point topLeft(65, 73); |
173 gfx::Point bottomRight(182, 198); | 181 gfx::Point bottomRight(182, 198); |
174 gfx::Rect visibleContentRect = gfx::BoundingRect(topLeft, bottomRight); | 182 gfx::Rect visibleContentRect = gfx::BoundingRect(topLeft, bottomRight); |
175 | 183 |
176 gfx::Size layerSize(250, 250); | 184 gfx::Size layerSize(250, 250); |
177 QuadList quads; | 185 QuadList quads; |
178 SharedQuadStateList sharedStates; | 186 SharedQuadStateList sharedStates; |
179 getQuads(quads, sharedStates, gfx::Size(50, 50), gfx::Size(250, 250), LayerT
ilingData::NoBorderTexels, visibleContentRect); | 187 getQuads(quads, sharedStates, gfx::Size(50, 50), gfx::Size(250, 250), LayerT
ilingData::NoBorderTexels, visibleContentRect); |
180 verifyQuadsExactlyCoverRect(quads, visibleContentRect); | 188 verifyQuadsExactlyCoverRect(quads, visibleContentRect); |
181 } | 189 } |
182 WITH_AND_WITHOUT_BORDER_TEST(coverageVisibleRectIntersectsTiles); | 190 WITH_AND_WITHOUT_BORDER_TEST(coverageVisibleRectIntersectsTiles); |
183 | 191 |
184 static void coverageVisibleRectIntersectsBounds(LayerTilingData::BorderTexelOpti
on borders) | 192 static void coverageVisibleRectIntersectsBounds(LayerTilingData::BorderTexelOpti
on borders) |
185 { | 193 { |
| 194 DebugScopedSetImplThread scopedImplThread; |
| 195 |
186 gfx::Size layerSize(220, 210); | 196 gfx::Size layerSize(220, 210); |
187 gfx::Rect visibleContentRect(gfx::Point(), layerSize); | 197 gfx::Rect visibleContentRect(gfx::Point(), layerSize); |
188 QuadList quads; | 198 QuadList quads; |
189 SharedQuadStateList sharedStates; | 199 SharedQuadStateList sharedStates; |
190 getQuads(quads, sharedStates, gfx::Size(100, 100), layerSize, LayerTilingDat
a::NoBorderTexels, visibleContentRect); | 200 getQuads(quads, sharedStates, gfx::Size(100, 100), layerSize, LayerTilingDat
a::NoBorderTexels, visibleContentRect); |
191 verifyQuadsExactlyCoverRect(quads, visibleContentRect); | 201 verifyQuadsExactlyCoverRect(quads, visibleContentRect); |
192 } | 202 } |
193 WITH_AND_WITHOUT_BORDER_TEST(coverageVisibleRectIntersectsBounds); | 203 WITH_AND_WITHOUT_BORDER_TEST(coverageVisibleRectIntersectsBounds); |
194 | 204 |
195 TEST(TiledLayerImplTest, textureInfoForLayerNoBorders) | 205 TEST(TiledLayerImplTest, textureInfoForLayerNoBorders) |
196 { | 206 { |
| 207 DebugScopedSetImplThread scopedImplThread; |
| 208 |
197 gfx::Size tileSize(50, 50); | 209 gfx::Size tileSize(50, 50); |
198 gfx::Size layerSize(250, 250); | 210 gfx::Size layerSize(250, 250); |
199 QuadList quads; | 211 QuadList quads; |
200 SharedQuadStateList sharedStates; | 212 SharedQuadStateList sharedStates; |
201 getQuads(quads, sharedStates, tileSize, layerSize, LayerTilingData::NoBorder
Texels, gfx::Rect(gfx::Point(), layerSize)); | 213 getQuads(quads, sharedStates, tileSize, layerSize, LayerTilingData::NoBorder
Texels, gfx::Rect(gfx::Point(), layerSize)); |
202 | 214 |
203 for (size_t i = 0; i < quads.size(); ++i) { | 215 for (size_t i = 0; i < quads.size(); ++i) { |
204 ASSERT_EQ(quads[i]->material(), DrawQuad::TiledContent) << quadString <<
i; | 216 ASSERT_EQ(quads[i]->material(), DrawQuad::TiledContent) << quadString <<
i; |
205 TileDrawQuad* quad = static_cast<TileDrawQuad*>(quads[i]); | 217 TileDrawQuad* quad = static_cast<TileDrawQuad*>(quads[i]); |
206 | 218 |
207 EXPECT_NE(quad->resourceId(), 0u) << quadString << i; | 219 EXPECT_NE(quad->resourceId(), 0u) << quadString << i; |
208 EXPECT_EQ(quad->textureOffset(), gfx::Vector2d()) << quadString << i; | 220 EXPECT_EQ(quad->textureOffset(), gfx::Vector2d()) << quadString << i; |
209 EXPECT_EQ(quad->textureSize(), tileSize) << quadString << i; | 221 EXPECT_EQ(quad->textureSize(), tileSize) << quadString << i; |
210 EXPECT_EQ(gfx::Rect(0, 0, 1, 1), quad->opaqueRect()) << quadString << i; | 222 EXPECT_EQ(gfx::Rect(0, 0, 1, 1), quad->opaqueRect()) << quadString << i; |
211 } | 223 } |
212 } | 224 } |
213 | 225 |
214 TEST(TiledLayerImplTest, tileOpaqueRectForLayerNoBorders) | 226 TEST(TiledLayerImplTest, tileOpaqueRectForLayerNoBorders) |
215 { | 227 { |
| 228 DebugScopedSetImplThread scopedImplThread; |
| 229 |
216 gfx::Size tileSize(50, 50); | 230 gfx::Size tileSize(50, 50); |
217 gfx::Size layerSize(250, 250); | 231 gfx::Size layerSize(250, 250); |
218 QuadList quads; | 232 QuadList quads; |
219 SharedQuadStateList sharedStates; | 233 SharedQuadStateList sharedStates; |
220 getQuads(quads, sharedStates, tileSize, layerSize, LayerTilingData::NoBorder
Texels, gfx::Rect(gfx::Point(), layerSize)); | 234 getQuads(quads, sharedStates, tileSize, layerSize, LayerTilingData::NoBorder
Texels, gfx::Rect(gfx::Point(), layerSize)); |
221 | 235 |
222 for (size_t i = 0; i < quads.size(); ++i) { | 236 for (size_t i = 0; i < quads.size(); ++i) { |
223 ASSERT_EQ(quads[i]->material(), DrawQuad::TiledContent) << quadString <<
i; | 237 ASSERT_EQ(quads[i]->material(), DrawQuad::TiledContent) << quadString <<
i; |
224 TileDrawQuad* quad = static_cast<TileDrawQuad*>(quads[i]); | 238 TileDrawQuad* quad = static_cast<TileDrawQuad*>(quads[i]); |
225 | 239 |
226 EXPECT_EQ(gfx::Rect(0, 0, 1, 1), quad->opaqueRect()) << quadString << i; | 240 EXPECT_EQ(gfx::Rect(0, 0, 1, 1), quad->opaqueRect()) << quadString << i; |
227 } | 241 } |
228 } | 242 } |
229 | 243 |
230 } // namespace | 244 } // namespace |
OLD | NEW |