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