[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] | 032bfc4 | 2013-10-29 22:23:52 | [diff] [blame] | 9 | #include <algorithm> |
| 10 | |
[email protected] | 7f0d825f | 2013-03-18 07:24:30 | [diff] [blame] | 11 | #include "cc/output/compositor_frame.h" |
[email protected] | cecc834 | 2014-03-20 21:43:39 | [diff] [blame] | 12 | #include "content/public/common/common_param_traits.h" |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 13 | #include "ipc/ipc_message.h" |
| 14 | #include "testing/gtest/include/gtest/gtest.h" |
[email protected] | 645a47f2 | 2013-09-26 05:42:32 | [diff] [blame] | 15 | #include "third_party/khronos/GLES2/gl2ext.h" |
[email protected] | a176567 | 2013-08-12 23:45:02 | [diff] [blame] | 16 | #include "third_party/skia/include/effects/SkBlurImageFilter.h" |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 17 | |
[email protected] | cecc834 | 2014-03-20 21:43:39 | [diff] [blame] | 18 | #if defined(OS_POSIX) |
| 19 | #include "base/file_descriptor_posix.h" |
| 20 | #endif |
| 21 | |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 22 | using cc::CheckerboardDrawQuad; |
[email protected] | bf189f6 | 2012-12-18 03:42:11 | [diff] [blame] | 23 | using cc::DelegatedFrameData; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 24 | using cc::DebugBorderDrawQuad; |
| 25 | using cc::DrawQuad; |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame] | 26 | using cc::FilterOperation; |
| 27 | using cc::FilterOperations; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 28 | using cc::IOSurfaceDrawQuad; |
[email protected] | 9ee4d3a | 2013-03-27 17:43:16 | [diff] [blame] | 29 | using cc::PictureDrawQuad; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 30 | using cc::RenderPass; |
[email protected] | 0cd7d6f7 | 2014-08-22 14:50:51 | [diff] [blame] | 31 | using cc::RenderPassId; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 32 | using cc::RenderPassDrawQuad; |
| 33 | using cc::ResourceProvider; |
| 34 | using cc::SharedQuadState; |
[email protected] | cecc834 | 2014-03-20 21:43:39 | [diff] [blame] | 35 | using cc::SoftwareFrameData; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 36 | using cc::SolidColorDrawQuad; |
[email protected] | 78d3012 | 2014-01-17 06:32:36 | [diff] [blame] | 37 | using cc::SurfaceDrawQuad; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 38 | using cc::TextureDrawQuad; |
| 39 | using cc::TileDrawQuad; |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 40 | using cc::TransferableResource; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 41 | using cc::StreamVideoDrawQuad; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 42 | using cc::YUVVideoDrawQuad; |
[email protected] | c8686a0 | 2012-11-27 08:29:00 | [diff] [blame] | 43 | using gfx::Transform; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 44 | |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 45 | namespace content { |
| 46 | namespace { |
| 47 | |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 48 | class CCMessagesTest : public testing::Test { |
| 49 | protected: |
| 50 | void Compare(const RenderPass* a, const RenderPass* b) { |
| 51 | EXPECT_EQ(a->id, b->id); |
| 52 | EXPECT_EQ(a->output_rect.ToString(), b->output_rect.ToString()); |
| 53 | EXPECT_EQ(a->damage_rect.ToString(), b->damage_rect.ToString()); |
| 54 | EXPECT_EQ(a->transform_to_root_target, b->transform_to_root_target); |
| 55 | EXPECT_EQ(a->has_transparent_background, b->has_transparent_background); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | void Compare(const SharedQuadState* a, const SharedQuadState* b) { |
| 59 | EXPECT_EQ(a->content_to_target_transform, b->content_to_target_transform); |
[email protected] | f902bf9 | 2013-03-04 18:33:27 | [diff] [blame] | 60 | EXPECT_EQ(a->content_bounds, b->content_bounds); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 61 | EXPECT_EQ(a->visible_content_rect, b->visible_content_rect); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 62 | EXPECT_EQ(a->clip_rect, b->clip_rect); |
| 63 | EXPECT_EQ(a->is_clipped, b->is_clipped); |
| 64 | EXPECT_EQ(a->opacity, b->opacity); |
[email protected] | 7bbeaf4e | 2013-11-26 10:27:22 | [diff] [blame] | 65 | EXPECT_EQ(a->blend_mode, b->blend_mode); |
[email protected] | a9d4d4f | 2014-06-19 06:49:28 | [diff] [blame] | 66 | EXPECT_EQ(a->sorting_context_id, b->sorting_context_id); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | void Compare(const DrawQuad* a, const DrawQuad* b) { |
| 70 | ASSERT_NE(DrawQuad::INVALID, a->material); |
| 71 | ASSERT_EQ(a->material, b->material); |
| 72 | EXPECT_EQ(a->rect.ToString(), b->rect.ToString()); |
| 73 | EXPECT_EQ(a->opaque_rect.ToString(), b->opaque_rect.ToString()); |
| 74 | EXPECT_EQ(a->visible_rect.ToString(), b->visible_rect.ToString()); |
| 75 | EXPECT_EQ(a->needs_blending, b->needs_blending); |
| 76 | |
| 77 | Compare(a->shared_quad_state, b->shared_quad_state); |
| 78 | |
| 79 | switch (a->material) { |
| 80 | case DrawQuad::CHECKERBOARD: |
| 81 | Compare(CheckerboardDrawQuad::MaterialCast(a), |
| 82 | CheckerboardDrawQuad::MaterialCast(b)); |
| 83 | break; |
| 84 | case DrawQuad::DEBUG_BORDER: |
| 85 | Compare(DebugBorderDrawQuad::MaterialCast(a), |
| 86 | DebugBorderDrawQuad::MaterialCast(b)); |
| 87 | break; |
| 88 | case DrawQuad::IO_SURFACE_CONTENT: |
| 89 | Compare(IOSurfaceDrawQuad::MaterialCast(a), |
| 90 | IOSurfaceDrawQuad::MaterialCast(b)); |
| 91 | break; |
[email protected] | 9ee4d3a | 2013-03-27 17:43:16 | [diff] [blame] | 92 | case DrawQuad::PICTURE_CONTENT: |
| 93 | Compare(PictureDrawQuad::MaterialCast(a), |
| 94 | PictureDrawQuad::MaterialCast(b)); |
| 95 | break; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 96 | case DrawQuad::RENDER_PASS: |
| 97 | Compare(RenderPassDrawQuad::MaterialCast(a), |
| 98 | RenderPassDrawQuad::MaterialCast(b)); |
| 99 | break; |
| 100 | case DrawQuad::TEXTURE_CONTENT: |
| 101 | Compare(TextureDrawQuad::MaterialCast(a), |
| 102 | TextureDrawQuad::MaterialCast(b)); |
| 103 | break; |
| 104 | case DrawQuad::TILED_CONTENT: |
| 105 | Compare(TileDrawQuad::MaterialCast(a), |
| 106 | TileDrawQuad::MaterialCast(b)); |
| 107 | break; |
| 108 | case DrawQuad::SOLID_COLOR: |
| 109 | Compare(SolidColorDrawQuad::MaterialCast(a), |
| 110 | SolidColorDrawQuad::MaterialCast(b)); |
| 111 | break; |
| 112 | case DrawQuad::STREAM_VIDEO_CONTENT: |
| 113 | Compare(StreamVideoDrawQuad::MaterialCast(a), |
| 114 | StreamVideoDrawQuad::MaterialCast(b)); |
| 115 | break; |
[email protected] | 78d3012 | 2014-01-17 06:32:36 | [diff] [blame] | 116 | case DrawQuad::SURFACE_CONTENT: |
| 117 | Compare(SurfaceDrawQuad::MaterialCast(a), |
| 118 | SurfaceDrawQuad::MaterialCast(b)); |
| 119 | break; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 120 | case DrawQuad::YUV_VIDEO_CONTENT: |
| 121 | Compare(YUVVideoDrawQuad::MaterialCast(a), |
| 122 | YUVVideoDrawQuad::MaterialCast(b)); |
| 123 | break; |
| 124 | case DrawQuad::INVALID: |
| 125 | break; |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | void Compare(const CheckerboardDrawQuad* a, const CheckerboardDrawQuad* b) { |
| 130 | EXPECT_EQ(a->color, b->color); |
danakj | e1419ce | 2015-03-04 21:26:27 | [diff] [blame] | 131 | EXPECT_EQ(a->scale, b->scale); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | void Compare(const DebugBorderDrawQuad* a, const DebugBorderDrawQuad* b) { |
| 135 | EXPECT_EQ(a->color, b->color); |
| 136 | EXPECT_EQ(a->width, b->width); |
| 137 | } |
| 138 | |
| 139 | void Compare(const IOSurfaceDrawQuad* a, const IOSurfaceDrawQuad* b) { |
| 140 | EXPECT_EQ(a->io_surface_size.ToString(), b->io_surface_size.ToString()); |
[email protected] | b7cfc63 | 2013-04-10 04:44:49 | [diff] [blame] | 141 | EXPECT_EQ(a->io_surface_resource_id, b->io_surface_resource_id); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 142 | EXPECT_EQ(a->orientation, b->orientation); |
| 143 | } |
| 144 | |
| 145 | void Compare(const RenderPassDrawQuad* a, const RenderPassDrawQuad* b) { |
[email protected] | 82f93fb | 2013-04-17 21:42:06 | [diff] [blame] | 146 | EXPECT_EQ(a->render_pass_id, b->render_pass_id); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 147 | EXPECT_EQ(a->mask_resource_id, b->mask_resource_id); |
enne | f6f3fbba4 | 2014-10-16 18:16:49 | [diff] [blame] | 148 | EXPECT_EQ(a->mask_uv_scale.ToString(), b->mask_uv_scale.ToString()); |
| 149 | EXPECT_EQ(a->mask_texture_size.ToString(), b->mask_texture_size.ToString()); |
[email protected] | 1dc7943e | 2013-09-26 04:41:48 | [diff] [blame] | 150 | EXPECT_EQ(a->filters.size(), b->filters.size()); |
| 151 | for (size_t i = 0; i < a->filters.size(); ++i) { |
| 152 | if (a->filters.at(i).type() != cc::FilterOperation::REFERENCE) { |
| 153 | EXPECT_EQ(a->filters.at(i), b->filters.at(i)); |
| 154 | } else { |
| 155 | EXPECT_EQ(b->filters.at(i).type(), cc::FilterOperation::REFERENCE); |
| 156 | EXPECT_EQ(a->filters.at(i).image_filter()->countInputs(), |
| 157 | b->filters.at(i).image_filter()->countInputs()); |
| 158 | } |
| 159 | } |
[email protected] | 7ac3d49 | 2014-08-08 21:25:32 | [diff] [blame] | 160 | EXPECT_EQ(a->filters_scale, b->filters_scale); |
[email protected] | 2006204 | 2012-12-21 22:16:36 | [diff] [blame] | 161 | EXPECT_EQ(a->background_filters, b->background_filters); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | void Compare(const SolidColorDrawQuad* a, const SolidColorDrawQuad* b) { |
| 165 | EXPECT_EQ(a->color, b->color); |
[email protected] | 10a30b1 | 2013-05-02 16:42:11 | [diff] [blame] | 166 | EXPECT_EQ(a->force_anti_aliasing_off, b->force_anti_aliasing_off); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 167 | } |
| 168 | |
| 169 | void Compare(const StreamVideoDrawQuad* a, const StreamVideoDrawQuad* b) { |
[email protected] | b7cfc63 | 2013-04-10 04:44:49 | [diff] [blame] | 170 | EXPECT_EQ(a->resource_id, b->resource_id); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 171 | EXPECT_EQ(a->matrix, b->matrix); |
| 172 | } |
| 173 | |
[email protected] | 78d3012 | 2014-01-17 06:32:36 | [diff] [blame] | 174 | void Compare(const SurfaceDrawQuad* a, const SurfaceDrawQuad* b) { |
| 175 | EXPECT_EQ(a->surface_id, b->surface_id); |
| 176 | } |
| 177 | |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 178 | void Compare(const TextureDrawQuad* a, const TextureDrawQuad* b) { |
| 179 | EXPECT_EQ(a->resource_id, b->resource_id); |
| 180 | EXPECT_EQ(a->premultiplied_alpha, b->premultiplied_alpha); |
[email protected] | 1fd555b | 2013-01-18 00:13:21 | [diff] [blame] | 181 | EXPECT_EQ(a->uv_top_left, b->uv_top_left); |
| 182 | EXPECT_EQ(a->uv_bottom_right, b->uv_bottom_right); |
[email protected] | d18b4d6 | 2013-07-12 05:33:49 | [diff] [blame] | 183 | EXPECT_EQ(a->background_color, b->background_color); |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 184 | EXPECT_EQ(a->vertex_opacity[0], b->vertex_opacity[0]); |
| 185 | EXPECT_EQ(a->vertex_opacity[1], b->vertex_opacity[1]); |
| 186 | EXPECT_EQ(a->vertex_opacity[2], b->vertex_opacity[2]); |
| 187 | EXPECT_EQ(a->vertex_opacity[3], b->vertex_opacity[3]); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 188 | EXPECT_EQ(a->flipped, b->flipped); |
jackhou | 10c9af4 | 2014-12-04 05:24:44 | [diff] [blame] | 189 | EXPECT_EQ(a->nearest_neighbor, b->nearest_neighbor); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | void Compare(const TileDrawQuad* a, const TileDrawQuad* b) { |
| 193 | EXPECT_EQ(a->resource_id, b->resource_id); |
| 194 | EXPECT_EQ(a->tex_coord_rect, b->tex_coord_rect); |
| 195 | EXPECT_EQ(a->texture_size, b->texture_size); |
| 196 | EXPECT_EQ(a->swizzle_contents, b->swizzle_contents); |
jackhou | 2422961 | 2014-12-13 23:41:00 | [diff] [blame] | 197 | EXPECT_EQ(a->nearest_neighbor, b->nearest_neighbor); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | void Compare(const YUVVideoDrawQuad* a, const YUVVideoDrawQuad* b) { |
[email protected] | 95052aa | 2014-03-27 11:43:50 | [diff] [blame] | 201 | EXPECT_EQ(a->tex_coord_rect, b->tex_coord_rect); |
magjed | 7364ff9 | 2015-03-27 09:11:08 | [diff] [blame^] | 202 | EXPECT_EQ(a->ya_tex_size, b->ya_tex_size); |
| 203 | EXPECT_EQ(a->uv_tex_size, b->uv_tex_size); |
[email protected] | b7cfc63 | 2013-04-10 04:44:49 | [diff] [blame] | 204 | EXPECT_EQ(a->y_plane_resource_id, b->y_plane_resource_id); |
| 205 | EXPECT_EQ(a->u_plane_resource_id, b->u_plane_resource_id); |
| 206 | EXPECT_EQ(a->v_plane_resource_id, b->v_plane_resource_id); |
[email protected] | 0402b238 | 2013-06-07 21:50:54 | [diff] [blame] | 207 | EXPECT_EQ(a->a_plane_resource_id, b->a_plane_resource_id); |
[email protected] | 82faf5e | 2014-05-03 02:25:58 | [diff] [blame] | 208 | EXPECT_EQ(a->color_space, b->color_space); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 209 | } |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 210 | |
| 211 | void Compare(const TransferableResource& a, const TransferableResource& b) { |
| 212 | EXPECT_EQ(a.id, b.id); |
| 213 | EXPECT_EQ(a.format, b.format); |
[email protected] | 8018929 | 2013-02-28 01:59:36 | [diff] [blame] | 214 | EXPECT_EQ(a.filter, b.filter); |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 215 | EXPECT_EQ(a.size.ToString(), b.size.ToString()); |
[email protected] | df41e25 | 2014-02-03 23:39:50 | [diff] [blame] | 216 | for (size_t i = 0; i < arraysize(a.mailbox_holder.mailbox.name); ++i) { |
| 217 | EXPECT_EQ(a.mailbox_holder.mailbox.name[i], |
| 218 | b.mailbox_holder.mailbox.name[i]); |
| 219 | } |
| 220 | EXPECT_EQ(a.mailbox_holder.texture_target, b.mailbox_holder.texture_target); |
| 221 | EXPECT_EQ(a.mailbox_holder.sync_point, b.mailbox_holder.sync_point); |
[email protected] | a8c63be2 | 2014-08-07 02:39:49 | [diff] [blame] | 222 | EXPECT_EQ(a.allow_overlay, b.allow_overlay); |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 223 | } |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 224 | }; |
| 225 | |
| 226 | TEST_F(CCMessagesTest, AllQuads) { |
[email protected] | 753bb25 | 2013-11-04 22:28:12 | [diff] [blame] | 227 | IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 228 | |
[email protected] | c8686a0 | 2012-11-27 08:29:00 | [diff] [blame] | 229 | Transform arbitrary_matrix; |
| 230 | arbitrary_matrix.Scale(3, 3); |
| 231 | arbitrary_matrix.Translate(-5, 20); |
| 232 | arbitrary_matrix.Rotate(15); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 233 | gfx::Rect arbitrary_rect1(-5, 9, 3, 15); |
[email protected] | 8e1da69 | 2013-10-12 17:11:30 | [diff] [blame] | 234 | gfx::Rect arbitrary_rect1_inside_rect1(-4, 12, 2, 8); |
| 235 | gfx::Rect arbitrary_rect2_inside_rect1(-5, 11, 1, 2); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 236 | gfx::Rect arbitrary_rect2(40, 23, 11, 7); |
[email protected] | 8e1da69 | 2013-10-12 17:11:30 | [diff] [blame] | 237 | gfx::Rect arbitrary_rect1_inside_rect2(44, 23, 4, 2); |
| 238 | gfx::Rect arbitrary_rect2_inside_rect2(41, 25, 3, 5); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 239 | gfx::Rect arbitrary_rect3(7, -53, 22, 19); |
[email protected] | 8e1da69 | 2013-10-12 17:11:30 | [diff] [blame] | 240 | gfx::Rect arbitrary_rect1_inside_rect3(10, -40, 6, 3); |
| 241 | gfx::Rect arbitrary_rect2_inside_rect3(12, -51, 5, 12); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 242 | 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); |
| 246 | gfx::SizeF arbitrary_sizef1(15.2f, 104.6f); |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 247 | gfx::PointF arbitrary_pointf1(31.4f, 15.9f); |
| 248 | gfx::PointF arbitrary_pointf2(26.5f, -35.8f); |
[email protected] | 7ac3d49 | 2014-08-08 21:25:32 | [diff] [blame] | 249 | gfx::Vector2dF arbitrary_vector2df1(16.2f, -85.1f); |
enne | f6f3fbba4 | 2014-10-16 18:16:49 | [diff] [blame] | 250 | gfx::Vector2dF arbitrary_vector2df2(-8.3f, 0.47f); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 251 | float arbitrary_float1 = 0.7f; |
| 252 | float arbitrary_float2 = 0.3f; |
| 253 | float arbitrary_float3 = 0.9f; |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 254 | float arbitrary_float_array[4] = {3.5f, 6.2f, 9.3f, 12.3f}; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 255 | bool arbitrary_bool1 = true; |
| 256 | bool arbitrary_bool2 = false; |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 257 | bool arbitrary_bool3 = true; |
jackhou | 10c9af4 | 2014-12-04 05:24:44 | [diff] [blame] | 258 | bool arbitrary_bool4 = true; |
[email protected] | a9d4d4f | 2014-06-19 06:49:28 | [diff] [blame] | 259 | int arbitrary_context_id1 = 12; |
| 260 | int arbitrary_context_id2 = 57; |
| 261 | int arbitrary_context_id3 = -503; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 262 | int arbitrary_int = 5; |
| 263 | SkColor arbitrary_color = SkColorSetARGB(25, 36, 47, 58); |
[email protected] | 7bbeaf4e | 2013-11-26 10:27:22 | [diff] [blame] | 264 | 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] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 267 | IOSurfaceDrawQuad::Orientation arbitrary_orientation = |
| 268 | IOSurfaceDrawQuad::UNFLIPPED; |
[email protected] | 0cd7d6f7 | 2014-08-22 14:50:51 | [diff] [blame] | 269 | RenderPassId arbitrary_id(10, 14); |
[email protected] | b7cfc63 | 2013-04-10 04:44:49 | [diff] [blame] | 270 | ResourceProvider::ResourceId arbitrary_resourceid1 = 55; |
| 271 | ResourceProvider::ResourceId arbitrary_resourceid2 = 47; |
| 272 | ResourceProvider::ResourceId arbitrary_resourceid3 = 23; |
[email protected] | 0402b238 | 2013-06-07 21:50:54 | [diff] [blame] | 273 | ResourceProvider::ResourceId arbitrary_resourceid4 = 16; |
[email protected] | a176567 | 2013-08-12 23:45:02 | [diff] [blame] | 274 | SkScalar arbitrary_sigma = SkFloatToScalar(2.0f); |
[email protected] | 82faf5e | 2014-05-03 02:25:58 | [diff] [blame] | 275 | YUVVideoDrawQuad::ColorSpace arbitrary_color_space = |
| 276 | YUVVideoDrawQuad::REC_601; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 277 | |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame] | 278 | FilterOperations arbitrary_filters1; |
| 279 | arbitrary_filters1.Append(FilterOperation::CreateGrayscaleFilter( |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 280 | arbitrary_float1)); |
[email protected] | 1dc7943e | 2013-09-26 04:41:48 | [diff] [blame] | 281 | skia::RefPtr<SkImageFilter> arbitrary_filter = skia::AdoptRef( |
[email protected] | bb209bf | 2014-05-11 00:37:11 | [diff] [blame] | 282 | SkBlurImageFilter::Create(arbitrary_sigma, arbitrary_sigma)); |
[email protected] | 1dc7943e | 2013-09-26 04:41:48 | [diff] [blame] | 283 | arbitrary_filters1.Append( |
| 284 | cc::FilterOperation::CreateReferenceFilter(arbitrary_filter)); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 285 | |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame] | 286 | FilterOperations arbitrary_filters2; |
| 287 | arbitrary_filters2.Append(FilterOperation::CreateBrightnessFilter( |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 288 | arbitrary_float2)); |
| 289 | |
[email protected] | 2b7f389 | 2014-05-08 01:45:18 | [diff] [blame] | 290 | scoped_ptr<RenderPass> pass_in = RenderPass::Create(); |
| 291 | pass_in->SetAll(arbitrary_id, |
| 292 | arbitrary_rect1, |
| 293 | arbitrary_rect2, |
| 294 | arbitrary_matrix, |
| 295 | arbitrary_bool1); |
| 296 | |
| 297 | SharedQuadState* shared_state1_in = pass_in->CreateAndAppendSharedQuadState(); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 298 | shared_state1_in->SetAll(arbitrary_matrix, |
[email protected] | f902bf9 | 2013-03-04 18:33:27 | [diff] [blame] | 299 | arbitrary_size1, |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 300 | arbitrary_rect1, |
| 301 | arbitrary_rect2, |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 302 | arbitrary_bool1, |
[email protected] | 7bbeaf4e | 2013-11-26 10:27:22 | [diff] [blame] | 303 | arbitrary_float1, |
[email protected] | a9d4d4f | 2014-06-19 06:49:28 | [diff] [blame] | 304 | arbitrary_blend_mode1, |
| 305 | arbitrary_context_id1); |
[email protected] | 2b7f389 | 2014-05-08 01:45:18 | [diff] [blame] | 306 | |
| 307 | scoped_ptr<RenderPass> pass_cmp = RenderPass::Create(); |
| 308 | pass_cmp->SetAll(arbitrary_id, |
| 309 | arbitrary_rect1, |
| 310 | arbitrary_rect2, |
| 311 | arbitrary_matrix, |
| 312 | arbitrary_bool1); |
| 313 | |
| 314 | SharedQuadState* shared_state1_cmp = |
| 315 | pass_cmp->CreateAndAppendSharedQuadState(); |
| 316 | shared_state1_cmp->CopyFrom(shared_state1_in); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 317 | |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 318 | CheckerboardDrawQuad* checkerboard_in = |
| 319 | pass_in->CreateAndAppendDrawQuad<CheckerboardDrawQuad>(); |
danakj | e1419ce | 2015-03-04 21:26:27 | [diff] [blame] | 320 | checkerboard_in->SetAll(shared_state1_in, arbitrary_rect1, |
[email protected] | 8e1da69 | 2013-10-12 17:11:30 | [diff] [blame] | 321 | arbitrary_rect2_inside_rect1, |
danakj | e1419ce | 2015-03-04 21:26:27 | [diff] [blame] | 322 | arbitrary_rect1_inside_rect1, arbitrary_bool1, |
| 323 | arbitrary_color, arbitrary_float1); |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 324 | pass_cmp->CopyFromAndAppendDrawQuad(checkerboard_in, |
| 325 | checkerboard_in->shared_quad_state); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 326 | |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 327 | DebugBorderDrawQuad* debugborder_in = |
| 328 | pass_in->CreateAndAppendDrawQuad<DebugBorderDrawQuad>(); |
[email protected] | 2b7f389 | 2014-05-08 01:45:18 | [diff] [blame] | 329 | debugborder_in->SetAll(shared_state1_in, |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 330 | arbitrary_rect3, |
[email protected] | 8e1da69 | 2013-10-12 17:11:30 | [diff] [blame] | 331 | arbitrary_rect1_inside_rect3, |
| 332 | arbitrary_rect2_inside_rect3, |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 333 | arbitrary_bool1, |
| 334 | arbitrary_color, |
| 335 | arbitrary_int); |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 336 | pass_cmp->CopyFromAndAppendDrawQuad(debugborder_in, |
| 337 | debugborder_in->shared_quad_state); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 338 | |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 339 | IOSurfaceDrawQuad* iosurface_in = |
| 340 | pass_in->CreateAndAppendDrawQuad<IOSurfaceDrawQuad>(); |
[email protected] | 2b7f389 | 2014-05-08 01:45:18 | [diff] [blame] | 341 | iosurface_in->SetAll(shared_state1_in, |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 342 | arbitrary_rect2, |
[email protected] | 8e1da69 | 2013-10-12 17:11:30 | [diff] [blame] | 343 | arbitrary_rect2_inside_rect2, |
| 344 | arbitrary_rect1_inside_rect2, |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 345 | arbitrary_bool1, |
| 346 | arbitrary_size1, |
[email protected] | b7cfc63 | 2013-04-10 04:44:49 | [diff] [blame] | 347 | arbitrary_resourceid3, |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 348 | arbitrary_orientation); |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 349 | pass_cmp->CopyFromAndAppendDrawQuad(iosurface_in, |
| 350 | iosurface_in->shared_quad_state); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 351 | |
[email protected] | 2b7f389 | 2014-05-08 01:45:18 | [diff] [blame] | 352 | SharedQuadState* shared_state2_in = pass_in->CreateAndAppendSharedQuadState(); |
[email protected] | cbe94b7a | 2013-11-13 11:03:37 | [diff] [blame] | 353 | shared_state2_in->SetAll(arbitrary_matrix, |
| 354 | arbitrary_size2, |
| 355 | arbitrary_rect2, |
| 356 | arbitrary_rect3, |
| 357 | arbitrary_bool1, |
[email protected] | 7bbeaf4e | 2013-11-26 10:27:22 | [diff] [blame] | 358 | arbitrary_float2, |
[email protected] | a9d4d4f | 2014-06-19 06:49:28 | [diff] [blame] | 359 | arbitrary_blend_mode2, |
| 360 | arbitrary_context_id2); |
[email protected] | 2b7f389 | 2014-05-08 01:45:18 | [diff] [blame] | 361 | SharedQuadState* shared_state2_cmp = |
| 362 | pass_cmp->CreateAndAppendSharedQuadState(); |
| 363 | shared_state2_cmp->CopyFrom(shared_state2_in); |
[email protected] | cbe94b7a | 2013-11-13 11:03:37 | [diff] [blame] | 364 | |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 365 | RenderPassDrawQuad* renderpass_in = |
| 366 | pass_in->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); |
[email protected] | 2b7f389 | 2014-05-08 01:45:18 | [diff] [blame] | 367 | renderpass_in->SetAll(shared_state2_in, |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 368 | arbitrary_rect1, |
[email protected] | 8e1da69 | 2013-10-12 17:11:30 | [diff] [blame] | 369 | arbitrary_rect2_inside_rect1, |
| 370 | arbitrary_rect1_inside_rect1, |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 371 | arbitrary_bool1, |
| 372 | arbitrary_id, |
[email protected] | b7cfc63 | 2013-04-10 04:44:49 | [diff] [blame] | 373 | arbitrary_resourceid2, |
[email protected] | 7ac3d49 | 2014-08-08 21:25:32 | [diff] [blame] | 374 | arbitrary_vector2df1, |
enne | f6f3fbba4 | 2014-10-16 18:16:49 | [diff] [blame] | 375 | arbitrary_size1, |
| 376 | arbitrary_filters1, |
| 377 | arbitrary_vector2df2, |
[email protected] | 2006204 | 2012-12-21 22:16:36 | [diff] [blame] | 378 | arbitrary_filters2); |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 379 | pass_cmp->CopyFromAndAppendRenderPassDrawQuad( |
| 380 | renderpass_in, |
| 381 | renderpass_in->shared_quad_state, |
| 382 | renderpass_in->render_pass_id); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 383 | |
[email protected] | 2b7f389 | 2014-05-08 01:45:18 | [diff] [blame] | 384 | SharedQuadState* shared_state3_in = pass_in->CreateAndAppendSharedQuadState(); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 385 | shared_state3_in->SetAll(arbitrary_matrix, |
[email protected] | f902bf9 | 2013-03-04 18:33:27 | [diff] [blame] | 386 | arbitrary_size3, |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 387 | arbitrary_rect3, |
| 388 | arbitrary_rect1, |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 389 | arbitrary_bool1, |
[email protected] | 7bbeaf4e | 2013-11-26 10:27:22 | [diff] [blame] | 390 | arbitrary_float3, |
[email protected] | a9d4d4f | 2014-06-19 06:49:28 | [diff] [blame] | 391 | arbitrary_blend_mode3, |
| 392 | arbitrary_context_id3); |
[email protected] | 2b7f389 | 2014-05-08 01:45:18 | [diff] [blame] | 393 | SharedQuadState* shared_state3_cmp = |
| 394 | pass_cmp->CreateAndAppendSharedQuadState(); |
| 395 | shared_state3_cmp->CopyFrom(shared_state3_in); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 396 | |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 397 | SolidColorDrawQuad* solidcolor_in = |
| 398 | pass_in->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
[email protected] | 2b7f389 | 2014-05-08 01:45:18 | [diff] [blame] | 399 | solidcolor_in->SetAll(shared_state3_in, |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 400 | arbitrary_rect3, |
[email protected] | 8e1da69 | 2013-10-12 17:11:30 | [diff] [blame] | 401 | arbitrary_rect1_inside_rect3, |
| 402 | arbitrary_rect2_inside_rect3, |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 403 | arbitrary_bool1, |
[email protected] | 10a30b1 | 2013-05-02 16:42:11 | [diff] [blame] | 404 | arbitrary_color, |
| 405 | arbitrary_bool2); |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 406 | pass_cmp->CopyFromAndAppendDrawQuad(solidcolor_in, |
| 407 | solidcolor_in->shared_quad_state); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 408 | |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 409 | StreamVideoDrawQuad* streamvideo_in = |
| 410 | pass_in->CreateAndAppendDrawQuad<StreamVideoDrawQuad>(); |
[email protected] | 2b7f389 | 2014-05-08 01:45:18 | [diff] [blame] | 411 | streamvideo_in->SetAll(shared_state3_in, |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 412 | arbitrary_rect2, |
[email protected] | 8e1da69 | 2013-10-12 17:11:30 | [diff] [blame] | 413 | arbitrary_rect2_inside_rect2, |
| 414 | arbitrary_rect1_inside_rect2, |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 415 | arbitrary_bool1, |
[email protected] | b7cfc63 | 2013-04-10 04:44:49 | [diff] [blame] | 416 | arbitrary_resourceid2, |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 417 | arbitrary_matrix); |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 418 | pass_cmp->CopyFromAndAppendDrawQuad(streamvideo_in, |
| 419 | streamvideo_in->shared_quad_state); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 420 | |
[email protected] | 16a6af15 | 2014-06-13 04:20:16 | [diff] [blame] | 421 | cc::SurfaceId arbitrary_surface_id(3); |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 422 | SurfaceDrawQuad* surface_in = |
| 423 | pass_in->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
[email protected] | 2b7f389 | 2014-05-08 01:45:18 | [diff] [blame] | 424 | surface_in->SetAll(shared_state3_in, |
| 425 | arbitrary_rect2, |
| 426 | arbitrary_rect2_inside_rect2, |
| 427 | arbitrary_rect1_inside_rect2, |
| 428 | arbitrary_bool1, |
| 429 | arbitrary_surface_id); |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 430 | pass_cmp->CopyFromAndAppendDrawQuad(surface_in, |
| 431 | surface_in->shared_quad_state); |
[email protected] | 78d3012 | 2014-01-17 06:32:36 | [diff] [blame] | 432 | |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 433 | TextureDrawQuad* texture_in = |
| 434 | pass_in->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
[email protected] | 2b7f389 | 2014-05-08 01:45:18 | [diff] [blame] | 435 | texture_in->SetAll(shared_state3_in, |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 436 | arbitrary_rect2, |
[email protected] | 8e1da69 | 2013-10-12 17:11:30 | [diff] [blame] | 437 | arbitrary_rect2_inside_rect2, |
| 438 | arbitrary_rect1_inside_rect2, |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 439 | arbitrary_bool1, |
[email protected] | b7cfc63 | 2013-04-10 04:44:49 | [diff] [blame] | 440 | arbitrary_resourceid1, |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 441 | arbitrary_bool2, |
| 442 | arbitrary_pointf1, |
| 443 | arbitrary_pointf2, |
[email protected] | d18b4d6 | 2013-07-12 05:33:49 | [diff] [blame] | 444 | arbitrary_color, |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 445 | arbitrary_float_array, |
jackhou | 10c9af4 | 2014-12-04 05:24:44 | [diff] [blame] | 446 | arbitrary_bool3, |
| 447 | arbitrary_bool4); |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 448 | pass_cmp->CopyFromAndAppendDrawQuad(texture_in, |
| 449 | texture_in->shared_quad_state); |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 450 | |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 451 | TileDrawQuad* tile_in = pass_in->CreateAndAppendDrawQuad<TileDrawQuad>(); |
[email protected] | 2b7f389 | 2014-05-08 01:45:18 | [diff] [blame] | 452 | tile_in->SetAll(shared_state3_in, |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 453 | arbitrary_rect2, |
[email protected] | 8e1da69 | 2013-10-12 17:11:30 | [diff] [blame] | 454 | arbitrary_rect2_inside_rect2, |
| 455 | arbitrary_rect1_inside_rect2, |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 456 | arbitrary_bool1, |
[email protected] | b7cfc63 | 2013-04-10 04:44:49 | [diff] [blame] | 457 | arbitrary_resourceid3, |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 458 | arbitrary_rectf1, |
| 459 | arbitrary_size1, |
jackhou | 2422961 | 2014-12-13 23:41:00 | [diff] [blame] | 460 | arbitrary_bool2, |
| 461 | arbitrary_bool3); |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 462 | pass_cmp->CopyFromAndAppendDrawQuad(tile_in, tile_in->shared_quad_state); |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 463 | |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 464 | YUVVideoDrawQuad* yuvvideo_in = |
| 465 | pass_in->CreateAndAppendDrawQuad<YUVVideoDrawQuad>(); |
[email protected] | 2b7f389 | 2014-05-08 01:45:18 | [diff] [blame] | 466 | yuvvideo_in->SetAll(shared_state3_in, |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 467 | arbitrary_rect1, |
[email protected] | 8e1da69 | 2013-10-12 17:11:30 | [diff] [blame] | 468 | arbitrary_rect2_inside_rect1, |
| 469 | arbitrary_rect1_inside_rect1, |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 470 | arbitrary_bool1, |
[email protected] | 95052aa | 2014-03-27 11:43:50 | [diff] [blame] | 471 | arbitrary_rectf1, |
enne | a2a2970 | 2015-02-02 22:21:21 | [diff] [blame] | 472 | arbitrary_size1, |
magjed | 7364ff9 | 2015-03-27 09:11:08 | [diff] [blame^] | 473 | arbitrary_size2, |
[email protected] | b7cfc63 | 2013-04-10 04:44:49 | [diff] [blame] | 474 | arbitrary_resourceid1, |
| 475 | arbitrary_resourceid2, |
[email protected] | 0402b238 | 2013-06-07 21:50:54 | [diff] [blame] | 476 | arbitrary_resourceid3, |
[email protected] | 82faf5e | 2014-05-03 02:25:58 | [diff] [blame] | 477 | arbitrary_resourceid4, |
| 478 | arbitrary_color_space); |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 479 | pass_cmp->CopyFromAndAppendDrawQuad(yuvvideo_in, |
| 480 | yuvvideo_in->shared_quad_state); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 481 | |
| 482 | // Make sure the in and cmp RenderPasses match. |
| 483 | Compare(pass_cmp.get(), pass_in.get()); |
| 484 | ASSERT_EQ(3u, pass_in->shared_quad_state_list.size()); |
[email protected] | 78d3012 | 2014-01-17 06:32:36 | [diff] [blame] | 485 | ASSERT_EQ(10u, pass_in->quad_list.size()); |
weiliangc | 808f70f | 2014-10-03 22:53:15 | [diff] [blame] | 486 | for (cc::SharedQuadStateList::ConstIterator |
| 487 | cmp_iterator = pass_cmp->shared_quad_state_list.begin(), |
| 488 | in_iterator = pass_in->shared_quad_state_list.begin(); |
| 489 | in_iterator != pass_in->shared_quad_state_list.end(); |
| 490 | ++cmp_iterator, ++in_iterator) { |
weiliangc | 48805fce | 2014-10-29 20:30:12 | [diff] [blame] | 491 | Compare(*cmp_iterator, *in_iterator); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 492 | } |
weiliangc | 7eb7ee6 | 2014-10-07 00:04:40 | [diff] [blame] | 493 | for (auto in_iter = pass_in->quad_list.cbegin(), |
| 494 | cmp_iter = pass_cmp->quad_list.cbegin(); |
| 495 | in_iter != pass_in->quad_list.cend(); |
weiliangc | 032e929d | 2014-09-26 01:55:01 | [diff] [blame] | 496 | ++in_iter, ++cmp_iter) |
weiliangc | 48805fce | 2014-10-29 20:30:12 | [diff] [blame] | 497 | Compare(*cmp_iter, *in_iter); |
weiliangc | 032e929d | 2014-09-26 01:55:01 | [diff] [blame] | 498 | |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 499 | for (size_t i = 1; i < pass_in->quad_list.size(); ++i) { |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 500 | bool same_shared_quad_state_cmp = |
weiliangc | 032e929d | 2014-09-26 01:55:01 | [diff] [blame] | 501 | pass_cmp->quad_list.ElementAt(i)->shared_quad_state == |
| 502 | pass_cmp->quad_list.ElementAt(i - 1)->shared_quad_state; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 503 | bool same_shared_quad_state_in = |
weiliangc | 032e929d | 2014-09-26 01:55:01 | [diff] [blame] | 504 | pass_in->quad_list.ElementAt(i)->shared_quad_state == |
| 505 | pass_in->quad_list.ElementAt(i - 1)->shared_quad_state; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 506 | EXPECT_EQ(same_shared_quad_state_cmp, same_shared_quad_state_in); |
| 507 | } |
| 508 | |
[email protected] | bf189f6 | 2012-12-18 03:42:11 | [diff] [blame] | 509 | DelegatedFrameData frame_in; |
[email protected] | ead39c5 | 2013-01-09 07:22:45 | [diff] [blame] | 510 | frame_in.render_pass_list.push_back(pass_in.Pass()); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 511 | |
[email protected] | bf189f6 | 2012-12-18 03:42:11 | [diff] [blame] | 512 | IPC::ParamTraits<DelegatedFrameData>::Write(&msg, frame_in); |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 513 | |
[email protected] | bf189f6 | 2012-12-18 03:42:11 | [diff] [blame] | 514 | DelegatedFrameData frame_out; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 515 | PickleIterator iter(msg); |
[email protected] | bf189f6 | 2012-12-18 03:42:11 | [diff] [blame] | 516 | EXPECT_TRUE(IPC::ParamTraits<DelegatedFrameData>::Read(&msg, |
| 517 | &iter, &frame_out)); |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 518 | |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 519 | // Make sure the out and cmp RenderPasses match. |
[email protected] | ead39c5 | 2013-01-09 07:22:45 | [diff] [blame] | 520 | scoped_ptr<RenderPass> pass_out = frame_out.render_pass_list.take( |
| 521 | frame_out.render_pass_list.begin()); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 522 | Compare(pass_cmp.get(), pass_out.get()); |
| 523 | ASSERT_EQ(3u, pass_out->shared_quad_state_list.size()); |
[email protected] | 78d3012 | 2014-01-17 06:32:36 | [diff] [blame] | 524 | ASSERT_EQ(10u, pass_out->quad_list.size()); |
weiliangc | 808f70f | 2014-10-03 22:53:15 | [diff] [blame] | 525 | for (cc::SharedQuadStateList::ConstIterator |
| 526 | cmp_iterator = pass_cmp->shared_quad_state_list.begin(), |
| 527 | out_iterator = pass_out->shared_quad_state_list.begin(); |
| 528 | out_iterator != pass_out->shared_quad_state_list.end(); |
| 529 | ++cmp_iterator, ++out_iterator) { |
weiliangc | 48805fce | 2014-10-29 20:30:12 | [diff] [blame] | 530 | Compare(*cmp_iterator, *out_iterator); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 531 | } |
weiliangc | 7eb7ee6 | 2014-10-07 00:04:40 | [diff] [blame] | 532 | for (auto out_iter = pass_out->quad_list.cbegin(), |
| 533 | cmp_iter = pass_cmp->quad_list.cbegin(); |
| 534 | out_iter != pass_out->quad_list.cend(); |
weiliangc | 032e929d | 2014-09-26 01:55:01 | [diff] [blame] | 535 | ++out_iter, ++cmp_iter) |
weiliangc | 48805fce | 2014-10-29 20:30:12 | [diff] [blame] | 536 | Compare(*cmp_iter, *out_iter); |
weiliangc | 032e929d | 2014-09-26 01:55:01 | [diff] [blame] | 537 | |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 538 | for (size_t i = 1; i < pass_out->quad_list.size(); ++i) { |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 539 | bool same_shared_quad_state_cmp = |
weiliangc | 032e929d | 2014-09-26 01:55:01 | [diff] [blame] | 540 | pass_cmp->quad_list.ElementAt(i)->shared_quad_state == |
| 541 | pass_cmp->quad_list.ElementAt(i - 1)->shared_quad_state; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 542 | bool same_shared_quad_state_out = |
weiliangc | 032e929d | 2014-09-26 01:55:01 | [diff] [blame] | 543 | pass_out->quad_list.ElementAt(i)->shared_quad_state == |
| 544 | pass_out->quad_list.ElementAt(i - 1)->shared_quad_state; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 545 | EXPECT_EQ(same_shared_quad_state_cmp, same_shared_quad_state_out); |
| 546 | } |
| 547 | } |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 548 | |
[email protected] | cbe94b7a | 2013-11-13 11:03:37 | [diff] [blame] | 549 | TEST_F(CCMessagesTest, UnusedSharedQuadStates) { |
[email protected] | cbe94b7a | 2013-11-13 11:03:37 | [diff] [blame] | 550 | scoped_ptr<RenderPass> pass_in = RenderPass::Create(); |
[email protected] | 0cd7d6f7 | 2014-08-22 14:50:51 | [diff] [blame] | 551 | pass_in->SetAll(RenderPassId(1, 1), |
[email protected] | cbe94b7a | 2013-11-13 11:03:37 | [diff] [blame] | 552 | gfx::Rect(100, 100), |
[email protected] | b4ead7b | 2014-04-07 18:12:18 | [diff] [blame] | 553 | gfx::Rect(), |
[email protected] | cbe94b7a | 2013-11-13 11:03:37 | [diff] [blame] | 554 | gfx::Transform(), |
[email protected] | 8590da3 | 2014-03-28 20:49:07 | [diff] [blame] | 555 | false); |
[email protected] | cbe94b7a | 2013-11-13 11:03:37 | [diff] [blame] | 556 | |
| 557 | // The first SharedQuadState is used. |
[email protected] | 2b7f389 | 2014-05-08 01:45:18 | [diff] [blame] | 558 | SharedQuadState* shared_state1_in = pass_in->CreateAndAppendSharedQuadState(); |
[email protected] | 7bbeaf4e | 2013-11-26 10:27:22 | [diff] [blame] | 559 | shared_state1_in->SetAll(gfx::Transform(), |
| 560 | gfx::Size(1, 1), |
| 561 | gfx::Rect(), |
| 562 | gfx::Rect(), |
| 563 | false, |
| 564 | 1.f, |
[email protected] | a9d4d4f | 2014-06-19 06:49:28 | [diff] [blame] | 565 | SkXfermode::kSrcOver_Mode, |
| 566 | 0); |
[email protected] | cbe94b7a | 2013-11-13 11:03:37 | [diff] [blame] | 567 | |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 568 | CheckerboardDrawQuad* quad1 = |
| 569 | pass_in->CreateAndAppendDrawQuad<CheckerboardDrawQuad>(); |
danakj | e1419ce | 2015-03-04 21:26:27 | [diff] [blame] | 570 | quad1->SetAll(shared_state1_in, gfx::Rect(10, 10), gfx::Rect(10, 10), |
| 571 | gfx::Rect(10, 10), false, SK_ColorRED, 1.f); |
[email protected] | cbe94b7a | 2013-11-13 11:03:37 | [diff] [blame] | 572 | |
| 573 | // The second and third SharedQuadStates are not used. |
[email protected] | 2b7f389 | 2014-05-08 01:45:18 | [diff] [blame] | 574 | SharedQuadState* shared_state2_in = pass_in->CreateAndAppendSharedQuadState(); |
[email protected] | 7bbeaf4e | 2013-11-26 10:27:22 | [diff] [blame] | 575 | shared_state2_in->SetAll(gfx::Transform(), |
| 576 | gfx::Size(2, 2), |
| 577 | gfx::Rect(), |
| 578 | gfx::Rect(), |
| 579 | false, |
| 580 | 1.f, |
[email protected] | a9d4d4f | 2014-06-19 06:49:28 | [diff] [blame] | 581 | SkXfermode::kSrcOver_Mode, |
| 582 | 0); |
[email protected] | cbe94b7a | 2013-11-13 11:03:37 | [diff] [blame] | 583 | |
[email protected] | 2b7f389 | 2014-05-08 01:45:18 | [diff] [blame] | 584 | SharedQuadState* shared_state3_in = pass_in->CreateAndAppendSharedQuadState(); |
[email protected] | 7bbeaf4e | 2013-11-26 10:27:22 | [diff] [blame] | 585 | shared_state3_in->SetAll(gfx::Transform(), |
| 586 | gfx::Size(3, 3), |
| 587 | gfx::Rect(), |
| 588 | gfx::Rect(), |
| 589 | false, |
| 590 | 1.f, |
[email protected] | a9d4d4f | 2014-06-19 06:49:28 | [diff] [blame] | 591 | SkXfermode::kSrcOver_Mode, |
| 592 | 0); |
[email protected] | cbe94b7a | 2013-11-13 11:03:37 | [diff] [blame] | 593 | |
| 594 | // The fourth SharedQuadState is used. |
[email protected] | 2b7f389 | 2014-05-08 01:45:18 | [diff] [blame] | 595 | SharedQuadState* shared_state4_in = pass_in->CreateAndAppendSharedQuadState(); |
[email protected] | 7bbeaf4e | 2013-11-26 10:27:22 | [diff] [blame] | 596 | shared_state4_in->SetAll(gfx::Transform(), |
| 597 | gfx::Size(4, 4), |
| 598 | gfx::Rect(), |
| 599 | gfx::Rect(), |
| 600 | false, |
| 601 | 1.f, |
[email protected] | a9d4d4f | 2014-06-19 06:49:28 | [diff] [blame] | 602 | SkXfermode::kSrcOver_Mode, |
| 603 | 0); |
[email protected] | cbe94b7a | 2013-11-13 11:03:37 | [diff] [blame] | 604 | |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 605 | CheckerboardDrawQuad* quad2 = |
| 606 | pass_in->CreateAndAppendDrawQuad<CheckerboardDrawQuad>(); |
danakj | e1419ce | 2015-03-04 21:26:27 | [diff] [blame] | 607 | quad2->SetAll(shared_state4_in, gfx::Rect(10, 10), gfx::Rect(10, 10), |
| 608 | gfx::Rect(10, 10), false, SK_ColorRED, 1.f); |
[email protected] | cbe94b7a | 2013-11-13 11:03:37 | [diff] [blame] | 609 | |
| 610 | // The fifth is not used again. |
[email protected] | 2b7f389 | 2014-05-08 01:45:18 | [diff] [blame] | 611 | SharedQuadState* shared_state5_in = pass_in->CreateAndAppendSharedQuadState(); |
[email protected] | 7bbeaf4e | 2013-11-26 10:27:22 | [diff] [blame] | 612 | shared_state5_in->SetAll(gfx::Transform(), |
| 613 | gfx::Size(5, 5), |
| 614 | gfx::Rect(), |
| 615 | gfx::Rect(), |
| 616 | false, |
| 617 | 1.f, |
[email protected] | a9d4d4f | 2014-06-19 06:49:28 | [diff] [blame] | 618 | SkXfermode::kSrcOver_Mode, |
| 619 | 0); |
[email protected] | cbe94b7a | 2013-11-13 11:03:37 | [diff] [blame] | 620 | |
[email protected] | cbe94b7a | 2013-11-13 11:03:37 | [diff] [blame] | 621 | // 5 SharedQuadStates go in. |
| 622 | ASSERT_EQ(5u, pass_in->shared_quad_state_list.size()); |
| 623 | ASSERT_EQ(2u, pass_in->quad_list.size()); |
| 624 | |
| 625 | DelegatedFrameData frame_in; |
| 626 | frame_in.render_pass_list.push_back(pass_in.Pass()); |
| 627 | |
| 628 | IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); |
| 629 | IPC::ParamTraits<DelegatedFrameData>::Write(&msg, frame_in); |
| 630 | |
| 631 | DelegatedFrameData frame_out; |
| 632 | PickleIterator iter(msg); |
| 633 | EXPECT_TRUE( |
| 634 | IPC::ParamTraits<DelegatedFrameData>::Read(&msg, &iter, &frame_out)); |
| 635 | |
| 636 | scoped_ptr<RenderPass> pass_out = |
| 637 | frame_out.render_pass_list.take(frame_out.render_pass_list.begin()); |
| 638 | |
| 639 | // 2 SharedQuadStates come out. The first and fourth SharedQuadStates were |
| 640 | // used by quads, and so serialized. Others were not. |
| 641 | ASSERT_EQ(2u, pass_out->shared_quad_state_list.size()); |
| 642 | ASSERT_EQ(2u, pass_out->quad_list.size()); |
| 643 | |
weiliangc | 808f70f | 2014-10-03 22:53:15 | [diff] [blame] | 644 | EXPECT_EQ( |
| 645 | gfx::Size(1, 1).ToString(), |
| 646 | pass_out->shared_quad_state_list.ElementAt(0)->content_bounds.ToString()); |
| 647 | EXPECT_EQ( |
| 648 | gfx::Size(4, 4).ToString(), |
| 649 | pass_out->shared_quad_state_list.ElementAt(1)->content_bounds.ToString()); |
[email protected] | cbe94b7a | 2013-11-13 11:03:37 | [diff] [blame] | 650 | } |
| 651 | |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 652 | TEST_F(CCMessagesTest, Resources) { |
[email protected] | 753bb25 | 2013-11-04 22:28:12 | [diff] [blame] | 653 | IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 654 | gfx::Size arbitrary_size(757, 1281); |
[email protected] | 09831f7f | 2013-02-27 03:32:15 | [diff] [blame] | 655 | unsigned int arbitrary_uint1 = 71234838; |
| 656 | unsigned int arbitrary_uint2 = 53589793; |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 657 | |
[email protected] | e0a4d73 | 2014-02-15 00:23:26 | [diff] [blame] | 658 | GLbyte arbitrary_mailbox1[GL_MAILBOX_SIZE_CHROMIUM] = { |
| 659 | 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, |
| 660 | 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, |
| 661 | 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4}; |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 662 | |
[email protected] | e0a4d73 | 2014-02-15 00:23:26 | [diff] [blame] | 663 | GLbyte arbitrary_mailbox2[GL_MAILBOX_SIZE_CHROMIUM] = { |
| 664 | 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, |
| 665 | 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, 8, 7, |
| 666 | 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, 8, 7}; |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 667 | |
| 668 | TransferableResource arbitrary_resource1; |
| 669 | arbitrary_resource1.id = 2178312; |
[email protected] | 27a41fe | 2013-09-19 05:05:14 | [diff] [blame] | 670 | arbitrary_resource1.format = cc::RGBA_8888; |
[email protected] | 8018929 | 2013-02-28 01:59:36 | [diff] [blame] | 671 | arbitrary_resource1.filter = 53; |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 672 | arbitrary_resource1.size = gfx::Size(37189, 123123); |
[email protected] | df41e25 | 2014-02-03 23:39:50 | [diff] [blame] | 673 | arbitrary_resource1.mailbox_holder.mailbox.SetName(arbitrary_mailbox1); |
| 674 | arbitrary_resource1.mailbox_holder.texture_target = GL_TEXTURE_2D; |
| 675 | arbitrary_resource1.mailbox_holder.sync_point = arbitrary_uint1; |
[email protected] | a8c63be2 | 2014-08-07 02:39:49 | [diff] [blame] | 676 | arbitrary_resource1.allow_overlay = true; |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 677 | |
| 678 | TransferableResource arbitrary_resource2; |
| 679 | arbitrary_resource2.id = 789132; |
[email protected] | 27a41fe | 2013-09-19 05:05:14 | [diff] [blame] | 680 | arbitrary_resource2.format = cc::RGBA_4444; |
[email protected] | 645a47f2 | 2013-09-26 05:42:32 | [diff] [blame] | 681 | arbitrary_resource2.filter = 47; |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 682 | arbitrary_resource2.size = gfx::Size(89123, 23789); |
[email protected] | df41e25 | 2014-02-03 23:39:50 | [diff] [blame] | 683 | arbitrary_resource2.mailbox_holder.mailbox.SetName(arbitrary_mailbox2); |
| 684 | arbitrary_resource2.mailbox_holder.texture_target = GL_TEXTURE_EXTERNAL_OES; |
| 685 | arbitrary_resource2.mailbox_holder.sync_point = arbitrary_uint2; |
[email protected] | a8c63be2 | 2014-08-07 02:39:49 | [diff] [blame] | 686 | arbitrary_resource2.allow_overlay = false; |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 687 | |
[email protected] | cb7d649 | 2013-10-03 02:40:04 | [diff] [blame] | 688 | scoped_ptr<RenderPass> renderpass_in = RenderPass::Create(); |
| 689 | renderpass_in->SetNew( |
[email protected] | 0cd7d6f7 | 2014-08-22 14:50:51 | [diff] [blame] | 690 | RenderPassId(1, 1), gfx::Rect(), gfx::Rect(), gfx::Transform()); |
[email protected] | cb7d649 | 2013-10-03 02:40:04 | [diff] [blame] | 691 | |
[email protected] | bf189f6 | 2012-12-18 03:42:11 | [diff] [blame] | 692 | DelegatedFrameData frame_in; |
[email protected] | 09831f7f | 2013-02-27 03:32:15 | [diff] [blame] | 693 | frame_in.resource_list.push_back(arbitrary_resource1); |
| 694 | frame_in.resource_list.push_back(arbitrary_resource2); |
[email protected] | cb7d649 | 2013-10-03 02:40:04 | [diff] [blame] | 695 | frame_in.render_pass_list.push_back(renderpass_in.Pass()); |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 696 | |
[email protected] | bf189f6 | 2012-12-18 03:42:11 | [diff] [blame] | 697 | IPC::ParamTraits<DelegatedFrameData>::Write(&msg, frame_in); |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 698 | |
[email protected] | bf189f6 | 2012-12-18 03:42:11 | [diff] [blame] | 699 | DelegatedFrameData frame_out; |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 700 | PickleIterator iter(msg); |
[email protected] | bf189f6 | 2012-12-18 03:42:11 | [diff] [blame] | 701 | EXPECT_TRUE(IPC::ParamTraits<DelegatedFrameData>::Read(&msg, |
| 702 | &iter, &frame_out)); |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 703 | |
[email protected] | 09831f7f | 2013-02-27 03:32:15 | [diff] [blame] | 704 | ASSERT_EQ(2u, frame_out.resource_list.size()); |
| 705 | Compare(arbitrary_resource1, frame_out.resource_list[0]); |
| 706 | Compare(arbitrary_resource2, frame_out.resource_list[1]); |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 707 | } |
| 708 | |
[email protected] | cecc834 | 2014-03-20 21:43:39 | [diff] [blame] | 709 | TEST_F(CCMessagesTest, SoftwareFrameData) { |
| 710 | cc::SoftwareFrameData frame_in; |
| 711 | frame_in.id = 3; |
| 712 | frame_in.size = gfx::Size(40, 20); |
| 713 | frame_in.damage_rect = gfx::Rect(5, 18, 31, 44); |
[email protected] | f197008 | 2014-04-09 04:29:56 | [diff] [blame] | 714 | frame_in.bitmap_id = cc::SharedBitmap::GenerateId(); |
[email protected] | cecc834 | 2014-03-20 21:43:39 | [diff] [blame] | 715 | |
| 716 | // Write the frame. |
| 717 | IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); |
| 718 | IPC::ParamTraits<cc::SoftwareFrameData>::Write(&msg, frame_in); |
| 719 | |
| 720 | // Read the frame. |
| 721 | cc::SoftwareFrameData frame_out; |
| 722 | PickleIterator iter(msg); |
| 723 | EXPECT_TRUE( |
| 724 | IPC::ParamTraits<SoftwareFrameData>::Read(&msg, &iter, &frame_out)); |
| 725 | EXPECT_EQ(frame_in.id, frame_out.id); |
| 726 | EXPECT_EQ(frame_in.size.ToString(), frame_out.size.ToString()); |
| 727 | EXPECT_EQ(frame_in.damage_rect.ToString(), frame_out.damage_rect.ToString()); |
[email protected] | f197008 | 2014-04-09 04:29:56 | [diff] [blame] | 728 | EXPECT_EQ(frame_in.bitmap_id, frame_out.bitmap_id); |
[email protected] | cecc834 | 2014-03-20 21:43:39 | [diff] [blame] | 729 | } |
| 730 | |
| 731 | TEST_F(CCMessagesTest, SoftwareFrameDataMaxInt) { |
| 732 | SoftwareFrameData frame_in; |
| 733 | frame_in.id = 3; |
| 734 | frame_in.size = gfx::Size(40, 20); |
| 735 | frame_in.damage_rect = gfx::Rect(5, 18, 31, 44); |
[email protected] | f197008 | 2014-04-09 04:29:56 | [diff] [blame] | 736 | frame_in.bitmap_id = cc::SharedBitmap::GenerateId(); |
[email protected] | cecc834 | 2014-03-20 21:43:39 | [diff] [blame] | 737 | |
| 738 | // Write the SoftwareFrameData by hand, make sure it works. |
| 739 | { |
| 740 | IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); |
| 741 | IPC::WriteParam(&msg, frame_in.id); |
| 742 | IPC::WriteParam(&msg, frame_in.size); |
| 743 | IPC::WriteParam(&msg, frame_in.damage_rect); |
[email protected] | f197008 | 2014-04-09 04:29:56 | [diff] [blame] | 744 | IPC::WriteParam(&msg, frame_in.bitmap_id); |
[email protected] | cecc834 | 2014-03-20 21:43:39 | [diff] [blame] | 745 | SoftwareFrameData frame_out; |
| 746 | PickleIterator iter(msg); |
| 747 | EXPECT_TRUE( |
| 748 | IPC::ParamTraits<SoftwareFrameData>::Read(&msg, &iter, &frame_out)); |
| 749 | } |
| 750 | |
| 751 | // The size of the frame may overflow when multiplied together. |
| 752 | int max = std::numeric_limits<int>::max(); |
| 753 | frame_in.size = gfx::Size(max, max); |
| 754 | |
| 755 | // If size_t is larger than int, then int*int*4 can always fit in size_t. |
| 756 | bool expect_read = sizeof(size_t) >= sizeof(int) * 2; |
| 757 | |
| 758 | // Write the SoftwareFrameData with the MaxInt size, if it causes overflow it |
| 759 | // should fail. |
| 760 | { |
| 761 | IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); |
| 762 | IPC::WriteParam(&msg, frame_in.id); |
| 763 | IPC::WriteParam(&msg, frame_in.size); |
| 764 | IPC::WriteParam(&msg, frame_in.damage_rect); |
[email protected] | f197008 | 2014-04-09 04:29:56 | [diff] [blame] | 765 | IPC::WriteParam(&msg, frame_in.bitmap_id); |
[email protected] | cecc834 | 2014-03-20 21:43:39 | [diff] [blame] | 766 | SoftwareFrameData frame_out; |
| 767 | PickleIterator iter(msg); |
| 768 | EXPECT_EQ( |
| 769 | expect_read, |
| 770 | IPC::ParamTraits<SoftwareFrameData>::Read(&msg, &iter, &frame_out)); |
| 771 | } |
| 772 | } |
| 773 | |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 774 | } // namespace |
| 775 | } // namespace content |