blob: 8d8b08add432acaa7bc5377d1715adc595cab8b4 [file] [log] [blame]
[email protected]4934d362012-11-22 22:04:531// 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.
4
5#include "content/common/cc_messages.h"
6
7#include <string.h>
8
[email protected]7f0d825f2013-03-18 07:24:309#include "cc/output/compositor_frame.h"
[email protected]4934d362012-11-22 22:04:5310#include "ipc/ipc_message.h"
11#include "testing/gtest/include/gtest/gtest.h"
12
13using cc::CheckerboardDrawQuad;
[email protected]bf189f62012-12-18 03:42:1114using cc::DelegatedFrameData;
[email protected]4934d362012-11-22 22:04:5315using cc::DebugBorderDrawQuad;
16using cc::DrawQuad;
[email protected]ae6b1a72013-06-25 18:49:2917using cc::FilterOperation;
18using cc::FilterOperations;
[email protected]4934d362012-11-22 22:04:5319using cc::IOSurfaceDrawQuad;
[email protected]9ee4d3a2013-03-27 17:43:1620using cc::PictureDrawQuad;
[email protected]4934d362012-11-22 22:04:5321using cc::RenderPass;
22using cc::RenderPassDrawQuad;
23using cc::ResourceProvider;
24using cc::SharedQuadState;
25using cc::SolidColorDrawQuad;
26using cc::TextureDrawQuad;
27using cc::TileDrawQuad;
[email protected]bca159072012-12-04 00:52:4428using cc::TransferableResource;
[email protected]4934d362012-11-22 22:04:5329using cc::StreamVideoDrawQuad;
30using cc::VideoLayerImpl;
31using cc::YUVVideoDrawQuad;
[email protected]c8686a02012-11-27 08:29:0032using gfx::Transform;
[email protected]4934d362012-11-22 22:04:5333
[email protected]bca159072012-12-04 00:52:4434namespace content {
35namespace {
36
[email protected]4934d362012-11-22 22:04:5337class CCMessagesTest : public testing::Test {
38 protected:
39 void Compare(const RenderPass* a, const RenderPass* b) {
40 EXPECT_EQ(a->id, b->id);
41 EXPECT_EQ(a->output_rect.ToString(), b->output_rect.ToString());
42 EXPECT_EQ(a->damage_rect.ToString(), b->damage_rect.ToString());
43 EXPECT_EQ(a->transform_to_root_target, b->transform_to_root_target);
44 EXPECT_EQ(a->has_transparent_background, b->has_transparent_background);
45 EXPECT_EQ(a->has_occlusion_from_outside_target_surface,
46 b->has_occlusion_from_outside_target_surface);
[email protected]4934d362012-11-22 22:04:5347 }
48
49 void Compare(const SharedQuadState* a, const SharedQuadState* b) {
50 EXPECT_EQ(a->content_to_target_transform, b->content_to_target_transform);
[email protected]f902bf92013-03-04 18:33:2751 EXPECT_EQ(a->content_bounds, b->content_bounds);
[email protected]4934d362012-11-22 22:04:5352 EXPECT_EQ(a->visible_content_rect, b->visible_content_rect);
[email protected]4934d362012-11-22 22:04:5353 EXPECT_EQ(a->clip_rect, b->clip_rect);
54 EXPECT_EQ(a->is_clipped, b->is_clipped);
55 EXPECT_EQ(a->opacity, b->opacity);
56 }
57
58 void Compare(const DrawQuad* a, const DrawQuad* b) {
59 ASSERT_NE(DrawQuad::INVALID, a->material);
60 ASSERT_EQ(a->material, b->material);
61 EXPECT_EQ(a->rect.ToString(), b->rect.ToString());
62 EXPECT_EQ(a->opaque_rect.ToString(), b->opaque_rect.ToString());
63 EXPECT_EQ(a->visible_rect.ToString(), b->visible_rect.ToString());
64 EXPECT_EQ(a->needs_blending, b->needs_blending);
65
66 Compare(a->shared_quad_state, b->shared_quad_state);
67
68 switch (a->material) {
69 case DrawQuad::CHECKERBOARD:
70 Compare(CheckerboardDrawQuad::MaterialCast(a),
71 CheckerboardDrawQuad::MaterialCast(b));
72 break;
73 case DrawQuad::DEBUG_BORDER:
74 Compare(DebugBorderDrawQuad::MaterialCast(a),
75 DebugBorderDrawQuad::MaterialCast(b));
76 break;
77 case DrawQuad::IO_SURFACE_CONTENT:
78 Compare(IOSurfaceDrawQuad::MaterialCast(a),
79 IOSurfaceDrawQuad::MaterialCast(b));
80 break;
[email protected]9ee4d3a2013-03-27 17:43:1681 case DrawQuad::PICTURE_CONTENT:
82 Compare(PictureDrawQuad::MaterialCast(a),
83 PictureDrawQuad::MaterialCast(b));
84 break;
[email protected]4934d362012-11-22 22:04:5385 case DrawQuad::RENDER_PASS:
86 Compare(RenderPassDrawQuad::MaterialCast(a),
87 RenderPassDrawQuad::MaterialCast(b));
88 break;
89 case DrawQuad::TEXTURE_CONTENT:
90 Compare(TextureDrawQuad::MaterialCast(a),
91 TextureDrawQuad::MaterialCast(b));
92 break;
93 case DrawQuad::TILED_CONTENT:
94 Compare(TileDrawQuad::MaterialCast(a),
95 TileDrawQuad::MaterialCast(b));
96 break;
97 case DrawQuad::SOLID_COLOR:
98 Compare(SolidColorDrawQuad::MaterialCast(a),
99 SolidColorDrawQuad::MaterialCast(b));
100 break;
101 case DrawQuad::STREAM_VIDEO_CONTENT:
102 Compare(StreamVideoDrawQuad::MaterialCast(a),
103 StreamVideoDrawQuad::MaterialCast(b));
104 break;
105 case DrawQuad::YUV_VIDEO_CONTENT:
106 Compare(YUVVideoDrawQuad::MaterialCast(a),
107 YUVVideoDrawQuad::MaterialCast(b));
108 break;
109 case DrawQuad::INVALID:
110 break;
111 }
112 }
113
114 void Compare(const CheckerboardDrawQuad* a, const CheckerboardDrawQuad* b) {
115 EXPECT_EQ(a->color, b->color);
116 }
117
118 void Compare(const DebugBorderDrawQuad* a, const DebugBorderDrawQuad* b) {
119 EXPECT_EQ(a->color, b->color);
120 EXPECT_EQ(a->width, b->width);
121 }
122
123 void Compare(const IOSurfaceDrawQuad* a, const IOSurfaceDrawQuad* b) {
124 EXPECT_EQ(a->io_surface_size.ToString(), b->io_surface_size.ToString());
[email protected]b7cfc632013-04-10 04:44:49125 EXPECT_EQ(a->io_surface_resource_id, b->io_surface_resource_id);
[email protected]4934d362012-11-22 22:04:53126 EXPECT_EQ(a->orientation, b->orientation);
127 }
128
129 void Compare(const RenderPassDrawQuad* a, const RenderPassDrawQuad* b) {
[email protected]82f93fb2013-04-17 21:42:06130 EXPECT_EQ(a->render_pass_id, b->render_pass_id);
[email protected]4934d362012-11-22 22:04:53131 EXPECT_EQ(a->is_replica, b->is_replica);
132 EXPECT_EQ(a->mask_resource_id, b->mask_resource_id);
133 EXPECT_EQ(a->contents_changed_since_last_frame,
134 b->contents_changed_since_last_frame);
[email protected]458af1e2012-12-13 05:12:18135 EXPECT_EQ(a->mask_uv_rect.ToString(), b->mask_uv_rect.ToString());
[email protected]20062042012-12-21 22:16:36136 EXPECT_EQ(a->filters, b->filters);
137 EXPECT_EQ(a->filter, b->filter);
138 EXPECT_EQ(a->background_filters, b->background_filters);
[email protected]4934d362012-11-22 22:04:53139 }
140
141 void Compare(const SolidColorDrawQuad* a, const SolidColorDrawQuad* b) {
142 EXPECT_EQ(a->color, b->color);
[email protected]10a30b12013-05-02 16:42:11143 EXPECT_EQ(a->force_anti_aliasing_off, b->force_anti_aliasing_off);
[email protected]4934d362012-11-22 22:04:53144 }
145
146 void Compare(const StreamVideoDrawQuad* a, const StreamVideoDrawQuad* b) {
[email protected]b7cfc632013-04-10 04:44:49147 EXPECT_EQ(a->resource_id, b->resource_id);
[email protected]4934d362012-11-22 22:04:53148 EXPECT_EQ(a->matrix, b->matrix);
149 }
150
151 void Compare(const TextureDrawQuad* a, const TextureDrawQuad* b) {
152 EXPECT_EQ(a->resource_id, b->resource_id);
153 EXPECT_EQ(a->premultiplied_alpha, b->premultiplied_alpha);
[email protected]1fd555b2013-01-18 00:13:21154 EXPECT_EQ(a->uv_top_left, b->uv_top_left);
155 EXPECT_EQ(a->uv_bottom_right, b->uv_bottom_right);
[email protected]61df9d82013-01-30 02:32:42156 EXPECT_EQ(a->vertex_opacity[0], b->vertex_opacity[0]);
157 EXPECT_EQ(a->vertex_opacity[1], b->vertex_opacity[1]);
158 EXPECT_EQ(a->vertex_opacity[2], b->vertex_opacity[2]);
159 EXPECT_EQ(a->vertex_opacity[3], b->vertex_opacity[3]);
[email protected]4934d362012-11-22 22:04:53160 EXPECT_EQ(a->flipped, b->flipped);
161 }
162
163 void Compare(const TileDrawQuad* a, const TileDrawQuad* b) {
164 EXPECT_EQ(a->resource_id, b->resource_id);
165 EXPECT_EQ(a->tex_coord_rect, b->tex_coord_rect);
166 EXPECT_EQ(a->texture_size, b->texture_size);
167 EXPECT_EQ(a->swizzle_contents, b->swizzle_contents);
[email protected]4934d362012-11-22 22:04:53168 }
169
170 void Compare(const YUVVideoDrawQuad* a, const YUVVideoDrawQuad* b) {
171 EXPECT_EQ(a->tex_scale, b->tex_scale);
[email protected]b7cfc632013-04-10 04:44:49172 EXPECT_EQ(a->y_plane_resource_id, b->y_plane_resource_id);
173 EXPECT_EQ(a->u_plane_resource_id, b->u_plane_resource_id);
174 EXPECT_EQ(a->v_plane_resource_id, b->v_plane_resource_id);
[email protected]0402b2382013-06-07 21:50:54175 EXPECT_EQ(a->a_plane_resource_id, b->a_plane_resource_id);
[email protected]4934d362012-11-22 22:04:53176 }
[email protected]bca159072012-12-04 00:52:44177
178 void Compare(const TransferableResource& a, const TransferableResource& b) {
179 EXPECT_EQ(a.id, b.id);
[email protected]09831f7f2013-02-27 03:32:15180 EXPECT_EQ(a.sync_point, b.sync_point);
[email protected]bca159072012-12-04 00:52:44181 EXPECT_EQ(a.format, b.format);
[email protected]80189292013-02-28 01:59:36182 EXPECT_EQ(a.filter, b.filter);
[email protected]bca159072012-12-04 00:52:44183 EXPECT_EQ(a.size.ToString(), b.size.ToString());
184 for (size_t i = 0; i < arraysize(a.mailbox.name); ++i)
185 EXPECT_EQ(a.mailbox.name[i], b.mailbox.name[i]);
186 }
[email protected]4934d362012-11-22 22:04:53187};
188
189TEST_F(CCMessagesTest, AllQuads) {
190 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
191
[email protected]c8686a02012-11-27 08:29:00192 Transform arbitrary_matrix;
193 arbitrary_matrix.Scale(3, 3);
194 arbitrary_matrix.Translate(-5, 20);
195 arbitrary_matrix.Rotate(15);
[email protected]4934d362012-11-22 22:04:53196 gfx::Rect arbitrary_rect1(-5, 9, 3, 15);
197 gfx::Rect arbitrary_rect2(40, 23, 11, 7);
198 gfx::Rect arbitrary_rect3(7, -53, 22, 19);
199 gfx::Size arbitrary_size1(15, 19);
200 gfx::Size arbitrary_size2(3, 99);
201 gfx::Size arbitrary_size3(75, 1281);
202 gfx::RectF arbitrary_rectf1(4.2f, -922.1f, 15.6f, 29.5f);
203 gfx::SizeF arbitrary_sizef1(15.2f, 104.6f);
[email protected]61df9d82013-01-30 02:32:42204 gfx::PointF arbitrary_pointf1(31.4f, 15.9f);
205 gfx::PointF arbitrary_pointf2(26.5f, -35.8f);
[email protected]4934d362012-11-22 22:04:53206 float arbitrary_float1 = 0.7f;
207 float arbitrary_float2 = 0.3f;
208 float arbitrary_float3 = 0.9f;
[email protected]61df9d82013-01-30 02:32:42209 float arbitrary_float_array[4] = {3.5f, 6.2f, 9.3f, 12.3f};
[email protected]4934d362012-11-22 22:04:53210 bool arbitrary_bool1 = true;
211 bool arbitrary_bool2 = false;
[email protected]61df9d82013-01-30 02:32:42212 bool arbitrary_bool3 = true;
[email protected]4934d362012-11-22 22:04:53213 int arbitrary_int = 5;
214 SkColor arbitrary_color = SkColorSetARGB(25, 36, 47, 58);
215 IOSurfaceDrawQuad::Orientation arbitrary_orientation =
216 IOSurfaceDrawQuad::UNFLIPPED;
217 RenderPass::Id arbitrary_id(10, 14);
[email protected]b7cfc632013-04-10 04:44:49218 ResourceProvider::ResourceId arbitrary_resourceid1 = 55;
219 ResourceProvider::ResourceId arbitrary_resourceid2 = 47;
220 ResourceProvider::ResourceId arbitrary_resourceid3 = 23;
[email protected]0402b2382013-06-07 21:50:54221 ResourceProvider::ResourceId arbitrary_resourceid4 = 16;
[email protected]4934d362012-11-22 22:04:53222
[email protected]ae6b1a72013-06-25 18:49:29223 FilterOperations arbitrary_filters1;
224 arbitrary_filters1.Append(FilterOperation::CreateGrayscaleFilter(
[email protected]4934d362012-11-22 22:04:53225 arbitrary_float1));
226
[email protected]ae6b1a72013-06-25 18:49:29227 FilterOperations arbitrary_filters2;
228 arbitrary_filters2.Append(FilterOperation::CreateBrightnessFilter(
[email protected]4934d362012-11-22 22:04:53229 arbitrary_float2));
230
[email protected]1940c4e2012-12-04 05:08:15231 // TODO(danakj): filter is not serialized.
232 skia::RefPtr<SkImageFilter> arbitrary_filter;
233
[email protected]4934d362012-11-22 22:04:53234 scoped_ptr<SharedQuadState> shared_state1_in = SharedQuadState::Create();
235 shared_state1_in->SetAll(arbitrary_matrix,
[email protected]f902bf92013-03-04 18:33:27236 arbitrary_size1,
[email protected]4934d362012-11-22 22:04:53237 arbitrary_rect1,
238 arbitrary_rect2,
[email protected]4934d362012-11-22 22:04:53239 arbitrary_bool1,
240 arbitrary_float1);
241 scoped_ptr<SharedQuadState> shared_state1_cmp = shared_state1_in->Copy();
242
243 scoped_ptr<CheckerboardDrawQuad> checkerboard_in =
244 CheckerboardDrawQuad::Create();
245 checkerboard_in->SetAll(shared_state1_in.get(),
246 arbitrary_rect1,
247 arbitrary_rect2,
248 arbitrary_rect3,
249 arbitrary_bool1,
250 arbitrary_color);
251 scoped_ptr<DrawQuad> checkerboard_cmp = checkerboard_in->Copy(
252 checkerboard_in->shared_quad_state);
253
254 scoped_ptr<DebugBorderDrawQuad> debugborder_in =
255 DebugBorderDrawQuad::Create();
256 debugborder_in->SetAll(shared_state1_in.get(),
257 arbitrary_rect3,
258 arbitrary_rect1,
259 arbitrary_rect2,
260 arbitrary_bool1,
261 arbitrary_color,
262 arbitrary_int);
263 scoped_ptr<DrawQuad> debugborder_cmp = debugborder_in->Copy(
264 debugborder_in->shared_quad_state);
265
266 scoped_ptr<IOSurfaceDrawQuad> iosurface_in =
267 IOSurfaceDrawQuad::Create();
268 iosurface_in->SetAll(shared_state1_in.get(),
269 arbitrary_rect2,
270 arbitrary_rect3,
271 arbitrary_rect1,
272 arbitrary_bool1,
273 arbitrary_size1,
[email protected]b7cfc632013-04-10 04:44:49274 arbitrary_resourceid3,
[email protected]4934d362012-11-22 22:04:53275 arbitrary_orientation);
276 scoped_ptr<DrawQuad> iosurface_cmp = iosurface_in->Copy(
277 iosurface_in->shared_quad_state);
278
279 scoped_ptr<RenderPassDrawQuad> renderpass_in =
280 RenderPassDrawQuad::Create();
281 renderpass_in->SetAll(shared_state1_in.get(),
282 arbitrary_rect1,
283 arbitrary_rect2,
284 arbitrary_rect3,
285 arbitrary_bool1,
286 arbitrary_id,
287 arbitrary_bool2,
[email protected]b7cfc632013-04-10 04:44:49288 arbitrary_resourceid2,
[email protected]4934d362012-11-22 22:04:53289 arbitrary_rect1,
[email protected]20062042012-12-21 22:16:36290 arbitrary_rectf1,
291 arbitrary_filters1,
[email protected]10a30b12013-05-02 16:42:11292 arbitrary_filter, // TODO(piman): not serialized.
[email protected]20062042012-12-21 22:16:36293 arbitrary_filters2);
[email protected]4934d362012-11-22 22:04:53294 scoped_ptr<RenderPassDrawQuad> renderpass_cmp = renderpass_in->Copy(
295 renderpass_in->shared_quad_state, renderpass_in->render_pass_id);
296
297 scoped_ptr<SharedQuadState> shared_state2_in = SharedQuadState::Create();
298 shared_state2_in->SetAll(arbitrary_matrix,
[email protected]f902bf92013-03-04 18:33:27299 arbitrary_size2,
[email protected]4934d362012-11-22 22:04:53300 arbitrary_rect2,
301 arbitrary_rect3,
[email protected]4934d362012-11-22 22:04:53302 arbitrary_bool1,
303 arbitrary_float2);
304 scoped_ptr<SharedQuadState> shared_state2_cmp = shared_state2_in->Copy();
305
306 scoped_ptr<SharedQuadState> shared_state3_in = SharedQuadState::Create();
307 shared_state3_in->SetAll(arbitrary_matrix,
[email protected]f902bf92013-03-04 18:33:27308 arbitrary_size3,
[email protected]4934d362012-11-22 22:04:53309 arbitrary_rect3,
310 arbitrary_rect1,
[email protected]4934d362012-11-22 22:04:53311 arbitrary_bool1,
312 arbitrary_float3);
313 scoped_ptr<SharedQuadState> shared_state3_cmp = shared_state3_in->Copy();
314
315 scoped_ptr<SolidColorDrawQuad> solidcolor_in =
316 SolidColorDrawQuad::Create();
317 solidcolor_in->SetAll(shared_state1_in.get(),
318 arbitrary_rect3,
319 arbitrary_rect1,
320 arbitrary_rect2,
321 arbitrary_bool1,
[email protected]10a30b12013-05-02 16:42:11322 arbitrary_color,
323 arbitrary_bool2);
[email protected]4934d362012-11-22 22:04:53324 scoped_ptr<DrawQuad> solidcolor_cmp = solidcolor_in->Copy(
325 solidcolor_in->shared_quad_state);
326
327 scoped_ptr<StreamVideoDrawQuad> streamvideo_in =
328 StreamVideoDrawQuad::Create();
329 streamvideo_in->SetAll(shared_state1_in.get(),
330 arbitrary_rect2,
331 arbitrary_rect3,
332 arbitrary_rect1,
333 arbitrary_bool1,
[email protected]b7cfc632013-04-10 04:44:49334 arbitrary_resourceid2,
[email protected]4934d362012-11-22 22:04:53335 arbitrary_matrix);
336 scoped_ptr<DrawQuad> streamvideo_cmp = streamvideo_in->Copy(
337 streamvideo_in->shared_quad_state);
338
[email protected]61df9d82013-01-30 02:32:42339 scoped_ptr<TextureDrawQuad> texture_in = TextureDrawQuad::Create();
340 texture_in->SetAll(shared_state1_in.get(),
341 arbitrary_rect2,
342 arbitrary_rect3,
343 arbitrary_rect1,
344 arbitrary_bool1,
[email protected]b7cfc632013-04-10 04:44:49345 arbitrary_resourceid1,
[email protected]61df9d82013-01-30 02:32:42346 arbitrary_bool2,
347 arbitrary_pointf1,
348 arbitrary_pointf2,
349 arbitrary_float_array,
350 arbitrary_bool3);
351 scoped_ptr<DrawQuad> texture_cmp = texture_in->Copy(
352 texture_in->shared_quad_state);
353
354 scoped_ptr<TileDrawQuad> tile_in = TileDrawQuad::Create();
355 tile_in->SetAll(shared_state1_in.get(),
356 arbitrary_rect2,
357 arbitrary_rect3,
358 arbitrary_rect1,
359 arbitrary_bool1,
[email protected]b7cfc632013-04-10 04:44:49360 arbitrary_resourceid3,
[email protected]61df9d82013-01-30 02:32:42361 arbitrary_rectf1,
362 arbitrary_size1,
[email protected]f902bf92013-03-04 18:33:27363 arbitrary_bool2);
[email protected]61df9d82013-01-30 02:32:42364 scoped_ptr<DrawQuad> tile_cmp = tile_in->Copy(
365 tile_in->shared_quad_state);
366
[email protected]4934d362012-11-22 22:04:53367 scoped_ptr<YUVVideoDrawQuad> yuvvideo_in =
368 YUVVideoDrawQuad::Create();
369 yuvvideo_in->SetAll(shared_state1_in.get(),
370 arbitrary_rect1,
371 arbitrary_rect2,
372 arbitrary_rect3,
373 arbitrary_bool1,
374 arbitrary_sizef1,
[email protected]b7cfc632013-04-10 04:44:49375 arbitrary_resourceid1,
376 arbitrary_resourceid2,
[email protected]0402b2382013-06-07 21:50:54377 arbitrary_resourceid3,
378 arbitrary_resourceid4);
[email protected]4934d362012-11-22 22:04:53379 scoped_ptr<DrawQuad> yuvvideo_cmp = yuvvideo_in->Copy(
380 yuvvideo_in->shared_quad_state);
381
382 scoped_ptr<RenderPass> pass_in = RenderPass::Create();
383 pass_in->SetAll(arbitrary_id,
384 arbitrary_rect1,
385 arbitrary_rectf1,
386 arbitrary_matrix,
387 arbitrary_bool1,
[email protected]20062042012-12-21 22:16:36388 arbitrary_bool2);
[email protected]4934d362012-11-22 22:04:53389
[email protected]ead39c52013-01-09 07:22:45390 pass_in->shared_quad_state_list.push_back(shared_state1_in.Pass());
391 pass_in->quad_list.push_back(checkerboard_in.PassAs<DrawQuad>());
392 pass_in->quad_list.push_back(debugborder_in.PassAs<DrawQuad>());
393 pass_in->quad_list.push_back(iosurface_in.PassAs<DrawQuad>());
394 pass_in->quad_list.push_back(renderpass_in.PassAs<DrawQuad>());
395 pass_in->shared_quad_state_list.push_back(shared_state2_in.Pass());
396 pass_in->shared_quad_state_list.push_back(shared_state3_in.Pass());
397 pass_in->quad_list.push_back(solidcolor_in.PassAs<DrawQuad>());
398 pass_in->quad_list.push_back(streamvideo_in.PassAs<DrawQuad>());
[email protected]61df9d82013-01-30 02:32:42399 pass_in->quad_list.push_back(texture_in.PassAs<DrawQuad>());
400 pass_in->quad_list.push_back(tile_in.PassAs<DrawQuad>());
[email protected]ead39c52013-01-09 07:22:45401 pass_in->quad_list.push_back(yuvvideo_in.PassAs<DrawQuad>());
[email protected]4934d362012-11-22 22:04:53402
403 scoped_ptr<RenderPass> pass_cmp = RenderPass::Create();
404 pass_cmp->SetAll(arbitrary_id,
405 arbitrary_rect1,
406 arbitrary_rectf1,
407 arbitrary_matrix,
408 arbitrary_bool1,
[email protected]20062042012-12-21 22:16:36409 arbitrary_bool2);
[email protected]4934d362012-11-22 22:04:53410
[email protected]ead39c52013-01-09 07:22:45411 pass_cmp->shared_quad_state_list.push_back(shared_state1_cmp.Pass());
412 pass_cmp->quad_list.push_back(checkerboard_cmp.PassAs<DrawQuad>());
413 pass_cmp->quad_list.push_back(debugborder_cmp.PassAs<DrawQuad>());
414 pass_cmp->quad_list.push_back(iosurface_cmp.PassAs<DrawQuad>());
415 pass_cmp->quad_list.push_back(renderpass_cmp.PassAs<DrawQuad>());
416 pass_cmp->shared_quad_state_list.push_back(shared_state2_cmp.Pass());
417 pass_cmp->shared_quad_state_list.push_back(shared_state3_cmp.Pass());
418 pass_cmp->quad_list.push_back(solidcolor_cmp.PassAs<DrawQuad>());
419 pass_cmp->quad_list.push_back(streamvideo_cmp.PassAs<DrawQuad>());
[email protected]61df9d82013-01-30 02:32:42420 pass_cmp->quad_list.push_back(texture_cmp.PassAs<DrawQuad>());
421 pass_cmp->quad_list.push_back(tile_cmp.PassAs<DrawQuad>());
[email protected]ead39c52013-01-09 07:22:45422 pass_cmp->quad_list.push_back(yuvvideo_cmp.PassAs<DrawQuad>());
[email protected]4934d362012-11-22 22:04:53423
424 // Make sure the in and cmp RenderPasses match.
425 Compare(pass_cmp.get(), pass_in.get());
426 ASSERT_EQ(3u, pass_in->shared_quad_state_list.size());
[email protected]61df9d82013-01-30 02:32:42427 ASSERT_EQ(9u, pass_in->quad_list.size());
[email protected]4934d362012-11-22 22:04:53428 for (size_t i = 0; i < 3; ++i) {
429 Compare(pass_cmp->shared_quad_state_list[i],
430 pass_in->shared_quad_state_list[i]);
431 }
[email protected]61df9d82013-01-30 02:32:42432 for (size_t i = 0; i < pass_in->quad_list.size(); ++i)
[email protected]4934d362012-11-22 22:04:53433 Compare(pass_cmp->quad_list[i], pass_in->quad_list[i]);
[email protected]61df9d82013-01-30 02:32:42434 for (size_t i = 1; i < pass_in->quad_list.size(); ++i) {
[email protected]4934d362012-11-22 22:04:53435 bool same_shared_quad_state_cmp =
436 pass_cmp->quad_list[i]->shared_quad_state ==
437 pass_cmp->quad_list[i - 1]->shared_quad_state;
438 bool same_shared_quad_state_in =
439 pass_in->quad_list[i]->shared_quad_state ==
440 pass_in->quad_list[i - 1]->shared_quad_state;
441 EXPECT_EQ(same_shared_quad_state_cmp, same_shared_quad_state_in);
442 }
443
[email protected]bf189f62012-12-18 03:42:11444 DelegatedFrameData frame_in;
[email protected]ead39c52013-01-09 07:22:45445 frame_in.render_pass_list.push_back(pass_in.Pass());
[email protected]4934d362012-11-22 22:04:53446
[email protected]bf189f62012-12-18 03:42:11447 IPC::ParamTraits<DelegatedFrameData>::Write(&msg, frame_in);
[email protected]bca159072012-12-04 00:52:44448
[email protected]bf189f62012-12-18 03:42:11449 DelegatedFrameData frame_out;
[email protected]4934d362012-11-22 22:04:53450 PickleIterator iter(msg);
[email protected]bf189f62012-12-18 03:42:11451 EXPECT_TRUE(IPC::ParamTraits<DelegatedFrameData>::Read(&msg,
452 &iter, &frame_out));
[email protected]bca159072012-12-04 00:52:44453
[email protected]4934d362012-11-22 22:04:53454 // Make sure the out and cmp RenderPasses match.
[email protected]ead39c52013-01-09 07:22:45455 scoped_ptr<RenderPass> pass_out = frame_out.render_pass_list.take(
456 frame_out.render_pass_list.begin());
[email protected]4934d362012-11-22 22:04:53457 Compare(pass_cmp.get(), pass_out.get());
458 ASSERT_EQ(3u, pass_out->shared_quad_state_list.size());
[email protected]61df9d82013-01-30 02:32:42459 ASSERT_EQ(9u, pass_out->quad_list.size());
[email protected]4934d362012-11-22 22:04:53460 for (size_t i = 0; i < 3; ++i) {
461 Compare(pass_cmp->shared_quad_state_list[i],
462 pass_out->shared_quad_state_list[i]);
463 }
[email protected]61df9d82013-01-30 02:32:42464 for (size_t i = 0; i < pass_out->quad_list.size(); ++i)
[email protected]4934d362012-11-22 22:04:53465 Compare(pass_cmp->quad_list[i], pass_out->quad_list[i]);
[email protected]61df9d82013-01-30 02:32:42466 for (size_t i = 1; i < pass_out->quad_list.size(); ++i) {
[email protected]4934d362012-11-22 22:04:53467 bool same_shared_quad_state_cmp =
468 pass_cmp->quad_list[i]->shared_quad_state ==
469 pass_cmp->quad_list[i - 1]->shared_quad_state;
470 bool same_shared_quad_state_out =
471 pass_out->quad_list[i]->shared_quad_state ==
472 pass_out->quad_list[i - 1]->shared_quad_state;
473 EXPECT_EQ(same_shared_quad_state_cmp, same_shared_quad_state_out);
474 }
475}
[email protected]bca159072012-12-04 00:52:44476
477TEST_F(CCMessagesTest, Resources) {
478 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
479 gfx::Size arbitrary_size(757, 1281);
[email protected]09831f7f2013-02-27 03:32:15480 unsigned int arbitrary_uint1 = 71234838;
481 unsigned int arbitrary_uint2 = 53589793;
[email protected]bca159072012-12-04 00:52:44482
483 GLbyte arbitrary_mailbox1[64] = {
484 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
485 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
486 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
487 1, 2, 3, 4
488 };
489
490 GLbyte arbitrary_mailbox2[64] = {
491 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0,
492 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0,
493 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0,
494 0, 9, 8, 7
495 };
496
497 TransferableResource arbitrary_resource1;
498 arbitrary_resource1.id = 2178312;
[email protected]09831f7f2013-02-27 03:32:15499 arbitrary_resource1.sync_point = arbitrary_uint1;
[email protected]bca159072012-12-04 00:52:44500 arbitrary_resource1.format = 7;
[email protected]80189292013-02-28 01:59:36501 arbitrary_resource1.filter = 53;
[email protected]bca159072012-12-04 00:52:44502 arbitrary_resource1.size = gfx::Size(37189, 123123);
[email protected]1aca0092013-03-04 22:46:03503 arbitrary_resource1.mailbox.SetName(arbitrary_mailbox1);
[email protected]bca159072012-12-04 00:52:44504
505 TransferableResource arbitrary_resource2;
506 arbitrary_resource2.id = 789132;
[email protected]09831f7f2013-02-27 03:32:15507 arbitrary_resource1.sync_point = arbitrary_uint2;
[email protected]bca159072012-12-04 00:52:44508 arbitrary_resource2.format = 30;
[email protected]80189292013-02-28 01:59:36509 arbitrary_resource1.filter = 47;
[email protected]bca159072012-12-04 00:52:44510 arbitrary_resource2.size = gfx::Size(89123, 23789);
[email protected]1aca0092013-03-04 22:46:03511 arbitrary_resource2.mailbox.SetName(arbitrary_mailbox2);
[email protected]bca159072012-12-04 00:52:44512
[email protected]bf189f62012-12-18 03:42:11513 DelegatedFrameData frame_in;
[email protected]09831f7f2013-02-27 03:32:15514 frame_in.resource_list.push_back(arbitrary_resource1);
515 frame_in.resource_list.push_back(arbitrary_resource2);
[email protected]bca159072012-12-04 00:52:44516
[email protected]bf189f62012-12-18 03:42:11517 IPC::ParamTraits<DelegatedFrameData>::Write(&msg, frame_in);
[email protected]bca159072012-12-04 00:52:44518
[email protected]bf189f62012-12-18 03:42:11519 DelegatedFrameData frame_out;
[email protected]bca159072012-12-04 00:52:44520 PickleIterator iter(msg);
[email protected]bf189f62012-12-18 03:42:11521 EXPECT_TRUE(IPC::ParamTraits<DelegatedFrameData>::Read(&msg,
522 &iter, &frame_out));
[email protected]bca159072012-12-04 00:52:44523
[email protected]09831f7f2013-02-27 03:32:15524 ASSERT_EQ(2u, frame_out.resource_list.size());
525 Compare(arbitrary_resource1, frame_out.resource_list[0]);
526 Compare(arbitrary_resource2, frame_out.resource_list[1]);
[email protected]bca159072012-12-04 00:52:44527}
528
529} // namespace
530} // namespace content