OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stddef.h> | 5 #include <stddef.h> |
6 #include <string.h> | 6 #include <string.h> |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 static constexpr cc::FrameSinkId kArbitraryFrameSinkId(1, 1); | 48 static constexpr cc::FrameSinkId kArbitraryFrameSinkId(1, 1); |
49 | 49 |
50 class CCParamTraitsTest : public testing::Test { | 50 class CCParamTraitsTest : public testing::Test { |
51 protected: | 51 protected: |
52 void Compare(const RenderPass* a, const RenderPass* b) { | 52 void Compare(const RenderPass* a, const RenderPass* b) { |
53 EXPECT_EQ(a->id, b->id); | 53 EXPECT_EQ(a->id, b->id); |
54 EXPECT_EQ(a->output_rect.ToString(), b->output_rect.ToString()); | 54 EXPECT_EQ(a->output_rect.ToString(), b->output_rect.ToString()); |
55 EXPECT_EQ(a->damage_rect.ToString(), b->damage_rect.ToString()); | 55 EXPECT_EQ(a->damage_rect.ToString(), b->damage_rect.ToString()); |
56 EXPECT_EQ(a->transform_to_root_target, b->transform_to_root_target); | 56 EXPECT_EQ(a->transform_to_root_target, b->transform_to_root_target); |
| 57 EXPECT_EQ(a->filters.size(), b->filters.size()); |
| 58 for (size_t i = 0; i < a->filters.size(); ++i) { |
| 59 if (a->filters.at(i).type() != cc::FilterOperation::REFERENCE) { |
| 60 EXPECT_EQ(a->filters.at(i), b->filters.at(i)); |
| 61 } else { |
| 62 EXPECT_EQ(b->filters.at(i).type(), cc::FilterOperation::REFERENCE); |
| 63 EXPECT_EQ(a->filters.at(i).image_filter()->countInputs(), |
| 64 b->filters.at(i).image_filter()->countInputs()); |
| 65 } |
| 66 } |
| 67 EXPECT_EQ(a->background_filters.size(), b->background_filters.size()); |
| 68 for (size_t i = 0; i < a->background_filters.size(); ++i) { |
| 69 if (a->background_filters.at(i).type() != |
| 70 cc::FilterOperation::REFERENCE) { |
| 71 EXPECT_EQ(a->background_filters.at(i), b->background_filters.at(i)); |
| 72 } else { |
| 73 EXPECT_EQ(b->background_filters.at(i).type(), |
| 74 cc::FilterOperation::REFERENCE); |
| 75 EXPECT_EQ(a->background_filters.at(i).image_filter()->countInputs(), |
| 76 b->background_filters.at(i).image_filter()->countInputs()); |
| 77 } |
| 78 } |
57 EXPECT_EQ(a->has_transparent_background, b->has_transparent_background); | 79 EXPECT_EQ(a->has_transparent_background, b->has_transparent_background); |
58 } | 80 } |
59 | 81 |
60 void Compare(const SharedQuadState* a, const SharedQuadState* b) { | 82 void Compare(const SharedQuadState* a, const SharedQuadState* b) { |
61 EXPECT_EQ(a->quad_to_target_transform, b->quad_to_target_transform); | 83 EXPECT_EQ(a->quad_to_target_transform, b->quad_to_target_transform); |
62 EXPECT_EQ(a->quad_layer_bounds, b->quad_layer_bounds); | 84 EXPECT_EQ(a->quad_layer_bounds, b->quad_layer_bounds); |
63 EXPECT_EQ(a->visible_quad_layer_rect, b->visible_quad_layer_rect); | 85 EXPECT_EQ(a->visible_quad_layer_rect, b->visible_quad_layer_rect); |
64 EXPECT_EQ(a->clip_rect, b->clip_rect); | 86 EXPECT_EQ(a->clip_rect, b->clip_rect); |
65 EXPECT_EQ(a->is_clipped, b->is_clipped); | 87 EXPECT_EQ(a->is_clipped, b->is_clipped); |
66 EXPECT_EQ(a->opacity, b->opacity); | 88 EXPECT_EQ(a->opacity, b->opacity); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 void Compare(const DebugBorderDrawQuad* a, const DebugBorderDrawQuad* b) { | 144 void Compare(const DebugBorderDrawQuad* a, const DebugBorderDrawQuad* b) { |
123 EXPECT_EQ(a->color, b->color); | 145 EXPECT_EQ(a->color, b->color); |
124 EXPECT_EQ(a->width, b->width); | 146 EXPECT_EQ(a->width, b->width); |
125 } | 147 } |
126 | 148 |
127 void Compare(const RenderPassDrawQuad* a, const RenderPassDrawQuad* b) { | 149 void Compare(const RenderPassDrawQuad* a, const RenderPassDrawQuad* b) { |
128 EXPECT_EQ(a->render_pass_id, b->render_pass_id); | 150 EXPECT_EQ(a->render_pass_id, b->render_pass_id); |
129 EXPECT_EQ(a->mask_resource_id(), b->mask_resource_id()); | 151 EXPECT_EQ(a->mask_resource_id(), b->mask_resource_id()); |
130 EXPECT_EQ(a->mask_uv_scale.ToString(), b->mask_uv_scale.ToString()); | 152 EXPECT_EQ(a->mask_uv_scale.ToString(), b->mask_uv_scale.ToString()); |
131 EXPECT_EQ(a->mask_texture_size.ToString(), b->mask_texture_size.ToString()); | 153 EXPECT_EQ(a->mask_texture_size.ToString(), b->mask_texture_size.ToString()); |
132 EXPECT_EQ(a->filters.size(), b->filters.size()); | |
133 for (size_t i = 0; i < a->filters.size(); ++i) { | |
134 if (a->filters.at(i).type() != cc::FilterOperation::REFERENCE) { | |
135 EXPECT_EQ(a->filters.at(i), b->filters.at(i)); | |
136 } else { | |
137 EXPECT_EQ(b->filters.at(i).type(), cc::FilterOperation::REFERENCE); | |
138 EXPECT_EQ(a->filters.at(i).image_filter()->countInputs(), | |
139 b->filters.at(i).image_filter()->countInputs()); | |
140 } | |
141 } | |
142 EXPECT_EQ(a->filters_scale, b->filters_scale); | 154 EXPECT_EQ(a->filters_scale, b->filters_scale); |
143 EXPECT_EQ(a->filters_origin, b->filters_origin); | 155 EXPECT_EQ(a->filters_origin, b->filters_origin); |
144 EXPECT_EQ(a->background_filters, b->background_filters); | |
145 } | 156 } |
146 | 157 |
147 void Compare(const SolidColorDrawQuad* a, const SolidColorDrawQuad* b) { | 158 void Compare(const SolidColorDrawQuad* a, const SolidColorDrawQuad* b) { |
148 EXPECT_EQ(a->color, b->color); | 159 EXPECT_EQ(a->color, b->color); |
149 EXPECT_EQ(a->force_anti_aliasing_off, b->force_anti_aliasing_off); | 160 EXPECT_EQ(a->force_anti_aliasing_off, b->force_anti_aliasing_off); |
150 } | 161 } |
151 | 162 |
152 void Compare(const StreamVideoDrawQuad* a, const StreamVideoDrawQuad* b) { | 163 void Compare(const StreamVideoDrawQuad* a, const StreamVideoDrawQuad* b) { |
153 EXPECT_EQ(a->resource_id(), b->resource_id()); | 164 EXPECT_EQ(a->resource_id(), b->resource_id()); |
154 EXPECT_EQ(a->resource_size_in_pixels(), b->resource_size_in_pixels()); | 165 EXPECT_EQ(a->resource_size_in_pixels(), b->resource_size_in_pixels()); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 FilterOperation::CreateGrayscaleFilter(arbitrary_float1)); | 287 FilterOperation::CreateGrayscaleFilter(arbitrary_float1)); |
277 arbitrary_filters1.Append(cc::FilterOperation::CreateReferenceFilter( | 288 arbitrary_filters1.Append(cc::FilterOperation::CreateReferenceFilter( |
278 SkBlurImageFilter::Make(arbitrary_sigma, arbitrary_sigma, nullptr))); | 289 SkBlurImageFilter::Make(arbitrary_sigma, arbitrary_sigma, nullptr))); |
279 | 290 |
280 FilterOperations arbitrary_filters2; | 291 FilterOperations arbitrary_filters2; |
281 arbitrary_filters2.Append( | 292 arbitrary_filters2.Append( |
282 FilterOperation::CreateBrightnessFilter(arbitrary_float2)); | 293 FilterOperation::CreateBrightnessFilter(arbitrary_float2)); |
283 | 294 |
284 std::unique_ptr<RenderPass> child_pass_in = RenderPass::Create(); | 295 std::unique_ptr<RenderPass> child_pass_in = RenderPass::Create(); |
285 child_pass_in->SetAll(child_id, arbitrary_rect2, arbitrary_rect3, | 296 child_pass_in->SetAll(child_id, arbitrary_rect2, arbitrary_rect3, |
286 arbitrary_matrix2, arbitrary_bool2); | 297 arbitrary_matrix2, arbitrary_filters1, |
| 298 arbitrary_filters2, arbitrary_bool2); |
287 | 299 |
288 std::unique_ptr<RenderPass> child_pass_cmp = RenderPass::Create(); | 300 std::unique_ptr<RenderPass> child_pass_cmp = RenderPass::Create(); |
289 child_pass_cmp->SetAll(child_id, arbitrary_rect2, arbitrary_rect3, | 301 child_pass_cmp->SetAll(child_id, arbitrary_rect2, arbitrary_rect3, |
290 arbitrary_matrix2, arbitrary_bool2); | 302 arbitrary_matrix2, arbitrary_filters1, |
| 303 arbitrary_filters2, arbitrary_bool2); |
291 | 304 |
292 std::unique_ptr<RenderPass> pass_in = RenderPass::Create(); | 305 std::unique_ptr<RenderPass> pass_in = RenderPass::Create(); |
293 pass_in->SetAll(root_id, arbitrary_rect1, arbitrary_rect2, arbitrary_matrix1, | 306 pass_in->SetAll(root_id, arbitrary_rect1, arbitrary_rect2, arbitrary_matrix1, |
294 arbitrary_bool1); | 307 arbitrary_filters2, arbitrary_filters1, arbitrary_bool1); |
295 | 308 |
296 SharedQuadState* shared_state1_in = pass_in->CreateAndAppendSharedQuadState(); | 309 SharedQuadState* shared_state1_in = pass_in->CreateAndAppendSharedQuadState(); |
297 shared_state1_in->SetAll(arbitrary_matrix1, arbitrary_size1, arbitrary_rect1, | 310 shared_state1_in->SetAll(arbitrary_matrix1, arbitrary_size1, arbitrary_rect1, |
298 arbitrary_rect2, arbitrary_bool1, arbitrary_float1, | 311 arbitrary_rect2, arbitrary_bool1, arbitrary_float1, |
299 arbitrary_blend_mode1, arbitrary_context_id1); | 312 arbitrary_blend_mode1, arbitrary_context_id1); |
300 | 313 |
301 std::unique_ptr<RenderPass> pass_cmp = RenderPass::Create(); | 314 std::unique_ptr<RenderPass> pass_cmp = RenderPass::Create(); |
302 pass_cmp->SetAll(root_id, arbitrary_rect1, arbitrary_rect2, arbitrary_matrix1, | 315 pass_cmp->SetAll(root_id, arbitrary_rect1, arbitrary_rect2, arbitrary_matrix1, |
303 arbitrary_bool1); | 316 arbitrary_filters2, arbitrary_filters1, arbitrary_bool1); |
304 | 317 |
305 SharedQuadState* shared_state1_cmp = | 318 SharedQuadState* shared_state1_cmp = |
306 pass_cmp->CreateAndAppendSharedQuadState(); | 319 pass_cmp->CreateAndAppendSharedQuadState(); |
307 *shared_state1_cmp = *shared_state1_in; | 320 *shared_state1_cmp = *shared_state1_in; |
308 | 321 |
309 DebugBorderDrawQuad* debugborder_in = | 322 DebugBorderDrawQuad* debugborder_in = |
310 pass_in->CreateAndAppendDrawQuad<DebugBorderDrawQuad>(); | 323 pass_in->CreateAndAppendDrawQuad<DebugBorderDrawQuad>(); |
311 debugborder_in->SetAll(shared_state1_in, arbitrary_rect3, | 324 debugborder_in->SetAll(shared_state1_in, arbitrary_rect3, |
312 arbitrary_rect1_inside_rect3, | 325 arbitrary_rect1_inside_rect3, |
313 arbitrary_rect2_inside_rect3, arbitrary_bool1, | 326 arbitrary_rect2_inside_rect3, arbitrary_bool1, |
314 arbitrary_color, arbitrary_int); | 327 arbitrary_color, arbitrary_int); |
315 pass_cmp->CopyFromAndAppendDrawQuad(debugborder_in, | 328 pass_cmp->CopyFromAndAppendDrawQuad(debugborder_in, |
316 debugborder_in->shared_quad_state); | 329 debugborder_in->shared_quad_state); |
317 | 330 |
318 SharedQuadState* shared_state2_in = pass_in->CreateAndAppendSharedQuadState(); | 331 SharedQuadState* shared_state2_in = pass_in->CreateAndAppendSharedQuadState(); |
319 shared_state2_in->SetAll(arbitrary_matrix2, arbitrary_size2, arbitrary_rect2, | 332 shared_state2_in->SetAll(arbitrary_matrix2, arbitrary_size2, arbitrary_rect2, |
320 arbitrary_rect3, arbitrary_bool1, arbitrary_float2, | 333 arbitrary_rect3, arbitrary_bool1, arbitrary_float2, |
321 arbitrary_blend_mode2, arbitrary_context_id2); | 334 arbitrary_blend_mode2, arbitrary_context_id2); |
322 SharedQuadState* shared_state2_cmp = | 335 SharedQuadState* shared_state2_cmp = |
323 pass_cmp->CreateAndAppendSharedQuadState(); | 336 pass_cmp->CreateAndAppendSharedQuadState(); |
324 *shared_state2_cmp = *shared_state2_in; | 337 *shared_state2_cmp = *shared_state2_in; |
325 | 338 |
326 RenderPassDrawQuad* renderpass_in = | 339 RenderPassDrawQuad* renderpass_in = |
327 pass_in->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); | 340 pass_in->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); |
328 renderpass_in->SetAll( | 341 renderpass_in->SetAll( |
329 shared_state2_in, arbitrary_rect1, arbitrary_rect2_inside_rect1, | 342 shared_state2_in, arbitrary_rect1, arbitrary_rect2_inside_rect1, |
330 arbitrary_rect1_inside_rect1, arbitrary_bool1, child_id, | 343 arbitrary_rect1_inside_rect1, arbitrary_bool1, child_id, |
331 arbitrary_resourceid2, arbitrary_vector2df1, arbitrary_size1, | 344 arbitrary_resourceid2, arbitrary_vector2df1, arbitrary_size1, |
332 arbitrary_filters1, arbitrary_vector2df2, arbitrary_pointf2, | 345 arbitrary_vector2df2, arbitrary_pointf2); |
333 arbitrary_filters2); | |
334 pass_cmp->CopyFromAndAppendRenderPassDrawQuad( | 346 pass_cmp->CopyFromAndAppendRenderPassDrawQuad( |
335 renderpass_in, renderpass_in->shared_quad_state, | 347 renderpass_in, renderpass_in->shared_quad_state, |
336 renderpass_in->render_pass_id); | 348 renderpass_in->render_pass_id); |
337 | 349 |
338 SharedQuadState* shared_state3_in = pass_in->CreateAndAppendSharedQuadState(); | 350 SharedQuadState* shared_state3_in = pass_in->CreateAndAppendSharedQuadState(); |
339 shared_state3_in->SetAll(arbitrary_matrix1, arbitrary_size3, arbitrary_rect3, | 351 shared_state3_in->SetAll(arbitrary_matrix1, arbitrary_size3, arbitrary_rect3, |
340 arbitrary_rect1, arbitrary_bool1, arbitrary_float3, | 352 arbitrary_rect1, arbitrary_bool1, arbitrary_float3, |
341 arbitrary_blend_mode3, arbitrary_context_id3); | 353 arbitrary_blend_mode3, arbitrary_context_id3); |
342 SharedQuadState* shared_state3_cmp = | 354 SharedQuadState* shared_state3_cmp = |
343 pass_cmp->CreateAndAppendSharedQuadState(); | 355 pass_cmp->CreateAndAppendSharedQuadState(); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 bool same_shared_quad_state_out = | 483 bool same_shared_quad_state_out = |
472 pass_out->quad_list.ElementAt(i)->shared_quad_state == | 484 pass_out->quad_list.ElementAt(i)->shared_quad_state == |
473 pass_out->quad_list.ElementAt(i - 1)->shared_quad_state; | 485 pass_out->quad_list.ElementAt(i - 1)->shared_quad_state; |
474 EXPECT_EQ(same_shared_quad_state_cmp, same_shared_quad_state_out); | 486 EXPECT_EQ(same_shared_quad_state_cmp, same_shared_quad_state_out); |
475 } | 487 } |
476 } | 488 } |
477 | 489 |
478 TEST_F(CCParamTraitsTest, UnusedSharedQuadStates) { | 490 TEST_F(CCParamTraitsTest, UnusedSharedQuadStates) { |
479 std::unique_ptr<RenderPass> pass_in = RenderPass::Create(); | 491 std::unique_ptr<RenderPass> pass_in = RenderPass::Create(); |
480 pass_in->SetAll(RenderPassId(1, 1), gfx::Rect(100, 100), gfx::Rect(), | 492 pass_in->SetAll(RenderPassId(1, 1), gfx::Rect(100, 100), gfx::Rect(), |
481 gfx::Transform(), false); | 493 gfx::Transform(), FilterOperations(), FilterOperations(), |
| 494 false); |
482 | 495 |
483 // The first SharedQuadState is used. | 496 // The first SharedQuadState is used. |
484 SharedQuadState* shared_state1_in = pass_in->CreateAndAppendSharedQuadState(); | 497 SharedQuadState* shared_state1_in = pass_in->CreateAndAppendSharedQuadState(); |
485 shared_state1_in->SetAll(gfx::Transform(), gfx::Size(1, 1), gfx::Rect(), | 498 shared_state1_in->SetAll(gfx::Transform(), gfx::Size(1, 1), gfx::Rect(), |
486 gfx::Rect(), false, 1.f, SkBlendMode::kSrcOver, 0); | 499 gfx::Rect(), false, 1.f, SkBlendMode::kSrcOver, 0); |
487 | 500 |
488 SolidColorDrawQuad* quad1 = | 501 SolidColorDrawQuad* quad1 = |
489 pass_in->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 502 pass_in->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
490 quad1->SetAll(shared_state1_in, gfx::Rect(10, 10), gfx::Rect(10, 10), | 503 quad1->SetAll(shared_state1_in, gfx::Rect(10, 10), gfx::Rect(10, 10), |
491 gfx::Rect(10, 10), false, SK_ColorRED, false); | 504 gfx::Rect(10, 10), false, SK_ColorRED, false); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 base::PickleIterator iter(msg); | 610 base::PickleIterator iter(msg); |
598 EXPECT_TRUE(IPC::ParamTraits<CompositorFrame>::Read(&msg, &iter, &frame_out)); | 611 EXPECT_TRUE(IPC::ParamTraits<CompositorFrame>::Read(&msg, &iter, &frame_out)); |
599 | 612 |
600 ASSERT_EQ(2u, frame_out.resource_list.size()); | 613 ASSERT_EQ(2u, frame_out.resource_list.size()); |
601 Compare(arbitrary_resource1, frame_out.resource_list[0]); | 614 Compare(arbitrary_resource1, frame_out.resource_list[0]); |
602 Compare(arbitrary_resource2, frame_out.resource_list[1]); | 615 Compare(arbitrary_resource2, frame_out.resource_list[1]); |
603 } | 616 } |
604 | 617 |
605 } // namespace | 618 } // namespace |
606 } // namespace content | 619 } // namespace content |
OLD | NEW |