1 // Copyright (c) 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 "content/common/cc_messages.h"
11 #include "cc/output/compositor_frame.h"
12 #include "ipc/ipc_message.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "third_party/khronos/GLES2/gl2ext.h"
15 #include "third_party/skia/include/effects/SkBlurImageFilter.h"
17 using cc::CheckerboardDrawQuad
;
18 using cc::DelegatedFrameData
;
19 using cc::DebugBorderDrawQuad
;
21 using cc::FilterOperation
;
22 using cc::FilterOperations
;
23 using cc::IOSurfaceDrawQuad
;
24 using cc::PictureDrawQuad
;
26 using cc::RenderPassDrawQuad
;
27 using cc::ResourceProvider
;
28 using cc::SharedQuadState
;
29 using cc::SolidColorDrawQuad
;
30 using cc::TextureDrawQuad
;
31 using cc::TileDrawQuad
;
32 using cc::TransferableResource
;
33 using cc::StreamVideoDrawQuad
;
34 using cc::VideoLayerImpl
;
35 using cc::YUVVideoDrawQuad
;
41 class CCMessagesTest
: public testing::Test
{
43 void Compare(const RenderPass
* a
, const RenderPass
* b
) {
44 EXPECT_EQ(a
->id
, b
->id
);
45 EXPECT_EQ(a
->output_rect
.ToString(), b
->output_rect
.ToString());
46 EXPECT_EQ(a
->damage_rect
.ToString(), b
->damage_rect
.ToString());
47 EXPECT_EQ(a
->transform_to_root_target
, b
->transform_to_root_target
);
48 EXPECT_EQ(a
->has_transparent_background
, b
->has_transparent_background
);
51 void Compare(const SharedQuadState
* a
, const SharedQuadState
* b
) {
52 EXPECT_EQ(a
->content_to_target_transform
, b
->content_to_target_transform
);
53 EXPECT_EQ(a
->content_bounds
, b
->content_bounds
);
54 EXPECT_EQ(a
->visible_content_rect
, b
->visible_content_rect
);
55 EXPECT_EQ(a
->clip_rect
, b
->clip_rect
);
56 EXPECT_EQ(a
->is_clipped
, b
->is_clipped
);
57 EXPECT_EQ(a
->opacity
, b
->opacity
);
60 void Compare(const DrawQuad
* a
, const DrawQuad
* b
) {
61 ASSERT_NE(DrawQuad::INVALID
, a
->material
);
62 ASSERT_EQ(a
->material
, b
->material
);
63 EXPECT_EQ(a
->rect
.ToString(), b
->rect
.ToString());
64 EXPECT_EQ(a
->opaque_rect
.ToString(), b
->opaque_rect
.ToString());
65 EXPECT_EQ(a
->visible_rect
.ToString(), b
->visible_rect
.ToString());
66 EXPECT_EQ(a
->needs_blending
, b
->needs_blending
);
68 Compare(a
->shared_quad_state
, b
->shared_quad_state
);
70 switch (a
->material
) {
71 case DrawQuad::CHECKERBOARD
:
72 Compare(CheckerboardDrawQuad::MaterialCast(a
),
73 CheckerboardDrawQuad::MaterialCast(b
));
75 case DrawQuad::DEBUG_BORDER
:
76 Compare(DebugBorderDrawQuad::MaterialCast(a
),
77 DebugBorderDrawQuad::MaterialCast(b
));
79 case DrawQuad::IO_SURFACE_CONTENT
:
80 Compare(IOSurfaceDrawQuad::MaterialCast(a
),
81 IOSurfaceDrawQuad::MaterialCast(b
));
83 case DrawQuad::PICTURE_CONTENT
:
84 Compare(PictureDrawQuad::MaterialCast(a
),
85 PictureDrawQuad::MaterialCast(b
));
87 case DrawQuad::RENDER_PASS
:
88 Compare(RenderPassDrawQuad::MaterialCast(a
),
89 RenderPassDrawQuad::MaterialCast(b
));
91 case DrawQuad::TEXTURE_CONTENT
:
92 Compare(TextureDrawQuad::MaterialCast(a
),
93 TextureDrawQuad::MaterialCast(b
));
95 case DrawQuad::TILED_CONTENT
:
96 Compare(TileDrawQuad::MaterialCast(a
),
97 TileDrawQuad::MaterialCast(b
));
99 case DrawQuad::SOLID_COLOR
:
100 Compare(SolidColorDrawQuad::MaterialCast(a
),
101 SolidColorDrawQuad::MaterialCast(b
));
103 case DrawQuad::STREAM_VIDEO_CONTENT
:
104 Compare(StreamVideoDrawQuad::MaterialCast(a
),
105 StreamVideoDrawQuad::MaterialCast(b
));
107 case DrawQuad::YUV_VIDEO_CONTENT
:
108 Compare(YUVVideoDrawQuad::MaterialCast(a
),
109 YUVVideoDrawQuad::MaterialCast(b
));
111 case DrawQuad::INVALID
:
116 void Compare(const CheckerboardDrawQuad
* a
, const CheckerboardDrawQuad
* b
) {
117 EXPECT_EQ(a
->color
, b
->color
);
120 void Compare(const DebugBorderDrawQuad
* a
, const DebugBorderDrawQuad
* b
) {
121 EXPECT_EQ(a
->color
, b
->color
);
122 EXPECT_EQ(a
->width
, b
->width
);
125 void Compare(const IOSurfaceDrawQuad
* a
, const IOSurfaceDrawQuad
* b
) {
126 EXPECT_EQ(a
->io_surface_size
.ToString(), b
->io_surface_size
.ToString());
127 EXPECT_EQ(a
->io_surface_resource_id
, b
->io_surface_resource_id
);
128 EXPECT_EQ(a
->orientation
, b
->orientation
);
131 void Compare(const RenderPassDrawQuad
* a
, const RenderPassDrawQuad
* b
) {
132 EXPECT_EQ(a
->render_pass_id
, b
->render_pass_id
);
133 EXPECT_EQ(a
->is_replica
, b
->is_replica
);
134 EXPECT_EQ(a
->mask_resource_id
, b
->mask_resource_id
);
135 EXPECT_EQ(a
->contents_changed_since_last_frame
,
136 b
->contents_changed_since_last_frame
);
137 EXPECT_EQ(a
->mask_uv_rect
.ToString(), b
->mask_uv_rect
.ToString());
138 EXPECT_EQ(a
->filters
.size(), b
->filters
.size());
139 for (size_t i
= 0; i
< a
->filters
.size(); ++i
) {
140 if (a
->filters
.at(i
).type() != cc::FilterOperation::REFERENCE
) {
141 EXPECT_EQ(a
->filters
.at(i
), b
->filters
.at(i
));
143 EXPECT_EQ(b
->filters
.at(i
).type(), cc::FilterOperation::REFERENCE
);
144 EXPECT_EQ(a
->filters
.at(i
).image_filter()->countInputs(),
145 b
->filters
.at(i
).image_filter()->countInputs());
148 EXPECT_EQ(a
->background_filters
, b
->background_filters
);
151 void Compare(const SolidColorDrawQuad
* a
, const SolidColorDrawQuad
* b
) {
152 EXPECT_EQ(a
->color
, b
->color
);
153 EXPECT_EQ(a
->force_anti_aliasing_off
, b
->force_anti_aliasing_off
);
156 void Compare(const StreamVideoDrawQuad
* a
, const StreamVideoDrawQuad
* b
) {
157 EXPECT_EQ(a
->resource_id
, b
->resource_id
);
158 EXPECT_EQ(a
->matrix
, b
->matrix
);
161 void Compare(const TextureDrawQuad
* a
, const TextureDrawQuad
* b
) {
162 EXPECT_EQ(a
->resource_id
, b
->resource_id
);
163 EXPECT_EQ(a
->premultiplied_alpha
, b
->premultiplied_alpha
);
164 EXPECT_EQ(a
->uv_top_left
, b
->uv_top_left
);
165 EXPECT_EQ(a
->uv_bottom_right
, b
->uv_bottom_right
);
166 EXPECT_EQ(a
->background_color
, b
->background_color
);
167 EXPECT_EQ(a
->vertex_opacity
[0], b
->vertex_opacity
[0]);
168 EXPECT_EQ(a
->vertex_opacity
[1], b
->vertex_opacity
[1]);
169 EXPECT_EQ(a
->vertex_opacity
[2], b
->vertex_opacity
[2]);
170 EXPECT_EQ(a
->vertex_opacity
[3], b
->vertex_opacity
[3]);
171 EXPECT_EQ(a
->flipped
, b
->flipped
);
174 void Compare(const TileDrawQuad
* a
, const TileDrawQuad
* b
) {
175 EXPECT_EQ(a
->resource_id
, b
->resource_id
);
176 EXPECT_EQ(a
->tex_coord_rect
, b
->tex_coord_rect
);
177 EXPECT_EQ(a
->texture_size
, b
->texture_size
);
178 EXPECT_EQ(a
->swizzle_contents
, b
->swizzle_contents
);
181 void Compare(const YUVVideoDrawQuad
* a
, const YUVVideoDrawQuad
* b
) {
182 EXPECT_EQ(a
->tex_scale
, b
->tex_scale
);
183 EXPECT_EQ(a
->y_plane_resource_id
, b
->y_plane_resource_id
);
184 EXPECT_EQ(a
->u_plane_resource_id
, b
->u_plane_resource_id
);
185 EXPECT_EQ(a
->v_plane_resource_id
, b
->v_plane_resource_id
);
186 EXPECT_EQ(a
->a_plane_resource_id
, b
->a_plane_resource_id
);
189 void Compare(const TransferableResource
& a
, const TransferableResource
& b
) {
190 EXPECT_EQ(a
.id
, b
.id
);
191 EXPECT_EQ(a
.sync_point
, b
.sync_point
);
192 EXPECT_EQ(a
.format
, b
.format
);
193 EXPECT_EQ(a
.target
, b
.target
);
194 EXPECT_EQ(a
.filter
, b
.filter
);
195 EXPECT_EQ(a
.size
.ToString(), b
.size
.ToString());
196 for (size_t i
= 0; i
< arraysize(a
.mailbox
.name
); ++i
)
197 EXPECT_EQ(a
.mailbox
.name
[i
], b
.mailbox
.name
[i
]);
201 TEST_F(CCMessagesTest
, AllQuads
) {
202 IPC::Message
msg(1, 2, IPC::Message::PRIORITY_NORMAL
);
204 Transform arbitrary_matrix
;
205 arbitrary_matrix
.Scale(3, 3);
206 arbitrary_matrix
.Translate(-5, 20);
207 arbitrary_matrix
.Rotate(15);
208 gfx::Rect
arbitrary_rect1(-5, 9, 3, 15);
209 gfx::Rect
arbitrary_rect1_inside_rect1(-4, 12, 2, 8);
210 gfx::Rect
arbitrary_rect2_inside_rect1(-5, 11, 1, 2);
211 gfx::Rect
arbitrary_rect2(40, 23, 11, 7);
212 gfx::Rect
arbitrary_rect1_inside_rect2(44, 23, 4, 2);
213 gfx::Rect
arbitrary_rect2_inside_rect2(41, 25, 3, 5);
214 gfx::Rect
arbitrary_rect3(7, -53, 22, 19);
215 gfx::Rect
arbitrary_rect1_inside_rect3(10, -40, 6, 3);
216 gfx::Rect
arbitrary_rect2_inside_rect3(12, -51, 5, 12);
217 gfx::Size
arbitrary_size1(15, 19);
218 gfx::Size
arbitrary_size2(3, 99);
219 gfx::Size
arbitrary_size3(75, 1281);
220 gfx::RectF
arbitrary_rectf1(4.2f
, -922.1f
, 15.6f
, 29.5f
);
221 gfx::SizeF
arbitrary_sizef1(15.2f
, 104.6f
);
222 gfx::PointF
arbitrary_pointf1(31.4f
, 15.9f
);
223 gfx::PointF
arbitrary_pointf2(26.5f
, -35.8f
);
224 float arbitrary_float1
= 0.7f
;
225 float arbitrary_float2
= 0.3f
;
226 float arbitrary_float3
= 0.9f
;
227 float arbitrary_float_array
[4] = {3.5f
, 6.2f
, 9.3f
, 12.3f
};
228 bool arbitrary_bool1
= true;
229 bool arbitrary_bool2
= false;
230 bool arbitrary_bool3
= true;
231 int arbitrary_int
= 5;
232 SkColor arbitrary_color
= SkColorSetARGB(25, 36, 47, 58);
233 IOSurfaceDrawQuad::Orientation arbitrary_orientation
=
234 IOSurfaceDrawQuad::UNFLIPPED
;
235 RenderPass::Id
arbitrary_id(10, 14);
236 ResourceProvider::ResourceId arbitrary_resourceid1
= 55;
237 ResourceProvider::ResourceId arbitrary_resourceid2
= 47;
238 ResourceProvider::ResourceId arbitrary_resourceid3
= 23;
239 ResourceProvider::ResourceId arbitrary_resourceid4
= 16;
240 SkScalar arbitrary_sigma
= SkFloatToScalar(2.0f
);
242 FilterOperations arbitrary_filters1
;
243 arbitrary_filters1
.Append(FilterOperation::CreateGrayscaleFilter(
245 skia::RefPtr
<SkImageFilter
> arbitrary_filter
= skia::AdoptRef(
246 new SkBlurImageFilter(arbitrary_sigma
, arbitrary_sigma
));
247 arbitrary_filters1
.Append(
248 cc::FilterOperation::CreateReferenceFilter(arbitrary_filter
));
250 FilterOperations arbitrary_filters2
;
251 arbitrary_filters2
.Append(FilterOperation::CreateBrightnessFilter(
254 scoped_ptr
<SharedQuadState
> shared_state1_in
= SharedQuadState::Create();
255 shared_state1_in
->SetAll(arbitrary_matrix
,
261 scoped_ptr
<SharedQuadState
> shared_state1_cmp
= shared_state1_in
->Copy();
263 scoped_ptr
<CheckerboardDrawQuad
> checkerboard_in
=
264 CheckerboardDrawQuad::Create();
265 checkerboard_in
->SetAll(shared_state1_in
.get(),
267 arbitrary_rect2_inside_rect1
,
268 arbitrary_rect1_inside_rect1
,
271 scoped_ptr
<DrawQuad
> checkerboard_cmp
= checkerboard_in
->Copy(
272 checkerboard_in
->shared_quad_state
);
274 scoped_ptr
<DebugBorderDrawQuad
> debugborder_in
=
275 DebugBorderDrawQuad::Create();
276 debugborder_in
->SetAll(shared_state1_in
.get(),
278 arbitrary_rect1_inside_rect3
,
279 arbitrary_rect2_inside_rect3
,
283 scoped_ptr
<DrawQuad
> debugborder_cmp
= debugborder_in
->Copy(
284 debugborder_in
->shared_quad_state
);
286 scoped_ptr
<IOSurfaceDrawQuad
> iosurface_in
=
287 IOSurfaceDrawQuad::Create();
288 iosurface_in
->SetAll(shared_state1_in
.get(),
290 arbitrary_rect2_inside_rect2
,
291 arbitrary_rect1_inside_rect2
,
294 arbitrary_resourceid3
,
295 arbitrary_orientation
);
296 scoped_ptr
<DrawQuad
> iosurface_cmp
= iosurface_in
->Copy(
297 iosurface_in
->shared_quad_state
);
299 scoped_ptr
<RenderPassDrawQuad
> renderpass_in
=
300 RenderPassDrawQuad::Create();
301 renderpass_in
->SetAll(shared_state1_in
.get(),
303 arbitrary_rect2_inside_rect1
,
304 arbitrary_rect1_inside_rect1
,
308 arbitrary_resourceid2
,
313 scoped_ptr
<RenderPassDrawQuad
> renderpass_cmp
= renderpass_in
->Copy(
314 renderpass_in
->shared_quad_state
, renderpass_in
->render_pass_id
);
316 scoped_ptr
<SharedQuadState
> shared_state2_in
= SharedQuadState::Create();
317 shared_state2_in
->SetAll(arbitrary_matrix
,
323 scoped_ptr
<SharedQuadState
> shared_state2_cmp
= shared_state2_in
->Copy();
325 scoped_ptr
<SharedQuadState
> shared_state3_in
= SharedQuadState::Create();
326 shared_state3_in
->SetAll(arbitrary_matrix
,
332 scoped_ptr
<SharedQuadState
> shared_state3_cmp
= shared_state3_in
->Copy();
334 scoped_ptr
<SolidColorDrawQuad
> solidcolor_in
=
335 SolidColorDrawQuad::Create();
336 solidcolor_in
->SetAll(shared_state1_in
.get(),
338 arbitrary_rect1_inside_rect3
,
339 arbitrary_rect2_inside_rect3
,
343 scoped_ptr
<DrawQuad
> solidcolor_cmp
= solidcolor_in
->Copy(
344 solidcolor_in
->shared_quad_state
);
346 scoped_ptr
<StreamVideoDrawQuad
> streamvideo_in
=
347 StreamVideoDrawQuad::Create();
348 streamvideo_in
->SetAll(shared_state1_in
.get(),
350 arbitrary_rect2_inside_rect2
,
351 arbitrary_rect1_inside_rect2
,
353 arbitrary_resourceid2
,
355 scoped_ptr
<DrawQuad
> streamvideo_cmp
= streamvideo_in
->Copy(
356 streamvideo_in
->shared_quad_state
);
358 scoped_ptr
<TextureDrawQuad
> texture_in
= TextureDrawQuad::Create();
359 texture_in
->SetAll(shared_state1_in
.get(),
361 arbitrary_rect2_inside_rect2
,
362 arbitrary_rect1_inside_rect2
,
364 arbitrary_resourceid1
,
369 arbitrary_float_array
,
371 scoped_ptr
<DrawQuad
> texture_cmp
= texture_in
->Copy(
372 texture_in
->shared_quad_state
);
374 scoped_ptr
<TileDrawQuad
> tile_in
= TileDrawQuad::Create();
375 tile_in
->SetAll(shared_state1_in
.get(),
377 arbitrary_rect2_inside_rect2
,
378 arbitrary_rect1_inside_rect2
,
380 arbitrary_resourceid3
,
384 scoped_ptr
<DrawQuad
> tile_cmp
= tile_in
->Copy(
385 tile_in
->shared_quad_state
);
387 scoped_ptr
<YUVVideoDrawQuad
> yuvvideo_in
=
388 YUVVideoDrawQuad::Create();
389 yuvvideo_in
->SetAll(shared_state1_in
.get(),
391 arbitrary_rect2_inside_rect1
,
392 arbitrary_rect1_inside_rect1
,
395 arbitrary_resourceid1
,
396 arbitrary_resourceid2
,
397 arbitrary_resourceid3
,
398 arbitrary_resourceid4
);
399 scoped_ptr
<DrawQuad
> yuvvideo_cmp
= yuvvideo_in
->Copy(
400 yuvvideo_in
->shared_quad_state
);
402 scoped_ptr
<RenderPass
> pass_in
= RenderPass::Create();
403 pass_in
->SetAll(arbitrary_id
,
409 pass_in
->shared_quad_state_list
.push_back(shared_state1_in
.Pass());
410 pass_in
->quad_list
.push_back(checkerboard_in
.PassAs
<DrawQuad
>());
411 pass_in
->quad_list
.push_back(debugborder_in
.PassAs
<DrawQuad
>());
412 pass_in
->quad_list
.push_back(iosurface_in
.PassAs
<DrawQuad
>());
413 pass_in
->quad_list
.push_back(renderpass_in
.PassAs
<DrawQuad
>());
414 pass_in
->shared_quad_state_list
.push_back(shared_state2_in
.Pass());
415 pass_in
->shared_quad_state_list
.push_back(shared_state3_in
.Pass());
416 pass_in
->quad_list
.push_back(solidcolor_in
.PassAs
<DrawQuad
>());
417 pass_in
->quad_list
.push_back(streamvideo_in
.PassAs
<DrawQuad
>());
418 pass_in
->quad_list
.push_back(texture_in
.PassAs
<DrawQuad
>());
419 pass_in
->quad_list
.push_back(tile_in
.PassAs
<DrawQuad
>());
420 pass_in
->quad_list
.push_back(yuvvideo_in
.PassAs
<DrawQuad
>());
422 scoped_ptr
<RenderPass
> pass_cmp
= RenderPass::Create();
423 pass_cmp
->SetAll(arbitrary_id
,
429 pass_cmp
->shared_quad_state_list
.push_back(shared_state1_cmp
.Pass());
430 pass_cmp
->quad_list
.push_back(checkerboard_cmp
.PassAs
<DrawQuad
>());
431 pass_cmp
->quad_list
.push_back(debugborder_cmp
.PassAs
<DrawQuad
>());
432 pass_cmp
->quad_list
.push_back(iosurface_cmp
.PassAs
<DrawQuad
>());
433 pass_cmp
->quad_list
.push_back(renderpass_cmp
.PassAs
<DrawQuad
>());
434 pass_cmp
->shared_quad_state_list
.push_back(shared_state2_cmp
.Pass());
435 pass_cmp
->shared_quad_state_list
.push_back(shared_state3_cmp
.Pass());
436 pass_cmp
->quad_list
.push_back(solidcolor_cmp
.PassAs
<DrawQuad
>());
437 pass_cmp
->quad_list
.push_back(streamvideo_cmp
.PassAs
<DrawQuad
>());
438 pass_cmp
->quad_list
.push_back(texture_cmp
.PassAs
<DrawQuad
>());
439 pass_cmp
->quad_list
.push_back(tile_cmp
.PassAs
<DrawQuad
>());
440 pass_cmp
->quad_list
.push_back(yuvvideo_cmp
.PassAs
<DrawQuad
>());
442 // Make sure the in and cmp RenderPasses match.
443 Compare(pass_cmp
.get(), pass_in
.get());
444 ASSERT_EQ(3u, pass_in
->shared_quad_state_list
.size());
445 ASSERT_EQ(9u, pass_in
->quad_list
.size());
446 for (size_t i
= 0; i
< 3; ++i
) {
447 Compare(pass_cmp
->shared_quad_state_list
[i
],
448 pass_in
->shared_quad_state_list
[i
]);
450 for (size_t i
= 0; i
< pass_in
->quad_list
.size(); ++i
)
451 Compare(pass_cmp
->quad_list
[i
], pass_in
->quad_list
[i
]);
452 for (size_t i
= 1; i
< pass_in
->quad_list
.size(); ++i
) {
453 bool same_shared_quad_state_cmp
=
454 pass_cmp
->quad_list
[i
]->shared_quad_state
==
455 pass_cmp
->quad_list
[i
- 1]->shared_quad_state
;
456 bool same_shared_quad_state_in
=
457 pass_in
->quad_list
[i
]->shared_quad_state
==
458 pass_in
->quad_list
[i
- 1]->shared_quad_state
;
459 EXPECT_EQ(same_shared_quad_state_cmp
, same_shared_quad_state_in
);
462 DelegatedFrameData frame_in
;
463 frame_in
.render_pass_list
.push_back(pass_in
.Pass());
465 IPC::ParamTraits
<DelegatedFrameData
>::Write(&msg
, frame_in
);
467 DelegatedFrameData frame_out
;
468 PickleIterator
iter(msg
);
469 EXPECT_TRUE(IPC::ParamTraits
<DelegatedFrameData
>::Read(&msg
,
472 // Make sure the out and cmp RenderPasses match.
473 scoped_ptr
<RenderPass
> pass_out
= frame_out
.render_pass_list
.take(
474 frame_out
.render_pass_list
.begin());
475 Compare(pass_cmp
.get(), pass_out
.get());
476 ASSERT_EQ(3u, pass_out
->shared_quad_state_list
.size());
477 ASSERT_EQ(9u, pass_out
->quad_list
.size());
478 for (size_t i
= 0; i
< 3; ++i
) {
479 Compare(pass_cmp
->shared_quad_state_list
[i
],
480 pass_out
->shared_quad_state_list
[i
]);
482 for (size_t i
= 0; i
< pass_out
->quad_list
.size(); ++i
)
483 Compare(pass_cmp
->quad_list
[i
], pass_out
->quad_list
[i
]);
484 for (size_t i
= 1; i
< pass_out
->quad_list
.size(); ++i
) {
485 bool same_shared_quad_state_cmp
=
486 pass_cmp
->quad_list
[i
]->shared_quad_state
==
487 pass_cmp
->quad_list
[i
- 1]->shared_quad_state
;
488 bool same_shared_quad_state_out
=
489 pass_out
->quad_list
[i
]->shared_quad_state
==
490 pass_out
->quad_list
[i
- 1]->shared_quad_state
;
491 EXPECT_EQ(same_shared_quad_state_cmp
, same_shared_quad_state_out
);
495 TEST_F(CCMessagesTest
, Resources
) {
496 IPC::Message
msg(1, 2, IPC::Message::PRIORITY_NORMAL
);
497 gfx::Size
arbitrary_size(757, 1281);
498 unsigned int arbitrary_uint1
= 71234838;
499 unsigned int arbitrary_uint2
= 53589793;
501 GLbyte arbitrary_mailbox1
[64] = {
502 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
503 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
504 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
508 GLbyte arbitrary_mailbox2
[64] = {
509 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0,
510 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0,
511 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0,
515 TransferableResource arbitrary_resource1
;
516 arbitrary_resource1
.id
= 2178312;
517 arbitrary_resource1
.sync_point
= arbitrary_uint1
;
518 arbitrary_resource1
.format
= cc::RGBA_8888
;
519 arbitrary_resource1
.target
= GL_TEXTURE_2D
;
520 arbitrary_resource1
.filter
= 53;
521 arbitrary_resource1
.size
= gfx::Size(37189, 123123);
522 arbitrary_resource1
.mailbox
.SetName(arbitrary_mailbox1
);
524 TransferableResource arbitrary_resource2
;
525 arbitrary_resource2
.id
= 789132;
526 arbitrary_resource2
.sync_point
= arbitrary_uint2
;
527 arbitrary_resource2
.format
= cc::RGBA_4444
;
528 arbitrary_resource2
.target
= GL_TEXTURE_EXTERNAL_OES
;
529 arbitrary_resource2
.filter
= 47;
530 arbitrary_resource2
.size
= gfx::Size(89123, 23789);
531 arbitrary_resource2
.mailbox
.SetName(arbitrary_mailbox2
);
533 scoped_ptr
<RenderPass
> renderpass_in
= RenderPass::Create();
534 renderpass_in
->SetNew(
535 RenderPass::Id(1, 1), gfx::Rect(), gfx::Rect(), gfx::Transform());
537 DelegatedFrameData frame_in
;
538 frame_in
.resource_list
.push_back(arbitrary_resource1
);
539 frame_in
.resource_list
.push_back(arbitrary_resource2
);
540 frame_in
.render_pass_list
.push_back(renderpass_in
.Pass());
542 IPC::ParamTraits
<DelegatedFrameData
>::Write(&msg
, frame_in
);
544 DelegatedFrameData frame_out
;
545 PickleIterator
iter(msg
);
546 EXPECT_TRUE(IPC::ParamTraits
<DelegatedFrameData
>::Read(&msg
,
549 ASSERT_EQ(2u, frame_out
.resource_list
.size());
550 Compare(arbitrary_resource1
, frame_out
.resource_list
[0]);
551 Compare(arbitrary_resource2
, frame_out
.resource_list
[1]);
554 TEST_F(CCMessagesTest
, LargestQuadType
) {
558 for (int i
= 0; !done
; ++i
) {
559 switch (static_cast<DrawQuad::Material
>(i
)) {
560 case cc::DrawQuad::CHECKERBOARD
:
561 largest
= std::max(largest
, sizeof(cc::CheckerboardDrawQuad
));
563 case cc::DrawQuad::DEBUG_BORDER
:
564 largest
= std::max(largest
, sizeof(cc::DebugBorderDrawQuad
));
566 case cc::DrawQuad::IO_SURFACE_CONTENT
:
567 largest
= std::max(largest
, sizeof(cc::IOSurfaceDrawQuad
));
569 case cc::DrawQuad::PICTURE_CONTENT
:
570 largest
= std::max(largest
, sizeof(cc::PictureDrawQuad
));
572 case cc::DrawQuad::TEXTURE_CONTENT
:
573 largest
= std::max(largest
, sizeof(cc::TextureDrawQuad
));
575 case cc::DrawQuad::RENDER_PASS
:
576 largest
= std::max(largest
, sizeof(cc::RenderPassDrawQuad
));
578 case cc::DrawQuad::SOLID_COLOR
:
579 largest
= std::max(largest
, sizeof(cc::SolidColorDrawQuad
));
581 case cc::DrawQuad::TILED_CONTENT
:
582 largest
= std::max(largest
, sizeof(cc::TileDrawQuad
));
584 case cc::DrawQuad::STREAM_VIDEO_CONTENT
:
585 largest
= std::max(largest
, sizeof(cc::StreamVideoDrawQuad
));
587 case cc::DrawQuad::YUV_VIDEO_CONTENT
:
588 largest
= std::max(largest
, sizeof(cc::YUVVideoDrawQuad
));
590 case cc::DrawQuad::INVALID
:
597 // Verify the largest DrawQuad type is RenderPassDrawQuad. If this ever
598 // changes, then the ReserveSizeForRenderPassWrite() method needs to be
599 // updated as well to use the new largest quad.
600 EXPECT_EQ(sizeof(RenderPassDrawQuad
), largest
);
604 } // namespace content