blob: fad9c5350f39ecde7f2b927963345df5e83f36bf [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
avia9aa7a82015-12-25 03:06:315#include <stddef.h>
[email protected]4934d362012-11-22 22:04:536#include <string.h>
[email protected]032bfc42013-10-29 22:23:527#include <algorithm>
dchengf63a1252015-12-26 20:43:138#include <utility>
[email protected]032bfc42013-10-29 22:23:529
avia9aa7a82015-12-25 03:06:3110#include "base/macros.h"
11#include "build/build_config.h"
fsamuel812b8482016-05-16 18:52:1812#include "cc/ipc/cc_param_traits.h"
[email protected]7f0d825f2013-03-18 07:24:3013#include "cc/output/compositor_frame.h"
fsamuel812b8482016-05-16 18:52:1814#include "cc/quads/picture_draw_quad.h"
15#include "cc/quads/render_pass_draw_quad.h"
[email protected]4934d362012-11-22 22:04:5316#include "ipc/ipc_message.h"
17#include "testing/gtest/include/gtest/gtest.h"
[email protected]a1765672013-08-12 23:45:0218#include "third_party/skia/include/effects/SkBlurImageFilter.h"
[email protected]4934d362012-11-22 22:04:5319
[email protected]cecc8342014-03-20 21:43:3920#if defined(OS_POSIX)
21#include "base/file_descriptor_posix.h"
22#endif
23
samansce5c3c32016-11-18 13:47:3424using cc::CompositorFrame;
[email protected]4934d362012-11-22 22:04:5325using cc::DebugBorderDrawQuad;
26using cc::DrawQuad;
[email protected]ae6b1a72013-06-25 18:49:2927using cc::FilterOperation;
28using cc::FilterOperations;
[email protected]9ee4d3a2013-03-27 17:43:1629using cc::PictureDrawQuad;
[email protected]4934d362012-11-22 22:04:5330using cc::RenderPass;
31using cc::RenderPassDrawQuad;
jbaumanbbd425e2015-05-19 00:33:3532using cc::ResourceId;
[email protected]4934d362012-11-22 22:04:5333using cc::ResourceProvider;
34using cc::SharedQuadState;
35using cc::SolidColorDrawQuad;
[email protected]78d30122014-01-17 06:32:3636using cc::SurfaceDrawQuad;
[email protected]4934d362012-11-22 22:04:5337using cc::TextureDrawQuad;
38using cc::TileDrawQuad;
[email protected]bca159072012-12-04 00:52:4439using cc::TransferableResource;
[email protected]4934d362012-11-22 22:04:5340using cc::StreamVideoDrawQuad;
[email protected]4934d362012-11-22 22:04:5341using cc::YUVVideoDrawQuad;
[email protected]c8686a02012-11-27 08:29:0042using gfx::Transform;
[email protected]4934d362012-11-22 22:04:5343
[email protected]bca159072012-12-04 00:52:4444namespace content {
45namespace {
46
fsamuele0f705b2016-10-01 14:07:1447static constexpr cc::FrameSinkId kArbitraryFrameSinkId(1, 1);
48
fsamuelf76098e2016-05-18 17:26:5149class CCParamTraitsTest : public testing::Test {
[email protected]4934d362012-11-22 22:04:5350 protected:
51 void Compare(const RenderPass* a, const RenderPass* b) {
52 EXPECT_EQ(a->id, b->id);
53 EXPECT_EQ(a->output_rect.ToString(), b->output_rect.ToString());
54 EXPECT_EQ(a->damage_rect.ToString(), b->damage_rect.ToString());
55 EXPECT_EQ(a->transform_to_root_target, b->transform_to_root_target);
ajumaa26e58452016-12-15 22:35:0156 EXPECT_EQ(a->filters.size(), b->filters.size());
57 for (size_t i = 0; i < a->filters.size(); ++i) {
58 if (a->filters.at(i).type() != cc::FilterOperation::REFERENCE) {
59 EXPECT_EQ(a->filters.at(i), b->filters.at(i));
60 } else {
61 EXPECT_EQ(b->filters.at(i).type(), cc::FilterOperation::REFERENCE);
62 EXPECT_EQ(a->filters.at(i).image_filter()->countInputs(),
63 b->filters.at(i).image_filter()->countInputs());
64 }
65 }
66 EXPECT_EQ(a->background_filters.size(), b->background_filters.size());
67 for (size_t i = 0; i < a->background_filters.size(); ++i) {
68 if (a->background_filters.at(i).type() !=
69 cc::FilterOperation::REFERENCE) {
70 EXPECT_EQ(a->background_filters.at(i), b->background_filters.at(i));
71 } else {
72 EXPECT_EQ(b->background_filters.at(i).type(),
73 cc::FilterOperation::REFERENCE);
74 EXPECT_EQ(a->background_filters.at(i).image_filter()->countInputs(),
75 b->background_filters.at(i).image_filter()->countInputs());
76 }
77 }
ccameron625dae1e2017-02-13 23:44:4478 EXPECT_EQ(a->color_space, b->color_space);
[email protected]4934d362012-11-22 22:04:5379 EXPECT_EQ(a->has_transparent_background, b->has_transparent_background);
[email protected]4934d362012-11-22 22:04:5380 }
81
82 void Compare(const SharedQuadState* a, const SharedQuadState* b) {
danakj64767d902015-06-19 00:10:4383 EXPECT_EQ(a->quad_to_target_transform, b->quad_to_target_transform);
84 EXPECT_EQ(a->quad_layer_bounds, b->quad_layer_bounds);
85 EXPECT_EQ(a->visible_quad_layer_rect, b->visible_quad_layer_rect);
[email protected]4934d362012-11-22 22:04:5386 EXPECT_EQ(a->clip_rect, b->clip_rect);
87 EXPECT_EQ(a->is_clipped, b->is_clipped);
88 EXPECT_EQ(a->opacity, b->opacity);
[email protected]7bbeaf4e2013-11-26 10:27:2289 EXPECT_EQ(a->blend_mode, b->blend_mode);
[email protected]a9d4d4f2014-06-19 06:49:2890 EXPECT_EQ(a->sorting_context_id, b->sorting_context_id);
[email protected]4934d362012-11-22 22:04:5391 }
92
93 void Compare(const DrawQuad* a, const DrawQuad* b) {
94 ASSERT_NE(DrawQuad::INVALID, a->material);
95 ASSERT_EQ(a->material, b->material);
96 EXPECT_EQ(a->rect.ToString(), b->rect.ToString());
97 EXPECT_EQ(a->opaque_rect.ToString(), b->opaque_rect.ToString());
98 EXPECT_EQ(a->visible_rect.ToString(), b->visible_rect.ToString());
99 EXPECT_EQ(a->needs_blending, b->needs_blending);
100
101 Compare(a->shared_quad_state, b->shared_quad_state);
102
103 switch (a->material) {
[email protected]4934d362012-11-22 22:04:53104 case DrawQuad::DEBUG_BORDER:
105 Compare(DebugBorderDrawQuad::MaterialCast(a),
106 DebugBorderDrawQuad::MaterialCast(b));
107 break;
[email protected]9ee4d3a2013-03-27 17:43:16108 case DrawQuad::PICTURE_CONTENT:
109 Compare(PictureDrawQuad::MaterialCast(a),
110 PictureDrawQuad::MaterialCast(b));
111 break;
[email protected]4934d362012-11-22 22:04:53112 case DrawQuad::RENDER_PASS:
113 Compare(RenderPassDrawQuad::MaterialCast(a),
114 RenderPassDrawQuad::MaterialCast(b));
115 break;
116 case DrawQuad::TEXTURE_CONTENT:
117 Compare(TextureDrawQuad::MaterialCast(a),
118 TextureDrawQuad::MaterialCast(b));
119 break;
120 case DrawQuad::TILED_CONTENT:
fsamuelf76098e2016-05-18 17:26:51121 Compare(TileDrawQuad::MaterialCast(a), TileDrawQuad::MaterialCast(b));
[email protected]4934d362012-11-22 22:04:53122 break;
123 case DrawQuad::SOLID_COLOR:
124 Compare(SolidColorDrawQuad::MaterialCast(a),
125 SolidColorDrawQuad::MaterialCast(b));
126 break;
127 case DrawQuad::STREAM_VIDEO_CONTENT:
128 Compare(StreamVideoDrawQuad::MaterialCast(a),
129 StreamVideoDrawQuad::MaterialCast(b));
130 break;
[email protected]78d30122014-01-17 06:32:36131 case DrawQuad::SURFACE_CONTENT:
132 Compare(SurfaceDrawQuad::MaterialCast(a),
133 SurfaceDrawQuad::MaterialCast(b));
134 break;
[email protected]4934d362012-11-22 22:04:53135 case DrawQuad::YUV_VIDEO_CONTENT:
136 Compare(YUVVideoDrawQuad::MaterialCast(a),
137 YUVVideoDrawQuad::MaterialCast(b));
138 break;
139 case DrawQuad::INVALID:
140 break;
141 }
142 }
143
[email protected]4934d362012-11-22 22:04:53144 void Compare(const DebugBorderDrawQuad* a, const DebugBorderDrawQuad* b) {
145 EXPECT_EQ(a->color, b->color);
146 EXPECT_EQ(a->width, b->width);
147 }
148
[email protected]4934d362012-11-22 22:04:53149 void Compare(const RenderPassDrawQuad* a, const RenderPassDrawQuad* b) {
[email protected]82f93fb2013-04-17 21:42:06150 EXPECT_EQ(a->render_pass_id, b->render_pass_id);
vmpstr0eca2e82015-06-02 22:14:46151 EXPECT_EQ(a->mask_resource_id(), b->mask_resource_id());
ennef6f3fbba42014-10-16 18:16:49152 EXPECT_EQ(a->mask_uv_scale.ToString(), b->mask_uv_scale.ToString());
153 EXPECT_EQ(a->mask_texture_size.ToString(), b->mask_texture_size.ToString());
[email protected]7ac3d492014-08-08 21:25:32154 EXPECT_EQ(a->filters_scale, b->filters_scale);
Stephen White5941ecb02016-08-30 01:28:24155 EXPECT_EQ(a->filters_origin, b->filters_origin);
[email protected]4934d362012-11-22 22:04:53156 }
157
158 void Compare(const SolidColorDrawQuad* a, const SolidColorDrawQuad* b) {
159 EXPECT_EQ(a->color, b->color);
[email protected]10a30b12013-05-02 16:42:11160 EXPECT_EQ(a->force_anti_aliasing_off, b->force_anti_aliasing_off);
[email protected]4934d362012-11-22 22:04:53161 }
162
163 void Compare(const StreamVideoDrawQuad* a, const StreamVideoDrawQuad* b) {
vmpstr0eca2e82015-06-02 22:14:46164 EXPECT_EQ(a->resource_id(), b->resource_id());
achaulkf89f5942015-06-10 17:01:35165 EXPECT_EQ(a->resource_size_in_pixels(), b->resource_size_in_pixels());
[email protected]4934d362012-11-22 22:04:53166 EXPECT_EQ(a->matrix, b->matrix);
167 }
168
[email protected]78d30122014-01-17 06:32:36169 void Compare(const SurfaceDrawQuad* a, const SurfaceDrawQuad* b) {
170 EXPECT_EQ(a->surface_id, b->surface_id);
171 }
172
[email protected]4934d362012-11-22 22:04:53173 void Compare(const TextureDrawQuad* a, const TextureDrawQuad* b) {
vmpstr0eca2e82015-06-02 22:14:46174 EXPECT_EQ(a->resource_id(), b->resource_id());
achaulkf89f5942015-06-10 17:01:35175 EXPECT_EQ(a->resource_size_in_pixels(), b->resource_size_in_pixels());
[email protected]4934d362012-11-22 22:04:53176 EXPECT_EQ(a->premultiplied_alpha, b->premultiplied_alpha);
[email protected]1fd555b2013-01-18 00:13:21177 EXPECT_EQ(a->uv_top_left, b->uv_top_left);
178 EXPECT_EQ(a->uv_bottom_right, b->uv_bottom_right);
[email protected]d18b4d62013-07-12 05:33:49179 EXPECT_EQ(a->background_color, b->background_color);
[email protected]61df9d82013-01-30 02:32:42180 EXPECT_EQ(a->vertex_opacity[0], b->vertex_opacity[0]);
181 EXPECT_EQ(a->vertex_opacity[1], b->vertex_opacity[1]);
182 EXPECT_EQ(a->vertex_opacity[2], b->vertex_opacity[2]);
183 EXPECT_EQ(a->vertex_opacity[3], b->vertex_opacity[3]);
halliwellaa111282015-05-13 21:58:43184 EXPECT_EQ(a->y_flipped, b->y_flipped);
jackhou10c9af42014-12-04 05:24:44185 EXPECT_EQ(a->nearest_neighbor, b->nearest_neighbor);
jbauman0c1bf21132016-05-19 19:20:07186 EXPECT_EQ(a->secure_output_only, b->secure_output_only);
[email protected]4934d362012-11-22 22:04:53187 }
188
189 void Compare(const TileDrawQuad* a, const TileDrawQuad* b) {
vmpstr0eca2e82015-06-02 22:14:46190 EXPECT_EQ(a->resource_id(), b->resource_id());
[email protected]4934d362012-11-22 22:04:53191 EXPECT_EQ(a->tex_coord_rect, b->tex_coord_rect);
192 EXPECT_EQ(a->texture_size, b->texture_size);
193 EXPECT_EQ(a->swizzle_contents, b->swizzle_contents);
jackhou24229612014-12-13 23:41:00194 EXPECT_EQ(a->nearest_neighbor, b->nearest_neighbor);
[email protected]4934d362012-11-22 22:04:53195 }
196
197 void Compare(const YUVVideoDrawQuad* a, const YUVVideoDrawQuad* b) {
revemanb71e3992015-05-12 23:01:51198 EXPECT_EQ(a->ya_tex_coord_rect, b->ya_tex_coord_rect);
199 EXPECT_EQ(a->uv_tex_coord_rect, b->uv_tex_coord_rect);
magjed7364ff92015-03-27 09:11:08200 EXPECT_EQ(a->ya_tex_size, b->ya_tex_size);
201 EXPECT_EQ(a->uv_tex_size, b->uv_tex_size);
vmpstr0eca2e82015-06-02 22:14:46202 EXPECT_EQ(a->y_plane_resource_id(), b->y_plane_resource_id());
203 EXPECT_EQ(a->u_plane_resource_id(), b->u_plane_resource_id());
204 EXPECT_EQ(a->v_plane_resource_id(), b->v_plane_resource_id());
205 EXPECT_EQ(a->a_plane_resource_id(), b->a_plane_resource_id());
[email protected]82faf5e2014-05-03 02:25:58206 EXPECT_EQ(a->color_space, b->color_space);
jbaumanaa35e3e2016-08-03 22:46:32207 EXPECT_EQ(a->bits_per_channel, b->bits_per_channel);
[email protected]4934d362012-11-22 22:04:53208 }
[email protected]bca159072012-12-04 00:52:44209
210 void Compare(const TransferableResource& a, const TransferableResource& b) {
211 EXPECT_EQ(a.id, b.id);
212 EXPECT_EQ(a.format, b.format);
[email protected]80189292013-02-28 01:59:36213 EXPECT_EQ(a.filter, b.filter);
[email protected]bca159072012-12-04 00:52:44214 EXPECT_EQ(a.size.ToString(), b.size.ToString());
[email protected]df41e252014-02-03 23:39:50215 for (size_t i = 0; i < arraysize(a.mailbox_holder.mailbox.name); ++i) {
216 EXPECT_EQ(a.mailbox_holder.mailbox.name[i],
217 b.mailbox_holder.mailbox.name[i]);
218 }
219 EXPECT_EQ(a.mailbox_holder.texture_target, b.mailbox_holder.texture_target);
dyencc16ed4d2015-11-03 20:03:04220 EXPECT_EQ(a.mailbox_holder.sync_token, b.mailbox_holder.sync_token);
ccameron268c09fd2015-10-08 20:23:46221 EXPECT_EQ(a.is_overlay_candidate, b.is_overlay_candidate);
liberato304dc192016-12-09 20:55:26222#if defined(OS_ANDROID)
223 EXPECT_EQ(a.is_backed_by_surface_texture, b.is_backed_by_surface_texture);
224 EXPECT_EQ(a.wants_promotion_hint, b.wants_promotion_hint);
225#endif
[email protected]bca159072012-12-04 00:52:44226 }
[email protected]4934d362012-11-22 22:04:53227};
228
fsamuelf76098e2016-05-18 17:26:51229TEST_F(CCParamTraitsTest, AllQuads) {
[email protected]753bb252013-11-04 22:28:12230 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
[email protected]4934d362012-11-22 22:04:53231
danakj112d3a102015-04-14 18:24:49232 Transform arbitrary_matrix1;
233 arbitrary_matrix1.Scale(3, 3);
234 arbitrary_matrix1.Translate(-5, 20);
235 arbitrary_matrix1.Rotate(15);
236 Transform arbitrary_matrix2;
237 arbitrary_matrix2.Scale(10, -1);
238 arbitrary_matrix2.Translate(20, 3);
239 arbitrary_matrix2.Rotate(24);
[email protected]4934d362012-11-22 22:04:53240 gfx::Rect arbitrary_rect1(-5, 9, 3, 15);
[email protected]8e1da692013-10-12 17:11:30241 gfx::Rect arbitrary_rect1_inside_rect1(-4, 12, 2, 8);
242 gfx::Rect arbitrary_rect2_inside_rect1(-5, 11, 1, 2);
[email protected]4934d362012-11-22 22:04:53243 gfx::Rect arbitrary_rect2(40, 23, 11, 7);
[email protected]8e1da692013-10-12 17:11:30244 gfx::Rect arbitrary_rect1_inside_rect2(44, 23, 4, 2);
245 gfx::Rect arbitrary_rect2_inside_rect2(41, 25, 3, 5);
[email protected]4934d362012-11-22 22:04:53246 gfx::Rect arbitrary_rect3(7, -53, 22, 19);
[email protected]8e1da692013-10-12 17:11:30247 gfx::Rect arbitrary_rect1_inside_rect3(10, -40, 6, 3);
248 gfx::Rect arbitrary_rect2_inside_rect3(12, -51, 5, 12);
[email protected]4934d362012-11-22 22:04:53249 gfx::Size arbitrary_size1(15, 19);
250 gfx::Size arbitrary_size2(3, 99);
251 gfx::Size arbitrary_size3(75, 1281);
252 gfx::RectF arbitrary_rectf1(4.2f, -922.1f, 15.6f, 29.5f);
revemanb71e3992015-05-12 23:01:51253 gfx::RectF arbitrary_rectf2(2.1f, -411.05f, 7.8f, 14.75f);
[email protected]4934d362012-11-22 22:04:53254 gfx::SizeF arbitrary_sizef1(15.2f, 104.6f);
[email protected]61df9d82013-01-30 02:32:42255 gfx::PointF arbitrary_pointf1(31.4f, 15.9f);
256 gfx::PointF arbitrary_pointf2(26.5f, -35.8f);
[email protected]7ac3d492014-08-08 21:25:32257 gfx::Vector2dF arbitrary_vector2df1(16.2f, -85.1f);
ennef6f3fbba42014-10-16 18:16:49258 gfx::Vector2dF arbitrary_vector2df2(-8.3f, 0.47f);
[email protected]4934d362012-11-22 22:04:53259 float arbitrary_float1 = 0.7f;
260 float arbitrary_float2 = 0.3f;
261 float arbitrary_float3 = 0.9f;
[email protected]61df9d82013-01-30 02:32:42262 float arbitrary_float_array[4] = {3.5f, 6.2f, 9.3f, 12.3f};
[email protected]4934d362012-11-22 22:04:53263 bool arbitrary_bool1 = true;
264 bool arbitrary_bool2 = false;
[email protected]61df9d82013-01-30 02:32:42265 bool arbitrary_bool3 = true;
jackhou10c9af42014-12-04 05:24:44266 bool arbitrary_bool4 = true;
achaulkf89f5942015-06-10 17:01:35267 bool arbitrary_bool5 = false;
jbauman0c1bf21132016-05-19 19:20:07268 bool arbitrary_bool6 = true;
[email protected]a9d4d4f2014-06-19 06:49:28269 int arbitrary_context_id1 = 12;
270 int arbitrary_context_id2 = 57;
271 int arbitrary_context_id3 = -503;
jbaumanaa35e3e2016-08-03 22:46:32272 int arbitrary_int = 13;
[email protected]4934d362012-11-22 22:04:53273 SkColor arbitrary_color = SkColorSetARGB(25, 36, 47, 58);
reedcc9c70f2016-11-22 04:26:01274 SkBlendMode arbitrary_blend_mode1 = SkBlendMode::kScreen;
275 SkBlendMode arbitrary_blend_mode2 = SkBlendMode::kLighten;
276 SkBlendMode arbitrary_blend_mode3 = SkBlendMode::kOverlay;
jbaumanbbd425e2015-05-19 00:33:35277 ResourceId arbitrary_resourceid1 = 55;
278 ResourceId arbitrary_resourceid2 = 47;
279 ResourceId arbitrary_resourceid3 = 23;
280 ResourceId arbitrary_resourceid4 = 16;
[email protected]a1765672013-08-12 23:45:02281 SkScalar arbitrary_sigma = SkFloatToScalar(2.0f);
ccameron625dae1e2017-02-13 23:44:44282 gfx::ColorSpace arbitrary_color_space = gfx::ColorSpace::CreateREC601();
283 YUVVideoDrawQuad::ColorSpace arbitrary_video_color_space =
[email protected]82faf5e2014-05-03 02:25:58284 YUVVideoDrawQuad::REC_601;
[email protected]4934d362012-11-22 22:04:53285
danakj880b80ed2016-12-07 01:27:01286 int child_id = 30;
287 int root_id = 14;
danakj112d3a102015-04-14 18:24:49288
[email protected]ae6b1a72013-06-25 18:49:29289 FilterOperations arbitrary_filters1;
[email protected]1dc7943e2013-09-26 04:41:48290 arbitrary_filters1.Append(
fsamuelf76098e2016-05-18 17:26:51291 FilterOperation::CreateGrayscaleFilter(arbitrary_float1));
292 arbitrary_filters1.Append(cc::FilterOperation::CreateReferenceFilter(
293 SkBlurImageFilter::Make(arbitrary_sigma, arbitrary_sigma, nullptr)));
[email protected]4934d362012-11-22 22:04:53294
[email protected]ae6b1a72013-06-25 18:49:29295 FilterOperations arbitrary_filters2;
fsamuelf76098e2016-05-18 17:26:51296 arbitrary_filters2.Append(
297 FilterOperation::CreateBrightnessFilter(arbitrary_float2));
[email protected]4934d362012-11-22 22:04:53298
dcheng4ac58c7a2016-04-09 04:51:48299 std::unique_ptr<RenderPass> child_pass_in = RenderPass::Create();
danakj112d3a102015-04-14 18:24:49300 child_pass_in->SetAll(child_id, arbitrary_rect2, arbitrary_rect3,
ajumaa26e58452016-12-15 22:35:01301 arbitrary_matrix2, arbitrary_filters1,
ccameron625dae1e2017-02-13 23:44:44302 arbitrary_filters2, arbitrary_color_space,
303 arbitrary_bool2);
danakj112d3a102015-04-14 18:24:49304
dcheng4ac58c7a2016-04-09 04:51:48305 std::unique_ptr<RenderPass> child_pass_cmp = RenderPass::Create();
danakj112d3a102015-04-14 18:24:49306 child_pass_cmp->SetAll(child_id, arbitrary_rect2, arbitrary_rect3,
ajumaa26e58452016-12-15 22:35:01307 arbitrary_matrix2, arbitrary_filters1,
ccameron625dae1e2017-02-13 23:44:44308 arbitrary_filters2, arbitrary_color_space,
309 arbitrary_bool2);
danakj112d3a102015-04-14 18:24:49310
dcheng4ac58c7a2016-04-09 04:51:48311 std::unique_ptr<RenderPass> pass_in = RenderPass::Create();
danakj112d3a102015-04-14 18:24:49312 pass_in->SetAll(root_id, arbitrary_rect1, arbitrary_rect2, arbitrary_matrix1,
ccameron625dae1e2017-02-13 23:44:44313 arbitrary_filters2, arbitrary_filters1, arbitrary_color_space,
314 arbitrary_bool1);
[email protected]2b7f3892014-05-08 01:45:18315
316 SharedQuadState* shared_state1_in = pass_in->CreateAndAppendSharedQuadState();
danakj112d3a102015-04-14 18:24:49317 shared_state1_in->SetAll(arbitrary_matrix1, arbitrary_size1, arbitrary_rect1,
318 arbitrary_rect2, arbitrary_bool1, arbitrary_float1,
319 arbitrary_blend_mode1, arbitrary_context_id1);
[email protected]2b7f3892014-05-08 01:45:18320
dcheng4ac58c7a2016-04-09 04:51:48321 std::unique_ptr<RenderPass> pass_cmp = RenderPass::Create();
danakj112d3a102015-04-14 18:24:49322 pass_cmp->SetAll(root_id, arbitrary_rect1, arbitrary_rect2, arbitrary_matrix1,
ccameron625dae1e2017-02-13 23:44:44323 arbitrary_filters2, arbitrary_filters1,
324 arbitrary_color_space, arbitrary_bool1);
[email protected]2b7f3892014-05-08 01:45:18325
326 SharedQuadState* shared_state1_cmp =
327 pass_cmp->CreateAndAppendSharedQuadState();
fsamuel95998762016-06-02 11:22:22328 *shared_state1_cmp = *shared_state1_in;
[email protected]4934d362012-11-22 22:04:53329
[email protected]3b85fd92014-07-10 00:00:02330 DebugBorderDrawQuad* debugborder_in =
331 pass_in->CreateAndAppendDrawQuad<DebugBorderDrawQuad>();
fsamuelf76098e2016-05-18 17:26:51332 debugborder_in->SetAll(shared_state1_in, arbitrary_rect3,
[email protected]8e1da692013-10-12 17:11:30333 arbitrary_rect1_inside_rect3,
fsamuelf76098e2016-05-18 17:26:51334 arbitrary_rect2_inside_rect3, arbitrary_bool1,
335 arbitrary_color, arbitrary_int);
[email protected]3b85fd92014-07-10 00:00:02336 pass_cmp->CopyFromAndAppendDrawQuad(debugborder_in,
337 debugborder_in->shared_quad_state);
[email protected]4934d362012-11-22 22:04:53338
[email protected]2b7f3892014-05-08 01:45:18339 SharedQuadState* shared_state2_in = pass_in->CreateAndAppendSharedQuadState();
danakj112d3a102015-04-14 18:24:49340 shared_state2_in->SetAll(arbitrary_matrix2, arbitrary_size2, arbitrary_rect2,
341 arbitrary_rect3, arbitrary_bool1, arbitrary_float2,
342 arbitrary_blend_mode2, arbitrary_context_id2);
[email protected]2b7f3892014-05-08 01:45:18343 SharedQuadState* shared_state2_cmp =
344 pass_cmp->CreateAndAppendSharedQuadState();
fsamuel95998762016-06-02 11:22:22345 *shared_state2_cmp = *shared_state2_in;
[email protected]cbe94b7a2013-11-13 11:03:37346
[email protected]3b85fd92014-07-10 00:00:02347 RenderPassDrawQuad* renderpass_in =
348 pass_in->CreateAndAppendDrawQuad<RenderPassDrawQuad>();
danakj112d3a102015-04-14 18:24:49349 renderpass_in->SetAll(
350 shared_state2_in, arbitrary_rect1, arbitrary_rect2_inside_rect1,
351 arbitrary_rect1_inside_rect1, arbitrary_bool1, child_id,
352 arbitrary_resourceid2, arbitrary_vector2df1, arbitrary_size1,
ajumaa26e58452016-12-15 22:35:01353 arbitrary_vector2df2, arbitrary_pointf2);
[email protected]3b85fd92014-07-10 00:00:02354 pass_cmp->CopyFromAndAppendRenderPassDrawQuad(
fsamuelf76098e2016-05-18 17:26:51355 renderpass_in, renderpass_in->shared_quad_state,
[email protected]3b85fd92014-07-10 00:00:02356 renderpass_in->render_pass_id);
[email protected]4934d362012-11-22 22:04:53357
[email protected]2b7f3892014-05-08 01:45:18358 SharedQuadState* shared_state3_in = pass_in->CreateAndAppendSharedQuadState();
danakj112d3a102015-04-14 18:24:49359 shared_state3_in->SetAll(arbitrary_matrix1, arbitrary_size3, arbitrary_rect3,
360 arbitrary_rect1, arbitrary_bool1, arbitrary_float3,
361 arbitrary_blend_mode3, arbitrary_context_id3);
[email protected]2b7f3892014-05-08 01:45:18362 SharedQuadState* shared_state3_cmp =
363 pass_cmp->CreateAndAppendSharedQuadState();
fsamuel95998762016-06-02 11:22:22364 *shared_state3_cmp = *shared_state3_in;
[email protected]4934d362012-11-22 22:04:53365
[email protected]3b85fd92014-07-10 00:00:02366 SolidColorDrawQuad* solidcolor_in =
367 pass_in->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
fsamuelf76098e2016-05-18 17:26:51368 solidcolor_in->SetAll(shared_state3_in, arbitrary_rect3,
[email protected]8e1da692013-10-12 17:11:30369 arbitrary_rect1_inside_rect3,
fsamuelf76098e2016-05-18 17:26:51370 arbitrary_rect2_inside_rect3, arbitrary_bool1,
371 arbitrary_color, arbitrary_bool2);
[email protected]3b85fd92014-07-10 00:00:02372 pass_cmp->CopyFromAndAppendDrawQuad(solidcolor_in,
373 solidcolor_in->shared_quad_state);
[email protected]4934d362012-11-22 22:04:53374
[email protected]3b85fd92014-07-10 00:00:02375 StreamVideoDrawQuad* streamvideo_in =
376 pass_in->CreateAndAppendDrawQuad<StreamVideoDrawQuad>();
achaulkf89f5942015-06-10 17:01:35377 streamvideo_in->SetAll(
378 shared_state3_in, arbitrary_rect2, arbitrary_rect2_inside_rect2,
379 arbitrary_rect1_inside_rect2, arbitrary_bool1, arbitrary_resourceid2,
ccameron268c09fd2015-10-08 20:23:46380 arbitrary_size1, arbitrary_matrix1);
[email protected]3b85fd92014-07-10 00:00:02381 pass_cmp->CopyFromAndAppendDrawQuad(streamvideo_in,
382 streamvideo_in->shared_quad_state);
[email protected]4934d362012-11-22 22:04:53383
staraz7d7f6eb2016-11-11 00:19:17384 cc::SurfaceId arbitrary_surface_id(
385 kArbitraryFrameSinkId,
samans5258bfb2017-01-27 21:16:26386 cc::LocalSurfaceId(3, base::UnguessableToken::Create()));
[email protected]3b85fd92014-07-10 00:00:02387 SurfaceDrawQuad* surface_in =
388 pass_in->CreateAndAppendDrawQuad<SurfaceDrawQuad>();
fsamuelf76098e2016-05-18 17:26:51389 surface_in->SetAll(shared_state3_in, arbitrary_rect2,
390 arbitrary_rect2_inside_rect2, arbitrary_rect1_inside_rect2,
391 arbitrary_bool1, arbitrary_surface_id);
[email protected]3b85fd92014-07-10 00:00:02392 pass_cmp->CopyFromAndAppendDrawQuad(surface_in,
393 surface_in->shared_quad_state);
[email protected]78d30122014-01-17 06:32:36394
[email protected]3b85fd92014-07-10 00:00:02395 TextureDrawQuad* texture_in =
396 pass_in->CreateAndAppendDrawQuad<TextureDrawQuad>();
jbauman0c1bf21132016-05-19 19:20:07397 texture_in->SetAll(shared_state3_in, arbitrary_rect2,
398 arbitrary_rect2_inside_rect2, arbitrary_rect1_inside_rect2,
399 arbitrary_bool1, arbitrary_resourceid1, arbitrary_size1,
400 arbitrary_bool2, arbitrary_pointf1, arbitrary_pointf2,
401 arbitrary_color, arbitrary_float_array, arbitrary_bool4,
402 arbitrary_bool5, arbitrary_bool6);
[email protected]3b85fd92014-07-10 00:00:02403 pass_cmp->CopyFromAndAppendDrawQuad(texture_in,
404 texture_in->shared_quad_state);
[email protected]61df9d82013-01-30 02:32:42405
[email protected]3b85fd92014-07-10 00:00:02406 TileDrawQuad* tile_in = pass_in->CreateAndAppendDrawQuad<TileDrawQuad>();
fsamuelf76098e2016-05-18 17:26:51407 tile_in->SetAll(shared_state3_in, arbitrary_rect2,
408 arbitrary_rect2_inside_rect2, arbitrary_rect1_inside_rect2,
409 arbitrary_bool1, arbitrary_resourceid3, arbitrary_rectf1,
410 arbitrary_size1, arbitrary_bool2, arbitrary_bool3);
[email protected]3b85fd92014-07-10 00:00:02411 pass_cmp->CopyFromAndAppendDrawQuad(tile_in, tile_in->shared_quad_state);
[email protected]61df9d82013-01-30 02:32:42412
[email protected]3b85fd92014-07-10 00:00:02413 YUVVideoDrawQuad* yuvvideo_in =
414 pass_in->CreateAndAppendDrawQuad<YUVVideoDrawQuad>();
revemanb71e3992015-05-12 23:01:51415 yuvvideo_in->SetAll(
416 shared_state3_in, arbitrary_rect1, arbitrary_rect2_inside_rect1,
417 arbitrary_rect1_inside_rect1, arbitrary_bool1, arbitrary_rectf1,
418 arbitrary_rectf2, arbitrary_size1, arbitrary_size2, arbitrary_resourceid1,
419 arbitrary_resourceid2, arbitrary_resourceid3, arbitrary_resourceid4,
ccameron625dae1e2017-02-13 23:44:44420 arbitrary_video_color_space, arbitrary_color_space, arbitrary_float1,
hubbeaf57af302016-08-11 10:42:32421 arbitrary_float2, arbitrary_int);
[email protected]3b85fd92014-07-10 00:00:02422 pass_cmp->CopyFromAndAppendDrawQuad(yuvvideo_in,
423 yuvvideo_in->shared_quad_state);
[email protected]4934d362012-11-22 22:04:53424
425 // Make sure the in and cmp RenderPasses match.
danakj112d3a102015-04-14 18:24:49426 Compare(child_pass_cmp.get(), child_pass_in.get());
427 ASSERT_EQ(0u, child_pass_in->shared_quad_state_list.size());
428 ASSERT_EQ(0u, child_pass_in->quad_list.size());
[email protected]4934d362012-11-22 22:04:53429 Compare(pass_cmp.get(), pass_in.get());
430 ASSERT_EQ(3u, pass_in->shared_quad_state_list.size());
ccameron648c9112016-05-18 23:44:07431 ASSERT_EQ(8u, pass_in->quad_list.size());
weiliangc808f70f2014-10-03 22:53:15432 for (cc::SharedQuadStateList::ConstIterator
433 cmp_iterator = pass_cmp->shared_quad_state_list.begin(),
434 in_iterator = pass_in->shared_quad_state_list.begin();
435 in_iterator != pass_in->shared_quad_state_list.end();
436 ++cmp_iterator, ++in_iterator) {
weiliangc48805fce2014-10-29 20:30:12437 Compare(*cmp_iterator, *in_iterator);
[email protected]4934d362012-11-22 22:04:53438 }
weiliangc7eb7ee62014-10-07 00:04:40439 for (auto in_iter = pass_in->quad_list.cbegin(),
440 cmp_iter = pass_cmp->quad_list.cbegin();
fsamuelf76098e2016-05-18 17:26:51441 in_iter != pass_in->quad_list.cend(); ++in_iter, ++cmp_iter)
weiliangc48805fce2014-10-29 20:30:12442 Compare(*cmp_iter, *in_iter);
weiliangc032e929d2014-09-26 01:55:01443
[email protected]61df9d82013-01-30 02:32:42444 for (size_t i = 1; i < pass_in->quad_list.size(); ++i) {
[email protected]4934d362012-11-22 22:04:53445 bool same_shared_quad_state_cmp =
weiliangc032e929d2014-09-26 01:55:01446 pass_cmp->quad_list.ElementAt(i)->shared_quad_state ==
447 pass_cmp->quad_list.ElementAt(i - 1)->shared_quad_state;
[email protected]4934d362012-11-22 22:04:53448 bool same_shared_quad_state_in =
weiliangc032e929d2014-09-26 01:55:01449 pass_in->quad_list.ElementAt(i)->shared_quad_state ==
450 pass_in->quad_list.ElementAt(i - 1)->shared_quad_state;
[email protected]4934d362012-11-22 22:04:53451 EXPECT_EQ(same_shared_quad_state_cmp, same_shared_quad_state_in);
452 }
453
samansce5c3c32016-11-18 13:47:34454 CompositorFrame frame_in;
dchengf63a1252015-12-26 20:43:13455 frame_in.render_pass_list.push_back(std::move(child_pass_in));
456 frame_in.render_pass_list.push_back(std::move(pass_in));
[email protected]4934d362012-11-22 22:04:53457
samansce5c3c32016-11-18 13:47:34458 IPC::ParamTraits<CompositorFrame>::Write(&msg, frame_in);
[email protected]bca159072012-12-04 00:52:44459
samansce5c3c32016-11-18 13:47:34460 CompositorFrame frame_out;
brettwbd4d7112015-06-03 04:29:25461 base::PickleIterator iter(msg);
samansce5c3c32016-11-18 13:47:34462 EXPECT_TRUE(IPC::ParamTraits<CompositorFrame>::Read(&msg, &iter, &frame_out));
[email protected]bca159072012-12-04 00:52:44463
[email protected]4934d362012-11-22 22:04:53464 // Make sure the out and cmp RenderPasses match.
dcheng4ac58c7a2016-04-09 04:51:48465 std::unique_ptr<RenderPass> child_pass_out =
dchengf63a1252015-12-26 20:43:13466 std::move(frame_out.render_pass_list[0]);
danakj112d3a102015-04-14 18:24:49467 Compare(child_pass_cmp.get(), child_pass_out.get());
468 ASSERT_EQ(0u, child_pass_out->shared_quad_state_list.size());
469 ASSERT_EQ(0u, child_pass_out->quad_list.size());
dcheng4ac58c7a2016-04-09 04:51:48470 std::unique_ptr<RenderPass> pass_out =
471 std::move(frame_out.render_pass_list[1]);
[email protected]4934d362012-11-22 22:04:53472 Compare(pass_cmp.get(), pass_out.get());
473 ASSERT_EQ(3u, pass_out->shared_quad_state_list.size());
ccameron648c9112016-05-18 23:44:07474 ASSERT_EQ(8u, pass_out->quad_list.size());
weiliangc808f70f2014-10-03 22:53:15475 for (cc::SharedQuadStateList::ConstIterator
476 cmp_iterator = pass_cmp->shared_quad_state_list.begin(),
477 out_iterator = pass_out->shared_quad_state_list.begin();
478 out_iterator != pass_out->shared_quad_state_list.end();
479 ++cmp_iterator, ++out_iterator) {
weiliangc48805fce2014-10-29 20:30:12480 Compare(*cmp_iterator, *out_iterator);
[email protected]4934d362012-11-22 22:04:53481 }
weiliangc7eb7ee62014-10-07 00:04:40482 for (auto out_iter = pass_out->quad_list.cbegin(),
483 cmp_iter = pass_cmp->quad_list.cbegin();
fsamuelf76098e2016-05-18 17:26:51484 out_iter != pass_out->quad_list.cend(); ++out_iter, ++cmp_iter)
weiliangc48805fce2014-10-29 20:30:12485 Compare(*cmp_iter, *out_iter);
weiliangc032e929d2014-09-26 01:55:01486
[email protected]61df9d82013-01-30 02:32:42487 for (size_t i = 1; i < pass_out->quad_list.size(); ++i) {
[email protected]4934d362012-11-22 22:04:53488 bool same_shared_quad_state_cmp =
weiliangc032e929d2014-09-26 01:55:01489 pass_cmp->quad_list.ElementAt(i)->shared_quad_state ==
490 pass_cmp->quad_list.ElementAt(i - 1)->shared_quad_state;
[email protected]4934d362012-11-22 22:04:53491 bool same_shared_quad_state_out =
weiliangc032e929d2014-09-26 01:55:01492 pass_out->quad_list.ElementAt(i)->shared_quad_state ==
493 pass_out->quad_list.ElementAt(i - 1)->shared_quad_state;
[email protected]4934d362012-11-22 22:04:53494 EXPECT_EQ(same_shared_quad_state_cmp, same_shared_quad_state_out);
495 }
496}
[email protected]bca159072012-12-04 00:52:44497
fsamuelf76098e2016-05-18 17:26:51498TEST_F(CCParamTraitsTest, UnusedSharedQuadStates) {
dcheng4ac58c7a2016-04-09 04:51:48499 std::unique_ptr<RenderPass> pass_in = RenderPass::Create();
ajumaa26e58452016-12-15 22:35:01500 pass_in->SetAll(1, gfx::Rect(100, 100), gfx::Rect(), gfx::Transform(),
ccameron625dae1e2017-02-13 23:44:44501 FilterOperations(), FilterOperations(),
502 gfx::ColorSpace::CreateSRGB(), false);
[email protected]cbe94b7a2013-11-13 11:03:37503
504 // The first SharedQuadState is used.
[email protected]2b7f3892014-05-08 01:45:18505 SharedQuadState* shared_state1_in = pass_in->CreateAndAppendSharedQuadState();
fsamuelf76098e2016-05-18 17:26:51506 shared_state1_in->SetAll(gfx::Transform(), gfx::Size(1, 1), gfx::Rect(),
reedcc9c70f2016-11-22 04:26:01507 gfx::Rect(), false, 1.f, SkBlendMode::kSrcOver, 0);
[email protected]cbe94b7a2013-11-13 11:03:37508
danakja8f1ac32015-08-05 18:46:57509 SolidColorDrawQuad* quad1 =
510 pass_in->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
danakje1419ce2015-03-04 21:26:27511 quad1->SetAll(shared_state1_in, gfx::Rect(10, 10), gfx::Rect(10, 10),
danakja8f1ac32015-08-05 18:46:57512 gfx::Rect(10, 10), false, SK_ColorRED, false);
[email protected]cbe94b7a2013-11-13 11:03:37513
514 // The second and third SharedQuadStates are not used.
[email protected]2b7f3892014-05-08 01:45:18515 SharedQuadState* shared_state2_in = pass_in->CreateAndAppendSharedQuadState();
fsamuelf76098e2016-05-18 17:26:51516 shared_state2_in->SetAll(gfx::Transform(), gfx::Size(2, 2), gfx::Rect(),
reedcc9c70f2016-11-22 04:26:01517 gfx::Rect(), false, 1.f, SkBlendMode::kSrcOver, 0);
[email protected]cbe94b7a2013-11-13 11:03:37518
[email protected]2b7f3892014-05-08 01:45:18519 SharedQuadState* shared_state3_in = pass_in->CreateAndAppendSharedQuadState();
fsamuelf76098e2016-05-18 17:26:51520 shared_state3_in->SetAll(gfx::Transform(), gfx::Size(3, 3), gfx::Rect(),
reedcc9c70f2016-11-22 04:26:01521 gfx::Rect(), false, 1.f, SkBlendMode::kSrcOver, 0);
[email protected]cbe94b7a2013-11-13 11:03:37522
523 // The fourth SharedQuadState is used.
[email protected]2b7f3892014-05-08 01:45:18524 SharedQuadState* shared_state4_in = pass_in->CreateAndAppendSharedQuadState();
fsamuelf76098e2016-05-18 17:26:51525 shared_state4_in->SetAll(gfx::Transform(), gfx::Size(4, 4), gfx::Rect(),
reedcc9c70f2016-11-22 04:26:01526 gfx::Rect(), false, 1.f, SkBlendMode::kSrcOver, 0);
[email protected]cbe94b7a2013-11-13 11:03:37527
danakja8f1ac32015-08-05 18:46:57528 SolidColorDrawQuad* quad2 =
529 pass_in->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
danakje1419ce2015-03-04 21:26:27530 quad2->SetAll(shared_state4_in, gfx::Rect(10, 10), gfx::Rect(10, 10),
danakja8f1ac32015-08-05 18:46:57531 gfx::Rect(10, 10), false, SK_ColorRED, false);
[email protected]cbe94b7a2013-11-13 11:03:37532
533 // The fifth is not used again.
[email protected]2b7f3892014-05-08 01:45:18534 SharedQuadState* shared_state5_in = pass_in->CreateAndAppendSharedQuadState();
fsamuelf76098e2016-05-18 17:26:51535 shared_state5_in->SetAll(gfx::Transform(), gfx::Size(5, 5), gfx::Rect(),
reedcc9c70f2016-11-22 04:26:01536 gfx::Rect(), false, 1.f, SkBlendMode::kSrcOver, 0);
[email protected]cbe94b7a2013-11-13 11:03:37537
[email protected]cbe94b7a2013-11-13 11:03:37538 // 5 SharedQuadStates go in.
539 ASSERT_EQ(5u, pass_in->shared_quad_state_list.size());
540 ASSERT_EQ(2u, pass_in->quad_list.size());
541
samansce5c3c32016-11-18 13:47:34542 CompositorFrame frame_in;
dchengf63a1252015-12-26 20:43:13543 frame_in.render_pass_list.push_back(std::move(pass_in));
[email protected]cbe94b7a2013-11-13 11:03:37544
545 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
samansce5c3c32016-11-18 13:47:34546 IPC::ParamTraits<CompositorFrame>::Write(&msg, frame_in);
[email protected]cbe94b7a2013-11-13 11:03:37547
samansce5c3c32016-11-18 13:47:34548 CompositorFrame frame_out;
brettwbd4d7112015-06-03 04:29:25549 base::PickleIterator iter(msg);
samansce5c3c32016-11-18 13:47:34550 EXPECT_TRUE(IPC::ParamTraits<CompositorFrame>::Read(&msg, &iter, &frame_out));
[email protected]cbe94b7a2013-11-13 11:03:37551
dcheng4ac58c7a2016-04-09 04:51:48552 std::unique_ptr<RenderPass> pass_out =
553 std::move(frame_out.render_pass_list[0]);
[email protected]cbe94b7a2013-11-13 11:03:37554
555 // 2 SharedQuadStates come out. The first and fourth SharedQuadStates were
556 // used by quads, and so serialized. Others were not.
557 ASSERT_EQ(2u, pass_out->shared_quad_state_list.size());
558 ASSERT_EQ(2u, pass_out->quad_list.size());
559
danakj64767d902015-06-19 00:10:43560 EXPECT_EQ(gfx::Size(1, 1).ToString(),
561 pass_out->shared_quad_state_list.ElementAt(0)
562 ->quad_layer_bounds.ToString());
563 EXPECT_EQ(gfx::Size(4, 4).ToString(),
564 pass_out->shared_quad_state_list.ElementAt(1)
565 ->quad_layer_bounds.ToString());
[email protected]cbe94b7a2013-11-13 11:03:37566}
567
fsamuelf76098e2016-05-18 17:26:51568TEST_F(CCParamTraitsTest, Resources) {
[email protected]753bb252013-11-04 22:28:12569 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
[email protected]bca159072012-12-04 00:52:44570 gfx::Size arbitrary_size(757, 1281);
lukasza2573ce7d2016-02-16 19:17:22571 gpu::SyncToken arbitrary_token1(gpu::CommandBufferNamespace::GPU_IO, 0,
572 gpu::CommandBufferId::FromUnsafeValue(0x123),
dyen398dd0142016-01-21 22:05:56573 71234838);
574 arbitrary_token1.SetVerifyFlush();
lukasza2573ce7d2016-02-16 19:17:22575 gpu::SyncToken arbitrary_token2(gpu::CommandBufferNamespace::GPU_IO, 0,
576 gpu::CommandBufferId::FromUnsafeValue(0x123),
dyen398dd0142016-01-21 22:05:56577 53589793);
578 arbitrary_token2.SetVerifyFlush();
[email protected]bca159072012-12-04 00:52:44579
[email protected]e0a4d732014-02-15 00:23:26580 GLbyte arbitrary_mailbox1[GL_MAILBOX_SIZE_CHROMIUM] = {
piman02b9c4e2016-11-01 00:25:18581 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6};
[email protected]bca159072012-12-04 00:52:44582
[email protected]e0a4d732014-02-15 00:23:26583 GLbyte arbitrary_mailbox2[GL_MAILBOX_SIZE_CHROMIUM] = {
piman02b9c4e2016-11-01 00:25:18584 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2};
[email protected]bca159072012-12-04 00:52:44585
586 TransferableResource arbitrary_resource1;
587 arbitrary_resource1.id = 2178312;
[email protected]27a41fe2013-09-19 05:05:14588 arbitrary_resource1.format = cc::RGBA_8888;
[email protected]80189292013-02-28 01:59:36589 arbitrary_resource1.filter = 53;
[email protected]bca159072012-12-04 00:52:44590 arbitrary_resource1.size = gfx::Size(37189, 123123);
[email protected]df41e252014-02-03 23:39:50591 arbitrary_resource1.mailbox_holder.mailbox.SetName(arbitrary_mailbox1);
592 arbitrary_resource1.mailbox_holder.texture_target = GL_TEXTURE_2D;
dyencc16ed4d2015-11-03 20:03:04593 arbitrary_resource1.mailbox_holder.sync_token = arbitrary_token1;
ccameron268c09fd2015-10-08 20:23:46594 arbitrary_resource1.is_overlay_candidate = true;
liberato304dc192016-12-09 20:55:26595#if defined(OS_ANDROID)
596 arbitrary_resource1.is_backed_by_surface_texture = true;
597 arbitrary_resource1.wants_promotion_hint = true;
598#endif
[email protected]bca159072012-12-04 00:52:44599
600 TransferableResource arbitrary_resource2;
601 arbitrary_resource2.id = 789132;
[email protected]27a41fe2013-09-19 05:05:14602 arbitrary_resource2.format = cc::RGBA_4444;
[email protected]645a47f22013-09-26 05:42:32603 arbitrary_resource2.filter = 47;
[email protected]bca159072012-12-04 00:52:44604 arbitrary_resource2.size = gfx::Size(89123, 23789);
[email protected]df41e252014-02-03 23:39:50605 arbitrary_resource2.mailbox_holder.mailbox.SetName(arbitrary_mailbox2);
606 arbitrary_resource2.mailbox_holder.texture_target = GL_TEXTURE_EXTERNAL_OES;
dyencc16ed4d2015-11-03 20:03:04607 arbitrary_resource2.mailbox_holder.sync_token = arbitrary_token2;
ccameron268c09fd2015-10-08 20:23:46608 arbitrary_resource2.is_overlay_candidate = false;
liberato304dc192016-12-09 20:55:26609#if defined(OS_ANDROID)
610 arbitrary_resource2.is_backed_by_surface_texture = false;
611 arbitrary_resource2.wants_promotion_hint = false;
612#endif
[email protected]bca159072012-12-04 00:52:44613
dcheng4ac58c7a2016-04-09 04:51:48614 std::unique_ptr<RenderPass> renderpass_in = RenderPass::Create();
danakj880b80ed2016-12-07 01:27:01615 renderpass_in->SetNew(1, gfx::Rect(), gfx::Rect(), gfx::Transform());
[email protected]cb7d6492013-10-03 02:40:04616
samansce5c3c32016-11-18 13:47:34617 CompositorFrame frame_in;
[email protected]09831f7f2013-02-27 03:32:15618 frame_in.resource_list.push_back(arbitrary_resource1);
619 frame_in.resource_list.push_back(arbitrary_resource2);
dchengf63a1252015-12-26 20:43:13620 frame_in.render_pass_list.push_back(std::move(renderpass_in));
[email protected]bca159072012-12-04 00:52:44621
samansce5c3c32016-11-18 13:47:34622 IPC::ParamTraits<CompositorFrame>::Write(&msg, frame_in);
[email protected]bca159072012-12-04 00:52:44623
samansce5c3c32016-11-18 13:47:34624 CompositorFrame frame_out;
brettwbd4d7112015-06-03 04:29:25625 base::PickleIterator iter(msg);
samansce5c3c32016-11-18 13:47:34626 EXPECT_TRUE(IPC::ParamTraits<CompositorFrame>::Read(&msg, &iter, &frame_out));
[email protected]bca159072012-12-04 00:52:44627
[email protected]09831f7f2013-02-27 03:32:15628 ASSERT_EQ(2u, frame_out.resource_list.size());
629 Compare(arbitrary_resource1, frame_out.resource_list[0]);
630 Compare(arbitrary_resource2, frame_out.resource_list[1]);
[email protected]bca159072012-12-04 00:52:44631}
632
633} // namespace
634} // namespace content