blob: 8886a1426cbc0ea8adf2af677d6fa3f51c08a6ef [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
[email protected]bf189f62012-12-18 03:42:1124using cc::DelegatedFrameData;
[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]4934d362012-11-22 22:04:5329using cc::IOSurfaceDrawQuad;
[email protected]9ee4d3a2013-03-27 17:43:1630using cc::PictureDrawQuad;
[email protected]4934d362012-11-22 22:04:5331using cc::RenderPass;
[email protected]0cd7d6f72014-08-22 14:50:5132using cc::RenderPassId;
[email protected]4934d362012-11-22 22:04:5333using cc::RenderPassDrawQuad;
jbaumanbbd425e2015-05-19 00:33:3534using cc::ResourceId;
[email protected]4934d362012-11-22 22:04:5335using cc::ResourceProvider;
36using cc::SharedQuadState;
37using cc::SolidColorDrawQuad;
[email protected]78d30122014-01-17 06:32:3638using cc::SurfaceDrawQuad;
[email protected]4934d362012-11-22 22:04:5339using cc::TextureDrawQuad;
40using cc::TileDrawQuad;
[email protected]bca159072012-12-04 00:52:4441using cc::TransferableResource;
[email protected]4934d362012-11-22 22:04:5342using cc::StreamVideoDrawQuad;
[email protected]4934d362012-11-22 22:04:5343using cc::YUVVideoDrawQuad;
[email protected]c8686a02012-11-27 08:29:0044using gfx::Transform;
[email protected]4934d362012-11-22 22:04:5345
[email protected]bca159072012-12-04 00:52:4446namespace content {
47namespace {
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);
56 EXPECT_EQ(a->has_transparent_background, b->has_transparent_background);
[email protected]4934d362012-11-22 22:04:5357 }
58
59 void Compare(const SharedQuadState* a, const SharedQuadState* b) {
danakj64767d902015-06-19 00:10:4360 EXPECT_EQ(a->quad_to_target_transform, b->quad_to_target_transform);
61 EXPECT_EQ(a->quad_layer_bounds, b->quad_layer_bounds);
62 EXPECT_EQ(a->visible_quad_layer_rect, b->visible_quad_layer_rect);
[email protected]4934d362012-11-22 22:04:5363 EXPECT_EQ(a->clip_rect, b->clip_rect);
64 EXPECT_EQ(a->is_clipped, b->is_clipped);
65 EXPECT_EQ(a->opacity, b->opacity);
[email protected]7bbeaf4e2013-11-26 10:27:2266 EXPECT_EQ(a->blend_mode, b->blend_mode);
[email protected]a9d4d4f2014-06-19 06:49:2867 EXPECT_EQ(a->sorting_context_id, b->sorting_context_id);
[email protected]4934d362012-11-22 22:04:5368 }
69
70 void Compare(const DrawQuad* a, const DrawQuad* b) {
71 ASSERT_NE(DrawQuad::INVALID, a->material);
72 ASSERT_EQ(a->material, b->material);
73 EXPECT_EQ(a->rect.ToString(), b->rect.ToString());
74 EXPECT_EQ(a->opaque_rect.ToString(), b->opaque_rect.ToString());
75 EXPECT_EQ(a->visible_rect.ToString(), b->visible_rect.ToString());
76 EXPECT_EQ(a->needs_blending, b->needs_blending);
77
78 Compare(a->shared_quad_state, b->shared_quad_state);
79
80 switch (a->material) {
[email protected]4934d362012-11-22 22:04:5381 case DrawQuad::DEBUG_BORDER:
82 Compare(DebugBorderDrawQuad::MaterialCast(a),
83 DebugBorderDrawQuad::MaterialCast(b));
84 break;
85 case DrawQuad::IO_SURFACE_CONTENT:
86 Compare(IOSurfaceDrawQuad::MaterialCast(a),
87 IOSurfaceDrawQuad::MaterialCast(b));
88 break;
[email protected]9ee4d3a2013-03-27 17:43:1689 case DrawQuad::PICTURE_CONTENT:
90 Compare(PictureDrawQuad::MaterialCast(a),
91 PictureDrawQuad::MaterialCast(b));
92 break;
[email protected]4934d362012-11-22 22:04:5393 case DrawQuad::RENDER_PASS:
94 Compare(RenderPassDrawQuad::MaterialCast(a),
95 RenderPassDrawQuad::MaterialCast(b));
96 break;
97 case DrawQuad::TEXTURE_CONTENT:
98 Compare(TextureDrawQuad::MaterialCast(a),
99 TextureDrawQuad::MaterialCast(b));
100 break;
101 case DrawQuad::TILED_CONTENT:
fsamuelf76098e2016-05-18 17:26:51102 Compare(TileDrawQuad::MaterialCast(a), TileDrawQuad::MaterialCast(b));
[email protected]4934d362012-11-22 22:04:53103 break;
104 case DrawQuad::SOLID_COLOR:
105 Compare(SolidColorDrawQuad::MaterialCast(a),
106 SolidColorDrawQuad::MaterialCast(b));
107 break;
108 case DrawQuad::STREAM_VIDEO_CONTENT:
109 Compare(StreamVideoDrawQuad::MaterialCast(a),
110 StreamVideoDrawQuad::MaterialCast(b));
111 break;
[email protected]78d30122014-01-17 06:32:36112 case DrawQuad::SURFACE_CONTENT:
113 Compare(SurfaceDrawQuad::MaterialCast(a),
114 SurfaceDrawQuad::MaterialCast(b));
115 break;
[email protected]4934d362012-11-22 22:04:53116 case DrawQuad::YUV_VIDEO_CONTENT:
117 Compare(YUVVideoDrawQuad::MaterialCast(a),
118 YUVVideoDrawQuad::MaterialCast(b));
119 break;
120 case DrawQuad::INVALID:
121 break;
122 }
123 }
124
[email protected]4934d362012-11-22 22:04:53125 void Compare(const DebugBorderDrawQuad* a, const DebugBorderDrawQuad* b) {
126 EXPECT_EQ(a->color, b->color);
127 EXPECT_EQ(a->width, b->width);
128 }
129
130 void Compare(const IOSurfaceDrawQuad* a, const IOSurfaceDrawQuad* b) {
131 EXPECT_EQ(a->io_surface_size.ToString(), b->io_surface_size.ToString());
vmpstr0eca2e82015-06-02 22:14:46132 EXPECT_EQ(a->io_surface_resource_id(), b->io_surface_resource_id());
[email protected]4934d362012-11-22 22:04:53133 EXPECT_EQ(a->orientation, b->orientation);
134 }
135
136 void Compare(const RenderPassDrawQuad* a, const RenderPassDrawQuad* b) {
[email protected]82f93fb2013-04-17 21:42:06137 EXPECT_EQ(a->render_pass_id, b->render_pass_id);
vmpstr0eca2e82015-06-02 22:14:46138 EXPECT_EQ(a->mask_resource_id(), b->mask_resource_id());
ennef6f3fbba42014-10-16 18:16:49139 EXPECT_EQ(a->mask_uv_scale.ToString(), b->mask_uv_scale.ToString());
140 EXPECT_EQ(a->mask_texture_size.ToString(), b->mask_texture_size.ToString());
[email protected]1dc7943e2013-09-26 04:41:48141 EXPECT_EQ(a->filters.size(), b->filters.size());
142 for (size_t i = 0; i < a->filters.size(); ++i) {
143 if (a->filters.at(i).type() != cc::FilterOperation::REFERENCE) {
144 EXPECT_EQ(a->filters.at(i), b->filters.at(i));
145 } else {
146 EXPECT_EQ(b->filters.at(i).type(), cc::FilterOperation::REFERENCE);
147 EXPECT_EQ(a->filters.at(i).image_filter()->countInputs(),
148 b->filters.at(i).image_filter()->countInputs());
149 }
150 }
[email protected]7ac3d492014-08-08 21:25:32151 EXPECT_EQ(a->filters_scale, b->filters_scale);
[email protected]20062042012-12-21 22:16:36152 EXPECT_EQ(a->background_filters, b->background_filters);
[email protected]4934d362012-11-22 22:04:53153 }
154
155 void Compare(const SolidColorDrawQuad* a, const SolidColorDrawQuad* b) {
156 EXPECT_EQ(a->color, b->color);
[email protected]10a30b12013-05-02 16:42:11157 EXPECT_EQ(a->force_anti_aliasing_off, b->force_anti_aliasing_off);
[email protected]4934d362012-11-22 22:04:53158 }
159
160 void Compare(const StreamVideoDrawQuad* a, const StreamVideoDrawQuad* b) {
vmpstr0eca2e82015-06-02 22:14:46161 EXPECT_EQ(a->resource_id(), b->resource_id());
achaulkf89f5942015-06-10 17:01:35162 EXPECT_EQ(a->resource_size_in_pixels(), b->resource_size_in_pixels());
[email protected]4934d362012-11-22 22:04:53163 EXPECT_EQ(a->matrix, b->matrix);
164 }
165
[email protected]78d30122014-01-17 06:32:36166 void Compare(const SurfaceDrawQuad* a, const SurfaceDrawQuad* b) {
167 EXPECT_EQ(a->surface_id, b->surface_id);
168 }
169
[email protected]4934d362012-11-22 22:04:53170 void Compare(const TextureDrawQuad* a, const TextureDrawQuad* b) {
vmpstr0eca2e82015-06-02 22:14:46171 EXPECT_EQ(a->resource_id(), b->resource_id());
achaulkf89f5942015-06-10 17:01:35172 EXPECT_EQ(a->resource_size_in_pixels(), b->resource_size_in_pixels());
[email protected]4934d362012-11-22 22:04:53173 EXPECT_EQ(a->premultiplied_alpha, b->premultiplied_alpha);
[email protected]1fd555b2013-01-18 00:13:21174 EXPECT_EQ(a->uv_top_left, b->uv_top_left);
175 EXPECT_EQ(a->uv_bottom_right, b->uv_bottom_right);
[email protected]d18b4d62013-07-12 05:33:49176 EXPECT_EQ(a->background_color, b->background_color);
[email protected]61df9d82013-01-30 02:32:42177 EXPECT_EQ(a->vertex_opacity[0], b->vertex_opacity[0]);
178 EXPECT_EQ(a->vertex_opacity[1], b->vertex_opacity[1]);
179 EXPECT_EQ(a->vertex_opacity[2], b->vertex_opacity[2]);
180 EXPECT_EQ(a->vertex_opacity[3], b->vertex_opacity[3]);
halliwellaa111282015-05-13 21:58:43181 EXPECT_EQ(a->y_flipped, b->y_flipped);
jackhou10c9af42014-12-04 05:24:44182 EXPECT_EQ(a->nearest_neighbor, b->nearest_neighbor);
[email protected]4934d362012-11-22 22:04:53183 }
184
185 void Compare(const TileDrawQuad* a, const TileDrawQuad* b) {
vmpstr0eca2e82015-06-02 22:14:46186 EXPECT_EQ(a->resource_id(), b->resource_id());
[email protected]4934d362012-11-22 22:04:53187 EXPECT_EQ(a->tex_coord_rect, b->tex_coord_rect);
188 EXPECT_EQ(a->texture_size, b->texture_size);
189 EXPECT_EQ(a->swizzle_contents, b->swizzle_contents);
jackhou24229612014-12-13 23:41:00190 EXPECT_EQ(a->nearest_neighbor, b->nearest_neighbor);
[email protected]4934d362012-11-22 22:04:53191 }
192
193 void Compare(const YUVVideoDrawQuad* a, const YUVVideoDrawQuad* b) {
revemanb71e3992015-05-12 23:01:51194 EXPECT_EQ(a->ya_tex_coord_rect, b->ya_tex_coord_rect);
195 EXPECT_EQ(a->uv_tex_coord_rect, b->uv_tex_coord_rect);
magjed7364ff92015-03-27 09:11:08196 EXPECT_EQ(a->ya_tex_size, b->ya_tex_size);
197 EXPECT_EQ(a->uv_tex_size, b->uv_tex_size);
vmpstr0eca2e82015-06-02 22:14:46198 EXPECT_EQ(a->y_plane_resource_id(), b->y_plane_resource_id());
199 EXPECT_EQ(a->u_plane_resource_id(), b->u_plane_resource_id());
200 EXPECT_EQ(a->v_plane_resource_id(), b->v_plane_resource_id());
201 EXPECT_EQ(a->a_plane_resource_id(), b->a_plane_resource_id());
[email protected]82faf5e2014-05-03 02:25:58202 EXPECT_EQ(a->color_space, b->color_space);
[email protected]4934d362012-11-22 22:04:53203 }
[email protected]bca159072012-12-04 00:52:44204
205 void Compare(const TransferableResource& a, const TransferableResource& b) {
206 EXPECT_EQ(a.id, b.id);
207 EXPECT_EQ(a.format, b.format);
[email protected]80189292013-02-28 01:59:36208 EXPECT_EQ(a.filter, b.filter);
[email protected]bca159072012-12-04 00:52:44209 EXPECT_EQ(a.size.ToString(), b.size.ToString());
[email protected]df41e252014-02-03 23:39:50210 for (size_t i = 0; i < arraysize(a.mailbox_holder.mailbox.name); ++i) {
211 EXPECT_EQ(a.mailbox_holder.mailbox.name[i],
212 b.mailbox_holder.mailbox.name[i]);
213 }
214 EXPECT_EQ(a.mailbox_holder.texture_target, b.mailbox_holder.texture_target);
dyencc16ed4d2015-11-03 20:03:04215 EXPECT_EQ(a.mailbox_holder.sync_token, b.mailbox_holder.sync_token);
ccameron268c09fd2015-10-08 20:23:46216 EXPECT_EQ(a.is_overlay_candidate, b.is_overlay_candidate);
[email protected]bca159072012-12-04 00:52:44217 }
[email protected]4934d362012-11-22 22:04:53218};
219
fsamuelf76098e2016-05-18 17:26:51220TEST_F(CCParamTraitsTest, AllQuads) {
[email protected]753bb252013-11-04 22:28:12221 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
[email protected]4934d362012-11-22 22:04:53222
danakj112d3a102015-04-14 18:24:49223 Transform arbitrary_matrix1;
224 arbitrary_matrix1.Scale(3, 3);
225 arbitrary_matrix1.Translate(-5, 20);
226 arbitrary_matrix1.Rotate(15);
227 Transform arbitrary_matrix2;
228 arbitrary_matrix2.Scale(10, -1);
229 arbitrary_matrix2.Translate(20, 3);
230 arbitrary_matrix2.Rotate(24);
[email protected]4934d362012-11-22 22:04:53231 gfx::Rect arbitrary_rect1(-5, 9, 3, 15);
[email protected]8e1da692013-10-12 17:11:30232 gfx::Rect arbitrary_rect1_inside_rect1(-4, 12, 2, 8);
233 gfx::Rect arbitrary_rect2_inside_rect1(-5, 11, 1, 2);
[email protected]4934d362012-11-22 22:04:53234 gfx::Rect arbitrary_rect2(40, 23, 11, 7);
[email protected]8e1da692013-10-12 17:11:30235 gfx::Rect arbitrary_rect1_inside_rect2(44, 23, 4, 2);
236 gfx::Rect arbitrary_rect2_inside_rect2(41, 25, 3, 5);
[email protected]4934d362012-11-22 22:04:53237 gfx::Rect arbitrary_rect3(7, -53, 22, 19);
[email protected]8e1da692013-10-12 17:11:30238 gfx::Rect arbitrary_rect1_inside_rect3(10, -40, 6, 3);
239 gfx::Rect arbitrary_rect2_inside_rect3(12, -51, 5, 12);
[email protected]4934d362012-11-22 22:04:53240 gfx::Size arbitrary_size1(15, 19);
241 gfx::Size arbitrary_size2(3, 99);
242 gfx::Size arbitrary_size3(75, 1281);
243 gfx::RectF arbitrary_rectf1(4.2f, -922.1f, 15.6f, 29.5f);
revemanb71e3992015-05-12 23:01:51244 gfx::RectF arbitrary_rectf2(2.1f, -411.05f, 7.8f, 14.75f);
[email protected]4934d362012-11-22 22:04:53245 gfx::SizeF arbitrary_sizef1(15.2f, 104.6f);
[email protected]61df9d82013-01-30 02:32:42246 gfx::PointF arbitrary_pointf1(31.4f, 15.9f);
247 gfx::PointF arbitrary_pointf2(26.5f, -35.8f);
[email protected]7ac3d492014-08-08 21:25:32248 gfx::Vector2dF arbitrary_vector2df1(16.2f, -85.1f);
ennef6f3fbba42014-10-16 18:16:49249 gfx::Vector2dF arbitrary_vector2df2(-8.3f, 0.47f);
[email protected]4934d362012-11-22 22:04:53250 float arbitrary_float1 = 0.7f;
251 float arbitrary_float2 = 0.3f;
252 float arbitrary_float3 = 0.9f;
[email protected]61df9d82013-01-30 02:32:42253 float arbitrary_float_array[4] = {3.5f, 6.2f, 9.3f, 12.3f};
[email protected]4934d362012-11-22 22:04:53254 bool arbitrary_bool1 = true;
255 bool arbitrary_bool2 = false;
[email protected]61df9d82013-01-30 02:32:42256 bool arbitrary_bool3 = true;
jackhou10c9af42014-12-04 05:24:44257 bool arbitrary_bool4 = true;
achaulkf89f5942015-06-10 17:01:35258 bool arbitrary_bool5 = false;
[email protected]a9d4d4f2014-06-19 06:49:28259 int arbitrary_context_id1 = 12;
260 int arbitrary_context_id2 = 57;
261 int arbitrary_context_id3 = -503;
[email protected]4934d362012-11-22 22:04:53262 int arbitrary_int = 5;
263 SkColor arbitrary_color = SkColorSetARGB(25, 36, 47, 58);
[email protected]7bbeaf4e2013-11-26 10:27:22264 SkXfermode::Mode arbitrary_blend_mode1 = SkXfermode::kScreen_Mode;
265 SkXfermode::Mode arbitrary_blend_mode2 = SkXfermode::kLighten_Mode;
266 SkXfermode::Mode arbitrary_blend_mode3 = SkXfermode::kOverlay_Mode;
[email protected]4934d362012-11-22 22:04:53267 IOSurfaceDrawQuad::Orientation arbitrary_orientation =
268 IOSurfaceDrawQuad::UNFLIPPED;
jbaumanbbd425e2015-05-19 00:33:35269 ResourceId arbitrary_resourceid1 = 55;
270 ResourceId arbitrary_resourceid2 = 47;
271 ResourceId arbitrary_resourceid3 = 23;
272 ResourceId arbitrary_resourceid4 = 16;
[email protected]a1765672013-08-12 23:45:02273 SkScalar arbitrary_sigma = SkFloatToScalar(2.0f);
[email protected]82faf5e2014-05-03 02:25:58274 YUVVideoDrawQuad::ColorSpace arbitrary_color_space =
275 YUVVideoDrawQuad::REC_601;
[email protected]4934d362012-11-22 22:04:53276
danakj112d3a102015-04-14 18:24:49277 RenderPassId child_id(30, 5);
278 RenderPassId root_id(10, 14);
279
[email protected]ae6b1a72013-06-25 18:49:29280 FilterOperations arbitrary_filters1;
[email protected]1dc7943e2013-09-26 04:41:48281 arbitrary_filters1.Append(
fsamuelf76098e2016-05-18 17:26:51282 FilterOperation::CreateGrayscaleFilter(arbitrary_float1));
283 arbitrary_filters1.Append(cc::FilterOperation::CreateReferenceFilter(
284 SkBlurImageFilter::Make(arbitrary_sigma, arbitrary_sigma, nullptr)));
[email protected]4934d362012-11-22 22:04:53285
[email protected]ae6b1a72013-06-25 18:49:29286 FilterOperations arbitrary_filters2;
fsamuelf76098e2016-05-18 17:26:51287 arbitrary_filters2.Append(
288 FilterOperation::CreateBrightnessFilter(arbitrary_float2));
[email protected]4934d362012-11-22 22:04:53289
dcheng4ac58c7a2016-04-09 04:51:48290 std::unique_ptr<RenderPass> child_pass_in = RenderPass::Create();
danakj112d3a102015-04-14 18:24:49291 child_pass_in->SetAll(child_id, arbitrary_rect2, arbitrary_rect3,
292 arbitrary_matrix2, arbitrary_bool2);
293
dcheng4ac58c7a2016-04-09 04:51:48294 std::unique_ptr<RenderPass> child_pass_cmp = RenderPass::Create();
danakj112d3a102015-04-14 18:24:49295 child_pass_cmp->SetAll(child_id, arbitrary_rect2, arbitrary_rect3,
296 arbitrary_matrix2, arbitrary_bool2);
297
dcheng4ac58c7a2016-04-09 04:51:48298 std::unique_ptr<RenderPass> pass_in = RenderPass::Create();
danakj112d3a102015-04-14 18:24:49299 pass_in->SetAll(root_id, arbitrary_rect1, arbitrary_rect2, arbitrary_matrix1,
[email protected]2b7f3892014-05-08 01:45:18300 arbitrary_bool1);
301
302 SharedQuadState* shared_state1_in = pass_in->CreateAndAppendSharedQuadState();
danakj112d3a102015-04-14 18:24:49303 shared_state1_in->SetAll(arbitrary_matrix1, arbitrary_size1, arbitrary_rect1,
304 arbitrary_rect2, arbitrary_bool1, arbitrary_float1,
305 arbitrary_blend_mode1, arbitrary_context_id1);
[email protected]2b7f3892014-05-08 01:45:18306
dcheng4ac58c7a2016-04-09 04:51:48307 std::unique_ptr<RenderPass> pass_cmp = RenderPass::Create();
danakj112d3a102015-04-14 18:24:49308 pass_cmp->SetAll(root_id, arbitrary_rect1, arbitrary_rect2, arbitrary_matrix1,
[email protected]2b7f3892014-05-08 01:45:18309 arbitrary_bool1);
310
311 SharedQuadState* shared_state1_cmp =
312 pass_cmp->CreateAndAppendSharedQuadState();
313 shared_state1_cmp->CopyFrom(shared_state1_in);
[email protected]4934d362012-11-22 22:04:53314
[email protected]3b85fd92014-07-10 00:00:02315 DebugBorderDrawQuad* debugborder_in =
316 pass_in->CreateAndAppendDrawQuad<DebugBorderDrawQuad>();
fsamuelf76098e2016-05-18 17:26:51317 debugborder_in->SetAll(shared_state1_in, arbitrary_rect3,
[email protected]8e1da692013-10-12 17:11:30318 arbitrary_rect1_inside_rect3,
fsamuelf76098e2016-05-18 17:26:51319 arbitrary_rect2_inside_rect3, arbitrary_bool1,
320 arbitrary_color, arbitrary_int);
[email protected]3b85fd92014-07-10 00:00:02321 pass_cmp->CopyFromAndAppendDrawQuad(debugborder_in,
322 debugborder_in->shared_quad_state);
[email protected]4934d362012-11-22 22:04:53323
[email protected]3b85fd92014-07-10 00:00:02324 IOSurfaceDrawQuad* iosurface_in =
325 pass_in->CreateAndAppendDrawQuad<IOSurfaceDrawQuad>();
fsamuelf76098e2016-05-18 17:26:51326 iosurface_in->SetAll(
327 shared_state1_in, arbitrary_rect2, arbitrary_rect2_inside_rect2,
328 arbitrary_rect1_inside_rect2, arbitrary_bool1, arbitrary_size1,
329 arbitrary_resourceid3, arbitrary_orientation);
[email protected]3b85fd92014-07-10 00:00:02330 pass_cmp->CopyFromAndAppendDrawQuad(iosurface_in,
331 iosurface_in->shared_quad_state);
[email protected]4934d362012-11-22 22:04:53332
[email protected]2b7f3892014-05-08 01:45:18333 SharedQuadState* shared_state2_in = pass_in->CreateAndAppendSharedQuadState();
danakj112d3a102015-04-14 18:24:49334 shared_state2_in->SetAll(arbitrary_matrix2, arbitrary_size2, arbitrary_rect2,
335 arbitrary_rect3, arbitrary_bool1, arbitrary_float2,
336 arbitrary_blend_mode2, arbitrary_context_id2);
[email protected]2b7f3892014-05-08 01:45:18337 SharedQuadState* shared_state2_cmp =
338 pass_cmp->CreateAndAppendSharedQuadState();
339 shared_state2_cmp->CopyFrom(shared_state2_in);
[email protected]cbe94b7a2013-11-13 11:03:37340
[email protected]3b85fd92014-07-10 00:00:02341 RenderPassDrawQuad* renderpass_in =
342 pass_in->CreateAndAppendDrawQuad<RenderPassDrawQuad>();
danakj112d3a102015-04-14 18:24:49343 renderpass_in->SetAll(
344 shared_state2_in, arbitrary_rect1, arbitrary_rect2_inside_rect1,
345 arbitrary_rect1_inside_rect1, arbitrary_bool1, child_id,
346 arbitrary_resourceid2, arbitrary_vector2df1, arbitrary_size1,
347 arbitrary_filters1, arbitrary_vector2df2, arbitrary_filters2);
[email protected]3b85fd92014-07-10 00:00:02348 pass_cmp->CopyFromAndAppendRenderPassDrawQuad(
fsamuelf76098e2016-05-18 17:26:51349 renderpass_in, renderpass_in->shared_quad_state,
[email protected]3b85fd92014-07-10 00:00:02350 renderpass_in->render_pass_id);
[email protected]4934d362012-11-22 22:04:53351
[email protected]2b7f3892014-05-08 01:45:18352 SharedQuadState* shared_state3_in = pass_in->CreateAndAppendSharedQuadState();
danakj112d3a102015-04-14 18:24:49353 shared_state3_in->SetAll(arbitrary_matrix1, arbitrary_size3, arbitrary_rect3,
354 arbitrary_rect1, arbitrary_bool1, arbitrary_float3,
355 arbitrary_blend_mode3, arbitrary_context_id3);
[email protected]2b7f3892014-05-08 01:45:18356 SharedQuadState* shared_state3_cmp =
357 pass_cmp->CreateAndAppendSharedQuadState();
358 shared_state3_cmp->CopyFrom(shared_state3_in);
[email protected]4934d362012-11-22 22:04:53359
[email protected]3b85fd92014-07-10 00:00:02360 SolidColorDrawQuad* solidcolor_in =
361 pass_in->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
fsamuelf76098e2016-05-18 17:26:51362 solidcolor_in->SetAll(shared_state3_in, arbitrary_rect3,
[email protected]8e1da692013-10-12 17:11:30363 arbitrary_rect1_inside_rect3,
fsamuelf76098e2016-05-18 17:26:51364 arbitrary_rect2_inside_rect3, arbitrary_bool1,
365 arbitrary_color, arbitrary_bool2);
[email protected]3b85fd92014-07-10 00:00:02366 pass_cmp->CopyFromAndAppendDrawQuad(solidcolor_in,
367 solidcolor_in->shared_quad_state);
[email protected]4934d362012-11-22 22:04:53368
[email protected]3b85fd92014-07-10 00:00:02369 StreamVideoDrawQuad* streamvideo_in =
370 pass_in->CreateAndAppendDrawQuad<StreamVideoDrawQuad>();
achaulkf89f5942015-06-10 17:01:35371 streamvideo_in->SetAll(
372 shared_state3_in, arbitrary_rect2, arbitrary_rect2_inside_rect2,
373 arbitrary_rect1_inside_rect2, arbitrary_bool1, arbitrary_resourceid2,
ccameron268c09fd2015-10-08 20:23:46374 arbitrary_size1, arbitrary_matrix1);
[email protected]3b85fd92014-07-10 00:00:02375 pass_cmp->CopyFromAndAppendDrawQuad(streamvideo_in,
376 streamvideo_in->shared_quad_state);
[email protected]4934d362012-11-22 22:04:53377
[email protected]16a6af152014-06-13 04:20:16378 cc::SurfaceId arbitrary_surface_id(3);
[email protected]3b85fd92014-07-10 00:00:02379 SurfaceDrawQuad* surface_in =
380 pass_in->CreateAndAppendDrawQuad<SurfaceDrawQuad>();
fsamuelf76098e2016-05-18 17:26:51381 surface_in->SetAll(shared_state3_in, arbitrary_rect2,
382 arbitrary_rect2_inside_rect2, arbitrary_rect1_inside_rect2,
383 arbitrary_bool1, arbitrary_surface_id);
[email protected]3b85fd92014-07-10 00:00:02384 pass_cmp->CopyFromAndAppendDrawQuad(surface_in,
385 surface_in->shared_quad_state);
[email protected]78d30122014-01-17 06:32:36386
[email protected]3b85fd92014-07-10 00:00:02387 TextureDrawQuad* texture_in =
388 pass_in->CreateAndAppendDrawQuad<TextureDrawQuad>();
fsamuelf76098e2016-05-18 17:26:51389 texture_in->SetAll(
390 shared_state3_in, arbitrary_rect2, arbitrary_rect2_inside_rect2,
391 arbitrary_rect1_inside_rect2, arbitrary_bool1, arbitrary_resourceid1,
392 arbitrary_size1, arbitrary_bool2, arbitrary_pointf1, arbitrary_pointf2,
393 arbitrary_color, arbitrary_float_array, arbitrary_bool4, arbitrary_bool5);
[email protected]3b85fd92014-07-10 00:00:02394 pass_cmp->CopyFromAndAppendDrawQuad(texture_in,
395 texture_in->shared_quad_state);
[email protected]61df9d82013-01-30 02:32:42396
[email protected]3b85fd92014-07-10 00:00:02397 TileDrawQuad* tile_in = pass_in->CreateAndAppendDrawQuad<TileDrawQuad>();
fsamuelf76098e2016-05-18 17:26:51398 tile_in->SetAll(shared_state3_in, arbitrary_rect2,
399 arbitrary_rect2_inside_rect2, arbitrary_rect1_inside_rect2,
400 arbitrary_bool1, arbitrary_resourceid3, arbitrary_rectf1,
401 arbitrary_size1, arbitrary_bool2, arbitrary_bool3);
[email protected]3b85fd92014-07-10 00:00:02402 pass_cmp->CopyFromAndAppendDrawQuad(tile_in, tile_in->shared_quad_state);
[email protected]61df9d82013-01-30 02:32:42403
[email protected]3b85fd92014-07-10 00:00:02404 YUVVideoDrawQuad* yuvvideo_in =
405 pass_in->CreateAndAppendDrawQuad<YUVVideoDrawQuad>();
revemanb71e3992015-05-12 23:01:51406 yuvvideo_in->SetAll(
407 shared_state3_in, arbitrary_rect1, arbitrary_rect2_inside_rect1,
408 arbitrary_rect1_inside_rect1, arbitrary_bool1, arbitrary_rectf1,
409 arbitrary_rectf2, arbitrary_size1, arbitrary_size2, arbitrary_resourceid1,
410 arbitrary_resourceid2, arbitrary_resourceid3, arbitrary_resourceid4,
hubbe82ba0a12016-02-09 00:01:14411 arbitrary_color_space, arbitrary_float1, arbitrary_float2);
[email protected]3b85fd92014-07-10 00:00:02412 pass_cmp->CopyFromAndAppendDrawQuad(yuvvideo_in,
413 yuvvideo_in->shared_quad_state);
[email protected]4934d362012-11-22 22:04:53414
415 // Make sure the in and cmp RenderPasses match.
danakj112d3a102015-04-14 18:24:49416 Compare(child_pass_cmp.get(), child_pass_in.get());
417 ASSERT_EQ(0u, child_pass_in->shared_quad_state_list.size());
418 ASSERT_EQ(0u, child_pass_in->quad_list.size());
[email protected]4934d362012-11-22 22:04:53419 Compare(pass_cmp.get(), pass_in.get());
420 ASSERT_EQ(3u, pass_in->shared_quad_state_list.size());
danakja8f1ac32015-08-05 18:46:57421 ASSERT_EQ(9u, pass_in->quad_list.size());
weiliangc808f70f2014-10-03 22:53:15422 for (cc::SharedQuadStateList::ConstIterator
423 cmp_iterator = pass_cmp->shared_quad_state_list.begin(),
424 in_iterator = pass_in->shared_quad_state_list.begin();
425 in_iterator != pass_in->shared_quad_state_list.end();
426 ++cmp_iterator, ++in_iterator) {
weiliangc48805fce2014-10-29 20:30:12427 Compare(*cmp_iterator, *in_iterator);
[email protected]4934d362012-11-22 22:04:53428 }
weiliangc7eb7ee62014-10-07 00:04:40429 for (auto in_iter = pass_in->quad_list.cbegin(),
430 cmp_iter = pass_cmp->quad_list.cbegin();
fsamuelf76098e2016-05-18 17:26:51431 in_iter != pass_in->quad_list.cend(); ++in_iter, ++cmp_iter)
weiliangc48805fce2014-10-29 20:30:12432 Compare(*cmp_iter, *in_iter);
weiliangc032e929d2014-09-26 01:55:01433
[email protected]61df9d82013-01-30 02:32:42434 for (size_t i = 1; i < pass_in->quad_list.size(); ++i) {
[email protected]4934d362012-11-22 22:04:53435 bool same_shared_quad_state_cmp =
weiliangc032e929d2014-09-26 01:55:01436 pass_cmp->quad_list.ElementAt(i)->shared_quad_state ==
437 pass_cmp->quad_list.ElementAt(i - 1)->shared_quad_state;
[email protected]4934d362012-11-22 22:04:53438 bool same_shared_quad_state_in =
weiliangc032e929d2014-09-26 01:55:01439 pass_in->quad_list.ElementAt(i)->shared_quad_state ==
440 pass_in->quad_list.ElementAt(i - 1)->shared_quad_state;
[email protected]4934d362012-11-22 22:04:53441 EXPECT_EQ(same_shared_quad_state_cmp, same_shared_quad_state_in);
442 }
443
[email protected]bf189f62012-12-18 03:42:11444 DelegatedFrameData frame_in;
dchengf63a1252015-12-26 20:43:13445 frame_in.render_pass_list.push_back(std::move(child_pass_in));
446 frame_in.render_pass_list.push_back(std::move(pass_in));
[email protected]4934d362012-11-22 22:04:53447
[email protected]bf189f62012-12-18 03:42:11448 IPC::ParamTraits<DelegatedFrameData>::Write(&msg, frame_in);
[email protected]bca159072012-12-04 00:52:44449
[email protected]bf189f62012-12-18 03:42:11450 DelegatedFrameData frame_out;
brettwbd4d7112015-06-03 04:29:25451 base::PickleIterator iter(msg);
fsamuelf76098e2016-05-18 17:26:51452 EXPECT_TRUE(
453 IPC::ParamTraits<DelegatedFrameData>::Read(&msg, &iter, &frame_out));
[email protected]bca159072012-12-04 00:52:44454
[email protected]4934d362012-11-22 22:04:53455 // Make sure the out and cmp RenderPasses match.
dcheng4ac58c7a2016-04-09 04:51:48456 std::unique_ptr<RenderPass> child_pass_out =
dchengf63a1252015-12-26 20:43:13457 std::move(frame_out.render_pass_list[0]);
danakj112d3a102015-04-14 18:24:49458 Compare(child_pass_cmp.get(), child_pass_out.get());
459 ASSERT_EQ(0u, child_pass_out->shared_quad_state_list.size());
460 ASSERT_EQ(0u, child_pass_out->quad_list.size());
dcheng4ac58c7a2016-04-09 04:51:48461 std::unique_ptr<RenderPass> pass_out =
462 std::move(frame_out.render_pass_list[1]);
[email protected]4934d362012-11-22 22:04:53463 Compare(pass_cmp.get(), pass_out.get());
464 ASSERT_EQ(3u, pass_out->shared_quad_state_list.size());
danakja8f1ac32015-08-05 18:46:57465 ASSERT_EQ(9u, pass_out->quad_list.size());
weiliangc808f70f2014-10-03 22:53:15466 for (cc::SharedQuadStateList::ConstIterator
467 cmp_iterator = pass_cmp->shared_quad_state_list.begin(),
468 out_iterator = pass_out->shared_quad_state_list.begin();
469 out_iterator != pass_out->shared_quad_state_list.end();
470 ++cmp_iterator, ++out_iterator) {
weiliangc48805fce2014-10-29 20:30:12471 Compare(*cmp_iterator, *out_iterator);
[email protected]4934d362012-11-22 22:04:53472 }
weiliangc7eb7ee62014-10-07 00:04:40473 for (auto out_iter = pass_out->quad_list.cbegin(),
474 cmp_iter = pass_cmp->quad_list.cbegin();
fsamuelf76098e2016-05-18 17:26:51475 out_iter != pass_out->quad_list.cend(); ++out_iter, ++cmp_iter)
weiliangc48805fce2014-10-29 20:30:12476 Compare(*cmp_iter, *out_iter);
weiliangc032e929d2014-09-26 01:55:01477
[email protected]61df9d82013-01-30 02:32:42478 for (size_t i = 1; i < pass_out->quad_list.size(); ++i) {
[email protected]4934d362012-11-22 22:04:53479 bool same_shared_quad_state_cmp =
weiliangc032e929d2014-09-26 01:55:01480 pass_cmp->quad_list.ElementAt(i)->shared_quad_state ==
481 pass_cmp->quad_list.ElementAt(i - 1)->shared_quad_state;
[email protected]4934d362012-11-22 22:04:53482 bool same_shared_quad_state_out =
weiliangc032e929d2014-09-26 01:55:01483 pass_out->quad_list.ElementAt(i)->shared_quad_state ==
484 pass_out->quad_list.ElementAt(i - 1)->shared_quad_state;
[email protected]4934d362012-11-22 22:04:53485 EXPECT_EQ(same_shared_quad_state_cmp, same_shared_quad_state_out);
486 }
487}
[email protected]bca159072012-12-04 00:52:44488
fsamuelf76098e2016-05-18 17:26:51489TEST_F(CCParamTraitsTest, UnusedSharedQuadStates) {
dcheng4ac58c7a2016-04-09 04:51:48490 std::unique_ptr<RenderPass> pass_in = RenderPass::Create();
fsamuelf76098e2016-05-18 17:26:51491 pass_in->SetAll(RenderPassId(1, 1), gfx::Rect(100, 100), gfx::Rect(),
492 gfx::Transform(), false);
[email protected]cbe94b7a2013-11-13 11:03:37493
494 // The first SharedQuadState is used.
[email protected]2b7f3892014-05-08 01:45:18495 SharedQuadState* shared_state1_in = pass_in->CreateAndAppendSharedQuadState();
fsamuelf76098e2016-05-18 17:26:51496 shared_state1_in->SetAll(gfx::Transform(), gfx::Size(1, 1), gfx::Rect(),
497 gfx::Rect(), false, 1.f, SkXfermode::kSrcOver_Mode,
[email protected]a9d4d4f2014-06-19 06:49:28498 0);
[email protected]cbe94b7a2013-11-13 11:03:37499
danakja8f1ac32015-08-05 18:46:57500 SolidColorDrawQuad* quad1 =
501 pass_in->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
danakje1419ce2015-03-04 21:26:27502 quad1->SetAll(shared_state1_in, gfx::Rect(10, 10), gfx::Rect(10, 10),
danakja8f1ac32015-08-05 18:46:57503 gfx::Rect(10, 10), false, SK_ColorRED, false);
[email protected]cbe94b7a2013-11-13 11:03:37504
505 // The second and third SharedQuadStates are not used.
[email protected]2b7f3892014-05-08 01:45:18506 SharedQuadState* shared_state2_in = pass_in->CreateAndAppendSharedQuadState();
fsamuelf76098e2016-05-18 17:26:51507 shared_state2_in->SetAll(gfx::Transform(), gfx::Size(2, 2), gfx::Rect(),
508 gfx::Rect(), false, 1.f, SkXfermode::kSrcOver_Mode,
[email protected]a9d4d4f2014-06-19 06:49:28509 0);
[email protected]cbe94b7a2013-11-13 11:03:37510
[email protected]2b7f3892014-05-08 01:45:18511 SharedQuadState* shared_state3_in = pass_in->CreateAndAppendSharedQuadState();
fsamuelf76098e2016-05-18 17:26:51512 shared_state3_in->SetAll(gfx::Transform(), gfx::Size(3, 3), gfx::Rect(),
513 gfx::Rect(), false, 1.f, SkXfermode::kSrcOver_Mode,
[email protected]a9d4d4f2014-06-19 06:49:28514 0);
[email protected]cbe94b7a2013-11-13 11:03:37515
516 // The fourth SharedQuadState is used.
[email protected]2b7f3892014-05-08 01:45:18517 SharedQuadState* shared_state4_in = pass_in->CreateAndAppendSharedQuadState();
fsamuelf76098e2016-05-18 17:26:51518 shared_state4_in->SetAll(gfx::Transform(), gfx::Size(4, 4), gfx::Rect(),
519 gfx::Rect(), false, 1.f, SkXfermode::kSrcOver_Mode,
[email protected]a9d4d4f2014-06-19 06:49:28520 0);
[email protected]cbe94b7a2013-11-13 11:03:37521
danakja8f1ac32015-08-05 18:46:57522 SolidColorDrawQuad* quad2 =
523 pass_in->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
danakje1419ce2015-03-04 21:26:27524 quad2->SetAll(shared_state4_in, gfx::Rect(10, 10), gfx::Rect(10, 10),
danakja8f1ac32015-08-05 18:46:57525 gfx::Rect(10, 10), false, SK_ColorRED, false);
[email protected]cbe94b7a2013-11-13 11:03:37526
527 // The fifth is not used again.
[email protected]2b7f3892014-05-08 01:45:18528 SharedQuadState* shared_state5_in = pass_in->CreateAndAppendSharedQuadState();
fsamuelf76098e2016-05-18 17:26:51529 shared_state5_in->SetAll(gfx::Transform(), gfx::Size(5, 5), gfx::Rect(),
530 gfx::Rect(), false, 1.f, SkXfermode::kSrcOver_Mode,
[email protected]a9d4d4f2014-06-19 06:49:28531 0);
[email protected]cbe94b7a2013-11-13 11:03:37532
[email protected]cbe94b7a2013-11-13 11:03:37533 // 5 SharedQuadStates go in.
534 ASSERT_EQ(5u, pass_in->shared_quad_state_list.size());
535 ASSERT_EQ(2u, pass_in->quad_list.size());
536
537 DelegatedFrameData frame_in;
dchengf63a1252015-12-26 20:43:13538 frame_in.render_pass_list.push_back(std::move(pass_in));
[email protected]cbe94b7a2013-11-13 11:03:37539
540 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
541 IPC::ParamTraits<DelegatedFrameData>::Write(&msg, frame_in);
542
543 DelegatedFrameData frame_out;
brettwbd4d7112015-06-03 04:29:25544 base::PickleIterator iter(msg);
[email protected]cbe94b7a2013-11-13 11:03:37545 EXPECT_TRUE(
546 IPC::ParamTraits<DelegatedFrameData>::Read(&msg, &iter, &frame_out));
547
dcheng4ac58c7a2016-04-09 04:51:48548 std::unique_ptr<RenderPass> pass_out =
549 std::move(frame_out.render_pass_list[0]);
[email protected]cbe94b7a2013-11-13 11:03:37550
551 // 2 SharedQuadStates come out. The first and fourth SharedQuadStates were
552 // used by quads, and so serialized. Others were not.
553 ASSERT_EQ(2u, pass_out->shared_quad_state_list.size());
554 ASSERT_EQ(2u, pass_out->quad_list.size());
555
danakj64767d902015-06-19 00:10:43556 EXPECT_EQ(gfx::Size(1, 1).ToString(),
557 pass_out->shared_quad_state_list.ElementAt(0)
558 ->quad_layer_bounds.ToString());
559 EXPECT_EQ(gfx::Size(4, 4).ToString(),
560 pass_out->shared_quad_state_list.ElementAt(1)
561 ->quad_layer_bounds.ToString());
[email protected]cbe94b7a2013-11-13 11:03:37562}
563
fsamuelf76098e2016-05-18 17:26:51564TEST_F(CCParamTraitsTest, Resources) {
[email protected]753bb252013-11-04 22:28:12565 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
[email protected]bca159072012-12-04 00:52:44566 gfx::Size arbitrary_size(757, 1281);
lukasza2573ce7d2016-02-16 19:17:22567 gpu::SyncToken arbitrary_token1(gpu::CommandBufferNamespace::GPU_IO, 0,
568 gpu::CommandBufferId::FromUnsafeValue(0x123),
dyen398dd0142016-01-21 22:05:56569 71234838);
570 arbitrary_token1.SetVerifyFlush();
lukasza2573ce7d2016-02-16 19:17:22571 gpu::SyncToken arbitrary_token2(gpu::CommandBufferNamespace::GPU_IO, 0,
572 gpu::CommandBufferId::FromUnsafeValue(0x123),
dyen398dd0142016-01-21 22:05:56573 53589793);
574 arbitrary_token2.SetVerifyFlush();
[email protected]bca159072012-12-04 00:52:44575
[email protected]e0a4d732014-02-15 00:23:26576 GLbyte arbitrary_mailbox1[GL_MAILBOX_SIZE_CHROMIUM] = {
577 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2,
578 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4,
579 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4};
[email protected]bca159072012-12-04 00:52:44580
[email protected]e0a4d732014-02-15 00:23:26581 GLbyte arbitrary_mailbox2[GL_MAILBOX_SIZE_CHROMIUM] = {
582 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9,
583 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, 8, 7,
584 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, 8, 7};
[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;
[email protected]bca159072012-12-04 00:52:44595
596 TransferableResource arbitrary_resource2;
597 arbitrary_resource2.id = 789132;
[email protected]27a41fe2013-09-19 05:05:14598 arbitrary_resource2.format = cc::RGBA_4444;
[email protected]645a47f22013-09-26 05:42:32599 arbitrary_resource2.filter = 47;
[email protected]bca159072012-12-04 00:52:44600 arbitrary_resource2.size = gfx::Size(89123, 23789);
[email protected]df41e252014-02-03 23:39:50601 arbitrary_resource2.mailbox_holder.mailbox.SetName(arbitrary_mailbox2);
602 arbitrary_resource2.mailbox_holder.texture_target = GL_TEXTURE_EXTERNAL_OES;
dyencc16ed4d2015-11-03 20:03:04603 arbitrary_resource2.mailbox_holder.sync_token = arbitrary_token2;
ccameron268c09fd2015-10-08 20:23:46604 arbitrary_resource2.is_overlay_candidate = false;
[email protected]bca159072012-12-04 00:52:44605
dcheng4ac58c7a2016-04-09 04:51:48606 std::unique_ptr<RenderPass> renderpass_in = RenderPass::Create();
fsamuelf76098e2016-05-18 17:26:51607 renderpass_in->SetNew(RenderPassId(1, 1), gfx::Rect(), gfx::Rect(),
608 gfx::Transform());
[email protected]cb7d6492013-10-03 02:40:04609
[email protected]bf189f62012-12-18 03:42:11610 DelegatedFrameData frame_in;
[email protected]09831f7f2013-02-27 03:32:15611 frame_in.resource_list.push_back(arbitrary_resource1);
612 frame_in.resource_list.push_back(arbitrary_resource2);
dchengf63a1252015-12-26 20:43:13613 frame_in.render_pass_list.push_back(std::move(renderpass_in));
[email protected]bca159072012-12-04 00:52:44614
[email protected]bf189f62012-12-18 03:42:11615 IPC::ParamTraits<DelegatedFrameData>::Write(&msg, frame_in);
[email protected]bca159072012-12-04 00:52:44616
[email protected]bf189f62012-12-18 03:42:11617 DelegatedFrameData frame_out;
brettwbd4d7112015-06-03 04:29:25618 base::PickleIterator iter(msg);
fsamuelf76098e2016-05-18 17:26:51619 EXPECT_TRUE(
620 IPC::ParamTraits<DelegatedFrameData>::Read(&msg, &iter, &frame_out));
[email protected]bca159072012-12-04 00:52:44621
[email protected]09831f7f2013-02-27 03:32:15622 ASSERT_EQ(2u, frame_out.resource_list.size());
623 Compare(arbitrary_resource1, frame_out.resource_list[0]);
624 Compare(arbitrary_resource2, frame_out.resource_list[1]);
[email protected]bca159072012-12-04 00:52:44625}
626
627} // namespace
628} // namespace content