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 "CCTiledLayerImpl.h" | 7 #include "CCTiledLayerImpl.h" |
8 | 8 |
| 9 #include "CCAppendQuadsData.h" |
9 #include "CCLayerTestCommon.h" | 10 #include "CCLayerTestCommon.h" |
10 #include "CCLayerTilingData.h" | 11 #include "CCLayerTilingData.h" |
11 #include "CCSingleThreadProxy.h" | 12 #include "CCSingleThreadProxy.h" |
12 #include "CCTileDrawQuad.h" | 13 #include "CCTileDrawQuad.h" |
13 #include "MockCCQuadCuller.h" | 14 #include "MockCCQuadCuller.h" |
14 #include <gmock/gmock.h> | 15 #include <gmock/gmock.h> |
15 #include <gtest/gtest.h> | 16 #include <gtest/gtest.h> |
16 | 17 |
17 using namespace WebCore; | 18 using namespace WebCore; |
18 using namespace CCLayerTestCommon; | 19 using namespace CCLayerTestCommon; |
(...skipping 30 matching lines...) Expand all Loading... |
49 | 50 |
50 const IntSize tileSize(90, 90); | 51 const IntSize tileSize(90, 90); |
51 const int numTilesX = 8; | 52 const int numTilesX = 8; |
52 const int numTilesY = 4; | 53 const int numTilesY = 4; |
53 const IntSize layerSize(tileSize.width() * numTilesX, tileSize.height() * nu
mTilesY); | 54 const IntSize layerSize(tileSize.width() * numTilesX, tileSize.height() * nu
mTilesY); |
54 | 55 |
55 // Verify default layer does creates quads | 56 // Verify default layer does creates quads |
56 { | 57 { |
57 OwnPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, CCLaye
rTilingData::NoBorderTexels); | 58 OwnPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, CCLaye
rTilingData::NoBorderTexels); |
58 MockCCQuadCuller quadCuller; | 59 MockCCQuadCuller quadCuller; |
59 bool hadMissingTiles = false; | 60 CCAppendQuadsData data; |
60 layer->appendQuads(quadCuller, hadMissingTiles); | 61 layer->appendQuads(quadCuller, data); |
61 const unsigned numTiles = numTilesX * numTilesY; | 62 const unsigned numTiles = numTilesX * numTilesY; |
62 EXPECT_EQ(quadCuller.quadList().size(), numTiles); | 63 EXPECT_EQ(quadCuller.quadList().size(), numTiles); |
63 } | 64 } |
64 | 65 |
65 // Layer with empty visible layer rect produces no quads | 66 // Layer with empty visible layer rect produces no quads |
66 { | 67 { |
67 OwnPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, CCLaye
rTilingData::NoBorderTexels); | 68 OwnPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, CCLaye
rTilingData::NoBorderTexels); |
68 layer->setVisibleContentRect(IntRect()); | 69 layer->setVisibleContentRect(IntRect()); |
69 | 70 |
70 MockCCQuadCuller quadCuller; | 71 MockCCQuadCuller quadCuller; |
71 bool hadMissingTiles = false; | 72 CCAppendQuadsData data; |
72 layer->appendQuads(quadCuller, hadMissingTiles); | 73 layer->appendQuads(quadCuller, data); |
73 EXPECT_EQ(quadCuller.quadList().size(), 0u); | 74 EXPECT_EQ(quadCuller.quadList().size(), 0u); |
74 } | 75 } |
75 | 76 |
76 // Layer with non-intersecting visible layer rect produces no quads | 77 // Layer with non-intersecting visible layer rect produces no quads |
77 { | 78 { |
78 OwnPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, CCLaye
rTilingData::NoBorderTexels); | 79 OwnPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, CCLaye
rTilingData::NoBorderTexels); |
79 | 80 |
80 IntRect outsideBounds(IntPoint(-100, -100), IntSize(50, 50)); | 81 IntRect outsideBounds(IntPoint(-100, -100), IntSize(50, 50)); |
81 layer->setVisibleContentRect(outsideBounds); | 82 layer->setVisibleContentRect(outsideBounds); |
82 | 83 |
83 MockCCQuadCuller quadCuller; | 84 MockCCQuadCuller quadCuller; |
84 bool hadMissingTiles = false; | 85 CCAppendQuadsData data; |
85 layer->appendQuads(quadCuller, hadMissingTiles); | 86 layer->appendQuads(quadCuller, data); |
86 EXPECT_EQ(quadCuller.quadList().size(), 0u); | 87 EXPECT_EQ(quadCuller.quadList().size(), 0u); |
87 } | 88 } |
88 | 89 |
89 // Layer with skips draw produces no quads | 90 // Layer with skips draw produces no quads |
90 { | 91 { |
91 OwnPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, CCLaye
rTilingData::NoBorderTexels); | 92 OwnPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, CCLaye
rTilingData::NoBorderTexels); |
92 layer->setSkipsDraw(true); | 93 layer->setSkipsDraw(true); |
93 | 94 |
94 MockCCQuadCuller quadCuller; | 95 MockCCQuadCuller quadCuller; |
95 bool hadMissingTiles = false; | 96 CCAppendQuadsData data; |
96 layer->appendQuads(quadCuller, hadMissingTiles); | 97 layer->appendQuads(quadCuller, data); |
97 EXPECT_EQ(quadCuller.quadList().size(), 0u); | 98 EXPECT_EQ(quadCuller.quadList().size(), 0u); |
98 } | 99 } |
99 } | 100 } |
100 | 101 |
101 TEST(CCTiledLayerImplTest, checkerboarding) | 102 TEST(CCTiledLayerImplTest, checkerboarding) |
102 { | 103 { |
103 DebugScopedSetImplThread scopedImplThread; | 104 DebugScopedSetImplThread scopedImplThread; |
104 | 105 |
105 const IntSize tileSize(10, 10); | 106 const IntSize tileSize(10, 10); |
106 const int numTilesX = 2; | 107 const int numTilesX = 2; |
107 const int numTilesY = 2; | 108 const int numTilesY = 2; |
108 const IntSize layerSize(tileSize.width() * numTilesX, tileSize.height() * nu
mTilesY); | 109 const IntSize layerSize(tileSize.width() * numTilesX, tileSize.height() * nu
mTilesY); |
109 | 110 |
110 OwnPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, CCLayerTil
ingData::NoBorderTexels); | 111 OwnPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, CCLayerTil
ingData::NoBorderTexels); |
111 | 112 |
112 // No checkerboarding | 113 // No checkerboarding |
113 { | 114 { |
114 MockCCQuadCuller quadCuller; | 115 MockCCQuadCuller quadCuller; |
115 bool hadMissingTiles = false; | 116 CCAppendQuadsData data; |
116 layer->appendQuads(quadCuller, hadMissingTiles); | 117 layer->appendQuads(quadCuller, data); |
117 EXPECT_EQ(quadCuller.quadList().size(), 4u); | 118 EXPECT_EQ(quadCuller.quadList().size(), 4u); |
118 EXPECT_FALSE(hadMissingTiles); | 119 EXPECT_FALSE(data.hadMissingTiles); |
119 | 120 |
120 for (size_t i = 0; i < quadCuller.quadList().size(); ++i) | 121 for (size_t i = 0; i < quadCuller.quadList().size(); ++i) |
121 EXPECT_EQ(quadCuller.quadList()[i]->material(), CCDrawQuad::TiledCon
tent); | 122 EXPECT_EQ(quadCuller.quadList()[i]->material(), CCDrawQuad::TiledCon
tent); |
122 } | 123 } |
123 | 124 |
124 for (int i = 0; i < numTilesX; ++i) | 125 for (int i = 0; i < numTilesX; ++i) |
125 for (int j = 0; j < numTilesY; ++j) | 126 for (int j = 0; j < numTilesY; ++j) |
126 layer->pushTileProperties(i, j, 0, IntRect()); | 127 layer->pushTileProperties(i, j, 0, IntRect()); |
127 | 128 |
128 // All checkerboarding | 129 // All checkerboarding |
129 { | 130 { |
130 MockCCQuadCuller quadCuller; | 131 MockCCQuadCuller quadCuller; |
131 bool hadMissingTiles = false; | 132 CCAppendQuadsData data; |
132 layer->appendQuads(quadCuller, hadMissingTiles); | 133 layer->appendQuads(quadCuller, data); |
133 EXPECT_TRUE(hadMissingTiles); | 134 EXPECT_TRUE(data.hadMissingTiles); |
134 EXPECT_EQ(quadCuller.quadList().size(), 4u); | 135 EXPECT_EQ(quadCuller.quadList().size(), 4u); |
135 for (size_t i = 0; i < quadCuller.quadList().size(); ++i) | 136 for (size_t i = 0; i < quadCuller.quadList().size(); ++i) |
136 EXPECT_NE(quadCuller.quadList()[i]->material(), CCDrawQuad::TiledCon
tent); | 137 EXPECT_NE(quadCuller.quadList()[i]->material(), CCDrawQuad::TiledCon
tent); |
137 } | 138 } |
138 } | 139 } |
139 | 140 |
140 static void getQuads(CCQuadList& quads, CCSharedQuadStateList& sharedStates, Int
Size tileSize, const IntSize& layerSize, CCLayerTilingData::BorderTexelOption bo
rderTexelOption, const IntRect& visibleContentRect) | 141 static void getQuads(CCQuadList& quads, CCSharedQuadStateList& sharedStates, Int
Size tileSize, const IntSize& layerSize, CCLayerTilingData::BorderTexelOption bo
rderTexelOption, const IntRect& visibleContentRect) |
141 { | 142 { |
142 OwnPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, borderTexe
lOption); | 143 OwnPtr<CCTiledLayerImpl> layer = createLayer(tileSize, layerSize, borderTexe
lOption); |
143 layer->setVisibleContentRect(visibleContentRect); | 144 layer->setVisibleContentRect(visibleContentRect); |
144 layer->setBounds(layerSize); | 145 layer->setBounds(layerSize); |
145 | 146 |
146 MockCCQuadCuller quadCuller(quads, sharedStates); | 147 MockCCQuadCuller quadCuller(quads, sharedStates); |
147 bool hadMissingTiles = false; | 148 CCAppendQuadsData data; |
148 layer->appendQuads(quadCuller, hadMissingTiles); | 149 layer->appendQuads(quadCuller, data); |
149 } | 150 } |
150 | 151 |
151 // Test with both border texels and without. | 152 // Test with both border texels and without. |
152 #define WITH_AND_WITHOUT_BORDER_TEST(testFixtureName) \ | 153 #define WITH_AND_WITHOUT_BORDER_TEST(testFixtureName) \ |
153 TEST(CCTiledLayerImplTest, testFixtureName##NoBorders) \ | 154 TEST(CCTiledLayerImplTest, testFixtureName##NoBorders) \ |
154 { \ | 155 { \ |
155 testFixtureName(CCLayerTilingData::NoBorderTexels); \ | 156 testFixtureName(CCLayerTilingData::NoBorderTexels); \ |
156 } \ | 157 } \ |
157 TEST(CCTiledLayerImplTest, testFixtureName##HasBorders) \ | 158 TEST(CCTiledLayerImplTest, testFixtureName##HasBorders) \ |
158 { \ | 159 { \ |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 | 235 |
235 for (size_t i = 0; i < quads.size(); ++i) { | 236 for (size_t i = 0; i < quads.size(); ++i) { |
236 ASSERT_EQ(quads[i]->material(), CCDrawQuad::TiledContent) << quadString
<< i; | 237 ASSERT_EQ(quads[i]->material(), CCDrawQuad::TiledContent) << quadString
<< i; |
237 CCTileDrawQuad* quad = static_cast<CCTileDrawQuad*>(quads[i].get()); | 238 CCTileDrawQuad* quad = static_cast<CCTileDrawQuad*>(quads[i].get()); |
238 | 239 |
239 EXPECT_EQ(IntRect(0, 0, 1, 1), quad->opaqueRect()) << quadString << i; | 240 EXPECT_EQ(IntRect(0, 0, 1, 1), quad->opaqueRect()) << quadString << i; |
240 } | 241 } |
241 } | 242 } |
242 | 243 |
243 } // namespace | 244 } // namespace |
OLD | NEW |