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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 output_is_secure_(false), | 233 output_is_secure_(false), |
234 animation_host_(), | 234 animation_host_(), |
235 rendering_stats_instrumentation_(rendering_stats_instrumentation), | 235 rendering_stats_instrumentation_(rendering_stats_instrumentation), |
236 micro_benchmark_controller_(this), | 236 micro_benchmark_controller_(this), |
237 shared_bitmap_manager_(shared_bitmap_manager), | 237 shared_bitmap_manager_(shared_bitmap_manager), |
238 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), | 238 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), |
239 task_graph_runner_(task_graph_runner), | 239 task_graph_runner_(task_graph_runner), |
240 id_(id), | 240 id_(id), |
241 requires_high_res_to_draw_(false), | 241 requires_high_res_to_draw_(false), |
242 is_likely_to_require_a_draw_(false), | 242 is_likely_to_require_a_draw_(false), |
243 frame_timing_tracker_(FrameTimingTracker::Create(this)), | |
244 mutator_(nullptr) { | 243 mutator_(nullptr) { |
245 animation_host_ = AnimationHost::Create(ThreadInstance::IMPL); | 244 animation_host_ = AnimationHost::Create(ThreadInstance::IMPL); |
246 animation_host_->SetMutatorHostClient(this); | 245 animation_host_->SetMutatorHostClient(this); |
247 animation_host_->SetSupportsScrollAnimations(SupportsImplScrolling()); | 246 animation_host_->SetSupportsScrollAnimations(SupportsImplScrolling()); |
248 | 247 |
249 DCHECK(task_runner_provider_->IsImplThread()); | 248 DCHECK(task_runner_provider_->IsImplThread()); |
250 DidVisibilityChange(this, visible_); | 249 DidVisibilityChange(this, visible_); |
251 | 250 |
252 SetDebugState(settings.initial_debug_state); | 251 SetDebugState(settings.initial_debug_state); |
253 | 252 |
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
893 } else if (it.represents_itself() && !it->visible_layer_rect().IsEmpty()) { | 892 } else if (it.represents_itself() && !it->visible_layer_rect().IsEmpty()) { |
894 bool occluded = | 893 bool occluded = |
895 it->draw_properties().occlusion_in_content_space.IsOccluded( | 894 it->draw_properties().occlusion_in_content_space.IsOccluded( |
896 it->visible_layer_rect()); | 895 it->visible_layer_rect()); |
897 if (!occluded && it->WillDraw(draw_mode, resource_provider_.get())) { | 896 if (!occluded && it->WillDraw(draw_mode, resource_provider_.get())) { |
898 DCHECK_EQ(active_tree_.get(), it->layer_tree_impl()); | 897 DCHECK_EQ(active_tree_.get(), it->layer_tree_impl()); |
899 | 898 |
900 frame->will_draw_layers.push_back(*it); | 899 frame->will_draw_layers.push_back(*it); |
901 | 900 |
902 it->AppendQuads(target_render_pass, &append_quads_data); | 901 it->AppendQuads(target_render_pass, &append_quads_data); |
903 | |
904 // For layers that represent themselves, add composite frame timing | |
905 // requests if the visible rect intersects the requested rect. | |
906 for (const auto& request : it->frame_timing_requests()) { | |
907 if (request.rect().Intersects(it->visible_layer_rect())) { | |
908 frame->composite_events.push_back( | |
909 FrameTimingTracker::FrameAndRectIds( | |
910 active_tree_->source_frame_number(), request.id())); | |
911 } | |
912 } | |
913 } | 902 } |
914 | 903 |
915 ++layers_drawn; | 904 ++layers_drawn; |
916 } | 905 } |
917 | 906 |
918 rendering_stats_instrumentation_->AddVisibleContentArea( | 907 rendering_stats_instrumentation_->AddVisibleContentArea( |
919 append_quads_data.visible_layer_area); | 908 append_quads_data.visible_layer_area); |
920 rendering_stats_instrumentation_->AddApproximatedVisibleContentArea( | 909 rendering_stats_instrumentation_->AddApproximatedVisibleContentArea( |
921 append_quads_data.approximated_visible_content_area); | 910 append_quads_data.approximated_visible_content_area); |
922 rendering_stats_instrumentation_->AddCheckerboardedVisibleContentArea( | 911 rendering_stats_instrumentation_->AddCheckerboardedVisibleContentArea( |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1604 | 1593 |
1605 return metadata; | 1594 return metadata; |
1606 } | 1595 } |
1607 | 1596 |
1608 void LayerTreeHostImpl::DrawLayers(FrameData* frame) { | 1597 void LayerTreeHostImpl::DrawLayers(FrameData* frame) { |
1609 TRACE_EVENT0("cc", "LayerTreeHostImpl::DrawLayers"); | 1598 TRACE_EVENT0("cc", "LayerTreeHostImpl::DrawLayers"); |
1610 | 1599 |
1611 base::TimeTicks frame_begin_time = CurrentBeginFrameArgs().frame_time; | 1600 base::TimeTicks frame_begin_time = CurrentBeginFrameArgs().frame_time; |
1612 DCHECK(CanDraw()); | 1601 DCHECK(CanDraw()); |
1613 | 1602 |
1614 if (!frame->composite_events.empty()) { | |
1615 frame_timing_tracker_->SaveTimeStamps(frame_begin_time, | |
1616 frame->composite_events); | |
1617 } | |
1618 | |
1619 if (frame->has_no_damage) { | 1603 if (frame->has_no_damage) { |
1620 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NoDamage", TRACE_EVENT_SCOPE_THREAD); | 1604 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NoDamage", TRACE_EVENT_SCOPE_THREAD); |
1621 DCHECK(!resourceless_software_draw_); | 1605 DCHECK(!resourceless_software_draw_); |
1622 return; | 1606 return; |
1623 } | 1607 } |
1624 | 1608 |
1625 DCHECK(!frame->render_passes.empty()); | 1609 DCHECK(!frame->render_passes.empty()); |
1626 | 1610 |
1627 fps_counter_->SaveTimeStamp(frame_begin_time, | 1611 fps_counter_->SaveTimeStamp(frame_begin_time, |
1628 !output_surface_->context_provider()); | 1612 !output_surface_->context_provider()); |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2243 int max_copy_texture_chromium_size = context_provider->ContextCapabilities() | 2227 int max_copy_texture_chromium_size = context_provider->ContextCapabilities() |
2244 .gpu.max_copy_texture_chromium_size; | 2228 .gpu.max_copy_texture_chromium_size; |
2245 | 2229 |
2246 *tile_task_worker_pool = OneCopyTileTaskWorkerPool::Create( | 2230 *tile_task_worker_pool = OneCopyTileTaskWorkerPool::Create( |
2247 GetTaskRunner(), task_graph_runner, context_provider, | 2231 GetTaskRunner(), task_graph_runner, context_provider, |
2248 resource_provider_.get(), max_copy_texture_chromium_size, | 2232 resource_provider_.get(), max_copy_texture_chromium_size, |
2249 settings_.use_partial_raster, settings_.max_staging_buffer_usage_in_bytes, | 2233 settings_.use_partial_raster, settings_.max_staging_buffer_usage_in_bytes, |
2250 settings_.renderer_settings.preferred_tile_format); | 2234 settings_.renderer_settings.preferred_tile_format); |
2251 } | 2235 } |
2252 | 2236 |
2253 void LayerTreeHostImpl::RecordMainFrameTiming( | |
2254 const BeginFrameArgs& start_of_main_frame_args, | |
2255 const BeginFrameArgs& expected_next_main_frame_args) { | |
2256 std::vector<int64_t> request_ids; | |
2257 active_tree_->GatherFrameTimingRequestIds(&request_ids); | |
2258 if (request_ids.empty()) | |
2259 return; | |
2260 | |
2261 base::TimeTicks start_time = start_of_main_frame_args.frame_time; | |
2262 base::TimeTicks end_time = expected_next_main_frame_args.frame_time; | |
2263 frame_timing_tracker_->SaveMainFrameTimeStamps( | |
2264 request_ids, start_time, end_time, active_tree_->source_frame_number()); | |
2265 } | |
2266 | |
2267 void LayerTreeHostImpl::PostFrameTimingEvents( | |
2268 std::unique_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, | |
2269 std::unique_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { | |
2270 client_->PostFrameTimingEventsOnImplThread(std::move(composite_events), | |
2271 std::move(main_frame_events)); | |
2272 } | |
2273 | |
2274 void LayerTreeHostImpl::SetLayerTreeMutator(LayerTreeMutator* mutator) { | 2237 void LayerTreeHostImpl::SetLayerTreeMutator(LayerTreeMutator* mutator) { |
2275 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), | 2238 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), |
2276 "LayerTreeHostImpl::SetLayerTreeMutator"); | 2239 "LayerTreeHostImpl::SetLayerTreeMutator"); |
2277 mutator_ = mutator; | 2240 mutator_ = mutator; |
2278 } | 2241 } |
2279 | 2242 |
2280 void LayerTreeHostImpl::CleanUpTileManagerAndUIResources() { | 2243 void LayerTreeHostImpl::CleanUpTileManagerAndUIResources() { |
2281 ClearUIResources(); | 2244 ClearUIResources(); |
2282 tile_manager_->FinishTasksAndCleanUp(); | 2245 tile_manager_->FinishTasksAndCleanUp(); |
2283 resource_pool_ = nullptr; | 2246 resource_pool_ = nullptr; |
(...skipping 1696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3980 return task_runner_provider_->HasImplThread(); | 3943 return task_runner_provider_->HasImplThread(); |
3981 } | 3944 } |
3982 | 3945 |
3983 bool LayerTreeHostImpl::CommitToActiveTree() const { | 3946 bool LayerTreeHostImpl::CommitToActiveTree() const { |
3984 // In single threaded mode we skip the pending tree and commit directly to the | 3947 // In single threaded mode we skip the pending tree and commit directly to the |
3985 // active tree. | 3948 // active tree. |
3986 return !task_runner_provider_->HasImplThread(); | 3949 return !task_runner_provider_->HasImplThread(); |
3987 } | 3950 } |
3988 | 3951 |
3989 } // namespace cc | 3952 } // namespace cc |
OLD | NEW |