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/layers/delegated_renderer_layer_impl.h" | 5 #include "cc/layers/delegated_renderer_layer_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 ResourceProvider* resource_provider) { | 250 ResourceProvider* resource_provider) { |
251 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) | 251 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) |
252 return false; | 252 return false; |
253 return LayerImpl::WillDraw(draw_mode, resource_provider); | 253 return LayerImpl::WillDraw(draw_mode, resource_provider); |
254 } | 254 } |
255 | 255 |
256 void DelegatedRendererLayerImpl::AppendQuads( | 256 void DelegatedRendererLayerImpl::AppendQuads( |
257 RenderPass* render_pass, | 257 RenderPass* render_pass, |
258 const Occlusion& occlusion_in_content_space, | 258 const Occlusion& occlusion_in_content_space, |
259 AppendQuadsData* append_quads_data) { | 259 AppendQuadsData* append_quads_data) { |
260 AppendRainbowDebugBorder(render_pass, append_quads_data); | 260 AppendRainbowDebugBorder(render_pass); |
261 | 261 |
262 // This list will be empty after a lost context until a new frame arrives. | 262 // This list will be empty after a lost context until a new frame arrives. |
263 if (render_passes_in_draw_order_.empty()) | 263 if (render_passes_in_draw_order_.empty()) |
264 return; | 264 return; |
265 | 265 |
266 RenderPassId target_render_pass_id = append_quads_data->render_pass_id; | 266 RenderPassId target_render_pass_id = render_pass->id; |
267 | 267 |
268 const RenderPass* root_delegated_render_pass = | 268 const RenderPass* root_delegated_render_pass = |
269 render_passes_in_draw_order_.back(); | 269 render_passes_in_draw_order_.back(); |
270 | 270 |
271 DCHECK(root_delegated_render_pass->output_rect.origin().IsOrigin()); | 271 DCHECK(root_delegated_render_pass->output_rect.origin().IsOrigin()); |
272 gfx::Size frame_size = root_delegated_render_pass->output_rect.size(); | 272 gfx::Size frame_size = root_delegated_render_pass->output_rect.size(); |
273 | 273 |
274 // If the index of the RenderPassId is 0, then it is a RenderPass generated | 274 // If the index of the RenderPassId is 0, then it is a RenderPass generated |
275 // for a layer in this compositor, not the delegating renderer. Then we want | 275 // for a layer in this compositor, not the delegating renderer. Then we want |
276 // to merge our root RenderPass with the target RenderPass. Otherwise, it is | 276 // to merge our root RenderPass with the target RenderPass. Otherwise, it is |
277 // some RenderPass which we added from the delegating renderer. | 277 // some RenderPass which we added from the delegating renderer. |
278 bool should_merge_root_render_pass_with_target = !target_render_pass_id.index; | 278 bool should_merge_root_render_pass_with_target = !target_render_pass_id.index; |
279 if (should_merge_root_render_pass_with_target) { | 279 if (should_merge_root_render_pass_with_target) { |
280 // Verify that the RenderPass we are appending to is created by our | 280 // Verify that the RenderPass we are appending to is created by our |
281 // render_target. | 281 // render_target. |
282 DCHECK(target_render_pass_id.layer_id == render_target()->id()); | 282 DCHECK(target_render_pass_id.layer_id == render_target()->id()); |
283 | 283 |
284 AppendRenderPassQuads(render_pass, | 284 AppendRenderPassQuads(render_pass, |
285 occlusion_in_content_space, | 285 occlusion_in_content_space, |
286 append_quads_data, | |
287 root_delegated_render_pass, | 286 root_delegated_render_pass, |
288 frame_size); | 287 frame_size); |
289 } else { | 288 } else { |
290 // Verify that the RenderPass we are appending to was created by us. | 289 // Verify that the RenderPass we are appending to was created by us. |
291 DCHECK(target_render_pass_id.layer_id == id()); | 290 DCHECK(target_render_pass_id.layer_id == id()); |
292 | 291 |
293 int render_pass_index = IdToIndex(target_render_pass_id.index); | 292 int render_pass_index = IdToIndex(target_render_pass_id.index); |
294 const RenderPass* delegated_render_pass = | 293 const RenderPass* delegated_render_pass = |
295 render_passes_in_draw_order_[render_pass_index]; | 294 render_passes_in_draw_order_[render_pass_index]; |
296 AppendRenderPassQuads(render_pass, | 295 AppendRenderPassQuads(render_pass, |
297 occlusion_in_content_space, | 296 occlusion_in_content_space, |
298 append_quads_data, | |
299 delegated_render_pass, | 297 delegated_render_pass, |
300 frame_size); | 298 frame_size); |
301 } | 299 } |
302 } | 300 } |
303 | 301 |
304 void DelegatedRendererLayerImpl::AppendRainbowDebugBorder( | 302 void DelegatedRendererLayerImpl::AppendRainbowDebugBorder( |
305 RenderPass* render_pass, | 303 RenderPass* render_pass) { |
306 AppendQuadsData* append_quads_data) { | |
307 if (!ShowDebugBorders()) | 304 if (!ShowDebugBorders()) |
308 return; | 305 return; |
309 | 306 |
310 SharedQuadState* shared_quad_state = | 307 SharedQuadState* shared_quad_state = |
311 render_pass->CreateAndAppendSharedQuadState(); | 308 render_pass->CreateAndAppendSharedQuadState(); |
312 PopulateSharedQuadState(shared_quad_state); | 309 PopulateSharedQuadState(shared_quad_state); |
313 | 310 |
314 SkColor color; | 311 SkColor color; |
315 float border_width; | 312 float border_width; |
316 GetDebugBorderProperties(&color, &border_width); | 313 GetDebugBorderProperties(&color, &border_width); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 375 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
379 right_quad->SetNew( | 376 right_quad->SetNew( |
380 shared_quad_state, right, right, colors[i % kNumColors], false); | 377 shared_quad_state, right, right, colors[i % kNumColors], false); |
381 } | 378 } |
382 } | 379 } |
383 } | 380 } |
384 | 381 |
385 void DelegatedRendererLayerImpl::AppendRenderPassQuads( | 382 void DelegatedRendererLayerImpl::AppendRenderPassQuads( |
386 RenderPass* render_pass, | 383 RenderPass* render_pass, |
387 const Occlusion& occlusion_in_content_space, | 384 const Occlusion& occlusion_in_content_space, |
388 AppendQuadsData* append_quads_data, | |
389 const RenderPass* delegated_render_pass, | 385 const RenderPass* delegated_render_pass, |
390 const gfx::Size& frame_size) const { | 386 const gfx::Size& frame_size) const { |
391 const SharedQuadState* delegated_shared_quad_state = nullptr; | 387 const SharedQuadState* delegated_shared_quad_state = nullptr; |
392 SharedQuadState* output_shared_quad_state = nullptr; | 388 SharedQuadState* output_shared_quad_state = nullptr; |
393 | 389 |
394 for (const auto& delegated_quad : delegated_render_pass->quad_list) { | 390 for (const auto& delegated_quad : delegated_render_pass->quad_list) { |
395 bool is_root_delegated_render_pass = | 391 bool is_root_delegated_render_pass = |
396 delegated_render_pass == render_passes_in_draw_order_.back(); | 392 delegated_render_pass == render_passes_in_draw_order_.back(); |
397 | 393 |
398 if (delegated_quad->shared_quad_state != delegated_shared_quad_state) { | 394 if (delegated_quad->shared_quad_state != delegated_shared_quad_state) { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 RenderPassDrawQuad::MaterialCast(delegated_quad)->render_pass_id; | 456 RenderPassDrawQuad::MaterialCast(delegated_quad)->render_pass_id; |
461 RenderPassId output_contributing_render_pass_id(-1, -1); | 457 RenderPassId output_contributing_render_pass_id(-1, -1); |
462 | 458 |
463 bool present = | 459 bool present = |
464 ConvertDelegatedRenderPassId(delegated_contributing_render_pass_id, | 460 ConvertDelegatedRenderPassId(delegated_contributing_render_pass_id, |
465 &output_contributing_render_pass_id); | 461 &output_contributing_render_pass_id); |
466 | 462 |
467 // The frame may have a RenderPassDrawQuad that points to a RenderPass not | 463 // The frame may have a RenderPassDrawQuad that points to a RenderPass not |
468 // part of the frame. Just ignore these quads. | 464 // part of the frame. Just ignore these quads. |
469 if (present) { | 465 if (present) { |
470 DCHECK(output_contributing_render_pass_id != | 466 DCHECK(output_contributing_render_pass_id != render_pass->id); |
471 append_quads_data->render_pass_id); | |
472 | 467 |
473 RenderPassDrawQuad* output_quad = | 468 RenderPassDrawQuad* output_quad = |
474 render_pass->CopyFromAndAppendRenderPassDrawQuad( | 469 render_pass->CopyFromAndAppendRenderPassDrawQuad( |
475 RenderPassDrawQuad::MaterialCast(delegated_quad), | 470 RenderPassDrawQuad::MaterialCast(delegated_quad), |
476 output_shared_quad_state, | 471 output_shared_quad_state, |
477 output_contributing_render_pass_id); | 472 output_contributing_render_pass_id); |
478 output_quad->visible_rect = quad_visible_rect; | 473 output_quad->visible_rect = quad_visible_rect; |
479 } | 474 } |
480 } | 475 } |
481 } | 476 } |
(...skipping 10 matching lines...) Expand all Loading... |
492 if (own_child_id_) { | 487 if (own_child_id_) { |
493 ResourceProvider* provider = layer_tree_impl()->resource_provider(); | 488 ResourceProvider* provider = layer_tree_impl()->resource_provider(); |
494 provider->DestroyChild(child_id_); | 489 provider->DestroyChild(child_id_); |
495 } | 490 } |
496 | 491 |
497 resources_.clear(); | 492 resources_.clear(); |
498 child_id_ = 0; | 493 child_id_ = 0; |
499 } | 494 } |
500 | 495 |
501 } // namespace cc | 496 } // namespace cc |
OLD | NEW |