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