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