OLD | NEW |
---|---|
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/trees/layer_tree_impl.h" | 5 #include "cc/trees/layer_tree_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
573 settings().layer_transforms_should_scale_layer_contents, | 573 settings().layer_transforms_should_scale_layer_contents, |
574 settings().verify_property_trees, | 574 settings().verify_property_trees, |
575 &render_surface_layer_list_, render_surface_layer_list_id_); | 575 &render_surface_layer_list_, render_surface_layer_list_id_); |
576 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 576 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
577 } | 577 } |
578 | 578 |
579 { | 579 { |
580 TRACE_EVENT_BEGIN2("cc", "LayerTreeImpl::UpdateTilePriorities", "IsActive", | 580 TRACE_EVENT_BEGIN2("cc", "LayerTreeImpl::UpdateTilePriorities", "IsActive", |
581 IsActiveTree(), "SourceFrameNumber", | 581 IsActiveTree(), "SourceFrameNumber", |
582 source_frame_number_); | 582 source_frame_number_); |
583 scoped_ptr<OcclusionTracker<LayerImpl>> occlusion_tracker; | 583 OcclusionTracker<LayerImpl> occlusion_tracker( |
584 if (settings().use_occlusion_for_tile_prioritization) { | 584 root_layer()->render_surface()->content_rect()); |
585 occlusion_tracker.reset(new OcclusionTracker<LayerImpl>( | 585 occlusion_tracker.set_minimum_tracking_size( |
586 root_layer()->render_surface()->content_rect())); | 586 settings().minimum_occlusion_tracking_size); |
587 occlusion_tracker->set_minimum_tracking_size( | |
588 settings().minimum_occlusion_tracking_size); | |
589 } | |
590 | |
591 bool resourceless_software_draw = (layer_tree_host_impl_->GetDrawMode() == | |
592 DRAW_MODE_RESOURCELESS_SOFTWARE); | |
593 | 587 |
594 // LayerIterator is used here instead of CallFunctionForSubtree to only | 588 // LayerIterator is used here instead of CallFunctionForSubtree to only |
595 // UpdateTilePriorities on layers that will be visible (and thus have valid | 589 // UpdateTilePriorities on layers that will be visible (and thus have valid |
596 // draw properties) and not because any ordering is required. | 590 // draw properties) and not because any ordering is required. |
597 typedef LayerIterator<LayerImpl> LayerIteratorType; | 591 auto end = LayerIterator<LayerImpl>::End(&render_surface_layer_list_); |
598 LayerIteratorType end = LayerIteratorType::End(&render_surface_layer_list_); | 592 for (auto it = LayerIterator<LayerImpl>::Begin(&render_surface_layer_list_); |
593 it != end; ++it) { | |
594 occlusion_tracker.EnterLayer(it); | |
595 | |
596 if (it.represents_itself()) { | |
597 Occlusion occlusion = | |
598 occlusion_tracker.GetCurrentOcclusionForLayer(it->draw_transform()); | |
599 it->draw_properties().occlusion_in_content_space = occlusion; | |
600 } | |
601 | |
602 if (it.represents_contributing_render_surface()) { | |
603 it->render_surface()->set_occlusion_in_content_space( | |
604 occlusion_tracker.GetCurrentOcclusionForContributingSurface( | |
605 it->render_surface()->draw_transform())); | |
606 it->render_surface()->set_replica_occlusion_in_content_space( | |
607 occlusion_tracker.GetCurrentOcclusionForContributingSurface( | |
608 it->render_surface()->replica_draw_transform())); | |
609 if (LayerImpl* mask = it->mask_layer()) { | |
610 mask->draw_properties().occlusion_in_content_space = | |
611 occlusion_tracker.GetCurrentOcclusionForContributingSurface( | |
612 it->render_surface()->draw_transform() * | |
vmpstr
2015/02/13 00:24:54
This is probably lack of knowledge for my part, bu
danakj
2015/02/13 00:27:07
The mask is used when drawing the surface, so I th
enne (OOO)
2015/02/13 00:30:23
Occlusion on masks is not used anywhere, as it's r
| |
613 it->draw_transform()); | |
614 } | |
615 if (it->replica_layer()) { | |
616 if (LayerImpl* mask = it->replica_layer()->mask_layer()) { | |
617 mask->draw_properties().occlusion_in_content_space = | |
618 occlusion_tracker.GetCurrentOcclusionForContributingSurface( | |
619 it->render_surface()->replica_draw_transform() * | |
620 it->draw_transform()); | |
621 } | |
622 } | |
623 } | |
624 | |
625 occlusion_tracker.LeaveLayer(it); | |
626 } | |
627 | |
628 unoccluded_screen_space_region_ = | |
629 occlusion_tracker.ComputeVisibleRegionInScreen(); | |
630 | |
631 const bool resourceless_software_draw = | |
632 (layer_tree_host_impl_->GetDrawMode() == | |
633 DRAW_MODE_RESOURCELESS_SOFTWARE); | |
634 static const Occlusion kEmptyOcclusion; | |
599 size_t layers_updated_count = 0; | 635 size_t layers_updated_count = 0; |
600 bool tile_priorities_updated = false; | 636 bool tile_priorities_updated = false; |
601 for (LayerIteratorType it = | 637 for (PictureLayerImpl* layer : picture_layers_) { |
602 LayerIteratorType::Begin(&render_surface_layer_list_); | 638 // TODO(danakj): Remove this to fix crbug.com/446751 |
603 it != end; | 639 if (!layer->IsDrawnRenderSurfaceLayerListMember()) |
604 ++it) { | |
605 if (occlusion_tracker) | |
606 occlusion_tracker->EnterLayer(it); | |
607 | |
608 LayerImpl* layer = *it; | |
609 const Occlusion& occlusion_in_content_space = | |
610 occlusion_tracker ? occlusion_tracker->GetCurrentOcclusionForLayer( | |
611 layer->draw_transform()) | |
612 : Occlusion(); | |
613 | |
614 if (it.represents_itself()) { | |
615 tile_priorities_updated |= layer->UpdateTiles( | |
616 occlusion_in_content_space, resourceless_software_draw); | |
617 ++layers_updated_count; | |
618 } | |
619 | |
620 if (!it.represents_contributing_render_surface()) { | |
621 if (occlusion_tracker) | |
622 occlusion_tracker->LeaveLayer(it); | |
623 continue; | 640 continue; |
624 } | 641 ++layers_updated_count; |
625 | 642 const Occlusion& occlusion = |
626 if (layer->mask_layer()) { | 643 settings().use_occlusion_for_tile_prioritization |
627 tile_priorities_updated |= layer->mask_layer()->UpdateTiles( | 644 ? layer->draw_properties().occlusion_in_content_space |
628 occlusion_in_content_space, resourceless_software_draw); | 645 : kEmptyOcclusion; |
629 ++layers_updated_count; | 646 tile_priorities_updated |= |
630 } | 647 layer->UpdateTiles(occlusion, resourceless_software_draw); |
vmpstr
2015/02/13 00:24:54
mask and replica mask also need update tiles, righ
| |
631 if (layer->replica_layer() && layer->replica_layer()->mask_layer()) { | |
632 tile_priorities_updated |= | |
633 layer->replica_layer()->mask_layer()->UpdateTiles( | |
634 occlusion_in_content_space, resourceless_software_draw); | |
635 ++layers_updated_count; | |
636 } | |
637 | |
638 if (occlusion_tracker) | |
639 occlusion_tracker->LeaveLayer(it); | |
640 } | 648 } |
641 | 649 |
642 if (tile_priorities_updated) | 650 if (tile_priorities_updated) |
643 DidModifyTilePriorities(); | 651 DidModifyTilePriorities(); |
644 | 652 |
645 TRACE_EVENT_END1("cc", "LayerTreeImpl::UpdateTilePriorities", | 653 TRACE_EVENT_END1("cc", "LayerTreeImpl::UpdateTilePriorities", |
646 "layers_updated_count", layers_updated_count); | 654 "layers_updated_count", layers_updated_count); |
647 } | 655 } |
648 | 656 |
649 DCHECK(!needs_update_draw_properties_) << | 657 DCHECK(!needs_update_draw_properties_) << |
650 "CalcDrawProperties should not set_needs_update_draw_properties()"; | 658 "CalcDrawProperties should not set_needs_update_draw_properties()"; |
651 return true; | 659 return true; |
652 } | 660 } |
653 | 661 |
654 const LayerImplList& LayerTreeImpl::RenderSurfaceLayerList() const { | 662 const LayerImplList& LayerTreeImpl::RenderSurfaceLayerList() const { |
655 // If this assert triggers, then the list is dirty. | 663 // If this assert triggers, then the list is dirty. |
656 DCHECK(!needs_update_draw_properties_); | 664 DCHECK(!needs_update_draw_properties_); |
657 return render_surface_layer_list_; | 665 return render_surface_layer_list_; |
658 } | 666 } |
659 | 667 |
668 const Region& LayerTreeImpl::UnoccludedScreenSpaceRegion() const { | |
669 // If this assert triggers, then the render_surface_layer_list_ is dirty, so | |
670 // the unoccluded_screen_space_region_ is not valid anymore. | |
671 DCHECK(!needs_update_draw_properties_); | |
672 return unoccluded_screen_space_region_; | |
673 } | |
674 | |
660 gfx::Size LayerTreeImpl::ScrollableSize() const { | 675 gfx::Size LayerTreeImpl::ScrollableSize() const { |
661 LayerImpl* root_scroll_layer = OuterViewportScrollLayer() | 676 LayerImpl* root_scroll_layer = OuterViewportScrollLayer() |
662 ? OuterViewportScrollLayer() | 677 ? OuterViewportScrollLayer() |
663 : InnerViewportScrollLayer(); | 678 : InnerViewportScrollLayer(); |
664 if (!root_scroll_layer || root_scroll_layer->children().empty()) | 679 if (!root_scroll_layer || root_scroll_layer->children().empty()) |
665 return gfx::Size(); | 680 return gfx::Size(); |
666 return root_scroll_layer->children()[0]->bounds(); | 681 return root_scroll_layer->children()[0]->bounds(); |
667 } | 682 } |
668 | 683 |
669 LayerImpl* LayerTreeImpl::LayerById(int id) { | 684 LayerImpl* LayerTreeImpl::LayerById(int id) { |
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1590 scoped_ptr<PendingPageScaleAnimation> pending_animation) { | 1605 scoped_ptr<PendingPageScaleAnimation> pending_animation) { |
1591 pending_page_scale_animation_ = pending_animation.Pass(); | 1606 pending_page_scale_animation_ = pending_animation.Pass(); |
1592 } | 1607 } |
1593 | 1608 |
1594 scoped_ptr<PendingPageScaleAnimation> | 1609 scoped_ptr<PendingPageScaleAnimation> |
1595 LayerTreeImpl::TakePendingPageScaleAnimation() { | 1610 LayerTreeImpl::TakePendingPageScaleAnimation() { |
1596 return pending_page_scale_animation_.Pass(); | 1611 return pending_page_scale_animation_.Pass(); |
1597 } | 1612 } |
1598 | 1613 |
1599 } // namespace cc | 1614 } // namespace cc |
OLD | NEW |