| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "cc/quads/render_pass.h" | 5 #include "cc/quads/render_pass.h" |
| 6 | 6 |
| 7 #include "cc/base/math_util.h" | 7 #include "cc/base/math_util.h" |
| 8 #include "cc/output/copy_output_request.h" | 8 #include "cc/output/copy_output_request.h" |
| 9 #include "cc/quads/render_pass_draw_quad.h" | 9 #include "cc/quads/render_pass_draw_quad.h" |
| 10 #include "cc/quads/solid_color_draw_quad.h" | 10 #include "cc/quads/solid_color_draw_quad.h" |
| 11 #include "cc/test/geometry_test_utils.h" | 11 #include "cc/test/geometry_test_utils.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include "third_party/skia/include/effects/SkBlurImageFilter.h" | 13 #include "third_party/skia/include/effects/SkBlurImageFilter.h" |
| 14 #include "ui/gfx/transform.h" | 14 #include "ui/gfx/transform.h" |
| 15 | 15 |
| 16 namespace cc { | 16 namespace cc { |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 struct RenderPassSize { | 19 struct RenderPassSize { |
| 20 // If you add a new field to this class, make sure to add it to the | 20 // If you add a new field to this class, make sure to add it to the |
| 21 // Copy() tests. | 21 // Copy() tests. |
| 22 RenderPassId id; | 22 RenderPassId id; |
| 23 QuadList quad_list; | 23 QuadList quad_list; |
| 24 SharedQuadStateList shared_quad_state_list; | 24 SharedQuadStateList shared_quad_state_list; |
| 25 gfx::Transform transform_to_root_target; | 25 gfx::Transform transform_to_root_target; |
| 26 gfx::Rect output_rect; | 26 gfx::Rect output_rect; |
| 27 gfx::Rect damage_rect; | 27 gfx::Rect damage_rect; |
| 28 bool has_transparent_background; | 28 bool has_transparent_background; |
| 29 std::vector<SurfaceId> referenced_surfaces; |
| 29 std::vector<scoped_ptr<CopyOutputRequest>> copy_callbacks; | 30 std::vector<scoped_ptr<CopyOutputRequest>> copy_callbacks; |
| 30 }; | 31 }; |
| 31 | 32 |
| 32 static void CompareRenderPassLists(const RenderPassList& expected_list, | 33 static void CompareRenderPassLists(const RenderPassList& expected_list, |
| 33 const RenderPassList& actual_list) { | 34 const RenderPassList& actual_list) { |
| 34 EXPECT_EQ(expected_list.size(), actual_list.size()); | 35 EXPECT_EQ(expected_list.size(), actual_list.size()); |
| 35 for (size_t i = 0; i < actual_list.size(); ++i) { | 36 for (size_t i = 0; i < actual_list.size(); ++i) { |
| 36 RenderPass* expected = expected_list[i].get(); | 37 RenderPass* expected = expected_list[i].get(); |
| 37 RenderPass* actual = actual_list[i].get(); | 38 RenderPass* actual = actual_list[i].get(); |
| 38 | 39 |
| 39 EXPECT_EQ(expected->id, actual->id); | 40 EXPECT_EQ(expected->id, actual->id); |
| 40 EXPECT_EQ(expected->output_rect, actual->output_rect); | 41 EXPECT_EQ(expected->output_rect, actual->output_rect); |
| 41 EXPECT_EQ(expected->transform_to_root_target, | 42 EXPECT_EQ(expected->transform_to_root_target, |
| 42 actual->transform_to_root_target); | 43 actual->transform_to_root_target); |
| 43 EXPECT_EQ(expected->damage_rect, actual->damage_rect); | 44 EXPECT_EQ(expected->damage_rect, actual->damage_rect); |
| 44 EXPECT_EQ(expected->has_transparent_background, | 45 EXPECT_EQ(expected->has_transparent_background, |
| 45 actual->has_transparent_background); | 46 actual->has_transparent_background); |
| 46 | 47 |
| 47 EXPECT_EQ(expected->shared_quad_state_list.size(), | 48 EXPECT_EQ(expected->shared_quad_state_list.size(), |
| 48 actual->shared_quad_state_list.size()); | 49 actual->shared_quad_state_list.size()); |
| 49 EXPECT_EQ(expected->quad_list.size(), actual->quad_list.size()); | 50 EXPECT_EQ(expected->quad_list.size(), actual->quad_list.size()); |
| 51 EXPECT_EQ(expected->referenced_surfaces, actual->referenced_surfaces); |
| 50 | 52 |
| 51 for (auto exp_iter = expected->quad_list.cbegin(), | 53 for (auto exp_iter = expected->quad_list.cbegin(), |
| 52 act_iter = actual->quad_list.cbegin(); | 54 act_iter = actual->quad_list.cbegin(); |
| 53 exp_iter != expected->quad_list.cend(); | 55 exp_iter != expected->quad_list.cend(); |
| 54 ++exp_iter, ++act_iter) { | 56 ++exp_iter, ++act_iter) { |
| 55 EXPECT_EQ(exp_iter->rect.ToString(), act_iter->rect.ToString()); | 57 EXPECT_EQ(exp_iter->rect.ToString(), act_iter->rect.ToString()); |
| 56 EXPECT_EQ(exp_iter->shared_quad_state->quad_layer_bounds.ToString(), | 58 EXPECT_EQ(exp_iter->shared_quad_state->quad_layer_bounds.ToString(), |
| 57 act_iter->shared_quad_state->quad_layer_bounds.ToString()); | 59 act_iter->shared_quad_state->quad_layer_bounds.ToString()); |
| 58 } | 60 } |
| 59 } | 61 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 | 95 |
| 94 RenderPassId new_id(63, 4); | 96 RenderPassId new_id(63, 4); |
| 95 | 97 |
| 96 scoped_ptr<RenderPass> copy = pass->Copy(new_id); | 98 scoped_ptr<RenderPass> copy = pass->Copy(new_id); |
| 97 EXPECT_EQ(new_id, copy->id); | 99 EXPECT_EQ(new_id, copy->id); |
| 98 EXPECT_EQ(pass->output_rect, copy->output_rect); | 100 EXPECT_EQ(pass->output_rect, copy->output_rect); |
| 99 EXPECT_EQ(pass->transform_to_root_target, copy->transform_to_root_target); | 101 EXPECT_EQ(pass->transform_to_root_target, copy->transform_to_root_target); |
| 100 EXPECT_EQ(pass->damage_rect, copy->damage_rect); | 102 EXPECT_EQ(pass->damage_rect, copy->damage_rect); |
| 101 EXPECT_EQ(pass->has_transparent_background, copy->has_transparent_background); | 103 EXPECT_EQ(pass->has_transparent_background, copy->has_transparent_background); |
| 102 EXPECT_EQ(0u, copy->quad_list.size()); | 104 EXPECT_EQ(0u, copy->quad_list.size()); |
| 105 EXPECT_EQ(0u, copy->referenced_surfaces.size()); |
| 103 | 106 |
| 104 // The copy request should not be copied/duplicated. | 107 // The copy request should not be copied/duplicated. |
| 105 EXPECT_EQ(1u, pass->copy_requests.size()); | 108 EXPECT_EQ(1u, pass->copy_requests.size()); |
| 106 EXPECT_EQ(0u, copy->copy_requests.size()); | 109 EXPECT_EQ(0u, copy->copy_requests.size()); |
| 107 | 110 |
| 108 EXPECT_EQ(sizeof(RenderPassSize), sizeof(RenderPass)); | 111 EXPECT_EQ(sizeof(RenderPassSize), sizeof(RenderPass)); |
| 109 } | 112 } |
| 110 | 113 |
| 111 TEST(RenderPassTest, CopyAllShouldBeIdentical) { | 114 TEST(RenderPassTest, CopyAllShouldBeIdentical) { |
| 112 RenderPassList pass_list; | 115 RenderPassList pass_list; |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 | 307 |
| 305 // Make a copy with CopyAll(). | 308 // Make a copy with CopyAll(). |
| 306 RenderPassList copy_list; | 309 RenderPassList copy_list; |
| 307 RenderPass::CopyAll(pass_list, ©_list); | 310 RenderPass::CopyAll(pass_list, ©_list); |
| 308 | 311 |
| 309 CompareRenderPassLists(pass_list, copy_list); | 312 CompareRenderPassLists(pass_list, copy_list); |
| 310 } | 313 } |
| 311 | 314 |
| 312 } // namespace | 315 } // namespace |
| 313 } // namespace cc | 316 } // namespace cc |
| OLD | NEW |