| 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_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 | 700 |
| 701 return false; | 701 return false; |
| 702 } | 702 } |
| 703 | 703 |
| 704 void LayerTreeHostImpl::QueueSwapPromiseForMainThreadScrollUpdate( | 704 void LayerTreeHostImpl::QueueSwapPromiseForMainThreadScrollUpdate( |
| 705 std::unique_ptr<SwapPromise> swap_promise) { | 705 std::unique_ptr<SwapPromise> swap_promise) { |
| 706 swap_promises_for_main_thread_scroll_update_.push_back( | 706 swap_promises_for_main_thread_scroll_update_.push_back( |
| 707 std::move(swap_promise)); | 707 std::move(swap_promise)); |
| 708 } | 708 } |
| 709 | 709 |
| 710 void LayerTreeHostImpl::TrackDamageForAllSurfaces( | |
| 711 const LayerImplList& render_surface_layer_list) { | |
| 712 // For now, we use damage tracking to compute a global scissor. To do this, we | |
| 713 // must compute all damage tracking before drawing anything, so that we know | |
| 714 // the root damage rect. The root damage rect is then used to scissor each | |
| 715 // surface. | |
| 716 size_t render_surface_layer_list_size = render_surface_layer_list.size(); | |
| 717 for (size_t i = 0; i < render_surface_layer_list_size; ++i) { | |
| 718 size_t surface_index = render_surface_layer_list_size - 1 - i; | |
| 719 LayerImpl* render_surface_layer = render_surface_layer_list[surface_index]; | |
| 720 RenderSurfaceImpl* render_surface = | |
| 721 render_surface_layer->GetRenderSurface(); | |
| 722 DCHECK(render_surface); | |
| 723 render_surface->damage_tracker()->UpdateDamageTrackingState( | |
| 724 render_surface->layer_list(), render_surface, | |
| 725 render_surface->SurfacePropertyChangedOnlyFromDescendant(), | |
| 726 render_surface->content_rect(), render_surface->MaskLayer(), | |
| 727 render_surface->Filters()); | |
| 728 } | |
| 729 } | |
| 730 | |
| 731 void LayerTreeHostImpl::FrameData::AsValueInto( | 710 void LayerTreeHostImpl::FrameData::AsValueInto( |
| 732 base::trace_event::TracedValue* value) const { | 711 base::trace_event::TracedValue* value) const { |
| 733 value->SetBoolean("has_no_damage", has_no_damage); | 712 value->SetBoolean("has_no_damage", has_no_damage); |
| 734 | 713 |
| 735 // Quad data can be quite large, so only dump render passes if we select | 714 // Quad data can be quite large, so only dump render passes if we select |
| 736 // cc.debug.quads. | 715 // cc.debug.quads. |
| 737 bool quads_enabled; | 716 bool quads_enabled; |
| 738 TRACE_EVENT_CATEGORY_GROUP_ENABLED( | 717 TRACE_EVENT_CATEGORY_GROUP_ENABLED( |
| 739 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), &quads_enabled); | 718 TRACE_DISABLED_BY_DEFAULT("cc.debug.quads"), &quads_enabled); |
| 740 if (quads_enabled) { | 719 if (quads_enabled) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 list.begin(), list.end(), | 779 list.begin(), list.end(), |
| 801 [id](const std::unique_ptr<RenderPass>& p) { return p->id == id; }); | 780 [id](const std::unique_ptr<RenderPass>& p) { return p->id == id; }); |
| 802 return it == list.end() ? nullptr : it->get(); | 781 return it == list.end() ? nullptr : it->get(); |
| 803 } | 782 } |
| 804 | 783 |
| 805 DrawResult LayerTreeHostImpl::CalculateRenderPasses(FrameData* frame) { | 784 DrawResult LayerTreeHostImpl::CalculateRenderPasses(FrameData* frame) { |
| 806 DCHECK(frame->render_passes.empty()); | 785 DCHECK(frame->render_passes.empty()); |
| 807 DCHECK(CanDraw()); | 786 DCHECK(CanDraw()); |
| 808 DCHECK(!active_tree_->LayerListIsEmpty()); | 787 DCHECK(!active_tree_->LayerListIsEmpty()); |
| 809 | 788 |
| 810 TrackDamageForAllSurfaces(*frame->render_surface_layer_list); | 789 // For now, we use damage tracking to compute a global scissor. To do this, we |
| 790 // must compute all damage tracking before drawing anything, so that we know |
| 791 // the root damage rect. The root damage rect is then used to scissor each |
| 792 // surface. |
| 793 DamageTracker::UpdateDamageTracking(active_tree_.get(), |
| 794 active_tree_->RenderSurfaceLayerList()); |
| 811 | 795 |
| 812 // If the root render surface has no visible damage, then don't generate a | 796 // If the root render surface has no visible damage, then don't generate a |
| 813 // frame at all. | 797 // frame at all. |
| 814 RenderSurfaceImpl* root_surface = active_tree_->RootRenderSurface(); | 798 RenderSurfaceImpl* root_surface = active_tree_->RootRenderSurface(); |
| 815 bool root_surface_has_no_visible_damage = | 799 bool root_surface_has_no_visible_damage = |
| 816 !root_surface->GetDamageRect().Intersects(root_surface->content_rect()); | 800 !root_surface->GetDamageRect().Intersects(root_surface->content_rect()); |
| 817 bool root_surface_has_contributing_layers = | 801 bool root_surface_has_contributing_layers = |
| 818 !root_surface->layer_list().empty(); | 802 !root_surface->layer_list().empty(); |
| 819 bool hud_wants_to_draw_ = active_tree_->hud_layer() && | 803 bool hud_wants_to_draw_ = active_tree_->hud_layer() && |
| 820 active_tree_->hud_layer()->IsAnimatingHUDContents(); | 804 active_tree_->hud_layer()->IsAnimatingHUDContents(); |
| (...skipping 3478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4299 } | 4283 } |
| 4300 | 4284 |
| 4301 void LayerTreeHostImpl::UpdateScrollSourceInfo(bool is_wheel_scroll) { | 4285 void LayerTreeHostImpl::UpdateScrollSourceInfo(bool is_wheel_scroll) { |
| 4302 if (is_wheel_scroll) | 4286 if (is_wheel_scroll) |
| 4303 has_scrolled_by_wheel_ = true; | 4287 has_scrolled_by_wheel_ = true; |
| 4304 else | 4288 else |
| 4305 has_scrolled_by_touch_ = true; | 4289 has_scrolled_by_touch_ = true; |
| 4306 } | 4290 } |
| 4307 | 4291 |
| 4308 } // namespace cc | 4292 } // namespace cc |
| OLD | NEW |