Add @VisibleForTesting to fix ChromePublic release build.
[chromium-blink-merge.git] / cc / quads / draw_quad_unittest.cc
blobe66bcdffe73a36f6589e134b2087e536f0830543
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 content_bounds(26, 28);
38 gfx::Rect visible_content_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,
47 content_bounds,
48 visible_content_rect,
49 clip_rect,
50 is_clipped,
51 opacity,
52 blend_mode,
53 sorting_context_id);
55 scoped_ptr<SharedQuadState> copy(new SharedQuadState);
56 copy->CopyFrom(state.get());
57 EXPECT_EQ(quad_transform, copy->content_to_target_transform);
58 EXPECT_EQ(visible_content_rect, copy->visible_content_rect);
59 EXPECT_EQ(opacity, copy->opacity);
60 EXPECT_EQ(clip_rect, copy->clip_rect);
61 EXPECT_EQ(is_clipped, copy->is_clipped);
62 EXPECT_EQ(blend_mode, copy->blend_mode);
65 SharedQuadState* CreateSharedQuadState(RenderPass* render_pass) {
66 gfx::Transform quad_transform = gfx::Transform(1.0, 0.0, 0.5, 1.0, 0.5, 0.0);
67 gfx::Size content_bounds(26, 28);
68 gfx::Rect visible_content_rect(10, 12, 14, 16);
69 gfx::Rect clip_rect(19, 21, 23, 25);
70 bool is_clipped = false;
71 float opacity = 1.f;
72 int sorting_context_id = 65536;
73 SkXfermode::Mode blend_mode = SkXfermode::kSrcOver_Mode;
75 SharedQuadState* state = render_pass->CreateAndAppendSharedQuadState();
76 state->SetAll(quad_transform,
77 content_bounds,
78 visible_content_rect,
79 clip_rect,
80 is_clipped,
81 opacity,
82 blend_mode,
83 sorting_context_id);
84 return state;
87 void CompareDrawQuad(DrawQuad* quad,
88 DrawQuad* copy,
89 SharedQuadState* copy_shared_state) {
90 EXPECT_EQ(quad->material, copy->material);
91 EXPECT_EQ(quad->rect, copy->rect);
92 EXPECT_EQ(quad->visible_rect, copy->visible_rect);
93 EXPECT_EQ(quad->opaque_rect, copy->opaque_rect);
94 EXPECT_EQ(quad->needs_blending, copy->needs_blending);
95 EXPECT_EQ(copy_shared_state, copy->shared_quad_state);
98 #define CREATE_SHARED_STATE() \
99 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); \
100 SharedQuadState* shared_state(CreateSharedQuadState(render_pass.get())); \
101 SharedQuadState* copy_shared_state = \
102 render_pass->CreateAndAppendSharedQuadState(); \
103 copy_shared_state->CopyFrom(shared_state);
105 #define QUAD_DATA \
106 gfx::Rect quad_rect(30, 40, 50, 60); \
107 gfx::Rect quad_visible_rect(40, 50, 30, 20); \
108 gfx::Rect quad_opaque_rect(60, 55, 10, 10); \
109 ALLOW_UNUSED_LOCAL(quad_opaque_rect); \
110 bool needs_blending = true; \
111 ALLOW_UNUSED_LOCAL(needs_blending);
113 #define SETUP_AND_COPY_QUAD_NEW(Type, quad) \
114 DrawQuad* copy_new = \
115 render_pass->CopyFromAndAppendDrawQuad(quad_new, copy_shared_state); \
116 CompareDrawQuad(quad_new, copy_new, copy_shared_state); \
117 const Type* copy_quad = Type::MaterialCast(copy_new); \
118 ALLOW_UNUSED_LOCAL(copy_quad);
120 #define SETUP_AND_COPY_QUAD_ALL(Type, quad) \
121 DrawQuad* copy_all = \
122 render_pass->CopyFromAndAppendDrawQuad(quad_all, copy_shared_state); \
123 CompareDrawQuad(quad_all, copy_all, copy_shared_state); \
124 copy_quad = Type::MaterialCast(copy_all);
126 #define SETUP_AND_COPY_QUAD_NEW_RP(Type, quad, a) \
127 DrawQuad* copy_new = render_pass->CopyFromAndAppendRenderPassDrawQuad( \
128 quad_new, copy_shared_state, a); \
129 CompareDrawQuad(quad_new, copy_new, copy_shared_state); \
130 const Type* copy_quad = Type::MaterialCast(copy_new); \
131 ALLOW_UNUSED_LOCAL(copy_quad);
133 #define SETUP_AND_COPY_QUAD_ALL_RP(Type, quad, a) \
134 DrawQuad* copy_all = render_pass->CopyFromAndAppendRenderPassDrawQuad( \
135 quad_all, copy_shared_state, a); \
136 CompareDrawQuad(quad_all, copy_all, copy_shared_state); \
137 copy_quad = Type::MaterialCast(copy_all);
139 #define CREATE_QUAD_1_NEW(Type, a) \
140 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
141 { QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a); } \
142 SETUP_AND_COPY_QUAD_NEW(Type, quad_new);
144 #define CREATE_QUAD_1_ALL(Type, a) \
145 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \
147 QUAD_DATA quad_all->SetAll(shared_state, \
148 quad_rect, \
149 quad_opaque_rect, \
150 quad_visible_rect, \
151 needs_blending, \
152 a); \
154 SETUP_AND_COPY_QUAD_ALL(Type, quad_all);
156 #define CREATE_QUAD_2_NEW(Type, a, b) \
157 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
158 { QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b); } \
159 SETUP_AND_COPY_QUAD_NEW(Type, quad_new);
161 #define CREATE_QUAD_2_ALL(Type, a, b) \
162 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \
164 QUAD_DATA quad_all->SetAll(shared_state, \
165 quad_rect, \
166 quad_opaque_rect, \
167 quad_visible_rect, \
168 needs_blending, \
169 a, \
170 b); \
172 SETUP_AND_COPY_QUAD_ALL(Type, quad_all);
174 #define CREATE_QUAD_3_NEW(Type, a, b, c) \
175 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
176 { QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b, c); } \
177 SETUP_AND_COPY_QUAD_NEW(Type, quad_new);
179 #define CREATE_QUAD_3_ALL(Type, a, b, c) \
180 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \
182 QUAD_DATA quad_all->SetAll(shared_state, \
183 quad_rect, \
184 quad_opaque_rect, \
185 quad_visible_rect, \
186 needs_blending, \
187 a, \
188 b, \
189 c); \
191 SETUP_AND_COPY_QUAD_ALL(Type, quad_all);
193 #define CREATE_QUAD_4_NEW(Type, a, b, c, d) \
194 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
195 { QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b, c, d); } \
196 SETUP_AND_COPY_QUAD_NEW(Type, quad_new);
198 #define CREATE_QUAD_4_ALL(Type, a, b, c, d) \
199 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \
201 QUAD_DATA quad_all->SetAll(shared_state, \
202 quad_rect, \
203 quad_opaque_rect, \
204 quad_visible_rect, \
205 needs_blending, \
206 a, \
207 b, \
208 c, \
209 d); \
211 SETUP_AND_COPY_QUAD_ALL(Type, quad_all);
213 #define CREATE_QUAD_5_NEW(Type, a, b, c, d, e) \
214 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
215 { QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b, c, d, e); } \
216 SETUP_AND_COPY_QUAD_NEW(Type, quad_new);
218 #define CREATE_QUAD_5_ALL(Type, a, b, c, d, e) \
219 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \
221 QUAD_DATA quad_all->SetAll(shared_state, \
222 quad_rect, \
223 quad_opaque_rect, \
224 quad_visible_rect, \
225 needs_blending, \
226 a, \
227 b, \
228 c, \
229 d, \
230 e); \
232 SETUP_AND_COPY_QUAD_ALL(Type, quad_all);
234 #define CREATE_QUAD_6_NEW(Type, a, b, c, d, e, f) \
235 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
236 { QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b, c, d, e, f); } \
237 SETUP_AND_COPY_QUAD_NEW(Type, quad_new);
239 #define CREATE_QUAD_6_ALL(Type, a, b, c, d, e, f) \
240 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \
242 QUAD_DATA quad_all->SetAll(shared_state, \
243 quad_rect, \
244 quad_opaque_rect, \
245 quad_visible_rect, \
246 needs_blending, \
247 a, \
248 b, \
249 c, \
250 d, \
251 e, \
252 f); \
254 SETUP_AND_COPY_QUAD_ALL(Type, quad_all);
256 #define CREATE_QUAD_7_NEW(Type, a, b, c, d, e, f, g) \
257 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
259 QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b, c, d, e, f, g); \
261 SETUP_AND_COPY_QUAD_NEW(Type, quad_new);
263 #define CREATE_QUAD_7_ALL(Type, a, b, c, d, e, f, g) \
264 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \
266 QUAD_DATA quad_all->SetAll(shared_state, \
267 quad_rect, \
268 quad_opaque_rect, \
269 quad_visible_rect, \
270 needs_blending, \
271 a, \
272 b, \
273 c, \
274 d, \
275 e, \
276 f, \
277 g); \
279 SETUP_AND_COPY_QUAD_ALL(Type, quad_all);
281 #define CREATE_QUAD_8_NEW(Type, a, b, c, d, e, f, g, h) \
282 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
284 QUAD_DATA quad_new->SetNew( \
285 shared_state, quad_rect, a, b, c, d, e, f, g, h); \
287 SETUP_AND_COPY_QUAD_NEW(Type, quad_new);
289 #define CREATE_QUAD_8_ALL(Type, a, b, c, d, e, f, g, h) \
290 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \
292 QUAD_DATA quad_all->SetAll(shared_state, \
293 quad_rect, \
294 quad_opaque_rect, \
295 quad_visible_rect, \
296 needs_blending, \
297 a, \
298 b, \
299 c, \
300 d, \
301 e, \
302 f, \
303 g, \
304 h); \
306 SETUP_AND_COPY_QUAD_ALL(Type, quad_all);
308 #define CREATE_QUAD_9_NEW(Type, a, b, c, d, e, f, g, h, i) \
309 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
311 QUAD_DATA quad_new->SetNew( \
312 shared_state, quad_rect, a, b, c, d, e, f, g, h, i); \
314 SETUP_AND_COPY_QUAD_NEW(Type, quad_new);
316 #define CREATE_QUAD_9_ALL(Type, a, b, c, d, e, f, g, h, i) \
317 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \
319 QUAD_DATA quad_all->SetAll(shared_state, quad_rect, quad_opaque_rect, \
320 quad_visible_rect, needs_blending, a, b, c, d, \
321 e, f, g, h, i); \
323 SETUP_AND_COPY_QUAD_ALL(Type, quad_all);
325 #define CREATE_QUAD_10_NEW(Type, a, b, c, d, e, f, g, h, i, j) \
326 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
328 QUAD_DATA quad_new->SetNew( \
329 shared_state, quad_rect, a, b, c, d, e, f, g, h, i, j); \
331 SETUP_AND_COPY_QUAD_NEW(Type, quad_new);
333 #define CREATE_QUAD_11_NEW(Type, a, b, c, d, e, f, g, h, i, j, k) \
334 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
336 QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b, c, d, e, f, g, \
337 h, i, j, k); \
339 SETUP_AND_COPY_QUAD_NEW(Type, quad_new);
341 #define CREATE_QUAD_ALL_RP(Type, a, b, c, d, e, f, g, copy_a) \
342 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \
344 QUAD_DATA quad_all->SetAll(shared_state, \
345 quad_rect, \
346 quad_opaque_rect, \
347 quad_visible_rect, \
348 needs_blending, \
349 a, \
350 b, \
351 c, \
352 d, \
353 e, \
354 f, \
355 g); \
357 SETUP_AND_COPY_QUAD_ALL_RP(Type, quad_all, copy_a);
359 #define CREATE_QUAD_NEW_RP(Type, a, b, c, d, e, f, g, h, copy_a) \
360 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
362 QUAD_DATA quad_new->SetNew( \
363 shared_state, quad_rect, a, b, c, d, e, f, g, h); \
365 SETUP_AND_COPY_QUAD_NEW_RP(Type, quad_new, copy_a);
367 TEST(DrawQuadTest, CopyCheckerboardDrawQuad) {
368 gfx::Rect visible_rect(40, 50, 30, 20);
369 SkColor color = 0xfabb0011;
370 float scale = 2.3f;
371 CREATE_SHARED_STATE();
373 CREATE_QUAD_3_NEW(CheckerboardDrawQuad, visible_rect, color, scale);
374 EXPECT_EQ(DrawQuad::CHECKERBOARD, copy_quad->material);
375 EXPECT_EQ(visible_rect, copy_quad->visible_rect);
376 EXPECT_EQ(color, copy_quad->color);
377 EXPECT_EQ(scale, copy_quad->scale);
379 CREATE_QUAD_2_ALL(CheckerboardDrawQuad, color, scale);
380 EXPECT_EQ(DrawQuad::CHECKERBOARD, copy_quad->material);
381 EXPECT_EQ(color, copy_quad->color);
382 EXPECT_EQ(scale, copy_quad->scale);
385 TEST(DrawQuadTest, CopyDebugBorderDrawQuad) {
386 gfx::Rect visible_rect(40, 50, 30, 20);
387 SkColor color = 0xfabb0011;
388 int width = 99;
389 CREATE_SHARED_STATE();
391 CREATE_QUAD_3_NEW(DebugBorderDrawQuad, visible_rect, color, width);
392 EXPECT_EQ(DrawQuad::DEBUG_BORDER, copy_quad->material);
393 EXPECT_EQ(visible_rect, copy_quad->visible_rect);
394 EXPECT_EQ(color, copy_quad->color);
395 EXPECT_EQ(width, copy_quad->width);
397 CREATE_QUAD_2_ALL(DebugBorderDrawQuad, color, width);
398 EXPECT_EQ(DrawQuad::DEBUG_BORDER, copy_quad->material);
399 EXPECT_EQ(color, copy_quad->color);
400 EXPECT_EQ(width, copy_quad->width);
403 TEST(DrawQuadTest, CopyIOSurfaceDrawQuad) {
404 gfx::Rect opaque_rect(33, 47, 10, 12);
405 gfx::Rect visible_rect(40, 50, 30, 20);
406 gfx::Size size(58, 95);
407 ResourceId resource_id = 72;
408 IOSurfaceDrawQuad::Orientation orientation = IOSurfaceDrawQuad::UNFLIPPED;
409 CREATE_SHARED_STATE();
411 CREATE_QUAD_5_NEW(IOSurfaceDrawQuad,
412 opaque_rect,
413 visible_rect,
414 size,
415 resource_id,
416 orientation);
417 EXPECT_EQ(DrawQuad::IO_SURFACE_CONTENT, copy_quad->material);
418 EXPECT_EQ(visible_rect, copy_quad->visible_rect);
419 EXPECT_EQ(opaque_rect, copy_quad->opaque_rect);
420 EXPECT_EQ(size, copy_quad->io_surface_size);
421 EXPECT_EQ(resource_id, copy_quad->io_surface_resource_id);
422 EXPECT_EQ(orientation, copy_quad->orientation);
424 CREATE_QUAD_3_ALL(IOSurfaceDrawQuad, size, resource_id, orientation);
425 EXPECT_EQ(DrawQuad::IO_SURFACE_CONTENT, copy_quad->material);
426 EXPECT_EQ(size, copy_quad->io_surface_size);
427 EXPECT_EQ(resource_id, copy_quad->io_surface_resource_id);
428 EXPECT_EQ(orientation, copy_quad->orientation);
431 TEST(DrawQuadTest, CopyRenderPassDrawQuad) {
432 gfx::Rect visible_rect(40, 50, 30, 20);
433 RenderPassId render_pass_id(22, 64);
434 ResourceId mask_resource_id = 78;
435 gfx::Vector2dF mask_uv_scale(33.f, 19.f);
436 gfx::Size mask_texture_size(128, 134);
437 FilterOperations filters;
438 filters.Append(FilterOperation::CreateBlurFilter(1.f));
439 gfx::Vector2dF filters_scale;
440 FilterOperations background_filters;
441 background_filters.Append(
442 FilterOperation::CreateGrayscaleFilter(1.f));
444 RenderPassId copied_render_pass_id(235, 11);
445 CREATE_SHARED_STATE();
447 CREATE_QUAD_NEW_RP(RenderPassDrawQuad,
448 visible_rect,
449 render_pass_id,
450 mask_resource_id,
451 mask_uv_scale,
452 mask_texture_size,
453 filters,
454 filters_scale,
455 background_filters,
456 copied_render_pass_id);
457 EXPECT_EQ(DrawQuad::RENDER_PASS, copy_quad->material);
458 EXPECT_EQ(visible_rect, copy_quad->visible_rect);
459 EXPECT_EQ(copied_render_pass_id, copy_quad->render_pass_id);
460 EXPECT_EQ(mask_resource_id, copy_quad->mask_resource_id);
461 EXPECT_EQ(mask_uv_scale.ToString(), copy_quad->mask_uv_scale.ToString());
462 EXPECT_EQ(mask_texture_size.ToString(),
463 copy_quad->mask_texture_size.ToString());
464 EXPECT_EQ(filters, copy_quad->filters);
465 EXPECT_EQ(filters_scale, copy_quad->filters_scale);
466 EXPECT_EQ(background_filters, copy_quad->background_filters);
468 CREATE_QUAD_ALL_RP(RenderPassDrawQuad,
469 render_pass_id,
470 mask_resource_id,
471 mask_uv_scale,
472 mask_texture_size,
473 filters,
474 filters_scale,
475 background_filters,
476 copied_render_pass_id);
477 EXPECT_EQ(DrawQuad::RENDER_PASS, copy_quad->material);
478 EXPECT_EQ(copied_render_pass_id, copy_quad->render_pass_id);
479 EXPECT_EQ(mask_resource_id, copy_quad->mask_resource_id);
480 EXPECT_EQ(mask_uv_scale.ToString(), copy_quad->mask_uv_scale.ToString());
481 EXPECT_EQ(mask_texture_size.ToString(),
482 copy_quad->mask_texture_size.ToString());
483 EXPECT_EQ(filters, copy_quad->filters);
484 EXPECT_EQ(filters_scale, copy_quad->filters_scale);
485 EXPECT_EQ(background_filters, copy_quad->background_filters);
488 TEST(DrawQuadTest, CopySolidColorDrawQuad) {
489 gfx::Rect visible_rect(40, 50, 30, 20);
490 SkColor color = 0x49494949;
491 bool force_anti_aliasing_off = false;
492 CREATE_SHARED_STATE();
494 CREATE_QUAD_3_NEW(
495 SolidColorDrawQuad, visible_rect, color, force_anti_aliasing_off);
496 EXPECT_EQ(DrawQuad::SOLID_COLOR, copy_quad->material);
497 EXPECT_EQ(visible_rect, copy_quad->visible_rect);
498 EXPECT_EQ(color, copy_quad->color);
499 EXPECT_EQ(force_anti_aliasing_off, copy_quad->force_anti_aliasing_off);
501 CREATE_QUAD_2_ALL(SolidColorDrawQuad, color, force_anti_aliasing_off);
502 EXPECT_EQ(DrawQuad::SOLID_COLOR, copy_quad->material);
503 EXPECT_EQ(color, copy_quad->color);
504 EXPECT_EQ(force_anti_aliasing_off, copy_quad->force_anti_aliasing_off);
507 TEST(DrawQuadTest, CopyStreamVideoDrawQuad) {
508 gfx::Rect opaque_rect(33, 47, 10, 12);
509 gfx::Rect visible_rect(40, 50, 30, 20);
510 ResourceId resource_id = 64;
511 gfx::Transform matrix = gfx::Transform(0.5, 0.25, 1, 0.75, 0, 1);
512 CREATE_SHARED_STATE();
514 CREATE_QUAD_4_NEW(
515 StreamVideoDrawQuad, opaque_rect, visible_rect, resource_id, matrix);
516 EXPECT_EQ(DrawQuad::STREAM_VIDEO_CONTENT, copy_quad->material);
517 EXPECT_EQ(visible_rect, copy_quad->visible_rect);
518 EXPECT_EQ(opaque_rect, copy_quad->opaque_rect);
519 EXPECT_EQ(resource_id, copy_quad->resource_id);
520 EXPECT_EQ(matrix, copy_quad->matrix);
522 CREATE_QUAD_2_ALL(StreamVideoDrawQuad, resource_id, matrix);
523 EXPECT_EQ(DrawQuad::STREAM_VIDEO_CONTENT, copy_quad->material);
524 EXPECT_EQ(resource_id, copy_quad->resource_id);
525 EXPECT_EQ(matrix, copy_quad->matrix);
528 TEST(DrawQuadTest, CopySurfaceDrawQuad) {
529 gfx::Rect visible_rect(40, 50, 30, 20);
530 SurfaceId surface_id(1234);
531 CREATE_SHARED_STATE();
533 CREATE_QUAD_2_NEW(SurfaceDrawQuad, visible_rect, surface_id);
534 EXPECT_EQ(DrawQuad::SURFACE_CONTENT, copy_quad->material);
535 EXPECT_EQ(visible_rect, copy_quad->visible_rect);
536 EXPECT_EQ(surface_id, copy_quad->surface_id);
538 CREATE_QUAD_1_ALL(SurfaceDrawQuad, surface_id);
539 EXPECT_EQ(DrawQuad::SURFACE_CONTENT, copy_quad->material);
540 EXPECT_EQ(surface_id, copy_quad->surface_id);
544 TEST(DrawQuadTest, CopyTextureDrawQuad) {
545 gfx::Rect opaque_rect(33, 47, 10, 12);
546 gfx::Rect visible_rect(40, 50, 30, 20);
547 unsigned resource_id = 82;
548 bool premultiplied_alpha = true;
549 gfx::PointF uv_top_left(0.5f, 224.f);
550 gfx::PointF uv_bottom_right(51.5f, 260.f);
551 const float vertex_opacity[] = { 1.0f, 1.0f, 1.0f, 1.0f };
552 bool y_flipped = true;
553 bool nearest_neighbor = true;
554 CREATE_SHARED_STATE();
556 CREATE_QUAD_10_NEW(TextureDrawQuad,
557 opaque_rect,
558 visible_rect,
559 resource_id,
560 premultiplied_alpha,
561 uv_top_left,
562 uv_bottom_right,
563 SK_ColorTRANSPARENT,
564 vertex_opacity,
565 y_flipped,
566 nearest_neighbor);
567 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, copy_quad->material);
568 EXPECT_EQ(visible_rect, copy_quad->visible_rect);
569 EXPECT_EQ(opaque_rect, copy_quad->opaque_rect);
570 EXPECT_EQ(resource_id, copy_quad->resource_id);
571 EXPECT_EQ(premultiplied_alpha, copy_quad->premultiplied_alpha);
572 EXPECT_EQ(uv_top_left, copy_quad->uv_top_left);
573 EXPECT_EQ(uv_bottom_right, copy_quad->uv_bottom_right);
574 EXPECT_FLOAT_ARRAY_EQ(vertex_opacity, copy_quad->vertex_opacity, 4);
575 EXPECT_EQ(y_flipped, copy_quad->y_flipped);
576 EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor);
578 CREATE_QUAD_8_ALL(TextureDrawQuad,
579 resource_id,
580 premultiplied_alpha,
581 uv_top_left,
582 uv_bottom_right,
583 SK_ColorTRANSPARENT,
584 vertex_opacity,
585 y_flipped,
586 nearest_neighbor);
587 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, copy_quad->material);
588 EXPECT_EQ(resource_id, copy_quad->resource_id);
589 EXPECT_EQ(premultiplied_alpha, copy_quad->premultiplied_alpha);
590 EXPECT_EQ(uv_top_left, copy_quad->uv_top_left);
591 EXPECT_EQ(uv_bottom_right, copy_quad->uv_bottom_right);
592 EXPECT_FLOAT_ARRAY_EQ(vertex_opacity, copy_quad->vertex_opacity, 4);
593 EXPECT_EQ(y_flipped, copy_quad->y_flipped);
594 EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor);
597 TEST(DrawQuadTest, CopyTileDrawQuad) {
598 gfx::Rect opaque_rect(33, 44, 22, 33);
599 gfx::Rect visible_rect(40, 50, 30, 20);
600 unsigned resource_id = 104;
601 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f);
602 gfx::Size texture_size(85, 32);
603 bool swizzle_contents = true;
604 bool nearest_neighbor = true;
605 CREATE_SHARED_STATE();
607 CREATE_QUAD_7_NEW(TileDrawQuad,
608 opaque_rect,
609 visible_rect,
610 resource_id,
611 tex_coord_rect,
612 texture_size,
613 swizzle_contents,
614 nearest_neighbor);
615 EXPECT_EQ(DrawQuad::TILED_CONTENT, copy_quad->material);
616 EXPECT_EQ(opaque_rect, copy_quad->opaque_rect);
617 EXPECT_EQ(visible_rect, copy_quad->visible_rect);
618 EXPECT_EQ(resource_id, copy_quad->resource_id);
619 EXPECT_EQ(tex_coord_rect, copy_quad->tex_coord_rect);
620 EXPECT_EQ(texture_size, copy_quad->texture_size);
621 EXPECT_EQ(swizzle_contents, copy_quad->swizzle_contents);
622 EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor);
624 CREATE_QUAD_5_ALL(TileDrawQuad,
625 resource_id,
626 tex_coord_rect,
627 texture_size,
628 swizzle_contents,
629 nearest_neighbor);
630 EXPECT_EQ(DrawQuad::TILED_CONTENT, copy_quad->material);
631 EXPECT_EQ(resource_id, copy_quad->resource_id);
632 EXPECT_EQ(tex_coord_rect, copy_quad->tex_coord_rect);
633 EXPECT_EQ(texture_size, copy_quad->texture_size);
634 EXPECT_EQ(swizzle_contents, copy_quad->swizzle_contents);
635 EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor);
638 TEST(DrawQuadTest, CopyYUVVideoDrawQuad) {
639 gfx::Rect opaque_rect(33, 47, 10, 12);
640 gfx::Rect visible_rect(40, 50, 30, 20);
641 gfx::RectF ya_tex_coord_rect(40, 50, 30, 20);
642 gfx::RectF uv_tex_coord_rect(20, 25, 15, 10);
643 gfx::Size ya_tex_size(32, 68);
644 gfx::Size uv_tex_size(41, 51);
645 ResourceId y_plane_resource_id = 45;
646 ResourceId u_plane_resource_id = 532;
647 ResourceId v_plane_resource_id = 4;
648 ResourceId a_plane_resource_id = 63;
649 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::JPEG;
650 CREATE_SHARED_STATE();
652 CREATE_QUAD_11_NEW(YUVVideoDrawQuad, opaque_rect, visible_rect,
653 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size,
654 uv_tex_size, y_plane_resource_id, u_plane_resource_id,
655 v_plane_resource_id, a_plane_resource_id, color_space);
656 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copy_quad->material);
657 EXPECT_EQ(opaque_rect, copy_quad->opaque_rect);
658 EXPECT_EQ(visible_rect, copy_quad->visible_rect);
659 EXPECT_EQ(ya_tex_coord_rect, copy_quad->ya_tex_coord_rect);
660 EXPECT_EQ(uv_tex_coord_rect, copy_quad->uv_tex_coord_rect);
661 EXPECT_EQ(ya_tex_size, copy_quad->ya_tex_size);
662 EXPECT_EQ(uv_tex_size, copy_quad->uv_tex_size);
663 EXPECT_EQ(y_plane_resource_id, copy_quad->y_plane_resource_id);
664 EXPECT_EQ(u_plane_resource_id, copy_quad->u_plane_resource_id);
665 EXPECT_EQ(v_plane_resource_id, copy_quad->v_plane_resource_id);
666 EXPECT_EQ(a_plane_resource_id, copy_quad->a_plane_resource_id);
667 EXPECT_EQ(color_space, copy_quad->color_space);
669 CREATE_QUAD_9_ALL(YUVVideoDrawQuad, ya_tex_coord_rect, uv_tex_coord_rect,
670 ya_tex_size, uv_tex_size, y_plane_resource_id,
671 u_plane_resource_id, v_plane_resource_id,
672 a_plane_resource_id, color_space);
673 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copy_quad->material);
674 EXPECT_EQ(ya_tex_coord_rect, copy_quad->ya_tex_coord_rect);
675 EXPECT_EQ(uv_tex_coord_rect, copy_quad->uv_tex_coord_rect);
676 EXPECT_EQ(ya_tex_size, copy_quad->ya_tex_size);
677 EXPECT_EQ(uv_tex_size, copy_quad->uv_tex_size);
678 EXPECT_EQ(y_plane_resource_id, copy_quad->y_plane_resource_id);
679 EXPECT_EQ(u_plane_resource_id, copy_quad->u_plane_resource_id);
680 EXPECT_EQ(v_plane_resource_id, copy_quad->v_plane_resource_id);
681 EXPECT_EQ(a_plane_resource_id, copy_quad->a_plane_resource_id);
682 EXPECT_EQ(color_space, copy_quad->color_space);
685 TEST(DrawQuadTest, CopyPictureDrawQuad) {
686 gfx::Rect opaque_rect(33, 44, 22, 33);
687 gfx::Rect visible_rect(40, 50, 30, 20);
688 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f);
689 gfx::Size texture_size(85, 32);
690 bool nearest_neighbor = true;
691 ResourceFormat texture_format = RGBA_8888;
692 gfx::Rect content_rect(30, 40, 20, 30);
693 float contents_scale = 3.141592f;
694 scoped_refptr<RasterSource> raster_source =
695 FakePicturePileImpl::CreateEmptyPile(gfx::Size(100, 100),
696 gfx::Size(100, 100));
697 CREATE_SHARED_STATE();
699 CREATE_QUAD_9_NEW(PictureDrawQuad, opaque_rect, visible_rect, tex_coord_rect,
700 texture_size, nearest_neighbor, texture_format,
701 content_rect, contents_scale, raster_source);
702 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, copy_quad->material);
703 EXPECT_EQ(opaque_rect, copy_quad->opaque_rect);
704 EXPECT_EQ(visible_rect, copy_quad->visible_rect);
705 EXPECT_EQ(tex_coord_rect, copy_quad->tex_coord_rect);
706 EXPECT_EQ(texture_size, copy_quad->texture_size);
707 EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor);
708 EXPECT_EQ(texture_format, copy_quad->texture_format);
709 EXPECT_EQ(content_rect, copy_quad->content_rect);
710 EXPECT_EQ(contents_scale, copy_quad->contents_scale);
711 EXPECT_EQ(raster_source, copy_quad->raster_source);
713 CREATE_QUAD_7_ALL(PictureDrawQuad, tex_coord_rect, texture_size,
714 nearest_neighbor, texture_format, content_rect,
715 contents_scale, raster_source);
716 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, copy_quad->material);
717 EXPECT_EQ(tex_coord_rect, copy_quad->tex_coord_rect);
718 EXPECT_EQ(texture_size, copy_quad->texture_size);
719 EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor);
720 EXPECT_EQ(texture_format, copy_quad->texture_format);
721 EXPECT_EQ(content_rect, copy_quad->content_rect);
722 EXPECT_EQ(contents_scale, copy_quad->contents_scale);
723 EXPECT_EQ(raster_source, copy_quad->raster_source);
726 class DrawQuadIteratorTest : public testing::Test {
727 protected:
728 ResourceId IncrementResourceId(ResourceId id) {
729 ++num_resources_;
730 return id + 1;
733 int IterateAndCount(DrawQuad* quad) {
734 num_resources_ = 0;
735 quad->IterateResources(base::Bind(
736 &DrawQuadIteratorTest::IncrementResourceId, base::Unretained(this)));
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);
812 quad_new->mask_resource_id = 0;
813 EXPECT_EQ(0, IterateAndCount(quad_new));
814 EXPECT_EQ(0u, quad_new->mask_resource_id);
817 TEST_F(DrawQuadIteratorTest, SolidColorDrawQuad) {
818 gfx::Rect visible_rect(40, 50, 30, 20);
819 SkColor color = 0x49494949;
820 bool force_anti_aliasing_off = false;
822 CREATE_SHARED_STATE();
823 CREATE_QUAD_3_NEW(
824 SolidColorDrawQuad, visible_rect, color, force_anti_aliasing_off);
825 EXPECT_EQ(0, IterateAndCount(quad_new));
828 TEST_F(DrawQuadIteratorTest, StreamVideoDrawQuad) {
829 gfx::Rect opaque_rect(33, 47, 10, 12);
830 gfx::Rect visible_rect(40, 50, 30, 20);
831 ResourceId resource_id = 64;
832 gfx::Transform matrix = gfx::Transform(0.5, 0.25, 1, 0.75, 0, 1);
834 CREATE_SHARED_STATE();
835 CREATE_QUAD_4_NEW(
836 StreamVideoDrawQuad, opaque_rect, visible_rect, resource_id, matrix);
837 EXPECT_EQ(resource_id, quad_new->resource_id);
838 EXPECT_EQ(1, IterateAndCount(quad_new));
839 EXPECT_EQ(resource_id + 1, quad_new->resource_id);
842 TEST_F(DrawQuadIteratorTest, SurfaceDrawQuad) {
843 gfx::Rect visible_rect(40, 50, 30, 20);
844 SurfaceId surface_id(4321);
846 CREATE_SHARED_STATE();
847 CREATE_QUAD_2_NEW(SurfaceDrawQuad, visible_rect, surface_id);
848 EXPECT_EQ(0, IterateAndCount(quad_new));
851 TEST_F(DrawQuadIteratorTest, TextureDrawQuad) {
852 gfx::Rect opaque_rect(33, 47, 10, 12);
853 gfx::Rect visible_rect(40, 50, 30, 20);
854 unsigned resource_id = 82;
855 bool premultiplied_alpha = true;
856 gfx::PointF uv_top_left(0.5f, 224.f);
857 gfx::PointF uv_bottom_right(51.5f, 260.f);
858 const float vertex_opacity[] = { 1.0f, 1.0f, 1.0f, 1.0f };
859 bool y_flipped = true;
860 bool nearest_neighbor = true;
862 CREATE_SHARED_STATE();
863 CREATE_QUAD_10_NEW(TextureDrawQuad,
864 opaque_rect,
865 visible_rect,
866 resource_id,
867 premultiplied_alpha,
868 uv_top_left,
869 uv_bottom_right,
870 SK_ColorTRANSPARENT,
871 vertex_opacity,
872 y_flipped,
873 nearest_neighbor);
874 EXPECT_EQ(resource_id, quad_new->resource_id);
875 EXPECT_EQ(1, IterateAndCount(quad_new));
876 EXPECT_EQ(resource_id + 1, quad_new->resource_id);
879 TEST_F(DrawQuadIteratorTest, TileDrawQuad) {
880 gfx::Rect opaque_rect(33, 44, 22, 33);
881 gfx::Rect visible_rect(40, 50, 30, 20);
882 unsigned resource_id = 104;
883 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f);
884 gfx::Size texture_size(85, 32);
885 bool swizzle_contents = true;
886 bool nearest_neighbor = true;
888 CREATE_SHARED_STATE();
889 CREATE_QUAD_7_NEW(TileDrawQuad,
890 opaque_rect,
891 visible_rect,
892 resource_id,
893 tex_coord_rect,
894 texture_size,
895 swizzle_contents,
896 nearest_neighbor);
897 EXPECT_EQ(resource_id, quad_new->resource_id);
898 EXPECT_EQ(1, IterateAndCount(quad_new));
899 EXPECT_EQ(resource_id + 1, quad_new->resource_id);
902 TEST_F(DrawQuadIteratorTest, YUVVideoDrawQuad) {
903 gfx::Rect opaque_rect(33, 47, 10, 12);
904 gfx::Rect visible_rect(40, 50, 30, 20);
905 gfx::RectF ya_tex_coord_rect(0.0f, 0.0f, 0.75f, 0.5f);
906 gfx::RectF uv_tex_coord_rect(0.0f, 0.0f, 0.375f, 0.25f);
907 gfx::Size ya_tex_size(32, 68);
908 gfx::Size uv_tex_size(41, 51);
909 ResourceId y_plane_resource_id = 45;
910 ResourceId u_plane_resource_id = 532;
911 ResourceId v_plane_resource_id = 4;
912 ResourceId a_plane_resource_id = 63;
913 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::JPEG;
915 CREATE_SHARED_STATE();
916 CREATE_QUAD_11_NEW(YUVVideoDrawQuad, opaque_rect, visible_rect,
917 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size,
918 uv_tex_size, y_plane_resource_id, u_plane_resource_id,
919 v_plane_resource_id, a_plane_resource_id, color_space);
920 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copy_quad->material);
921 EXPECT_EQ(y_plane_resource_id, quad_new->y_plane_resource_id);
922 EXPECT_EQ(u_plane_resource_id, quad_new->u_plane_resource_id);
923 EXPECT_EQ(v_plane_resource_id, quad_new->v_plane_resource_id);
924 EXPECT_EQ(a_plane_resource_id, quad_new->a_plane_resource_id);
925 EXPECT_EQ(color_space, quad_new->color_space);
926 EXPECT_EQ(4, IterateAndCount(quad_new));
927 EXPECT_EQ(y_plane_resource_id + 1, quad_new->y_plane_resource_id);
928 EXPECT_EQ(u_plane_resource_id + 1, quad_new->u_plane_resource_id);
929 EXPECT_EQ(v_plane_resource_id + 1, quad_new->v_plane_resource_id);
930 EXPECT_EQ(a_plane_resource_id + 1, quad_new->a_plane_resource_id);
933 // Disabled until picture draw quad is supported for ubercomp: crbug.com/231715
934 TEST_F(DrawQuadIteratorTest, DISABLED_PictureDrawQuad) {
935 gfx::Rect opaque_rect(33, 44, 22, 33);
936 gfx::Rect visible_rect(40, 50, 30, 20);
937 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f);
938 gfx::Size texture_size(85, 32);
939 bool nearest_neighbor = true;
940 ResourceFormat texture_format = RGBA_8888;
941 gfx::Rect content_rect(30, 40, 20, 30);
942 float contents_scale = 3.141592f;
943 scoped_refptr<RasterSource> raster_source =
944 FakePicturePileImpl::CreateEmptyPile(gfx::Size(100, 100),
945 gfx::Size(100, 100));
947 CREATE_SHARED_STATE();
948 CREATE_QUAD_9_NEW(PictureDrawQuad, opaque_rect, visible_rect, tex_coord_rect,
949 texture_size, nearest_neighbor, texture_format,
950 content_rect, contents_scale, raster_source);
951 EXPECT_EQ(0, IterateAndCount(quad_new));
954 TEST(DrawQuadTest, LargestQuadType) {
955 size_t largest = 0;
957 for (int i = 0; i <= DrawQuad::MATERIAL_LAST; ++i) {
958 switch (static_cast<DrawQuad::Material>(i)) {
959 case DrawQuad::CHECKERBOARD:
960 largest = std::max(largest, sizeof(CheckerboardDrawQuad));
961 break;
962 case DrawQuad::DEBUG_BORDER:
963 largest = std::max(largest, sizeof(DebugBorderDrawQuad));
964 break;
965 case DrawQuad::IO_SURFACE_CONTENT:
966 largest = std::max(largest, sizeof(IOSurfaceDrawQuad));
967 break;
968 case DrawQuad::PICTURE_CONTENT:
969 largest = std::max(largest, sizeof(PictureDrawQuad));
970 break;
971 case DrawQuad::TEXTURE_CONTENT:
972 largest = std::max(largest, sizeof(TextureDrawQuad));
973 break;
974 case DrawQuad::RENDER_PASS:
975 largest = std::max(largest, sizeof(RenderPassDrawQuad));
976 break;
977 case DrawQuad::SOLID_COLOR:
978 largest = std::max(largest, sizeof(SolidColorDrawQuad));
979 break;
980 case DrawQuad::SURFACE_CONTENT:
981 largest = std::max(largest, sizeof(SurfaceDrawQuad));
982 break;
983 case DrawQuad::TILED_CONTENT:
984 largest = std::max(largest, sizeof(TileDrawQuad));
985 break;
986 case DrawQuad::STREAM_VIDEO_CONTENT:
987 largest = std::max(largest, sizeof(StreamVideoDrawQuad));
988 break;
989 case DrawQuad::YUV_VIDEO_CONTENT:
990 largest = std::max(largest, sizeof(YUVVideoDrawQuad));
991 break;
992 case DrawQuad::INVALID:
993 break;
996 EXPECT_EQ(LargestDrawQuadSize(), largest);
998 if (!HasFailure())
999 return;
1001 // On failure, output the size of all quads for debugging.
1002 LOG(ERROR) << "largest " << largest;
1003 LOG(ERROR) << "kLargestDrawQuad " << LargestDrawQuadSize();
1004 for (int i = 0; i <= DrawQuad::MATERIAL_LAST; ++i) {
1005 switch (static_cast<DrawQuad::Material>(i)) {
1006 case DrawQuad::CHECKERBOARD:
1007 LOG(ERROR) << "CheckerboardDrawQuad " << sizeof(CheckerboardDrawQuad);
1008 break;
1009 case DrawQuad::DEBUG_BORDER:
1010 LOG(ERROR) << "DebugBorderDrawQuad " << sizeof(DebugBorderDrawQuad);
1011 break;
1012 case DrawQuad::IO_SURFACE_CONTENT:
1013 LOG(ERROR) << "IOSurfaceDrawQuad " << sizeof(IOSurfaceDrawQuad);
1014 break;
1015 case DrawQuad::PICTURE_CONTENT:
1016 LOG(ERROR) << "PictureDrawQuad " << sizeof(PictureDrawQuad);
1017 break;
1018 case DrawQuad::TEXTURE_CONTENT:
1019 LOG(ERROR) << "TextureDrawQuad " << sizeof(TextureDrawQuad);
1020 break;
1021 case DrawQuad::RENDER_PASS:
1022 LOG(ERROR) << "RenderPassDrawQuad " << sizeof(RenderPassDrawQuad);
1023 break;
1024 case DrawQuad::SOLID_COLOR:
1025 LOG(ERROR) << "SolidColorDrawQuad " << sizeof(SolidColorDrawQuad);
1026 break;
1027 case DrawQuad::SURFACE_CONTENT:
1028 LOG(ERROR) << "SurfaceDrawQuad " << sizeof(SurfaceDrawQuad);
1029 break;
1030 case DrawQuad::TILED_CONTENT:
1031 LOG(ERROR) << "TileDrawQuad " << sizeof(TileDrawQuad);
1032 break;
1033 case DrawQuad::STREAM_VIDEO_CONTENT:
1034 LOG(ERROR) << "StreamVideoDrawQuad " << sizeof(StreamVideoDrawQuad);
1035 break;
1036 case DrawQuad::YUV_VIDEO_CONTENT:
1037 LOG(ERROR) << "YUVVideoDrawQuad " << sizeof(YUVVideoDrawQuad);
1038 break;
1039 case DrawQuad::INVALID:
1040 break;
1045 } // namespace
1046 } // namespace cc