OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/viz/service/display/surface_aggregator.h" | 5 #include "components/viz/service/display/surface_aggregator.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
258 size_t sqs_size = source.shared_quad_state_list.size(); | 258 size_t sqs_size = source.shared_quad_state_list.size(); |
259 size_t dq_size = source.quad_list.size(); | 259 size_t dq_size = source.quad_list.size(); |
260 std::unique_ptr<cc::RenderPass> copy_pass( | 260 std::unique_ptr<cc::RenderPass> copy_pass( |
261 cc::RenderPass::Create(sqs_size, dq_size)); | 261 cc::RenderPass::Create(sqs_size, dq_size)); |
262 | 262 |
263 cc::RenderPassId remapped_pass_id = RemapPassId(source.id, surface_id); | 263 cc::RenderPassId remapped_pass_id = RemapPassId(source.id, surface_id); |
264 | 264 |
265 copy_pass->SetAll(remapped_pass_id, source.output_rect, source.output_rect, | 265 copy_pass->SetAll(remapped_pass_id, source.output_rect, source.output_rect, |
266 source.transform_to_root_target, source.filters, | 266 source.transform_to_root_target, source.filters, |
267 source.background_filters, blending_color_space_, | 267 source.background_filters, blending_color_space_, |
268 source.has_transparent_background); | 268 source.has_transparent_background, |
269 source.cache_render_surface, | |
270 source.has_damage_from_contributing_content); | |
danakj
2017/07/19 22:52:55
Are you expecting CompositorFrames from clients to
wutao
2017/07/21 05:59:24
There are 3 contributing_contents:
1. contributing
| |
269 | 271 |
270 MoveMatchingRequests(source.id, ©_requests, ©_pass->copy_requests); | 272 MoveMatchingRequests(source.id, ©_requests, ©_pass->copy_requests); |
271 | 273 |
272 // Contributing passes aggregated in to the pass list need to take the | 274 // Contributing passes aggregated in to the pass list need to take the |
273 // transform of the surface quad into account to update their transform to | 275 // transform of the surface quad into account to update their transform to |
274 // the root surface. | 276 // the root surface. |
275 copy_pass->transform_to_root_target.ConcatTransform( | 277 copy_pass->transform_to_root_target.ConcatTransform( |
276 surface_quad->shared_quad_state->quad_to_target_transform); | 278 surface_quad->shared_quad_state->quad_to_target_transform); |
277 copy_pass->transform_to_root_target.ConcatTransform(target_transform); | 279 copy_pass->transform_to_root_target.ConcatTransform(target_transform); |
278 copy_pass->transform_to_root_target.ConcatTransform( | 280 copy_pass->transform_to_root_target.ConcatTransform( |
279 dest_pass->transform_to_root_target); | 281 dest_pass->transform_to_root_target); |
280 | 282 |
281 CopyQuadsToPass(source.quad_list, source.shared_quad_state_list, | 283 CopyQuadsToPass(source.quad_list, source.shared_quad_state_list, |
282 child_to_parent_map, gfx::Transform(), ClipData(), | 284 child_to_parent_map, gfx::Transform(), ClipData(), |
283 copy_pass.get(), surface_id); | 285 copy_pass.get(), surface_id); |
284 | 286 |
285 if (!copy_request_passes_.count(remapped_pass_id) && | 287 if (!copy_request_passes_.count(remapped_pass_id) && |
danakj
2017/07/19 22:52:55
Can you help me understand why in CopyQuadsToPass
wutao
2017/07/21 05:59:24
Here we also ignore damage and do not recalculate
| |
288 !cached_render_surface_passes_.count(remapped_pass_id) && | |
danakj
2017/07/19 22:52:54
How is this different than checking source.cache_r
wutao
2017/07/21 05:59:24
I think you are right. So I do not need to modify
| |
286 !moved_pixel_passes_.count(remapped_pass_id)) { | 289 !moved_pixel_passes_.count(remapped_pass_id)) { |
287 gfx::Transform inverse_transform(gfx::Transform::kSkipInitialization); | 290 gfx::Transform inverse_transform(gfx::Transform::kSkipInitialization); |
288 if (copy_pass->transform_to_root_target.GetInverse(&inverse_transform)) { | 291 if (copy_pass->transform_to_root_target.GetInverse(&inverse_transform)) { |
289 gfx::Rect damage_rect_in_render_pass_space = | 292 gfx::Rect damage_rect_in_render_pass_space = |
290 cc::MathUtil::ProjectEnclosingClippedRect(inverse_transform, | 293 cc::MathUtil::ProjectEnclosingClippedRect(inverse_transform, |
291 root_damage_rect_); | 294 root_damage_rect_); |
292 copy_pass->damage_rect.Intersect(damage_rect_in_render_pass_space); | 295 copy_pass->damage_rect.Intersect(damage_rect_in_render_pass_space); |
293 } | 296 } |
294 } | 297 } |
295 | 298 |
299 id_to_render_pass_map_.insert( | |
300 std::make_pair(copy_pass->id, copy_pass.get())); | |
296 dest_pass_list_->push_back(std::move(copy_pass)); | 301 dest_pass_list_->push_back(std::move(copy_pass)); |
297 } | 302 } |
298 | 303 |
299 gfx::Transform surface_transform = | 304 gfx::Transform surface_transform = |
300 surface_quad->shared_quad_state->quad_to_target_transform; | 305 surface_quad->shared_quad_state->quad_to_target_transform; |
301 surface_transform.ConcatTransform(target_transform); | 306 surface_transform.ConcatTransform(target_transform); |
302 | 307 |
303 const auto& last_pass = *render_pass_list.back(); | 308 const auto& last_pass = *render_pass_list.back(); |
309 // Check if the surface_quad has damage. | |
danakj
2017/07/19 22:52:54
Can this comment explain why this damage check is
wutao
2017/07/21 05:59:24
Will change the comment. The damage here is only f
| |
310 if (dest_pass->cache_render_surface) { | |
311 dest_pass->has_damage_from_contributing_content |= | |
312 !DamageRectForSurface(surface, last_pass, last_pass.output_rect) | |
danakj
2017/07/19 22:52:54
This is different from the use of this function in
wutao
2017/07/21 05:59:24
This will check if all the surface_quads (includin
| |
313 .IsEmpty(); | |
314 } | |
315 | |
304 if (merge_pass) { | 316 if (merge_pass) { |
305 // TODO(jamesr): Clean up last pass special casing. | 317 // TODO(jamesr): Clean up last pass special casing. |
306 const cc::QuadList& quads = last_pass.quad_list; | 318 const cc::QuadList& quads = last_pass.quad_list; |
307 | 319 |
308 // Intersect the transformed visible rect and the clip rect to create a | 320 // Intersect the transformed visible rect and the clip rect to create a |
309 // smaller cliprect for the quad. | 321 // smaller cliprect for the quad. |
310 ClipData surface_quad_clip_rect( | 322 ClipData surface_quad_clip_rect( |
311 true, cc::MathUtil::MapEnclosingClippedRect( | 323 true, cc::MathUtil::MapEnclosingClippedRect( |
312 surface_quad->shared_quad_state->quad_to_target_transform, | 324 surface_quad->shared_quad_state->quad_to_target_transform, |
313 surface_quad->visible_rect)); | 325 surface_quad->visible_rect)); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
403 const cc::QuadList& source_quad_list, | 415 const cc::QuadList& source_quad_list, |
404 const cc::SharedQuadStateList& source_shared_quad_state_list, | 416 const cc::SharedQuadStateList& source_shared_quad_state_list, |
405 const std::unordered_map<cc::ResourceId, cc::ResourceId>& | 417 const std::unordered_map<cc::ResourceId, cc::ResourceId>& |
406 child_to_parent_map, | 418 child_to_parent_map, |
407 const gfx::Transform& target_transform, | 419 const gfx::Transform& target_transform, |
408 const ClipData& clip_rect, | 420 const ClipData& clip_rect, |
409 cc::RenderPass* dest_pass, | 421 cc::RenderPass* dest_pass, |
410 const SurfaceId& surface_id) { | 422 const SurfaceId& surface_id) { |
411 const cc::SharedQuadState* last_copied_source_shared_quad_state = nullptr; | 423 const cc::SharedQuadState* last_copied_source_shared_quad_state = nullptr; |
412 const cc::SharedQuadState* dest_shared_quad_state = nullptr; | 424 const cc::SharedQuadState* dest_shared_quad_state = nullptr; |
413 // If the current frame has copy requests then aggregate the entire | 425 // If the current frame has copy requests or cache render surface, then |
414 // thing, as otherwise parts of the copy requests may be ignored. | 426 // aggregate the entire thing, as otherwise parts of the copy requests or |
415 const bool ignore_undamaged = aggregate_only_damaged_ && | 427 // render surface may be ignored. |
danakj
2017/07/19 22:52:55
I think you mean to say that you want what's in th
wutao
2017/07/21 05:59:24
Yes. Changed accordingly.
| |
416 !has_copy_requests_ && | 428 const bool ignore_undamaged = |
417 !moved_pixel_passes_.count(dest_pass->id); | 429 aggregate_only_damaged_ && !has_copy_requests_ && |
430 !has_cached_render_surfaces_ && !moved_pixel_passes_.count(dest_pass->id); | |
418 // Damage rect in the quad space of the current shared quad state. | 431 // Damage rect in the quad space of the current shared quad state. |
419 // TODO(jbauman): This rect may contain unnecessary area if | 432 // TODO(jbauman): This rect may contain unnecessary area if |
420 // transform isn't axis-aligned. | 433 // transform isn't axis-aligned. |
421 gfx::Rect damage_rect_in_quad_space; | 434 gfx::Rect damage_rect_in_quad_space; |
422 bool damage_rect_in_quad_space_valid = false; | 435 bool damage_rect_in_quad_space_valid = false; |
423 | 436 |
424 #if DCHECK_IS_ON() | 437 #if DCHECK_IS_ON() |
425 // If quads have come in with SharedQuadState out of order, or when quads have | 438 // If quads have come in with SharedQuadState out of order, or when quads have |
426 // invalid SharedQuadState pointer, it should DCHECK. | 439 // invalid SharedQuadState pointer, it should DCHECK. |
427 auto sqs_iter = source_shared_quad_state_list.cbegin(); | 440 auto sqs_iter = source_shared_quad_state_list.cbegin(); |
(...skipping 20 matching lines...) Expand all Loading... | |
448 continue; | 461 continue; |
449 | 462 |
450 HandleSurfaceQuad(surface_quad, target_transform, clip_rect, dest_pass, | 463 HandleSurfaceQuad(surface_quad, target_transform, clip_rect, dest_pass, |
451 ignore_undamaged, &damage_rect_in_quad_space, | 464 ignore_undamaged, &damage_rect_in_quad_space, |
452 &damage_rect_in_quad_space_valid); | 465 &damage_rect_in_quad_space_valid); |
453 } else { | 466 } else { |
454 if (quad->shared_quad_state != last_copied_source_shared_quad_state) { | 467 if (quad->shared_quad_state != last_copied_source_shared_quad_state) { |
455 dest_shared_quad_state = CopySharedQuadState( | 468 dest_shared_quad_state = CopySharedQuadState( |
456 quad->shared_quad_state, target_transform, clip_rect, dest_pass); | 469 quad->shared_quad_state, target_transform, clip_rect, dest_pass); |
457 last_copied_source_shared_quad_state = quad->shared_quad_state; | 470 last_copied_source_shared_quad_state = quad->shared_quad_state; |
458 if (aggregate_only_damaged_ && !has_copy_requests_) { | 471 if (aggregate_only_damaged_ && !has_copy_requests_ && |
danakj
2017/07/19 22:52:54
Can you help me understand why this doesn't comput
wutao
2017/07/21 05:59:24
Looks like the final result is same, but we might
| |
472 !has_cached_render_surfaces_) { | |
459 damage_rect_in_quad_space_valid = CalculateQuadSpaceDamageRect( | 473 damage_rect_in_quad_space_valid = CalculateQuadSpaceDamageRect( |
460 dest_shared_quad_state->quad_to_target_transform, | 474 dest_shared_quad_state->quad_to_target_transform, |
461 dest_pass->transform_to_root_target, root_damage_rect_, | 475 dest_pass->transform_to_root_target, root_damage_rect_, |
462 &damage_rect_in_quad_space); | 476 &damage_rect_in_quad_space); |
463 } | 477 } |
464 } | 478 } |
465 | 479 |
466 if (ignore_undamaged) { | 480 if (ignore_undamaged) { |
467 if (damage_rect_in_quad_space_valid && | 481 if (damage_rect_in_quad_space_valid && |
468 !damage_rect_in_quad_space.Intersects(quad->visible_rect)) | 482 !damage_rect_in_quad_space.Intersects(quad->visible_rect)) |
469 continue; | 483 continue; |
470 } | 484 } |
471 | 485 |
472 cc::DrawQuad* dest_quad; | 486 cc::DrawQuad* dest_quad; |
473 if (quad->material == cc::DrawQuad::RENDER_PASS) { | 487 if (quad->material == cc::DrawQuad::RENDER_PASS) { |
474 const auto* pass_quad = cc::RenderPassDrawQuad::MaterialCast(quad); | 488 const auto* pass_quad = cc::RenderPassDrawQuad::MaterialCast(quad); |
475 int original_pass_id = pass_quad->render_pass_id; | 489 int original_pass_id = pass_quad->render_pass_id; |
476 int remapped_pass_id = RemapPassId(original_pass_id, surface_id); | 490 int remapped_pass_id = RemapPassId(original_pass_id, surface_id); |
477 | 491 if (dest_pass->cache_render_surface) { |
492 auto iter = id_to_render_pass_map_.find(remapped_pass_id); | |
493 if (iter != id_to_render_pass_map_.end()) { | |
494 dest_pass->has_damage_from_contributing_content |= | |
495 iter->second->has_damage_from_contributing_content; | |
danakj
2017/07/19 22:52:54
Is this just what HandleSurfaceDrawQuad() computed
wutao
2017/07/21 05:59:24
They are in different code path. Here is to handle
| |
496 } | |
497 } | |
478 dest_quad = dest_pass->CopyFromAndAppendRenderPassDrawQuad( | 498 dest_quad = dest_pass->CopyFromAndAppendRenderPassDrawQuad( |
479 pass_quad, dest_shared_quad_state, remapped_pass_id); | 499 pass_quad, dest_shared_quad_state, remapped_pass_id); |
480 } else if (quad->material == cc::DrawQuad::TEXTURE_CONTENT) { | 500 } else if (quad->material == cc::DrawQuad::TEXTURE_CONTENT) { |
481 const auto* texture_quad = cc::TextureDrawQuad::MaterialCast(quad); | 501 const auto* texture_quad = cc::TextureDrawQuad::MaterialCast(quad); |
482 if (texture_quad->secure_output_only && | 502 if (texture_quad->secure_output_only && |
483 (!output_is_secure_ || copy_request_passes_.count(dest_pass->id))) { | 503 (!output_is_secure_ || copy_request_passes_.count(dest_pass->id))) { |
484 auto* solid_color_quad = | 504 auto* solid_color_quad = |
485 dest_pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>(); | 505 dest_pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>(); |
486 solid_color_quad->SetNew(dest_shared_quad_state, quad->rect, | 506 solid_color_quad->SetNew(dest_shared_quad_state, quad->rect, |
487 quad->visible_rect, SK_ColorBLACK, false); | 507 quad->visible_rect, SK_ColorBLACK, false); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
535 auto copy_pass = cc::RenderPass::Create(sqs_size, dq_size); | 555 auto copy_pass = cc::RenderPass::Create(sqs_size, dq_size); |
536 | 556 |
537 MoveMatchingRequests(source.id, ©_requests, ©_pass->copy_requests); | 557 MoveMatchingRequests(source.id, ©_requests, ©_pass->copy_requests); |
538 | 558 |
539 cc::RenderPassId remapped_pass_id = | 559 cc::RenderPassId remapped_pass_id = |
540 RemapPassId(source.id, surface->surface_id()); | 560 RemapPassId(source.id, surface->surface_id()); |
541 | 561 |
542 copy_pass->SetAll(remapped_pass_id, source.output_rect, source.output_rect, | 562 copy_pass->SetAll(remapped_pass_id, source.output_rect, source.output_rect, |
543 source.transform_to_root_target, source.filters, | 563 source.transform_to_root_target, source.filters, |
544 source.background_filters, blending_color_space_, | 564 source.background_filters, blending_color_space_, |
545 source.has_transparent_background); | 565 source.has_transparent_background, |
566 source.cache_render_surface, | |
567 source.has_damage_from_contributing_content); | |
danakj
2017/07/19 22:52:54
Same questions here as in HandleSurfaceDrawQuad
wutao
2017/07/21 05:59:24
Please see the reply to the other comment.
| |
546 | 568 |
547 CopyQuadsToPass(source.quad_list, source.shared_quad_state_list, | 569 CopyQuadsToPass(source.quad_list, source.shared_quad_state_list, |
548 child_to_parent_map, gfx::Transform(), ClipData(), | 570 child_to_parent_map, gfx::Transform(), ClipData(), |
549 copy_pass.get(), surface->surface_id()); | 571 copy_pass.get(), surface->surface_id()); |
550 if (!copy_request_passes_.count(remapped_pass_id) && | 572 if (!copy_request_passes_.count(remapped_pass_id) && |
573 !cached_render_surface_passes_.count(remapped_pass_id) && | |
551 !moved_pixel_passes_.count(remapped_pass_id)) { | 574 !moved_pixel_passes_.count(remapped_pass_id)) { |
552 gfx::Transform inverse_transform(gfx::Transform::kSkipInitialization); | 575 gfx::Transform inverse_transform(gfx::Transform::kSkipInitialization); |
553 if (copy_pass->transform_to_root_target.GetInverse(&inverse_transform)) { | 576 if (copy_pass->transform_to_root_target.GetInverse(&inverse_transform)) { |
554 gfx::Rect damage_rect_in_render_pass_space = | 577 gfx::Rect damage_rect_in_render_pass_space = |
555 cc::MathUtil::ProjectEnclosingClippedRect(inverse_transform, | 578 cc::MathUtil::ProjectEnclosingClippedRect(inverse_transform, |
556 root_damage_rect_); | 579 root_damage_rect_); |
557 copy_pass->damage_rect.Intersect(damage_rect_in_render_pass_space); | 580 copy_pass->damage_rect.Intersect(damage_rect_in_render_pass_space); |
558 } | 581 } |
559 } | 582 } |
560 | 583 |
584 id_to_render_pass_map_.insert( | |
585 std::make_pair(copy_pass->id, copy_pass.get())); | |
561 dest_pass_list_->push_back(std::move(copy_pass)); | 586 dest_pass_list_->push_back(std::move(copy_pass)); |
562 } | 587 } |
danakj
2017/07/19 22:52:54
It doesn't compute the damage from contributing th
wutao
2017/07/21 05:59:24
All damage from contributing contents should be ha
| |
563 } | 588 } |
564 | 589 |
565 void SurfaceAggregator::ProcessAddedAndRemovedSurfaces() { | 590 void SurfaceAggregator::ProcessAddedAndRemovedSurfaces() { |
566 for (const auto& surface : previous_contained_surfaces_) { | 591 for (const auto& surface : previous_contained_surfaces_) { |
567 if (!contained_surfaces_.count(surface.first)) { | 592 if (!contained_surfaces_.count(surface.first)) { |
568 // Release resources of removed surface. | 593 // Release resources of removed surface. |
569 auto it = surface_id_to_resource_child_id_.find(surface.first); | 594 auto it = surface_id_to_resource_child_id_.find(surface.first); |
570 if (it != surface_id_to_resource_child_id_.end()) { | 595 if (it != surface_id_to_resource_child_id_.end()) { |
571 provider_->DestroyChild(it->second); | 596 provider_->DestroyChild(it->second); |
572 surface_id_to_resource_child_id_.erase(it); | 597 surface_id_to_resource_child_id_.erase(it); |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
754 CHECK(debug_weak_this.get()); | 779 CHECK(debug_weak_this.get()); |
755 // TODO(staraz): It shouldn't need to call the callback when the damage is | 780 // TODO(staraz): It shouldn't need to call the callback when the damage is |
756 // from |surface| and not from |child_surfaces|. | 781 // from |surface| and not from |child_surfaces|. |
757 if (!damage_rect.IsEmpty()) { | 782 if (!damage_rect.IsEmpty()) { |
758 surface->RunWillDrawCallback(damage_rect); | 783 surface->RunWillDrawCallback(damage_rect); |
759 manager_->SurfaceWillDraw(surface->surface_id()); | 784 manager_->SurfaceWillDraw(surface->surface_id()); |
760 } | 785 } |
761 | 786 |
762 CHECK(debug_weak_this.get()); | 787 CHECK(debug_weak_this.get()); |
763 for (const auto& render_pass : frame.render_pass_list) { | 788 for (const auto& render_pass : frame.render_pass_list) { |
764 if (!render_pass->copy_requests.empty()) { | 789 cc::RenderPassId remapped_pass_id = |
765 cc::RenderPassId remapped_pass_id = | 790 RemapPassId(render_pass->id, surface_id); |
766 RemapPassId(render_pass->id, surface_id); | 791 if (!render_pass->copy_requests.empty()) |
767 copy_request_passes_.insert(remapped_pass_id); | 792 copy_request_passes_.insert(remapped_pass_id); |
768 } | 793 if (render_pass->cache_render_surface) |
794 cached_render_surface_passes_.insert(remapped_pass_id); | |
769 } | 795 } |
770 | 796 |
771 referenced_surfaces_.erase(referenced_surfaces_.find(surface->surface_id())); | 797 referenced_surfaces_.erase(referenced_surfaces_.find(surface->surface_id())); |
772 if (!damage_rect.IsEmpty() && frame.metadata.may_contain_video) | 798 if (!damage_rect.IsEmpty() && frame.metadata.may_contain_video) |
773 result->may_contain_video = true; | 799 result->may_contain_video = true; |
774 return damage_rect; | 800 return damage_rect; |
775 } | 801 } |
776 | 802 |
777 void SurfaceAggregator::CopyUndrawnSurfaces(PrewalkResult* prewalk_result) { | 803 void SurfaceAggregator::CopyUndrawnSurfaces(PrewalkResult* prewalk_result) { |
778 // undrawn_surfaces are Surfaces that were identified by prewalk as being | 804 // undrawn_surfaces are Surfaces that were identified by prewalk as being |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
811 } | 837 } |
812 } else { | 838 } else { |
813 referenced_surfaces_.insert(surface_id); | 839 referenced_surfaces_.insert(surface_id); |
814 CopyPasses(frame, surface); | 840 CopyPasses(frame, surface); |
815 // CopyPasses may have mutated container, need to re-query to erase. | 841 // CopyPasses may have mutated container, need to re-query to erase. |
816 referenced_surfaces_.erase(referenced_surfaces_.find(surface_id)); | 842 referenced_surfaces_.erase(referenced_surfaces_.find(surface_id)); |
817 } | 843 } |
818 } | 844 } |
819 } | 845 } |
820 | 846 |
821 void SurfaceAggregator::PropagateCopyRequestPasses() { | 847 void SurfaceAggregator::PropagatePasses( |
822 std::vector<cc::RenderPassId> copy_requests_to_iterate( | 848 base::flat_set<cc::RenderPassId>* passes) { |
823 copy_request_passes_.begin(), copy_request_passes_.end()); | 849 std::vector<cc::RenderPassId> passes_to_iterate(passes->begin(), |
824 while (!copy_requests_to_iterate.empty()) { | 850 passes->end()); |
825 int first = copy_requests_to_iterate.back(); | 851 while (!passes_to_iterate.empty()) { |
826 copy_requests_to_iterate.pop_back(); | 852 cc::RenderPassId first = passes_to_iterate.back(); |
853 passes_to_iterate.pop_back(); | |
827 auto it = render_pass_dependencies_.find(first); | 854 auto it = render_pass_dependencies_.find(first); |
828 if (it == render_pass_dependencies_.end()) | 855 if (it == render_pass_dependencies_.end()) |
829 continue; | 856 continue; |
830 for (auto pass : it->second) { | 857 for (auto pass : it->second) { |
831 if (copy_request_passes_.insert(pass).second) { | 858 if (passes->insert(pass).second) { |
832 copy_requests_to_iterate.push_back(pass); | 859 passes_to_iterate.push_back(pass); |
833 } | 860 } |
834 } | 861 } |
835 } | 862 } |
836 } | 863 } |
837 | 864 |
838 cc::CompositorFrame SurfaceAggregator::Aggregate(const SurfaceId& surface_id) { | 865 cc::CompositorFrame SurfaceAggregator::Aggregate(const SurfaceId& surface_id) { |
839 uma_stats_.Reset(); | 866 uma_stats_.Reset(); |
840 | 867 |
841 cc::Surface* surface = manager_->GetSurfaceForId(surface_id); | 868 cc::Surface* surface = manager_->GetSurfaceForId(surface_id); |
842 DCHECK(surface); | 869 DCHECK(surface); |
843 contained_surfaces_[surface_id] = surface->frame_index(); | 870 contained_surfaces_[surface_id] = surface->frame_index(); |
844 | 871 |
845 if (!surface->HasActiveFrame()) | 872 if (!surface->HasActiveFrame()) |
846 return {}; | 873 return {}; |
847 | 874 |
848 const cc::CompositorFrame& root_surface_frame = surface->GetActiveFrame(); | 875 const cc::CompositorFrame& root_surface_frame = surface->GetActiveFrame(); |
849 TRACE_EVENT0("viz", "SurfaceAggregator::Aggregate"); | 876 TRACE_EVENT0("viz", "SurfaceAggregator::Aggregate"); |
850 | 877 |
851 cc::CompositorFrame frame; | 878 cc::CompositorFrame frame; |
852 | 879 |
853 dest_pass_list_ = &frame.render_pass_list; | 880 dest_pass_list_ = &frame.render_pass_list; |
854 | 881 |
855 valid_surfaces_.clear(); | 882 valid_surfaces_.clear(); |
856 PrewalkResult prewalk_result; | 883 PrewalkResult prewalk_result; |
857 root_damage_rect_ = PrewalkTree(surface_id, false, 0, &prewalk_result); | 884 root_damage_rect_ = PrewalkTree(surface_id, false, 0, &prewalk_result); |
858 PropagateCopyRequestPasses(); | 885 PropagatePasses(©_request_passes_); |
danakj
2017/07/19 22:52:55
granted the name comes from what was there before
wutao
2017/07/21 05:59:24
1. I do not need to modify this function.
2. I thi
| |
886 PropagatePasses(&cached_render_surface_passes_); | |
859 has_copy_requests_ = !copy_request_passes_.empty(); | 887 has_copy_requests_ = !copy_request_passes_.empty(); |
888 has_cached_render_surfaces_ = !cached_render_surface_passes_.empty(); | |
860 frame.metadata.may_contain_video = prewalk_result.may_contain_video; | 889 frame.metadata.may_contain_video = prewalk_result.may_contain_video; |
861 | 890 |
862 CopyUndrawnSurfaces(&prewalk_result); | 891 CopyUndrawnSurfaces(&prewalk_result); |
863 referenced_surfaces_.insert(surface_id); | 892 referenced_surfaces_.insert(surface_id); |
864 CopyPasses(root_surface_frame, surface); | 893 CopyPasses(root_surface_frame, surface); |
865 // CopyPasses may have mutated container, need to re-query to erase. | 894 // CopyPasses may have mutated container, need to re-query to erase. |
866 referenced_surfaces_.erase(referenced_surfaces_.find(surface_id)); | 895 referenced_surfaces_.erase(referenced_surfaces_.find(surface_id)); |
867 AddColorConversionPass(); | 896 AddColorConversionPass(); |
868 | 897 |
869 moved_pixel_passes_.clear(); | 898 moved_pixel_passes_.clear(); |
870 copy_request_passes_.clear(); | 899 copy_request_passes_.clear(); |
900 cached_render_surface_passes_.clear(); | |
871 render_pass_dependencies_.clear(); | 901 render_pass_dependencies_.clear(); |
872 | 902 |
873 // Remove all render pass mappings that weren't used in the current frame. | 903 // Remove all render pass mappings that weren't used in the current frame. |
874 for (auto it = render_pass_allocator_map_.begin(); | 904 for (auto it = render_pass_allocator_map_.begin(); |
875 it != render_pass_allocator_map_.end();) { | 905 it != render_pass_allocator_map_.end();) { |
876 if (it->second.in_use) { | 906 if (it->second.in_use) { |
877 it->second.in_use = false; | 907 it->second.in_use = false; |
878 it++; | 908 it++; |
879 } else { | 909 } else { |
880 it = render_pass_allocator_map_.erase(it); | 910 it = render_pass_allocator_map_.erase(it); |
881 } | 911 } |
882 } | 912 } |
883 | 913 |
884 DCHECK(referenced_surfaces_.empty()); | 914 DCHECK(referenced_surfaces_.empty()); |
885 | 915 |
886 if (dest_pass_list_->empty()) | 916 if (dest_pass_list_->empty()) |
887 return {}; | 917 return {}; |
888 | 918 |
889 dest_pass_list_ = NULL; | 919 dest_pass_list_ = NULL; |
920 id_to_render_pass_map_.clear(); | |
890 ProcessAddedAndRemovedSurfaces(); | 921 ProcessAddedAndRemovedSurfaces(); |
891 contained_surfaces_.swap(previous_contained_surfaces_); | 922 contained_surfaces_.swap(previous_contained_surfaces_); |
892 contained_surfaces_.clear(); | 923 contained_surfaces_.clear(); |
893 | 924 |
894 for (auto it : previous_contained_surfaces_) { | 925 for (auto it : previous_contained_surfaces_) { |
895 cc::Surface* surface = manager_->GetSurfaceForId(it.first); | 926 cc::Surface* surface = manager_->GetSurfaceForId(it.first); |
896 if (surface) | 927 if (surface) |
897 surface->TakeLatencyInfo(&frame.metadata.latency_info); | 928 surface->TakeLatencyInfo(&frame.metadata.latency_info); |
898 } | 929 } |
899 | 930 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
933 const gfx::ColorSpace& output_color_space) { | 964 const gfx::ColorSpace& output_color_space) { |
934 blending_color_space_ = blending_color_space.IsValid() | 965 blending_color_space_ = blending_color_space.IsValid() |
935 ? blending_color_space | 966 ? blending_color_space |
936 : gfx::ColorSpace::CreateSRGB(); | 967 : gfx::ColorSpace::CreateSRGB(); |
937 output_color_space_ = output_color_space.IsValid() | 968 output_color_space_ = output_color_space.IsValid() |
938 ? output_color_space | 969 ? output_color_space |
939 : gfx::ColorSpace::CreateSRGB(); | 970 : gfx::ColorSpace::CreateSRGB(); |
940 } | 971 } |
941 | 972 |
942 } // namespace viz | 973 } // namespace viz |
OLD | NEW |