Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: cc/tiled_layer_impl_unittest.cc

Issue 11232051: Remove static thread pointers from CC (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Apply code review comments Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/thread_proxy.cc ('k') | cc/tiled_layer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
51 const gfx::Size tileSize(90, 90); 49 const gfx::Size 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 gfx::Size layerSize(tileSize.width() * numTilesX, tileSize.height() * numTilesY); 52 const gfx::Size layerSize(tileSize.width() * numTilesX, tileSize.height() * numTilesY);
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
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 gfx::Size tileSize(10, 10); 102 const gfx::Size 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 gfx::Size layerSize(tileSize.width() * numTilesX, tileSize.height() * numTilesY); 105 const gfx::Size layerSize(tileSize.width() * numTilesX, tileSize.height() * numTilesY);
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
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 gfx::Size layerSize(1000, 1000); 161 gfx::Size layerSize(1000, 1000);
168 QuadList quads; 162 QuadList quads;
169 SharedQuadStateList sharedStates; 163 SharedQuadStateList sharedStates;
170 getQuads(quads, sharedStates, gfx::Size(100, 100), layerSize, borders, gfx:: Rect(gfx::Point(), layerSize)); 164 getQuads(quads, sharedStates, gfx::Size(100, 100), layerSize, borders, gfx:: Rect(gfx::Point(), layerSize));
171 verifyQuadsExactlyCoverRect(quads, gfx::Rect(gfx::Point(), layerSize)); 165 verifyQuadsExactlyCoverRect(quads, gfx::Rect(gfx::Point(), 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 gfx::Point topLeft(65, 73); 172 gfx::Point topLeft(65, 73);
181 gfx::Point bottomRight(182, 198); 173 gfx::Point bottomRight(182, 198);
182 gfx::Rect visibleContentRect = gfx::BoundingRect(topLeft, bottomRight); 174 gfx::Rect visibleContentRect = gfx::BoundingRect(topLeft, bottomRight);
183 175
184 gfx::Size layerSize(250, 250); 176 gfx::Size layerSize(250, 250);
185 QuadList quads; 177 QuadList quads;
186 SharedQuadStateList sharedStates; 178 SharedQuadStateList sharedStates;
187 getQuads(quads, sharedStates, gfx::Size(50, 50), gfx::Size(250, 250), LayerT ilingData::NoBorderTexels, visibleContentRect); 179 getQuads(quads, sharedStates, gfx::Size(50, 50), gfx::Size(250, 250), LayerT ilingData::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 gfx::Size layerSize(220, 210); 186 gfx::Size layerSize(220, 210);
197 gfx::Rect visibleContentRect(gfx::Point(), layerSize); 187 gfx::Rect visibleContentRect(gfx::Point(), layerSize);
198 QuadList quads; 188 QuadList quads;
199 SharedQuadStateList sharedStates; 189 SharedQuadStateList sharedStates;
200 getQuads(quads, sharedStates, gfx::Size(100, 100), layerSize, LayerTilingDat a::NoBorderTexels, visibleContentRect); 190 getQuads(quads, sharedStates, gfx::Size(100, 100), layerSize, LayerTilingDat a::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 gfx::Size tileSize(50, 50); 197 gfx::Size tileSize(50, 50);
210 gfx::Size layerSize(250, 250); 198 gfx::Size layerSize(250, 250);
211 QuadList quads; 199 QuadList quads;
212 SharedQuadStateList sharedStates; 200 SharedQuadStateList sharedStates;
213 getQuads(quads, sharedStates, tileSize, layerSize, LayerTilingData::NoBorder Texels, gfx::Rect(gfx::Point(), layerSize)); 201 getQuads(quads, sharedStates, tileSize, layerSize, LayerTilingData::NoBorder Texels, gfx::Rect(gfx::Point(), 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(), gfx::Vector2d()) << quadString << i; 208 EXPECT_EQ(quad->textureOffset(), gfx::Vector2d()) << 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 gfx::Size tileSize(50, 50); 216 gfx::Size tileSize(50, 50);
231 gfx::Size layerSize(250, 250); 217 gfx::Size layerSize(250, 250);
232 QuadList quads; 218 QuadList quads;
233 SharedQuadStateList sharedStates; 219 SharedQuadStateList sharedStates;
234 getQuads(quads, sharedStates, tileSize, layerSize, LayerTilingData::NoBorder Texels, gfx::Rect(gfx::Point(), layerSize)); 220 getQuads(quads, sharedStates, tileSize, layerSize, LayerTilingData::NoBorder Texels, gfx::Rect(gfx::Point(), 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 } // anonymous namespace 230 } // anonymous namespace
OLDNEW
« no previous file with comments | « cc/thread_proxy.cc ('k') | cc/tiled_layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698