[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "content/common/cc_messages.h" |
| 6 | |
| 7 | #include <string.h> |
| 8 | |
[email protected] | 7f0d825f | 2013-03-18 07:24:30 | [diff] [blame] | 9 | #include "cc/output/compositor_frame.h" |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 10 | #include "ipc/ipc_message.h" |
| 11 | #include "testing/gtest/include/gtest/gtest.h" |
| 12 | |
| 13 | using cc::CheckerboardDrawQuad; |
[email protected] | bf189f6 | 2012-12-18 03:42:11 | [diff] [blame] | 14 | using cc::DelegatedFrameData; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 15 | using cc::DebugBorderDrawQuad; |
| 16 | using cc::DrawQuad; |
| 17 | using cc::IOSurfaceDrawQuad; |
[email protected] | 9ee4d3a | 2013-03-27 17:43:16 | [diff] [blame] | 18 | using cc::PictureDrawQuad; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 19 | using cc::RenderPass; |
| 20 | using cc::RenderPassDrawQuad; |
| 21 | using cc::ResourceProvider; |
| 22 | using cc::SharedQuadState; |
| 23 | using cc::SolidColorDrawQuad; |
| 24 | using cc::TextureDrawQuad; |
| 25 | using cc::TileDrawQuad; |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 26 | using cc::TransferableResource; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 27 | using cc::StreamVideoDrawQuad; |
| 28 | using cc::VideoLayerImpl; |
| 29 | using cc::YUVVideoDrawQuad; |
[email protected] | c8686a0 | 2012-11-27 08:29:00 | [diff] [blame] | 30 | using gfx::Transform; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 31 | using WebKit::WebFilterOperation; |
| 32 | using WebKit::WebFilterOperations; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 33 | |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 34 | namespace content { |
| 35 | namespace { |
| 36 | |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 37 | class CCMessagesTest : public testing::Test { |
| 38 | protected: |
| 39 | void Compare(const RenderPass* a, const RenderPass* b) { |
| 40 | EXPECT_EQ(a->id, b->id); |
| 41 | EXPECT_EQ(a->output_rect.ToString(), b->output_rect.ToString()); |
| 42 | EXPECT_EQ(a->damage_rect.ToString(), b->damage_rect.ToString()); |
| 43 | EXPECT_EQ(a->transform_to_root_target, b->transform_to_root_target); |
| 44 | EXPECT_EQ(a->has_transparent_background, b->has_transparent_background); |
| 45 | EXPECT_EQ(a->has_occlusion_from_outside_target_surface, |
| 46 | b->has_occlusion_from_outside_target_surface); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | void Compare(const SharedQuadState* a, const SharedQuadState* b) { |
| 50 | EXPECT_EQ(a->content_to_target_transform, b->content_to_target_transform); |
[email protected] | f902bf9 | 2013-03-04 18:33:27 | [diff] [blame] | 51 | EXPECT_EQ(a->content_bounds, b->content_bounds); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 52 | EXPECT_EQ(a->visible_content_rect, b->visible_content_rect); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 53 | EXPECT_EQ(a->clip_rect, b->clip_rect); |
| 54 | EXPECT_EQ(a->is_clipped, b->is_clipped); |
| 55 | EXPECT_EQ(a->opacity, b->opacity); |
| 56 | } |
| 57 | |
| 58 | void Compare(const DrawQuad* a, const DrawQuad* b) { |
| 59 | ASSERT_NE(DrawQuad::INVALID, a->material); |
| 60 | ASSERT_EQ(a->material, b->material); |
| 61 | EXPECT_EQ(a->rect.ToString(), b->rect.ToString()); |
| 62 | EXPECT_EQ(a->opaque_rect.ToString(), b->opaque_rect.ToString()); |
| 63 | EXPECT_EQ(a->visible_rect.ToString(), b->visible_rect.ToString()); |
| 64 | EXPECT_EQ(a->needs_blending, b->needs_blending); |
| 65 | |
| 66 | Compare(a->shared_quad_state, b->shared_quad_state); |
| 67 | |
| 68 | switch (a->material) { |
| 69 | case DrawQuad::CHECKERBOARD: |
| 70 | Compare(CheckerboardDrawQuad::MaterialCast(a), |
| 71 | CheckerboardDrawQuad::MaterialCast(b)); |
| 72 | break; |
| 73 | case DrawQuad::DEBUG_BORDER: |
| 74 | Compare(DebugBorderDrawQuad::MaterialCast(a), |
| 75 | DebugBorderDrawQuad::MaterialCast(b)); |
| 76 | break; |
| 77 | case DrawQuad::IO_SURFACE_CONTENT: |
| 78 | Compare(IOSurfaceDrawQuad::MaterialCast(a), |
| 79 | IOSurfaceDrawQuad::MaterialCast(b)); |
| 80 | break; |
[email protected] | 9ee4d3a | 2013-03-27 17:43:16 | [diff] [blame] | 81 | case DrawQuad::PICTURE_CONTENT: |
| 82 | Compare(PictureDrawQuad::MaterialCast(a), |
| 83 | PictureDrawQuad::MaterialCast(b)); |
| 84 | break; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 85 | case DrawQuad::RENDER_PASS: |
| 86 | Compare(RenderPassDrawQuad::MaterialCast(a), |
| 87 | RenderPassDrawQuad::MaterialCast(b)); |
| 88 | break; |
| 89 | case DrawQuad::TEXTURE_CONTENT: |
| 90 | Compare(TextureDrawQuad::MaterialCast(a), |
| 91 | TextureDrawQuad::MaterialCast(b)); |
| 92 | break; |
| 93 | case DrawQuad::TILED_CONTENT: |
| 94 | Compare(TileDrawQuad::MaterialCast(a), |
| 95 | TileDrawQuad::MaterialCast(b)); |
| 96 | break; |
| 97 | case DrawQuad::SOLID_COLOR: |
| 98 | Compare(SolidColorDrawQuad::MaterialCast(a), |
| 99 | SolidColorDrawQuad::MaterialCast(b)); |
| 100 | break; |
| 101 | case DrawQuad::STREAM_VIDEO_CONTENT: |
| 102 | Compare(StreamVideoDrawQuad::MaterialCast(a), |
| 103 | StreamVideoDrawQuad::MaterialCast(b)); |
| 104 | break; |
| 105 | case DrawQuad::YUV_VIDEO_CONTENT: |
| 106 | Compare(YUVVideoDrawQuad::MaterialCast(a), |
| 107 | YUVVideoDrawQuad::MaterialCast(b)); |
| 108 | break; |
| 109 | case DrawQuad::INVALID: |
| 110 | break; |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | void Compare(const CheckerboardDrawQuad* a, const CheckerboardDrawQuad* b) { |
| 115 | EXPECT_EQ(a->color, b->color); |
| 116 | } |
| 117 | |
| 118 | void Compare(const DebugBorderDrawQuad* a, const DebugBorderDrawQuad* b) { |
| 119 | EXPECT_EQ(a->color, b->color); |
| 120 | EXPECT_EQ(a->width, b->width); |
| 121 | } |
| 122 | |
| 123 | void Compare(const IOSurfaceDrawQuad* a, const IOSurfaceDrawQuad* b) { |
| 124 | EXPECT_EQ(a->io_surface_size.ToString(), b->io_surface_size.ToString()); |
[email protected] | b7cfc63 | 2013-04-10 04:44:49 | [diff] [blame] | 125 | EXPECT_EQ(a->io_surface_resource_id, b->io_surface_resource_id); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 126 | EXPECT_EQ(a->orientation, b->orientation); |
| 127 | } |
| 128 | |
| 129 | void Compare(const RenderPassDrawQuad* a, const RenderPassDrawQuad* b) { |
[email protected] | 82f93fb | 2013-04-17 21:42:06 | [diff] [blame] | 130 | EXPECT_EQ(a->render_pass_id, b->render_pass_id); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 131 | EXPECT_EQ(a->is_replica, b->is_replica); |
| 132 | EXPECT_EQ(a->mask_resource_id, b->mask_resource_id); |
| 133 | EXPECT_EQ(a->contents_changed_since_last_frame, |
| 134 | b->contents_changed_since_last_frame); |
[email protected] | 458af1e | 2012-12-13 05:12:18 | [diff] [blame] | 135 | EXPECT_EQ(a->mask_uv_rect.ToString(), b->mask_uv_rect.ToString()); |
[email protected] | 2006204 | 2012-12-21 22:16:36 | [diff] [blame] | 136 | EXPECT_EQ(a->filters, b->filters); |
| 137 | EXPECT_EQ(a->filter, b->filter); |
| 138 | EXPECT_EQ(a->background_filters, b->background_filters); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | void Compare(const SolidColorDrawQuad* a, const SolidColorDrawQuad* b) { |
| 142 | EXPECT_EQ(a->color, b->color); |
[email protected] | 10a30b1 | 2013-05-02 16:42:11 | [diff] [blame^] | 143 | EXPECT_EQ(a->force_anti_aliasing_off, b->force_anti_aliasing_off); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | void Compare(const StreamVideoDrawQuad* a, const StreamVideoDrawQuad* b) { |
[email protected] | b7cfc63 | 2013-04-10 04:44:49 | [diff] [blame] | 147 | EXPECT_EQ(a->resource_id, b->resource_id); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 148 | EXPECT_EQ(a->matrix, b->matrix); |
| 149 | } |
| 150 | |
| 151 | void Compare(const TextureDrawQuad* a, const TextureDrawQuad* b) { |
| 152 | EXPECT_EQ(a->resource_id, b->resource_id); |
| 153 | EXPECT_EQ(a->premultiplied_alpha, b->premultiplied_alpha); |
[email protected] | 1fd555b | 2013-01-18 00:13:21 | [diff] [blame] | 154 | EXPECT_EQ(a->uv_top_left, b->uv_top_left); |
| 155 | EXPECT_EQ(a->uv_bottom_right, b->uv_bottom_right); |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 156 | EXPECT_EQ(a->vertex_opacity[0], b->vertex_opacity[0]); |
| 157 | EXPECT_EQ(a->vertex_opacity[1], b->vertex_opacity[1]); |
| 158 | EXPECT_EQ(a->vertex_opacity[2], b->vertex_opacity[2]); |
| 159 | EXPECT_EQ(a->vertex_opacity[3], b->vertex_opacity[3]); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 160 | EXPECT_EQ(a->flipped, b->flipped); |
| 161 | } |
| 162 | |
| 163 | void Compare(const TileDrawQuad* a, const TileDrawQuad* b) { |
| 164 | EXPECT_EQ(a->resource_id, b->resource_id); |
| 165 | EXPECT_EQ(a->tex_coord_rect, b->tex_coord_rect); |
| 166 | EXPECT_EQ(a->texture_size, b->texture_size); |
| 167 | EXPECT_EQ(a->swizzle_contents, b->swizzle_contents); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 168 | } |
| 169 | |
| 170 | void Compare(const YUVVideoDrawQuad* a, const YUVVideoDrawQuad* b) { |
| 171 | EXPECT_EQ(a->tex_scale, b->tex_scale); |
[email protected] | b7cfc63 | 2013-04-10 04:44:49 | [diff] [blame] | 172 | EXPECT_EQ(a->y_plane_resource_id, b->y_plane_resource_id); |
| 173 | EXPECT_EQ(a->u_plane_resource_id, b->u_plane_resource_id); |
| 174 | EXPECT_EQ(a->v_plane_resource_id, b->v_plane_resource_id); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 175 | } |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 176 | |
| 177 | void Compare(const TransferableResource& a, const TransferableResource& b) { |
| 178 | EXPECT_EQ(a.id, b.id); |
[email protected] | 09831f7f | 2013-02-27 03:32:15 | [diff] [blame] | 179 | EXPECT_EQ(a.sync_point, b.sync_point); |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 180 | EXPECT_EQ(a.format, b.format); |
[email protected] | 8018929 | 2013-02-28 01:59:36 | [diff] [blame] | 181 | EXPECT_EQ(a.filter, b.filter); |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 182 | EXPECT_EQ(a.size.ToString(), b.size.ToString()); |
| 183 | for (size_t i = 0; i < arraysize(a.mailbox.name); ++i) |
| 184 | EXPECT_EQ(a.mailbox.name[i], b.mailbox.name[i]); |
| 185 | } |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 186 | }; |
| 187 | |
| 188 | TEST_F(CCMessagesTest, AllQuads) { |
| 189 | IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); |
| 190 | |
[email protected] | c8686a0 | 2012-11-27 08:29:00 | [diff] [blame] | 191 | Transform arbitrary_matrix; |
| 192 | arbitrary_matrix.Scale(3, 3); |
| 193 | arbitrary_matrix.Translate(-5, 20); |
| 194 | arbitrary_matrix.Rotate(15); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 195 | gfx::Rect arbitrary_rect1(-5, 9, 3, 15); |
| 196 | gfx::Rect arbitrary_rect2(40, 23, 11, 7); |
| 197 | gfx::Rect arbitrary_rect3(7, -53, 22, 19); |
| 198 | gfx::Size arbitrary_size1(15, 19); |
| 199 | gfx::Size arbitrary_size2(3, 99); |
| 200 | gfx::Size arbitrary_size3(75, 1281); |
| 201 | gfx::RectF arbitrary_rectf1(4.2f, -922.1f, 15.6f, 29.5f); |
| 202 | gfx::SizeF arbitrary_sizef1(15.2f, 104.6f); |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 203 | gfx::PointF arbitrary_pointf1(31.4f, 15.9f); |
| 204 | gfx::PointF arbitrary_pointf2(26.5f, -35.8f); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 205 | float arbitrary_float1 = 0.7f; |
| 206 | float arbitrary_float2 = 0.3f; |
| 207 | float arbitrary_float3 = 0.9f; |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 208 | float arbitrary_float_array[4] = {3.5f, 6.2f, 9.3f, 12.3f}; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 209 | bool arbitrary_bool1 = true; |
| 210 | bool arbitrary_bool2 = false; |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 211 | bool arbitrary_bool3 = true; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 212 | int arbitrary_int = 5; |
| 213 | SkColor arbitrary_color = SkColorSetARGB(25, 36, 47, 58); |
| 214 | IOSurfaceDrawQuad::Orientation arbitrary_orientation = |
| 215 | IOSurfaceDrawQuad::UNFLIPPED; |
| 216 | RenderPass::Id arbitrary_id(10, 14); |
[email protected] | b7cfc63 | 2013-04-10 04:44:49 | [diff] [blame] | 217 | ResourceProvider::ResourceId arbitrary_resourceid1 = 55; |
| 218 | ResourceProvider::ResourceId arbitrary_resourceid2 = 47; |
| 219 | ResourceProvider::ResourceId arbitrary_resourceid3 = 23; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 220 | |
| 221 | WebFilterOperations arbitrary_filters1; |
| 222 | arbitrary_filters1.append(WebFilterOperation::createGrayscaleFilter( |
| 223 | arbitrary_float1)); |
| 224 | |
| 225 | WebFilterOperations arbitrary_filters2; |
| 226 | arbitrary_filters2.append(WebFilterOperation::createBrightnessFilter( |
| 227 | arbitrary_float2)); |
| 228 | |
[email protected] | 1940c4e | 2012-12-04 05:08:15 | [diff] [blame] | 229 | // TODO(danakj): filter is not serialized. |
| 230 | skia::RefPtr<SkImageFilter> arbitrary_filter; |
| 231 | |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 232 | scoped_ptr<SharedQuadState> shared_state1_in = SharedQuadState::Create(); |
| 233 | shared_state1_in->SetAll(arbitrary_matrix, |
[email protected] | f902bf9 | 2013-03-04 18:33:27 | [diff] [blame] | 234 | arbitrary_size1, |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 235 | arbitrary_rect1, |
| 236 | arbitrary_rect2, |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 237 | arbitrary_bool1, |
| 238 | arbitrary_float1); |
| 239 | scoped_ptr<SharedQuadState> shared_state1_cmp = shared_state1_in->Copy(); |
| 240 | |
| 241 | scoped_ptr<CheckerboardDrawQuad> checkerboard_in = |
| 242 | CheckerboardDrawQuad::Create(); |
| 243 | checkerboard_in->SetAll(shared_state1_in.get(), |
| 244 | arbitrary_rect1, |
| 245 | arbitrary_rect2, |
| 246 | arbitrary_rect3, |
| 247 | arbitrary_bool1, |
| 248 | arbitrary_color); |
| 249 | scoped_ptr<DrawQuad> checkerboard_cmp = checkerboard_in->Copy( |
| 250 | checkerboard_in->shared_quad_state); |
| 251 | |
| 252 | scoped_ptr<DebugBorderDrawQuad> debugborder_in = |
| 253 | DebugBorderDrawQuad::Create(); |
| 254 | debugborder_in->SetAll(shared_state1_in.get(), |
| 255 | arbitrary_rect3, |
| 256 | arbitrary_rect1, |
| 257 | arbitrary_rect2, |
| 258 | arbitrary_bool1, |
| 259 | arbitrary_color, |
| 260 | arbitrary_int); |
| 261 | scoped_ptr<DrawQuad> debugborder_cmp = debugborder_in->Copy( |
| 262 | debugborder_in->shared_quad_state); |
| 263 | |
| 264 | scoped_ptr<IOSurfaceDrawQuad> iosurface_in = |
| 265 | IOSurfaceDrawQuad::Create(); |
| 266 | iosurface_in->SetAll(shared_state1_in.get(), |
| 267 | arbitrary_rect2, |
| 268 | arbitrary_rect3, |
| 269 | arbitrary_rect1, |
| 270 | arbitrary_bool1, |
| 271 | arbitrary_size1, |
[email protected] | b7cfc63 | 2013-04-10 04:44:49 | [diff] [blame] | 272 | arbitrary_resourceid3, |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 273 | arbitrary_orientation); |
| 274 | scoped_ptr<DrawQuad> iosurface_cmp = iosurface_in->Copy( |
| 275 | iosurface_in->shared_quad_state); |
| 276 | |
| 277 | scoped_ptr<RenderPassDrawQuad> renderpass_in = |
| 278 | RenderPassDrawQuad::Create(); |
| 279 | renderpass_in->SetAll(shared_state1_in.get(), |
| 280 | arbitrary_rect1, |
| 281 | arbitrary_rect2, |
| 282 | arbitrary_rect3, |
| 283 | arbitrary_bool1, |
| 284 | arbitrary_id, |
| 285 | arbitrary_bool2, |
[email protected] | b7cfc63 | 2013-04-10 04:44:49 | [diff] [blame] | 286 | arbitrary_resourceid2, |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 287 | arbitrary_rect1, |
[email protected] | 2006204 | 2012-12-21 22:16:36 | [diff] [blame] | 288 | arbitrary_rectf1, |
| 289 | arbitrary_filters1, |
[email protected] | 10a30b1 | 2013-05-02 16:42:11 | [diff] [blame^] | 290 | arbitrary_filter, // TODO(piman): not serialized. |
[email protected] | 2006204 | 2012-12-21 22:16:36 | [diff] [blame] | 291 | arbitrary_filters2); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 292 | scoped_ptr<RenderPassDrawQuad> renderpass_cmp = renderpass_in->Copy( |
| 293 | renderpass_in->shared_quad_state, renderpass_in->render_pass_id); |
| 294 | |
| 295 | scoped_ptr<SharedQuadState> shared_state2_in = SharedQuadState::Create(); |
| 296 | shared_state2_in->SetAll(arbitrary_matrix, |
[email protected] | f902bf9 | 2013-03-04 18:33:27 | [diff] [blame] | 297 | arbitrary_size2, |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 298 | arbitrary_rect2, |
| 299 | arbitrary_rect3, |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 300 | arbitrary_bool1, |
| 301 | arbitrary_float2); |
| 302 | scoped_ptr<SharedQuadState> shared_state2_cmp = shared_state2_in->Copy(); |
| 303 | |
| 304 | scoped_ptr<SharedQuadState> shared_state3_in = SharedQuadState::Create(); |
| 305 | shared_state3_in->SetAll(arbitrary_matrix, |
[email protected] | f902bf9 | 2013-03-04 18:33:27 | [diff] [blame] | 306 | arbitrary_size3, |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 307 | arbitrary_rect3, |
| 308 | arbitrary_rect1, |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 309 | arbitrary_bool1, |
| 310 | arbitrary_float3); |
| 311 | scoped_ptr<SharedQuadState> shared_state3_cmp = shared_state3_in->Copy(); |
| 312 | |
| 313 | scoped_ptr<SolidColorDrawQuad> solidcolor_in = |
| 314 | SolidColorDrawQuad::Create(); |
| 315 | solidcolor_in->SetAll(shared_state1_in.get(), |
| 316 | arbitrary_rect3, |
| 317 | arbitrary_rect1, |
| 318 | arbitrary_rect2, |
| 319 | arbitrary_bool1, |
[email protected] | 10a30b1 | 2013-05-02 16:42:11 | [diff] [blame^] | 320 | arbitrary_color, |
| 321 | arbitrary_bool2); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 322 | scoped_ptr<DrawQuad> solidcolor_cmp = solidcolor_in->Copy( |
| 323 | solidcolor_in->shared_quad_state); |
| 324 | |
| 325 | scoped_ptr<StreamVideoDrawQuad> streamvideo_in = |
| 326 | StreamVideoDrawQuad::Create(); |
| 327 | streamvideo_in->SetAll(shared_state1_in.get(), |
| 328 | arbitrary_rect2, |
| 329 | arbitrary_rect3, |
| 330 | arbitrary_rect1, |
| 331 | arbitrary_bool1, |
[email protected] | b7cfc63 | 2013-04-10 04:44:49 | [diff] [blame] | 332 | arbitrary_resourceid2, |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 333 | arbitrary_matrix); |
| 334 | scoped_ptr<DrawQuad> streamvideo_cmp = streamvideo_in->Copy( |
| 335 | streamvideo_in->shared_quad_state); |
| 336 | |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 337 | scoped_ptr<TextureDrawQuad> texture_in = TextureDrawQuad::Create(); |
| 338 | texture_in->SetAll(shared_state1_in.get(), |
| 339 | arbitrary_rect2, |
| 340 | arbitrary_rect3, |
| 341 | arbitrary_rect1, |
| 342 | arbitrary_bool1, |
[email protected] | b7cfc63 | 2013-04-10 04:44:49 | [diff] [blame] | 343 | arbitrary_resourceid1, |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 344 | arbitrary_bool2, |
| 345 | arbitrary_pointf1, |
| 346 | arbitrary_pointf2, |
| 347 | arbitrary_float_array, |
| 348 | arbitrary_bool3); |
| 349 | scoped_ptr<DrawQuad> texture_cmp = texture_in->Copy( |
| 350 | texture_in->shared_quad_state); |
| 351 | |
| 352 | scoped_ptr<TileDrawQuad> tile_in = TileDrawQuad::Create(); |
| 353 | tile_in->SetAll(shared_state1_in.get(), |
| 354 | arbitrary_rect2, |
| 355 | arbitrary_rect3, |
| 356 | arbitrary_rect1, |
| 357 | arbitrary_bool1, |
[email protected] | b7cfc63 | 2013-04-10 04:44:49 | [diff] [blame] | 358 | arbitrary_resourceid3, |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 359 | arbitrary_rectf1, |
| 360 | arbitrary_size1, |
[email protected] | f902bf9 | 2013-03-04 18:33:27 | [diff] [blame] | 361 | arbitrary_bool2); |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 362 | scoped_ptr<DrawQuad> tile_cmp = tile_in->Copy( |
| 363 | tile_in->shared_quad_state); |
| 364 | |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 365 | scoped_ptr<YUVVideoDrawQuad> yuvvideo_in = |
| 366 | YUVVideoDrawQuad::Create(); |
| 367 | yuvvideo_in->SetAll(shared_state1_in.get(), |
| 368 | arbitrary_rect1, |
| 369 | arbitrary_rect2, |
| 370 | arbitrary_rect3, |
| 371 | arbitrary_bool1, |
| 372 | arbitrary_sizef1, |
[email protected] | b7cfc63 | 2013-04-10 04:44:49 | [diff] [blame] | 373 | arbitrary_resourceid1, |
| 374 | arbitrary_resourceid2, |
| 375 | arbitrary_resourceid3); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 376 | scoped_ptr<DrawQuad> yuvvideo_cmp = yuvvideo_in->Copy( |
| 377 | yuvvideo_in->shared_quad_state); |
| 378 | |
| 379 | scoped_ptr<RenderPass> pass_in = RenderPass::Create(); |
| 380 | pass_in->SetAll(arbitrary_id, |
| 381 | arbitrary_rect1, |
| 382 | arbitrary_rectf1, |
| 383 | arbitrary_matrix, |
| 384 | arbitrary_bool1, |
[email protected] | 2006204 | 2012-12-21 22:16:36 | [diff] [blame] | 385 | arbitrary_bool2); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 386 | |
[email protected] | ead39c5 | 2013-01-09 07:22:45 | [diff] [blame] | 387 | pass_in->shared_quad_state_list.push_back(shared_state1_in.Pass()); |
| 388 | pass_in->quad_list.push_back(checkerboard_in.PassAs<DrawQuad>()); |
| 389 | pass_in->quad_list.push_back(debugborder_in.PassAs<DrawQuad>()); |
| 390 | pass_in->quad_list.push_back(iosurface_in.PassAs<DrawQuad>()); |
| 391 | pass_in->quad_list.push_back(renderpass_in.PassAs<DrawQuad>()); |
| 392 | pass_in->shared_quad_state_list.push_back(shared_state2_in.Pass()); |
| 393 | pass_in->shared_quad_state_list.push_back(shared_state3_in.Pass()); |
| 394 | pass_in->quad_list.push_back(solidcolor_in.PassAs<DrawQuad>()); |
| 395 | pass_in->quad_list.push_back(streamvideo_in.PassAs<DrawQuad>()); |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 396 | pass_in->quad_list.push_back(texture_in.PassAs<DrawQuad>()); |
| 397 | pass_in->quad_list.push_back(tile_in.PassAs<DrawQuad>()); |
[email protected] | ead39c5 | 2013-01-09 07:22:45 | [diff] [blame] | 398 | pass_in->quad_list.push_back(yuvvideo_in.PassAs<DrawQuad>()); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 399 | |
| 400 | scoped_ptr<RenderPass> pass_cmp = RenderPass::Create(); |
| 401 | pass_cmp->SetAll(arbitrary_id, |
| 402 | arbitrary_rect1, |
| 403 | arbitrary_rectf1, |
| 404 | arbitrary_matrix, |
| 405 | arbitrary_bool1, |
[email protected] | 2006204 | 2012-12-21 22:16:36 | [diff] [blame] | 406 | arbitrary_bool2); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 407 | |
[email protected] | ead39c5 | 2013-01-09 07:22:45 | [diff] [blame] | 408 | pass_cmp->shared_quad_state_list.push_back(shared_state1_cmp.Pass()); |
| 409 | pass_cmp->quad_list.push_back(checkerboard_cmp.PassAs<DrawQuad>()); |
| 410 | pass_cmp->quad_list.push_back(debugborder_cmp.PassAs<DrawQuad>()); |
| 411 | pass_cmp->quad_list.push_back(iosurface_cmp.PassAs<DrawQuad>()); |
| 412 | pass_cmp->quad_list.push_back(renderpass_cmp.PassAs<DrawQuad>()); |
| 413 | pass_cmp->shared_quad_state_list.push_back(shared_state2_cmp.Pass()); |
| 414 | pass_cmp->shared_quad_state_list.push_back(shared_state3_cmp.Pass()); |
| 415 | pass_cmp->quad_list.push_back(solidcolor_cmp.PassAs<DrawQuad>()); |
| 416 | pass_cmp->quad_list.push_back(streamvideo_cmp.PassAs<DrawQuad>()); |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 417 | pass_cmp->quad_list.push_back(texture_cmp.PassAs<DrawQuad>()); |
| 418 | pass_cmp->quad_list.push_back(tile_cmp.PassAs<DrawQuad>()); |
[email protected] | ead39c5 | 2013-01-09 07:22:45 | [diff] [blame] | 419 | pass_cmp->quad_list.push_back(yuvvideo_cmp.PassAs<DrawQuad>()); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 420 | |
| 421 | // Make sure the in and cmp RenderPasses match. |
| 422 | Compare(pass_cmp.get(), pass_in.get()); |
| 423 | ASSERT_EQ(3u, pass_in->shared_quad_state_list.size()); |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 424 | ASSERT_EQ(9u, pass_in->quad_list.size()); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 425 | for (size_t i = 0; i < 3; ++i) { |
| 426 | Compare(pass_cmp->shared_quad_state_list[i], |
| 427 | pass_in->shared_quad_state_list[i]); |
| 428 | } |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 429 | for (size_t i = 0; i < pass_in->quad_list.size(); ++i) |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 430 | Compare(pass_cmp->quad_list[i], pass_in->quad_list[i]); |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 431 | for (size_t i = 1; i < pass_in->quad_list.size(); ++i) { |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 432 | bool same_shared_quad_state_cmp = |
| 433 | pass_cmp->quad_list[i]->shared_quad_state == |
| 434 | pass_cmp->quad_list[i - 1]->shared_quad_state; |
| 435 | bool same_shared_quad_state_in = |
| 436 | pass_in->quad_list[i]->shared_quad_state == |
| 437 | pass_in->quad_list[i - 1]->shared_quad_state; |
| 438 | EXPECT_EQ(same_shared_quad_state_cmp, same_shared_quad_state_in); |
| 439 | } |
| 440 | |
[email protected] | bf189f6 | 2012-12-18 03:42:11 | [diff] [blame] | 441 | DelegatedFrameData frame_in; |
[email protected] | ead39c5 | 2013-01-09 07:22:45 | [diff] [blame] | 442 | frame_in.render_pass_list.push_back(pass_in.Pass()); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 443 | |
[email protected] | bf189f6 | 2012-12-18 03:42:11 | [diff] [blame] | 444 | IPC::ParamTraits<DelegatedFrameData>::Write(&msg, frame_in); |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 445 | |
[email protected] | bf189f6 | 2012-12-18 03:42:11 | [diff] [blame] | 446 | DelegatedFrameData frame_out; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 447 | PickleIterator iter(msg); |
[email protected] | bf189f6 | 2012-12-18 03:42:11 | [diff] [blame] | 448 | EXPECT_TRUE(IPC::ParamTraits<DelegatedFrameData>::Read(&msg, |
| 449 | &iter, &frame_out)); |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 450 | |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 451 | // Make sure the out and cmp RenderPasses match. |
[email protected] | ead39c5 | 2013-01-09 07:22:45 | [diff] [blame] | 452 | scoped_ptr<RenderPass> pass_out = frame_out.render_pass_list.take( |
| 453 | frame_out.render_pass_list.begin()); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 454 | Compare(pass_cmp.get(), pass_out.get()); |
| 455 | ASSERT_EQ(3u, pass_out->shared_quad_state_list.size()); |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 456 | ASSERT_EQ(9u, pass_out->quad_list.size()); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 457 | for (size_t i = 0; i < 3; ++i) { |
| 458 | Compare(pass_cmp->shared_quad_state_list[i], |
| 459 | pass_out->shared_quad_state_list[i]); |
| 460 | } |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 461 | for (size_t i = 0; i < pass_out->quad_list.size(); ++i) |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 462 | Compare(pass_cmp->quad_list[i], pass_out->quad_list[i]); |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 463 | for (size_t i = 1; i < pass_out->quad_list.size(); ++i) { |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 464 | bool same_shared_quad_state_cmp = |
| 465 | pass_cmp->quad_list[i]->shared_quad_state == |
| 466 | pass_cmp->quad_list[i - 1]->shared_quad_state; |
| 467 | bool same_shared_quad_state_out = |
| 468 | pass_out->quad_list[i]->shared_quad_state == |
| 469 | pass_out->quad_list[i - 1]->shared_quad_state; |
| 470 | EXPECT_EQ(same_shared_quad_state_cmp, same_shared_quad_state_out); |
| 471 | } |
| 472 | } |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 473 | |
| 474 | TEST_F(CCMessagesTest, Resources) { |
| 475 | IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); |
| 476 | gfx::Size arbitrary_size(757, 1281); |
[email protected] | 09831f7f | 2013-02-27 03:32:15 | [diff] [blame] | 477 | unsigned int arbitrary_uint1 = 71234838; |
| 478 | unsigned int arbitrary_uint2 = 53589793; |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 479 | |
| 480 | GLbyte arbitrary_mailbox1[64] = { |
| 481 | 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, |
| 482 | 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, |
| 483 | 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, |
| 484 | 1, 2, 3, 4 |
| 485 | }; |
| 486 | |
| 487 | GLbyte arbitrary_mailbox2[64] = { |
| 488 | 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, |
| 489 | 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, |
| 490 | 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, |
| 491 | 0, 9, 8, 7 |
| 492 | }; |
| 493 | |
| 494 | TransferableResource arbitrary_resource1; |
| 495 | arbitrary_resource1.id = 2178312; |
[email protected] | 09831f7f | 2013-02-27 03:32:15 | [diff] [blame] | 496 | arbitrary_resource1.sync_point = arbitrary_uint1; |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 497 | arbitrary_resource1.format = 7; |
[email protected] | 8018929 | 2013-02-28 01:59:36 | [diff] [blame] | 498 | arbitrary_resource1.filter = 53; |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 499 | arbitrary_resource1.size = gfx::Size(37189, 123123); |
[email protected] | 1aca009 | 2013-03-04 22:46:03 | [diff] [blame] | 500 | arbitrary_resource1.mailbox.SetName(arbitrary_mailbox1); |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 501 | |
| 502 | TransferableResource arbitrary_resource2; |
| 503 | arbitrary_resource2.id = 789132; |
[email protected] | 09831f7f | 2013-02-27 03:32:15 | [diff] [blame] | 504 | arbitrary_resource1.sync_point = arbitrary_uint2; |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 505 | arbitrary_resource2.format = 30; |
[email protected] | 8018929 | 2013-02-28 01:59:36 | [diff] [blame] | 506 | arbitrary_resource1.filter = 47; |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 507 | arbitrary_resource2.size = gfx::Size(89123, 23789); |
[email protected] | 1aca009 | 2013-03-04 22:46:03 | [diff] [blame] | 508 | arbitrary_resource2.mailbox.SetName(arbitrary_mailbox2); |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 509 | |
[email protected] | bf189f6 | 2012-12-18 03:42:11 | [diff] [blame] | 510 | DelegatedFrameData frame_in; |
[email protected] | 09831f7f | 2013-02-27 03:32:15 | [diff] [blame] | 511 | frame_in.resource_list.push_back(arbitrary_resource1); |
| 512 | frame_in.resource_list.push_back(arbitrary_resource2); |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 513 | |
[email protected] | bf189f6 | 2012-12-18 03:42:11 | [diff] [blame] | 514 | IPC::ParamTraits<DelegatedFrameData>::Write(&msg, frame_in); |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 515 | |
[email protected] | bf189f6 | 2012-12-18 03:42:11 | [diff] [blame] | 516 | DelegatedFrameData frame_out; |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 517 | PickleIterator iter(msg); |
[email protected] | bf189f6 | 2012-12-18 03:42:11 | [diff] [blame] | 518 | EXPECT_TRUE(IPC::ParamTraits<DelegatedFrameData>::Read(&msg, |
| 519 | &iter, &frame_out)); |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 520 | |
[email protected] | 09831f7f | 2013-02-27 03:32:15 | [diff] [blame] | 521 | ASSERT_EQ(2u, frame_out.resource_list.size()); |
| 522 | Compare(arbitrary_resource1, frame_out.resource_list[0]); |
| 523 | Compare(arbitrary_resource2, frame_out.resource_list[1]); |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 524 | } |
| 525 | |
| 526 | } // namespace |
| 527 | } // namespace content |