Roll src/third_party/WebKit d10c917:a1123a1 (svn 198729:198730)
[chromium-blink-merge.git] / cc / quads / draw_quad_unittest.cc
blob833f388aafb6f257a702d685ddcebaaacfb1d943
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/quads/draw_quad.h"
7 #include <algorithm>
9 #include "base/bind.h"
10 #include "base/compiler_specific.h"
11 #include "cc/base/math_util.h"
12 #include "cc/output/filter_operations.h"
13 #include "cc/quads/checkerboard_draw_quad.h"
14 #include "cc/quads/debug_border_draw_quad.h"
15 #include "cc/quads/io_surface_draw_quad.h"
16 #include "cc/quads/largest_draw_quad.h"
17 #include "cc/quads/picture_draw_quad.h"
18 #include "cc/quads/render_pass.h"
19 #include "cc/quads/render_pass_draw_quad.h"
20 #include "cc/quads/solid_color_draw_quad.h"
21 #include "cc/quads/stream_video_draw_quad.h"
22 #include "cc/quads/surface_draw_quad.h"
23 #include "cc/quads/texture_draw_quad.h"
24 #include "cc/quads/tile_draw_quad.h"
25 #include "cc/quads/yuv_video_draw_quad.h"
26 #include "cc/test/fake_picture_pile_impl.h"
27 #include "cc/test/geometry_test_utils.h"
28 #include "testing/gtest/include/gtest/gtest.h"
29 #include "third_party/skia/include/effects/SkBlurImageFilter.h"
30 #include "ui/gfx/transform.h"
32 namespace cc {
33 namespace {
35 TEST(DrawQuadTest, CopySharedQuadState) {
36 gfx::Transform quad_transform = gfx::Transform(1.0, 0.0, 0.5, 1.0, 0.5, 0.0);
37 gfx::Size layer_bounds(26, 28);
38 gfx::Rect visible_layer_rect(10, 12, 14, 16);
39 gfx::Rect clip_rect(19, 21, 23, 25);
40 bool is_clipped = true;
41 float opacity = 0.25f;
42 SkXfermode::Mode blend_mode = SkXfermode::kMultiply_Mode;
43 int sorting_context_id = 65536;
45 scoped_ptr<SharedQuadState> state(new SharedQuadState);
46 state->SetAll(quad_transform, layer_bounds, visible_layer_rect, clip_rect,
47 is_clipped, opacity, blend_mode, sorting_context_id);
49 scoped_ptr<SharedQuadState> copy(new SharedQuadState);
50 copy->CopyFrom(state.get());
51 EXPECT_EQ(quad_transform, copy->quad_to_target_transform);
52 EXPECT_EQ(visible_layer_rect, copy->visible_quad_layer_rect);
53 EXPECT_EQ(opacity, copy->opacity);
54 EXPECT_EQ(clip_rect, copy->clip_rect);
55 EXPECT_EQ(is_clipped, copy->is_clipped);
56 EXPECT_EQ(blend_mode, copy->blend_mode);
59 SharedQuadState* CreateSharedQuadState(RenderPass* render_pass) {
60 gfx::Transform quad_transform = gfx::Transform(1.0, 0.0, 0.5, 1.0, 0.5, 0.0);
61 gfx::Size layer_bounds(26, 28);
62 gfx::Rect visible_layer_rect(10, 12, 14, 16);
63 gfx::Rect clip_rect(19, 21, 23, 25);
64 bool is_clipped = false;
65 float opacity = 1.f;
66 int sorting_context_id = 65536;
67 SkXfermode::Mode blend_mode = SkXfermode::kSrcOver_Mode;
69 SharedQuadState* state = render_pass->CreateAndAppendSharedQuadState();
70 state->SetAll(quad_transform, layer_bounds, visible_layer_rect, clip_rect,
71 is_clipped, opacity, blend_mode, sorting_context_id);
72 return state;
75 void CompareDrawQuad(DrawQuad* quad,
76 DrawQuad* copy,
77 SharedQuadState* copy_shared_state) {
78 EXPECT_EQ(quad->material, copy->material);
79 EXPECT_EQ(quad->rect, copy->rect);
80 EXPECT_EQ(quad->visible_rect, copy->visible_rect);
81 EXPECT_EQ(quad->opaque_rect, copy->opaque_rect);
82 EXPECT_EQ(quad->needs_blending, copy->needs_blending);
83 EXPECT_EQ(copy_shared_state, copy->shared_quad_state);
86 #define CREATE_SHARED_STATE() \
87 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); \
88 SharedQuadState* shared_state(CreateSharedQuadState(render_pass.get())); \
89 SharedQuadState* copy_shared_state = \
90 render_pass->CreateAndAppendSharedQuadState(); \
91 copy_shared_state->CopyFrom(shared_state);
93 #define QUAD_DATA \
94 gfx::Rect quad_rect(30, 40, 50, 60); \
95 gfx::Rect quad_visible_rect(40, 50, 30, 20); \
96 gfx::Rect quad_opaque_rect(60, 55, 10, 10); \
97 ALLOW_UNUSED_LOCAL(quad_opaque_rect); \
98 bool needs_blending = true; \
99 ALLOW_UNUSED_LOCAL(needs_blending);
101 #define SETUP_AND_COPY_QUAD_NEW(Type, quad) \
102 DrawQuad* copy_new = \
103 render_pass->CopyFromAndAppendDrawQuad(quad_new, copy_shared_state); \
104 CompareDrawQuad(quad_new, copy_new, copy_shared_state); \
105 const Type* copy_quad = Type::MaterialCast(copy_new); \
106 ALLOW_UNUSED_LOCAL(copy_quad);
108 #define SETUP_AND_COPY_QUAD_ALL(Type, quad) \
109 DrawQuad* copy_all = \
110 render_pass->CopyFromAndAppendDrawQuad(quad_all, copy_shared_state); \
111 CompareDrawQuad(quad_all, copy_all, copy_shared_state); \
112 copy_quad = Type::MaterialCast(copy_all);
114 #define SETUP_AND_COPY_QUAD_NEW_RP(Type, quad, a) \
115 DrawQuad* copy_new = render_pass->CopyFromAndAppendRenderPassDrawQuad( \
116 quad_new, copy_shared_state, a); \
117 CompareDrawQuad(quad_new, copy_new, copy_shared_state); \
118 const Type* copy_quad = Type::MaterialCast(copy_new); \
119 ALLOW_UNUSED_LOCAL(copy_quad);
121 #define SETUP_AND_COPY_QUAD_ALL_RP(Type, quad, a) \
122 DrawQuad* copy_all = render_pass->CopyFromAndAppendRenderPassDrawQuad( \
123 quad_all, copy_shared_state, a); \
124 CompareDrawQuad(quad_all, copy_all, copy_shared_state); \
125 copy_quad = Type::MaterialCast(copy_all);
127 #define CREATE_QUAD_1_NEW(Type, a) \
128 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
129 { QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a); } \
130 SETUP_AND_COPY_QUAD_NEW(Type, quad_new);
132 #define CREATE_QUAD_1_ALL(Type, a) \
133 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \
135 QUAD_DATA quad_all->SetAll(shared_state, \
136 quad_rect, \
137 quad_opaque_rect, \
138 quad_visible_rect, \
139 needs_blending, \
140 a); \
142 SETUP_AND_COPY_QUAD_ALL(Type, quad_all);
144 #define CREATE_QUAD_2_NEW(Type, a, b) \
145 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
146 { QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b); } \
147 SETUP_AND_COPY_QUAD_NEW(Type, quad_new);
149 #define CREATE_QUAD_2_ALL(Type, a, b) \
150 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \
152 QUAD_DATA quad_all->SetAll(shared_state, \
153 quad_rect, \
154 quad_opaque_rect, \
155 quad_visible_rect, \
156 needs_blending, \
157 a, \
158 b); \
160 SETUP_AND_COPY_QUAD_ALL(Type, quad_all);
162 #define CREATE_QUAD_3_NEW(Type, a, b, c) \
163 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
164 { QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b, c); } \
165 SETUP_AND_COPY_QUAD_NEW(Type, quad_new);
167 #define CREATE_QUAD_3_ALL(Type, a, b, c) \
168 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \
170 QUAD_DATA quad_all->SetAll(shared_state, \
171 quad_rect, \
172 quad_opaque_rect, \
173 quad_visible_rect, \
174 needs_blending, \
175 a, \
176 b, \
177 c); \
179 SETUP_AND_COPY_QUAD_ALL(Type, quad_all);
181 #define CREATE_QUAD_4_NEW(Type, a, b, c, d) \
182 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
183 { QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b, c, d); } \
184 SETUP_AND_COPY_QUAD_NEW(Type, quad_new);
186 #define CREATE_QUAD_4_ALL(Type, a, b, c, d) \
187 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \
189 QUAD_DATA quad_all->SetAll(shared_state, \
190 quad_rect, \
191 quad_opaque_rect, \
192 quad_visible_rect, \
193 needs_blending, \
194 a, \
195 b, \
196 c, \
197 d); \
199 SETUP_AND_COPY_QUAD_ALL(Type, quad_all);
201 #define CREATE_QUAD_5_NEW(Type, a, b, c, d, e) \
202 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
203 { QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b, c, d, e); } \
204 SETUP_AND_COPY_QUAD_NEW(Type, quad_new);
206 #define CREATE_QUAD_5_ALL(Type, a, b, c, d, e) \
207 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \
209 QUAD_DATA quad_all->SetAll(shared_state, \
210 quad_rect, \
211 quad_opaque_rect, \
212 quad_visible_rect, \
213 needs_blending, \
214 a, \
215 b, \
216 c, \
217 d, \
218 e); \
220 SETUP_AND_COPY_QUAD_ALL(Type, quad_all);
222 #define CREATE_QUAD_6_NEW(Type, a, b, c, d, e, f) \
223 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
224 { QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b, c, d, e, f); } \
225 SETUP_AND_COPY_QUAD_NEW(Type, quad_new);
227 #define CREATE_QUAD_6_ALL(Type, a, b, c, d, e, f) \
228 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \
230 QUAD_DATA quad_all->SetAll(shared_state, \
231 quad_rect, \
232 quad_opaque_rect, \
233 quad_visible_rect, \
234 needs_blending, \
235 a, \
236 b, \
237 c, \
238 d, \
239 e, \
240 f); \
242 SETUP_AND_COPY_QUAD_ALL(Type, quad_all);
244 #define CREATE_QUAD_7_NEW(Type, a, b, c, d, e, f, g) \
245 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
247 QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b, c, d, e, f, g); \
249 SETUP_AND_COPY_QUAD_NEW(Type, quad_new);
251 #define CREATE_QUAD_7_ALL(Type, a, b, c, d, e, f, g) \
252 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \
254 QUAD_DATA quad_all->SetAll(shared_state, \
255 quad_rect, \
256 quad_opaque_rect, \
257 quad_visible_rect, \
258 needs_blending, \
259 a, \
260 b, \
261 c, \
262 d, \
263 e, \
264 f, \
265 g); \
267 SETUP_AND_COPY_QUAD_ALL(Type, quad_all);
269 #define CREATE_QUAD_8_NEW(Type, a, b, c, d, e, f, g, h) \
270 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
272 QUAD_DATA quad_new->SetNew( \
273 shared_state, quad_rect, a, b, c, d, e, f, g, h); \
275 SETUP_AND_COPY_QUAD_NEW(Type, quad_new);
277 #define CREATE_QUAD_8_ALL(Type, a, b, c, d, e, f, g, h) \
278 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \
280 QUAD_DATA quad_all->SetAll(shared_state, \
281 quad_rect, \
282 quad_opaque_rect, \
283 quad_visible_rect, \
284 needs_blending, \
285 a, \
286 b, \
287 c, \
288 d, \
289 e, \
290 f, \
291 g, \
292 h); \
294 SETUP_AND_COPY_QUAD_ALL(Type, quad_all);
296 #define CREATE_QUAD_9_NEW(Type, a, b, c, d, e, f, g, h, i) \
297 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
299 QUAD_DATA quad_new->SetNew( \
300 shared_state, quad_rect, a, b, c, d, e, f, g, h, i); \
302 SETUP_AND_COPY_QUAD_NEW(Type, quad_new);
304 #define CREATE_QUAD_9_ALL(Type, a, b, c, d, e, f, g, h, i) \
305 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \
307 QUAD_DATA quad_all->SetAll(shared_state, quad_rect, quad_opaque_rect, \
308 quad_visible_rect, needs_blending, a, b, c, d, \
309 e, f, g, h, i); \
311 SETUP_AND_COPY_QUAD_ALL(Type, quad_all);
313 #define CREATE_QUAD_10_NEW(Type, a, b, c, d, e, f, g, h, i, j) \
314 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
316 QUAD_DATA quad_new->SetNew( \
317 shared_state, quad_rect, a, b, c, d, e, f, g, h, i, j); \
319 SETUP_AND_COPY_QUAD_NEW(Type, quad_new);
321 #define CREATE_QUAD_10_ALL(Type, a, b, c, d, e, f, g, h, i, j) \
322 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \
324 QUAD_DATA quad_all->SetAll(shared_state, quad_rect, quad_opaque_rect, \
325 quad_visible_rect, needs_blending, a, b, c, d, \
326 e, f, g, h, i, j); \
328 SETUP_AND_COPY_QUAD_ALL(Type, quad_all);
330 #define CREATE_QUAD_11_NEW(Type, a, b, c, d, e, f, g, h, i, j, k) \
331 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
333 QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b, c, d, e, f, g, \
334 h, i, j, k); \
336 SETUP_AND_COPY_QUAD_NEW(Type, quad_new);
338 #define CREATE_QUAD_ALL_RP(Type, a, b, c, d, e, f, g, copy_a) \
339 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \
341 QUAD_DATA quad_all->SetAll(shared_state, \
342 quad_rect, \
343 quad_opaque_rect, \
344 quad_visible_rect, \
345 needs_blending, \
346 a, \
347 b, \
348 c, \
349 d, \
350 e, \
351 f, \
352 g); \
354 SETUP_AND_COPY_QUAD_ALL_RP(Type, quad_all, copy_a);
356 #define CREATE_QUAD_NEW_RP(Type, a, b, c, d, e, f, g, h, copy_a) \
357 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
359 QUAD_DATA quad_new->SetNew( \
360 shared_state, quad_rect, a, b, c, d, e, f, g, h); \
362 SETUP_AND_COPY_QUAD_NEW_RP(Type, quad_new, copy_a);
364 TEST(DrawQuadTest, CopyCheckerboardDrawQuad) {
365 gfx::Rect visible_rect(40, 50, 30, 20);
366 SkColor color = 0xfabb0011;
367 float scale = 2.3f;
368 CREATE_SHARED_STATE();
370 CREATE_QUAD_3_NEW(CheckerboardDrawQuad, visible_rect, color, scale);
371 EXPECT_EQ(DrawQuad::CHECKERBOARD, copy_quad->material);
372 EXPECT_EQ(visible_rect, copy_quad->visible_rect);
373 EXPECT_EQ(color, copy_quad->color);
374 EXPECT_EQ(scale, copy_quad->scale);
376 CREATE_QUAD_2_ALL(CheckerboardDrawQuad, color, scale);
377 EXPECT_EQ(DrawQuad::CHECKERBOARD, copy_quad->material);
378 EXPECT_EQ(color, copy_quad->color);
379 EXPECT_EQ(scale, copy_quad->scale);
382 TEST(DrawQuadTest, CopyDebugBorderDrawQuad) {
383 gfx::Rect visible_rect(40, 50, 30, 20);
384 SkColor color = 0xfabb0011;
385 int width = 99;
386 CREATE_SHARED_STATE();
388 CREATE_QUAD_3_NEW(DebugBorderDrawQuad, visible_rect, color, width);
389 EXPECT_EQ(DrawQuad::DEBUG_BORDER, copy_quad->material);
390 EXPECT_EQ(visible_rect, copy_quad->visible_rect);
391 EXPECT_EQ(color, copy_quad->color);
392 EXPECT_EQ(width, copy_quad->width);
394 CREATE_QUAD_2_ALL(DebugBorderDrawQuad, color, width);
395 EXPECT_EQ(DrawQuad::DEBUG_BORDER, copy_quad->material);
396 EXPECT_EQ(color, copy_quad->color);
397 EXPECT_EQ(width, copy_quad->width);
400 TEST(DrawQuadTest, CopyIOSurfaceDrawQuad) {
401 gfx::Rect opaque_rect(33, 47, 10, 12);
402 gfx::Rect visible_rect(40, 50, 30, 20);
403 gfx::Size size(58, 95);
404 ResourceId resource_id = 72;
405 IOSurfaceDrawQuad::Orientation orientation = IOSurfaceDrawQuad::UNFLIPPED;
406 CREATE_SHARED_STATE();
408 CREATE_QUAD_5_NEW(IOSurfaceDrawQuad,
409 opaque_rect,
410 visible_rect,
411 size,
412 resource_id,
413 orientation);
414 EXPECT_EQ(DrawQuad::IO_SURFACE_CONTENT, copy_quad->material);
415 EXPECT_EQ(visible_rect, copy_quad->visible_rect);
416 EXPECT_EQ(opaque_rect, copy_quad->opaque_rect);
417 EXPECT_EQ(size, copy_quad->io_surface_size);
418 EXPECT_EQ(resource_id, copy_quad->io_surface_resource_id());
419 EXPECT_EQ(orientation, copy_quad->orientation);
421 CREATE_QUAD_3_ALL(IOSurfaceDrawQuad, size, resource_id, orientation);
422 EXPECT_EQ(DrawQuad::IO_SURFACE_CONTENT, copy_quad->material);
423 EXPECT_EQ(size, copy_quad->io_surface_size);
424 EXPECT_EQ(resource_id, copy_quad->io_surface_resource_id());
425 EXPECT_EQ(orientation, copy_quad->orientation);
428 TEST(DrawQuadTest, CopyRenderPassDrawQuad) {
429 gfx::Rect visible_rect(40, 50, 30, 20);
430 RenderPassId render_pass_id(22, 64);
431 ResourceId mask_resource_id = 78;
432 gfx::Vector2dF mask_uv_scale(33.f, 19.f);
433 gfx::Size mask_texture_size(128, 134);
434 FilterOperations filters;
435 filters.Append(FilterOperation::CreateBlurFilter(1.f));
436 gfx::Vector2dF filters_scale;
437 FilterOperations background_filters;
438 background_filters.Append(
439 FilterOperation::CreateGrayscaleFilter(1.f));
441 RenderPassId copied_render_pass_id(235, 11);
442 CREATE_SHARED_STATE();
444 CREATE_QUAD_NEW_RP(RenderPassDrawQuad,
445 visible_rect,
446 render_pass_id,
447 mask_resource_id,
448 mask_uv_scale,
449 mask_texture_size,
450 filters,
451 filters_scale,
452 background_filters,
453 copied_render_pass_id);
454 EXPECT_EQ(DrawQuad::RENDER_PASS, copy_quad->material);
455 EXPECT_EQ(visible_rect, copy_quad->visible_rect);
456 EXPECT_EQ(copied_render_pass_id, copy_quad->render_pass_id);
457 EXPECT_EQ(mask_resource_id, copy_quad->mask_resource_id());
458 EXPECT_EQ(mask_uv_scale.ToString(), copy_quad->mask_uv_scale.ToString());
459 EXPECT_EQ(mask_texture_size.ToString(),
460 copy_quad->mask_texture_size.ToString());
461 EXPECT_EQ(filters, copy_quad->filters);
462 EXPECT_EQ(filters_scale, copy_quad->filters_scale);
463 EXPECT_EQ(background_filters, copy_quad->background_filters);
465 CREATE_QUAD_ALL_RP(RenderPassDrawQuad,
466 render_pass_id,
467 mask_resource_id,
468 mask_uv_scale,
469 mask_texture_size,
470 filters,
471 filters_scale,
472 background_filters,
473 copied_render_pass_id);
474 EXPECT_EQ(DrawQuad::RENDER_PASS, copy_quad->material);
475 EXPECT_EQ(copied_render_pass_id, copy_quad->render_pass_id);
476 EXPECT_EQ(mask_resource_id, copy_quad->mask_resource_id());
477 EXPECT_EQ(mask_uv_scale.ToString(), copy_quad->mask_uv_scale.ToString());
478 EXPECT_EQ(mask_texture_size.ToString(),
479 copy_quad->mask_texture_size.ToString());
480 EXPECT_EQ(filters, copy_quad->filters);
481 EXPECT_EQ(filters_scale, copy_quad->filters_scale);
482 EXPECT_EQ(background_filters, copy_quad->background_filters);
485 TEST(DrawQuadTest, CopySolidColorDrawQuad) {
486 gfx::Rect visible_rect(40, 50, 30, 20);
487 SkColor color = 0x49494949;
488 bool force_anti_aliasing_off = false;
489 CREATE_SHARED_STATE();
491 CREATE_QUAD_3_NEW(
492 SolidColorDrawQuad, visible_rect, color, force_anti_aliasing_off);
493 EXPECT_EQ(DrawQuad::SOLID_COLOR, copy_quad->material);
494 EXPECT_EQ(visible_rect, copy_quad->visible_rect);
495 EXPECT_EQ(color, copy_quad->color);
496 EXPECT_EQ(force_anti_aliasing_off, copy_quad->force_anti_aliasing_off);
498 CREATE_QUAD_2_ALL(SolidColorDrawQuad, color, force_anti_aliasing_off);
499 EXPECT_EQ(DrawQuad::SOLID_COLOR, copy_quad->material);
500 EXPECT_EQ(color, copy_quad->color);
501 EXPECT_EQ(force_anti_aliasing_off, copy_quad->force_anti_aliasing_off);
504 TEST(DrawQuadTest, CopyStreamVideoDrawQuad) {
505 gfx::Rect opaque_rect(33, 47, 10, 12);
506 gfx::Rect visible_rect(40, 50, 30, 20);
507 ResourceId resource_id = 64;
508 gfx::Size resource_size_in_pixels = gfx::Size(40, 41);
509 bool allow_overlay = true;
510 gfx::Transform matrix = gfx::Transform(0.5, 0.25, 1, 0.75, 0, 1);
511 CREATE_SHARED_STATE();
513 CREATE_QUAD_6_NEW(StreamVideoDrawQuad, opaque_rect, visible_rect, resource_id,
514 resource_size_in_pixels, allow_overlay, matrix);
515 EXPECT_EQ(DrawQuad::STREAM_VIDEO_CONTENT, copy_quad->material);
516 EXPECT_EQ(visible_rect, copy_quad->visible_rect);
517 EXPECT_EQ(opaque_rect, copy_quad->opaque_rect);
518 EXPECT_EQ(resource_id, copy_quad->resource_id());
519 EXPECT_EQ(allow_overlay, copy_quad->allow_overlay());
520 EXPECT_EQ(resource_size_in_pixels, copy_quad->resource_size_in_pixels());
521 EXPECT_EQ(matrix, copy_quad->matrix);
523 CREATE_QUAD_4_ALL(StreamVideoDrawQuad, resource_id, resource_size_in_pixels,
524 allow_overlay, matrix);
525 EXPECT_EQ(DrawQuad::STREAM_VIDEO_CONTENT, copy_quad->material);
526 EXPECT_EQ(resource_id, copy_quad->resource_id());
527 EXPECT_EQ(allow_overlay, copy_quad->allow_overlay());
528 EXPECT_EQ(resource_size_in_pixels, copy_quad->resource_size_in_pixels());
529 EXPECT_EQ(matrix, copy_quad->matrix);
532 TEST(DrawQuadTest, CopySurfaceDrawQuad) {
533 gfx::Rect visible_rect(40, 50, 30, 20);
534 SurfaceId surface_id(1234);
535 CREATE_SHARED_STATE();
537 CREATE_QUAD_2_NEW(SurfaceDrawQuad, visible_rect, surface_id);
538 EXPECT_EQ(DrawQuad::SURFACE_CONTENT, copy_quad->material);
539 EXPECT_EQ(visible_rect, copy_quad->visible_rect);
540 EXPECT_EQ(surface_id, copy_quad->surface_id);
542 CREATE_QUAD_1_ALL(SurfaceDrawQuad, surface_id);
543 EXPECT_EQ(DrawQuad::SURFACE_CONTENT, copy_quad->material);
544 EXPECT_EQ(surface_id, copy_quad->surface_id);
548 TEST(DrawQuadTest, CopyTextureDrawQuad) {
549 gfx::Rect opaque_rect(33, 47, 10, 12);
550 gfx::Rect visible_rect(40, 50, 30, 20);
551 unsigned resource_id = 82;
552 gfx::Size resource_size_in_pixels = gfx::Size(40, 41);
553 bool allow_overlay = true;
554 bool premultiplied_alpha = true;
555 gfx::PointF uv_top_left(0.5f, 224.f);
556 gfx::PointF uv_bottom_right(51.5f, 260.f);
557 const float vertex_opacity[] = { 1.0f, 1.0f, 1.0f, 1.0f };
558 bool y_flipped = true;
559 bool nearest_neighbor = true;
560 CREATE_SHARED_STATE();
562 CREATE_QUAD_10_NEW(TextureDrawQuad,
563 opaque_rect,
564 visible_rect,
565 resource_id,
566 premultiplied_alpha,
567 uv_top_left,
568 uv_bottom_right,
569 SK_ColorTRANSPARENT,
570 vertex_opacity,
571 y_flipped,
572 nearest_neighbor);
573 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, copy_quad->material);
574 EXPECT_EQ(visible_rect, copy_quad->visible_rect);
575 EXPECT_EQ(opaque_rect, copy_quad->opaque_rect);
576 EXPECT_EQ(resource_id, copy_quad->resource_id());
577 EXPECT_EQ(premultiplied_alpha, copy_quad->premultiplied_alpha);
578 EXPECT_EQ(uv_top_left, copy_quad->uv_top_left);
579 EXPECT_EQ(uv_bottom_right, copy_quad->uv_bottom_right);
580 EXPECT_FLOAT_ARRAY_EQ(vertex_opacity, copy_quad->vertex_opacity, 4);
581 EXPECT_EQ(y_flipped, copy_quad->y_flipped);
582 EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor);
584 CREATE_QUAD_10_ALL(TextureDrawQuad, resource_id, resource_size_in_pixels,
585 allow_overlay, premultiplied_alpha, uv_top_left,
586 uv_bottom_right, SK_ColorTRANSPARENT, vertex_opacity,
587 y_flipped, nearest_neighbor);
588 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, copy_quad->material);
589 EXPECT_EQ(resource_id, copy_quad->resource_id());
590 EXPECT_EQ(allow_overlay, copy_quad->allow_overlay());
591 EXPECT_EQ(resource_size_in_pixels, copy_quad->resource_size_in_pixels());
592 EXPECT_EQ(premultiplied_alpha, copy_quad->premultiplied_alpha);
593 EXPECT_EQ(uv_top_left, copy_quad->uv_top_left);
594 EXPECT_EQ(uv_bottom_right, copy_quad->uv_bottom_right);
595 EXPECT_FLOAT_ARRAY_EQ(vertex_opacity, copy_quad->vertex_opacity, 4);
596 EXPECT_EQ(y_flipped, copy_quad->y_flipped);
597 EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor);
600 TEST(DrawQuadTest, CopyTileDrawQuad) {
601 gfx::Rect opaque_rect(33, 44, 22, 33);
602 gfx::Rect visible_rect(40, 50, 30, 20);
603 unsigned resource_id = 104;
604 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f);
605 gfx::Size texture_size(85, 32);
606 bool swizzle_contents = true;
607 bool nearest_neighbor = true;
608 CREATE_SHARED_STATE();
610 CREATE_QUAD_7_NEW(TileDrawQuad,
611 opaque_rect,
612 visible_rect,
613 resource_id,
614 tex_coord_rect,
615 texture_size,
616 swizzle_contents,
617 nearest_neighbor);
618 EXPECT_EQ(DrawQuad::TILED_CONTENT, copy_quad->material);
619 EXPECT_EQ(opaque_rect, copy_quad->opaque_rect);
620 EXPECT_EQ(visible_rect, copy_quad->visible_rect);
621 EXPECT_EQ(resource_id, copy_quad->resource_id());
622 EXPECT_EQ(tex_coord_rect, copy_quad->tex_coord_rect);
623 EXPECT_EQ(texture_size, copy_quad->texture_size);
624 EXPECT_EQ(swizzle_contents, copy_quad->swizzle_contents);
625 EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor);
627 CREATE_QUAD_5_ALL(TileDrawQuad,
628 resource_id,
629 tex_coord_rect,
630 texture_size,
631 swizzle_contents,
632 nearest_neighbor);
633 EXPECT_EQ(DrawQuad::TILED_CONTENT, copy_quad->material);
634 EXPECT_EQ(resource_id, copy_quad->resource_id());
635 EXPECT_EQ(tex_coord_rect, copy_quad->tex_coord_rect);
636 EXPECT_EQ(texture_size, copy_quad->texture_size);
637 EXPECT_EQ(swizzle_contents, copy_quad->swizzle_contents);
638 EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor);
641 TEST(DrawQuadTest, CopyYUVVideoDrawQuad) {
642 gfx::Rect opaque_rect(33, 47, 10, 12);
643 gfx::Rect visible_rect(40, 50, 30, 20);
644 gfx::RectF ya_tex_coord_rect(40, 50, 30, 20);
645 gfx::RectF uv_tex_coord_rect(20, 25, 15, 10);
646 gfx::Size ya_tex_size(32, 68);
647 gfx::Size uv_tex_size(41, 51);
648 ResourceId y_plane_resource_id = 45;
649 ResourceId u_plane_resource_id = 532;
650 ResourceId v_plane_resource_id = 4;
651 ResourceId a_plane_resource_id = 63;
652 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::JPEG;
653 CREATE_SHARED_STATE();
655 CREATE_QUAD_11_NEW(YUVVideoDrawQuad, opaque_rect, visible_rect,
656 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size,
657 uv_tex_size, y_plane_resource_id, u_plane_resource_id,
658 v_plane_resource_id, a_plane_resource_id, color_space);
659 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copy_quad->material);
660 EXPECT_EQ(opaque_rect, copy_quad->opaque_rect);
661 EXPECT_EQ(visible_rect, copy_quad->visible_rect);
662 EXPECT_EQ(ya_tex_coord_rect, copy_quad->ya_tex_coord_rect);
663 EXPECT_EQ(uv_tex_coord_rect, copy_quad->uv_tex_coord_rect);
664 EXPECT_EQ(ya_tex_size, copy_quad->ya_tex_size);
665 EXPECT_EQ(uv_tex_size, copy_quad->uv_tex_size);
666 EXPECT_EQ(y_plane_resource_id, copy_quad->y_plane_resource_id());
667 EXPECT_EQ(u_plane_resource_id, copy_quad->u_plane_resource_id());
668 EXPECT_EQ(v_plane_resource_id, copy_quad->v_plane_resource_id());
669 EXPECT_EQ(a_plane_resource_id, copy_quad->a_plane_resource_id());
670 EXPECT_EQ(color_space, copy_quad->color_space);
672 CREATE_QUAD_9_ALL(YUVVideoDrawQuad, ya_tex_coord_rect, uv_tex_coord_rect,
673 ya_tex_size, uv_tex_size, y_plane_resource_id,
674 u_plane_resource_id, v_plane_resource_id,
675 a_plane_resource_id, color_space);
676 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copy_quad->material);
677 EXPECT_EQ(ya_tex_coord_rect, copy_quad->ya_tex_coord_rect);
678 EXPECT_EQ(uv_tex_coord_rect, copy_quad->uv_tex_coord_rect);
679 EXPECT_EQ(ya_tex_size, copy_quad->ya_tex_size);
680 EXPECT_EQ(uv_tex_size, copy_quad->uv_tex_size);
681 EXPECT_EQ(y_plane_resource_id, copy_quad->y_plane_resource_id());
682 EXPECT_EQ(u_plane_resource_id, copy_quad->u_plane_resource_id());
683 EXPECT_EQ(v_plane_resource_id, copy_quad->v_plane_resource_id());
684 EXPECT_EQ(a_plane_resource_id, copy_quad->a_plane_resource_id());
685 EXPECT_EQ(color_space, copy_quad->color_space);
688 TEST(DrawQuadTest, CopyPictureDrawQuad) {
689 gfx::Rect opaque_rect(33, 44, 22, 33);
690 gfx::Rect visible_rect(40, 50, 30, 20);
691 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f);
692 gfx::Size texture_size(85, 32);
693 bool nearest_neighbor = true;
694 ResourceFormat texture_format = RGBA_8888;
695 gfx::Rect content_rect(30, 40, 20, 30);
696 float contents_scale = 3.141592f;
697 scoped_refptr<RasterSource> raster_source =
698 FakePicturePileImpl::CreateEmptyPile(gfx::Size(100, 100),
699 gfx::Size(100, 100));
700 CREATE_SHARED_STATE();
702 CREATE_QUAD_9_NEW(PictureDrawQuad, opaque_rect, visible_rect, tex_coord_rect,
703 texture_size, nearest_neighbor, texture_format,
704 content_rect, contents_scale, raster_source);
705 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, copy_quad->material);
706 EXPECT_EQ(opaque_rect, copy_quad->opaque_rect);
707 EXPECT_EQ(visible_rect, copy_quad->visible_rect);
708 EXPECT_EQ(tex_coord_rect, copy_quad->tex_coord_rect);
709 EXPECT_EQ(texture_size, copy_quad->texture_size);
710 EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor);
711 EXPECT_EQ(texture_format, copy_quad->texture_format);
712 EXPECT_EQ(content_rect, copy_quad->content_rect);
713 EXPECT_EQ(contents_scale, copy_quad->contents_scale);
714 EXPECT_EQ(raster_source, copy_quad->raster_source);
716 CREATE_QUAD_7_ALL(PictureDrawQuad, tex_coord_rect, texture_size,
717 nearest_neighbor, texture_format, content_rect,
718 contents_scale, raster_source);
719 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, copy_quad->material);
720 EXPECT_EQ(tex_coord_rect, copy_quad->tex_coord_rect);
721 EXPECT_EQ(texture_size, copy_quad->texture_size);
722 EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor);
723 EXPECT_EQ(texture_format, copy_quad->texture_format);
724 EXPECT_EQ(content_rect, copy_quad->content_rect);
725 EXPECT_EQ(contents_scale, copy_quad->contents_scale);
726 EXPECT_EQ(raster_source, copy_quad->raster_source);
729 class DrawQuadIteratorTest : public testing::Test {
730 protected:
731 int IterateAndCount(DrawQuad* quad) {
732 num_resources_ = 0;
733 for (ResourceId& resource_id : quad->resources) {
734 ++num_resources_;
735 ++resource_id;
737 return num_resources_;
740 private:
741 int num_resources_;
744 TEST_F(DrawQuadIteratorTest, CheckerboardDrawQuad) {
745 gfx::Rect visible_rect(40, 50, 30, 20);
746 SkColor color = 0xfabb0011;
747 float scale = 3.2f;
749 CREATE_SHARED_STATE();
750 CREATE_QUAD_3_NEW(CheckerboardDrawQuad, visible_rect, color, scale);
751 EXPECT_EQ(0, IterateAndCount(quad_new));
754 TEST_F(DrawQuadIteratorTest, DebugBorderDrawQuad) {
755 gfx::Rect visible_rect(40, 50, 30, 20);
756 SkColor color = 0xfabb0011;
757 int width = 99;
759 CREATE_SHARED_STATE();
760 CREATE_QUAD_3_NEW(DebugBorderDrawQuad, visible_rect, color, width);
761 EXPECT_EQ(0, IterateAndCount(quad_new));
764 TEST_F(DrawQuadIteratorTest, IOSurfaceDrawQuad) {
765 gfx::Rect opaque_rect(33, 47, 10, 12);
766 gfx::Rect visible_rect(40, 50, 30, 20);
767 gfx::Size size(58, 95);
768 ResourceId resource_id = 72;
769 IOSurfaceDrawQuad::Orientation orientation = IOSurfaceDrawQuad::UNFLIPPED;
771 CREATE_SHARED_STATE();
772 CREATE_QUAD_5_NEW(IOSurfaceDrawQuad,
773 opaque_rect,
774 visible_rect,
775 size,
776 resource_id,
777 orientation);
778 EXPECT_EQ(resource_id, quad_new->io_surface_resource_id());
779 EXPECT_EQ(1, IterateAndCount(quad_new));
780 EXPECT_EQ(resource_id + 1, quad_new->io_surface_resource_id());
783 TEST_F(DrawQuadIteratorTest, RenderPassDrawQuad) {
784 gfx::Rect visible_rect(40, 50, 30, 20);
785 RenderPassId render_pass_id(22, 64);
786 ResourceId mask_resource_id = 78;
787 gfx::Vector2dF mask_uv_scale(33.f, 19.f);
788 gfx::Size mask_texture_size(128, 134);
789 FilterOperations filters;
790 filters.Append(FilterOperation::CreateBlurFilter(1.f));
791 gfx::Vector2dF filters_scale(2.f, 3.f);
792 FilterOperations background_filters;
793 background_filters.Append(
794 FilterOperation::CreateGrayscaleFilter(1.f));
796 RenderPassId copied_render_pass_id(235, 11);
798 CREATE_SHARED_STATE();
799 CREATE_QUAD_NEW_RP(RenderPassDrawQuad,
800 visible_rect,
801 render_pass_id,
802 mask_resource_id,
803 mask_uv_scale,
804 mask_texture_size,
805 filters,
806 filters_scale,
807 background_filters,
808 copied_render_pass_id);
809 EXPECT_EQ(mask_resource_id, quad_new->mask_resource_id());
810 EXPECT_EQ(1, IterateAndCount(quad_new));
811 EXPECT_EQ(mask_resource_id + 1, quad_new->mask_resource_id());
813 ResourceId new_mask_resource_id = 0;
814 gfx::Rect quad_rect(30, 40, 50, 60);
815 quad_new->SetNew(shared_state, quad_rect, visible_rect, render_pass_id,
816 new_mask_resource_id, mask_uv_scale, mask_texture_size,
817 filters, filters_scale, background_filters);
818 EXPECT_EQ(0, IterateAndCount(quad_new));
819 EXPECT_EQ(0u, quad_new->mask_resource_id());
822 TEST_F(DrawQuadIteratorTest, SolidColorDrawQuad) {
823 gfx::Rect visible_rect(40, 50, 30, 20);
824 SkColor color = 0x49494949;
825 bool force_anti_aliasing_off = false;
827 CREATE_SHARED_STATE();
828 CREATE_QUAD_3_NEW(
829 SolidColorDrawQuad, visible_rect, color, force_anti_aliasing_off);
830 EXPECT_EQ(0, IterateAndCount(quad_new));
833 TEST_F(DrawQuadIteratorTest, StreamVideoDrawQuad) {
834 gfx::Rect opaque_rect(33, 47, 10, 12);
835 gfx::Rect visible_rect(40, 50, 30, 20);
836 ResourceId resource_id = 64;
837 gfx::Size resource_size_in_pixels = gfx::Size(40, 41);
838 bool allow_overlay = true;
839 gfx::Transform matrix = gfx::Transform(0.5, 0.25, 1, 0.75, 0, 1);
841 CREATE_SHARED_STATE();
842 CREATE_QUAD_6_NEW(StreamVideoDrawQuad, opaque_rect, visible_rect, resource_id,
843 resource_size_in_pixels, allow_overlay, matrix);
844 EXPECT_EQ(resource_id, quad_new->resource_id());
845 EXPECT_EQ(allow_overlay, quad_new->allow_overlay());
846 EXPECT_EQ(resource_size_in_pixels, quad_new->resource_size_in_pixels());
847 EXPECT_EQ(1, IterateAndCount(quad_new));
848 EXPECT_EQ(resource_id + 1, quad_new->resource_id());
851 TEST_F(DrawQuadIteratorTest, SurfaceDrawQuad) {
852 gfx::Rect visible_rect(40, 50, 30, 20);
853 SurfaceId surface_id(4321);
855 CREATE_SHARED_STATE();
856 CREATE_QUAD_2_NEW(SurfaceDrawQuad, visible_rect, surface_id);
857 EXPECT_EQ(0, IterateAndCount(quad_new));
860 TEST_F(DrawQuadIteratorTest, TextureDrawQuad) {
861 gfx::Rect opaque_rect(33, 47, 10, 12);
862 gfx::Rect visible_rect(40, 50, 30, 20);
863 unsigned resource_id = 82;
864 bool premultiplied_alpha = true;
865 gfx::PointF uv_top_left(0.5f, 224.f);
866 gfx::PointF uv_bottom_right(51.5f, 260.f);
867 const float vertex_opacity[] = { 1.0f, 1.0f, 1.0f, 1.0f };
868 bool y_flipped = true;
869 bool nearest_neighbor = true;
871 CREATE_SHARED_STATE();
872 CREATE_QUAD_10_NEW(TextureDrawQuad,
873 opaque_rect,
874 visible_rect,
875 resource_id,
876 premultiplied_alpha,
877 uv_top_left,
878 uv_bottom_right,
879 SK_ColorTRANSPARENT,
880 vertex_opacity,
881 y_flipped,
882 nearest_neighbor);
883 EXPECT_EQ(resource_id, quad_new->resource_id());
884 EXPECT_EQ(1, IterateAndCount(quad_new));
885 EXPECT_EQ(resource_id + 1, quad_new->resource_id());
888 TEST_F(DrawQuadIteratorTest, TileDrawQuad) {
889 gfx::Rect opaque_rect(33, 44, 22, 33);
890 gfx::Rect visible_rect(40, 50, 30, 20);
891 unsigned resource_id = 104;
892 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f);
893 gfx::Size texture_size(85, 32);
894 bool swizzle_contents = true;
895 bool nearest_neighbor = true;
897 CREATE_SHARED_STATE();
898 CREATE_QUAD_7_NEW(TileDrawQuad,
899 opaque_rect,
900 visible_rect,
901 resource_id,
902 tex_coord_rect,
903 texture_size,
904 swizzle_contents,
905 nearest_neighbor);
906 EXPECT_EQ(resource_id, quad_new->resource_id());
907 EXPECT_EQ(1, IterateAndCount(quad_new));
908 EXPECT_EQ(resource_id + 1, quad_new->resource_id());
911 TEST_F(DrawQuadIteratorTest, YUVVideoDrawQuad) {
912 gfx::Rect opaque_rect(33, 47, 10, 12);
913 gfx::Rect visible_rect(40, 50, 30, 20);
914 gfx::RectF ya_tex_coord_rect(0.0f, 0.0f, 0.75f, 0.5f);
915 gfx::RectF uv_tex_coord_rect(0.0f, 0.0f, 0.375f, 0.25f);
916 gfx::Size ya_tex_size(32, 68);
917 gfx::Size uv_tex_size(41, 51);
918 ResourceId y_plane_resource_id = 45;
919 ResourceId u_plane_resource_id = 532;
920 ResourceId v_plane_resource_id = 4;
921 ResourceId a_plane_resource_id = 63;
922 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::JPEG;
924 CREATE_SHARED_STATE();
925 CREATE_QUAD_11_NEW(YUVVideoDrawQuad, opaque_rect, visible_rect,
926 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size,
927 uv_tex_size, y_plane_resource_id, u_plane_resource_id,
928 v_plane_resource_id, a_plane_resource_id, color_space);
929 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copy_quad->material);
930 EXPECT_EQ(y_plane_resource_id, quad_new->y_plane_resource_id());
931 EXPECT_EQ(u_plane_resource_id, quad_new->u_plane_resource_id());
932 EXPECT_EQ(v_plane_resource_id, quad_new->v_plane_resource_id());
933 EXPECT_EQ(a_plane_resource_id, quad_new->a_plane_resource_id());
934 EXPECT_EQ(color_space, quad_new->color_space);
935 EXPECT_EQ(4, IterateAndCount(quad_new));
936 EXPECT_EQ(y_plane_resource_id + 1, quad_new->y_plane_resource_id());
937 EXPECT_EQ(u_plane_resource_id + 1, quad_new->u_plane_resource_id());
938 EXPECT_EQ(v_plane_resource_id + 1, quad_new->v_plane_resource_id());
939 EXPECT_EQ(a_plane_resource_id + 1, quad_new->a_plane_resource_id());
942 // Disabled until picture draw quad is supported for ubercomp: crbug.com/231715
943 TEST_F(DrawQuadIteratorTest, DISABLED_PictureDrawQuad) {
944 gfx::Rect opaque_rect(33, 44, 22, 33);
945 gfx::Rect visible_rect(40, 50, 30, 20);
946 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f);
947 gfx::Size texture_size(85, 32);
948 bool nearest_neighbor = true;
949 ResourceFormat texture_format = RGBA_8888;
950 gfx::Rect content_rect(30, 40, 20, 30);
951 float contents_scale = 3.141592f;
952 scoped_refptr<RasterSource> raster_source =
953 FakePicturePileImpl::CreateEmptyPile(gfx::Size(100, 100),
954 gfx::Size(100, 100));
956 CREATE_SHARED_STATE();
957 CREATE_QUAD_9_NEW(PictureDrawQuad, opaque_rect, visible_rect, tex_coord_rect,
958 texture_size, nearest_neighbor, texture_format,
959 content_rect, contents_scale, raster_source);
960 EXPECT_EQ(0, IterateAndCount(quad_new));
963 TEST(DrawQuadTest, LargestQuadType) {
964 size_t largest = 0;
966 for (int i = 0; i <= DrawQuad::MATERIAL_LAST; ++i) {
967 switch (static_cast<DrawQuad::Material>(i)) {
968 case DrawQuad::CHECKERBOARD:
969 largest = std::max(largest, sizeof(CheckerboardDrawQuad));
970 break;
971 case DrawQuad::DEBUG_BORDER:
972 largest = std::max(largest, sizeof(DebugBorderDrawQuad));
973 break;
974 case DrawQuad::IO_SURFACE_CONTENT:
975 largest = std::max(largest, sizeof(IOSurfaceDrawQuad));
976 break;
977 case DrawQuad::PICTURE_CONTENT:
978 largest = std::max(largest, sizeof(PictureDrawQuad));
979 break;
980 case DrawQuad::TEXTURE_CONTENT:
981 largest = std::max(largest, sizeof(TextureDrawQuad));
982 break;
983 case DrawQuad::RENDER_PASS:
984 largest = std::max(largest, sizeof(RenderPassDrawQuad));
985 break;
986 case DrawQuad::SOLID_COLOR:
987 largest = std::max(largest, sizeof(SolidColorDrawQuad));
988 break;
989 case DrawQuad::SURFACE_CONTENT:
990 largest = std::max(largest, sizeof(SurfaceDrawQuad));
991 break;
992 case DrawQuad::TILED_CONTENT:
993 largest = std::max(largest, sizeof(TileDrawQuad));
994 break;
995 case DrawQuad::STREAM_VIDEO_CONTENT:
996 largest = std::max(largest, sizeof(StreamVideoDrawQuad));
997 break;
998 case DrawQuad::YUV_VIDEO_CONTENT:
999 largest = std::max(largest, sizeof(YUVVideoDrawQuad));
1000 break;
1001 case DrawQuad::INVALID:
1002 break;
1005 EXPECT_EQ(LargestDrawQuadSize(), largest);
1007 if (!HasFailure())
1008 return;
1010 // On failure, output the size of all quads for debugging.
1011 LOG(ERROR) << "largest " << largest;
1012 LOG(ERROR) << "kLargestDrawQuad " << LargestDrawQuadSize();
1013 for (int i = 0; i <= DrawQuad::MATERIAL_LAST; ++i) {
1014 switch (static_cast<DrawQuad::Material>(i)) {
1015 case DrawQuad::CHECKERBOARD:
1016 LOG(ERROR) << "CheckerboardDrawQuad " << sizeof(CheckerboardDrawQuad);
1017 break;
1018 case DrawQuad::DEBUG_BORDER:
1019 LOG(ERROR) << "DebugBorderDrawQuad " << sizeof(DebugBorderDrawQuad);
1020 break;
1021 case DrawQuad::IO_SURFACE_CONTENT:
1022 LOG(ERROR) << "IOSurfaceDrawQuad " << sizeof(IOSurfaceDrawQuad);
1023 break;
1024 case DrawQuad::PICTURE_CONTENT:
1025 LOG(ERROR) << "PictureDrawQuad " << sizeof(PictureDrawQuad);
1026 break;
1027 case DrawQuad::TEXTURE_CONTENT:
1028 LOG(ERROR) << "TextureDrawQuad " << sizeof(TextureDrawQuad);
1029 break;
1030 case DrawQuad::RENDER_PASS:
1031 LOG(ERROR) << "RenderPassDrawQuad " << sizeof(RenderPassDrawQuad);
1032 break;
1033 case DrawQuad::SOLID_COLOR:
1034 LOG(ERROR) << "SolidColorDrawQuad " << sizeof(SolidColorDrawQuad);
1035 break;
1036 case DrawQuad::SURFACE_CONTENT:
1037 LOG(ERROR) << "SurfaceDrawQuad " << sizeof(SurfaceDrawQuad);
1038 break;
1039 case DrawQuad::TILED_CONTENT:
1040 LOG(ERROR) << "TileDrawQuad " << sizeof(TileDrawQuad);
1041 break;
1042 case DrawQuad::STREAM_VIDEO_CONTENT:
1043 LOG(ERROR) << "StreamVideoDrawQuad " << sizeof(StreamVideoDrawQuad);
1044 break;
1045 case DrawQuad::YUV_VIDEO_CONTENT:
1046 LOG(ERROR) << "YUVVideoDrawQuad " << sizeof(YUVVideoDrawQuad);
1047 break;
1048 case DrawQuad::INVALID:
1049 break;
1054 } // namespace
1055 } // namespace cc