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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 pass->copy_requests.push_back(CopyOutputRequest::CreateEmptyRequest()); | 79 pass->copy_requests.push_back(CopyOutputRequest::CreateEmptyRequest()); |
80 | 80 |
81 // Stick a quad in the pass, this should not get copied. | 81 // Stick a quad in the pass, this should not get copied. |
82 SharedQuadState* shared_state = pass->CreateAndAppendSharedQuadState(); | 82 SharedQuadState* shared_state = pass->CreateAndAppendSharedQuadState(); |
83 shared_state->SetAll(gfx::Transform(), | 83 shared_state->SetAll(gfx::Transform(), |
84 gfx::Size(), | 84 gfx::Size(), |
85 gfx::Rect(), | 85 gfx::Rect(), |
86 gfx::Rect(), | 86 gfx::Rect(), |
87 false, | 87 false, |
88 1, | 88 1, |
89 SkXfermode::kSrcOver_Mode); | 89 SkXfermode::kSrcOver_Mode, |
| 90 0); |
90 | 91 |
91 scoped_ptr<CheckerboardDrawQuad> checkerboard_quad = | 92 scoped_ptr<CheckerboardDrawQuad> checkerboard_quad = |
92 CheckerboardDrawQuad::Create(); | 93 CheckerboardDrawQuad::Create(); |
93 checkerboard_quad->SetNew( | 94 checkerboard_quad->SetNew( |
94 pass->shared_quad_state_list.back(), gfx::Rect(), gfx::Rect(), SkColor()); | 95 pass->shared_quad_state_list.back(), gfx::Rect(), gfx::Rect(), SkColor()); |
95 pass->quad_list.push_back(checkerboard_quad.PassAs<DrawQuad>()); | 96 pass->quad_list.push_back(checkerboard_quad.PassAs<DrawQuad>()); |
96 | 97 |
97 RenderPass::Id new_id(63, 4); | 98 RenderPass::Id new_id(63, 4); |
98 | 99 |
99 scoped_ptr<RenderPass> copy = pass->Copy(new_id); | 100 scoped_ptr<RenderPass> copy = pass->Copy(new_id); |
(...skipping 29 matching lines...) Expand all Loading... |
129 has_transparent_background); | 130 has_transparent_background); |
130 | 131 |
131 // Two quads using one shared state. | 132 // Two quads using one shared state. |
132 SharedQuadState* shared_state1 = pass->CreateAndAppendSharedQuadState(); | 133 SharedQuadState* shared_state1 = pass->CreateAndAppendSharedQuadState(); |
133 shared_state1->SetAll(gfx::Transform(), | 134 shared_state1->SetAll(gfx::Transform(), |
134 gfx::Size(1, 1), | 135 gfx::Size(1, 1), |
135 gfx::Rect(), | 136 gfx::Rect(), |
136 gfx::Rect(), | 137 gfx::Rect(), |
137 false, | 138 false, |
138 1, | 139 1, |
139 SkXfermode::kSrcOver_Mode); | 140 SkXfermode::kSrcOver_Mode, |
| 141 0); |
140 | 142 |
141 scoped_ptr<CheckerboardDrawQuad> checkerboard_quad1 = | 143 scoped_ptr<CheckerboardDrawQuad> checkerboard_quad1 = |
142 CheckerboardDrawQuad::Create(); | 144 CheckerboardDrawQuad::Create(); |
143 checkerboard_quad1->SetNew(pass->shared_quad_state_list.back(), | 145 checkerboard_quad1->SetNew(pass->shared_quad_state_list.back(), |
144 gfx::Rect(1, 1, 1, 1), | 146 gfx::Rect(1, 1, 1, 1), |
145 gfx::Rect(1, 1, 1, 1), | 147 gfx::Rect(1, 1, 1, 1), |
146 SkColor()); | 148 SkColor()); |
147 pass->quad_list.push_back(checkerboard_quad1.PassAs<DrawQuad>()); | 149 pass->quad_list.push_back(checkerboard_quad1.PassAs<DrawQuad>()); |
148 | 150 |
149 scoped_ptr<CheckerboardDrawQuad> checkerboard_quad2 = | 151 scoped_ptr<CheckerboardDrawQuad> checkerboard_quad2 = |
150 CheckerboardDrawQuad::Create(); | 152 CheckerboardDrawQuad::Create(); |
151 checkerboard_quad2->SetNew(pass->shared_quad_state_list.back(), | 153 checkerboard_quad2->SetNew(pass->shared_quad_state_list.back(), |
152 gfx::Rect(2, 2, 2, 2), | 154 gfx::Rect(2, 2, 2, 2), |
153 gfx::Rect(2, 2, 2, 2), | 155 gfx::Rect(2, 2, 2, 2), |
154 SkColor()); | 156 SkColor()); |
155 pass->quad_list.push_back(checkerboard_quad2.PassAs<DrawQuad>()); | 157 pass->quad_list.push_back(checkerboard_quad2.PassAs<DrawQuad>()); |
156 | 158 |
157 // And two quads using another shared state. | 159 // And two quads using another shared state. |
158 SharedQuadState* shared_state2 = pass->CreateAndAppendSharedQuadState(); | 160 SharedQuadState* shared_state2 = pass->CreateAndAppendSharedQuadState(); |
159 shared_state2->SetAll(gfx::Transform(), | 161 shared_state2->SetAll(gfx::Transform(), |
160 gfx::Size(2, 2), | 162 gfx::Size(2, 2), |
161 gfx::Rect(), | 163 gfx::Rect(), |
162 gfx::Rect(), | 164 gfx::Rect(), |
163 false, | 165 false, |
164 1, | 166 1, |
165 SkXfermode::kSrcOver_Mode); | 167 SkXfermode::kSrcOver_Mode, |
| 168 0); |
166 | 169 |
167 scoped_ptr<CheckerboardDrawQuad> checkerboard_quad3 = | 170 scoped_ptr<CheckerboardDrawQuad> checkerboard_quad3 = |
168 CheckerboardDrawQuad::Create(); | 171 CheckerboardDrawQuad::Create(); |
169 checkerboard_quad3->SetNew(pass->shared_quad_state_list.back(), | 172 checkerboard_quad3->SetNew(pass->shared_quad_state_list.back(), |
170 gfx::Rect(3, 3, 3, 3), | 173 gfx::Rect(3, 3, 3, 3), |
171 gfx::Rect(3, 3, 3, 3), | 174 gfx::Rect(3, 3, 3, 3), |
172 SkColor()); | 175 SkColor()); |
173 pass->quad_list.push_back(checkerboard_quad3.PassAs<DrawQuad>()); | 176 pass->quad_list.push_back(checkerboard_quad3.PassAs<DrawQuad>()); |
174 | 177 |
175 scoped_ptr<CheckerboardDrawQuad> checkerboard_quad4 = | 178 scoped_ptr<CheckerboardDrawQuad> checkerboard_quad4 = |
(...skipping 20 matching lines...) Expand all Loading... |
196 contrib_has_transparent_background); | 199 contrib_has_transparent_background); |
197 | 200 |
198 SharedQuadState* contrib_shared_state = | 201 SharedQuadState* contrib_shared_state = |
199 contrib->CreateAndAppendSharedQuadState(); | 202 contrib->CreateAndAppendSharedQuadState(); |
200 contrib_shared_state->SetAll(gfx::Transform(), | 203 contrib_shared_state->SetAll(gfx::Transform(), |
201 gfx::Size(2, 2), | 204 gfx::Size(2, 2), |
202 gfx::Rect(), | 205 gfx::Rect(), |
203 gfx::Rect(), | 206 gfx::Rect(), |
204 false, | 207 false, |
205 1, | 208 1, |
206 SkXfermode::kSrcOver_Mode); | 209 SkXfermode::kSrcOver_Mode, |
| 210 0); |
207 | 211 |
208 scoped_ptr<CheckerboardDrawQuad> contrib_quad = | 212 scoped_ptr<CheckerboardDrawQuad> contrib_quad = |
209 CheckerboardDrawQuad::Create(); | 213 CheckerboardDrawQuad::Create(); |
210 contrib_quad->SetNew(contrib->shared_quad_state_list.back(), | 214 contrib_quad->SetNew(contrib->shared_quad_state_list.back(), |
211 gfx::Rect(3, 3, 3, 3), | 215 gfx::Rect(3, 3, 3, 3), |
212 gfx::Rect(3, 3, 3, 3), | 216 gfx::Rect(3, 3, 3, 3), |
213 SkColor()); | 217 SkColor()); |
214 contrib->quad_list.push_back(contrib_quad.PassAs<DrawQuad>()); | 218 contrib->quad_list.push_back(contrib_quad.PassAs<DrawQuad>()); |
215 | 219 |
216 // And a RenderPassDrawQuad for the contributing pass. | 220 // And a RenderPassDrawQuad for the contributing pass. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 has_transparent_background); | 259 has_transparent_background); |
256 | 260 |
257 // A shared state with a quad. | 261 // A shared state with a quad. |
258 SharedQuadState* shared_state1 = pass->CreateAndAppendSharedQuadState(); | 262 SharedQuadState* shared_state1 = pass->CreateAndAppendSharedQuadState(); |
259 shared_state1->SetAll(gfx::Transform(), | 263 shared_state1->SetAll(gfx::Transform(), |
260 gfx::Size(1, 1), | 264 gfx::Size(1, 1), |
261 gfx::Rect(), | 265 gfx::Rect(), |
262 gfx::Rect(), | 266 gfx::Rect(), |
263 false, | 267 false, |
264 1, | 268 1, |
265 SkXfermode::kSrcOver_Mode); | 269 SkXfermode::kSrcOver_Mode, |
| 270 0); |
266 | 271 |
267 scoped_ptr<CheckerboardDrawQuad> checkerboard_quad1 = | 272 scoped_ptr<CheckerboardDrawQuad> checkerboard_quad1 = |
268 CheckerboardDrawQuad::Create(); | 273 CheckerboardDrawQuad::Create(); |
269 checkerboard_quad1->SetNew(pass->shared_quad_state_list.back(), | 274 checkerboard_quad1->SetNew(pass->shared_quad_state_list.back(), |
270 gfx::Rect(1, 1, 1, 1), | 275 gfx::Rect(1, 1, 1, 1), |
271 gfx::Rect(1, 1, 1, 1), | 276 gfx::Rect(1, 1, 1, 1), |
272 SkColor()); | 277 SkColor()); |
273 pass->quad_list.push_back(checkerboard_quad1.PassAs<DrawQuad>()); | 278 pass->quad_list.push_back(checkerboard_quad1.PassAs<DrawQuad>()); |
274 | 279 |
275 // A shared state with no quads, they were culled. | 280 // A shared state with no quads, they were culled. |
276 SharedQuadState* shared_state2 = pass->CreateAndAppendSharedQuadState(); | 281 SharedQuadState* shared_state2 = pass->CreateAndAppendSharedQuadState(); |
277 shared_state2->SetAll(gfx::Transform(), | 282 shared_state2->SetAll(gfx::Transform(), |
278 gfx::Size(2, 2), | 283 gfx::Size(2, 2), |
279 gfx::Rect(), | 284 gfx::Rect(), |
280 gfx::Rect(), | 285 gfx::Rect(), |
281 false, | 286 false, |
282 1, | 287 1, |
283 SkXfermode::kSrcOver_Mode); | 288 SkXfermode::kSrcOver_Mode, |
| 289 0); |
284 | 290 |
285 // A second shared state with no quads. | 291 // A second shared state with no quads. |
286 SharedQuadState* shared_state3 = pass->CreateAndAppendSharedQuadState(); | 292 SharedQuadState* shared_state3 = pass->CreateAndAppendSharedQuadState(); |
287 shared_state3->SetAll(gfx::Transform(), | 293 shared_state3->SetAll(gfx::Transform(), |
288 gfx::Size(2, 2), | 294 gfx::Size(2, 2), |
289 gfx::Rect(), | 295 gfx::Rect(), |
290 gfx::Rect(), | 296 gfx::Rect(), |
291 false, | 297 false, |
292 1, | 298 1, |
293 SkXfermode::kSrcOver_Mode); | 299 SkXfermode::kSrcOver_Mode, |
| 300 0); |
294 | 301 |
295 // A last shared state with a quad again. | 302 // A last shared state with a quad again. |
296 SharedQuadState* shared_state4 = pass->CreateAndAppendSharedQuadState(); | 303 SharedQuadState* shared_state4 = pass->CreateAndAppendSharedQuadState(); |
297 shared_state4->SetAll(gfx::Transform(), | 304 shared_state4->SetAll(gfx::Transform(), |
298 gfx::Size(2, 2), | 305 gfx::Size(2, 2), |
299 gfx::Rect(), | 306 gfx::Rect(), |
300 gfx::Rect(), | 307 gfx::Rect(), |
301 false, | 308 false, |
302 1, | 309 1, |
303 SkXfermode::kSrcOver_Mode); | 310 SkXfermode::kSrcOver_Mode, |
| 311 0); |
304 | 312 |
305 scoped_ptr<CheckerboardDrawQuad> checkerboard_quad2 = | 313 scoped_ptr<CheckerboardDrawQuad> checkerboard_quad2 = |
306 CheckerboardDrawQuad::Create(); | 314 CheckerboardDrawQuad::Create(); |
307 checkerboard_quad2->SetNew(pass->shared_quad_state_list.back(), | 315 checkerboard_quad2->SetNew(pass->shared_quad_state_list.back(), |
308 gfx::Rect(3, 3, 3, 3), | 316 gfx::Rect(3, 3, 3, 3), |
309 gfx::Rect(3, 3, 3, 3), | 317 gfx::Rect(3, 3, 3, 3), |
310 SkColor()); | 318 SkColor()); |
311 pass->quad_list.push_back(checkerboard_quad2.PassAs<DrawQuad>()); | 319 pass->quad_list.push_back(checkerboard_quad2.PassAs<DrawQuad>()); |
312 | 320 |
313 pass_list.push_back(pass.PassAs<RenderPass>()); | 321 pass_list.push_back(pass.PassAs<RenderPass>()); |
314 | 322 |
315 // Make a copy with CopyAll(). | 323 // Make a copy with CopyAll(). |
316 RenderPassList copy_list; | 324 RenderPassList copy_list; |
317 RenderPass::CopyAll(pass_list, ©_list); | 325 RenderPass::CopyAll(pass_list, ©_list); |
318 | 326 |
319 CompareRenderPassLists(pass_list, copy_list); | 327 CompareRenderPassLists(pass_list, copy_list); |
320 } | 328 } |
321 | 329 |
322 } // namespace | 330 } // namespace |
323 } // namespace cc | 331 } // namespace cc |
OLD | NEW |