blob: bd089308fd14d9fd67ae6bd2a9d07c16449a5948 [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]a1765672013-08-12 23:45:0214#include "third_party/skia/include/effects/SkBlurImageFilter.h"
[email protected]4934d362012-11-22 22:04:5315
16using cc::CheckerboardDrawQuad;
[email protected]bf189f62012-12-18 03:42:1117using cc::DelegatedFrameData;
[email protected]4934d362012-11-22 22:04:5318using cc::DebugBorderDrawQuad;
19using cc::DrawQuad;
[email protected]ae6b1a72013-06-25 18:49:2920using cc::FilterOperation;
21using cc::FilterOperations;
[email protected]4934d362012-11-22 22:04:5322using cc::IOSurfaceDrawQuad;
[email protected]9ee4d3a2013-03-27 17:43:1623using cc::PictureDrawQuad;
[email protected]4934d362012-11-22 22:04:5324using cc::RenderPass;
25using cc::RenderPassDrawQuad;
26using cc::ResourceProvider;
27using cc::SharedQuadState;
28using cc::SolidColorDrawQuad;
29using cc::TextureDrawQuad;
30using cc::TileDrawQuad;
[email protected]bca159072012-12-04 00:52:4431using cc::TransferableResource;
[email protected]4934d362012-11-22 22:04:5332using cc::StreamVideoDrawQuad;
33using cc::VideoLayerImpl;
34using cc::YUVVideoDrawQuad;
[email protected]c8686a02012-11-27 08:29:0035using gfx::Transform;
[email protected]4934d362012-11-22 22:04:5336
[email protected]bca159072012-12-04 00:52:4437namespace content {
38namespace {
39
[email protected]4934d362012-11-22 22:04:5340class CCMessagesTest : public testing::Test {
41 protected:
42 void Compare(const RenderPass* a, const RenderPass* b) {
43 EXPECT_EQ(a->id, b->id);
44 EXPECT_EQ(a->output_rect.ToString(), b->output_rect.ToString());
45 EXPECT_EQ(a->damage_rect.ToString(), b->damage_rect.ToString());
46 EXPECT_EQ(a->transform_to_root_target, b->transform_to_root_target);
47 EXPECT_EQ(a->has_transparent_background, b->has_transparent_background);
48 EXPECT_EQ(a->has_occlusion_from_outside_target_surface,
49 b->has_occlusion_from_outside_target_surface);
[email protected]4934d362012-11-22 22:04:5350 }
51
52 void Compare(const SharedQuadState* a, const SharedQuadState* b) {
53 EXPECT_EQ(a->content_to_target_transform, b->content_to_target_transform);
[email protected]f902bf92013-03-04 18:33:2754 EXPECT_EQ(a->content_bounds, b->content_bounds);
[email protected]4934d362012-11-22 22:04:5355 EXPECT_EQ(a->visible_content_rect, b->visible_content_rect);
[email protected]4934d362012-11-22 22:04:5356 EXPECT_EQ(a->clip_rect, b->clip_rect);
57 EXPECT_EQ(a->is_clipped, b->is_clipped);
58 EXPECT_EQ(a->opacity, b->opacity);
59 }
60
61 void Compare(const DrawQuad* a, const DrawQuad* b) {
62 ASSERT_NE(DrawQuad::INVALID, a->material);
63 ASSERT_EQ(a->material, b->material);
64 EXPECT_EQ(a->rect.ToString(), b->rect.ToString());
65 EXPECT_EQ(a->opaque_rect.ToString(), b->opaque_rect.ToString());
66 EXPECT_EQ(a->visible_rect.ToString(), b->visible_rect.ToString());
67 EXPECT_EQ(a->needs_blending, b->needs_blending);
68
69 Compare(a->shared_quad_state, b->shared_quad_state);
70
71 switch (a->material) {
72 case DrawQuad::CHECKERBOARD:
73 Compare(CheckerboardDrawQuad::MaterialCast(a),
74 CheckerboardDrawQuad::MaterialCast(b));
75 break;
76 case DrawQuad::DEBUG_BORDER:
77 Compare(DebugBorderDrawQuad::MaterialCast(a),
78 DebugBorderDrawQuad::MaterialCast(b));
79 break;
80 case DrawQuad::IO_SURFACE_CONTENT:
81 Compare(IOSurfaceDrawQuad::MaterialCast(a),
82 IOSurfaceDrawQuad::MaterialCast(b));
83 break;
[email protected]9ee4d3a2013-03-27 17:43:1684 case DrawQuad::PICTURE_CONTENT:
85 Compare(PictureDrawQuad::MaterialCast(a),
86 PictureDrawQuad::MaterialCast(b));
87 break;
[email protected]4934d362012-11-22 22:04:5388 case DrawQuad::RENDER_PASS:
89 Compare(RenderPassDrawQuad::MaterialCast(a),
90 RenderPassDrawQuad::MaterialCast(b));
91 break;
92 case DrawQuad::TEXTURE_CONTENT:
93 Compare(TextureDrawQuad::MaterialCast(a),
94 TextureDrawQuad::MaterialCast(b));
95 break;
96 case DrawQuad::TILED_CONTENT:
97 Compare(TileDrawQuad::MaterialCast(a),
98 TileDrawQuad::MaterialCast(b));
99 break;
100 case DrawQuad::SOLID_COLOR:
101 Compare(SolidColorDrawQuad::MaterialCast(a),
102 SolidColorDrawQuad::MaterialCast(b));
103 break;
104 case DrawQuad::STREAM_VIDEO_CONTENT:
105 Compare(StreamVideoDrawQuad::MaterialCast(a),
106 StreamVideoDrawQuad::MaterialCast(b));
107 break;
108 case DrawQuad::YUV_VIDEO_CONTENT:
109 Compare(YUVVideoDrawQuad::MaterialCast(a),
110 YUVVideoDrawQuad::MaterialCast(b));
111 break;
112 case DrawQuad::INVALID:
113 break;
114 }
115 }
116
117 void Compare(const CheckerboardDrawQuad* a, const CheckerboardDrawQuad* b) {
118 EXPECT_EQ(a->color, b->color);
119 }
120
121 void Compare(const DebugBorderDrawQuad* a, const DebugBorderDrawQuad* b) {
122 EXPECT_EQ(a->color, b->color);
123 EXPECT_EQ(a->width, b->width);
124 }
125
126 void Compare(const IOSurfaceDrawQuad* a, const IOSurfaceDrawQuad* b) {
127 EXPECT_EQ(a->io_surface_size.ToString(), b->io_surface_size.ToString());
[email protected]b7cfc632013-04-10 04:44:49128 EXPECT_EQ(a->io_surface_resource_id, b->io_surface_resource_id);
[email protected]4934d362012-11-22 22:04:53129 EXPECT_EQ(a->orientation, b->orientation);
130 }
131
132 void Compare(const RenderPassDrawQuad* a, const RenderPassDrawQuad* b) {
[email protected]82f93fb2013-04-17 21:42:06133 EXPECT_EQ(a->render_pass_id, b->render_pass_id);
[email protected]4934d362012-11-22 22:04:53134 EXPECT_EQ(a->is_replica, b->is_replica);
135 EXPECT_EQ(a->mask_resource_id, b->mask_resource_id);
136 EXPECT_EQ(a->contents_changed_since_last_frame,
137 b->contents_changed_since_last_frame);
[email protected]458af1e2012-12-13 05:12:18138 EXPECT_EQ(a->mask_uv_rect.ToString(), b->mask_uv_rect.ToString());
[email protected]20062042012-12-21 22:16:36139 EXPECT_EQ(a->filters, b->filters);
[email protected]a1765672013-08-12 23:45:02140 if (!a->filter || !b->filter)
141 EXPECT_EQ(a->filter, b->filter);
142 else
143 EXPECT_EQ(a->filter->countInputs(), b->filter->countInputs());
[email protected]20062042012-12-21 22:16:36144 EXPECT_EQ(a->background_filters, b->background_filters);
[email protected]4934d362012-11-22 22:04:53145 }
146
147 void Compare(const SolidColorDrawQuad* a, const SolidColorDrawQuad* b) {
148 EXPECT_EQ(a->color, b->color);
[email protected]10a30b12013-05-02 16:42:11149 EXPECT_EQ(a->force_anti_aliasing_off, b->force_anti_aliasing_off);
[email protected]4934d362012-11-22 22:04:53150 }
151
152 void Compare(const StreamVideoDrawQuad* a, const StreamVideoDrawQuad* b) {
[email protected]b7cfc632013-04-10 04:44:49153 EXPECT_EQ(a->resource_id, b->resource_id);
[email protected]4934d362012-11-22 22:04:53154 EXPECT_EQ(a->matrix, b->matrix);
155 }
156
157 void Compare(const TextureDrawQuad* a, const TextureDrawQuad* b) {
158 EXPECT_EQ(a->resource_id, b->resource_id);
159 EXPECT_EQ(a->premultiplied_alpha, b->premultiplied_alpha);
[email protected]1fd555b2013-01-18 00:13:21160 EXPECT_EQ(a->uv_top_left, b->uv_top_left);
161 EXPECT_EQ(a->uv_bottom_right, b->uv_bottom_right);
[email protected]d18b4d62013-07-12 05:33:49162 EXPECT_EQ(a->background_color, b->background_color);
[email protected]61df9d82013-01-30 02:32:42163 EXPECT_EQ(a->vertex_opacity[0], b->vertex_opacity[0]);
164 EXPECT_EQ(a->vertex_opacity[1], b->vertex_opacity[1]);
165 EXPECT_EQ(a->vertex_opacity[2], b->vertex_opacity[2]);
166 EXPECT_EQ(a->vertex_opacity[3], b->vertex_opacity[3]);
[email protected]4934d362012-11-22 22:04:53167 EXPECT_EQ(a->flipped, b->flipped);
168 }
169
170 void Compare(const TileDrawQuad* a, const TileDrawQuad* b) {
171 EXPECT_EQ(a->resource_id, b->resource_id);
172 EXPECT_EQ(a->tex_coord_rect, b->tex_coord_rect);
173 EXPECT_EQ(a->texture_size, b->texture_size);
174 EXPECT_EQ(a->swizzle_contents, b->swizzle_contents);
[email protected]4934d362012-11-22 22:04:53175 }
176
177 void Compare(const YUVVideoDrawQuad* a, const YUVVideoDrawQuad* b) {
178 EXPECT_EQ(a->tex_scale, b->tex_scale);
[email protected]b7cfc632013-04-10 04:44:49179 EXPECT_EQ(a->y_plane_resource_id, b->y_plane_resource_id);
180 EXPECT_EQ(a->u_plane_resource_id, b->u_plane_resource_id);
181 EXPECT_EQ(a->v_plane_resource_id, b->v_plane_resource_id);
[email protected]0402b2382013-06-07 21:50:54182 EXPECT_EQ(a->a_plane_resource_id, b->a_plane_resource_id);
[email protected]4934d362012-11-22 22:04:53183 }
[email protected]bca159072012-12-04 00:52:44184
185 void Compare(const TransferableResource& a, const TransferableResource& b) {
186 EXPECT_EQ(a.id, b.id);
[email protected]09831f7f2013-02-27 03:32:15187 EXPECT_EQ(a.sync_point, b.sync_point);
[email protected]bca159072012-12-04 00:52:44188 EXPECT_EQ(a.format, b.format);
[email protected]80189292013-02-28 01:59:36189 EXPECT_EQ(a.filter, b.filter);
[email protected]bca159072012-12-04 00:52:44190 EXPECT_EQ(a.size.ToString(), b.size.ToString());
191 for (size_t i = 0; i < arraysize(a.mailbox.name); ++i)
192 EXPECT_EQ(a.mailbox.name[i], b.mailbox.name[i]);
193 }
[email protected]4934d362012-11-22 22:04:53194};
195
196TEST_F(CCMessagesTest, AllQuads) {
[email protected]a1765672013-08-12 23:45:02197 CommandLine& command_line = *CommandLine::ForCurrentProcess();
198 if (!command_line.HasSwitch(switches::kAllowFiltersOverIPC))
199 command_line.AppendSwitch(switches::kAllowFiltersOverIPC);
200
[email protected]4934d362012-11-22 22:04:53201 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
202
[email protected]c8686a02012-11-27 08:29:00203 Transform arbitrary_matrix;
204 arbitrary_matrix.Scale(3, 3);
205 arbitrary_matrix.Translate(-5, 20);
206 arbitrary_matrix.Rotate(15);
[email protected]4934d362012-11-22 22:04:53207 gfx::Rect arbitrary_rect1(-5, 9, 3, 15);
208 gfx::Rect arbitrary_rect2(40, 23, 11, 7);
209 gfx::Rect arbitrary_rect3(7, -53, 22, 19);
210 gfx::Size arbitrary_size1(15, 19);
211 gfx::Size arbitrary_size2(3, 99);
212 gfx::Size arbitrary_size3(75, 1281);
213 gfx::RectF arbitrary_rectf1(4.2f, -922.1f, 15.6f, 29.5f);
214 gfx::SizeF arbitrary_sizef1(15.2f, 104.6f);
[email protected]61df9d82013-01-30 02:32:42215 gfx::PointF arbitrary_pointf1(31.4f, 15.9f);
216 gfx::PointF arbitrary_pointf2(26.5f, -35.8f);
[email protected]4934d362012-11-22 22:04:53217 float arbitrary_float1 = 0.7f;
218 float arbitrary_float2 = 0.3f;
219 float arbitrary_float3 = 0.9f;
[email protected]61df9d82013-01-30 02:32:42220 float arbitrary_float_array[4] = {3.5f, 6.2f, 9.3f, 12.3f};
[email protected]4934d362012-11-22 22:04:53221 bool arbitrary_bool1 = true;
222 bool arbitrary_bool2 = false;
[email protected]61df9d82013-01-30 02:32:42223 bool arbitrary_bool3 = true;
[email protected]4934d362012-11-22 22:04:53224 int arbitrary_int = 5;
225 SkColor arbitrary_color = SkColorSetARGB(25, 36, 47, 58);
226 IOSurfaceDrawQuad::Orientation arbitrary_orientation =
227 IOSurfaceDrawQuad::UNFLIPPED;
228 RenderPass::Id arbitrary_id(10, 14);
[email protected]b7cfc632013-04-10 04:44:49229 ResourceProvider::ResourceId arbitrary_resourceid1 = 55;
230 ResourceProvider::ResourceId arbitrary_resourceid2 = 47;
231 ResourceProvider::ResourceId arbitrary_resourceid3 = 23;
[email protected]0402b2382013-06-07 21:50:54232 ResourceProvider::ResourceId arbitrary_resourceid4 = 16;
[email protected]a1765672013-08-12 23:45:02233 SkScalar arbitrary_sigma = SkFloatToScalar(2.0f);
[email protected]4934d362012-11-22 22:04:53234
[email protected]ae6b1a72013-06-25 18:49:29235 FilterOperations arbitrary_filters1;
236 arbitrary_filters1.Append(FilterOperation::CreateGrayscaleFilter(
[email protected]4934d362012-11-22 22:04:53237 arbitrary_float1));
238
[email protected]ae6b1a72013-06-25 18:49:29239 FilterOperations arbitrary_filters2;
240 arbitrary_filters2.Append(FilterOperation::CreateBrightnessFilter(
[email protected]4934d362012-11-22 22:04:53241 arbitrary_float2));
242
[email protected]a1765672013-08-12 23:45:02243 skia::RefPtr<SkImageFilter> arbitrary_filter = skia::AdoptRef(
244 new SkBlurImageFilter(arbitrary_sigma, arbitrary_sigma));
[email protected]1940c4e2012-12-04 05:08:15245
[email protected]4934d362012-11-22 22:04:53246 scoped_ptr<SharedQuadState> shared_state1_in = SharedQuadState::Create();
247 shared_state1_in->SetAll(arbitrary_matrix,
[email protected]f902bf92013-03-04 18:33:27248 arbitrary_size1,
[email protected]4934d362012-11-22 22:04:53249 arbitrary_rect1,
250 arbitrary_rect2,
[email protected]4934d362012-11-22 22:04:53251 arbitrary_bool1,
252 arbitrary_float1);
253 scoped_ptr<SharedQuadState> shared_state1_cmp = shared_state1_in->Copy();
254
255 scoped_ptr<CheckerboardDrawQuad> checkerboard_in =
256 CheckerboardDrawQuad::Create();
257 checkerboard_in->SetAll(shared_state1_in.get(),
258 arbitrary_rect1,
259 arbitrary_rect2,
260 arbitrary_rect3,
261 arbitrary_bool1,
262 arbitrary_color);
263 scoped_ptr<DrawQuad> checkerboard_cmp = checkerboard_in->Copy(
264 checkerboard_in->shared_quad_state);
265
266 scoped_ptr<DebugBorderDrawQuad> debugborder_in =
267 DebugBorderDrawQuad::Create();
268 debugborder_in->SetAll(shared_state1_in.get(),
269 arbitrary_rect3,
270 arbitrary_rect1,
271 arbitrary_rect2,
272 arbitrary_bool1,
273 arbitrary_color,
274 arbitrary_int);
275 scoped_ptr<DrawQuad> debugborder_cmp = debugborder_in->Copy(
276 debugborder_in->shared_quad_state);
277
278 scoped_ptr<IOSurfaceDrawQuad> iosurface_in =
279 IOSurfaceDrawQuad::Create();
280 iosurface_in->SetAll(shared_state1_in.get(),
281 arbitrary_rect2,
282 arbitrary_rect3,
283 arbitrary_rect1,
284 arbitrary_bool1,
285 arbitrary_size1,
[email protected]b7cfc632013-04-10 04:44:49286 arbitrary_resourceid3,
[email protected]4934d362012-11-22 22:04:53287 arbitrary_orientation);
288 scoped_ptr<DrawQuad> iosurface_cmp = iosurface_in->Copy(
289 iosurface_in->shared_quad_state);
290
291 scoped_ptr<RenderPassDrawQuad> renderpass_in =
292 RenderPassDrawQuad::Create();
293 renderpass_in->SetAll(shared_state1_in.get(),
294 arbitrary_rect1,
295 arbitrary_rect2,
296 arbitrary_rect3,
297 arbitrary_bool1,
298 arbitrary_id,
299 arbitrary_bool2,
[email protected]b7cfc632013-04-10 04:44:49300 arbitrary_resourceid2,
[email protected]4934d362012-11-22 22:04:53301 arbitrary_rect1,
[email protected]20062042012-12-21 22:16:36302 arbitrary_rectf1,
303 arbitrary_filters1,
[email protected]a1765672013-08-12 23:45:02304 arbitrary_filter,
[email protected]20062042012-12-21 22:16:36305 arbitrary_filters2);
[email protected]4934d362012-11-22 22:04:53306 scoped_ptr<RenderPassDrawQuad> renderpass_cmp = renderpass_in->Copy(
307 renderpass_in->shared_quad_state, renderpass_in->render_pass_id);
308
309 scoped_ptr<SharedQuadState> shared_state2_in = SharedQuadState::Create();
310 shared_state2_in->SetAll(arbitrary_matrix,
[email protected]f902bf92013-03-04 18:33:27311 arbitrary_size2,
[email protected]4934d362012-11-22 22:04:53312 arbitrary_rect2,
313 arbitrary_rect3,
[email protected]4934d362012-11-22 22:04:53314 arbitrary_bool1,
315 arbitrary_float2);
316 scoped_ptr<SharedQuadState> shared_state2_cmp = shared_state2_in->Copy();
317
318 scoped_ptr<SharedQuadState> shared_state3_in = SharedQuadState::Create();
319 shared_state3_in->SetAll(arbitrary_matrix,
[email protected]f902bf92013-03-04 18:33:27320 arbitrary_size3,
[email protected]4934d362012-11-22 22:04:53321 arbitrary_rect3,
322 arbitrary_rect1,
[email protected]4934d362012-11-22 22:04:53323 arbitrary_bool1,
324 arbitrary_float3);
325 scoped_ptr<SharedQuadState> shared_state3_cmp = shared_state3_in->Copy();
326
327 scoped_ptr<SolidColorDrawQuad> solidcolor_in =
328 SolidColorDrawQuad::Create();
329 solidcolor_in->SetAll(shared_state1_in.get(),
330 arbitrary_rect3,
331 arbitrary_rect1,
332 arbitrary_rect2,
333 arbitrary_bool1,
[email protected]10a30b12013-05-02 16:42:11334 arbitrary_color,
335 arbitrary_bool2);
[email protected]4934d362012-11-22 22:04:53336 scoped_ptr<DrawQuad> solidcolor_cmp = solidcolor_in->Copy(
337 solidcolor_in->shared_quad_state);
338
339 scoped_ptr<StreamVideoDrawQuad> streamvideo_in =
340 StreamVideoDrawQuad::Create();
341 streamvideo_in->SetAll(shared_state1_in.get(),
342 arbitrary_rect2,
343 arbitrary_rect3,
344 arbitrary_rect1,
345 arbitrary_bool1,
[email protected]b7cfc632013-04-10 04:44:49346 arbitrary_resourceid2,
[email protected]4934d362012-11-22 22:04:53347 arbitrary_matrix);
348 scoped_ptr<DrawQuad> streamvideo_cmp = streamvideo_in->Copy(
349 streamvideo_in->shared_quad_state);
350
[email protected]61df9d82013-01-30 02:32:42351 scoped_ptr<TextureDrawQuad> texture_in = TextureDrawQuad::Create();
352 texture_in->SetAll(shared_state1_in.get(),
353 arbitrary_rect2,
354 arbitrary_rect3,
355 arbitrary_rect1,
356 arbitrary_bool1,
[email protected]b7cfc632013-04-10 04:44:49357 arbitrary_resourceid1,
[email protected]61df9d82013-01-30 02:32:42358 arbitrary_bool2,
359 arbitrary_pointf1,
360 arbitrary_pointf2,
[email protected]d18b4d62013-07-12 05:33:49361 arbitrary_color,
[email protected]61df9d82013-01-30 02:32:42362 arbitrary_float_array,
363 arbitrary_bool3);
364 scoped_ptr<DrawQuad> texture_cmp = texture_in->Copy(
365 texture_in->shared_quad_state);
366
367 scoped_ptr<TileDrawQuad> tile_in = TileDrawQuad::Create();
368 tile_in->SetAll(shared_state1_in.get(),
369 arbitrary_rect2,
370 arbitrary_rect3,
371 arbitrary_rect1,
372 arbitrary_bool1,
[email protected]b7cfc632013-04-10 04:44:49373 arbitrary_resourceid3,
[email protected]61df9d82013-01-30 02:32:42374 arbitrary_rectf1,
375 arbitrary_size1,
[email protected]f902bf92013-03-04 18:33:27376 arbitrary_bool2);
[email protected]61df9d82013-01-30 02:32:42377 scoped_ptr<DrawQuad> tile_cmp = tile_in->Copy(
378 tile_in->shared_quad_state);
379
[email protected]4934d362012-11-22 22:04:53380 scoped_ptr<YUVVideoDrawQuad> yuvvideo_in =
381 YUVVideoDrawQuad::Create();
382 yuvvideo_in->SetAll(shared_state1_in.get(),
383 arbitrary_rect1,
384 arbitrary_rect2,
385 arbitrary_rect3,
386 arbitrary_bool1,
387 arbitrary_sizef1,
[email protected]b7cfc632013-04-10 04:44:49388 arbitrary_resourceid1,
389 arbitrary_resourceid2,
[email protected]0402b2382013-06-07 21:50:54390 arbitrary_resourceid3,
391 arbitrary_resourceid4);
[email protected]4934d362012-11-22 22:04:53392 scoped_ptr<DrawQuad> yuvvideo_cmp = yuvvideo_in->Copy(
393 yuvvideo_in->shared_quad_state);
394
395 scoped_ptr<RenderPass> pass_in = RenderPass::Create();
396 pass_in->SetAll(arbitrary_id,
397 arbitrary_rect1,
398 arbitrary_rectf1,
399 arbitrary_matrix,
400 arbitrary_bool1,
[email protected]20062042012-12-21 22:16:36401 arbitrary_bool2);
[email protected]4934d362012-11-22 22:04:53402
[email protected]ead39c52013-01-09 07:22:45403 pass_in->shared_quad_state_list.push_back(shared_state1_in.Pass());
404 pass_in->quad_list.push_back(checkerboard_in.PassAs<DrawQuad>());
405 pass_in->quad_list.push_back(debugborder_in.PassAs<DrawQuad>());
406 pass_in->quad_list.push_back(iosurface_in.PassAs<DrawQuad>());
407 pass_in->quad_list.push_back(renderpass_in.PassAs<DrawQuad>());
408 pass_in->shared_quad_state_list.push_back(shared_state2_in.Pass());
409 pass_in->shared_quad_state_list.push_back(shared_state3_in.Pass());
410 pass_in->quad_list.push_back(solidcolor_in.PassAs<DrawQuad>());
411 pass_in->quad_list.push_back(streamvideo_in.PassAs<DrawQuad>());
[email protected]61df9d82013-01-30 02:32:42412 pass_in->quad_list.push_back(texture_in.PassAs<DrawQuad>());
413 pass_in->quad_list.push_back(tile_in.PassAs<DrawQuad>());
[email protected]ead39c52013-01-09 07:22:45414 pass_in->quad_list.push_back(yuvvideo_in.PassAs<DrawQuad>());
[email protected]4934d362012-11-22 22:04:53415
416 scoped_ptr<RenderPass> pass_cmp = RenderPass::Create();
417 pass_cmp->SetAll(arbitrary_id,
418 arbitrary_rect1,
419 arbitrary_rectf1,
420 arbitrary_matrix,
421 arbitrary_bool1,
[email protected]20062042012-12-21 22:16:36422 arbitrary_bool2);
[email protected]4934d362012-11-22 22:04:53423
[email protected]ead39c52013-01-09 07:22:45424 pass_cmp->shared_quad_state_list.push_back(shared_state1_cmp.Pass());
425 pass_cmp->quad_list.push_back(checkerboard_cmp.PassAs<DrawQuad>());
426 pass_cmp->quad_list.push_back(debugborder_cmp.PassAs<DrawQuad>());
427 pass_cmp->quad_list.push_back(iosurface_cmp.PassAs<DrawQuad>());
428 pass_cmp->quad_list.push_back(renderpass_cmp.PassAs<DrawQuad>());
429 pass_cmp->shared_quad_state_list.push_back(shared_state2_cmp.Pass());
430 pass_cmp->shared_quad_state_list.push_back(shared_state3_cmp.Pass());
431 pass_cmp->quad_list.push_back(solidcolor_cmp.PassAs<DrawQuad>());
432 pass_cmp->quad_list.push_back(streamvideo_cmp.PassAs<DrawQuad>());
[email protected]61df9d82013-01-30 02:32:42433 pass_cmp->quad_list.push_back(texture_cmp.PassAs<DrawQuad>());
434 pass_cmp->quad_list.push_back(tile_cmp.PassAs<DrawQuad>());
[email protected]ead39c52013-01-09 07:22:45435 pass_cmp->quad_list.push_back(yuvvideo_cmp.PassAs<DrawQuad>());
[email protected]4934d362012-11-22 22:04:53436
437 // Make sure the in and cmp RenderPasses match.
438 Compare(pass_cmp.get(), pass_in.get());
439 ASSERT_EQ(3u, pass_in->shared_quad_state_list.size());
[email protected]61df9d82013-01-30 02:32:42440 ASSERT_EQ(9u, pass_in->quad_list.size());
[email protected]4934d362012-11-22 22:04:53441 for (size_t i = 0; i < 3; ++i) {
442 Compare(pass_cmp->shared_quad_state_list[i],
443 pass_in->shared_quad_state_list[i]);
444 }
[email protected]61df9d82013-01-30 02:32:42445 for (size_t i = 0; i < pass_in->quad_list.size(); ++i)
[email protected]4934d362012-11-22 22:04:53446 Compare(pass_cmp->quad_list[i], pass_in->quad_list[i]);
[email protected]61df9d82013-01-30 02:32:42447 for (size_t i = 1; i < pass_in->quad_list.size(); ++i) {
[email protected]4934d362012-11-22 22:04:53448 bool same_shared_quad_state_cmp =
449 pass_cmp->quad_list[i]->shared_quad_state ==
450 pass_cmp->quad_list[i - 1]->shared_quad_state;
451 bool same_shared_quad_state_in =
452 pass_in->quad_list[i]->shared_quad_state ==
453 pass_in->quad_list[i - 1]->shared_quad_state;
454 EXPECT_EQ(same_shared_quad_state_cmp, same_shared_quad_state_in);
455 }
456
[email protected]bf189f62012-12-18 03:42:11457 DelegatedFrameData frame_in;
[email protected]ead39c52013-01-09 07:22:45458 frame_in.render_pass_list.push_back(pass_in.Pass());
[email protected]4934d362012-11-22 22:04:53459
[email protected]bf189f62012-12-18 03:42:11460 IPC::ParamTraits<DelegatedFrameData>::Write(&msg, frame_in);
[email protected]bca159072012-12-04 00:52:44461
[email protected]bf189f62012-12-18 03:42:11462 DelegatedFrameData frame_out;
[email protected]4934d362012-11-22 22:04:53463 PickleIterator iter(msg);
[email protected]bf189f62012-12-18 03:42:11464 EXPECT_TRUE(IPC::ParamTraits<DelegatedFrameData>::Read(&msg,
465 &iter, &frame_out));
[email protected]bca159072012-12-04 00:52:44466
[email protected]4934d362012-11-22 22:04:53467 // Make sure the out and cmp RenderPasses match.
[email protected]ead39c52013-01-09 07:22:45468 scoped_ptr<RenderPass> pass_out = frame_out.render_pass_list.take(
469 frame_out.render_pass_list.begin());
[email protected]4934d362012-11-22 22:04:53470 Compare(pass_cmp.get(), pass_out.get());
471 ASSERT_EQ(3u, pass_out->shared_quad_state_list.size());
[email protected]61df9d82013-01-30 02:32:42472 ASSERT_EQ(9u, pass_out->quad_list.size());
[email protected]4934d362012-11-22 22:04:53473 for (size_t i = 0; i < 3; ++i) {
474 Compare(pass_cmp->shared_quad_state_list[i],
475 pass_out->shared_quad_state_list[i]);
476 }
[email protected]61df9d82013-01-30 02:32:42477 for (size_t i = 0; i < pass_out->quad_list.size(); ++i)
[email protected]4934d362012-11-22 22:04:53478 Compare(pass_cmp->quad_list[i], pass_out->quad_list[i]);
[email protected]61df9d82013-01-30 02:32:42479 for (size_t i = 1; i < pass_out->quad_list.size(); ++i) {
[email protected]4934d362012-11-22 22:04:53480 bool same_shared_quad_state_cmp =
481 pass_cmp->quad_list[i]->shared_quad_state ==
482 pass_cmp->quad_list[i - 1]->shared_quad_state;
483 bool same_shared_quad_state_out =
484 pass_out->quad_list[i]->shared_quad_state ==
485 pass_out->quad_list[i - 1]->shared_quad_state;
486 EXPECT_EQ(same_shared_quad_state_cmp, same_shared_quad_state_out);
487 }
488}
[email protected]bca159072012-12-04 00:52:44489
490TEST_F(CCMessagesTest, Resources) {
491 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
492 gfx::Size arbitrary_size(757, 1281);
[email protected]09831f7f2013-02-27 03:32:15493 unsigned int arbitrary_uint1 = 71234838;
494 unsigned int arbitrary_uint2 = 53589793;
[email protected]bca159072012-12-04 00:52:44495
496 GLbyte arbitrary_mailbox1[64] = {
497 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
498 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
499 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
500 1, 2, 3, 4
501 };
502
503 GLbyte arbitrary_mailbox2[64] = {
504 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0,
505 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0,
506 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0,
507 0, 9, 8, 7
508 };
509
510 TransferableResource arbitrary_resource1;
511 arbitrary_resource1.id = 2178312;
[email protected]09831f7f2013-02-27 03:32:15512 arbitrary_resource1.sync_point = arbitrary_uint1;
[email protected]bca159072012-12-04 00:52:44513 arbitrary_resource1.format = 7;
[email protected]80189292013-02-28 01:59:36514 arbitrary_resource1.filter = 53;
[email protected]bca159072012-12-04 00:52:44515 arbitrary_resource1.size = gfx::Size(37189, 123123);
[email protected]1aca0092013-03-04 22:46:03516 arbitrary_resource1.mailbox.SetName(arbitrary_mailbox1);
[email protected]bca159072012-12-04 00:52:44517
518 TransferableResource arbitrary_resource2;
519 arbitrary_resource2.id = 789132;
[email protected]09831f7f2013-02-27 03:32:15520 arbitrary_resource1.sync_point = arbitrary_uint2;
[email protected]bca159072012-12-04 00:52:44521 arbitrary_resource2.format = 30;
[email protected]80189292013-02-28 01:59:36522 arbitrary_resource1.filter = 47;
[email protected]bca159072012-12-04 00:52:44523 arbitrary_resource2.size = gfx::Size(89123, 23789);
[email protected]1aca0092013-03-04 22:46:03524 arbitrary_resource2.mailbox.SetName(arbitrary_mailbox2);
[email protected]bca159072012-12-04 00:52:44525
[email protected]bf189f62012-12-18 03:42:11526 DelegatedFrameData frame_in;
[email protected]09831f7f2013-02-27 03:32:15527 frame_in.resource_list.push_back(arbitrary_resource1);
528 frame_in.resource_list.push_back(arbitrary_resource2);
[email protected]bca159072012-12-04 00:52:44529
[email protected]bf189f62012-12-18 03:42:11530 IPC::ParamTraits<DelegatedFrameData>::Write(&msg, frame_in);
[email protected]bca159072012-12-04 00:52:44531
[email protected]bf189f62012-12-18 03:42:11532 DelegatedFrameData frame_out;
[email protected]bca159072012-12-04 00:52:44533 PickleIterator iter(msg);
[email protected]bf189f62012-12-18 03:42:11534 EXPECT_TRUE(IPC::ParamTraits<DelegatedFrameData>::Read(&msg,
535 &iter, &frame_out));
[email protected]bca159072012-12-04 00:52:44536
[email protected]09831f7f2013-02-27 03:32:15537 ASSERT_EQ(2u, frame_out.resource_list.size());
538 Compare(arbitrary_resource1, frame_out.resource_list[0]);
539 Compare(arbitrary_resource2, frame_out.resource_list[1]);
[email protected]bca159072012-12-04 00:52:44540}
541
542} // namespace
543} // namespace content