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
3 // found in the LICENSE file.
5 #include "cc/draw_quad.h"
7 #include "cc/checkerboard_draw_quad.h"
8 #include "cc/debug_border_draw_quad.h"
9 #include "cc/io_surface_draw_quad.h"
10 #include "cc/math_util.h"
11 #include "cc/render_pass_draw_quad.h"
12 #include "cc/solid_color_draw_quad.h"
13 #include "cc/stream_video_draw_quad.h"
14 #include "cc/test/geometry_test_utils.h"
15 #include "cc/texture_draw_quad.h"
16 #include "cc/tile_draw_quad.h"
17 #include "cc/yuv_video_draw_quad.h"
18 #include "testing/gtest/include/gtest/gtest.h"
19 #include "third_party/WebKit/Source/Platform/chromium/public/WebFilterOperations.h"
20 #include "third_party/skia/include/effects/SkBlurImageFilter.h"
21 #include "ui/gfx/transform.h"
26 TEST(DrawQuadTest
, copySharedQuadState
)
28 gfx::Transform quadTransform
= MathUtil::createGfxTransform(1, 0.5, 0, 1, 0.5, 0);
29 gfx::Rect
visibleContentRect(10, 12, 14, 16);
30 gfx::Rect
clippedRectInTarget(19, 21, 23, 25);
31 gfx::Rect clipRect
= clippedRectInTarget
;
32 bool isClipped
= true;
35 scoped_ptr
<SharedQuadState
> state(SharedQuadState::Create());
36 state
->SetAll(quadTransform
, visibleContentRect
, clippedRectInTarget
, clipRect
, isClipped
, opacity
);
38 scoped_ptr
<SharedQuadState
> copy(state
->Copy());
39 EXPECT_EQ(quadTransform
, copy
->content_to_target_transform
);
40 EXPECT_RECT_EQ(visibleContentRect
, copy
->visible_content_rect
);
41 EXPECT_RECT_EQ(clippedRectInTarget
, copy
->clipped_rect_in_target
);
42 EXPECT_EQ(opacity
, copy
->opacity
);
43 EXPECT_RECT_EQ(clipRect
, copy
->clip_rect
);
44 EXPECT_EQ(isClipped
, copy
->is_clipped
);
47 scoped_ptr
<SharedQuadState
> createSharedQuadState()
49 gfx::Transform quadTransform
= MathUtil::createGfxTransform(1, 0.5, 0, 1, 0.5, 0);
50 gfx::Rect
visibleContentRect(10, 12, 14, 16);
51 gfx::Rect
clippedRectInTarget(19, 21, 23, 25);
52 gfx::Rect clipRect
= clippedRectInTarget
;
53 bool isClipped
= false;
56 scoped_ptr
<SharedQuadState
> state(SharedQuadState::Create());
57 state
->SetAll(quadTransform
, visibleContentRect
, clippedRectInTarget
, clipRect
, isClipped
, opacity
);
61 void compareDrawQuad(DrawQuad
* quad
, DrawQuad
* copy
, SharedQuadState
* copySharedState
)
63 EXPECT_EQ(quad
->material
, copy
->material
);
64 EXPECT_RECT_EQ(quad
->rect
, copy
->rect
);
65 EXPECT_RECT_EQ(quad
->visible_rect
, copy
->visible_rect
);
66 EXPECT_RECT_EQ(quad
->opaque_rect
, copy
->opaque_rect
);
67 EXPECT_EQ(quad
->needs_blending
, copy
->needs_blending
);
68 EXPECT_EQ(copySharedState
, copy
->shared_quad_state
);
71 #define CREATE_SHARED_STATE() \
72 scoped_ptr<SharedQuadState> sharedState(createSharedQuadState()); \
73 scoped_ptr<SharedQuadState> copySharedState(sharedState->Copy()); \
76 gfx::Rect quadRect(30, 40, 50, 60); \
77 gfx::Rect quadVisibleRect(40, 50, 30, 20); \
78 gfx::Rect quadOpaqueRect(60, 55, 10, 10); \
79 bool needsBlending = true;
81 #define SETUP_AND_COPY_QUAD_NEW(Type, quad) \
82 scoped_ptr<DrawQuad> copyNew(quadNew->Copy(copySharedState.get())); \
83 compareDrawQuad(quadNew.get(), copyNew.get(), copySharedState.get()); \
84 const Type* copyQuad = Type::MaterialCast(copyNew.get());
86 #define SETUP_AND_COPY_QUAD_ALL(Type, quad) \
87 scoped_ptr<DrawQuad> copyAll(quadAll->Copy(copySharedState.get())); \
88 compareDrawQuad(quadAll.get(), copyAll.get(), copySharedState.get()); \
89 copyQuad = Type::MaterialCast(copyAll.get());
91 #define SETUP_AND_COPY_QUAD_NEW_1(Type, quad, a) \
92 scoped_ptr<DrawQuad> copyNew(quadNew->Copy(copySharedState.get(), a)); \
93 compareDrawQuad(quadNew.get(), copyNew.get(), copySharedState.get()); \
94 const Type* copyQuad = Type::MaterialCast(copyNew.get());
96 #define SETUP_AND_COPY_QUAD_ALL_1(Type, quad, a) \
97 scoped_ptr<DrawQuad> copyAll(quadAll->Copy(copySharedState.get(), a)); \
98 compareDrawQuad(quadAll.get(), copyAll.get(), copySharedState.get()); \
99 copyQuad = Type::MaterialCast(copyAll.get());
101 #define CREATE_QUAD_1_NEW(Type, a) \
102 scoped_ptr<Type> quadNew(Type::Create()); \
104 quadNew->SetNew(sharedState.get(), quadRect, a); } \
105 SETUP_AND_COPY_QUAD_NEW(Type, quadNew);
107 #define CREATE_QUAD_1_ALL(Type, a) \
108 scoped_ptr<Type> quadAll(Type::Create()); \
110 quadAll->SetAll(sharedState.get(), quadRect, quadOpaqueRect, quadVisibleRect, needsBlending, a); } \
111 SETUP_AND_COPY_QUAD_ALL(Type, quadAll);
113 #define CREATE_QUAD_2_NEW(Type, a, b) \
114 scoped_ptr<Type> quadNew(Type::Create()); \
116 quadNew->SetNew(sharedState.get(), quadRect, a, b); } \
117 SETUP_AND_COPY_QUAD_NEW(Type, quadNew);
119 #define CREATE_QUAD_2_ALL(Type, a, b) \
120 scoped_ptr<Type> quadAll(Type::Create()); \
122 quadAll->SetAll(sharedState.get(), quadRect, quadOpaqueRect, quadVisibleRect, needsBlending, a, b); } \
123 SETUP_AND_COPY_QUAD_ALL(Type, quadAll);
125 #define CREATE_QUAD_3_NEW(Type, a, b, c) \
126 scoped_ptr<Type> quadNew(Type::Create()); \
128 quadNew->SetNew(sharedState.get(), quadRect, a, b, c); } \
129 SETUP_AND_COPY_QUAD_NEW(Type, quadNew);
131 #define CREATE_QUAD_3_ALL(Type, a, b, c) \
132 scoped_ptr<Type> quadAll(Type::Create()); \
134 quadAll->SetAll(sharedState.get(), quadRect, quadOpaqueRect, quadVisibleRect, needsBlending, a, b, c); } \
135 SETUP_AND_COPY_QUAD_ALL(Type, quadAll);
137 #define CREATE_QUAD_4_NEW(Type, a, b, c, d) \
138 scoped_ptr<Type> quadNew(Type::Create()); \
140 quadNew->SetNew(sharedState.get(), quadRect, a, b, c, d); } \
141 SETUP_AND_COPY_QUAD_NEW(Type, quadNew);
143 #define CREATE_QUAD_4_ALL(Type, a, b, c, d) \
144 scoped_ptr<Type> quadAll(Type::Create()); \
146 quadAll->SetAll(sharedState.get(), quadRect, quadOpaqueRect, quadVisibleRect, needsBlending, a, b, c, d); } \
147 SETUP_AND_COPY_QUAD_ALL(Type, quadAll);
149 #define CREATE_QUAD_5_NEW(Type, a, b, c, d, e) \
150 scoped_ptr<Type> quadNew(Type::Create()); \
152 quadNew->SetNew(sharedState.get(), quadRect, a, b, c, d, e); } \
153 SETUP_AND_COPY_QUAD_NEW(Type, quadNew);
155 #define CREATE_QUAD_5_ALL(Type, a, b, c, d, e) \
156 scoped_ptr<Type> quadAll(Type::Create()); \
158 quadAll->SetAll(sharedState.get(), quadRect, quadOpaqueRect, quadVisibleRect, needsBlending, a, b, c, d, e); } \
159 SETUP_AND_COPY_QUAD_ALL(Type, quadAll);
161 #define CREATE_QUAD_5_NEW_1(Type, a, b, c, d, e, copyA) \
162 scoped_ptr<Type> quadNew(Type::Create()); \
164 quadNew->SetNew(sharedState.get(), quadRect, a, b, c, d, e); } \
165 SETUP_AND_COPY_QUAD_NEW_1(Type, quadNew, copyA);
167 #define CREATE_QUAD_5_ALL_1(Type, a, b, c, d, e, copyA) \
168 scoped_ptr<Type> quadAll(Type::Create()); \
170 quadAll->SetAll(sharedState.get(), quadRect, quadOpaqueRect, quadVisibleRect, needsBlending, a, b, c, d, e); } \
171 SETUP_AND_COPY_QUAD_ALL_1(Type, quadAll, copyA);
173 #define CREATE_QUAD_6_NEW(Type, a, b, c, d, e, f) \
174 scoped_ptr<Type> quadNew(Type::Create()); \
176 quadNew->SetNew(sharedState.get(), quadRect, a, b, c, d, e, f); } \
177 SETUP_AND_COPY_QUAD_NEW(Type, quadNew);
179 #define CREATE_QUAD_6_ALL(Type, a, b, c, d, e, f) \
180 scoped_ptr<Type> quadAll(Type::Create()); \
182 quadAll->SetAll(sharedState.get(), quadRect, quadOpaqueRect, quadVisibleRect, needsBlending, a, b, c, d, e, f); } \
183 SETUP_AND_COPY_QUAD_ALL(Type, quadAll);
185 #define CREATE_QUAD_7_NEW(Type, a, b, c, d, e, f, g) \
186 scoped_ptr<Type> quadNew(Type::Create()); \
188 quadNew->SetNew(sharedState.get(), quadRect, a, b, c, d, e, f, g); } \
189 SETUP_AND_COPY_QUAD_NEW(Type, quadNew);
191 #define CREATE_QUAD_7_ALL(Type, a, b, c, d, e, f, g) \
192 scoped_ptr<Type> quadAll(Type::Create()); \
194 quadAll->SetAll(sharedState.get(), quadRect, quadOpaqueRect, quadVisibleRect, needsBlending, a, b, c, d, e, f, g); } \
195 SETUP_AND_COPY_QUAD_ALL(Type, quadAll);
197 #define CREATE_QUAD_8_NEW(Type, a, b, c, d, e, f, g, h) \
198 scoped_ptr<Type> quadNew(Type::Create()); \
200 quadNew->SetNew(sharedState.get(), quadRect, a, b, c, d, e, f, g, h); } \
201 SETUP_AND_COPY_QUAD_NEW(Type, quadNew);
203 #define CREATE_QUAD_8_ALL(Type, a, b, c, d, e, f, g, h) \
204 scoped_ptr<Type> quadAll(Type::Create()); \
206 quadAll->SetAll(sharedState.get(), quadRect, quadOpaqueRect, quadVisibleRect, needsBlending, a, b, c, d, e, f, g, h); } \
207 SETUP_AND_COPY_QUAD_ALL(Type, quadAll);
209 #define CREATE_QUAD_8_NEW_1(Type, a, b, c, d, e, f, g, h, copyA) \
210 scoped_ptr<Type> quadNew(Type::Create()); \
212 quadNew->SetNew(sharedState.get(), quadRect, a, b, c, d, e, f, g, h); } \
213 SETUP_AND_COPY_QUAD_NEW_1(Type, quadNew, copyA);
215 #define CREATE_QUAD_8_ALL_1(Type, a, b, c, d, e, f, g, h, copyA) \
216 scoped_ptr<Type> quadAll(Type::Create()); \
218 quadAll->SetAll(sharedState.get(), quadRect, quadOpaqueRect, quadVisibleRect, needsBlending, a, b, c, d, e, f, g, h); } \
219 SETUP_AND_COPY_QUAD_ALL_1(Type, quadAll, copyA);
221 #define CREATE_QUAD_9_NEW(Type, a, b, c, d, e, f, g, h, i) \
222 scoped_ptr<Type> quadNew(Type::Create()); \
224 quadNew->SetNew(sharedState.get(), quadRect, a, b, c, d, e, f, g, h, i); } \
225 SETUP_AND_COPY_QUAD_NEW(Type, quadNew);
227 #define CREATE_QUAD_9_ALL(Type, a, b, c, d, e, f, g, h, i) \
228 scoped_ptr<Type> quadAll(Type::Create()); \
230 quadAll->SetAll(sharedState.get(), quadRect, quadOpaqueRect, quadVisibleRect, needsBlending, a, b, c, d, e, f, g, h, i); } \
231 SETUP_AND_COPY_QUAD_ALL(Type, quadAll);
233 TEST(DrawQuadTest
, copyCheckerboardDrawQuad
)
235 SkColor color
= 0xfabb0011;
236 CREATE_SHARED_STATE();
238 CREATE_QUAD_1_NEW(CheckerboardDrawQuad
, color
);
239 EXPECT_EQ(DrawQuad::CHECKERBOARD
, copyQuad
->material
);
240 EXPECT_EQ(color
, copyQuad
->color
);
242 CREATE_QUAD_1_ALL(CheckerboardDrawQuad
, color
);
243 EXPECT_EQ(DrawQuad::CHECKERBOARD
, copyQuad
->material
);
244 EXPECT_EQ(color
, copyQuad
->color
);
247 TEST(DrawQuadTest
, copyDebugBorderDrawQuad
)
249 SkColor color
= 0xfabb0011;
251 CREATE_SHARED_STATE();
253 CREATE_QUAD_2_NEW(DebugBorderDrawQuad
, color
, width
);
254 EXPECT_EQ(DrawQuad::DEBUG_BORDER
, copyQuad
->material
);
255 EXPECT_EQ(color
, copyQuad
->color
);
256 EXPECT_EQ(width
, copyQuad
->width
);
258 CREATE_QUAD_2_ALL(DebugBorderDrawQuad
, color
, width
);
259 EXPECT_EQ(DrawQuad::DEBUG_BORDER
, copyQuad
->material
);
260 EXPECT_EQ(color
, copyQuad
->color
);
261 EXPECT_EQ(width
, copyQuad
->width
);
264 TEST(DrawQuadTest
, copyIOSurfaceDrawQuad
)
266 gfx::Rect
opaqueRect(3, 7, 10, 12);
267 gfx::Size
size(58, 95);
268 unsigned textureId
= 72;
269 IOSurfaceDrawQuad::Orientation orientation
= IOSurfaceDrawQuad::UNFLIPPED
;
270 CREATE_SHARED_STATE();
272 CREATE_QUAD_4_NEW(IOSurfaceDrawQuad
, opaqueRect
, size
, textureId
, orientation
);
273 EXPECT_EQ(DrawQuad::IO_SURFACE_CONTENT
, copyQuad
->material
);
274 EXPECT_RECT_EQ(opaqueRect
, copyQuad
->opaque_rect
);
275 EXPECT_EQ(size
, copyQuad
->io_surface_size
);
276 EXPECT_EQ(textureId
, copyQuad
->io_surface_texture_id
);
277 EXPECT_EQ(orientation
, copyQuad
->orientation
);
279 CREATE_QUAD_3_ALL(IOSurfaceDrawQuad
, size
, textureId
, orientation
);
280 EXPECT_EQ(DrawQuad::IO_SURFACE_CONTENT
, copyQuad
->material
);
281 EXPECT_EQ(size
, copyQuad
->io_surface_size
);
282 EXPECT_EQ(textureId
, copyQuad
->io_surface_texture_id
);
283 EXPECT_EQ(orientation
, copyQuad
->orientation
);
286 TEST(DrawQuadTest
, copyRenderPassDrawQuad
)
288 RenderPass::Id
renderPassId(22, 64);
289 bool isReplica
= true;
290 ResourceProvider::ResourceId maskResourceId
= 78;
291 gfx::Rect
contentsChangedSinceLastFrame(42, 11, 74, 24);
292 gfx::RectF
maskUVRect(-45, -21, 33, 19);
293 WebKit::WebFilterOperations filters
;
294 filters
.append(WebKit::WebFilterOperation::createBlurFilter(1.f
));
295 WebKit::WebFilterOperations background_filters
;
296 background_filters
.append(
297 WebKit::WebFilterOperation::createGrayscaleFilter(1.f
));
298 skia::RefPtr
<SkImageFilter
> filter
= skia::AdoptRef(
299 new SkBlurImageFilter(SK_Scalar1
, SK_Scalar1
));
301 RenderPass::Id
copiedRenderPassId(235, 11);
302 CREATE_SHARED_STATE();
304 CREATE_QUAD_8_NEW_1(RenderPassDrawQuad
, renderPassId
, isReplica
, maskResourceId
, contentsChangedSinceLastFrame
, maskUVRect
, filters
, filter
, background_filters
, copiedRenderPassId
);
305 EXPECT_EQ(DrawQuad::RENDER_PASS
, copyQuad
->material
);
306 EXPECT_EQ(copiedRenderPassId
, copyQuad
->render_pass_id
);
307 EXPECT_EQ(isReplica
, copyQuad
->is_replica
);
308 EXPECT_EQ(maskResourceId
, copyQuad
->mask_resource_id
);
309 EXPECT_RECT_EQ(contentsChangedSinceLastFrame
, copyQuad
->contents_changed_since_last_frame
);
310 EXPECT_EQ(maskUVRect
.ToString(), copyQuad
->mask_uv_rect
.ToString());
311 EXPECT_EQ(filters
, copyQuad
->filters
);
312 EXPECT_EQ(filter
, copyQuad
->filter
);
313 EXPECT_EQ(background_filters
, copyQuad
->background_filters
);
315 CREATE_QUAD_8_ALL_1(RenderPassDrawQuad
, renderPassId
, isReplica
, maskResourceId
, contentsChangedSinceLastFrame
, maskUVRect
, filters
, filter
, background_filters
, copiedRenderPassId
);
316 EXPECT_EQ(DrawQuad::RENDER_PASS
, copyQuad
->material
);
317 EXPECT_EQ(copiedRenderPassId
, copyQuad
->render_pass_id
);
318 EXPECT_EQ(isReplica
, copyQuad
->is_replica
);
319 EXPECT_EQ(maskResourceId
, copyQuad
->mask_resource_id
);
320 EXPECT_RECT_EQ(contentsChangedSinceLastFrame
, copyQuad
->contents_changed_since_last_frame
);
321 EXPECT_EQ(maskUVRect
.ToString(), copyQuad
->mask_uv_rect
.ToString());
322 EXPECT_EQ(filters
, copyQuad
->filters
);
323 EXPECT_EQ(filter
, copyQuad
->filter
);
324 EXPECT_EQ(background_filters
, copyQuad
->background_filters
);
327 TEST(DrawQuadTest
, copySolidColorDrawQuad
)
329 SkColor color
= 0x49494949;
330 CREATE_SHARED_STATE();
332 CREATE_QUAD_1_NEW(SolidColorDrawQuad
, color
);
333 EXPECT_EQ(DrawQuad::SOLID_COLOR
, copyQuad
->material
);
334 EXPECT_EQ(color
, copyQuad
->color
);
336 CREATE_QUAD_1_ALL(SolidColorDrawQuad
, color
);
337 EXPECT_EQ(DrawQuad::SOLID_COLOR
, copyQuad
->material
);
338 EXPECT_EQ(color
, copyQuad
->color
);
341 TEST(DrawQuadTest
, copyStreamVideoDrawQuad
)
343 gfx::Rect
opaqueRect(3, 7, 10, 12);
344 unsigned textureId
= 64;
345 gfx::Transform matrix
= MathUtil::createGfxTransform(0.5, 1, 0.25, 0.75, 0, 1);
346 CREATE_SHARED_STATE();
348 CREATE_QUAD_3_NEW(StreamVideoDrawQuad
, opaqueRect
, textureId
, matrix
);
349 EXPECT_EQ(DrawQuad::STREAM_VIDEO_CONTENT
, copyQuad
->material
);
350 EXPECT_RECT_EQ(opaqueRect
, copyQuad
->opaque_rect
);
351 EXPECT_EQ(textureId
, copyQuad
->texture_id
);
352 EXPECT_EQ(matrix
, copyQuad
->matrix
);
354 CREATE_QUAD_2_ALL(StreamVideoDrawQuad
, textureId
, matrix
);
355 EXPECT_EQ(DrawQuad::STREAM_VIDEO_CONTENT
, copyQuad
->material
);
356 EXPECT_EQ(textureId
, copyQuad
->texture_id
);
357 EXPECT_EQ(matrix
, copyQuad
->matrix
);
360 TEST(DrawQuadTest
, copyTextureDrawQuad
)
362 gfx::Rect
opaqueRect(3, 7, 10, 12);
363 unsigned resourceId
= 82;
364 bool premultipliedAlpha
= true;
365 gfx::RectF
uvRect(0.5f
, 224.f
, 51.f
, 36.f
);
366 const float vertex_opacity
[] = {1.0f
, 1.0f
, 1.0f
, 1.0f
};
368 CREATE_SHARED_STATE();
370 CREATE_QUAD_6_NEW(TextureDrawQuad
, opaqueRect
, resourceId
, premultipliedAlpha
, uvRect
, vertex_opacity
, flipped
);
371 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT
, copyQuad
->material
);
372 EXPECT_RECT_EQ(opaqueRect
, copyQuad
->opaque_rect
);
373 EXPECT_EQ(resourceId
, copyQuad
->resource_id
);
374 EXPECT_EQ(premultipliedAlpha
, copyQuad
->premultiplied_alpha
);
375 EXPECT_FLOAT_RECT_EQ(uvRect
, copyQuad
->uv_rect
);
376 EXPECT_FLOAT_ARRAY_EQ(vertex_opacity
, copyQuad
->vertex_opacity
, 4);
377 EXPECT_EQ(flipped
, copyQuad
->flipped
);
379 CREATE_QUAD_5_ALL(TextureDrawQuad
, resourceId
, premultipliedAlpha
, uvRect
, vertex_opacity
, flipped
);
380 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT
, copyQuad
->material
);
381 EXPECT_EQ(resourceId
, copyQuad
->resource_id
);
382 EXPECT_EQ(premultipliedAlpha
, copyQuad
->premultiplied_alpha
);
383 EXPECT_FLOAT_RECT_EQ(uvRect
, copyQuad
->uv_rect
);
384 EXPECT_FLOAT_ARRAY_EQ(vertex_opacity
, copyQuad
->vertex_opacity
, 4);
385 EXPECT_EQ(flipped
, copyQuad
->flipped
);
388 TEST(DrawQuadTest
, copyTileDrawQuad
)
390 gfx::Rect
opaqueRect(33, 44, 22, 33);
391 unsigned resourceId
= 104;
392 gfx::RectF
texCoordRect(31, 12, 54, 20);
393 gfx::Size
textureSize(85, 32);
394 bool swizzleContents
= true;
395 bool leftEdgeAA
= true;
396 bool topEdgeAA
= true;
397 bool rightEdgeAA
= false;
398 bool bottomEdgeAA
= true;
399 CREATE_SHARED_STATE();
401 CREATE_QUAD_9_NEW(TileDrawQuad
, opaqueRect
, resourceId
, texCoordRect
, textureSize
, swizzleContents
, leftEdgeAA
, topEdgeAA
, rightEdgeAA
, bottomEdgeAA
);
402 EXPECT_EQ(DrawQuad::TILED_CONTENT
, copyQuad
->material
);
403 EXPECT_RECT_EQ(opaqueRect
, copyQuad
->opaque_rect
);
404 EXPECT_EQ(resourceId
, copyQuad
->resource_id
);
405 EXPECT_EQ(texCoordRect
, copyQuad
->tex_coord_rect
);
406 EXPECT_EQ(textureSize
, copyQuad
->texture_size
);
407 EXPECT_EQ(swizzleContents
, copyQuad
->swizzle_contents
);
408 EXPECT_EQ(leftEdgeAA
, copyQuad
->left_edge_aa
);
409 EXPECT_EQ(topEdgeAA
, copyQuad
->top_edge_aa
);
410 EXPECT_EQ(rightEdgeAA
, copyQuad
->right_edge_aa
);
411 EXPECT_EQ(bottomEdgeAA
, copyQuad
->bottom_edge_aa
);
413 CREATE_QUAD_8_ALL(TileDrawQuad
, resourceId
, texCoordRect
, textureSize
, swizzleContents
, leftEdgeAA
, topEdgeAA
, rightEdgeAA
, bottomEdgeAA
);
414 EXPECT_EQ(DrawQuad::TILED_CONTENT
, copyQuad
->material
);
415 EXPECT_EQ(resourceId
, copyQuad
->resource_id
);
416 EXPECT_EQ(texCoordRect
, copyQuad
->tex_coord_rect
);
417 EXPECT_EQ(textureSize
, copyQuad
->texture_size
);
418 EXPECT_EQ(swizzleContents
, copyQuad
->swizzle_contents
);
419 EXPECT_EQ(leftEdgeAA
, copyQuad
->left_edge_aa
);
420 EXPECT_EQ(topEdgeAA
, copyQuad
->top_edge_aa
);
421 EXPECT_EQ(rightEdgeAA
, copyQuad
->right_edge_aa
);
422 EXPECT_EQ(bottomEdgeAA
, copyQuad
->bottom_edge_aa
);
425 TEST(DrawQuadTest
, copyYUVVideoDrawQuad
)
427 gfx::Rect
opaqueRect(3, 7, 10, 12);
428 gfx::SizeF
texScale(0.75, 0.5);
429 VideoLayerImpl::FramePlane yPlane
;
430 yPlane
.resourceId
= 45;
431 yPlane
.size
= gfx::Size(34, 23);
433 VideoLayerImpl::FramePlane uPlane
;
434 uPlane
.resourceId
= 532;
435 uPlane
.size
= gfx::Size(134, 16);
437 VideoLayerImpl::FramePlane vPlane
;
438 vPlane
.resourceId
= 4;
439 vPlane
.size
= gfx::Size(456, 486);
441 CREATE_SHARED_STATE();
443 CREATE_QUAD_5_NEW(YUVVideoDrawQuad
, opaqueRect
, texScale
, yPlane
, uPlane
, vPlane
);
444 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT
, copyQuad
->material
);
445 EXPECT_RECT_EQ(opaqueRect
, copyQuad
->opaque_rect
);
446 EXPECT_EQ(texScale
, copyQuad
->tex_scale
);
447 EXPECT_EQ(yPlane
.resourceId
, copyQuad
->y_plane
.resourceId
);
448 EXPECT_EQ(yPlane
.size
, copyQuad
->y_plane
.size
);
449 EXPECT_EQ(yPlane
.format
, copyQuad
->y_plane
.format
);
450 EXPECT_EQ(uPlane
.resourceId
, copyQuad
->u_plane
.resourceId
);
451 EXPECT_EQ(uPlane
.size
, copyQuad
->u_plane
.size
);
452 EXPECT_EQ(uPlane
.format
, copyQuad
->u_plane
.format
);
453 EXPECT_EQ(vPlane
.resourceId
, copyQuad
->v_plane
.resourceId
);
454 EXPECT_EQ(vPlane
.size
, copyQuad
->v_plane
.size
);
455 EXPECT_EQ(vPlane
.format
, copyQuad
->v_plane
.format
);
457 CREATE_QUAD_4_ALL(YUVVideoDrawQuad
, texScale
, yPlane
, uPlane
, vPlane
);
458 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT
, copyQuad
->material
);
459 EXPECT_EQ(texScale
, copyQuad
->tex_scale
);
460 EXPECT_EQ(yPlane
.resourceId
, copyQuad
->y_plane
.resourceId
);
461 EXPECT_EQ(yPlane
.size
, copyQuad
->y_plane
.size
);
462 EXPECT_EQ(yPlane
.format
, copyQuad
->y_plane
.format
);
463 EXPECT_EQ(uPlane
.resourceId
, copyQuad
->u_plane
.resourceId
);
464 EXPECT_EQ(uPlane
.size
, copyQuad
->u_plane
.size
);
465 EXPECT_EQ(uPlane
.format
, copyQuad
->u_plane
.format
);
466 EXPECT_EQ(vPlane
.resourceId
, copyQuad
->v_plane
.resourceId
);
467 EXPECT_EQ(vPlane
.size
, copyQuad
->v_plane
.size
);
468 EXPECT_EQ(vPlane
.format
, copyQuad
->v_plane
.format
);