Delete unused downloads page asset.
[chromium-blink-merge.git] / cc / quads / draw_quad_unittest.cc
blob205243a7a026158e1dd8833394d17255b67afc95
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/debug_border_draw_quad.h"
14 #include "cc/quads/io_surface_draw_quad.h"
15 #include "cc/quads/largest_draw_quad.h"
16 #include "cc/quads/picture_draw_quad.h"
17 #include "cc/quads/render_pass.h"
18 #include "cc/quads/render_pass_draw_quad.h"
19 #include "cc/quads/solid_color_draw_quad.h"
20 #include "cc/quads/stream_video_draw_quad.h"
21 #include "cc/quads/surface_draw_quad.h"
22 #include "cc/quads/texture_draw_quad.h"
23 #include "cc/quads/tile_draw_quad.h"
24 #include "cc/quads/yuv_video_draw_quad.h"
25 #include "cc/test/fake_picture_pile_impl.h"
26 #include "cc/test/geometry_test_utils.h"
27 #include "testing/gtest/include/gtest/gtest.h"
28 #include "third_party/skia/include/effects/SkBlurImageFilter.h"
29 #include "ui/gfx/transform.h"
31 namespace cc {
32 namespace {
34 TEST(DrawQuadTest, CopySharedQuadState) {
35 gfx::Transform quad_transform = gfx::Transform(1.0, 0.0, 0.5, 1.0, 0.5, 0.0);
36 gfx::Size layer_bounds(26, 28);
37 gfx::Rect visible_layer_rect(10, 12, 14, 16);
38 gfx::Rect clip_rect(19, 21, 23, 25);
39 bool is_clipped = true;
40 float opacity = 0.25f;
41 SkXfermode::Mode blend_mode = SkXfermode::kMultiply_Mode;
42 int sorting_context_id = 65536;
44 scoped_ptr<SharedQuadState> state(new SharedQuadState);
45 state->SetAll(quad_transform, layer_bounds, visible_layer_rect, clip_rect,
46 is_clipped, opacity, blend_mode, sorting_context_id);
48 scoped_ptr<SharedQuadState> copy(new SharedQuadState);
49 copy->CopyFrom(state.get());
50 EXPECT_EQ(quad_transform, copy->quad_to_target_transform);
51 EXPECT_EQ(visible_layer_rect, copy->visible_quad_layer_rect);
52 EXPECT_EQ(opacity, copy->opacity);
53 EXPECT_EQ(clip_rect, copy->clip_rect);
54 EXPECT_EQ(is_clipped, copy->is_clipped);
55 EXPECT_EQ(blend_mode, copy->blend_mode);
58 SharedQuadState* CreateSharedQuadState(RenderPass* render_pass) {
59 gfx::Transform quad_transform = gfx::Transform(1.0, 0.0, 0.5, 1.0, 0.5, 0.0);
60 gfx::Size layer_bounds(26, 28);
61 gfx::Rect visible_layer_rect(10, 12, 14, 16);
62 gfx::Rect clip_rect(19, 21, 23, 25);
63 bool is_clipped = false;
64 float opacity = 1.f;
65 int sorting_context_id = 65536;
66 SkXfermode::Mode blend_mode = SkXfermode::kSrcOver_Mode;
68 SharedQuadState* state = render_pass->CreateAndAppendSharedQuadState();
69 state->SetAll(quad_transform, layer_bounds, visible_layer_rect, clip_rect,
70 is_clipped, opacity, blend_mode, sorting_context_id);
71 return state;
74 void CompareDrawQuad(DrawQuad* quad,
75 DrawQuad* copy,
76 SharedQuadState* copy_shared_state) {
77 EXPECT_EQ(quad->material, copy->material);
78 EXPECT_EQ(quad->rect, copy->rect);
79 EXPECT_EQ(quad->visible_rect, copy->visible_rect);
80 EXPECT_EQ(quad->opaque_rect, copy->opaque_rect);
81 EXPECT_EQ(quad->needs_blending, copy->needs_blending);
82 EXPECT_EQ(copy_shared_state, copy->shared_quad_state);
85 #define CREATE_SHARED_STATE() \
86 scoped_ptr<RenderPass> render_pass = RenderPass::Create(); \
87 SharedQuadState* shared_state(CreateSharedQuadState(render_pass.get())); \
88 SharedQuadState* copy_shared_state = \
89 render_pass->CreateAndAppendSharedQuadState(); \
90 copy_shared_state->CopyFrom(shared_state);
92 #define QUAD_DATA \
93 gfx::Rect quad_rect(30, 40, 50, 60); \
94 gfx::Rect quad_visible_rect(40, 50, 30, 20); \
95 gfx::Rect quad_opaque_rect(60, 55, 10, 10); \
96 ALLOW_UNUSED_LOCAL(quad_opaque_rect); \
97 bool needs_blending = true; \
98 ALLOW_UNUSED_LOCAL(needs_blending);
100 #define SETUP_AND_COPY_QUAD_NEW(Type, quad) \
101 DrawQuad* copy_new = \
102 render_pass->CopyFromAndAppendDrawQuad(quad_new, copy_shared_state); \
103 CompareDrawQuad(quad_new, copy_new, copy_shared_state); \
104 const Type* copy_quad = Type::MaterialCast(copy_new); \
105 ALLOW_UNUSED_LOCAL(copy_quad);
107 #define SETUP_AND_COPY_QUAD_ALL(Type, quad) \
108 DrawQuad* copy_all = \
109 render_pass->CopyFromAndAppendDrawQuad(quad_all, copy_shared_state); \
110 CompareDrawQuad(quad_all, copy_all, copy_shared_state); \
111 copy_quad = Type::MaterialCast(copy_all);
113 #define SETUP_AND_COPY_QUAD_NEW_RP(Type, quad, a) \
114 DrawQuad* copy_new = render_pass->CopyFromAndAppendRenderPassDrawQuad( \
115 quad_new, copy_shared_state, a); \
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_RP(Type, quad, a) \
121 DrawQuad* copy_all = render_pass->CopyFromAndAppendRenderPassDrawQuad( \
122 quad_all, copy_shared_state, a); \
123 CompareDrawQuad(quad_all, copy_all, copy_shared_state); \
124 copy_quad = Type::MaterialCast(copy_all);
126 #define CREATE_QUAD_1_NEW(Type, a) \
127 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
128 { QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a); } \
129 SETUP_AND_COPY_QUAD_NEW(Type, quad_new);
131 #define CREATE_QUAD_1_ALL(Type, a) \
132 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \
134 QUAD_DATA quad_all->SetAll(shared_state, \
135 quad_rect, \
136 quad_opaque_rect, \
137 quad_visible_rect, \
138 needs_blending, \
139 a); \
141 SETUP_AND_COPY_QUAD_ALL(Type, quad_all);
143 #define CREATE_QUAD_2_NEW(Type, a, b) \
144 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
145 { QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b); } \
146 SETUP_AND_COPY_QUAD_NEW(Type, quad_new);
148 #define CREATE_QUAD_2_ALL(Type, a, b) \
149 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \
151 QUAD_DATA quad_all->SetAll(shared_state, \
152 quad_rect, \
153 quad_opaque_rect, \
154 quad_visible_rect, \
155 needs_blending, \
156 a, \
157 b); \
159 SETUP_AND_COPY_QUAD_ALL(Type, quad_all);
161 #define CREATE_QUAD_3_NEW(Type, a, b, c) \
162 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
163 { QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b, c); } \
164 SETUP_AND_COPY_QUAD_NEW(Type, quad_new);
166 #define CREATE_QUAD_3_ALL(Type, a, b, c) \
167 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \
169 QUAD_DATA quad_all->SetAll(shared_state, \
170 quad_rect, \
171 quad_opaque_rect, \
172 quad_visible_rect, \
173 needs_blending, \
174 a, \
175 b, \
176 c); \
178 SETUP_AND_COPY_QUAD_ALL(Type, quad_all);
180 #define CREATE_QUAD_4_NEW(Type, a, b, c, d) \
181 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
182 { QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b, c, d); } \
183 SETUP_AND_COPY_QUAD_NEW(Type, quad_new);
185 #define CREATE_QUAD_4_ALL(Type, a, b, c, d) \
186 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \
188 QUAD_DATA quad_all->SetAll(shared_state, \
189 quad_rect, \
190 quad_opaque_rect, \
191 quad_visible_rect, \
192 needs_blending, \
193 a, \
194 b, \
195 c, \
196 d); \
198 SETUP_AND_COPY_QUAD_ALL(Type, quad_all);
200 #define CREATE_QUAD_5_NEW(Type, a, b, c, d, e) \
201 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
202 { QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b, c, d, e); } \
203 SETUP_AND_COPY_QUAD_NEW(Type, quad_new);
205 #define CREATE_QUAD_5_ALL(Type, a, b, c, d, e) \
206 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \
208 QUAD_DATA quad_all->SetAll(shared_state, \
209 quad_rect, \
210 quad_opaque_rect, \
211 quad_visible_rect, \
212 needs_blending, \
213 a, \
214 b, \
215 c, \
216 d, \
217 e); \
219 SETUP_AND_COPY_QUAD_ALL(Type, quad_all);
221 #define CREATE_QUAD_6_NEW(Type, a, b, c, d, e, f) \
222 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
223 { QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b, c, d, e, f); } \
224 SETUP_AND_COPY_QUAD_NEW(Type, quad_new);
226 #define CREATE_QUAD_6_ALL(Type, a, b, c, d, e, f) \
227 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \
229 QUAD_DATA quad_all->SetAll(shared_state, \
230 quad_rect, \
231 quad_opaque_rect, \
232 quad_visible_rect, \
233 needs_blending, \
234 a, \
235 b, \
236 c, \
237 d, \
238 e, \
239 f); \
241 SETUP_AND_COPY_QUAD_ALL(Type, quad_all);
243 #define CREATE_QUAD_7_NEW(Type, a, b, c, d, e, f, g) \
244 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
246 QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b, c, d, e, f, g); \
248 SETUP_AND_COPY_QUAD_NEW(Type, quad_new);
250 #define CREATE_QUAD_7_ALL(Type, a, b, c, d, e, f, g) \
251 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \
253 QUAD_DATA quad_all->SetAll(shared_state, \
254 quad_rect, \
255 quad_opaque_rect, \
256 quad_visible_rect, \
257 needs_blending, \
258 a, \
259 b, \
260 c, \
261 d, \
262 e, \
263 f, \
264 g); \
266 SETUP_AND_COPY_QUAD_ALL(Type, quad_all);
268 #define CREATE_QUAD_8_NEW(Type, a, b, c, d, e, f, g, h) \
269 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
271 QUAD_DATA quad_new->SetNew( \
272 shared_state, quad_rect, a, b, c, d, e, f, g, h); \
274 SETUP_AND_COPY_QUAD_NEW(Type, quad_new);
276 #define CREATE_QUAD_8_ALL(Type, a, b, c, d, e, f, g, h) \
277 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \
279 QUAD_DATA quad_all->SetAll(shared_state, \
280 quad_rect, \
281 quad_opaque_rect, \
282 quad_visible_rect, \
283 needs_blending, \
284 a, \
285 b, \
286 c, \
287 d, \
288 e, \
289 f, \
290 g, \
291 h); \
293 SETUP_AND_COPY_QUAD_ALL(Type, quad_all);
295 #define CREATE_QUAD_9_NEW(Type, a, b, c, d, e, f, g, h, i) \
296 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
298 QUAD_DATA quad_new->SetNew( \
299 shared_state, quad_rect, a, b, c, d, e, f, g, h, i); \
301 SETUP_AND_COPY_QUAD_NEW(Type, quad_new);
303 #define CREATE_QUAD_9_ALL(Type, a, b, c, d, e, f, g, h, i) \
304 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \
306 QUAD_DATA quad_all->SetAll(shared_state, quad_rect, quad_opaque_rect, \
307 quad_visible_rect, needs_blending, a, b, c, d, \
308 e, f, g, h, i); \
310 SETUP_AND_COPY_QUAD_ALL(Type, quad_all);
312 #define CREATE_QUAD_10_NEW(Type, a, b, c, d, e, f, g, h, i, j) \
313 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
315 QUAD_DATA quad_new->SetNew( \
316 shared_state, quad_rect, a, b, c, d, e, f, g, h, i, j); \
318 SETUP_AND_COPY_QUAD_NEW(Type, quad_new);
320 #define CREATE_QUAD_10_ALL(Type, a, b, c, d, e, f, g, h, i, j) \
321 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \
323 QUAD_DATA quad_all->SetAll(shared_state, quad_rect, quad_opaque_rect, \
324 quad_visible_rect, needs_blending, a, b, c, d, \
325 e, f, g, h, i, j); \
327 SETUP_AND_COPY_QUAD_ALL(Type, quad_all);
329 #define CREATE_QUAD_11_NEW(Type, a, b, c, d, e, f, g, h, i, j, k) \
330 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
332 QUAD_DATA quad_new->SetNew(shared_state, quad_rect, a, b, c, d, e, f, g, \
333 h, i, j, k); \
335 SETUP_AND_COPY_QUAD_NEW(Type, quad_new);
337 #define CREATE_QUAD_ALL_RP(Type, a, b, c, d, e, f, g, copy_a) \
338 Type* quad_all = render_pass->CreateAndAppendDrawQuad<Type>(); \
340 QUAD_DATA quad_all->SetAll(shared_state, \
341 quad_rect, \
342 quad_opaque_rect, \
343 quad_visible_rect, \
344 needs_blending, \
345 a, \
346 b, \
347 c, \
348 d, \
349 e, \
350 f, \
351 g); \
353 SETUP_AND_COPY_QUAD_ALL_RP(Type, quad_all, copy_a);
355 #define CREATE_QUAD_NEW_RP(Type, a, b, c, d, e, f, g, h, copy_a) \
356 Type* quad_new = render_pass->CreateAndAppendDrawQuad<Type>(); \
358 QUAD_DATA quad_new->SetNew( \
359 shared_state, quad_rect, a, b, c, d, e, f, g, h); \
361 SETUP_AND_COPY_QUAD_NEW_RP(Type, quad_new, copy_a);
363 TEST(DrawQuadTest, CopyDebugBorderDrawQuad) {
364 gfx::Rect visible_rect(40, 50, 30, 20);
365 SkColor color = 0xfabb0011;
366 int width = 99;
367 CREATE_SHARED_STATE();
369 CREATE_QUAD_3_NEW(DebugBorderDrawQuad, visible_rect, color, width);
370 EXPECT_EQ(DrawQuad::DEBUG_BORDER, copy_quad->material);
371 EXPECT_EQ(visible_rect, copy_quad->visible_rect);
372 EXPECT_EQ(color, copy_quad->color);
373 EXPECT_EQ(width, copy_quad->width);
375 CREATE_QUAD_2_ALL(DebugBorderDrawQuad, color, width);
376 EXPECT_EQ(DrawQuad::DEBUG_BORDER, copy_quad->material);
377 EXPECT_EQ(color, copy_quad->color);
378 EXPECT_EQ(width, copy_quad->width);
381 TEST(DrawQuadTest, CopyIOSurfaceDrawQuad) {
382 gfx::Rect opaque_rect(33, 47, 10, 12);
383 gfx::Rect visible_rect(40, 50, 30, 20);
384 gfx::Size size(58, 95);
385 ResourceId resource_id = 72;
386 IOSurfaceDrawQuad::Orientation orientation = IOSurfaceDrawQuad::UNFLIPPED;
387 bool allow_overlay = true;
388 CREATE_SHARED_STATE();
390 CREATE_QUAD_6_NEW(IOSurfaceDrawQuad,
391 opaque_rect,
392 visible_rect,
393 size,
394 resource_id,
395 orientation,
396 allow_overlay);
397 EXPECT_EQ(DrawQuad::IO_SURFACE_CONTENT, copy_quad->material);
398 EXPECT_EQ(visible_rect, copy_quad->visible_rect);
399 EXPECT_EQ(opaque_rect, copy_quad->opaque_rect);
400 EXPECT_EQ(size, copy_quad->io_surface_size);
401 EXPECT_EQ(resource_id, copy_quad->io_surface_resource_id());
402 EXPECT_EQ(orientation, copy_quad->orientation);
403 EXPECT_EQ(allow_overlay, copy_quad->allow_overlay);
405 CREATE_QUAD_4_ALL(IOSurfaceDrawQuad,
406 size,
407 resource_id,
408 orientation,
409 allow_overlay);
410 EXPECT_EQ(DrawQuad::IO_SURFACE_CONTENT, copy_quad->material);
411 EXPECT_EQ(size, copy_quad->io_surface_size);
412 EXPECT_EQ(resource_id, copy_quad->io_surface_resource_id());
413 EXPECT_EQ(orientation, copy_quad->orientation);
414 EXPECT_EQ(allow_overlay, copy_quad->allow_overlay);
417 TEST(DrawQuadTest, CopyRenderPassDrawQuad) {
418 gfx::Rect visible_rect(40, 50, 30, 20);
419 RenderPassId render_pass_id(22, 64);
420 ResourceId mask_resource_id = 78;
421 gfx::Vector2dF mask_uv_scale(33.f, 19.f);
422 gfx::Size mask_texture_size(128, 134);
423 FilterOperations filters;
424 filters.Append(FilterOperation::CreateBlurFilter(1.f));
425 gfx::Vector2dF filters_scale;
426 FilterOperations background_filters;
427 background_filters.Append(
428 FilterOperation::CreateGrayscaleFilter(1.f));
430 RenderPassId copied_render_pass_id(235, 11);
431 CREATE_SHARED_STATE();
433 CREATE_QUAD_NEW_RP(RenderPassDrawQuad,
434 visible_rect,
435 render_pass_id,
436 mask_resource_id,
437 mask_uv_scale,
438 mask_texture_size,
439 filters,
440 filters_scale,
441 background_filters,
442 copied_render_pass_id);
443 EXPECT_EQ(DrawQuad::RENDER_PASS, copy_quad->material);
444 EXPECT_EQ(visible_rect, copy_quad->visible_rect);
445 EXPECT_EQ(copied_render_pass_id, copy_quad->render_pass_id);
446 EXPECT_EQ(mask_resource_id, copy_quad->mask_resource_id());
447 EXPECT_EQ(mask_uv_scale.ToString(), copy_quad->mask_uv_scale.ToString());
448 EXPECT_EQ(mask_texture_size.ToString(),
449 copy_quad->mask_texture_size.ToString());
450 EXPECT_EQ(filters, copy_quad->filters);
451 EXPECT_EQ(filters_scale, copy_quad->filters_scale);
452 EXPECT_EQ(background_filters, copy_quad->background_filters);
454 CREATE_QUAD_ALL_RP(RenderPassDrawQuad,
455 render_pass_id,
456 mask_resource_id,
457 mask_uv_scale,
458 mask_texture_size,
459 filters,
460 filters_scale,
461 background_filters,
462 copied_render_pass_id);
463 EXPECT_EQ(DrawQuad::RENDER_PASS, copy_quad->material);
464 EXPECT_EQ(copied_render_pass_id, copy_quad->render_pass_id);
465 EXPECT_EQ(mask_resource_id, copy_quad->mask_resource_id());
466 EXPECT_EQ(mask_uv_scale.ToString(), copy_quad->mask_uv_scale.ToString());
467 EXPECT_EQ(mask_texture_size.ToString(),
468 copy_quad->mask_texture_size.ToString());
469 EXPECT_EQ(filters, copy_quad->filters);
470 EXPECT_EQ(filters_scale, copy_quad->filters_scale);
471 EXPECT_EQ(background_filters, copy_quad->background_filters);
474 TEST(DrawQuadTest, CopySolidColorDrawQuad) {
475 gfx::Rect visible_rect(40, 50, 30, 20);
476 SkColor color = 0x49494949;
477 bool force_anti_aliasing_off = false;
478 CREATE_SHARED_STATE();
480 CREATE_QUAD_3_NEW(
481 SolidColorDrawQuad, visible_rect, color, force_anti_aliasing_off);
482 EXPECT_EQ(DrawQuad::SOLID_COLOR, copy_quad->material);
483 EXPECT_EQ(visible_rect, copy_quad->visible_rect);
484 EXPECT_EQ(color, copy_quad->color);
485 EXPECT_EQ(force_anti_aliasing_off, copy_quad->force_anti_aliasing_off);
487 CREATE_QUAD_2_ALL(SolidColorDrawQuad, color, force_anti_aliasing_off);
488 EXPECT_EQ(DrawQuad::SOLID_COLOR, copy_quad->material);
489 EXPECT_EQ(color, copy_quad->color);
490 EXPECT_EQ(force_anti_aliasing_off, copy_quad->force_anti_aliasing_off);
493 TEST(DrawQuadTest, CopyStreamVideoDrawQuad) {
494 gfx::Rect opaque_rect(33, 47, 10, 12);
495 gfx::Rect visible_rect(40, 50, 30, 20);
496 ResourceId resource_id = 64;
497 gfx::Size resource_size_in_pixels = gfx::Size(40, 41);
498 bool allow_overlay = true;
499 gfx::Transform matrix = gfx::Transform(0.5, 0.25, 1, 0.75, 0, 1);
500 CREATE_SHARED_STATE();
502 CREATE_QUAD_6_NEW(StreamVideoDrawQuad, opaque_rect, visible_rect, resource_id,
503 resource_size_in_pixels, allow_overlay, matrix);
504 EXPECT_EQ(DrawQuad::STREAM_VIDEO_CONTENT, copy_quad->material);
505 EXPECT_EQ(visible_rect, copy_quad->visible_rect);
506 EXPECT_EQ(opaque_rect, copy_quad->opaque_rect);
507 EXPECT_EQ(resource_id, copy_quad->resource_id());
508 EXPECT_EQ(allow_overlay, copy_quad->allow_overlay());
509 EXPECT_EQ(resource_size_in_pixels, copy_quad->resource_size_in_pixels());
510 EXPECT_EQ(matrix, copy_quad->matrix);
512 CREATE_QUAD_4_ALL(StreamVideoDrawQuad, resource_id, resource_size_in_pixels,
513 allow_overlay, matrix);
514 EXPECT_EQ(DrawQuad::STREAM_VIDEO_CONTENT, copy_quad->material);
515 EXPECT_EQ(resource_id, copy_quad->resource_id());
516 EXPECT_EQ(allow_overlay, copy_quad->allow_overlay());
517 EXPECT_EQ(resource_size_in_pixels, copy_quad->resource_size_in_pixels());
518 EXPECT_EQ(matrix, copy_quad->matrix);
521 TEST(DrawQuadTest, CopySurfaceDrawQuad) {
522 gfx::Rect visible_rect(40, 50, 30, 20);
523 SurfaceId surface_id(1234);
524 CREATE_SHARED_STATE();
526 CREATE_QUAD_2_NEW(SurfaceDrawQuad, visible_rect, surface_id);
527 EXPECT_EQ(DrawQuad::SURFACE_CONTENT, copy_quad->material);
528 EXPECT_EQ(visible_rect, copy_quad->visible_rect);
529 EXPECT_EQ(surface_id, copy_quad->surface_id);
531 CREATE_QUAD_1_ALL(SurfaceDrawQuad, surface_id);
532 EXPECT_EQ(DrawQuad::SURFACE_CONTENT, copy_quad->material);
533 EXPECT_EQ(surface_id, copy_quad->surface_id);
537 TEST(DrawQuadTest, CopyTextureDrawQuad) {
538 gfx::Rect opaque_rect(33, 47, 10, 12);
539 gfx::Rect visible_rect(40, 50, 30, 20);
540 unsigned resource_id = 82;
541 gfx::Size resource_size_in_pixels = gfx::Size(40, 41);
542 bool allow_overlay = true;
543 bool premultiplied_alpha = true;
544 gfx::PointF uv_top_left(0.5f, 224.f);
545 gfx::PointF uv_bottom_right(51.5f, 260.f);
546 const float vertex_opacity[] = { 1.0f, 1.0f, 1.0f, 1.0f };
547 bool y_flipped = true;
548 bool nearest_neighbor = true;
549 CREATE_SHARED_STATE();
551 CREATE_QUAD_10_NEW(TextureDrawQuad,
552 opaque_rect,
553 visible_rect,
554 resource_id,
555 premultiplied_alpha,
556 uv_top_left,
557 uv_bottom_right,
558 SK_ColorTRANSPARENT,
559 vertex_opacity,
560 y_flipped,
561 nearest_neighbor);
562 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, copy_quad->material);
563 EXPECT_EQ(visible_rect, copy_quad->visible_rect);
564 EXPECT_EQ(opaque_rect, copy_quad->opaque_rect);
565 EXPECT_EQ(resource_id, copy_quad->resource_id());
566 EXPECT_EQ(premultiplied_alpha, copy_quad->premultiplied_alpha);
567 EXPECT_EQ(uv_top_left, copy_quad->uv_top_left);
568 EXPECT_EQ(uv_bottom_right, copy_quad->uv_bottom_right);
569 EXPECT_FLOAT_ARRAY_EQ(vertex_opacity, copy_quad->vertex_opacity, 4);
570 EXPECT_EQ(y_flipped, copy_quad->y_flipped);
571 EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor);
573 CREATE_QUAD_10_ALL(TextureDrawQuad, resource_id, resource_size_in_pixels,
574 allow_overlay, premultiplied_alpha, uv_top_left,
575 uv_bottom_right, SK_ColorTRANSPARENT, vertex_opacity,
576 y_flipped, nearest_neighbor);
577 EXPECT_EQ(DrawQuad::TEXTURE_CONTENT, copy_quad->material);
578 EXPECT_EQ(resource_id, copy_quad->resource_id());
579 EXPECT_EQ(allow_overlay, copy_quad->allow_overlay());
580 EXPECT_EQ(resource_size_in_pixels, copy_quad->resource_size_in_pixels());
581 EXPECT_EQ(premultiplied_alpha, copy_quad->premultiplied_alpha);
582 EXPECT_EQ(uv_top_left, copy_quad->uv_top_left);
583 EXPECT_EQ(uv_bottom_right, copy_quad->uv_bottom_right);
584 EXPECT_FLOAT_ARRAY_EQ(vertex_opacity, copy_quad->vertex_opacity, 4);
585 EXPECT_EQ(y_flipped, copy_quad->y_flipped);
586 EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor);
589 TEST(DrawQuadTest, CopyTileDrawQuad) {
590 gfx::Rect opaque_rect(33, 44, 22, 33);
591 gfx::Rect visible_rect(40, 50, 30, 20);
592 unsigned resource_id = 104;
593 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f);
594 gfx::Size texture_size(85, 32);
595 bool swizzle_contents = true;
596 bool nearest_neighbor = true;
597 CREATE_SHARED_STATE();
599 CREATE_QUAD_7_NEW(TileDrawQuad,
600 opaque_rect,
601 visible_rect,
602 resource_id,
603 tex_coord_rect,
604 texture_size,
605 swizzle_contents,
606 nearest_neighbor);
607 EXPECT_EQ(DrawQuad::TILED_CONTENT, copy_quad->material);
608 EXPECT_EQ(opaque_rect, copy_quad->opaque_rect);
609 EXPECT_EQ(visible_rect, copy_quad->visible_rect);
610 EXPECT_EQ(resource_id, copy_quad->resource_id());
611 EXPECT_EQ(tex_coord_rect, copy_quad->tex_coord_rect);
612 EXPECT_EQ(texture_size, copy_quad->texture_size);
613 EXPECT_EQ(swizzle_contents, copy_quad->swizzle_contents);
614 EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor);
616 CREATE_QUAD_5_ALL(TileDrawQuad,
617 resource_id,
618 tex_coord_rect,
619 texture_size,
620 swizzle_contents,
621 nearest_neighbor);
622 EXPECT_EQ(DrawQuad::TILED_CONTENT, copy_quad->material);
623 EXPECT_EQ(resource_id, copy_quad->resource_id());
624 EXPECT_EQ(tex_coord_rect, copy_quad->tex_coord_rect);
625 EXPECT_EQ(texture_size, copy_quad->texture_size);
626 EXPECT_EQ(swizzle_contents, copy_quad->swizzle_contents);
627 EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor);
630 TEST(DrawQuadTest, CopyYUVVideoDrawQuad) {
631 gfx::Rect opaque_rect(33, 47, 10, 12);
632 gfx::Rect visible_rect(40, 50, 30, 20);
633 gfx::RectF ya_tex_coord_rect(40, 50, 30, 20);
634 gfx::RectF uv_tex_coord_rect(20, 25, 15, 10);
635 gfx::Size ya_tex_size(32, 68);
636 gfx::Size uv_tex_size(41, 51);
637 ResourceId y_plane_resource_id = 45;
638 ResourceId u_plane_resource_id = 532;
639 ResourceId v_plane_resource_id = 4;
640 ResourceId a_plane_resource_id = 63;
641 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::JPEG;
642 CREATE_SHARED_STATE();
644 CREATE_QUAD_11_NEW(YUVVideoDrawQuad, opaque_rect, visible_rect,
645 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size,
646 uv_tex_size, y_plane_resource_id, u_plane_resource_id,
647 v_plane_resource_id, a_plane_resource_id, color_space);
648 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copy_quad->material);
649 EXPECT_EQ(opaque_rect, copy_quad->opaque_rect);
650 EXPECT_EQ(visible_rect, copy_quad->visible_rect);
651 EXPECT_EQ(ya_tex_coord_rect, copy_quad->ya_tex_coord_rect);
652 EXPECT_EQ(uv_tex_coord_rect, copy_quad->uv_tex_coord_rect);
653 EXPECT_EQ(ya_tex_size, copy_quad->ya_tex_size);
654 EXPECT_EQ(uv_tex_size, copy_quad->uv_tex_size);
655 EXPECT_EQ(y_plane_resource_id, copy_quad->y_plane_resource_id());
656 EXPECT_EQ(u_plane_resource_id, copy_quad->u_plane_resource_id());
657 EXPECT_EQ(v_plane_resource_id, copy_quad->v_plane_resource_id());
658 EXPECT_EQ(a_plane_resource_id, copy_quad->a_plane_resource_id());
659 EXPECT_EQ(color_space, copy_quad->color_space);
661 CREATE_QUAD_9_ALL(YUVVideoDrawQuad, ya_tex_coord_rect, uv_tex_coord_rect,
662 ya_tex_size, uv_tex_size, y_plane_resource_id,
663 u_plane_resource_id, v_plane_resource_id,
664 a_plane_resource_id, color_space);
665 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copy_quad->material);
666 EXPECT_EQ(ya_tex_coord_rect, copy_quad->ya_tex_coord_rect);
667 EXPECT_EQ(uv_tex_coord_rect, copy_quad->uv_tex_coord_rect);
668 EXPECT_EQ(ya_tex_size, copy_quad->ya_tex_size);
669 EXPECT_EQ(uv_tex_size, copy_quad->uv_tex_size);
670 EXPECT_EQ(y_plane_resource_id, copy_quad->y_plane_resource_id());
671 EXPECT_EQ(u_plane_resource_id, copy_quad->u_plane_resource_id());
672 EXPECT_EQ(v_plane_resource_id, copy_quad->v_plane_resource_id());
673 EXPECT_EQ(a_plane_resource_id, copy_quad->a_plane_resource_id());
674 EXPECT_EQ(color_space, copy_quad->color_space);
677 TEST(DrawQuadTest, CopyPictureDrawQuad) {
678 gfx::Rect opaque_rect(33, 44, 22, 33);
679 gfx::Rect visible_rect(40, 50, 30, 20);
680 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f);
681 gfx::Size texture_size(85, 32);
682 bool nearest_neighbor = true;
683 ResourceFormat texture_format = RGBA_8888;
684 gfx::Rect content_rect(30, 40, 20, 30);
685 float contents_scale = 3.141592f;
686 scoped_refptr<RasterSource> raster_source =
687 FakePicturePileImpl::CreateEmptyPile(gfx::Size(100, 100),
688 gfx::Size(100, 100));
689 CREATE_SHARED_STATE();
691 CREATE_QUAD_9_NEW(PictureDrawQuad, opaque_rect, visible_rect, tex_coord_rect,
692 texture_size, nearest_neighbor, texture_format,
693 content_rect, contents_scale, raster_source);
694 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, copy_quad->material);
695 EXPECT_EQ(opaque_rect, copy_quad->opaque_rect);
696 EXPECT_EQ(visible_rect, copy_quad->visible_rect);
697 EXPECT_EQ(tex_coord_rect, copy_quad->tex_coord_rect);
698 EXPECT_EQ(texture_size, copy_quad->texture_size);
699 EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor);
700 EXPECT_EQ(texture_format, copy_quad->texture_format);
701 EXPECT_EQ(content_rect, copy_quad->content_rect);
702 EXPECT_EQ(contents_scale, copy_quad->contents_scale);
703 EXPECT_EQ(raster_source, copy_quad->raster_source);
705 CREATE_QUAD_7_ALL(PictureDrawQuad, tex_coord_rect, texture_size,
706 nearest_neighbor, texture_format, content_rect,
707 contents_scale, raster_source);
708 EXPECT_EQ(DrawQuad::PICTURE_CONTENT, copy_quad->material);
709 EXPECT_EQ(tex_coord_rect, copy_quad->tex_coord_rect);
710 EXPECT_EQ(texture_size, copy_quad->texture_size);
711 EXPECT_EQ(nearest_neighbor, copy_quad->nearest_neighbor);
712 EXPECT_EQ(texture_format, copy_quad->texture_format);
713 EXPECT_EQ(content_rect, copy_quad->content_rect);
714 EXPECT_EQ(contents_scale, copy_quad->contents_scale);
715 EXPECT_EQ(raster_source, copy_quad->raster_source);
718 class DrawQuadIteratorTest : public testing::Test {
719 protected:
720 int IterateAndCount(DrawQuad* quad) {
721 num_resources_ = 0;
722 for (ResourceId& resource_id : quad->resources) {
723 ++num_resources_;
724 ++resource_id;
726 return num_resources_;
729 private:
730 int num_resources_;
733 TEST_F(DrawQuadIteratorTest, DebugBorderDrawQuad) {
734 gfx::Rect visible_rect(40, 50, 30, 20);
735 SkColor color = 0xfabb0011;
736 int width = 99;
738 CREATE_SHARED_STATE();
739 CREATE_QUAD_3_NEW(DebugBorderDrawQuad, visible_rect, color, width);
740 EXPECT_EQ(0, IterateAndCount(quad_new));
743 TEST_F(DrawQuadIteratorTest, IOSurfaceDrawQuad) {
744 gfx::Rect opaque_rect(33, 47, 10, 12);
745 gfx::Rect visible_rect(40, 50, 30, 20);
746 gfx::Size size(58, 95);
747 ResourceId resource_id = 72;
748 IOSurfaceDrawQuad::Orientation orientation = IOSurfaceDrawQuad::UNFLIPPED;
749 bool allow_overlay = true;
751 CREATE_SHARED_STATE();
752 CREATE_QUAD_6_NEW(IOSurfaceDrawQuad,
753 opaque_rect,
754 visible_rect,
755 size,
756 resource_id,
757 orientation,
758 allow_overlay);
759 EXPECT_EQ(resource_id, quad_new->io_surface_resource_id());
760 EXPECT_EQ(1, IterateAndCount(quad_new));
761 EXPECT_EQ(resource_id + 1, quad_new->io_surface_resource_id());
762 EXPECT_EQ(allow_overlay, copy_quad->allow_overlay);
765 TEST_F(DrawQuadIteratorTest, RenderPassDrawQuad) {
766 gfx::Rect visible_rect(40, 50, 30, 20);
767 RenderPassId render_pass_id(22, 64);
768 ResourceId mask_resource_id = 78;
769 gfx::Vector2dF mask_uv_scale(33.f, 19.f);
770 gfx::Size mask_texture_size(128, 134);
771 FilterOperations filters;
772 filters.Append(FilterOperation::CreateBlurFilter(1.f));
773 gfx::Vector2dF filters_scale(2.f, 3.f);
774 FilterOperations background_filters;
775 background_filters.Append(
776 FilterOperation::CreateGrayscaleFilter(1.f));
778 RenderPassId copied_render_pass_id(235, 11);
780 CREATE_SHARED_STATE();
781 CREATE_QUAD_NEW_RP(RenderPassDrawQuad,
782 visible_rect,
783 render_pass_id,
784 mask_resource_id,
785 mask_uv_scale,
786 mask_texture_size,
787 filters,
788 filters_scale,
789 background_filters,
790 copied_render_pass_id);
791 EXPECT_EQ(mask_resource_id, quad_new->mask_resource_id());
792 EXPECT_EQ(1, IterateAndCount(quad_new));
793 EXPECT_EQ(mask_resource_id + 1, quad_new->mask_resource_id());
795 ResourceId new_mask_resource_id = 0;
796 gfx::Rect quad_rect(30, 40, 50, 60);
797 quad_new->SetNew(shared_state, quad_rect, visible_rect, render_pass_id,
798 new_mask_resource_id, mask_uv_scale, mask_texture_size,
799 filters, filters_scale, background_filters);
800 EXPECT_EQ(0, IterateAndCount(quad_new));
801 EXPECT_EQ(0u, quad_new->mask_resource_id());
804 TEST_F(DrawQuadIteratorTest, SolidColorDrawQuad) {
805 gfx::Rect visible_rect(40, 50, 30, 20);
806 SkColor color = 0x49494949;
807 bool force_anti_aliasing_off = false;
809 CREATE_SHARED_STATE();
810 CREATE_QUAD_3_NEW(
811 SolidColorDrawQuad, visible_rect, color, force_anti_aliasing_off);
812 EXPECT_EQ(0, IterateAndCount(quad_new));
815 TEST_F(DrawQuadIteratorTest, StreamVideoDrawQuad) {
816 gfx::Rect opaque_rect(33, 47, 10, 12);
817 gfx::Rect visible_rect(40, 50, 30, 20);
818 ResourceId resource_id = 64;
819 gfx::Size resource_size_in_pixels = gfx::Size(40, 41);
820 bool allow_overlay = true;
821 gfx::Transform matrix = gfx::Transform(0.5, 0.25, 1, 0.75, 0, 1);
823 CREATE_SHARED_STATE();
824 CREATE_QUAD_6_NEW(StreamVideoDrawQuad, opaque_rect, visible_rect, resource_id,
825 resource_size_in_pixels, allow_overlay, matrix);
826 EXPECT_EQ(resource_id, quad_new->resource_id());
827 EXPECT_EQ(allow_overlay, quad_new->allow_overlay());
828 EXPECT_EQ(resource_size_in_pixels, quad_new->resource_size_in_pixels());
829 EXPECT_EQ(1, IterateAndCount(quad_new));
830 EXPECT_EQ(resource_id + 1, quad_new->resource_id());
833 TEST_F(DrawQuadIteratorTest, SurfaceDrawQuad) {
834 gfx::Rect visible_rect(40, 50, 30, 20);
835 SurfaceId surface_id(4321);
837 CREATE_SHARED_STATE();
838 CREATE_QUAD_2_NEW(SurfaceDrawQuad, visible_rect, surface_id);
839 EXPECT_EQ(0, IterateAndCount(quad_new));
842 TEST_F(DrawQuadIteratorTest, TextureDrawQuad) {
843 gfx::Rect opaque_rect(33, 47, 10, 12);
844 gfx::Rect visible_rect(40, 50, 30, 20);
845 unsigned resource_id = 82;
846 bool premultiplied_alpha = true;
847 gfx::PointF uv_top_left(0.5f, 224.f);
848 gfx::PointF uv_bottom_right(51.5f, 260.f);
849 const float vertex_opacity[] = { 1.0f, 1.0f, 1.0f, 1.0f };
850 bool y_flipped = true;
851 bool nearest_neighbor = true;
853 CREATE_SHARED_STATE();
854 CREATE_QUAD_10_NEW(TextureDrawQuad,
855 opaque_rect,
856 visible_rect,
857 resource_id,
858 premultiplied_alpha,
859 uv_top_left,
860 uv_bottom_right,
861 SK_ColorTRANSPARENT,
862 vertex_opacity,
863 y_flipped,
864 nearest_neighbor);
865 EXPECT_EQ(resource_id, quad_new->resource_id());
866 EXPECT_EQ(1, IterateAndCount(quad_new));
867 EXPECT_EQ(resource_id + 1, quad_new->resource_id());
870 TEST_F(DrawQuadIteratorTest, TileDrawQuad) {
871 gfx::Rect opaque_rect(33, 44, 22, 33);
872 gfx::Rect visible_rect(40, 50, 30, 20);
873 unsigned resource_id = 104;
874 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f);
875 gfx::Size texture_size(85, 32);
876 bool swizzle_contents = true;
877 bool nearest_neighbor = true;
879 CREATE_SHARED_STATE();
880 CREATE_QUAD_7_NEW(TileDrawQuad,
881 opaque_rect,
882 visible_rect,
883 resource_id,
884 tex_coord_rect,
885 texture_size,
886 swizzle_contents,
887 nearest_neighbor);
888 EXPECT_EQ(resource_id, quad_new->resource_id());
889 EXPECT_EQ(1, IterateAndCount(quad_new));
890 EXPECT_EQ(resource_id + 1, quad_new->resource_id());
893 TEST_F(DrawQuadIteratorTest, YUVVideoDrawQuad) {
894 gfx::Rect opaque_rect(33, 47, 10, 12);
895 gfx::Rect visible_rect(40, 50, 30, 20);
896 gfx::RectF ya_tex_coord_rect(0.0f, 0.0f, 0.75f, 0.5f);
897 gfx::RectF uv_tex_coord_rect(0.0f, 0.0f, 0.375f, 0.25f);
898 gfx::Size ya_tex_size(32, 68);
899 gfx::Size uv_tex_size(41, 51);
900 ResourceId y_plane_resource_id = 45;
901 ResourceId u_plane_resource_id = 532;
902 ResourceId v_plane_resource_id = 4;
903 ResourceId a_plane_resource_id = 63;
904 YUVVideoDrawQuad::ColorSpace color_space = YUVVideoDrawQuad::JPEG;
906 CREATE_SHARED_STATE();
907 CREATE_QUAD_11_NEW(YUVVideoDrawQuad, opaque_rect, visible_rect,
908 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size,
909 uv_tex_size, y_plane_resource_id, u_plane_resource_id,
910 v_plane_resource_id, a_plane_resource_id, color_space);
911 EXPECT_EQ(DrawQuad::YUV_VIDEO_CONTENT, copy_quad->material);
912 EXPECT_EQ(y_plane_resource_id, quad_new->y_plane_resource_id());
913 EXPECT_EQ(u_plane_resource_id, quad_new->u_plane_resource_id());
914 EXPECT_EQ(v_plane_resource_id, quad_new->v_plane_resource_id());
915 EXPECT_EQ(a_plane_resource_id, quad_new->a_plane_resource_id());
916 EXPECT_EQ(color_space, quad_new->color_space);
917 EXPECT_EQ(4, IterateAndCount(quad_new));
918 EXPECT_EQ(y_plane_resource_id + 1, quad_new->y_plane_resource_id());
919 EXPECT_EQ(u_plane_resource_id + 1, quad_new->u_plane_resource_id());
920 EXPECT_EQ(v_plane_resource_id + 1, quad_new->v_plane_resource_id());
921 EXPECT_EQ(a_plane_resource_id + 1, quad_new->a_plane_resource_id());
924 // Disabled until picture draw quad is supported for ubercomp: crbug.com/231715
925 TEST_F(DrawQuadIteratorTest, DISABLED_PictureDrawQuad) {
926 gfx::Rect opaque_rect(33, 44, 22, 33);
927 gfx::Rect visible_rect(40, 50, 30, 20);
928 gfx::RectF tex_coord_rect(31.f, 12.f, 54.f, 20.f);
929 gfx::Size texture_size(85, 32);
930 bool nearest_neighbor = true;
931 ResourceFormat texture_format = RGBA_8888;
932 gfx::Rect content_rect(30, 40, 20, 30);
933 float contents_scale = 3.141592f;
934 scoped_refptr<RasterSource> raster_source =
935 FakePicturePileImpl::CreateEmptyPile(gfx::Size(100, 100),
936 gfx::Size(100, 100));
938 CREATE_SHARED_STATE();
939 CREATE_QUAD_9_NEW(PictureDrawQuad, opaque_rect, visible_rect, tex_coord_rect,
940 texture_size, nearest_neighbor, texture_format,
941 content_rect, contents_scale, raster_source);
942 EXPECT_EQ(0, IterateAndCount(quad_new));
945 TEST(DrawQuadTest, LargestQuadType) {
946 size_t largest = 0;
948 for (int i = 0; i <= DrawQuad::MATERIAL_LAST; ++i) {
949 switch (static_cast<DrawQuad::Material>(i)) {
950 case DrawQuad::DEBUG_BORDER:
951 largest = std::max(largest, sizeof(DebugBorderDrawQuad));
952 break;
953 case DrawQuad::IO_SURFACE_CONTENT:
954 largest = std::max(largest, sizeof(IOSurfaceDrawQuad));
955 break;
956 case DrawQuad::PICTURE_CONTENT:
957 largest = std::max(largest, sizeof(PictureDrawQuad));
958 break;
959 case DrawQuad::TEXTURE_CONTENT:
960 largest = std::max(largest, sizeof(TextureDrawQuad));
961 break;
962 case DrawQuad::RENDER_PASS:
963 largest = std::max(largest, sizeof(RenderPassDrawQuad));
964 break;
965 case DrawQuad::SOLID_COLOR:
966 largest = std::max(largest, sizeof(SolidColorDrawQuad));
967 break;
968 case DrawQuad::SURFACE_CONTENT:
969 largest = std::max(largest, sizeof(SurfaceDrawQuad));
970 break;
971 case DrawQuad::TILED_CONTENT:
972 largest = std::max(largest, sizeof(TileDrawQuad));
973 break;
974 case DrawQuad::STREAM_VIDEO_CONTENT:
975 largest = std::max(largest, sizeof(StreamVideoDrawQuad));
976 break;
977 case DrawQuad::YUV_VIDEO_CONTENT:
978 largest = std::max(largest, sizeof(YUVVideoDrawQuad));
979 break;
980 case DrawQuad::INVALID:
981 break;
984 EXPECT_EQ(LargestDrawQuadSize(), largest);
986 if (!HasFailure())
987 return;
989 // On failure, output the size of all quads for debugging.
990 LOG(ERROR) << "largest " << largest;
991 LOG(ERROR) << "kLargestDrawQuad " << LargestDrawQuadSize();
992 for (int i = 0; i <= DrawQuad::MATERIAL_LAST; ++i) {
993 switch (static_cast<DrawQuad::Material>(i)) {
994 case DrawQuad::DEBUG_BORDER:
995 LOG(ERROR) << "DebugBorderDrawQuad " << sizeof(DebugBorderDrawQuad);
996 break;
997 case DrawQuad::IO_SURFACE_CONTENT:
998 LOG(ERROR) << "IOSurfaceDrawQuad " << sizeof(IOSurfaceDrawQuad);
999 break;
1000 case DrawQuad::PICTURE_CONTENT:
1001 LOG(ERROR) << "PictureDrawQuad " << sizeof(PictureDrawQuad);
1002 break;
1003 case DrawQuad::TEXTURE_CONTENT:
1004 LOG(ERROR) << "TextureDrawQuad " << sizeof(TextureDrawQuad);
1005 break;
1006 case DrawQuad::RENDER_PASS:
1007 LOG(ERROR) << "RenderPassDrawQuad " << sizeof(RenderPassDrawQuad);
1008 break;
1009 case DrawQuad::SOLID_COLOR:
1010 LOG(ERROR) << "SolidColorDrawQuad " << sizeof(SolidColorDrawQuad);
1011 break;
1012 case DrawQuad::SURFACE_CONTENT:
1013 LOG(ERROR) << "SurfaceDrawQuad " << sizeof(SurfaceDrawQuad);
1014 break;
1015 case DrawQuad::TILED_CONTENT:
1016 LOG(ERROR) << "TileDrawQuad " << sizeof(TileDrawQuad);
1017 break;
1018 case DrawQuad::STREAM_VIDEO_CONTENT:
1019 LOG(ERROR) << "StreamVideoDrawQuad " << sizeof(StreamVideoDrawQuad);
1020 break;
1021 case DrawQuad::YUV_VIDEO_CONTENT:
1022 LOG(ERROR) << "YUVVideoDrawQuad " << sizeof(YUVVideoDrawQuad);
1023 break;
1024 case DrawQuad::INVALID:
1025 break;
1030 } // namespace
1031 } // namespace cc