OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 sharedState = getQuads(quads, tileSize, layerSize, CCLayerTilingData::NoBord
erTexels, IntRect(IntPoint(), layerSize)); | 255 sharedState = getQuads(quads, tileSize, layerSize, CCLayerTilingData::NoBord
erTexels, IntRect(IntPoint(), layerSize)); |
256 | 256 |
257 for (size_t i = 0; i < quads.size(); ++i) { | 257 for (size_t i = 0; i < quads.size(); ++i) { |
258 ASSERT_EQ(quads[i]->material(), CCDrawQuad::TiledContent) << quadString
<< i; | 258 ASSERT_EQ(quads[i]->material(), CCDrawQuad::TiledContent) << quadString
<< i; |
259 CCTileDrawQuad* quad = static_cast<CCTileDrawQuad*>(quads[i].get()); | 259 CCTileDrawQuad* quad = static_cast<CCTileDrawQuad*>(quads[i].get()); |
260 | 260 |
261 EXPECT_EQ(IntRect(0, 0, 1, 1), quad->opaqueRect()) << quadString << i; | 261 EXPECT_EQ(IntRect(0, 0, 1, 1), quad->opaqueRect()) << quadString << i; |
262 } | 262 } |
263 } | 263 } |
264 | 264 |
265 TEST(CCTiledLayerImplTest, backgroundCoversViewport) | |
266 { | |
267 DebugScopedSetImplThread scopedImplThread; | |
268 | |
269 const IntSize tileSize(10, 10); | |
270 const int numTilesX = 2; | |
271 const int numTilesY = 2; | |
272 const unsigned numTiles = numTilesX * numTilesY; | |
273 const IntSize layerSize(tileSize.width() * numTilesX, tileSize.height() * nu
mTilesY); | |
274 OwnPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, CCLayerTil
ingData::NoBorderTexels); | |
275 layer->setBackgroundColor(Color::gray); | |
276 layer->setBackgroundCoversViewport(true); | |
277 | |
278 // No gutter rects | |
279 { | |
280 IntRect clipRect = IntRect(IntPoint(), layerSize); | |
281 layer->setClipRect(clipRect); | |
282 layer->setVisibleLayerRect(IntRect(IntPoint(), layerSize)); | |
283 | |
284 OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState
(); | |
285 | |
286 MockCCQuadCuller quadCuller; | |
287 bool usedCheckerboard = false; | |
288 layer->appendQuads(quadCuller, sharedQuadState.get(), usedCheckerboard); | |
289 EXPECT_EQ(quadCuller.quadList().size(), numTiles); | |
290 | |
291 for (size_t i = 0; i < quadCuller.quadList().size(); ++i) | |
292 EXPECT_EQ(quadCuller.quadList()[i]->material(), CCDrawQuad::TiledCon
tent); | |
293 } | |
294 | |
295 // Empty visible content area (fullscreen gutter rect) | |
296 { | |
297 IntRect clipRect = IntRect(100, 100, 100, 100); | |
298 layer->setClipRect(clipRect); | |
299 layer->setVisibleLayerRect(IntRect()); | |
300 | |
301 OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState
(); | |
302 MockCCQuadCuller quadCuller; | |
303 bool usedCheckerboard = false; | |
304 layer->appendQuads(quadCuller, sharedQuadState.get(), usedCheckerboard); | |
305 | |
306 for (size_t i = 0; i < quadCuller.quadList().size(); ++i) | |
307 EXPECT_EQ(quadCuller.quadList()[i]->material(), CCDrawQuad::SolidCol
or); | |
308 | |
309 verifyQuadsExactlyCoverRect(quadCuller.quadList(), clipRect); | |
310 } | |
311 | |
312 // Content area in middle of clip rect (four surrounding gutter rects) | |
313 { | |
314 IntRect clipRect = IntRect(-50, -50, 100, 100); | |
315 layer->setClipRect(clipRect); | |
316 layer->setVisibleLayerRect(IntRect(IntPoint(), layerSize)); | |
317 | |
318 OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState
(); | |
319 MockCCQuadCuller quadCuller; | |
320 bool usedCheckerboard = false; | |
321 layer->appendQuads(quadCuller, sharedQuadState.get(), usedCheckerboard); | |
322 | |
323 unsigned numContentTiles = 0, numGutterTiles = 0; | |
324 for (size_t i = 0; i < quadCuller.quadList().size(); ++i) { | |
325 if (quadCuller.quadList()[i]->material() == CCDrawQuad::TiledContent
) | |
326 numContentTiles++; | |
327 else if (quadCuller.quadList()[i]->material() == CCDrawQuad::SolidCo
lor) | |
328 numGutterTiles++; | |
329 } | |
330 EXPECT_EQ(numContentTiles, numTiles); | |
331 EXPECT_GE(numGutterTiles, 4u); | |
332 | |
333 verifyQuadsExactlyCoverRect(quadCuller.quadList(), clipRect); | |
334 } | |
335 } | |
336 | |
337 } // namespace | 265 } // namespace |
OLD | NEW |