blob: 799c39ff4502cd87834bf1f37bc2864b477c4e64 [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
avia9aa7a82015-12-25 03:06:317#include <stddef.h>
[email protected]4934d362012-11-22 22:04:538#include <string.h>
[email protected]032bfc42013-10-29 22:23:529#include <algorithm>
dchengf63a1252015-12-26 20:43:1310#include <utility>
[email protected]032bfc42013-10-29 22:23:5211
avia9aa7a82015-12-25 03:06:3112#include "base/macros.h"
13#include "build/build_config.h"
[email protected]7f0d825f2013-03-18 07:24:3014#include "cc/output/compositor_frame.h"
[email protected]cecc8342014-03-20 21:43:3915#include "content/public/common/common_param_traits.h"
[email protected]4934d362012-11-22 22:04:5316#include "ipc/ipc_message.h"
17#include "testing/gtest/include/gtest/gtest.h"
[email protected]645a47f22013-09-26 05:42:3218#include "third_party/khronos/GLES2/gl2ext.h"
[email protected]a1765672013-08-12 23:45:0219#include "third_party/skia/include/effects/SkBlurImageFilter.h"
[email protected]4934d362012-11-22 22:04:5320
[email protected]cecc8342014-03-20 21:43:3921#if defined(OS_POSIX)
22#include "base/file_descriptor_posix.h"
23#endif
24
[email protected]bf189f62012-12-18 03:42:1125using cc::DelegatedFrameData;
[email protected]4934d362012-11-22 22:04:5326using cc::DebugBorderDrawQuad;
27using cc::DrawQuad;
[email protected]ae6b1a72013-06-25 18:49:2928using cc::FilterOperation;
29using cc::FilterOperations;
[email protected]4934d362012-11-22 22:04:5330using cc::IOSurfaceDrawQuad;
[email protected]9ee4d3a2013-03-27 17:43:1631using cc::PictureDrawQuad;
[email protected]4934d362012-11-22 22:04:5332using cc::RenderPass;
[email protected]0cd7d6f72014-08-22 14:50:5133using cc::RenderPassId;
[email protected]4934d362012-11-22 22:04:5334using cc::RenderPassDrawQuad;
jbaumanbbd425e2015-05-19 00:33:3535using cc::ResourceId;
[email protected]4934d362012-11-22 22:04:5336using cc::ResourceProvider;
37using cc::SharedQuadState;
[email protected]4934d362012-11-22 22:04:5338using cc::SolidColorDrawQuad;
[email protected]78d30122014-01-17 06:32:3639using cc::SurfaceDrawQuad;
[email protected]4934d362012-11-22 22:04:5340using cc::TextureDrawQuad;
41using cc::TileDrawQuad;
[email protected]bca159072012-12-04 00:52:4442using cc::TransferableResource;
[email protected]4934d362012-11-22 22:04:5343using cc::StreamVideoDrawQuad;
[email protected]4934d362012-11-22 22:04:5344using cc::YUVVideoDrawQuad;
[email protected]c8686a02012-11-27 08:29:0045using gfx::Transform;
[email protected]4934d362012-11-22 22:04:5346
[email protected]bca159072012-12-04 00:52:4447namespace content {
48namespace {
49
[email protected]4934d362012-11-22 22:04:5350class CCMessagesTest : public testing::Test {
51 protected:
52 void Compare(const RenderPass* a, const RenderPass* b) {
53 EXPECT_EQ(a->id, b->id);
54 EXPECT_EQ(a->output_rect.ToString(), b->output_rect.ToString());
55 EXPECT_EQ(a->damage_rect.ToString(), b->damage_rect.ToString());
56 EXPECT_EQ(a->transform_to_root_target, b->transform_to_root_target);
57 EXPECT_EQ(a->has_transparent_background, b->has_transparent_background);
[email protected]4934d362012-11-22 22:04:5358 }
59
60 void Compare(const SharedQuadState* a, const SharedQuadState* b) {
danakj64767d902015-06-19 00:10:4361 EXPECT_EQ(a->quad_to_target_transform, b->quad_to_target_transform);
62 EXPECT_EQ(a->quad_layer_bounds, b->quad_layer_bounds);
63 EXPECT_EQ(a->visible_quad_layer_rect, b->visible_quad_layer_rect);
[email protected]4934d362012-11-22 22:04:5364 EXPECT_EQ(a->clip_rect, b->clip_rect);
65 EXPECT_EQ(a->is_clipped, b->is_clipped);
66 EXPECT_EQ(a->opacity, b->opacity);
[email protected]7bbeaf4e2013-11-26 10:27:2267 EXPECT_EQ(a->blend_mode, b->blend_mode);
[email protected]a9d4d4f2014-06-19 06:49:2868 EXPECT_EQ(a->sorting_context_id, b->sorting_context_id);
[email protected]4934d362012-11-22 22:04:5369 }
70
71 void Compare(const DrawQuad* a, const DrawQuad* b) {
72 ASSERT_NE(DrawQuad::INVALID, a->material);
73 ASSERT_EQ(a->material, b->material);
74 EXPECT_EQ(a->rect.ToString(), b->rect.ToString());
75 EXPECT_EQ(a->opaque_rect.ToString(), b->opaque_rect.ToString());
76 EXPECT_EQ(a->visible_rect.ToString(), b->visible_rect.ToString());
77 EXPECT_EQ(a->needs_blending, b->needs_blending);
78
79 Compare(a->shared_quad_state, b->shared_quad_state);
80
81 switch (a->material) {
[email protected]4934d362012-11-22 22:04:5382 case DrawQuad::DEBUG_BORDER:
83 Compare(DebugBorderDrawQuad::MaterialCast(a),
84 DebugBorderDrawQuad::MaterialCast(b));
85 break;
86 case DrawQuad::IO_SURFACE_CONTENT:
87 Compare(IOSurfaceDrawQuad::MaterialCast(a),
88 IOSurfaceDrawQuad::MaterialCast(b));
89 break;
[email protected]9ee4d3a2013-03-27 17:43:1690 case DrawQuad::PICTURE_CONTENT:
91 Compare(PictureDrawQuad::MaterialCast(a),
92 PictureDrawQuad::MaterialCast(b));
93 break;
[email protected]4934d362012-11-22 22:04:5394 case DrawQuad::RENDER_PASS:
95 Compare(RenderPassDrawQuad::MaterialCast(a),
96 RenderPassDrawQuad::MaterialCast(b));
97 break;
98 case DrawQuad::TEXTURE_CONTENT:
99 Compare(TextureDrawQuad::MaterialCast(a),
100 TextureDrawQuad::MaterialCast(b));
101 break;
102 case DrawQuad::TILED_CONTENT:
103 Compare(TileDrawQuad::MaterialCast(a),
104 TileDrawQuad::MaterialCast(b));
105 break;
106 case DrawQuad::SOLID_COLOR:
107 Compare(SolidColorDrawQuad::MaterialCast(a),
108 SolidColorDrawQuad::MaterialCast(b));
109 break;
110 case DrawQuad::STREAM_VIDEO_CONTENT:
111 Compare(StreamVideoDrawQuad::MaterialCast(a),
112 StreamVideoDrawQuad::MaterialCast(b));
113 break;
[email protected]78d30122014-01-17 06:32:36114 case DrawQuad::SURFACE_CONTENT:
115 Compare(SurfaceDrawQuad::MaterialCast(a),
116 SurfaceDrawQuad::MaterialCast(b));
117 break;
[email protected]4934d362012-11-22 22:04:53118 case DrawQuad::YUV_VIDEO_CONTENT:
119 Compare(YUVVideoDrawQuad::MaterialCast(a),
120 YUVVideoDrawQuad::MaterialCast(b));
121 break;
122 case DrawQuad::INVALID:
123 break;
124 }
125 }
126
[email protected]4934d362012-11-22 22:04:53127 void Compare(const DebugBorderDrawQuad* a, const DebugBorderDrawQuad* b) {
128 EXPECT_EQ(a->color, b->color);
129 EXPECT_EQ(a->width, b->width);
130 }
131
132 void Compare(const IOSurfaceDrawQuad* a, const IOSurfaceDrawQuad* b) {
133 EXPECT_EQ(a->io_surface_size.ToString(), b->io_surface_size.ToString());
vmpstr0eca2e82015-06-02 22:14:46134 EXPECT_EQ(a->io_surface_resource_id(), b->io_surface_resource_id());
[email protected]4934d362012-11-22 22:04:53135 EXPECT_EQ(a->orientation, b->orientation);
136 }
137
138 void Compare(const RenderPassDrawQuad* a, const RenderPassDrawQuad* b) {
[email protected]82f93fb2013-04-17 21:42:06139 EXPECT_EQ(a->render_pass_id, b->render_pass_id);
vmpstr0eca2e82015-06-02 22:14:46140 EXPECT_EQ(a->mask_resource_id(), b->mask_resource_id());
ennef6f3fbba42014-10-16 18:16:49141 EXPECT_EQ(a->mask_uv_scale.ToString(), b->mask_uv_scale.ToString());
142 EXPECT_EQ(a->mask_texture_size.ToString(), b->mask_texture_size.ToString());
[email protected]1dc7943e2013-09-26 04:41:48143 EXPECT_EQ(a->filters.size(), b->filters.size());
144 for (size_t i = 0; i < a->filters.size(); ++i) {
145 if (a->filters.at(i).type() != cc::FilterOperation::REFERENCE) {
146 EXPECT_EQ(a->filters.at(i), b->filters.at(i));
147 } else {
148 EXPECT_EQ(b->filters.at(i).type(), cc::FilterOperation::REFERENCE);
149 EXPECT_EQ(a->filters.at(i).image_filter()->countInputs(),
150 b->filters.at(i).image_filter()->countInputs());
151 }
152 }
[email protected]7ac3d492014-08-08 21:25:32153 EXPECT_EQ(a->filters_scale, b->filters_scale);
[email protected]20062042012-12-21 22:16:36154 EXPECT_EQ(a->background_filters, b->background_filters);
[email protected]4934d362012-11-22 22:04:53155 }
156
157 void Compare(const SolidColorDrawQuad* a, const SolidColorDrawQuad* b) {
158 EXPECT_EQ(a->color, b->color);
[email protected]10a30b12013-05-02 16:42:11159 EXPECT_EQ(a->force_anti_aliasing_off, b->force_anti_aliasing_off);
[email protected]4934d362012-11-22 22:04:53160 }
161
162 void Compare(const StreamVideoDrawQuad* a, const StreamVideoDrawQuad* b) {
vmpstr0eca2e82015-06-02 22:14:46163 EXPECT_EQ(a->resource_id(), b->resource_id());
achaulkf89f5942015-06-10 17:01:35164 EXPECT_EQ(a->resource_size_in_pixels(), b->resource_size_in_pixels());
[email protected]4934d362012-11-22 22:04:53165 EXPECT_EQ(a->matrix, b->matrix);
166 }
167
[email protected]78d30122014-01-17 06:32:36168 void Compare(const SurfaceDrawQuad* a, const SurfaceDrawQuad* b) {
169 EXPECT_EQ(a->surface_id, b->surface_id);
170 }
171
[email protected]4934d362012-11-22 22:04:53172 void Compare(const TextureDrawQuad* a, const TextureDrawQuad* b) {
vmpstr0eca2e82015-06-02 22:14:46173 EXPECT_EQ(a->resource_id(), b->resource_id());
achaulkf89f5942015-06-10 17:01:35174 EXPECT_EQ(a->resource_size_in_pixels(), b->resource_size_in_pixels());
[email protected]4934d362012-11-22 22:04:53175 EXPECT_EQ(a->premultiplied_alpha, b->premultiplied_alpha);
[email protected]1fd555b2013-01-18 00:13:21176 EXPECT_EQ(a->uv_top_left, b->uv_top_left);
177 EXPECT_EQ(a->uv_bottom_right, b->uv_bottom_right);
[email protected]d18b4d62013-07-12 05:33:49178 EXPECT_EQ(a->background_color, b->background_color);
[email protected]61df9d82013-01-30 02:32:42179 EXPECT_EQ(a->vertex_opacity[0], b->vertex_opacity[0]);
180 EXPECT_EQ(a->vertex_opacity[1], b->vertex_opacity[1]);
181 EXPECT_EQ(a->vertex_opacity[2], b->vertex_opacity[2]);
182 EXPECT_EQ(a->vertex_opacity[3], b->vertex_opacity[3]);
halliwellaa111282015-05-13 21:58:43183 EXPECT_EQ(a->y_flipped, b->y_flipped);
jackhou10c9af42014-12-04 05:24:44184 EXPECT_EQ(a->nearest_neighbor, b->nearest_neighbor);
[email protected]4934d362012-11-22 22:04:53185 }
186
187 void Compare(const TileDrawQuad* a, const TileDrawQuad* b) {
vmpstr0eca2e82015-06-02 22:14:46188 EXPECT_EQ(a->resource_id(), b->resource_id());
[email protected]4934d362012-11-22 22:04:53189 EXPECT_EQ(a->tex_coord_rect, b->tex_coord_rect);
190 EXPECT_EQ(a->texture_size, b->texture_size);
191 EXPECT_EQ(a->swizzle_contents, b->swizzle_contents);
jackhou24229612014-12-13 23:41:00192 EXPECT_EQ(a->nearest_neighbor, b->nearest_neighbor);
[email protected]4934d362012-11-22 22:04:53193 }
194
195 void Compare(const YUVVideoDrawQuad* a, const YUVVideoDrawQuad* b) {
revemanb71e3992015-05-12 23:01:51196 EXPECT_EQ(a->ya_tex_coord_rect, b->ya_tex_coord_rect);
197 EXPECT_EQ(a->uv_tex_coord_rect, b->uv_tex_coord_rect);
magjed7364ff92015-03-27 09:11:08198 EXPECT_EQ(a->ya_tex_size, b->ya_tex_size);
199 EXPECT_EQ(a->uv_tex_size, b->uv_tex_size);
vmpstr0eca2e82015-06-02 22:14:46200 EXPECT_EQ(a->y_plane_resource_id(), b->y_plane_resource_id());
201 EXPECT_EQ(a->u_plane_resource_id(), b->u_plane_resource_id());
202 EXPECT_EQ(a->v_plane_resource_id(), b->v_plane_resource_id());
203 EXPECT_EQ(a->a_plane_resource_id(), b->a_plane_resource_id());
[email protected]82faf5e2014-05-03 02:25:58204 EXPECT_EQ(a->color_space, b->color_space);
[email protected]4934d362012-11-22 22:04:53205 }
[email protected]bca159072012-12-04 00:52:44206
207 void Compare(const TransferableResource& a, const TransferableResource& b) {
208 EXPECT_EQ(a.id, b.id);
209 EXPECT_EQ(a.format, b.format);
[email protected]80189292013-02-28 01:59:36210 EXPECT_EQ(a.filter, b.filter);
[email protected]bca159072012-12-04 00:52:44211 EXPECT_EQ(a.size.ToString(), b.size.ToString());
[email protected]df41e252014-02-03 23:39:50212 for (size_t i = 0; i < arraysize(a.mailbox_holder.mailbox.name); ++i) {
213 EXPECT_EQ(a.mailbox_holder.mailbox.name[i],
214 b.mailbox_holder.mailbox.name[i]);
215 }
216 EXPECT_EQ(a.mailbox_holder.texture_target, b.mailbox_holder.texture_target);
dyencc16ed4d2015-11-03 20:03:04217 EXPECT_EQ(a.mailbox_holder.sync_token, b.mailbox_holder.sync_token);
ccameron268c09fd2015-10-08 20:23:46218 EXPECT_EQ(a.is_overlay_candidate, b.is_overlay_candidate);
[email protected]bca159072012-12-04 00:52:44219 }
[email protected]4934d362012-11-22 22:04:53220};
221
222TEST_F(CCMessagesTest, AllQuads) {
[email protected]753bb252013-11-04 22:28:12223 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
[email protected]4934d362012-11-22 22:04:53224
danakj112d3a102015-04-14 18:24:49225 Transform arbitrary_matrix1;
226 arbitrary_matrix1.Scale(3, 3);
227 arbitrary_matrix1.Translate(-5, 20);
228 arbitrary_matrix1.Rotate(15);
229 Transform arbitrary_matrix2;
230 arbitrary_matrix2.Scale(10, -1);
231 arbitrary_matrix2.Translate(20, 3);
232 arbitrary_matrix2.Rotate(24);
[email protected]4934d362012-11-22 22:04:53233 gfx::Rect arbitrary_rect1(-5, 9, 3, 15);
[email protected]8e1da692013-10-12 17:11:30234 gfx::Rect arbitrary_rect1_inside_rect1(-4, 12, 2, 8);
235 gfx::Rect arbitrary_rect2_inside_rect1(-5, 11, 1, 2);
[email protected]4934d362012-11-22 22:04:53236 gfx::Rect arbitrary_rect2(40, 23, 11, 7);
[email protected]8e1da692013-10-12 17:11:30237 gfx::Rect arbitrary_rect1_inside_rect2(44, 23, 4, 2);
238 gfx::Rect arbitrary_rect2_inside_rect2(41, 25, 3, 5);
[email protected]4934d362012-11-22 22:04:53239 gfx::Rect arbitrary_rect3(7, -53, 22, 19);
[email protected]8e1da692013-10-12 17:11:30240 gfx::Rect arbitrary_rect1_inside_rect3(10, -40, 6, 3);
241 gfx::Rect arbitrary_rect2_inside_rect3(12, -51, 5, 12);
[email protected]4934d362012-11-22 22:04:53242 gfx::Size arbitrary_size1(15, 19);
243 gfx::Size arbitrary_size2(3, 99);
244 gfx::Size arbitrary_size3(75, 1281);
245 gfx::RectF arbitrary_rectf1(4.2f, -922.1f, 15.6f, 29.5f);
revemanb71e3992015-05-12 23:01:51246 gfx::RectF arbitrary_rectf2(2.1f, -411.05f, 7.8f, 14.75f);
[email protected]4934d362012-11-22 22:04:53247 gfx::SizeF arbitrary_sizef1(15.2f, 104.6f);
[email protected]61df9d82013-01-30 02:32:42248 gfx::PointF arbitrary_pointf1(31.4f, 15.9f);
249 gfx::PointF arbitrary_pointf2(26.5f, -35.8f);
[email protected]7ac3d492014-08-08 21:25:32250 gfx::Vector2dF arbitrary_vector2df1(16.2f, -85.1f);
ennef6f3fbba42014-10-16 18:16:49251 gfx::Vector2dF arbitrary_vector2df2(-8.3f, 0.47f);
[email protected]4934d362012-11-22 22:04:53252 float arbitrary_float1 = 0.7f;
253 float arbitrary_float2 = 0.3f;
254 float arbitrary_float3 = 0.9f;
[email protected]61df9d82013-01-30 02:32:42255 float arbitrary_float_array[4] = {3.5f, 6.2f, 9.3f, 12.3f};
[email protected]4934d362012-11-22 22:04:53256 bool arbitrary_bool1 = true;
257 bool arbitrary_bool2 = false;
[email protected]61df9d82013-01-30 02:32:42258 bool arbitrary_bool3 = true;
jackhou10c9af42014-12-04 05:24:44259 bool arbitrary_bool4 = true;
achaulkf89f5942015-06-10 17:01:35260 bool arbitrary_bool5 = false;
[email protected]a9d4d4f2014-06-19 06:49:28261 int arbitrary_context_id1 = 12;
262 int arbitrary_context_id2 = 57;
263 int arbitrary_context_id3 = -503;
[email protected]4934d362012-11-22 22:04:53264 int arbitrary_int = 5;
265 SkColor arbitrary_color = SkColorSetARGB(25, 36, 47, 58);
[email protected]7bbeaf4e2013-11-26 10:27:22266 SkXfermode::Mode arbitrary_blend_mode1 = SkXfermode::kScreen_Mode;
267 SkXfermode::Mode arbitrary_blend_mode2 = SkXfermode::kLighten_Mode;
268 SkXfermode::Mode arbitrary_blend_mode3 = SkXfermode::kOverlay_Mode;
[email protected]4934d362012-11-22 22:04:53269 IOSurfaceDrawQuad::Orientation arbitrary_orientation =
270 IOSurfaceDrawQuad::UNFLIPPED;
jbaumanbbd425e2015-05-19 00:33:35271 ResourceId arbitrary_resourceid1 = 55;
272 ResourceId arbitrary_resourceid2 = 47;
273 ResourceId arbitrary_resourceid3 = 23;
274 ResourceId arbitrary_resourceid4 = 16;
[email protected]a1765672013-08-12 23:45:02275 SkScalar arbitrary_sigma = SkFloatToScalar(2.0f);
[email protected]82faf5e2014-05-03 02:25:58276 YUVVideoDrawQuad::ColorSpace arbitrary_color_space =
277 YUVVideoDrawQuad::REC_601;
[email protected]4934d362012-11-22 22:04:53278
danakj112d3a102015-04-14 18:24:49279 RenderPassId child_id(30, 5);
280 RenderPassId root_id(10, 14);
281
[email protected]ae6b1a72013-06-25 18:49:29282 FilterOperations arbitrary_filters1;
283 arbitrary_filters1.Append(FilterOperation::CreateGrayscaleFilter(
[email protected]4934d362012-11-22 22:04:53284 arbitrary_float1));
[email protected]1dc7943e2013-09-26 04:41:48285 skia::RefPtr<SkImageFilter> arbitrary_filter = skia::AdoptRef(
[email protected]bb209bf2014-05-11 00:37:11286 SkBlurImageFilter::Create(arbitrary_sigma, arbitrary_sigma));
[email protected]1dc7943e2013-09-26 04:41:48287 arbitrary_filters1.Append(
288 cc::FilterOperation::CreateReferenceFilter(arbitrary_filter));
[email protected]4934d362012-11-22 22:04:53289
[email protected]ae6b1a72013-06-25 18:49:29290 FilterOperations arbitrary_filters2;
291 arbitrary_filters2.Append(FilterOperation::CreateBrightnessFilter(
[email protected]4934d362012-11-22 22:04:53292 arbitrary_float2));
293
danakj112d3a102015-04-14 18:24:49294 scoped_ptr<RenderPass> child_pass_in = RenderPass::Create();
295 child_pass_in->SetAll(child_id, arbitrary_rect2, arbitrary_rect3,
296 arbitrary_matrix2, arbitrary_bool2);
297
298 scoped_ptr<RenderPass> child_pass_cmp = RenderPass::Create();
299 child_pass_cmp->SetAll(child_id, arbitrary_rect2, arbitrary_rect3,
300 arbitrary_matrix2, arbitrary_bool2);
301
[email protected]2b7f3892014-05-08 01:45:18302 scoped_ptr<RenderPass> pass_in = RenderPass::Create();
danakj112d3a102015-04-14 18:24:49303 pass_in->SetAll(root_id, arbitrary_rect1, arbitrary_rect2, arbitrary_matrix1,
[email protected]2b7f3892014-05-08 01:45:18304 arbitrary_bool1);
305
306 SharedQuadState* shared_state1_in = pass_in->CreateAndAppendSharedQuadState();
danakj112d3a102015-04-14 18:24:49307 shared_state1_in->SetAll(arbitrary_matrix1, arbitrary_size1, arbitrary_rect1,
308 arbitrary_rect2, arbitrary_bool1, arbitrary_float1,
309 arbitrary_blend_mode1, arbitrary_context_id1);
[email protected]2b7f3892014-05-08 01:45:18310
311 scoped_ptr<RenderPass> pass_cmp = RenderPass::Create();
danakj112d3a102015-04-14 18:24:49312 pass_cmp->SetAll(root_id, arbitrary_rect1, arbitrary_rect2, arbitrary_matrix1,
[email protected]2b7f3892014-05-08 01:45:18313 arbitrary_bool1);
314
315 SharedQuadState* shared_state1_cmp =
316 pass_cmp->CreateAndAppendSharedQuadState();
317 shared_state1_cmp->CopyFrom(shared_state1_in);
[email protected]4934d362012-11-22 22:04:53318
[email protected]3b85fd92014-07-10 00:00:02319 DebugBorderDrawQuad* debugborder_in =
320 pass_in->CreateAndAppendDrawQuad<DebugBorderDrawQuad>();
[email protected]2b7f3892014-05-08 01:45:18321 debugborder_in->SetAll(shared_state1_in,
[email protected]4934d362012-11-22 22:04:53322 arbitrary_rect3,
[email protected]8e1da692013-10-12 17:11:30323 arbitrary_rect1_inside_rect3,
324 arbitrary_rect2_inside_rect3,
[email protected]4934d362012-11-22 22:04:53325 arbitrary_bool1,
326 arbitrary_color,
327 arbitrary_int);
[email protected]3b85fd92014-07-10 00:00:02328 pass_cmp->CopyFromAndAppendDrawQuad(debugborder_in,
329 debugborder_in->shared_quad_state);
[email protected]4934d362012-11-22 22:04:53330
[email protected]3b85fd92014-07-10 00:00:02331 IOSurfaceDrawQuad* iosurface_in =
332 pass_in->CreateAndAppendDrawQuad<IOSurfaceDrawQuad>();
[email protected]2b7f3892014-05-08 01:45:18333 iosurface_in->SetAll(shared_state1_in,
[email protected]4934d362012-11-22 22:04:53334 arbitrary_rect2,
[email protected]8e1da692013-10-12 17:11:30335 arbitrary_rect2_inside_rect2,
336 arbitrary_rect1_inside_rect2,
[email protected]4934d362012-11-22 22:04:53337 arbitrary_bool1,
338 arbitrary_size1,
[email protected]b7cfc632013-04-10 04:44:49339 arbitrary_resourceid3,
ccameron268c09fd2015-10-08 20:23:46340 arbitrary_orientation);
[email protected]3b85fd92014-07-10 00:00:02341 pass_cmp->CopyFromAndAppendDrawQuad(iosurface_in,
342 iosurface_in->shared_quad_state);
[email protected]4934d362012-11-22 22:04:53343
[email protected]2b7f3892014-05-08 01:45:18344 SharedQuadState* shared_state2_in = pass_in->CreateAndAppendSharedQuadState();
danakj112d3a102015-04-14 18:24:49345 shared_state2_in->SetAll(arbitrary_matrix2, arbitrary_size2, arbitrary_rect2,
346 arbitrary_rect3, arbitrary_bool1, arbitrary_float2,
347 arbitrary_blend_mode2, arbitrary_context_id2);
[email protected]2b7f3892014-05-08 01:45:18348 SharedQuadState* shared_state2_cmp =
349 pass_cmp->CreateAndAppendSharedQuadState();
350 shared_state2_cmp->CopyFrom(shared_state2_in);
[email protected]cbe94b7a2013-11-13 11:03:37351
[email protected]3b85fd92014-07-10 00:00:02352 RenderPassDrawQuad* renderpass_in =
353 pass_in->CreateAndAppendDrawQuad<RenderPassDrawQuad>();
danakj112d3a102015-04-14 18:24:49354 renderpass_in->SetAll(
355 shared_state2_in, arbitrary_rect1, arbitrary_rect2_inside_rect1,
356 arbitrary_rect1_inside_rect1, arbitrary_bool1, child_id,
357 arbitrary_resourceid2, arbitrary_vector2df1, arbitrary_size1,
358 arbitrary_filters1, arbitrary_vector2df2, arbitrary_filters2);
[email protected]3b85fd92014-07-10 00:00:02359 pass_cmp->CopyFromAndAppendRenderPassDrawQuad(
360 renderpass_in,
361 renderpass_in->shared_quad_state,
362 renderpass_in->render_pass_id);
[email protected]4934d362012-11-22 22:04:53363
[email protected]2b7f3892014-05-08 01:45:18364 SharedQuadState* shared_state3_in = pass_in->CreateAndAppendSharedQuadState();
danakj112d3a102015-04-14 18:24:49365 shared_state3_in->SetAll(arbitrary_matrix1, arbitrary_size3, arbitrary_rect3,
366 arbitrary_rect1, arbitrary_bool1, arbitrary_float3,
367 arbitrary_blend_mode3, arbitrary_context_id3);
[email protected]2b7f3892014-05-08 01:45:18368 SharedQuadState* shared_state3_cmp =
369 pass_cmp->CreateAndAppendSharedQuadState();
370 shared_state3_cmp->CopyFrom(shared_state3_in);
[email protected]4934d362012-11-22 22:04:53371
[email protected]3b85fd92014-07-10 00:00:02372 SolidColorDrawQuad* solidcolor_in =
373 pass_in->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
[email protected]2b7f3892014-05-08 01:45:18374 solidcolor_in->SetAll(shared_state3_in,
[email protected]4934d362012-11-22 22:04:53375 arbitrary_rect3,
[email protected]8e1da692013-10-12 17:11:30376 arbitrary_rect1_inside_rect3,
377 arbitrary_rect2_inside_rect3,
[email protected]4934d362012-11-22 22:04:53378 arbitrary_bool1,
[email protected]10a30b12013-05-02 16:42:11379 arbitrary_color,
380 arbitrary_bool2);
[email protected]3b85fd92014-07-10 00:00:02381 pass_cmp->CopyFromAndAppendDrawQuad(solidcolor_in,
382 solidcolor_in->shared_quad_state);
[email protected]4934d362012-11-22 22:04:53383
[email protected]3b85fd92014-07-10 00:00:02384 StreamVideoDrawQuad* streamvideo_in =
385 pass_in->CreateAndAppendDrawQuad<StreamVideoDrawQuad>();
achaulkf89f5942015-06-10 17:01:35386 streamvideo_in->SetAll(
387 shared_state3_in, arbitrary_rect2, arbitrary_rect2_inside_rect2,
388 arbitrary_rect1_inside_rect2, arbitrary_bool1, arbitrary_resourceid2,
ccameron268c09fd2015-10-08 20:23:46389 arbitrary_size1, arbitrary_matrix1);
[email protected]3b85fd92014-07-10 00:00:02390 pass_cmp->CopyFromAndAppendDrawQuad(streamvideo_in,
391 streamvideo_in->shared_quad_state);
[email protected]4934d362012-11-22 22:04:53392
[email protected]16a6af152014-06-13 04:20:16393 cc::SurfaceId arbitrary_surface_id(3);
[email protected]3b85fd92014-07-10 00:00:02394 SurfaceDrawQuad* surface_in =
395 pass_in->CreateAndAppendDrawQuad<SurfaceDrawQuad>();
[email protected]2b7f3892014-05-08 01:45:18396 surface_in->SetAll(shared_state3_in,
397 arbitrary_rect2,
398 arbitrary_rect2_inside_rect2,
399 arbitrary_rect1_inside_rect2,
400 arbitrary_bool1,
401 arbitrary_surface_id);
[email protected]3b85fd92014-07-10 00:00:02402 pass_cmp->CopyFromAndAppendDrawQuad(surface_in,
403 surface_in->shared_quad_state);
[email protected]78d30122014-01-17 06:32:36404
[email protected]3b85fd92014-07-10 00:00:02405 TextureDrawQuad* texture_in =
406 pass_in->CreateAndAppendDrawQuad<TextureDrawQuad>();
achaulkf89f5942015-06-10 17:01:35407 texture_in->SetAll(shared_state3_in, arbitrary_rect2,
408 arbitrary_rect2_inside_rect2, arbitrary_rect1_inside_rect2,
409 arbitrary_bool1, arbitrary_resourceid1, arbitrary_size1,
ccameron268c09fd2015-10-08 20:23:46410 arbitrary_bool2, arbitrary_pointf1,
achaulkf89f5942015-06-10 17:01:35411 arbitrary_pointf2, arbitrary_color, arbitrary_float_array,
412 arbitrary_bool4, arbitrary_bool5);
[email protected]3b85fd92014-07-10 00:00:02413 pass_cmp->CopyFromAndAppendDrawQuad(texture_in,
414 texture_in->shared_quad_state);
[email protected]61df9d82013-01-30 02:32:42415
[email protected]3b85fd92014-07-10 00:00:02416 TileDrawQuad* tile_in = pass_in->CreateAndAppendDrawQuad<TileDrawQuad>();
[email protected]2b7f3892014-05-08 01:45:18417 tile_in->SetAll(shared_state3_in,
[email protected]61df9d82013-01-30 02:32:42418 arbitrary_rect2,
[email protected]8e1da692013-10-12 17:11:30419 arbitrary_rect2_inside_rect2,
420 arbitrary_rect1_inside_rect2,
[email protected]61df9d82013-01-30 02:32:42421 arbitrary_bool1,
[email protected]b7cfc632013-04-10 04:44:49422 arbitrary_resourceid3,
[email protected]61df9d82013-01-30 02:32:42423 arbitrary_rectf1,
424 arbitrary_size1,
jackhou24229612014-12-13 23:41:00425 arbitrary_bool2,
426 arbitrary_bool3);
[email protected]3b85fd92014-07-10 00:00:02427 pass_cmp->CopyFromAndAppendDrawQuad(tile_in, tile_in->shared_quad_state);
[email protected]61df9d82013-01-30 02:32:42428
[email protected]3b85fd92014-07-10 00:00:02429 YUVVideoDrawQuad* yuvvideo_in =
430 pass_in->CreateAndAppendDrawQuad<YUVVideoDrawQuad>();
revemanb71e3992015-05-12 23:01:51431 yuvvideo_in->SetAll(
432 shared_state3_in, arbitrary_rect1, arbitrary_rect2_inside_rect1,
433 arbitrary_rect1_inside_rect1, arbitrary_bool1, arbitrary_rectf1,
434 arbitrary_rectf2, arbitrary_size1, arbitrary_size2, arbitrary_resourceid1,
435 arbitrary_resourceid2, arbitrary_resourceid3, arbitrary_resourceid4,
436 arbitrary_color_space);
[email protected]3b85fd92014-07-10 00:00:02437 pass_cmp->CopyFromAndAppendDrawQuad(yuvvideo_in,
438 yuvvideo_in->shared_quad_state);
[email protected]4934d362012-11-22 22:04:53439
440 // Make sure the in and cmp RenderPasses match.
danakj112d3a102015-04-14 18:24:49441 Compare(child_pass_cmp.get(), child_pass_in.get());
442 ASSERT_EQ(0u, child_pass_in->shared_quad_state_list.size());
443 ASSERT_EQ(0u, child_pass_in->quad_list.size());
[email protected]4934d362012-11-22 22:04:53444 Compare(pass_cmp.get(), pass_in.get());
445 ASSERT_EQ(3u, pass_in->shared_quad_state_list.size());
danakja8f1ac32015-08-05 18:46:57446 ASSERT_EQ(9u, pass_in->quad_list.size());
weiliangc808f70f2014-10-03 22:53:15447 for (cc::SharedQuadStateList::ConstIterator
448 cmp_iterator = pass_cmp->shared_quad_state_list.begin(),
449 in_iterator = pass_in->shared_quad_state_list.begin();
450 in_iterator != pass_in->shared_quad_state_list.end();
451 ++cmp_iterator, ++in_iterator) {
weiliangc48805fce2014-10-29 20:30:12452 Compare(*cmp_iterator, *in_iterator);
[email protected]4934d362012-11-22 22:04:53453 }
weiliangc7eb7ee62014-10-07 00:04:40454 for (auto in_iter = pass_in->quad_list.cbegin(),
455 cmp_iter = pass_cmp->quad_list.cbegin();
456 in_iter != pass_in->quad_list.cend();
weiliangc032e929d2014-09-26 01:55:01457 ++in_iter, ++cmp_iter)
weiliangc48805fce2014-10-29 20:30:12458 Compare(*cmp_iter, *in_iter);
weiliangc032e929d2014-09-26 01:55:01459
[email protected]61df9d82013-01-30 02:32:42460 for (size_t i = 1; i < pass_in->quad_list.size(); ++i) {
[email protected]4934d362012-11-22 22:04:53461 bool same_shared_quad_state_cmp =
weiliangc032e929d2014-09-26 01:55:01462 pass_cmp->quad_list.ElementAt(i)->shared_quad_state ==
463 pass_cmp->quad_list.ElementAt(i - 1)->shared_quad_state;
[email protected]4934d362012-11-22 22:04:53464 bool same_shared_quad_state_in =
weiliangc032e929d2014-09-26 01:55:01465 pass_in->quad_list.ElementAt(i)->shared_quad_state ==
466 pass_in->quad_list.ElementAt(i - 1)->shared_quad_state;
[email protected]4934d362012-11-22 22:04:53467 EXPECT_EQ(same_shared_quad_state_cmp, same_shared_quad_state_in);
468 }
469
[email protected]bf189f62012-12-18 03:42:11470 DelegatedFrameData frame_in;
dchengf63a1252015-12-26 20:43:13471 frame_in.render_pass_list.push_back(std::move(child_pass_in));
472 frame_in.render_pass_list.push_back(std::move(pass_in));
[email protected]4934d362012-11-22 22:04:53473
[email protected]bf189f62012-12-18 03:42:11474 IPC::ParamTraits<DelegatedFrameData>::Write(&msg, frame_in);
[email protected]bca159072012-12-04 00:52:44475
[email protected]bf189f62012-12-18 03:42:11476 DelegatedFrameData frame_out;
brettwbd4d7112015-06-03 04:29:25477 base::PickleIterator iter(msg);
[email protected]bf189f62012-12-18 03:42:11478 EXPECT_TRUE(IPC::ParamTraits<DelegatedFrameData>::Read(&msg,
479 &iter, &frame_out));
[email protected]bca159072012-12-04 00:52:44480
[email protected]4934d362012-11-22 22:04:53481 // Make sure the out and cmp RenderPasses match.
dchengf63a1252015-12-26 20:43:13482 scoped_ptr<RenderPass> child_pass_out =
483 std::move(frame_out.render_pass_list[0]);
danakj112d3a102015-04-14 18:24:49484 Compare(child_pass_cmp.get(), child_pass_out.get());
485 ASSERT_EQ(0u, child_pass_out->shared_quad_state_list.size());
486 ASSERT_EQ(0u, child_pass_out->quad_list.size());
dchengf63a1252015-12-26 20:43:13487 scoped_ptr<RenderPass> pass_out = std::move(frame_out.render_pass_list[1]);
[email protected]4934d362012-11-22 22:04:53488 Compare(pass_cmp.get(), pass_out.get());
489 ASSERT_EQ(3u, pass_out->shared_quad_state_list.size());
danakja8f1ac32015-08-05 18:46:57490 ASSERT_EQ(9u, pass_out->quad_list.size());
weiliangc808f70f2014-10-03 22:53:15491 for (cc::SharedQuadStateList::ConstIterator
492 cmp_iterator = pass_cmp->shared_quad_state_list.begin(),
493 out_iterator = pass_out->shared_quad_state_list.begin();
494 out_iterator != pass_out->shared_quad_state_list.end();
495 ++cmp_iterator, ++out_iterator) {
weiliangc48805fce2014-10-29 20:30:12496 Compare(*cmp_iterator, *out_iterator);
[email protected]4934d362012-11-22 22:04:53497 }
weiliangc7eb7ee62014-10-07 00:04:40498 for (auto out_iter = pass_out->quad_list.cbegin(),
499 cmp_iter = pass_cmp->quad_list.cbegin();
500 out_iter != pass_out->quad_list.cend();
weiliangc032e929d2014-09-26 01:55:01501 ++out_iter, ++cmp_iter)
weiliangc48805fce2014-10-29 20:30:12502 Compare(*cmp_iter, *out_iter);
weiliangc032e929d2014-09-26 01:55:01503
[email protected]61df9d82013-01-30 02:32:42504 for (size_t i = 1; i < pass_out->quad_list.size(); ++i) {
[email protected]4934d362012-11-22 22:04:53505 bool same_shared_quad_state_cmp =
weiliangc032e929d2014-09-26 01:55:01506 pass_cmp->quad_list.ElementAt(i)->shared_quad_state ==
507 pass_cmp->quad_list.ElementAt(i - 1)->shared_quad_state;
[email protected]4934d362012-11-22 22:04:53508 bool same_shared_quad_state_out =
weiliangc032e929d2014-09-26 01:55:01509 pass_out->quad_list.ElementAt(i)->shared_quad_state ==
510 pass_out->quad_list.ElementAt(i - 1)->shared_quad_state;
[email protected]4934d362012-11-22 22:04:53511 EXPECT_EQ(same_shared_quad_state_cmp, same_shared_quad_state_out);
512 }
513}
[email protected]bca159072012-12-04 00:52:44514
[email protected]cbe94b7a2013-11-13 11:03:37515TEST_F(CCMessagesTest, UnusedSharedQuadStates) {
[email protected]cbe94b7a2013-11-13 11:03:37516 scoped_ptr<RenderPass> pass_in = RenderPass::Create();
[email protected]0cd7d6f72014-08-22 14:50:51517 pass_in->SetAll(RenderPassId(1, 1),
[email protected]cbe94b7a2013-11-13 11:03:37518 gfx::Rect(100, 100),
[email protected]b4ead7b2014-04-07 18:12:18519 gfx::Rect(),
[email protected]cbe94b7a2013-11-13 11:03:37520 gfx::Transform(),
[email protected]8590da32014-03-28 20:49:07521 false);
[email protected]cbe94b7a2013-11-13 11:03:37522
523 // The first SharedQuadState is used.
[email protected]2b7f3892014-05-08 01:45:18524 SharedQuadState* shared_state1_in = pass_in->CreateAndAppendSharedQuadState();
[email protected]7bbeaf4e2013-11-26 10:27:22525 shared_state1_in->SetAll(gfx::Transform(),
526 gfx::Size(1, 1),
527 gfx::Rect(),
528 gfx::Rect(),
529 false,
530 1.f,
[email protected]a9d4d4f2014-06-19 06:49:28531 SkXfermode::kSrcOver_Mode,
532 0);
[email protected]cbe94b7a2013-11-13 11:03:37533
danakja8f1ac32015-08-05 18:46:57534 SolidColorDrawQuad* quad1 =
535 pass_in->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
danakje1419ce2015-03-04 21:26:27536 quad1->SetAll(shared_state1_in, gfx::Rect(10, 10), gfx::Rect(10, 10),
danakja8f1ac32015-08-05 18:46:57537 gfx::Rect(10, 10), false, SK_ColorRED, false);
[email protected]cbe94b7a2013-11-13 11:03:37538
539 // The second and third SharedQuadStates are not used.
[email protected]2b7f3892014-05-08 01:45:18540 SharedQuadState* shared_state2_in = pass_in->CreateAndAppendSharedQuadState();
[email protected]7bbeaf4e2013-11-26 10:27:22541 shared_state2_in->SetAll(gfx::Transform(),
542 gfx::Size(2, 2),
543 gfx::Rect(),
544 gfx::Rect(),
545 false,
546 1.f,
[email protected]a9d4d4f2014-06-19 06:49:28547 SkXfermode::kSrcOver_Mode,
548 0);
[email protected]cbe94b7a2013-11-13 11:03:37549
[email protected]2b7f3892014-05-08 01:45:18550 SharedQuadState* shared_state3_in = pass_in->CreateAndAppendSharedQuadState();
[email protected]7bbeaf4e2013-11-26 10:27:22551 shared_state3_in->SetAll(gfx::Transform(),
552 gfx::Size(3, 3),
553 gfx::Rect(),
554 gfx::Rect(),
555 false,
556 1.f,
[email protected]a9d4d4f2014-06-19 06:49:28557 SkXfermode::kSrcOver_Mode,
558 0);
[email protected]cbe94b7a2013-11-13 11:03:37559
560 // The fourth SharedQuadState is used.
[email protected]2b7f3892014-05-08 01:45:18561 SharedQuadState* shared_state4_in = pass_in->CreateAndAppendSharedQuadState();
[email protected]7bbeaf4e2013-11-26 10:27:22562 shared_state4_in->SetAll(gfx::Transform(),
563 gfx::Size(4, 4),
564 gfx::Rect(),
565 gfx::Rect(),
566 false,
567 1.f,
[email protected]a9d4d4f2014-06-19 06:49:28568 SkXfermode::kSrcOver_Mode,
569 0);
[email protected]cbe94b7a2013-11-13 11:03:37570
danakja8f1ac32015-08-05 18:46:57571 SolidColorDrawQuad* quad2 =
572 pass_in->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
danakje1419ce2015-03-04 21:26:27573 quad2->SetAll(shared_state4_in, gfx::Rect(10, 10), gfx::Rect(10, 10),
danakja8f1ac32015-08-05 18:46:57574 gfx::Rect(10, 10), false, SK_ColorRED, false);
[email protected]cbe94b7a2013-11-13 11:03:37575
576 // The fifth is not used again.
[email protected]2b7f3892014-05-08 01:45:18577 SharedQuadState* shared_state5_in = pass_in->CreateAndAppendSharedQuadState();
[email protected]7bbeaf4e2013-11-26 10:27:22578 shared_state5_in->SetAll(gfx::Transform(),
579 gfx::Size(5, 5),
580 gfx::Rect(),
581 gfx::Rect(),
582 false,
583 1.f,
[email protected]a9d4d4f2014-06-19 06:49:28584 SkXfermode::kSrcOver_Mode,
585 0);
[email protected]cbe94b7a2013-11-13 11:03:37586
[email protected]cbe94b7a2013-11-13 11:03:37587 // 5 SharedQuadStates go in.
588 ASSERT_EQ(5u, pass_in->shared_quad_state_list.size());
589 ASSERT_EQ(2u, pass_in->quad_list.size());
590
591 DelegatedFrameData frame_in;
dchengf63a1252015-12-26 20:43:13592 frame_in.render_pass_list.push_back(std::move(pass_in));
[email protected]cbe94b7a2013-11-13 11:03:37593
594 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
595 IPC::ParamTraits<DelegatedFrameData>::Write(&msg, frame_in);
596
597 DelegatedFrameData frame_out;
brettwbd4d7112015-06-03 04:29:25598 base::PickleIterator iter(msg);
[email protected]cbe94b7a2013-11-13 11:03:37599 EXPECT_TRUE(
600 IPC::ParamTraits<DelegatedFrameData>::Read(&msg, &iter, &frame_out));
601
dchengf63a1252015-12-26 20:43:13602 scoped_ptr<RenderPass> pass_out = std::move(frame_out.render_pass_list[0]);
[email protected]cbe94b7a2013-11-13 11:03:37603
604 // 2 SharedQuadStates come out. The first and fourth SharedQuadStates were
605 // used by quads, and so serialized. Others were not.
606 ASSERT_EQ(2u, pass_out->shared_quad_state_list.size());
607 ASSERT_EQ(2u, pass_out->quad_list.size());
608
danakj64767d902015-06-19 00:10:43609 EXPECT_EQ(gfx::Size(1, 1).ToString(),
610 pass_out->shared_quad_state_list.ElementAt(0)
611 ->quad_layer_bounds.ToString());
612 EXPECT_EQ(gfx::Size(4, 4).ToString(),
613 pass_out->shared_quad_state_list.ElementAt(1)
614 ->quad_layer_bounds.ToString());
[email protected]cbe94b7a2013-11-13 11:03:37615}
616
[email protected]bca159072012-12-04 00:52:44617TEST_F(CCMessagesTest, Resources) {
[email protected]753bb252013-11-04 22:28:12618 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
[email protected]bca159072012-12-04 00:52:44619 gfx::Size arbitrary_size(757, 1281);
dyencc16ed4d2015-11-03 20:03:04620 gpu::SyncToken arbitrary_token1(71234838);
621 gpu::SyncToken arbitrary_token2(53589793);
[email protected]bca159072012-12-04 00:52:44622
[email protected]e0a4d732014-02-15 00:23:26623 GLbyte arbitrary_mailbox1[GL_MAILBOX_SIZE_CHROMIUM] = {
624 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2,
625 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4,
626 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:44627
[email protected]e0a4d732014-02-15 00:23:26628 GLbyte arbitrary_mailbox2[GL_MAILBOX_SIZE_CHROMIUM] = {
629 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9,
630 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, 8, 7,
631 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:44632
633 TransferableResource arbitrary_resource1;
634 arbitrary_resource1.id = 2178312;
[email protected]27a41fe2013-09-19 05:05:14635 arbitrary_resource1.format = cc::RGBA_8888;
[email protected]80189292013-02-28 01:59:36636 arbitrary_resource1.filter = 53;
[email protected]bca159072012-12-04 00:52:44637 arbitrary_resource1.size = gfx::Size(37189, 123123);
[email protected]df41e252014-02-03 23:39:50638 arbitrary_resource1.mailbox_holder.mailbox.SetName(arbitrary_mailbox1);
639 arbitrary_resource1.mailbox_holder.texture_target = GL_TEXTURE_2D;
dyencc16ed4d2015-11-03 20:03:04640 arbitrary_resource1.mailbox_holder.sync_token = arbitrary_token1;
ccameron268c09fd2015-10-08 20:23:46641 arbitrary_resource1.is_overlay_candidate = true;
[email protected]bca159072012-12-04 00:52:44642
643 TransferableResource arbitrary_resource2;
644 arbitrary_resource2.id = 789132;
[email protected]27a41fe2013-09-19 05:05:14645 arbitrary_resource2.format = cc::RGBA_4444;
[email protected]645a47f22013-09-26 05:42:32646 arbitrary_resource2.filter = 47;
[email protected]bca159072012-12-04 00:52:44647 arbitrary_resource2.size = gfx::Size(89123, 23789);
[email protected]df41e252014-02-03 23:39:50648 arbitrary_resource2.mailbox_holder.mailbox.SetName(arbitrary_mailbox2);
649 arbitrary_resource2.mailbox_holder.texture_target = GL_TEXTURE_EXTERNAL_OES;
dyencc16ed4d2015-11-03 20:03:04650 arbitrary_resource2.mailbox_holder.sync_token = arbitrary_token2;
ccameron268c09fd2015-10-08 20:23:46651 arbitrary_resource2.is_overlay_candidate = false;
[email protected]bca159072012-12-04 00:52:44652
[email protected]cb7d6492013-10-03 02:40:04653 scoped_ptr<RenderPass> renderpass_in = RenderPass::Create();
654 renderpass_in->SetNew(
[email protected]0cd7d6f72014-08-22 14:50:51655 RenderPassId(1, 1), gfx::Rect(), gfx::Rect(), gfx::Transform());
[email protected]cb7d6492013-10-03 02:40:04656
[email protected]bf189f62012-12-18 03:42:11657 DelegatedFrameData frame_in;
[email protected]09831f7f2013-02-27 03:32:15658 frame_in.resource_list.push_back(arbitrary_resource1);
659 frame_in.resource_list.push_back(arbitrary_resource2);
dchengf63a1252015-12-26 20:43:13660 frame_in.render_pass_list.push_back(std::move(renderpass_in));
[email protected]bca159072012-12-04 00:52:44661
[email protected]bf189f62012-12-18 03:42:11662 IPC::ParamTraits<DelegatedFrameData>::Write(&msg, frame_in);
[email protected]bca159072012-12-04 00:52:44663
[email protected]bf189f62012-12-18 03:42:11664 DelegatedFrameData frame_out;
brettwbd4d7112015-06-03 04:29:25665 base::PickleIterator iter(msg);
[email protected]bf189f62012-12-18 03:42:11666 EXPECT_TRUE(IPC::ParamTraits<DelegatedFrameData>::Read(&msg,
667 &iter, &frame_out));
[email protected]bca159072012-12-04 00:52:44668
[email protected]09831f7f2013-02-27 03:32:15669 ASSERT_EQ(2u, frame_out.resource_list.size());
670 Compare(arbitrary_resource1, frame_out.resource_list[0]);
671 Compare(arbitrary_resource2, frame_out.resource_list[1]);
[email protected]bca159072012-12-04 00:52:44672}
673
[email protected]bca159072012-12-04 00:52:44674} // namespace
675} // namespace content