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/checkerboard_draw_quad.h" | 10 #include "cc/quads/checkerboard_draw_quad.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 // If you add a new field to this class, make sure to add it to the | 24 // If you add a new field to this class, make sure to add it to the |
25 // Copy() tests. | 25 // Copy() tests. |
26 RenderPass::Id id; | 26 RenderPass::Id id; |
27 QuadList quad_list; | 27 QuadList quad_list; |
28 SharedQuadStateList shared_quad_state_list; | 28 SharedQuadStateList shared_quad_state_list; |
29 gfx::Transform transform_to_root_target; | 29 gfx::Transform transform_to_root_target; |
30 gfx::Rect output_rect; | 30 gfx::Rect output_rect; |
31 gfx::RectF damage_rect; | 31 gfx::RectF damage_rect; |
32 bool has_transparent_background; | 32 bool has_transparent_background; |
33 ScopedPtrVector<CopyOutputRequest> copy_callbacks; | 33 ScopedPtrVector<CopyOutputRequest> copy_callbacks; |
| 34 RenderPass::OverlayState overlay_state; |
34 }; | 35 }; |
35 | 36 |
36 static void CompareRenderPassLists(const RenderPassList& expected_list, | 37 static void CompareRenderPassLists(const RenderPassList& expected_list, |
37 const RenderPassList& actual_list) { | 38 const RenderPassList& actual_list) { |
38 EXPECT_EQ(expected_list.size(), actual_list.size()); | 39 EXPECT_EQ(expected_list.size(), actual_list.size()); |
39 for (size_t i = 0; i < actual_list.size(); ++i) { | 40 for (size_t i = 0; i < actual_list.size(); ++i) { |
40 RenderPass* expected = expected_list[i]; | 41 RenderPass* expected = expected_list[i]; |
41 RenderPass* actual = actual_list[i]; | 42 RenderPass* actual = actual_list[i]; |
42 | 43 |
43 EXPECT_EQ(expected->id, actual->id); | 44 EXPECT_EQ(expected->id, actual->id); |
44 EXPECT_RECT_EQ(expected->output_rect, actual->output_rect); | 45 EXPECT_RECT_EQ(expected->output_rect, actual->output_rect); |
45 EXPECT_EQ(expected->transform_to_root_target, | 46 EXPECT_EQ(expected->transform_to_root_target, |
46 actual->transform_to_root_target); | 47 actual->transform_to_root_target); |
47 EXPECT_RECT_EQ(expected->damage_rect, actual->damage_rect); | 48 EXPECT_RECT_EQ(expected->damage_rect, actual->damage_rect); |
48 EXPECT_EQ(expected->has_transparent_background, | 49 EXPECT_EQ(expected->has_transparent_background, |
49 actual->has_transparent_background); | 50 actual->has_transparent_background); |
| 51 EXPECT_EQ(expected->overlay_state, actual->overlay_state); |
50 | 52 |
51 EXPECT_EQ(expected->shared_quad_state_list.size(), | 53 EXPECT_EQ(expected->shared_quad_state_list.size(), |
52 actual->shared_quad_state_list.size()); | 54 actual->shared_quad_state_list.size()); |
53 EXPECT_EQ(expected->quad_list.size(), actual->quad_list.size()); | 55 EXPECT_EQ(expected->quad_list.size(), actual->quad_list.size()); |
54 | 56 |
55 for (size_t i = 0; i < expected->quad_list.size(); ++i) { | 57 for (size_t i = 0; i < expected->quad_list.size(); ++i) { |
56 EXPECT_EQ(expected->quad_list[i]->rect.ToString(), | 58 EXPECT_EQ(expected->quad_list[i]->rect.ToString(), |
57 actual->quad_list[i]->rect.ToString()); | 59 actual->quad_list[i]->rect.ToString()); |
58 EXPECT_EQ( | 60 EXPECT_EQ( |
59 expected->quad_list[i]->shared_quad_state->content_bounds.ToString(), | 61 expected->quad_list[i]->shared_quad_state->content_bounds.ToString(), |
60 actual->quad_list[i]->shared_quad_state->content_bounds.ToString()); | 62 actual->quad_list[i]->shared_quad_state->content_bounds.ToString()); |
61 } | 63 } |
62 } | 64 } |
63 } | 65 } |
64 | 66 |
65 TEST(RenderPassTest, CopyShouldBeIdenticalExceptIdAndQuads) { | 67 TEST(RenderPassTest, CopyShouldBeIdenticalExceptIdAndQuads) { |
66 RenderPass::Id id(3, 2); | 68 RenderPass::Id id(3, 2); |
67 gfx::Rect output_rect(45, 22, 120, 13); | 69 gfx::Rect output_rect(45, 22, 120, 13); |
68 gfx::Transform transform_to_root = | 70 gfx::Transform transform_to_root = |
69 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0); | 71 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0); |
70 gfx::Rect damage_rect(56, 123, 19, 43); | 72 gfx::Rect damage_rect(56, 123, 19, 43); |
71 bool has_transparent_background = true; | 73 bool has_transparent_background = true; |
| 74 RenderPass::OverlayState overlay_state = RenderPass::SIMPLE_OVERLAY; |
72 | 75 |
73 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); | 76 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); |
74 pass->SetAll(id, | 77 pass->SetAll(id, |
75 output_rect, | 78 output_rect, |
76 damage_rect, | 79 damage_rect, |
77 transform_to_root, | 80 transform_to_root, |
78 has_transparent_background); | 81 has_transparent_background, |
| 82 overlay_state); |
79 pass->copy_requests.push_back(CopyOutputRequest::CreateEmptyRequest()); | 83 pass->copy_requests.push_back(CopyOutputRequest::CreateEmptyRequest()); |
80 | 84 |
81 // Stick a quad in the pass, this should not get copied. | 85 // Stick a quad in the pass, this should not get copied. |
82 scoped_ptr<SharedQuadState> shared_state = SharedQuadState::Create(); | 86 scoped_ptr<SharedQuadState> shared_state = SharedQuadState::Create(); |
83 shared_state->SetAll(gfx::Transform(), | 87 shared_state->SetAll(gfx::Transform(), |
84 gfx::Size(), | 88 gfx::Size(), |
85 gfx::Rect(), | 89 gfx::Rect(), |
86 gfx::Rect(), | 90 gfx::Rect(), |
87 false, | 91 false, |
88 1, | 92 1, |
89 SkXfermode::kSrcOver_Mode); | 93 SkXfermode::kSrcOver_Mode); |
90 pass->AppendSharedQuadState(shared_state.Pass()); | 94 pass->AppendSharedQuadState(shared_state.Pass()); |
91 | 95 |
92 scoped_ptr<CheckerboardDrawQuad> checkerboard_quad = | 96 scoped_ptr<CheckerboardDrawQuad> checkerboard_quad = |
93 CheckerboardDrawQuad::Create(); | 97 CheckerboardDrawQuad::Create(); |
94 checkerboard_quad->SetNew( | 98 checkerboard_quad->SetNew( |
95 pass->shared_quad_state_list.back(), gfx::Rect(), gfx::Rect(), SkColor()); | 99 pass->shared_quad_state_list.back(), gfx::Rect(), gfx::Rect(), SkColor()); |
96 pass->quad_list.push_back(checkerboard_quad.PassAs<DrawQuad>()); | 100 pass->quad_list.push_back(checkerboard_quad.PassAs<DrawQuad>()); |
97 | 101 |
98 RenderPass::Id new_id(63, 4); | 102 RenderPass::Id new_id(63, 4); |
99 | 103 |
100 scoped_ptr<RenderPass> copy = pass->Copy(new_id); | 104 scoped_ptr<RenderPass> copy = pass->Copy(new_id); |
101 EXPECT_EQ(new_id, copy->id); | 105 EXPECT_EQ(new_id, copy->id); |
102 EXPECT_RECT_EQ(pass->output_rect, copy->output_rect); | 106 EXPECT_RECT_EQ(pass->output_rect, copy->output_rect); |
103 EXPECT_EQ(pass->transform_to_root_target, copy->transform_to_root_target); | 107 EXPECT_EQ(pass->transform_to_root_target, copy->transform_to_root_target); |
104 EXPECT_RECT_EQ(pass->damage_rect, copy->damage_rect); | 108 EXPECT_RECT_EQ(pass->damage_rect, copy->damage_rect); |
105 EXPECT_EQ(pass->has_transparent_background, copy->has_transparent_background); | 109 EXPECT_EQ(pass->has_transparent_background, copy->has_transparent_background); |
| 110 EXPECT_EQ(pass->overlay_state, copy->overlay_state); |
106 EXPECT_EQ(0u, copy->quad_list.size()); | 111 EXPECT_EQ(0u, copy->quad_list.size()); |
107 | 112 |
108 // The copy request should not be copied/duplicated. | 113 // The copy request should not be copied/duplicated. |
109 EXPECT_EQ(1u, pass->copy_requests.size()); | 114 EXPECT_EQ(1u, pass->copy_requests.size()); |
110 EXPECT_EQ(0u, copy->copy_requests.size()); | 115 EXPECT_EQ(0u, copy->copy_requests.size()); |
111 | 116 |
112 EXPECT_EQ(sizeof(RenderPassSize), sizeof(RenderPass)); | 117 EXPECT_EQ(sizeof(RenderPassSize), sizeof(RenderPass)); |
113 } | 118 } |
114 | 119 |
115 TEST(RenderPassTest, CopyAllShouldBeIdentical) { | 120 TEST(RenderPassTest, CopyAllShouldBeIdentical) { |
116 RenderPassList pass_list; | 121 RenderPassList pass_list; |
117 | 122 |
118 RenderPass::Id id(3, 2); | 123 RenderPass::Id id(3, 2); |
119 gfx::Rect output_rect(45, 22, 120, 13); | 124 gfx::Rect output_rect(45, 22, 120, 13); |
120 gfx::Transform transform_to_root = | 125 gfx::Transform transform_to_root = |
121 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0); | 126 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0); |
122 gfx::Rect damage_rect(56, 123, 19, 43); | 127 gfx::Rect damage_rect(56, 123, 19, 43); |
123 bool has_transparent_background = true; | 128 bool has_transparent_background = true; |
| 129 RenderPass::OverlayState overlay_state = RenderPass::SIMPLE_OVERLAY; |
124 | 130 |
125 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); | 131 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); |
126 pass->SetAll(id, | 132 pass->SetAll(id, |
127 output_rect, | 133 output_rect, |
128 damage_rect, | 134 damage_rect, |
129 transform_to_root, | 135 transform_to_root, |
130 has_transparent_background); | 136 has_transparent_background, |
| 137 overlay_state); |
131 | 138 |
132 // Two quads using one shared state. | 139 // Two quads using one shared state. |
133 scoped_ptr<SharedQuadState> shared_state1 = SharedQuadState::Create(); | 140 scoped_ptr<SharedQuadState> shared_state1 = SharedQuadState::Create(); |
134 shared_state1->SetAll(gfx::Transform(), | 141 shared_state1->SetAll(gfx::Transform(), |
135 gfx::Size(1, 1), | 142 gfx::Size(1, 1), |
136 gfx::Rect(), | 143 gfx::Rect(), |
137 gfx::Rect(), | 144 gfx::Rect(), |
138 false, | 145 false, |
139 1, | 146 1, |
140 SkXfermode::kSrcOver_Mode); | 147 SkXfermode::kSrcOver_Mode); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 SkColor()); | 190 SkColor()); |
184 pass->quad_list.push_back(checkerboard_quad4.PassAs<DrawQuad>()); | 191 pass->quad_list.push_back(checkerboard_quad4.PassAs<DrawQuad>()); |
185 | 192 |
186 // A second render pass with a quad. | 193 // A second render pass with a quad. |
187 RenderPass::Id contrib_id(4, 1); | 194 RenderPass::Id contrib_id(4, 1); |
188 gfx::Rect contrib_output_rect(10, 15, 12, 17); | 195 gfx::Rect contrib_output_rect(10, 15, 12, 17); |
189 gfx::Transform contrib_transform_to_root = | 196 gfx::Transform contrib_transform_to_root = |
190 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0); | 197 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0); |
191 gfx::Rect contrib_damage_rect(11, 16, 10, 15); | 198 gfx::Rect contrib_damage_rect(11, 16, 10, 15); |
192 bool contrib_has_transparent_background = true; | 199 bool contrib_has_transparent_background = true; |
| 200 RenderPass::OverlayState contrib_overlay_state = RenderPass::SIMPLE_OVERLAY; |
193 | 201 |
194 scoped_ptr<TestRenderPass> contrib = TestRenderPass::Create(); | 202 scoped_ptr<TestRenderPass> contrib = TestRenderPass::Create(); |
195 contrib->SetAll(contrib_id, | 203 contrib->SetAll(contrib_id, |
196 contrib_output_rect, | 204 contrib_output_rect, |
197 contrib_damage_rect, | 205 contrib_damage_rect, |
198 contrib_transform_to_root, | 206 contrib_transform_to_root, |
199 contrib_has_transparent_background); | 207 contrib_has_transparent_background, |
| 208 contrib_overlay_state); |
200 | 209 |
201 scoped_ptr<SharedQuadState> contrib_shared_state = SharedQuadState::Create(); | 210 scoped_ptr<SharedQuadState> contrib_shared_state = SharedQuadState::Create(); |
202 contrib_shared_state->SetAll(gfx::Transform(), | 211 contrib_shared_state->SetAll(gfx::Transform(), |
203 gfx::Size(2, 2), | 212 gfx::Size(2, 2), |
204 gfx::Rect(), | 213 gfx::Rect(), |
205 gfx::Rect(), | 214 gfx::Rect(), |
206 false, | 215 false, |
207 1, | 216 1, |
208 SkXfermode::kSrcOver_Mode); | 217 SkXfermode::kSrcOver_Mode); |
209 contrib->AppendSharedQuadState(contrib_shared_state.Pass()); | 218 contrib->AppendSharedQuadState(contrib_shared_state.Pass()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 | 251 |
243 TEST(RenderPassTest, CopyAllWithCulledQuads) { | 252 TEST(RenderPassTest, CopyAllWithCulledQuads) { |
244 RenderPassList pass_list; | 253 RenderPassList pass_list; |
245 | 254 |
246 RenderPass::Id id(3, 2); | 255 RenderPass::Id id(3, 2); |
247 gfx::Rect output_rect(45, 22, 120, 13); | 256 gfx::Rect output_rect(45, 22, 120, 13); |
248 gfx::Transform transform_to_root = | 257 gfx::Transform transform_to_root = |
249 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0); | 258 gfx::Transform(1.0, 0.5, 0.5, -0.5, -1.0, 0.0); |
250 gfx::Rect damage_rect(56, 123, 19, 43); | 259 gfx::Rect damage_rect(56, 123, 19, 43); |
251 bool has_transparent_background = true; | 260 bool has_transparent_background = true; |
| 261 RenderPass::OverlayState overlay_state = RenderPass::SIMPLE_OVERLAY; |
252 | 262 |
253 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); | 263 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); |
254 pass->SetAll(id, | 264 pass->SetAll(id, |
255 output_rect, | 265 output_rect, |
256 damage_rect, | 266 damage_rect, |
257 transform_to_root, | 267 transform_to_root, |
258 has_transparent_background); | 268 has_transparent_background, |
| 269 overlay_state); |
259 | 270 |
260 // A shared state with a quad. | 271 // A shared state with a quad. |
261 scoped_ptr<SharedQuadState> shared_state1 = SharedQuadState::Create(); | 272 scoped_ptr<SharedQuadState> shared_state1 = SharedQuadState::Create(); |
262 shared_state1->SetAll(gfx::Transform(), | 273 shared_state1->SetAll(gfx::Transform(), |
263 gfx::Size(1, 1), | 274 gfx::Size(1, 1), |
264 gfx::Rect(), | 275 gfx::Rect(), |
265 gfx::Rect(), | 276 gfx::Rect(), |
266 false, | 277 false, |
267 1, | 278 1, |
268 SkXfermode::kSrcOver_Mode); | 279 SkXfermode::kSrcOver_Mode); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 | 332 |
322 // Make a copy with CopyAll(). | 333 // Make a copy with CopyAll(). |
323 RenderPassList copy_list; | 334 RenderPassList copy_list; |
324 RenderPass::CopyAll(pass_list, ©_list); | 335 RenderPass::CopyAll(pass_list, ©_list); |
325 | 336 |
326 CompareRenderPassLists(pass_list, copy_list); | 337 CompareRenderPassLists(pass_list, copy_list); |
327 } | 338 } |
328 | 339 |
329 } // namespace | 340 } // namespace |
330 } // namespace cc | 341 } // namespace cc |
OLD | NEW |