blob: 465441982b781d00c828e929ba8ecf81dcd5bdae [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]a1765672013-08-12 23:45:029#include "base/command_line.h"
[email protected]7f0d825f2013-03-18 07:24:3010#include "cc/output/compositor_frame.h"
[email protected]a1765672013-08-12 23:45:0211#include "content/public/common/content_switches.h"
[email protected]4934d362012-11-22 22:04:5312#include "ipc/ipc_message.h"
13#include "testing/gtest/include/gtest/gtest.h"
[email protected]645a47f22013-09-26 05:42:3214#include "third_party/khronos/GLES2/gl2ext.h"
[email protected]a1765672013-08-12 23:45:0215#include "third_party/skia/include/effects/SkBlurImageFilter.h"
[email protected]4934d362012-11-22 22:04:5316
17using cc::CheckerboardDrawQuad;
[email protected]bf189f62012-12-18 03:42:1118using cc::DelegatedFrameData;
[email protected]4934d362012-11-22 22:04:5319using cc::DebugBorderDrawQuad;
20using cc::DrawQuad;
[email protected]ae6b1a72013-06-25 18:49:2921using cc::FilterOperation;
22using cc::FilterOperations;
[email protected]4934d362012-11-22 22:04:5323using cc::IOSurfaceDrawQuad;
[email protected]9ee4d3a2013-03-27 17:43:1624using cc::PictureDrawQuad;
[email protected]4934d362012-11-22 22:04:5325using cc::RenderPass;
26using cc::RenderPassDrawQuad;
27using cc::ResourceProvider;
28using cc::SharedQuadState;
29using cc::SolidColorDrawQuad;
30using cc::TextureDrawQuad;
31using cc::TileDrawQuad;
[email protected]bca159072012-12-04 00:52:4432using cc::TransferableResource;
[email protected]4934d362012-11-22 22:04:5333using cc::StreamVideoDrawQuad;
34using cc::VideoLayerImpl;
35using cc::YUVVideoDrawQuad;
[email protected]c8686a02012-11-27 08:29:0036using gfx::Transform;
[email protected]4934d362012-11-22 22:04:5337
[email protected]bca159072012-12-04 00:52:4438namespace content {
39namespace {
40
[email protected]4934d362012-11-22 22:04:5341class CCMessagesTest : public testing::Test {
42 protected:
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);
49 EXPECT_EQ(a->has_occlusion_from_outside_target_surface,
50 b->has_occlusion_from_outside_target_surface);
[email protected]4934d362012-11-22 22:04:5351 }
52
53 void Compare(const SharedQuadState* a, const SharedQuadState* b) {
54 EXPECT_EQ(a->content_to_target_transform, b->content_to_target_transform);
[email protected]f902bf92013-03-04 18:33:2755 EXPECT_EQ(a->content_bounds, b->content_bounds);
[email protected]4934d362012-11-22 22:04:5356 EXPECT_EQ(a->visible_content_rect, b->visible_content_rect);
[email protected]4934d362012-11-22 22:04:5357 EXPECT_EQ(a->clip_rect, b->clip_rect);
58 EXPECT_EQ(a->is_clipped, b->is_clipped);
59 EXPECT_EQ(a->opacity, b->opacity);
60 }
61
62 void Compare(const DrawQuad* a, const DrawQuad* b) {
63 ASSERT_NE(DrawQuad::INVALID, a->material);
64 ASSERT_EQ(a->material, b->material);
65 EXPECT_EQ(a->rect.ToString(), b->rect.ToString());
66 EXPECT_EQ(a->opaque_rect.ToString(), b->opaque_rect.ToString());
67 EXPECT_EQ(a->visible_rect.ToString(), b->visible_rect.ToString());
68 EXPECT_EQ(a->needs_blending, b->needs_blending);
69
70 Compare(a->shared_quad_state, b->shared_quad_state);
71
72 switch (a->material) {
73 case DrawQuad::CHECKERBOARD:
74 Compare(CheckerboardDrawQuad::MaterialCast(a),
75 CheckerboardDrawQuad::MaterialCast(b));
76 break;
77 case DrawQuad::DEBUG_BORDER:
78 Compare(DebugBorderDrawQuad::MaterialCast(a),
79 DebugBorderDrawQuad::MaterialCast(b));
80 break;
81 case DrawQuad::IO_SURFACE_CONTENT:
82 Compare(IOSurfaceDrawQuad::MaterialCast(a),
83 IOSurfaceDrawQuad::MaterialCast(b));
84 break;
[email protected]9ee4d3a2013-03-27 17:43:1685 case DrawQuad::PICTURE_CONTENT:
86 Compare(PictureDrawQuad::MaterialCast(a),
87 PictureDrawQuad::MaterialCast(b));
88 break;
[email protected]4934d362012-11-22 22:04:5389 case DrawQuad::RENDER_PASS:
90 Compare(RenderPassDrawQuad::MaterialCast(a),
91 RenderPassDrawQuad::MaterialCast(b));
92 break;
93 case DrawQuad::TEXTURE_CONTENT:
94 Compare(TextureDrawQuad::MaterialCast(a),
95 TextureDrawQuad::MaterialCast(b));
96 break;
97 case DrawQuad::TILED_CONTENT:
98 Compare(TileDrawQuad::MaterialCast(a),
99 TileDrawQuad::MaterialCast(b));
100 break;
101 case DrawQuad::SOLID_COLOR:
102 Compare(SolidColorDrawQuad::MaterialCast(a),
103 SolidColorDrawQuad::MaterialCast(b));
104 break;
105 case DrawQuad::STREAM_VIDEO_CONTENT:
106 Compare(StreamVideoDrawQuad::MaterialCast(a),
107 StreamVideoDrawQuad::MaterialCast(b));
108 break;
109 case DrawQuad::YUV_VIDEO_CONTENT:
110 Compare(YUVVideoDrawQuad::MaterialCast(a),
111 YUVVideoDrawQuad::MaterialCast(b));
112 break;
113 case DrawQuad::INVALID:
114 break;
115 }
116 }
117
118 void Compare(const CheckerboardDrawQuad* a, const CheckerboardDrawQuad* b) {
119 EXPECT_EQ(a->color, b->color);
120 }
121
122 void Compare(const DebugBorderDrawQuad* a, const DebugBorderDrawQuad* b) {
123 EXPECT_EQ(a->color, b->color);
124 EXPECT_EQ(a->width, b->width);
125 }
126
127 void Compare(const IOSurfaceDrawQuad* a, const IOSurfaceDrawQuad* b) {
128 EXPECT_EQ(a->io_surface_size.ToString(), b->io_surface_size.ToString());
[email protected]b7cfc632013-04-10 04:44:49129 EXPECT_EQ(a->io_surface_resource_id, b->io_surface_resource_id);
[email protected]4934d362012-11-22 22:04:53130 EXPECT_EQ(a->orientation, b->orientation);
131 }
132
133 void Compare(const RenderPassDrawQuad* a, const RenderPassDrawQuad* b) {
[email protected]82f93fb2013-04-17 21:42:06134 EXPECT_EQ(a->render_pass_id, b->render_pass_id);
[email protected]4934d362012-11-22 22:04:53135 EXPECT_EQ(a->is_replica, b->is_replica);
136 EXPECT_EQ(a->mask_resource_id, b->mask_resource_id);
137 EXPECT_EQ(a->contents_changed_since_last_frame,
138 b->contents_changed_since_last_frame);
[email protected]458af1e2012-12-13 05:12:18139 EXPECT_EQ(a->mask_uv_rect.ToString(), b->mask_uv_rect.ToString());
[email protected]1dc7943e2013-09-26 04:41:48140 EXPECT_EQ(a->filters.size(), b->filters.size());
141 for (size_t i = 0; i < a->filters.size(); ++i) {
142 if (a->filters.at(i).type() != cc::FilterOperation::REFERENCE) {
143 EXPECT_EQ(a->filters.at(i), b->filters.at(i));
144 } else {
145 EXPECT_EQ(b->filters.at(i).type(), cc::FilterOperation::REFERENCE);
146 EXPECT_EQ(a->filters.at(i).image_filter()->countInputs(),
147 b->filters.at(i).image_filter()->countInputs());
148 }
149 }
[email protected]20062042012-12-21 22:16:36150 EXPECT_EQ(a->background_filters, b->background_filters);
[email protected]4934d362012-11-22 22:04:53151 }
152
153 void Compare(const SolidColorDrawQuad* a, const SolidColorDrawQuad* b) {
154 EXPECT_EQ(a->color, b->color);
[email protected]10a30b12013-05-02 16:42:11155 EXPECT_EQ(a->force_anti_aliasing_off, b->force_anti_aliasing_off);
[email protected]4934d362012-11-22 22:04:53156 }
157
158 void Compare(const StreamVideoDrawQuad* a, const StreamVideoDrawQuad* b) {
[email protected]b7cfc632013-04-10 04:44:49159 EXPECT_EQ(a->resource_id, b->resource_id);
[email protected]4934d362012-11-22 22:04:53160 EXPECT_EQ(a->matrix, b->matrix);
161 }
162
163 void Compare(const TextureDrawQuad* a, const TextureDrawQuad* b) {
164 EXPECT_EQ(a->resource_id, b->resource_id);
165 EXPECT_EQ(a->premultiplied_alpha, b->premultiplied_alpha);
[email protected]1fd555b2013-01-18 00:13:21166 EXPECT_EQ(a->uv_top_left, b->uv_top_left);
167 EXPECT_EQ(a->uv_bottom_right, b->uv_bottom_right);
[email protected]d18b4d62013-07-12 05:33:49168 EXPECT_EQ(a->background_color, b->background_color);
[email protected]61df9d82013-01-30 02:32:42169 EXPECT_EQ(a->vertex_opacity[0], b->vertex_opacity[0]);
170 EXPECT_EQ(a->vertex_opacity[1], b->vertex_opacity[1]);
171 EXPECT_EQ(a->vertex_opacity[2], b->vertex_opacity[2]);
172 EXPECT_EQ(a->vertex_opacity[3], b->vertex_opacity[3]);
[email protected]4934d362012-11-22 22:04:53173 EXPECT_EQ(a->flipped, b->flipped);
174 }
175
176 void Compare(const TileDrawQuad* a, const TileDrawQuad* b) {
177 EXPECT_EQ(a->resource_id, b->resource_id);
178 EXPECT_EQ(a->tex_coord_rect, b->tex_coord_rect);
179 EXPECT_EQ(a->texture_size, b->texture_size);
180 EXPECT_EQ(a->swizzle_contents, b->swizzle_contents);
[email protected]4934d362012-11-22 22:04:53181 }
182
183 void Compare(const YUVVideoDrawQuad* a, const YUVVideoDrawQuad* b) {
184 EXPECT_EQ(a->tex_scale, b->tex_scale);
[email protected]b7cfc632013-04-10 04:44:49185 EXPECT_EQ(a->y_plane_resource_id, b->y_plane_resource_id);
186 EXPECT_EQ(a->u_plane_resource_id, b->u_plane_resource_id);
187 EXPECT_EQ(a->v_plane_resource_id, b->v_plane_resource_id);
[email protected]0402b2382013-06-07 21:50:54188 EXPECT_EQ(a->a_plane_resource_id, b->a_plane_resource_id);
[email protected]4934d362012-11-22 22:04:53189 }
[email protected]bca159072012-12-04 00:52:44190
191 void Compare(const TransferableResource& a, const TransferableResource& b) {
192 EXPECT_EQ(a.id, b.id);
[email protected]09831f7f2013-02-27 03:32:15193 EXPECT_EQ(a.sync_point, b.sync_point);
[email protected]bca159072012-12-04 00:52:44194 EXPECT_EQ(a.format, b.format);
[email protected]645a47f22013-09-26 05:42:32195 EXPECT_EQ(a.target, b.target);
[email protected]80189292013-02-28 01:59:36196 EXPECT_EQ(a.filter, b.filter);
[email protected]bca159072012-12-04 00:52:44197 EXPECT_EQ(a.size.ToString(), b.size.ToString());
198 for (size_t i = 0; i < arraysize(a.mailbox.name); ++i)
199 EXPECT_EQ(a.mailbox.name[i], b.mailbox.name[i]);
200 }
[email protected]4934d362012-11-22 22:04:53201};
202
203TEST_F(CCMessagesTest, AllQuads) {
[email protected]a1765672013-08-12 23:45:02204 CommandLine& command_line = *CommandLine::ForCurrentProcess();
205 if (!command_line.HasSwitch(switches::kAllowFiltersOverIPC))
206 command_line.AppendSwitch(switches::kAllowFiltersOverIPC);
207
[email protected]4934d362012-11-22 22:04:53208 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
209
[email protected]c8686a02012-11-27 08:29:00210 Transform arbitrary_matrix;
211 arbitrary_matrix.Scale(3, 3);
212 arbitrary_matrix.Translate(-5, 20);
213 arbitrary_matrix.Rotate(15);
[email protected]4934d362012-11-22 22:04:53214 gfx::Rect arbitrary_rect1(-5, 9, 3, 15);
215 gfx::Rect arbitrary_rect2(40, 23, 11, 7);
216 gfx::Rect arbitrary_rect3(7, -53, 22, 19);
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);
[email protected]61df9d82013-01-30 02:32:42222 gfx::PointF arbitrary_pointf1(31.4f, 15.9f);
223 gfx::PointF arbitrary_pointf2(26.5f, -35.8f);
[email protected]4934d362012-11-22 22:04:53224 float arbitrary_float1 = 0.7f;
225 float arbitrary_float2 = 0.3f;
226 float arbitrary_float3 = 0.9f;
[email protected]61df9d82013-01-30 02:32:42227 float arbitrary_float_array[4] = {3.5f, 6.2f, 9.3f, 12.3f};
[email protected]4934d362012-11-22 22:04:53228 bool arbitrary_bool1 = true;
229 bool arbitrary_bool2 = false;
[email protected]61df9d82013-01-30 02:32:42230 bool arbitrary_bool3 = true;
[email protected]4934d362012-11-22 22:04:53231 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);
[email protected]b7cfc632013-04-10 04:44:49236 ResourceProvider::ResourceId arbitrary_resourceid1 = 55;
237 ResourceProvider::ResourceId arbitrary_resourceid2 = 47;
238 ResourceProvider::ResourceId arbitrary_resourceid3 = 23;
[email protected]0402b2382013-06-07 21:50:54239 ResourceProvider::ResourceId arbitrary_resourceid4 = 16;
[email protected]a1765672013-08-12 23:45:02240 SkScalar arbitrary_sigma = SkFloatToScalar(2.0f);
[email protected]4934d362012-11-22 22:04:53241
[email protected]ae6b1a72013-06-25 18:49:29242 FilterOperations arbitrary_filters1;
243 arbitrary_filters1.Append(FilterOperation::CreateGrayscaleFilter(
[email protected]4934d362012-11-22 22:04:53244 arbitrary_float1));
[email protected]1dc7943e2013-09-26 04:41:48245 skia::RefPtr<SkImageFilter> arbitrary_filter = skia::AdoptRef(
246 new SkBlurImageFilter(arbitrary_sigma, arbitrary_sigma));
247 arbitrary_filters1.Append(
248 cc::FilterOperation::CreateReferenceFilter(arbitrary_filter));
[email protected]4934d362012-11-22 22:04:53249
[email protected]ae6b1a72013-06-25 18:49:29250 FilterOperations arbitrary_filters2;
251 arbitrary_filters2.Append(FilterOperation::CreateBrightnessFilter(
[email protected]4934d362012-11-22 22:04:53252 arbitrary_float2));
253
254 scoped_ptr<SharedQuadState> shared_state1_in = SharedQuadState::Create();
255 shared_state1_in->SetAll(arbitrary_matrix,
[email protected]f902bf92013-03-04 18:33:27256 arbitrary_size1,
[email protected]4934d362012-11-22 22:04:53257 arbitrary_rect1,
258 arbitrary_rect2,
[email protected]4934d362012-11-22 22:04:53259 arbitrary_bool1,
260 arbitrary_float1);
261 scoped_ptr<SharedQuadState> shared_state1_cmp = shared_state1_in->Copy();
262
263 scoped_ptr<CheckerboardDrawQuad> checkerboard_in =
264 CheckerboardDrawQuad::Create();
265 checkerboard_in->SetAll(shared_state1_in.get(),
266 arbitrary_rect1,
267 arbitrary_rect2,
268 arbitrary_rect3,
269 arbitrary_bool1,
270 arbitrary_color);
271 scoped_ptr<DrawQuad> checkerboard_cmp = checkerboard_in->Copy(
272 checkerboard_in->shared_quad_state);
273
274 scoped_ptr<DebugBorderDrawQuad> debugborder_in =
275 DebugBorderDrawQuad::Create();
276 debugborder_in->SetAll(shared_state1_in.get(),
277 arbitrary_rect3,
278 arbitrary_rect1,
279 arbitrary_rect2,
280 arbitrary_bool1,
281 arbitrary_color,
282 arbitrary_int);
283 scoped_ptr<DrawQuad> debugborder_cmp = debugborder_in->Copy(
284 debugborder_in->shared_quad_state);
285
286 scoped_ptr<IOSurfaceDrawQuad> iosurface_in =
287 IOSurfaceDrawQuad::Create();
288 iosurface_in->SetAll(shared_state1_in.get(),
289 arbitrary_rect2,
290 arbitrary_rect3,
291 arbitrary_rect1,
292 arbitrary_bool1,
293 arbitrary_size1,
[email protected]b7cfc632013-04-10 04:44:49294 arbitrary_resourceid3,
[email protected]4934d362012-11-22 22:04:53295 arbitrary_orientation);
296 scoped_ptr<DrawQuad> iosurface_cmp = iosurface_in->Copy(
297 iosurface_in->shared_quad_state);
298
299 scoped_ptr<RenderPassDrawQuad> renderpass_in =
300 RenderPassDrawQuad::Create();
301 renderpass_in->SetAll(shared_state1_in.get(),
302 arbitrary_rect1,
303 arbitrary_rect2,
304 arbitrary_rect3,
305 arbitrary_bool1,
306 arbitrary_id,
307 arbitrary_bool2,
[email protected]b7cfc632013-04-10 04:44:49308 arbitrary_resourceid2,
[email protected]4934d362012-11-22 22:04:53309 arbitrary_rect1,
[email protected]20062042012-12-21 22:16:36310 arbitrary_rectf1,
311 arbitrary_filters1,
[email protected]20062042012-12-21 22:16:36312 arbitrary_filters2);
[email protected]4934d362012-11-22 22:04:53313 scoped_ptr<RenderPassDrawQuad> renderpass_cmp = renderpass_in->Copy(
314 renderpass_in->shared_quad_state, renderpass_in->render_pass_id);
315
316 scoped_ptr<SharedQuadState> shared_state2_in = SharedQuadState::Create();
317 shared_state2_in->SetAll(arbitrary_matrix,
[email protected]f902bf92013-03-04 18:33:27318 arbitrary_size2,
[email protected]4934d362012-11-22 22:04:53319 arbitrary_rect2,
320 arbitrary_rect3,
[email protected]4934d362012-11-22 22:04:53321 arbitrary_bool1,
322 arbitrary_float2);
323 scoped_ptr<SharedQuadState> shared_state2_cmp = shared_state2_in->Copy();
324
325 scoped_ptr<SharedQuadState> shared_state3_in = SharedQuadState::Create();
326 shared_state3_in->SetAll(arbitrary_matrix,
[email protected]f902bf92013-03-04 18:33:27327 arbitrary_size3,
[email protected]4934d362012-11-22 22:04:53328 arbitrary_rect3,
329 arbitrary_rect1,
[email protected]4934d362012-11-22 22:04:53330 arbitrary_bool1,
331 arbitrary_float3);
332 scoped_ptr<SharedQuadState> shared_state3_cmp = shared_state3_in->Copy();
333
334 scoped_ptr<SolidColorDrawQuad> solidcolor_in =
335 SolidColorDrawQuad::Create();
336 solidcolor_in->SetAll(shared_state1_in.get(),
337 arbitrary_rect3,
338 arbitrary_rect1,
339 arbitrary_rect2,
340 arbitrary_bool1,
[email protected]10a30b12013-05-02 16:42:11341 arbitrary_color,
342 arbitrary_bool2);
[email protected]4934d362012-11-22 22:04:53343 scoped_ptr<DrawQuad> solidcolor_cmp = solidcolor_in->Copy(
344 solidcolor_in->shared_quad_state);
345
346 scoped_ptr<StreamVideoDrawQuad> streamvideo_in =
347 StreamVideoDrawQuad::Create();
348 streamvideo_in->SetAll(shared_state1_in.get(),
349 arbitrary_rect2,
350 arbitrary_rect3,
351 arbitrary_rect1,
352 arbitrary_bool1,
[email protected]b7cfc632013-04-10 04:44:49353 arbitrary_resourceid2,
[email protected]4934d362012-11-22 22:04:53354 arbitrary_matrix);
355 scoped_ptr<DrawQuad> streamvideo_cmp = streamvideo_in->Copy(
356 streamvideo_in->shared_quad_state);
357
[email protected]61df9d82013-01-30 02:32:42358 scoped_ptr<TextureDrawQuad> texture_in = TextureDrawQuad::Create();
359 texture_in->SetAll(shared_state1_in.get(),
360 arbitrary_rect2,
361 arbitrary_rect3,
362 arbitrary_rect1,
363 arbitrary_bool1,
[email protected]b7cfc632013-04-10 04:44:49364 arbitrary_resourceid1,
[email protected]61df9d82013-01-30 02:32:42365 arbitrary_bool2,
366 arbitrary_pointf1,
367 arbitrary_pointf2,
[email protected]d18b4d62013-07-12 05:33:49368 arbitrary_color,
[email protected]61df9d82013-01-30 02:32:42369 arbitrary_float_array,
370 arbitrary_bool3);
371 scoped_ptr<DrawQuad> texture_cmp = texture_in->Copy(
372 texture_in->shared_quad_state);
373
374 scoped_ptr<TileDrawQuad> tile_in = TileDrawQuad::Create();
375 tile_in->SetAll(shared_state1_in.get(),
376 arbitrary_rect2,
377 arbitrary_rect3,
378 arbitrary_rect1,
379 arbitrary_bool1,
[email protected]b7cfc632013-04-10 04:44:49380 arbitrary_resourceid3,
[email protected]61df9d82013-01-30 02:32:42381 arbitrary_rectf1,
382 arbitrary_size1,
[email protected]f902bf92013-03-04 18:33:27383 arbitrary_bool2);
[email protected]61df9d82013-01-30 02:32:42384 scoped_ptr<DrawQuad> tile_cmp = tile_in->Copy(
385 tile_in->shared_quad_state);
386
[email protected]4934d362012-11-22 22:04:53387 scoped_ptr<YUVVideoDrawQuad> yuvvideo_in =
388 YUVVideoDrawQuad::Create();
389 yuvvideo_in->SetAll(shared_state1_in.get(),
390 arbitrary_rect1,
391 arbitrary_rect2,
392 arbitrary_rect3,
393 arbitrary_bool1,
394 arbitrary_sizef1,
[email protected]b7cfc632013-04-10 04:44:49395 arbitrary_resourceid1,
396 arbitrary_resourceid2,
[email protected]0402b2382013-06-07 21:50:54397 arbitrary_resourceid3,
398 arbitrary_resourceid4);
[email protected]4934d362012-11-22 22:04:53399 scoped_ptr<DrawQuad> yuvvideo_cmp = yuvvideo_in->Copy(
400 yuvvideo_in->shared_quad_state);
401
402 scoped_ptr<RenderPass> pass_in = RenderPass::Create();
403 pass_in->SetAll(arbitrary_id,
404 arbitrary_rect1,
405 arbitrary_rectf1,
406 arbitrary_matrix,
407 arbitrary_bool1,
[email protected]20062042012-12-21 22:16:36408 arbitrary_bool2);
[email protected]4934d362012-11-22 22:04:53409
[email protected]ead39c52013-01-09 07:22:45410 pass_in->shared_quad_state_list.push_back(shared_state1_in.Pass());
411 pass_in->quad_list.push_back(checkerboard_in.PassAs<DrawQuad>());
412 pass_in->quad_list.push_back(debugborder_in.PassAs<DrawQuad>());
413 pass_in->quad_list.push_back(iosurface_in.PassAs<DrawQuad>());
414 pass_in->quad_list.push_back(renderpass_in.PassAs<DrawQuad>());
415 pass_in->shared_quad_state_list.push_back(shared_state2_in.Pass());
416 pass_in->shared_quad_state_list.push_back(shared_state3_in.Pass());
417 pass_in->quad_list.push_back(solidcolor_in.PassAs<DrawQuad>());
418 pass_in->quad_list.push_back(streamvideo_in.PassAs<DrawQuad>());
[email protected]61df9d82013-01-30 02:32:42419 pass_in->quad_list.push_back(texture_in.PassAs<DrawQuad>());
420 pass_in->quad_list.push_back(tile_in.PassAs<DrawQuad>());
[email protected]ead39c52013-01-09 07:22:45421 pass_in->quad_list.push_back(yuvvideo_in.PassAs<DrawQuad>());
[email protected]4934d362012-11-22 22:04:53422
423 scoped_ptr<RenderPass> pass_cmp = RenderPass::Create();
424 pass_cmp->SetAll(arbitrary_id,
425 arbitrary_rect1,
426 arbitrary_rectf1,
427 arbitrary_matrix,
428 arbitrary_bool1,
[email protected]20062042012-12-21 22:16:36429 arbitrary_bool2);
[email protected]4934d362012-11-22 22:04:53430
[email protected]ead39c52013-01-09 07:22:45431 pass_cmp->shared_quad_state_list.push_back(shared_state1_cmp.Pass());
432 pass_cmp->quad_list.push_back(checkerboard_cmp.PassAs<DrawQuad>());
433 pass_cmp->quad_list.push_back(debugborder_cmp.PassAs<DrawQuad>());
434 pass_cmp->quad_list.push_back(iosurface_cmp.PassAs<DrawQuad>());
435 pass_cmp->quad_list.push_back(renderpass_cmp.PassAs<DrawQuad>());
436 pass_cmp->shared_quad_state_list.push_back(shared_state2_cmp.Pass());
437 pass_cmp->shared_quad_state_list.push_back(shared_state3_cmp.Pass());
438 pass_cmp->quad_list.push_back(solidcolor_cmp.PassAs<DrawQuad>());
439 pass_cmp->quad_list.push_back(streamvideo_cmp.PassAs<DrawQuad>());
[email protected]61df9d82013-01-30 02:32:42440 pass_cmp->quad_list.push_back(texture_cmp.PassAs<DrawQuad>());
441 pass_cmp->quad_list.push_back(tile_cmp.PassAs<DrawQuad>());
[email protected]ead39c52013-01-09 07:22:45442 pass_cmp->quad_list.push_back(yuvvideo_cmp.PassAs<DrawQuad>());
[email protected]4934d362012-11-22 22:04:53443
444 // Make sure the in and cmp RenderPasses match.
445 Compare(pass_cmp.get(), pass_in.get());
446 ASSERT_EQ(3u, pass_in->shared_quad_state_list.size());
[email protected]61df9d82013-01-30 02:32:42447 ASSERT_EQ(9u, pass_in->quad_list.size());
[email protected]4934d362012-11-22 22:04:53448 for (size_t i = 0; i < 3; ++i) {
449 Compare(pass_cmp->shared_quad_state_list[i],
450 pass_in->shared_quad_state_list[i]);
451 }
[email protected]61df9d82013-01-30 02:32:42452 for (size_t i = 0; i < pass_in->quad_list.size(); ++i)
[email protected]4934d362012-11-22 22:04:53453 Compare(pass_cmp->quad_list[i], pass_in->quad_list[i]);
[email protected]61df9d82013-01-30 02:32:42454 for (size_t i = 1; i < pass_in->quad_list.size(); ++i) {
[email protected]4934d362012-11-22 22:04:53455 bool same_shared_quad_state_cmp =
456 pass_cmp->quad_list[i]->shared_quad_state ==
457 pass_cmp->quad_list[i - 1]->shared_quad_state;
458 bool same_shared_quad_state_in =
459 pass_in->quad_list[i]->shared_quad_state ==
460 pass_in->quad_list[i - 1]->shared_quad_state;
461 EXPECT_EQ(same_shared_quad_state_cmp, same_shared_quad_state_in);
462 }
463
[email protected]bf189f62012-12-18 03:42:11464 DelegatedFrameData frame_in;
[email protected]ead39c52013-01-09 07:22:45465 frame_in.render_pass_list.push_back(pass_in.Pass());
[email protected]4934d362012-11-22 22:04:53466
[email protected]bf189f62012-12-18 03:42:11467 IPC::ParamTraits<DelegatedFrameData>::Write(&msg, frame_in);
[email protected]bca159072012-12-04 00:52:44468
[email protected]bf189f62012-12-18 03:42:11469 DelegatedFrameData frame_out;
[email protected]4934d362012-11-22 22:04:53470 PickleIterator iter(msg);
[email protected]bf189f62012-12-18 03:42:11471 EXPECT_TRUE(IPC::ParamTraits<DelegatedFrameData>::Read(&msg,
472 &iter, &frame_out));
[email protected]bca159072012-12-04 00:52:44473
[email protected]4934d362012-11-22 22:04:53474 // Make sure the out and cmp RenderPasses match.
[email protected]ead39c52013-01-09 07:22:45475 scoped_ptr<RenderPass> pass_out = frame_out.render_pass_list.take(
476 frame_out.render_pass_list.begin());
[email protected]4934d362012-11-22 22:04:53477 Compare(pass_cmp.get(), pass_out.get());
478 ASSERT_EQ(3u, pass_out->shared_quad_state_list.size());
[email protected]61df9d82013-01-30 02:32:42479 ASSERT_EQ(9u, pass_out->quad_list.size());
[email protected]4934d362012-11-22 22:04:53480 for (size_t i = 0; i < 3; ++i) {
481 Compare(pass_cmp->shared_quad_state_list[i],
482 pass_out->shared_quad_state_list[i]);
483 }
[email protected]61df9d82013-01-30 02:32:42484 for (size_t i = 0; i < pass_out->quad_list.size(); ++i)
[email protected]4934d362012-11-22 22:04:53485 Compare(pass_cmp->quad_list[i], pass_out->quad_list[i]);
[email protected]61df9d82013-01-30 02:32:42486 for (size_t i = 1; i < pass_out->quad_list.size(); ++i) {
[email protected]4934d362012-11-22 22:04:53487 bool same_shared_quad_state_cmp =
488 pass_cmp->quad_list[i]->shared_quad_state ==
489 pass_cmp->quad_list[i - 1]->shared_quad_state;
490 bool same_shared_quad_state_out =
491 pass_out->quad_list[i]->shared_quad_state ==
492 pass_out->quad_list[i - 1]->shared_quad_state;
493 EXPECT_EQ(same_shared_quad_state_cmp, same_shared_quad_state_out);
494 }
495}
[email protected]bca159072012-12-04 00:52:44496
497TEST_F(CCMessagesTest, Resources) {
498 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
499 gfx::Size arbitrary_size(757, 1281);
[email protected]09831f7f2013-02-27 03:32:15500 unsigned int arbitrary_uint1 = 71234838;
501 unsigned int arbitrary_uint2 = 53589793;
[email protected]bca159072012-12-04 00:52:44502
503 GLbyte arbitrary_mailbox1[64] = {
504 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
505 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
506 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
507 1, 2, 3, 4
508 };
509
510 GLbyte arbitrary_mailbox2[64] = {
511 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0,
512 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0,
513 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0,
514 0, 9, 8, 7
515 };
516
517 TransferableResource arbitrary_resource1;
518 arbitrary_resource1.id = 2178312;
[email protected]09831f7f2013-02-27 03:32:15519 arbitrary_resource1.sync_point = arbitrary_uint1;
[email protected]27a41fe2013-09-19 05:05:14520 arbitrary_resource1.format = cc::RGBA_8888;
[email protected]645a47f22013-09-26 05:42:32521 arbitrary_resource1.target = GL_TEXTURE_2D;
[email protected]80189292013-02-28 01:59:36522 arbitrary_resource1.filter = 53;
[email protected]bca159072012-12-04 00:52:44523 arbitrary_resource1.size = gfx::Size(37189, 123123);
[email protected]1aca0092013-03-04 22:46:03524 arbitrary_resource1.mailbox.SetName(arbitrary_mailbox1);
[email protected]bca159072012-12-04 00:52:44525
526 TransferableResource arbitrary_resource2;
527 arbitrary_resource2.id = 789132;
[email protected]645a47f22013-09-26 05:42:32528 arbitrary_resource2.sync_point = arbitrary_uint2;
[email protected]27a41fe2013-09-19 05:05:14529 arbitrary_resource2.format = cc::RGBA_4444;
[email protected]645a47f22013-09-26 05:42:32530 arbitrary_resource2.target = GL_TEXTURE_EXTERNAL_OES;
531 arbitrary_resource2.filter = 47;
[email protected]bca159072012-12-04 00:52:44532 arbitrary_resource2.size = gfx::Size(89123, 23789);
[email protected]1aca0092013-03-04 22:46:03533 arbitrary_resource2.mailbox.SetName(arbitrary_mailbox2);
[email protected]bca159072012-12-04 00:52:44534
[email protected]bf189f62012-12-18 03:42:11535 DelegatedFrameData frame_in;
[email protected]09831f7f2013-02-27 03:32:15536 frame_in.resource_list.push_back(arbitrary_resource1);
537 frame_in.resource_list.push_back(arbitrary_resource2);
[email protected]bca159072012-12-04 00:52:44538
[email protected]bf189f62012-12-18 03:42:11539 IPC::ParamTraits<DelegatedFrameData>::Write(&msg, frame_in);
[email protected]bca159072012-12-04 00:52:44540
[email protected]bf189f62012-12-18 03:42:11541 DelegatedFrameData frame_out;
[email protected]bca159072012-12-04 00:52:44542 PickleIterator iter(msg);
[email protected]bf189f62012-12-18 03:42:11543 EXPECT_TRUE(IPC::ParamTraits<DelegatedFrameData>::Read(&msg,
544 &iter, &frame_out));
[email protected]bca159072012-12-04 00:52:44545
[email protected]09831f7f2013-02-27 03:32:15546 ASSERT_EQ(2u, frame_out.resource_list.size());
547 Compare(arbitrary_resource1, frame_out.resource_list[0]);
548 Compare(arbitrary_resource2, frame_out.resource_list[1]);
[email protected]bca159072012-12-04 00:52:44549}
550
551} // namespace
552} // namespace content