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; | |
30 std::vector<scoped_ptr<CopyOutputRequest>> copy_callbacks; | 29 std::vector<scoped_ptr<CopyOutputRequest>> copy_callbacks; |
31 }; | 30 }; |
32 | 31 |
33 static void CompareRenderPassLists(const RenderPassList& expected_list, | 32 static void CompareRenderPassLists(const RenderPassList& expected_list, |
34 const RenderPassList& actual_list) { | 33 const RenderPassList& actual_list) { |
35 EXPECT_EQ(expected_list.size(), actual_list.size()); | 34 EXPECT_EQ(expected_list.size(), actual_list.size()); |
36 for (size_t i = 0; i < actual_list.size(); ++i) { | 35 for (size_t i = 0; i < actual_list.size(); ++i) { |
37 RenderPass* expected = expected_list[i].get(); | 36 RenderPass* expected = expected_list[i].get(); |
38 RenderPass* actual = actual_list[i].get(); | 37 RenderPass* actual = actual_list[i].get(); |
39 | 38 |
40 EXPECT_EQ(expected->id, actual->id); | 39 EXPECT_EQ(expected->id, actual->id); |
41 EXPECT_EQ(expected->output_rect, actual->output_rect); | 40 EXPECT_EQ(expected->output_rect, actual->output_rect); |
42 EXPECT_EQ(expected->transform_to_root_target, | 41 EXPECT_EQ(expected->transform_to_root_target, |
43 actual->transform_to_root_target); | 42 actual->transform_to_root_target); |
44 EXPECT_EQ(expected->damage_rect, actual->damage_rect); | 43 EXPECT_EQ(expected->damage_rect, actual->damage_rect); |
45 EXPECT_EQ(expected->has_transparent_background, | 44 EXPECT_EQ(expected->has_transparent_background, |
46 actual->has_transparent_background); | 45 actual->has_transparent_background); |
47 | 46 |
48 EXPECT_EQ(expected->shared_quad_state_list.size(), | 47 EXPECT_EQ(expected->shared_quad_state_list.size(), |
49 actual->shared_quad_state_list.size()); | 48 actual->shared_quad_state_list.size()); |
50 EXPECT_EQ(expected->quad_list.size(), actual->quad_list.size()); | 49 EXPECT_EQ(expected->quad_list.size(), actual->quad_list.size()); |
51 EXPECT_EQ(expected->referenced_surfaces, actual->referenced_surfaces); | |
52 | 50 |
53 for (auto exp_iter = expected->quad_list.cbegin(), | 51 for (auto exp_iter = expected->quad_list.cbegin(), |
54 act_iter = actual->quad_list.cbegin(); | 52 act_iter = actual->quad_list.cbegin(); |
55 exp_iter != expected->quad_list.cend(); | 53 exp_iter != expected->quad_list.cend(); |
56 ++exp_iter, ++act_iter) { | 54 ++exp_iter, ++act_iter) { |
57 EXPECT_EQ(exp_iter->rect.ToString(), act_iter->rect.ToString()); | 55 EXPECT_EQ(exp_iter->rect.ToString(), act_iter->rect.ToString()); |
58 EXPECT_EQ(exp_iter->shared_quad_state->quad_layer_bounds.ToString(), | 56 EXPECT_EQ(exp_iter->shared_quad_state->quad_layer_bounds.ToString(), |
59 act_iter->shared_quad_state->quad_layer_bounds.ToString()); | 57 act_iter->shared_quad_state->quad_layer_bounds.ToString()); |
60 } | 58 } |
61 } | 59 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 | 93 |
96 RenderPassId new_id(63, 4); | 94 RenderPassId new_id(63, 4); |
97 | 95 |
98 scoped_ptr<RenderPass> copy = pass->Copy(new_id); | 96 scoped_ptr<RenderPass> copy = pass->Copy(new_id); |
99 EXPECT_EQ(new_id, copy->id); | 97 EXPECT_EQ(new_id, copy->id); |
100 EXPECT_EQ(pass->output_rect, copy->output_rect); | 98 EXPECT_EQ(pass->output_rect, copy->output_rect); |
101 EXPECT_EQ(pass->transform_to_root_target, copy->transform_to_root_target); | 99 EXPECT_EQ(pass->transform_to_root_target, copy->transform_to_root_target); |
102 EXPECT_EQ(pass->damage_rect, copy->damage_rect); | 100 EXPECT_EQ(pass->damage_rect, copy->damage_rect); |
103 EXPECT_EQ(pass->has_transparent_background, copy->has_transparent_background); | 101 EXPECT_EQ(pass->has_transparent_background, copy->has_transparent_background); |
104 EXPECT_EQ(0u, copy->quad_list.size()); | 102 EXPECT_EQ(0u, copy->quad_list.size()); |
105 EXPECT_EQ(0u, copy->referenced_surfaces.size()); | |
106 | 103 |
107 // The copy request should not be copied/duplicated. | 104 // The copy request should not be copied/duplicated. |
108 EXPECT_EQ(1u, pass->copy_requests.size()); | 105 EXPECT_EQ(1u, pass->copy_requests.size()); |
109 EXPECT_EQ(0u, copy->copy_requests.size()); | 106 EXPECT_EQ(0u, copy->copy_requests.size()); |
110 | 107 |
111 EXPECT_EQ(sizeof(RenderPassSize), sizeof(RenderPass)); | 108 EXPECT_EQ(sizeof(RenderPassSize), sizeof(RenderPass)); |
112 } | 109 } |
113 | 110 |
114 TEST(RenderPassTest, CopyAllShouldBeIdentical) { | 111 TEST(RenderPassTest, CopyAllShouldBeIdentical) { |
115 RenderPassList pass_list; | 112 RenderPassList pass_list; |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 | 304 |
308 // Make a copy with CopyAll(). | 305 // Make a copy with CopyAll(). |
309 RenderPassList copy_list; | 306 RenderPassList copy_list; |
310 RenderPass::CopyAll(pass_list, ©_list); | 307 RenderPass::CopyAll(pass_list, ©_list); |
311 | 308 |
312 CompareRenderPassLists(pass_list, copy_list); | 309 CompareRenderPassLists(pass_list, copy_list); |
313 } | 310 } |
314 | 311 |
315 } // namespace | 312 } // namespace |
316 } // namespace cc | 313 } // namespace cc |
OLD | NEW |