[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 | |
avi | a9aa7a8 | 2015-12-25 03:06:31 | [diff] [blame] | 5 | #include <stddef.h> |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 6 | #include <string.h> |
[email protected] | 032bfc4 | 2013-10-29 22:23:52 | [diff] [blame] | 7 | #include <algorithm> |
dcheng | f63a125 | 2015-12-26 20:43:13 | [diff] [blame] | 8 | #include <utility> |
[email protected] | 032bfc4 | 2013-10-29 22:23:52 | [diff] [blame] | 9 | |
avi | a9aa7a8 | 2015-12-25 03:06:31 | [diff] [blame] | 10 | #include "base/macros.h" |
| 11 | #include "build/build_config.h" |
fsamuel | 812b848 | 2016-05-16 18:52:18 | [diff] [blame] | 12 | #include "cc/ipc/cc_param_traits.h" |
[email protected] | 7f0d825f | 2013-03-18 07:24:30 | [diff] [blame] | 13 | #include "cc/output/compositor_frame.h" |
fsamuel | 812b848 | 2016-05-16 18:52:18 | [diff] [blame] | 14 | #include "cc/quads/picture_draw_quad.h" |
| 15 | #include "cc/quads/render_pass_draw_quad.h" |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 16 | #include "ipc/ipc_message.h" |
| 17 | #include "testing/gtest/include/gtest/gtest.h" |
[email protected] | a176567 | 2013-08-12 23:45:02 | [diff] [blame] | 18 | #include "third_party/skia/include/effects/SkBlurImageFilter.h" |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 19 | |
[email protected] | cecc834 | 2014-03-20 21:43:39 | [diff] [blame] | 20 | #if defined(OS_POSIX) |
| 21 | #include "base/file_descriptor_posix.h" |
| 22 | #endif |
| 23 | |
[email protected] | bf189f6 | 2012-12-18 03:42:11 | [diff] [blame] | 24 | using cc::DelegatedFrameData; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 25 | using cc::DebugBorderDrawQuad; |
| 26 | using cc::DrawQuad; |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame] | 27 | using cc::FilterOperation; |
| 28 | using cc::FilterOperations; |
[email protected] | 9ee4d3a | 2013-03-27 17:43:16 | [diff] [blame] | 29 | using cc::PictureDrawQuad; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 30 | using cc::RenderPass; |
[email protected] | 0cd7d6f7 | 2014-08-22 14:50:51 | [diff] [blame] | 31 | using cc::RenderPassId; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 32 | using cc::RenderPassDrawQuad; |
jbauman | bbd425e | 2015-05-19 00:33:35 | [diff] [blame] | 33 | using cc::ResourceId; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 34 | using cc::ResourceProvider; |
| 35 | using cc::SharedQuadState; |
| 36 | using cc::SolidColorDrawQuad; |
[email protected] | 78d3012 | 2014-01-17 06:32:36 | [diff] [blame] | 37 | using cc::SurfaceDrawQuad; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 38 | using cc::TextureDrawQuad; |
| 39 | using cc::TileDrawQuad; |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 40 | using cc::TransferableResource; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 41 | using cc::StreamVideoDrawQuad; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 42 | using cc::YUVVideoDrawQuad; |
[email protected] | c8686a0 | 2012-11-27 08:29:00 | [diff] [blame] | 43 | using gfx::Transform; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 44 | |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 45 | namespace content { |
| 46 | namespace { |
| 47 | |
fsamuel | f76098e | 2016-05-18 17:26:51 | [diff] [blame] | 48 | class CCParamTraitsTest : public testing::Test { |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 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) { |
danakj | 64767d90 | 2015-06-19 00:10:43 | [diff] [blame] | 59 | EXPECT_EQ(a->quad_to_target_transform, b->quad_to_target_transform); |
| 60 | EXPECT_EQ(a->quad_layer_bounds, b->quad_layer_bounds); |
| 61 | EXPECT_EQ(a->visible_quad_layer_rect, b->visible_quad_layer_rect); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 62 | EXPECT_EQ(a->clip_rect, b->clip_rect); |
| 63 | EXPECT_EQ(a->is_clipped, b->is_clipped); |
| 64 | EXPECT_EQ(a->opacity, b->opacity); |
[email protected] | 7bbeaf4e | 2013-11-26 10:27:22 | [diff] [blame] | 65 | EXPECT_EQ(a->blend_mode, b->blend_mode); |
[email protected] | a9d4d4f | 2014-06-19 06:49:28 | [diff] [blame] | 66 | EXPECT_EQ(a->sorting_context_id, b->sorting_context_id); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | void Compare(const DrawQuad* a, const DrawQuad* b) { |
| 70 | ASSERT_NE(DrawQuad::INVALID, a->material); |
| 71 | ASSERT_EQ(a->material, b->material); |
| 72 | EXPECT_EQ(a->rect.ToString(), b->rect.ToString()); |
| 73 | EXPECT_EQ(a->opaque_rect.ToString(), b->opaque_rect.ToString()); |
| 74 | EXPECT_EQ(a->visible_rect.ToString(), b->visible_rect.ToString()); |
| 75 | EXPECT_EQ(a->needs_blending, b->needs_blending); |
| 76 | |
| 77 | Compare(a->shared_quad_state, b->shared_quad_state); |
| 78 | |
| 79 | switch (a->material) { |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 80 | case DrawQuad::DEBUG_BORDER: |
| 81 | Compare(DebugBorderDrawQuad::MaterialCast(a), |
| 82 | DebugBorderDrawQuad::MaterialCast(b)); |
| 83 | break; |
[email protected] | 9ee4d3a | 2013-03-27 17:43:16 | [diff] [blame] | 84 | case DrawQuad::PICTURE_CONTENT: |
| 85 | Compare(PictureDrawQuad::MaterialCast(a), |
| 86 | PictureDrawQuad::MaterialCast(b)); |
| 87 | break; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 88 | case DrawQuad::RENDER_PASS: |
| 89 | Compare(RenderPassDrawQuad::MaterialCast(a), |
| 90 | RenderPassDrawQuad::MaterialCast(b)); |
| 91 | break; |
| 92 | case DrawQuad::TEXTURE_CONTENT: |
| 93 | Compare(TextureDrawQuad::MaterialCast(a), |
| 94 | TextureDrawQuad::MaterialCast(b)); |
| 95 | break; |
| 96 | case DrawQuad::TILED_CONTENT: |
fsamuel | f76098e | 2016-05-18 17:26:51 | [diff] [blame] | 97 | Compare(TileDrawQuad::MaterialCast(a), TileDrawQuad::MaterialCast(b)); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 98 | break; |
| 99 | case DrawQuad::SOLID_COLOR: |
| 100 | Compare(SolidColorDrawQuad::MaterialCast(a), |
| 101 | SolidColorDrawQuad::MaterialCast(b)); |
| 102 | break; |
| 103 | case DrawQuad::STREAM_VIDEO_CONTENT: |
| 104 | Compare(StreamVideoDrawQuad::MaterialCast(a), |
| 105 | StreamVideoDrawQuad::MaterialCast(b)); |
| 106 | break; |
[email protected] | 78d3012 | 2014-01-17 06:32:36 | [diff] [blame] | 107 | case DrawQuad::SURFACE_CONTENT: |
| 108 | Compare(SurfaceDrawQuad::MaterialCast(a), |
| 109 | SurfaceDrawQuad::MaterialCast(b)); |
| 110 | break; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 111 | case DrawQuad::YUV_VIDEO_CONTENT: |
| 112 | Compare(YUVVideoDrawQuad::MaterialCast(a), |
| 113 | YUVVideoDrawQuad::MaterialCast(b)); |
| 114 | break; |
| 115 | case DrawQuad::INVALID: |
| 116 | break; |
| 117 | } |
| 118 | } |
| 119 | |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 120 | void Compare(const DebugBorderDrawQuad* a, const DebugBorderDrawQuad* b) { |
| 121 | EXPECT_EQ(a->color, b->color); |
| 122 | EXPECT_EQ(a->width, b->width); |
| 123 | } |
| 124 | |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 125 | void Compare(const RenderPassDrawQuad* a, const RenderPassDrawQuad* b) { |
[email protected] | 82f93fb | 2013-04-17 21:42:06 | [diff] [blame] | 126 | EXPECT_EQ(a->render_pass_id, b->render_pass_id); |
vmpstr | 0eca2e8 | 2015-06-02 22:14:46 | [diff] [blame] | 127 | EXPECT_EQ(a->mask_resource_id(), b->mask_resource_id()); |
enne | f6f3fbba4 | 2014-10-16 18:16:49 | [diff] [blame] | 128 | EXPECT_EQ(a->mask_uv_scale.ToString(), b->mask_uv_scale.ToString()); |
| 129 | EXPECT_EQ(a->mask_texture_size.ToString(), b->mask_texture_size.ToString()); |
[email protected] | 1dc7943e | 2013-09-26 04:41:48 | [diff] [blame] | 130 | EXPECT_EQ(a->filters.size(), b->filters.size()); |
| 131 | for (size_t i = 0; i < a->filters.size(); ++i) { |
| 132 | if (a->filters.at(i).type() != cc::FilterOperation::REFERENCE) { |
| 133 | EXPECT_EQ(a->filters.at(i), b->filters.at(i)); |
| 134 | } else { |
| 135 | EXPECT_EQ(b->filters.at(i).type(), cc::FilterOperation::REFERENCE); |
| 136 | EXPECT_EQ(a->filters.at(i).image_filter()->countInputs(), |
| 137 | b->filters.at(i).image_filter()->countInputs()); |
| 138 | } |
| 139 | } |
[email protected] | 7ac3d49 | 2014-08-08 21:25:32 | [diff] [blame] | 140 | EXPECT_EQ(a->filters_scale, b->filters_scale); |
[email protected] | 2006204 | 2012-12-21 22:16:36 | [diff] [blame] | 141 | EXPECT_EQ(a->background_filters, b->background_filters); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | void Compare(const SolidColorDrawQuad* a, const SolidColorDrawQuad* b) { |
| 145 | EXPECT_EQ(a->color, b->color); |
[email protected] | 10a30b1 | 2013-05-02 16:42:11 | [diff] [blame] | 146 | EXPECT_EQ(a->force_anti_aliasing_off, b->force_anti_aliasing_off); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | void Compare(const StreamVideoDrawQuad* a, const StreamVideoDrawQuad* b) { |
vmpstr | 0eca2e8 | 2015-06-02 22:14:46 | [diff] [blame] | 150 | EXPECT_EQ(a->resource_id(), b->resource_id()); |
achaulk | f89f594 | 2015-06-10 17:01:35 | [diff] [blame] | 151 | EXPECT_EQ(a->resource_size_in_pixels(), b->resource_size_in_pixels()); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 152 | EXPECT_EQ(a->matrix, b->matrix); |
| 153 | } |
| 154 | |
[email protected] | 78d3012 | 2014-01-17 06:32:36 | [diff] [blame] | 155 | void Compare(const SurfaceDrawQuad* a, const SurfaceDrawQuad* b) { |
| 156 | EXPECT_EQ(a->surface_id, b->surface_id); |
| 157 | } |
| 158 | |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 159 | void Compare(const TextureDrawQuad* a, const TextureDrawQuad* b) { |
vmpstr | 0eca2e8 | 2015-06-02 22:14:46 | [diff] [blame] | 160 | EXPECT_EQ(a->resource_id(), b->resource_id()); |
achaulk | f89f594 | 2015-06-10 17:01:35 | [diff] [blame] | 161 | EXPECT_EQ(a->resource_size_in_pixels(), b->resource_size_in_pixels()); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 162 | EXPECT_EQ(a->premultiplied_alpha, b->premultiplied_alpha); |
[email protected] | 1fd555b | 2013-01-18 00:13:21 | [diff] [blame] | 163 | EXPECT_EQ(a->uv_top_left, b->uv_top_left); |
| 164 | EXPECT_EQ(a->uv_bottom_right, b->uv_bottom_right); |
[email protected] | d18b4d6 | 2013-07-12 05:33:49 | [diff] [blame] | 165 | EXPECT_EQ(a->background_color, b->background_color); |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 166 | EXPECT_EQ(a->vertex_opacity[0], b->vertex_opacity[0]); |
| 167 | EXPECT_EQ(a->vertex_opacity[1], b->vertex_opacity[1]); |
| 168 | EXPECT_EQ(a->vertex_opacity[2], b->vertex_opacity[2]); |
| 169 | EXPECT_EQ(a->vertex_opacity[3], b->vertex_opacity[3]); |
halliwell | aa11128 | 2015-05-13 21:58:43 | [diff] [blame] | 170 | EXPECT_EQ(a->y_flipped, b->y_flipped); |
jackhou | 10c9af4 | 2014-12-04 05:24:44 | [diff] [blame] | 171 | EXPECT_EQ(a->nearest_neighbor, b->nearest_neighbor); |
jbauman | 0c1bf2113 | 2016-05-19 19:20:07 | [diff] [blame] | 172 | EXPECT_EQ(a->secure_output_only, b->secure_output_only); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 173 | } |
| 174 | |
| 175 | void Compare(const TileDrawQuad* a, const TileDrawQuad* b) { |
vmpstr | 0eca2e8 | 2015-06-02 22:14:46 | [diff] [blame] | 176 | EXPECT_EQ(a->resource_id(), b->resource_id()); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 177 | EXPECT_EQ(a->tex_coord_rect, b->tex_coord_rect); |
| 178 | EXPECT_EQ(a->texture_size, b->texture_size); |
| 179 | EXPECT_EQ(a->swizzle_contents, b->swizzle_contents); |
jackhou | 2422961 | 2014-12-13 23:41:00 | [diff] [blame] | 180 | EXPECT_EQ(a->nearest_neighbor, b->nearest_neighbor); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | void Compare(const YUVVideoDrawQuad* a, const YUVVideoDrawQuad* b) { |
reveman | b71e399 | 2015-05-12 23:01:51 | [diff] [blame] | 184 | EXPECT_EQ(a->ya_tex_coord_rect, b->ya_tex_coord_rect); |
| 185 | EXPECT_EQ(a->uv_tex_coord_rect, b->uv_tex_coord_rect); |
magjed | 7364ff9 | 2015-03-27 09:11:08 | [diff] [blame] | 186 | EXPECT_EQ(a->ya_tex_size, b->ya_tex_size); |
| 187 | EXPECT_EQ(a->uv_tex_size, b->uv_tex_size); |
vmpstr | 0eca2e8 | 2015-06-02 22:14:46 | [diff] [blame] | 188 | EXPECT_EQ(a->y_plane_resource_id(), b->y_plane_resource_id()); |
| 189 | EXPECT_EQ(a->u_plane_resource_id(), b->u_plane_resource_id()); |
| 190 | EXPECT_EQ(a->v_plane_resource_id(), b->v_plane_resource_id()); |
| 191 | EXPECT_EQ(a->a_plane_resource_id(), b->a_plane_resource_id()); |
[email protected] | 82faf5e | 2014-05-03 02:25:58 | [diff] [blame] | 192 | EXPECT_EQ(a->color_space, b->color_space); |
jbauman | aa35e3e | 2016-08-03 22:46:32 | [diff] [blame^] | 193 | EXPECT_EQ(a->bits_per_channel, b->bits_per_channel); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 194 | } |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 195 | |
| 196 | void Compare(const TransferableResource& a, const TransferableResource& b) { |
| 197 | EXPECT_EQ(a.id, b.id); |
| 198 | EXPECT_EQ(a.format, b.format); |
[email protected] | 8018929 | 2013-02-28 01:59:36 | [diff] [blame] | 199 | EXPECT_EQ(a.filter, b.filter); |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 200 | EXPECT_EQ(a.size.ToString(), b.size.ToString()); |
[email protected] | df41e25 | 2014-02-03 23:39:50 | [diff] [blame] | 201 | for (size_t i = 0; i < arraysize(a.mailbox_holder.mailbox.name); ++i) { |
| 202 | EXPECT_EQ(a.mailbox_holder.mailbox.name[i], |
| 203 | b.mailbox_holder.mailbox.name[i]); |
| 204 | } |
| 205 | EXPECT_EQ(a.mailbox_holder.texture_target, b.mailbox_holder.texture_target); |
dyen | cc16ed4d | 2015-11-03 20:03:04 | [diff] [blame] | 206 | EXPECT_EQ(a.mailbox_holder.sync_token, b.mailbox_holder.sync_token); |
ccameron | 268c09fd | 2015-10-08 20:23:46 | [diff] [blame] | 207 | EXPECT_EQ(a.is_overlay_candidate, b.is_overlay_candidate); |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 208 | } |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 209 | }; |
| 210 | |
fsamuel | f76098e | 2016-05-18 17:26:51 | [diff] [blame] | 211 | TEST_F(CCParamTraitsTest, AllQuads) { |
[email protected] | 753bb25 | 2013-11-04 22:28:12 | [diff] [blame] | 212 | IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 213 | |
danakj | 112d3a10 | 2015-04-14 18:24:49 | [diff] [blame] | 214 | Transform arbitrary_matrix1; |
| 215 | arbitrary_matrix1.Scale(3, 3); |
| 216 | arbitrary_matrix1.Translate(-5, 20); |
| 217 | arbitrary_matrix1.Rotate(15); |
| 218 | Transform arbitrary_matrix2; |
| 219 | arbitrary_matrix2.Scale(10, -1); |
| 220 | arbitrary_matrix2.Translate(20, 3); |
| 221 | arbitrary_matrix2.Rotate(24); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 222 | gfx::Rect arbitrary_rect1(-5, 9, 3, 15); |
[email protected] | 8e1da69 | 2013-10-12 17:11:30 | [diff] [blame] | 223 | gfx::Rect arbitrary_rect1_inside_rect1(-4, 12, 2, 8); |
| 224 | gfx::Rect arbitrary_rect2_inside_rect1(-5, 11, 1, 2); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 225 | gfx::Rect arbitrary_rect2(40, 23, 11, 7); |
[email protected] | 8e1da69 | 2013-10-12 17:11:30 | [diff] [blame] | 226 | gfx::Rect arbitrary_rect1_inside_rect2(44, 23, 4, 2); |
| 227 | gfx::Rect arbitrary_rect2_inside_rect2(41, 25, 3, 5); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 228 | gfx::Rect arbitrary_rect3(7, -53, 22, 19); |
[email protected] | 8e1da69 | 2013-10-12 17:11:30 | [diff] [blame] | 229 | gfx::Rect arbitrary_rect1_inside_rect3(10, -40, 6, 3); |
| 230 | gfx::Rect arbitrary_rect2_inside_rect3(12, -51, 5, 12); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 231 | gfx::Size arbitrary_size1(15, 19); |
| 232 | gfx::Size arbitrary_size2(3, 99); |
| 233 | gfx::Size arbitrary_size3(75, 1281); |
| 234 | gfx::RectF arbitrary_rectf1(4.2f, -922.1f, 15.6f, 29.5f); |
reveman | b71e399 | 2015-05-12 23:01:51 | [diff] [blame] | 235 | gfx::RectF arbitrary_rectf2(2.1f, -411.05f, 7.8f, 14.75f); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 236 | gfx::SizeF arbitrary_sizef1(15.2f, 104.6f); |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 237 | gfx::PointF arbitrary_pointf1(31.4f, 15.9f); |
| 238 | gfx::PointF arbitrary_pointf2(26.5f, -35.8f); |
[email protected] | 7ac3d49 | 2014-08-08 21:25:32 | [diff] [blame] | 239 | gfx::Vector2dF arbitrary_vector2df1(16.2f, -85.1f); |
enne | f6f3fbba4 | 2014-10-16 18:16:49 | [diff] [blame] | 240 | gfx::Vector2dF arbitrary_vector2df2(-8.3f, 0.47f); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 241 | float arbitrary_float1 = 0.7f; |
| 242 | float arbitrary_float2 = 0.3f; |
| 243 | float arbitrary_float3 = 0.9f; |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 244 | float arbitrary_float_array[4] = {3.5f, 6.2f, 9.3f, 12.3f}; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 245 | bool arbitrary_bool1 = true; |
| 246 | bool arbitrary_bool2 = false; |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 247 | bool arbitrary_bool3 = true; |
jackhou | 10c9af4 | 2014-12-04 05:24:44 | [diff] [blame] | 248 | bool arbitrary_bool4 = true; |
achaulk | f89f594 | 2015-06-10 17:01:35 | [diff] [blame] | 249 | bool arbitrary_bool5 = false; |
jbauman | 0c1bf2113 | 2016-05-19 19:20:07 | [diff] [blame] | 250 | bool arbitrary_bool6 = true; |
[email protected] | a9d4d4f | 2014-06-19 06:49:28 | [diff] [blame] | 251 | int arbitrary_context_id1 = 12; |
| 252 | int arbitrary_context_id2 = 57; |
| 253 | int arbitrary_context_id3 = -503; |
jbauman | aa35e3e | 2016-08-03 22:46:32 | [diff] [blame^] | 254 | int arbitrary_int = 13; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 255 | SkColor arbitrary_color = SkColorSetARGB(25, 36, 47, 58); |
[email protected] | 7bbeaf4e | 2013-11-26 10:27:22 | [diff] [blame] | 256 | SkXfermode::Mode arbitrary_blend_mode1 = SkXfermode::kScreen_Mode; |
| 257 | SkXfermode::Mode arbitrary_blend_mode2 = SkXfermode::kLighten_Mode; |
| 258 | SkXfermode::Mode arbitrary_blend_mode3 = SkXfermode::kOverlay_Mode; |
jbauman | bbd425e | 2015-05-19 00:33:35 | [diff] [blame] | 259 | ResourceId arbitrary_resourceid1 = 55; |
| 260 | ResourceId arbitrary_resourceid2 = 47; |
| 261 | ResourceId arbitrary_resourceid3 = 23; |
| 262 | ResourceId arbitrary_resourceid4 = 16; |
[email protected] | a176567 | 2013-08-12 23:45:02 | [diff] [blame] | 263 | SkScalar arbitrary_sigma = SkFloatToScalar(2.0f); |
[email protected] | 82faf5e | 2014-05-03 02:25:58 | [diff] [blame] | 264 | YUVVideoDrawQuad::ColorSpace arbitrary_color_space = |
| 265 | YUVVideoDrawQuad::REC_601; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 266 | |
danakj | 112d3a10 | 2015-04-14 18:24:49 | [diff] [blame] | 267 | RenderPassId child_id(30, 5); |
| 268 | RenderPassId root_id(10, 14); |
| 269 | |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame] | 270 | FilterOperations arbitrary_filters1; |
[email protected] | 1dc7943e | 2013-09-26 04:41:48 | [diff] [blame] | 271 | arbitrary_filters1.Append( |
fsamuel | f76098e | 2016-05-18 17:26:51 | [diff] [blame] | 272 | FilterOperation::CreateGrayscaleFilter(arbitrary_float1)); |
| 273 | arbitrary_filters1.Append(cc::FilterOperation::CreateReferenceFilter( |
| 274 | SkBlurImageFilter::Make(arbitrary_sigma, arbitrary_sigma, nullptr))); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 275 | |
[email protected] | ae6b1a7 | 2013-06-25 18:49:29 | [diff] [blame] | 276 | FilterOperations arbitrary_filters2; |
fsamuel | f76098e | 2016-05-18 17:26:51 | [diff] [blame] | 277 | arbitrary_filters2.Append( |
| 278 | FilterOperation::CreateBrightnessFilter(arbitrary_float2)); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 279 | |
dcheng | 4ac58c7a | 2016-04-09 04:51:48 | [diff] [blame] | 280 | std::unique_ptr<RenderPass> child_pass_in = RenderPass::Create(); |
danakj | 112d3a10 | 2015-04-14 18:24:49 | [diff] [blame] | 281 | child_pass_in->SetAll(child_id, arbitrary_rect2, arbitrary_rect3, |
| 282 | arbitrary_matrix2, arbitrary_bool2); |
| 283 | |
dcheng | 4ac58c7a | 2016-04-09 04:51:48 | [diff] [blame] | 284 | std::unique_ptr<RenderPass> child_pass_cmp = RenderPass::Create(); |
danakj | 112d3a10 | 2015-04-14 18:24:49 | [diff] [blame] | 285 | child_pass_cmp->SetAll(child_id, arbitrary_rect2, arbitrary_rect3, |
| 286 | arbitrary_matrix2, arbitrary_bool2); |
| 287 | |
dcheng | 4ac58c7a | 2016-04-09 04:51:48 | [diff] [blame] | 288 | std::unique_ptr<RenderPass> pass_in = RenderPass::Create(); |
danakj | 112d3a10 | 2015-04-14 18:24:49 | [diff] [blame] | 289 | pass_in->SetAll(root_id, arbitrary_rect1, arbitrary_rect2, arbitrary_matrix1, |
[email protected] | 2b7f389 | 2014-05-08 01:45:18 | [diff] [blame] | 290 | arbitrary_bool1); |
| 291 | |
| 292 | SharedQuadState* shared_state1_in = pass_in->CreateAndAppendSharedQuadState(); |
danakj | 112d3a10 | 2015-04-14 18:24:49 | [diff] [blame] | 293 | shared_state1_in->SetAll(arbitrary_matrix1, arbitrary_size1, arbitrary_rect1, |
| 294 | arbitrary_rect2, arbitrary_bool1, arbitrary_float1, |
| 295 | arbitrary_blend_mode1, arbitrary_context_id1); |
[email protected] | 2b7f389 | 2014-05-08 01:45:18 | [diff] [blame] | 296 | |
dcheng | 4ac58c7a | 2016-04-09 04:51:48 | [diff] [blame] | 297 | std::unique_ptr<RenderPass> pass_cmp = RenderPass::Create(); |
danakj | 112d3a10 | 2015-04-14 18:24:49 | [diff] [blame] | 298 | pass_cmp->SetAll(root_id, arbitrary_rect1, arbitrary_rect2, arbitrary_matrix1, |
[email protected] | 2b7f389 | 2014-05-08 01:45:18 | [diff] [blame] | 299 | arbitrary_bool1); |
| 300 | |
| 301 | SharedQuadState* shared_state1_cmp = |
| 302 | pass_cmp->CreateAndAppendSharedQuadState(); |
fsamuel | 9599876 | 2016-06-02 11:22:22 | [diff] [blame] | 303 | *shared_state1_cmp = *shared_state1_in; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 304 | |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 305 | DebugBorderDrawQuad* debugborder_in = |
| 306 | pass_in->CreateAndAppendDrawQuad<DebugBorderDrawQuad>(); |
fsamuel | f76098e | 2016-05-18 17:26:51 | [diff] [blame] | 307 | debugborder_in->SetAll(shared_state1_in, arbitrary_rect3, |
[email protected] | 8e1da69 | 2013-10-12 17:11:30 | [diff] [blame] | 308 | arbitrary_rect1_inside_rect3, |
fsamuel | f76098e | 2016-05-18 17:26:51 | [diff] [blame] | 309 | arbitrary_rect2_inside_rect3, arbitrary_bool1, |
| 310 | arbitrary_color, arbitrary_int); |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 311 | pass_cmp->CopyFromAndAppendDrawQuad(debugborder_in, |
| 312 | debugborder_in->shared_quad_state); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 313 | |
[email protected] | 2b7f389 | 2014-05-08 01:45:18 | [diff] [blame] | 314 | SharedQuadState* shared_state2_in = pass_in->CreateAndAppendSharedQuadState(); |
danakj | 112d3a10 | 2015-04-14 18:24:49 | [diff] [blame] | 315 | shared_state2_in->SetAll(arbitrary_matrix2, arbitrary_size2, arbitrary_rect2, |
| 316 | arbitrary_rect3, arbitrary_bool1, arbitrary_float2, |
| 317 | arbitrary_blend_mode2, arbitrary_context_id2); |
[email protected] | 2b7f389 | 2014-05-08 01:45:18 | [diff] [blame] | 318 | SharedQuadState* shared_state2_cmp = |
| 319 | pass_cmp->CreateAndAppendSharedQuadState(); |
fsamuel | 9599876 | 2016-06-02 11:22:22 | [diff] [blame] | 320 | *shared_state2_cmp = *shared_state2_in; |
[email protected] | cbe94b7a | 2013-11-13 11:03:37 | [diff] [blame] | 321 | |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 322 | RenderPassDrawQuad* renderpass_in = |
| 323 | pass_in->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); |
danakj | 112d3a10 | 2015-04-14 18:24:49 | [diff] [blame] | 324 | renderpass_in->SetAll( |
| 325 | shared_state2_in, arbitrary_rect1, arbitrary_rect2_inside_rect1, |
| 326 | arbitrary_rect1_inside_rect1, arbitrary_bool1, child_id, |
| 327 | arbitrary_resourceid2, arbitrary_vector2df1, arbitrary_size1, |
| 328 | arbitrary_filters1, arbitrary_vector2df2, arbitrary_filters2); |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 329 | pass_cmp->CopyFromAndAppendRenderPassDrawQuad( |
fsamuel | f76098e | 2016-05-18 17:26:51 | [diff] [blame] | 330 | renderpass_in, renderpass_in->shared_quad_state, |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 331 | renderpass_in->render_pass_id); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 332 | |
[email protected] | 2b7f389 | 2014-05-08 01:45:18 | [diff] [blame] | 333 | SharedQuadState* shared_state3_in = pass_in->CreateAndAppendSharedQuadState(); |
danakj | 112d3a10 | 2015-04-14 18:24:49 | [diff] [blame] | 334 | shared_state3_in->SetAll(arbitrary_matrix1, arbitrary_size3, arbitrary_rect3, |
| 335 | arbitrary_rect1, arbitrary_bool1, arbitrary_float3, |
| 336 | arbitrary_blend_mode3, arbitrary_context_id3); |
[email protected] | 2b7f389 | 2014-05-08 01:45:18 | [diff] [blame] | 337 | SharedQuadState* shared_state3_cmp = |
| 338 | pass_cmp->CreateAndAppendSharedQuadState(); |
fsamuel | 9599876 | 2016-06-02 11:22:22 | [diff] [blame] | 339 | *shared_state3_cmp = *shared_state3_in; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 340 | |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 341 | SolidColorDrawQuad* solidcolor_in = |
| 342 | pass_in->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
fsamuel | f76098e | 2016-05-18 17:26:51 | [diff] [blame] | 343 | solidcolor_in->SetAll(shared_state3_in, arbitrary_rect3, |
[email protected] | 8e1da69 | 2013-10-12 17:11:30 | [diff] [blame] | 344 | arbitrary_rect1_inside_rect3, |
fsamuel | f76098e | 2016-05-18 17:26:51 | [diff] [blame] | 345 | arbitrary_rect2_inside_rect3, arbitrary_bool1, |
| 346 | arbitrary_color, arbitrary_bool2); |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 347 | pass_cmp->CopyFromAndAppendDrawQuad(solidcolor_in, |
| 348 | solidcolor_in->shared_quad_state); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 349 | |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 350 | StreamVideoDrawQuad* streamvideo_in = |
| 351 | pass_in->CreateAndAppendDrawQuad<StreamVideoDrawQuad>(); |
achaulk | f89f594 | 2015-06-10 17:01:35 | [diff] [blame] | 352 | streamvideo_in->SetAll( |
| 353 | shared_state3_in, arbitrary_rect2, arbitrary_rect2_inside_rect2, |
| 354 | arbitrary_rect1_inside_rect2, arbitrary_bool1, arbitrary_resourceid2, |
ccameron | 268c09fd | 2015-10-08 20:23:46 | [diff] [blame] | 355 | arbitrary_size1, arbitrary_matrix1); |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 356 | pass_cmp->CopyFromAndAppendDrawQuad(streamvideo_in, |
| 357 | streamvideo_in->shared_quad_state); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 358 | |
fsamuel | 845b871 | 2016-05-25 17:36:11 | [diff] [blame] | 359 | cc::SurfaceId arbitrary_surface_id(0, 3, 0); |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 360 | SurfaceDrawQuad* surface_in = |
| 361 | pass_in->CreateAndAppendDrawQuad<SurfaceDrawQuad>(); |
fsamuel | f76098e | 2016-05-18 17:26:51 | [diff] [blame] | 362 | surface_in->SetAll(shared_state3_in, arbitrary_rect2, |
| 363 | arbitrary_rect2_inside_rect2, arbitrary_rect1_inside_rect2, |
| 364 | arbitrary_bool1, arbitrary_surface_id); |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 365 | pass_cmp->CopyFromAndAppendDrawQuad(surface_in, |
| 366 | surface_in->shared_quad_state); |
[email protected] | 78d3012 | 2014-01-17 06:32:36 | [diff] [blame] | 367 | |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 368 | TextureDrawQuad* texture_in = |
| 369 | pass_in->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
jbauman | 0c1bf2113 | 2016-05-19 19:20:07 | [diff] [blame] | 370 | texture_in->SetAll(shared_state3_in, arbitrary_rect2, |
| 371 | arbitrary_rect2_inside_rect2, arbitrary_rect1_inside_rect2, |
| 372 | arbitrary_bool1, arbitrary_resourceid1, arbitrary_size1, |
| 373 | arbitrary_bool2, arbitrary_pointf1, arbitrary_pointf2, |
| 374 | arbitrary_color, arbitrary_float_array, arbitrary_bool4, |
| 375 | arbitrary_bool5, arbitrary_bool6); |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 376 | pass_cmp->CopyFromAndAppendDrawQuad(texture_in, |
| 377 | texture_in->shared_quad_state); |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 378 | |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 379 | TileDrawQuad* tile_in = pass_in->CreateAndAppendDrawQuad<TileDrawQuad>(); |
fsamuel | f76098e | 2016-05-18 17:26:51 | [diff] [blame] | 380 | tile_in->SetAll(shared_state3_in, arbitrary_rect2, |
| 381 | arbitrary_rect2_inside_rect2, arbitrary_rect1_inside_rect2, |
| 382 | arbitrary_bool1, arbitrary_resourceid3, arbitrary_rectf1, |
| 383 | arbitrary_size1, arbitrary_bool2, arbitrary_bool3); |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 384 | pass_cmp->CopyFromAndAppendDrawQuad(tile_in, tile_in->shared_quad_state); |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 385 | |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 386 | YUVVideoDrawQuad* yuvvideo_in = |
| 387 | pass_in->CreateAndAppendDrawQuad<YUVVideoDrawQuad>(); |
reveman | b71e399 | 2015-05-12 23:01:51 | [diff] [blame] | 388 | yuvvideo_in->SetAll( |
| 389 | shared_state3_in, arbitrary_rect1, arbitrary_rect2_inside_rect1, |
| 390 | arbitrary_rect1_inside_rect1, arbitrary_bool1, arbitrary_rectf1, |
| 391 | arbitrary_rectf2, arbitrary_size1, arbitrary_size2, arbitrary_resourceid1, |
| 392 | arbitrary_resourceid2, arbitrary_resourceid3, arbitrary_resourceid4, |
jbauman | aa35e3e | 2016-08-03 22:46:32 | [diff] [blame^] | 393 | arbitrary_color_space, arbitrary_float1, arbitrary_float2, arbitrary_int); |
[email protected] | 3b85fd9 | 2014-07-10 00:00:02 | [diff] [blame] | 394 | pass_cmp->CopyFromAndAppendDrawQuad(yuvvideo_in, |
| 395 | yuvvideo_in->shared_quad_state); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 396 | |
| 397 | // Make sure the in and cmp RenderPasses match. |
danakj | 112d3a10 | 2015-04-14 18:24:49 | [diff] [blame] | 398 | Compare(child_pass_cmp.get(), child_pass_in.get()); |
| 399 | ASSERT_EQ(0u, child_pass_in->shared_quad_state_list.size()); |
| 400 | ASSERT_EQ(0u, child_pass_in->quad_list.size()); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 401 | Compare(pass_cmp.get(), pass_in.get()); |
| 402 | ASSERT_EQ(3u, pass_in->shared_quad_state_list.size()); |
ccameron | 648c911 | 2016-05-18 23:44:07 | [diff] [blame] | 403 | ASSERT_EQ(8u, pass_in->quad_list.size()); |
weiliangc | 808f70f | 2014-10-03 22:53:15 | [diff] [blame] | 404 | for (cc::SharedQuadStateList::ConstIterator |
| 405 | cmp_iterator = pass_cmp->shared_quad_state_list.begin(), |
| 406 | in_iterator = pass_in->shared_quad_state_list.begin(); |
| 407 | in_iterator != pass_in->shared_quad_state_list.end(); |
| 408 | ++cmp_iterator, ++in_iterator) { |
weiliangc | 48805fce | 2014-10-29 20:30:12 | [diff] [blame] | 409 | Compare(*cmp_iterator, *in_iterator); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 410 | } |
weiliangc | 7eb7ee6 | 2014-10-07 00:04:40 | [diff] [blame] | 411 | for (auto in_iter = pass_in->quad_list.cbegin(), |
| 412 | cmp_iter = pass_cmp->quad_list.cbegin(); |
fsamuel | f76098e | 2016-05-18 17:26:51 | [diff] [blame] | 413 | in_iter != pass_in->quad_list.cend(); ++in_iter, ++cmp_iter) |
weiliangc | 48805fce | 2014-10-29 20:30:12 | [diff] [blame] | 414 | Compare(*cmp_iter, *in_iter); |
weiliangc | 032e929d | 2014-09-26 01:55:01 | [diff] [blame] | 415 | |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 416 | for (size_t i = 1; i < pass_in->quad_list.size(); ++i) { |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 417 | bool same_shared_quad_state_cmp = |
weiliangc | 032e929d | 2014-09-26 01:55:01 | [diff] [blame] | 418 | pass_cmp->quad_list.ElementAt(i)->shared_quad_state == |
| 419 | pass_cmp->quad_list.ElementAt(i - 1)->shared_quad_state; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 420 | bool same_shared_quad_state_in = |
weiliangc | 032e929d | 2014-09-26 01:55:01 | [diff] [blame] | 421 | pass_in->quad_list.ElementAt(i)->shared_quad_state == |
| 422 | pass_in->quad_list.ElementAt(i - 1)->shared_quad_state; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 423 | EXPECT_EQ(same_shared_quad_state_cmp, same_shared_quad_state_in); |
| 424 | } |
| 425 | |
[email protected] | bf189f6 | 2012-12-18 03:42:11 | [diff] [blame] | 426 | DelegatedFrameData frame_in; |
dcheng | f63a125 | 2015-12-26 20:43:13 | [diff] [blame] | 427 | frame_in.render_pass_list.push_back(std::move(child_pass_in)); |
| 428 | frame_in.render_pass_list.push_back(std::move(pass_in)); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 429 | |
[email protected] | bf189f6 | 2012-12-18 03:42:11 | [diff] [blame] | 430 | IPC::ParamTraits<DelegatedFrameData>::Write(&msg, frame_in); |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 431 | |
[email protected] | bf189f6 | 2012-12-18 03:42:11 | [diff] [blame] | 432 | DelegatedFrameData frame_out; |
brettw | bd4d711 | 2015-06-03 04:29:25 | [diff] [blame] | 433 | base::PickleIterator iter(msg); |
fsamuel | f76098e | 2016-05-18 17:26:51 | [diff] [blame] | 434 | EXPECT_TRUE( |
| 435 | IPC::ParamTraits<DelegatedFrameData>::Read(&msg, &iter, &frame_out)); |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 436 | |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 437 | // Make sure the out and cmp RenderPasses match. |
dcheng | 4ac58c7a | 2016-04-09 04:51:48 | [diff] [blame] | 438 | std::unique_ptr<RenderPass> child_pass_out = |
dcheng | f63a125 | 2015-12-26 20:43:13 | [diff] [blame] | 439 | std::move(frame_out.render_pass_list[0]); |
danakj | 112d3a10 | 2015-04-14 18:24:49 | [diff] [blame] | 440 | Compare(child_pass_cmp.get(), child_pass_out.get()); |
| 441 | ASSERT_EQ(0u, child_pass_out->shared_quad_state_list.size()); |
| 442 | ASSERT_EQ(0u, child_pass_out->quad_list.size()); |
dcheng | 4ac58c7a | 2016-04-09 04:51:48 | [diff] [blame] | 443 | std::unique_ptr<RenderPass> pass_out = |
| 444 | std::move(frame_out.render_pass_list[1]); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 445 | Compare(pass_cmp.get(), pass_out.get()); |
| 446 | ASSERT_EQ(3u, pass_out->shared_quad_state_list.size()); |
ccameron | 648c911 | 2016-05-18 23:44:07 | [diff] [blame] | 447 | ASSERT_EQ(8u, pass_out->quad_list.size()); |
weiliangc | 808f70f | 2014-10-03 22:53:15 | [diff] [blame] | 448 | for (cc::SharedQuadStateList::ConstIterator |
| 449 | cmp_iterator = pass_cmp->shared_quad_state_list.begin(), |
| 450 | out_iterator = pass_out->shared_quad_state_list.begin(); |
| 451 | out_iterator != pass_out->shared_quad_state_list.end(); |
| 452 | ++cmp_iterator, ++out_iterator) { |
weiliangc | 48805fce | 2014-10-29 20:30:12 | [diff] [blame] | 453 | Compare(*cmp_iterator, *out_iterator); |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 454 | } |
weiliangc | 7eb7ee6 | 2014-10-07 00:04:40 | [diff] [blame] | 455 | for (auto out_iter = pass_out->quad_list.cbegin(), |
| 456 | cmp_iter = pass_cmp->quad_list.cbegin(); |
fsamuel | f76098e | 2016-05-18 17:26:51 | [diff] [blame] | 457 | out_iter != pass_out->quad_list.cend(); ++out_iter, ++cmp_iter) |
weiliangc | 48805fce | 2014-10-29 20:30:12 | [diff] [blame] | 458 | Compare(*cmp_iter, *out_iter); |
weiliangc | 032e929d | 2014-09-26 01:55:01 | [diff] [blame] | 459 | |
[email protected] | 61df9d8 | 2013-01-30 02:32:42 | [diff] [blame] | 460 | for (size_t i = 1; i < pass_out->quad_list.size(); ++i) { |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 461 | bool same_shared_quad_state_cmp = |
weiliangc | 032e929d | 2014-09-26 01:55:01 | [diff] [blame] | 462 | pass_cmp->quad_list.ElementAt(i)->shared_quad_state == |
| 463 | pass_cmp->quad_list.ElementAt(i - 1)->shared_quad_state; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 464 | bool same_shared_quad_state_out = |
weiliangc | 032e929d | 2014-09-26 01:55:01 | [diff] [blame] | 465 | pass_out->quad_list.ElementAt(i)->shared_quad_state == |
| 466 | pass_out->quad_list.ElementAt(i - 1)->shared_quad_state; |
[email protected] | 4934d36 | 2012-11-22 22:04:53 | [diff] [blame] | 467 | EXPECT_EQ(same_shared_quad_state_cmp, same_shared_quad_state_out); |
| 468 | } |
| 469 | } |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 470 | |
fsamuel | f76098e | 2016-05-18 17:26:51 | [diff] [blame] | 471 | TEST_F(CCParamTraitsTest, UnusedSharedQuadStates) { |
dcheng | 4ac58c7a | 2016-04-09 04:51:48 | [diff] [blame] | 472 | std::unique_ptr<RenderPass> pass_in = RenderPass::Create(); |
fsamuel | f76098e | 2016-05-18 17:26:51 | [diff] [blame] | 473 | pass_in->SetAll(RenderPassId(1, 1), gfx::Rect(100, 100), gfx::Rect(), |
| 474 | gfx::Transform(), false); |
[email protected] | cbe94b7a | 2013-11-13 11:03:37 | [diff] [blame] | 475 | |
| 476 | // The first SharedQuadState is used. |
[email protected] | 2b7f389 | 2014-05-08 01:45:18 | [diff] [blame] | 477 | SharedQuadState* shared_state1_in = pass_in->CreateAndAppendSharedQuadState(); |
fsamuel | f76098e | 2016-05-18 17:26:51 | [diff] [blame] | 478 | shared_state1_in->SetAll(gfx::Transform(), gfx::Size(1, 1), gfx::Rect(), |
| 479 | gfx::Rect(), false, 1.f, SkXfermode::kSrcOver_Mode, |
[email protected] | a9d4d4f | 2014-06-19 06:49:28 | [diff] [blame] | 480 | 0); |
[email protected] | cbe94b7a | 2013-11-13 11:03:37 | [diff] [blame] | 481 | |
danakj | a8f1ac3 | 2015-08-05 18:46:57 | [diff] [blame] | 482 | SolidColorDrawQuad* quad1 = |
| 483 | pass_in->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
danakj | e1419ce | 2015-03-04 21:26:27 | [diff] [blame] | 484 | quad1->SetAll(shared_state1_in, gfx::Rect(10, 10), gfx::Rect(10, 10), |
danakj | a8f1ac3 | 2015-08-05 18:46:57 | [diff] [blame] | 485 | gfx::Rect(10, 10), false, SK_ColorRED, false); |
[email protected] | cbe94b7a | 2013-11-13 11:03:37 | [diff] [blame] | 486 | |
| 487 | // The second and third SharedQuadStates are not used. |
[email protected] | 2b7f389 | 2014-05-08 01:45:18 | [diff] [blame] | 488 | SharedQuadState* shared_state2_in = pass_in->CreateAndAppendSharedQuadState(); |
fsamuel | f76098e | 2016-05-18 17:26:51 | [diff] [blame] | 489 | shared_state2_in->SetAll(gfx::Transform(), gfx::Size(2, 2), gfx::Rect(), |
| 490 | gfx::Rect(), false, 1.f, SkXfermode::kSrcOver_Mode, |
[email protected] | a9d4d4f | 2014-06-19 06:49:28 | [diff] [blame] | 491 | 0); |
[email protected] | cbe94b7a | 2013-11-13 11:03:37 | [diff] [blame] | 492 | |
[email protected] | 2b7f389 | 2014-05-08 01:45:18 | [diff] [blame] | 493 | SharedQuadState* shared_state3_in = pass_in->CreateAndAppendSharedQuadState(); |
fsamuel | f76098e | 2016-05-18 17:26:51 | [diff] [blame] | 494 | shared_state3_in->SetAll(gfx::Transform(), gfx::Size(3, 3), gfx::Rect(), |
| 495 | gfx::Rect(), false, 1.f, SkXfermode::kSrcOver_Mode, |
[email protected] | a9d4d4f | 2014-06-19 06:49:28 | [diff] [blame] | 496 | 0); |
[email protected] | cbe94b7a | 2013-11-13 11:03:37 | [diff] [blame] | 497 | |
| 498 | // The fourth SharedQuadState is used. |
[email protected] | 2b7f389 | 2014-05-08 01:45:18 | [diff] [blame] | 499 | SharedQuadState* shared_state4_in = pass_in->CreateAndAppendSharedQuadState(); |
fsamuel | f76098e | 2016-05-18 17:26:51 | [diff] [blame] | 500 | shared_state4_in->SetAll(gfx::Transform(), gfx::Size(4, 4), gfx::Rect(), |
| 501 | gfx::Rect(), false, 1.f, SkXfermode::kSrcOver_Mode, |
[email protected] | a9d4d4f | 2014-06-19 06:49:28 | [diff] [blame] | 502 | 0); |
[email protected] | cbe94b7a | 2013-11-13 11:03:37 | [diff] [blame] | 503 | |
danakj | a8f1ac3 | 2015-08-05 18:46:57 | [diff] [blame] | 504 | SolidColorDrawQuad* quad2 = |
| 505 | pass_in->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
danakj | e1419ce | 2015-03-04 21:26:27 | [diff] [blame] | 506 | quad2->SetAll(shared_state4_in, gfx::Rect(10, 10), gfx::Rect(10, 10), |
danakj | a8f1ac3 | 2015-08-05 18:46:57 | [diff] [blame] | 507 | gfx::Rect(10, 10), false, SK_ColorRED, false); |
[email protected] | cbe94b7a | 2013-11-13 11:03:37 | [diff] [blame] | 508 | |
| 509 | // The fifth is not used again. |
[email protected] | 2b7f389 | 2014-05-08 01:45:18 | [diff] [blame] | 510 | SharedQuadState* shared_state5_in = pass_in->CreateAndAppendSharedQuadState(); |
fsamuel | f76098e | 2016-05-18 17:26:51 | [diff] [blame] | 511 | shared_state5_in->SetAll(gfx::Transform(), gfx::Size(5, 5), gfx::Rect(), |
| 512 | gfx::Rect(), false, 1.f, SkXfermode::kSrcOver_Mode, |
[email protected] | a9d4d4f | 2014-06-19 06:49:28 | [diff] [blame] | 513 | 0); |
[email protected] | cbe94b7a | 2013-11-13 11:03:37 | [diff] [blame] | 514 | |
[email protected] | cbe94b7a | 2013-11-13 11:03:37 | [diff] [blame] | 515 | // 5 SharedQuadStates go in. |
| 516 | ASSERT_EQ(5u, pass_in->shared_quad_state_list.size()); |
| 517 | ASSERT_EQ(2u, pass_in->quad_list.size()); |
| 518 | |
| 519 | DelegatedFrameData frame_in; |
dcheng | f63a125 | 2015-12-26 20:43:13 | [diff] [blame] | 520 | frame_in.render_pass_list.push_back(std::move(pass_in)); |
[email protected] | cbe94b7a | 2013-11-13 11:03:37 | [diff] [blame] | 521 | |
| 522 | IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); |
| 523 | IPC::ParamTraits<DelegatedFrameData>::Write(&msg, frame_in); |
| 524 | |
| 525 | DelegatedFrameData frame_out; |
brettw | bd4d711 | 2015-06-03 04:29:25 | [diff] [blame] | 526 | base::PickleIterator iter(msg); |
[email protected] | cbe94b7a | 2013-11-13 11:03:37 | [diff] [blame] | 527 | EXPECT_TRUE( |
| 528 | IPC::ParamTraits<DelegatedFrameData>::Read(&msg, &iter, &frame_out)); |
| 529 | |
dcheng | 4ac58c7a | 2016-04-09 04:51:48 | [diff] [blame] | 530 | std::unique_ptr<RenderPass> pass_out = |
| 531 | std::move(frame_out.render_pass_list[0]); |
[email protected] | cbe94b7a | 2013-11-13 11:03:37 | [diff] [blame] | 532 | |
| 533 | // 2 SharedQuadStates come out. The first and fourth SharedQuadStates were |
| 534 | // used by quads, and so serialized. Others were not. |
| 535 | ASSERT_EQ(2u, pass_out->shared_quad_state_list.size()); |
| 536 | ASSERT_EQ(2u, pass_out->quad_list.size()); |
| 537 | |
danakj | 64767d90 | 2015-06-19 00:10:43 | [diff] [blame] | 538 | EXPECT_EQ(gfx::Size(1, 1).ToString(), |
| 539 | pass_out->shared_quad_state_list.ElementAt(0) |
| 540 | ->quad_layer_bounds.ToString()); |
| 541 | EXPECT_EQ(gfx::Size(4, 4).ToString(), |
| 542 | pass_out->shared_quad_state_list.ElementAt(1) |
| 543 | ->quad_layer_bounds.ToString()); |
[email protected] | cbe94b7a | 2013-11-13 11:03:37 | [diff] [blame] | 544 | } |
| 545 | |
fsamuel | f76098e | 2016-05-18 17:26:51 | [diff] [blame] | 546 | TEST_F(CCParamTraitsTest, Resources) { |
[email protected] | 753bb25 | 2013-11-04 22:28:12 | [diff] [blame] | 547 | IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 548 | gfx::Size arbitrary_size(757, 1281); |
lukasza | 2573ce7d | 2016-02-16 19:17:22 | [diff] [blame] | 549 | gpu::SyncToken arbitrary_token1(gpu::CommandBufferNamespace::GPU_IO, 0, |
| 550 | gpu::CommandBufferId::FromUnsafeValue(0x123), |
dyen | 398dd014 | 2016-01-21 22:05:56 | [diff] [blame] | 551 | 71234838); |
| 552 | arbitrary_token1.SetVerifyFlush(); |
lukasza | 2573ce7d | 2016-02-16 19:17:22 | [diff] [blame] | 553 | gpu::SyncToken arbitrary_token2(gpu::CommandBufferNamespace::GPU_IO, 0, |
| 554 | gpu::CommandBufferId::FromUnsafeValue(0x123), |
dyen | 398dd014 | 2016-01-21 22:05:56 | [diff] [blame] | 555 | 53589793); |
| 556 | arbitrary_token2.SetVerifyFlush(); |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 557 | |
[email protected] | e0a4d73 | 2014-02-15 00:23:26 | [diff] [blame] | 558 | GLbyte arbitrary_mailbox1[GL_MAILBOX_SIZE_CHROMIUM] = { |
| 559 | 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, |
| 560 | 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, |
| 561 | 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] | 562 | |
[email protected] | e0a4d73 | 2014-02-15 00:23:26 | [diff] [blame] | 563 | GLbyte arbitrary_mailbox2[GL_MAILBOX_SIZE_CHROMIUM] = { |
| 564 | 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, |
| 565 | 8, 7, 6, 5, 4, 3, 2, 1, 9, 7, 5, 3, 1, 2, 4, 6, 8, 0, 0, 9, 8, 7, |
| 566 | 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] | 567 | |
| 568 | TransferableResource arbitrary_resource1; |
| 569 | arbitrary_resource1.id = 2178312; |
[email protected] | 27a41fe | 2013-09-19 05:05:14 | [diff] [blame] | 570 | arbitrary_resource1.format = cc::RGBA_8888; |
[email protected] | 8018929 | 2013-02-28 01:59:36 | [diff] [blame] | 571 | arbitrary_resource1.filter = 53; |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 572 | arbitrary_resource1.size = gfx::Size(37189, 123123); |
[email protected] | df41e25 | 2014-02-03 23:39:50 | [diff] [blame] | 573 | arbitrary_resource1.mailbox_holder.mailbox.SetName(arbitrary_mailbox1); |
| 574 | arbitrary_resource1.mailbox_holder.texture_target = GL_TEXTURE_2D; |
dyen | cc16ed4d | 2015-11-03 20:03:04 | [diff] [blame] | 575 | arbitrary_resource1.mailbox_holder.sync_token = arbitrary_token1; |
ccameron | 268c09fd | 2015-10-08 20:23:46 | [diff] [blame] | 576 | arbitrary_resource1.is_overlay_candidate = true; |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 577 | |
| 578 | TransferableResource arbitrary_resource2; |
| 579 | arbitrary_resource2.id = 789132; |
[email protected] | 27a41fe | 2013-09-19 05:05:14 | [diff] [blame] | 580 | arbitrary_resource2.format = cc::RGBA_4444; |
[email protected] | 645a47f2 | 2013-09-26 05:42:32 | [diff] [blame] | 581 | arbitrary_resource2.filter = 47; |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 582 | arbitrary_resource2.size = gfx::Size(89123, 23789); |
[email protected] | df41e25 | 2014-02-03 23:39:50 | [diff] [blame] | 583 | arbitrary_resource2.mailbox_holder.mailbox.SetName(arbitrary_mailbox2); |
| 584 | arbitrary_resource2.mailbox_holder.texture_target = GL_TEXTURE_EXTERNAL_OES; |
dyen | cc16ed4d | 2015-11-03 20:03:04 | [diff] [blame] | 585 | arbitrary_resource2.mailbox_holder.sync_token = arbitrary_token2; |
ccameron | 268c09fd | 2015-10-08 20:23:46 | [diff] [blame] | 586 | arbitrary_resource2.is_overlay_candidate = false; |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 587 | |
dcheng | 4ac58c7a | 2016-04-09 04:51:48 | [diff] [blame] | 588 | std::unique_ptr<RenderPass> renderpass_in = RenderPass::Create(); |
fsamuel | f76098e | 2016-05-18 17:26:51 | [diff] [blame] | 589 | renderpass_in->SetNew(RenderPassId(1, 1), gfx::Rect(), gfx::Rect(), |
| 590 | gfx::Transform()); |
[email protected] | cb7d649 | 2013-10-03 02:40:04 | [diff] [blame] | 591 | |
[email protected] | bf189f6 | 2012-12-18 03:42:11 | [diff] [blame] | 592 | DelegatedFrameData frame_in; |
[email protected] | 09831f7f | 2013-02-27 03:32:15 | [diff] [blame] | 593 | frame_in.resource_list.push_back(arbitrary_resource1); |
| 594 | frame_in.resource_list.push_back(arbitrary_resource2); |
dcheng | f63a125 | 2015-12-26 20:43:13 | [diff] [blame] | 595 | frame_in.render_pass_list.push_back(std::move(renderpass_in)); |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 596 | |
[email protected] | bf189f6 | 2012-12-18 03:42:11 | [diff] [blame] | 597 | IPC::ParamTraits<DelegatedFrameData>::Write(&msg, frame_in); |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 598 | |
[email protected] | bf189f6 | 2012-12-18 03:42:11 | [diff] [blame] | 599 | DelegatedFrameData frame_out; |
brettw | bd4d711 | 2015-06-03 04:29:25 | [diff] [blame] | 600 | base::PickleIterator iter(msg); |
fsamuel | f76098e | 2016-05-18 17:26:51 | [diff] [blame] | 601 | EXPECT_TRUE( |
| 602 | IPC::ParamTraits<DelegatedFrameData>::Read(&msg, &iter, &frame_out)); |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 603 | |
[email protected] | 09831f7f | 2013-02-27 03:32:15 | [diff] [blame] | 604 | ASSERT_EQ(2u, frame_out.resource_list.size()); |
| 605 | Compare(arbitrary_resource1, frame_out.resource_list[0]); |
| 606 | Compare(arbitrary_resource2, frame_out.resource_list[1]); |
[email protected] | bca15907 | 2012-12-04 00:52:44 | [diff] [blame] | 607 | } |
| 608 | |
| 609 | } // namespace |
| 610 | } // namespace content |