Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Side by Side Diff: cc/trees/layer_tree_host_impl.cc

Issue 2834123002: cc: Replace render surface layer list with a render surface list (Closed)
Patch Set: Address review comments Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 scroll_on_main_thread); 156 scroll_on_main_thread);
157 } 157 }
158 } 158 }
159 159
160 } // namespace 160 } // namespace
161 161
162 DEFINE_SCOPED_UMA_HISTOGRAM_TIMER(PendingTreeDurationHistogramTimer, 162 DEFINE_SCOPED_UMA_HISTOGRAM_TIMER(PendingTreeDurationHistogramTimer,
163 "Scheduling.%s.PendingTreeDuration"); 163 "Scheduling.%s.PendingTreeDuration");
164 164
165 LayerTreeHostImpl::FrameData::FrameData() 165 LayerTreeHostImpl::FrameData::FrameData()
166 : render_surface_layer_list(nullptr), 166 : render_surface_list(nullptr),
167 has_no_damage(false), 167 has_no_damage(false),
168 may_contain_video(false) {} 168 may_contain_video(false) {}
169 169
170 LayerTreeHostImpl::FrameData::~FrameData() {} 170 LayerTreeHostImpl::FrameData::~FrameData() {}
171 171
172 std::unique_ptr<LayerTreeHostImpl> LayerTreeHostImpl::Create( 172 std::unique_ptr<LayerTreeHostImpl> LayerTreeHostImpl::Create(
173 const LayerTreeSettings& settings, 173 const LayerTreeSettings& settings,
174 LayerTreeHostImplClient* client, 174 LayerTreeHostImplClient* client,
175 TaskRunnerProvider* task_runner_provider, 175 TaskRunnerProvider* task_runner_provider,
176 RenderingStatsInstrumentation* rendering_stats_instrumentation, 176 RenderingStatsInstrumentation* rendering_stats_instrumentation,
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 DrawResult LayerTreeHostImpl::CalculateRenderPasses(FrameData* frame) { 773 DrawResult LayerTreeHostImpl::CalculateRenderPasses(FrameData* frame) {
774 DCHECK(frame->render_passes.empty()); 774 DCHECK(frame->render_passes.empty());
775 DCHECK(CanDraw()); 775 DCHECK(CanDraw());
776 DCHECK(!active_tree_->LayerListIsEmpty()); 776 DCHECK(!active_tree_->LayerListIsEmpty());
777 777
778 // For now, we use damage tracking to compute a global scissor. To do this, we 778 // For now, we use damage tracking to compute a global scissor. To do this, we
779 // must compute all damage tracking before drawing anything, so that we know 779 // must compute all damage tracking before drawing anything, so that we know
780 // the root damage rect. The root damage rect is then used to scissor each 780 // the root damage rect. The root damage rect is then used to scissor each
781 // surface. 781 // surface.
782 DamageTracker::UpdateDamageTracking(active_tree_.get(), 782 DamageTracker::UpdateDamageTracking(active_tree_.get(),
783 active_tree_->RenderSurfaceLayerList()); 783 active_tree_->GetRenderSurfaceList());
784 784
785 // If the root render surface has no visible damage, then don't generate a 785 // If the root render surface has no visible damage, then don't generate a
786 // frame at all. 786 // frame at all.
787 RenderSurfaceImpl* root_surface = active_tree_->RootRenderSurface(); 787 RenderSurfaceImpl* root_surface = active_tree_->RootRenderSurface();
788 bool root_surface_has_no_visible_damage = 788 bool root_surface_has_no_visible_damage =
789 !root_surface->GetDamageRect().Intersects(root_surface->content_rect()); 789 !root_surface->GetDamageRect().Intersects(root_surface->content_rect());
790 bool root_surface_has_contributing_layers = 790 bool root_surface_has_contributing_layers =
791 !root_surface->layer_list().empty(); 791 !!root_surface->num_contributors();
792 bool hud_wants_to_draw_ = active_tree_->hud_layer() && 792 bool hud_wants_to_draw_ = active_tree_->hud_layer() &&
793 active_tree_->hud_layer()->IsAnimatingHUDContents(); 793 active_tree_->hud_layer()->IsAnimatingHUDContents();
794 bool must_always_swap = 794 bool must_always_swap =
795 compositor_frame_sink_->capabilities().must_always_swap; 795 compositor_frame_sink_->capabilities().must_always_swap;
796 // When touch handle visibility changes there is no visible damage 796 // When touch handle visibility changes there is no visible damage
797 // because touch handles are composited in the browser. However we 797 // because touch handles are composited in the browser. However we
798 // still want the browser to be notified that the handles changed 798 // still want the browser to be notified that the handles changed
799 // through the |ViewHostMsg_SwapCompositorFrame| IPC so we keep 799 // through the |ViewHostMsg_SwapCompositorFrame| IPC so we keep
800 // track of handle visibility changes through |handle_visibility_changed|. 800 // track of handle visibility changes through |handle_visibility_changed|.
801 bool handle_visibility_changed = 801 bool handle_visibility_changed =
802 active_tree_->GetAndResetHandleVisibilityChanged(); 802 active_tree_->GetAndResetHandleVisibilityChanged();
803 if (root_surface_has_contributing_layers && 803 if (root_surface_has_contributing_layers &&
804 root_surface_has_no_visible_damage && 804 root_surface_has_no_visible_damage &&
805 !active_tree_->property_trees()->effect_tree.HasCopyRequests() && 805 !active_tree_->property_trees()->effect_tree.HasCopyRequests() &&
806 !must_always_swap && !hud_wants_to_draw_ && !handle_visibility_changed) { 806 !must_always_swap && !hud_wants_to_draw_ && !handle_visibility_changed) {
807 TRACE_EVENT0("cc", 807 TRACE_EVENT0("cc",
808 "LayerTreeHostImpl::CalculateRenderPasses::EmptyDamageRect"); 808 "LayerTreeHostImpl::CalculateRenderPasses::EmptyDamageRect");
809 frame->has_no_damage = true; 809 frame->has_no_damage = true;
810 DCHECK(!resourceless_software_draw_); 810 DCHECK(!resourceless_software_draw_);
811 return DRAW_SUCCESS; 811 return DRAW_SUCCESS;
812 } 812 }
813 813
814 TRACE_EVENT_BEGIN2( 814 TRACE_EVENT_BEGIN2("cc", "LayerTreeHostImpl::CalculateRenderPasses",
815 "cc", "LayerTreeHostImpl::CalculateRenderPasses", 815 "render_surface_list.size()",
816 "render_surface_layer_list.size()", 816 static_cast<uint64_t>(frame->render_surface_list->size()),
817 static_cast<uint64_t>(frame->render_surface_layer_list->size()), 817 "RequiresHighResToDraw", RequiresHighResToDraw());
818 "RequiresHighResToDraw", RequiresHighResToDraw());
819 818
820 // Create the render passes in dependency order. 819 // Create the render passes in dependency order.
821 size_t render_surface_layer_list_size = 820 size_t render_surface_list_size = frame->render_surface_list->size();
822 frame->render_surface_layer_list->size(); 821 for (size_t i = 0; i < render_surface_list_size; ++i) {
823 for (size_t i = 0; i < render_surface_layer_list_size; ++i) { 822 size_t surface_index = render_surface_list_size - 1 - i;
824 size_t surface_index = render_surface_layer_list_size - 1 - i;
825 LayerImpl* render_surface_layer =
826 (*frame->render_surface_layer_list)[surface_index];
827 RenderSurfaceImpl* render_surface = 823 RenderSurfaceImpl* render_surface =
828 render_surface_layer->GetRenderSurface(); 824 (*frame->render_surface_list)[surface_index];
829 825
826 bool is_root_surface =
827 render_surface->EffectTreeIndex() == EffectTree::kContentsRootNodeId;
830 bool should_draw_into_render_pass = 828 bool should_draw_into_render_pass =
831 active_tree_->IsRootLayer(render_surface_layer) || 829 is_root_surface || render_surface->contributes_to_drawn_surface() ||
832 render_surface->contributes_to_drawn_surface() ||
833 render_surface->HasCopyRequest(); 830 render_surface->HasCopyRequest();
834 if (should_draw_into_render_pass) 831 if (should_draw_into_render_pass)
835 frame->render_passes.push_back(render_surface->CreateRenderPass()); 832 frame->render_passes.push_back(render_surface->CreateRenderPass());
836 } 833 }
837 834
838 // Damage rects for non-root passes aren't meaningful, so set them to be 835 // Damage rects for non-root passes aren't meaningful, so set them to be
839 // equal to the output rect. 836 // equal to the output rect.
840 for (size_t i = 0; i + 1 < frame->render_passes.size(); ++i) { 837 for (size_t i = 0; i + 1 < frame->render_passes.size(); ++i) {
841 RenderPass* pass = frame->render_passes[i].get(); 838 RenderPass* pass = frame->render_passes[i].get();
842 pass->damage_rect = pass->output_rect; 839 pass->damage_rect = pass->output_rect;
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 1103
1107 bool update_lcd_text = false; 1104 bool update_lcd_text = false;
1108 bool ok = active_tree_->UpdateDrawProperties(update_lcd_text); 1105 bool ok = active_tree_->UpdateDrawProperties(update_lcd_text);
1109 DCHECK(ok) << "UpdateDrawProperties failed during draw"; 1106 DCHECK(ok) << "UpdateDrawProperties failed during draw";
1110 1107
1111 // This will cause NotifyTileStateChanged() to be called for any tiles that 1108 // This will cause NotifyTileStateChanged() to be called for any tiles that
1112 // completed, which will add damage for visible tiles to the frame for them so 1109 // completed, which will add damage for visible tiles to the frame for them so
1113 // they appear as part of the current frame being drawn. 1110 // they appear as part of the current frame being drawn.
1114 tile_manager_.Flush(); 1111 tile_manager_.Flush();
1115 1112
1116 frame->render_surface_layer_list = &active_tree_->RenderSurfaceLayerList(); 1113 frame->render_surface_list = &active_tree_->GetRenderSurfaceList();
1117 frame->render_passes.clear(); 1114 frame->render_passes.clear();
1118 frame->will_draw_layers.clear(); 1115 frame->will_draw_layers.clear();
1119 frame->has_no_damage = false; 1116 frame->has_no_damage = false;
1120 frame->may_contain_video = false; 1117 frame->may_contain_video = false;
1121 1118
1122 if (active_tree_->RootRenderSurface()) { 1119 if (active_tree_->RootRenderSurface()) {
1123 gfx::Rect device_viewport_damage_rect = viewport_damage_rect_; 1120 gfx::Rect device_viewport_damage_rect = viewport_damage_rect_;
1124 viewport_damage_rect_ = gfx::Rect(); 1121 viewport_damage_rect_ = gfx::Rect();
1125 1122
1126 active_tree_->RootRenderSurface()->damage_tracker()->AddDamageNextUpdate( 1123 active_tree_->RootRenderSurface()->damage_tracker()->AddDamageNextUpdate(
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 } 1649 }
1653 1650
1654 fps_counter_->SaveTimeStamp(CurrentBeginFrameArgs().frame_time, 1651 fps_counter_->SaveTimeStamp(CurrentBeginFrameArgs().frame_time,
1655 !compositor_frame_sink_->context_provider()); 1652 !compositor_frame_sink_->context_provider());
1656 rendering_stats_instrumentation_->IncrementFrameCount(1); 1653 rendering_stats_instrumentation_->IncrementFrameCount(1);
1657 1654
1658 memory_history_->SaveEntry(tile_manager_.memory_stats_from_last_assign()); 1655 memory_history_->SaveEntry(tile_manager_.memory_stats_from_last_assign());
1659 1656
1660 if (debug_state_.ShowHudRects()) { 1657 if (debug_state_.ShowHudRects()) {
1661 debug_rect_history_->SaveDebugRectsForCurrentFrame( 1658 debug_rect_history_->SaveDebugRectsForCurrentFrame(
1662 active_tree(), active_tree_->hud_layer(), 1659 active_tree(), active_tree_->hud_layer(), *frame->render_surface_list,
1663 *frame->render_surface_layer_list, debug_state_); 1660 debug_state_);
1664 } 1661 }
1665 1662
1666 bool is_new_trace; 1663 bool is_new_trace;
1667 TRACE_EVENT_IS_NEW_TRACE(&is_new_trace); 1664 TRACE_EVENT_IS_NEW_TRACE(&is_new_trace);
1668 if (is_new_trace) { 1665 if (is_new_trace) {
1669 if (pending_tree_) { 1666 if (pending_tree_) {
1670 LayerTreeHostCommon::CallFunctionForEveryLayer( 1667 LayerTreeHostCommon::CallFunctionForEveryLayer(
1671 pending_tree(), [](LayerImpl* layer) { layer->DidBeginTracing(); }); 1668 pending_tree(), [](LayerImpl* layer) { layer->DidBeginTracing(); });
1672 } 1669 }
1673 LayerTreeHostCommon::CallFunctionForEveryLayer( 1670 LayerTreeHostCommon::CallFunctionForEveryLayer(
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1737 compositor_frame_sink_->SubmitCompositorFrame(std::move(compositor_frame)); 1734 compositor_frame_sink_->SubmitCompositorFrame(std::move(compositor_frame));
1738 1735
1739 // Clears the list of swap promises after calling DidSwap on each of them to 1736 // Clears the list of swap promises after calling DidSwap on each of them to
1740 // signal that the swap is over. 1737 // signal that the swap is over.
1741 active_tree()->ClearSwapPromises(); 1738 active_tree()->ClearSwapPromises();
1742 1739
1743 // The next frame should start by assuming nothing has changed, and changes 1740 // The next frame should start by assuming nothing has changed, and changes
1744 // are noted as they occur. 1741 // are noted as they occur.
1745 // TODO(boliu): If we did a temporary software renderer frame, propogate the 1742 // TODO(boliu): If we did a temporary software renderer frame, propogate the
1746 // damage forward to the next frame. 1743 // damage forward to the next frame.
1747 for (size_t i = 0; i < frame->render_surface_layer_list->size(); i++) { 1744 for (size_t i = 0; i < frame->render_surface_list->size(); i++) {
1748 auto* surface = (*frame->render_surface_layer_list)[i]->GetRenderSurface(); 1745 auto* surface = (*frame->render_surface_list)[i];
1749 surface->damage_tracker()->DidDrawDamagedArea(); 1746 surface->damage_tracker()->DidDrawDamagedArea();
1750 } 1747 }
1751 active_tree_->ResetAllChangeTracking(); 1748 active_tree_->ResetAllChangeTracking();
1752 1749
1753 active_tree_->set_has_ever_been_drawn(true); 1750 active_tree_->set_has_ever_been_drawn(true);
1754 devtools_instrumentation::DidDrawFrame(id_); 1751 devtools_instrumentation::DidDrawFrame(id_);
1755 benchmark_instrumentation::IssueImplThreadRenderingStatsEvent( 1752 benchmark_instrumentation::IssueImplThreadRenderingStatsEvent(
1756 rendering_stats_instrumentation_->impl_thread_rendering_stats()); 1753 rendering_stats_instrumentation_->impl_thread_rendering_stats());
1757 rendering_stats_instrumentation_->AccumulateAndClearImplThreadStats(); 1754 rendering_stats_instrumentation_->AccumulateAndClearImplThreadStats();
1758 return true; 1755 return true;
(...skipping 2540 matching lines...) Expand 10 before | Expand all | Expand 10 after
4299 } 4296 }
4300 4297
4301 void LayerTreeHostImpl::UpdateScrollSourceInfo(bool is_wheel_scroll) { 4298 void LayerTreeHostImpl::UpdateScrollSourceInfo(bool is_wheel_scroll) {
4302 if (is_wheel_scroll) 4299 if (is_wheel_scroll)
4303 has_scrolled_by_wheel_ = true; 4300 has_scrolled_by_wheel_ = true;
4304 else 4301 else
4305 has_scrolled_by_touch_ = true; 4302 has_scrolled_by_touch_ = true;
4306 } 4303 }
4307 4304
4308 } // namespace cc 4305 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698