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