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

Side by Side Diff: cc/draw_quad_unittest.cc

Issue 11418047: cc: Turn DrawQuad into a struct-like class with public data members. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: no virtual for SetAll() 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 | Annotate | Revision Log
« no previous file with comments | « cc/draw_quad.cc ('k') | cc/gl_renderer.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 "cc/draw_quad.h" 5 #include "cc/draw_quad.h"
6 6
7 #include "cc/checkerboard_draw_quad.h" 7 #include "cc/checkerboard_draw_quad.h"
8 #include "cc/debug_border_draw_quad.h" 8 #include "cc/debug_border_draw_quad.h"
9 #include "cc/io_surface_draw_quad.h" 9 #include "cc/io_surface_draw_quad.h"
10 #include "cc/render_pass_draw_quad.h" 10 #include "cc/render_pass_draw_quad.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 float opacity = 1; 49 float opacity = 1;
50 int id = 3; 50 int id = 3;
51 51
52 scoped_ptr<SharedQuadState> state(SharedQuadState::create(quadTransform, vis ibleContentRect, clippedRectInTarget, opacity)); 52 scoped_ptr<SharedQuadState> state(SharedQuadState::create(quadTransform, vis ibleContentRect, clippedRectInTarget, opacity));
53 state->id = id; 53 state->id = id;
54 return state.Pass(); 54 return state.Pass();
55 } 55 }
56 56
57 void compareDrawQuad(DrawQuad* quad, DrawQuad* copy, SharedQuadState* copyShared State) 57 void compareDrawQuad(DrawQuad* quad, DrawQuad* copy, SharedQuadState* copyShared State)
58 { 58 {
59 EXPECT_EQ(quad->material(), copy->material()); 59 EXPECT_EQ(quad->material, copy->material);
60 EXPECT_RECT_EQ(quad->rect(), copy->rect()); 60 EXPECT_RECT_EQ(quad->rect, copy->rect);
61 EXPECT_RECT_EQ(quad->visible_rect(), copy->visible_rect()); 61 EXPECT_RECT_EQ(quad->visible_rect, copy->visible_rect);
62 EXPECT_RECT_EQ(quad->opaque_rect(), copy->opaque_rect()); 62 EXPECT_RECT_EQ(quad->opaque_rect, copy->opaque_rect);
63 EXPECT_EQ(quad->needs_blending(), copy->needs_blending()); 63 EXPECT_EQ(quad->needs_blending, copy->needs_blending);
64 EXPECT_EQ(copySharedState, copy->shared_quad_state()); 64 EXPECT_EQ(copySharedState, copy->shared_quad_state);
65 } 65 }
66 66
67 #define CREATE_SHARED_STATE() \ 67 #define CREATE_SHARED_STATE() \
68 scoped_ptr<SharedQuadState> sharedState(createSharedQuadState()); \ 68 scoped_ptr<SharedQuadState> sharedState(createSharedQuadState()); \
69 scoped_ptr<SharedQuadState> copySharedState(sharedState->copy()); \ 69 scoped_ptr<SharedQuadState> copySharedState(sharedState->copy()); \
70 copySharedState->id = 5; 70 copySharedState->id = 5;
71 71
72 #define QUAD_DATA \ 72 #define QUAD_DATA \
73 gfx::Rect quadRect(30, 40, 50, 60); \ 73 gfx::Rect quadRect(30, 40, 50, 60); \
74 gfx::Rect quadVisibleRect(40, 50, 30, 20); 74 gfx::Rect quadVisibleRect(40, 50, 30, 20);
75 75
76 #define SETUP_AND_COPY_QUAD(Type, quad) \ 76 #define SETUP_AND_COPY_QUAD(Type, quad) \
77 quad->set_visible_rect(quadVisibleRect); \ 77 quad->visible_rect = quadVisibleRect; \
78 scoped_ptr<DrawQuad> copy(quad->Copy(copySharedState.get())); \ 78 scoped_ptr<DrawQuad> copy(quad->Copy(copySharedState.get())); \
79 compareDrawQuad(quad.get(), copy.get(), copySharedState.get()); \ 79 compareDrawQuad(quad.get(), copy.get(), copySharedState.get()); \
80 const Type* copyQuad = Type::materialCast(copy.get()); 80 const Type* copyQuad = Type::materialCast(copy.get());
81 81
82 #define SETUP_AND_COPY_QUAD_1(Type, quad, a) \ 82 #define SETUP_AND_COPY_QUAD_1(Type, quad, a) \
83 quad->set_visible_rect(quadVisibleRect); \ 83 quad->visible_rect = quadVisibleRect; \
84 scoped_ptr<DrawQuad> copy(quad->copy(copySharedState.get(), a)); \ 84 scoped_ptr<DrawQuad> copy(quad->copy(copySharedState.get(), a)); \
85 compareDrawQuad(quad.get(), copy.get(), copySharedState.get()); \ 85 compareDrawQuad(quad.get(), copy.get(), copySharedState.get()); \
86 const Type* copyQuad = Type::materialCast(copy.get()); 86 const Type* copyQuad = Type::materialCast(copy.get());
87 87
88 #define CREATE_QUAD_0(Type) \ 88 #define CREATE_QUAD_0(Type) \
89 QUAD_DATA \ 89 QUAD_DATA \
90 scoped_ptr<Type> quad(Type::create(sharedState.get(), quadRect)); \ 90 scoped_ptr<Type> quad(Type::create(sharedState.get(), quadRect)); \
91 SETUP_AND_COPY_QUAD(Type, quad); \ 91 SETUP_AND_COPY_QUAD(Type, quad); \
92 UNUSED_PARAM(copyQuad); 92 UNUSED_PARAM(copyQuad);
93 93
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 161
162 TEST(DrawQuadTest, copyIOSurfaceDrawQuad) 162 TEST(DrawQuadTest, copyIOSurfaceDrawQuad)
163 { 163 {
164 gfx::Rect opaqueRect(3, 7, 10, 12); 164 gfx::Rect opaqueRect(3, 7, 10, 12);
165 gfx::Size size(58, 95); 165 gfx::Size size(58, 95);
166 unsigned textureId = 72; 166 unsigned textureId = 72;
167 IOSurfaceDrawQuad::Orientation orientation = IOSurfaceDrawQuad::Unflipped; 167 IOSurfaceDrawQuad::Orientation orientation = IOSurfaceDrawQuad::Unflipped;
168 168
169 CREATE_SHARED_STATE(); 169 CREATE_SHARED_STATE();
170 CREATE_QUAD_4(IOSurfaceDrawQuad, opaqueRect, size, textureId, orientation); 170 CREATE_QUAD_4(IOSurfaceDrawQuad, opaqueRect, size, textureId, orientation);
171 EXPECT_RECT_EQ(opaqueRect, copyQuad->opaque_rect()); 171 EXPECT_RECT_EQ(opaqueRect, copyQuad->opaque_rect);
172 EXPECT_EQ(size, copyQuad->ioSurfaceSize()); 172 EXPECT_EQ(size, copyQuad->ioSurfaceSize());
173 EXPECT_EQ(textureId, copyQuad->ioSurfaceTextureId()); 173 EXPECT_EQ(textureId, copyQuad->ioSurfaceTextureId());
174 EXPECT_EQ(orientation, copyQuad->orientation()); 174 EXPECT_EQ(orientation, copyQuad->orientation());
175 } 175 }
176 176
177 TEST(DrawQuadTest, copyRenderPassDrawQuad) 177 TEST(DrawQuadTest, copyRenderPassDrawQuad)
178 { 178 {
179 RenderPass::Id renderPassId(22, 64); 179 RenderPass::Id renderPassId(22, 64);
180 bool isReplica = true; 180 bool isReplica = true;
181 ResourceProvider::ResourceId maskResourceId = 78; 181 ResourceProvider::ResourceId maskResourceId = 78;
(...skipping 27 matching lines...) Expand all
209 } 209 }
210 210
211 TEST(DrawQuadTest, copyStreamVideoDrawQuad) 211 TEST(DrawQuadTest, copyStreamVideoDrawQuad)
212 { 212 {
213 gfx::Rect opaqueRect(3, 7, 10, 12); 213 gfx::Rect opaqueRect(3, 7, 10, 12);
214 unsigned textureId = 64; 214 unsigned textureId = 64;
215 WebTransformationMatrix matrix(0.5, 1, 0.25, 0.75, 0, 1); 215 WebTransformationMatrix matrix(0.5, 1, 0.25, 0.75, 0, 1);
216 216
217 CREATE_SHARED_STATE(); 217 CREATE_SHARED_STATE();
218 CREATE_QUAD_3(StreamVideoDrawQuad, opaqueRect, textureId, matrix); 218 CREATE_QUAD_3(StreamVideoDrawQuad, opaqueRect, textureId, matrix);
219 EXPECT_RECT_EQ(opaqueRect, copyQuad->opaque_rect()); 219 EXPECT_RECT_EQ(opaqueRect, copyQuad->opaque_rect);
220 EXPECT_EQ(textureId, copyQuad->textureId()); 220 EXPECT_EQ(textureId, copyQuad->textureId());
221 EXPECT_EQ(matrix, copyQuad->matrix()); 221 EXPECT_EQ(matrix, copyQuad->matrix());
222 } 222 }
223 223
224 TEST(DrawQuadTest, copyTextureDrawQuad) 224 TEST(DrawQuadTest, copyTextureDrawQuad)
225 { 225 {
226 gfx::Rect opaqueRect(3, 7, 10, 12); 226 gfx::Rect opaqueRect(3, 7, 10, 12);
227 unsigned resourceId = 82; 227 unsigned resourceId = 82;
228 bool premultipliedAlpha = true; 228 bool premultipliedAlpha = true;
229 gfx::RectF uvRect(0.5, 224, -51, 36); 229 gfx::RectF uvRect(0.5, 224, -51, 36);
230 bool flipped = true; 230 bool flipped = true;
231 231
232 CREATE_SHARED_STATE(); 232 CREATE_SHARED_STATE();
233 CREATE_QUAD_5(TextureDrawQuad, opaqueRect, resourceId, premultipliedAlpha, u vRect, flipped); 233 CREATE_QUAD_5(TextureDrawQuad, opaqueRect, resourceId, premultipliedAlpha, u vRect, flipped);
234 EXPECT_RECT_EQ(opaqueRect, copyQuad->opaque_rect()); 234 EXPECT_RECT_EQ(opaqueRect, copyQuad->opaque_rect);
235 EXPECT_EQ(resourceId, copyQuad->resourceId()); 235 EXPECT_EQ(resourceId, copyQuad->resourceId());
236 EXPECT_EQ(premultipliedAlpha, copyQuad->premultipliedAlpha()); 236 EXPECT_EQ(premultipliedAlpha, copyQuad->premultipliedAlpha());
237 EXPECT_FLOAT_RECT_EQ(uvRect, copyQuad->uvRect()); 237 EXPECT_FLOAT_RECT_EQ(uvRect, copyQuad->uvRect());
238 EXPECT_EQ(flipped, copyQuad->flipped()); 238 EXPECT_EQ(flipped, copyQuad->flipped());
239 } 239 }
240 240
241 TEST(DrawQuadTest, copyTileDrawQuad) 241 TEST(DrawQuadTest, copyTileDrawQuad)
242 { 242 {
243 gfx::Rect opaqueRect(33, 44, 22, 33); 243 gfx::Rect opaqueRect(33, 44, 22, 33);
244 unsigned resourceId = 104; 244 unsigned resourceId = 104;
245 gfx::Vector2d textureOffset(-31, 47); 245 gfx::Vector2d textureOffset(-31, 47);
246 gfx::Size textureSize(85, 32); 246 gfx::Size textureSize(85, 32);
247 bool swizzleContents = true; 247 bool swizzleContents = true;
248 bool leftEdgeAA = true; 248 bool leftEdgeAA = true;
249 bool topEdgeAA = true; 249 bool topEdgeAA = true;
250 bool rightEdgeAA = false; 250 bool rightEdgeAA = false;
251 bool bottomEdgeAA = true; 251 bool bottomEdgeAA = true;
252 252
253 CREATE_SHARED_STATE(); 253 CREATE_SHARED_STATE();
254 CREATE_QUAD_9(TileDrawQuad, opaqueRect, resourceId, textureOffset, textureSi ze, swizzleContents, leftEdgeAA, topEdgeAA, rightEdgeAA, bottomEdgeAA); 254 CREATE_QUAD_9(TileDrawQuad, opaqueRect, resourceId, textureOffset, textureSi ze, swizzleContents, leftEdgeAA, topEdgeAA, rightEdgeAA, bottomEdgeAA);
255 EXPECT_RECT_EQ(opaqueRect, copyQuad->opaque_rect()); 255 EXPECT_RECT_EQ(opaqueRect, copyQuad->opaque_rect);
256 EXPECT_EQ(resourceId, copyQuad->resourceId()); 256 EXPECT_EQ(resourceId, copyQuad->resourceId());
257 EXPECT_EQ(textureOffset, copyQuad->textureOffset()); 257 EXPECT_EQ(textureOffset, copyQuad->textureOffset());
258 EXPECT_EQ(textureSize, copyQuad->textureSize()); 258 EXPECT_EQ(textureSize, copyQuad->textureSize());
259 EXPECT_EQ(swizzleContents, copyQuad->swizzleContents()); 259 EXPECT_EQ(swizzleContents, copyQuad->swizzleContents());
260 EXPECT_EQ(leftEdgeAA, copyQuad->leftEdgeAA()); 260 EXPECT_EQ(leftEdgeAA, copyQuad->leftEdgeAA());
261 EXPECT_EQ(topEdgeAA, copyQuad->topEdgeAA()); 261 EXPECT_EQ(topEdgeAA, copyQuad->topEdgeAA());
262 EXPECT_EQ(rightEdgeAA, copyQuad->rightEdgeAA()); 262 EXPECT_EQ(rightEdgeAA, copyQuad->rightEdgeAA());
263 EXPECT_EQ(bottomEdgeAA, copyQuad->bottomEdgeAA()); 263 EXPECT_EQ(bottomEdgeAA, copyQuad->bottomEdgeAA());
264 } 264 }
265 265
266 TEST(DrawQuadTest, copyYUVVideoDrawQuad) 266 TEST(DrawQuadTest, copyYUVVideoDrawQuad)
267 { 267 {
268 gfx::Rect opaqueRect(3, 7, 10, 12); 268 gfx::Rect opaqueRect(3, 7, 10, 12);
269 gfx::SizeF texScale(0.75, 0.5); 269 gfx::SizeF texScale(0.75, 0.5);
270 VideoLayerImpl::FramePlane yPlane; 270 VideoLayerImpl::FramePlane yPlane;
271 yPlane.resourceId = 45; 271 yPlane.resourceId = 45;
272 yPlane.size = gfx::Size(34, 23); 272 yPlane.size = gfx::Size(34, 23);
273 yPlane.format = 8; 273 yPlane.format = 8;
274 VideoLayerImpl::FramePlane uPlane; 274 VideoLayerImpl::FramePlane uPlane;
275 uPlane.resourceId = 532; 275 uPlane.resourceId = 532;
276 uPlane.size = gfx::Size(134, 16); 276 uPlane.size = gfx::Size(134, 16);
277 uPlane.format = 2; 277 uPlane.format = 2;
278 VideoLayerImpl::FramePlane vPlane; 278 VideoLayerImpl::FramePlane vPlane;
279 vPlane.resourceId = 4; 279 vPlane.resourceId = 4;
280 vPlane.size = gfx::Size(456, 486); 280 vPlane.size = gfx::Size(456, 486);
281 vPlane.format = 46; 281 vPlane.format = 46;
282 282
283 CREATE_SHARED_STATE(); 283 CREATE_SHARED_STATE();
284 CREATE_QUAD_5(YUVVideoDrawQuad, opaqueRect, texScale, yPlane, uPlane, vPlane ); 284 CREATE_QUAD_5(YUVVideoDrawQuad, opaqueRect, texScale, yPlane, uPlane, vPlane );
285 EXPECT_RECT_EQ(opaqueRect, copyQuad->opaque_rect()); 285 EXPECT_RECT_EQ(opaqueRect, copyQuad->opaque_rect);
286 EXPECT_EQ(texScale, copyQuad->texScale()); 286 EXPECT_EQ(texScale, copyQuad->texScale());
287 EXPECT_EQ(yPlane.resourceId, copyQuad->yPlane().resourceId); 287 EXPECT_EQ(yPlane.resourceId, copyQuad->yPlane().resourceId);
288 EXPECT_EQ(yPlane.size, copyQuad->yPlane().size); 288 EXPECT_EQ(yPlane.size, copyQuad->yPlane().size);
289 EXPECT_EQ(yPlane.format, copyQuad->yPlane().format); 289 EXPECT_EQ(yPlane.format, copyQuad->yPlane().format);
290 EXPECT_EQ(uPlane.resourceId, copyQuad->uPlane().resourceId); 290 EXPECT_EQ(uPlane.resourceId, copyQuad->uPlane().resourceId);
291 EXPECT_EQ(uPlane.size, copyQuad->uPlane().size); 291 EXPECT_EQ(uPlane.size, copyQuad->uPlane().size);
292 EXPECT_EQ(uPlane.format, copyQuad->uPlane().format); 292 EXPECT_EQ(uPlane.format, copyQuad->uPlane().format);
293 EXPECT_EQ(vPlane.resourceId, copyQuad->vPlane().resourceId); 293 EXPECT_EQ(vPlane.resourceId, copyQuad->vPlane().resourceId);
294 EXPECT_EQ(vPlane.size, copyQuad->vPlane().size); 294 EXPECT_EQ(vPlane.size, copyQuad->vPlane().size);
295 EXPECT_EQ(vPlane.format, copyQuad->vPlane().format); 295 EXPECT_EQ(vPlane.format, copyQuad->vPlane().format);
296 } 296 }
297 297
298 } // namespace 298 } // namespace
299 } // namespace cc 299 } // namespace cc
OLDNEW
« no previous file with comments | « cc/draw_quad.cc ('k') | cc/gl_renderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698