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

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

Issue 1464313007: cc: Introduce CompositorMode enum. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change ui::MockLayerTreeHost Created 5 years 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.h ('k') | ui/android/resources/resource_manager_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.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <stack> 8 #include <stack>
9 #include <string> 9 #include <string>
10 10
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 LayerTreeHost::InitParams::~InitParams() { 60 LayerTreeHost::InitParams::~InitParams() {
61 } 61 }
62 62
63 scoped_ptr<LayerTreeHost> LayerTreeHost::CreateThreaded( 63 scoped_ptr<LayerTreeHost> LayerTreeHost::CreateThreaded(
64 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, 64 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner,
65 InitParams* params) { 65 InitParams* params) {
66 DCHECK(params->main_task_runner.get()); 66 DCHECK(params->main_task_runner.get());
67 DCHECK(impl_task_runner.get()); 67 DCHECK(impl_task_runner.get());
68 DCHECK(params->settings); 68 DCHECK(params->settings);
69 scoped_ptr<LayerTreeHost> layer_tree_host(new LayerTreeHost(params)); 69 scoped_ptr<LayerTreeHost> layer_tree_host(
70 new LayerTreeHost(params, CompositorMode::Threaded));
70 layer_tree_host->InitializeThreaded( 71 layer_tree_host->InitializeThreaded(
71 params->main_task_runner, impl_task_runner, 72 params->main_task_runner, impl_task_runner,
72 std::move(params->external_begin_frame_source)); 73 std::move(params->external_begin_frame_source));
73 return layer_tree_host; 74 return layer_tree_host;
74 } 75 }
75 76
76 scoped_ptr<LayerTreeHost> LayerTreeHost::CreateSingleThreaded( 77 scoped_ptr<LayerTreeHost> LayerTreeHost::CreateSingleThreaded(
77 LayerTreeHostSingleThreadClient* single_thread_client, 78 LayerTreeHostSingleThreadClient* single_thread_client,
78 InitParams* params) { 79 InitParams* params) {
79 DCHECK(params->settings); 80 DCHECK(params->settings);
80 scoped_ptr<LayerTreeHost> layer_tree_host(new LayerTreeHost(params)); 81 scoped_ptr<LayerTreeHost> layer_tree_host(
82 new LayerTreeHost(params, CompositorMode::SingleThreaded));
81 layer_tree_host->InitializeSingleThreaded( 83 layer_tree_host->InitializeSingleThreaded(
82 single_thread_client, params->main_task_runner, 84 single_thread_client, params->main_task_runner,
83 std::move(params->external_begin_frame_source)); 85 std::move(params->external_begin_frame_source));
84 return layer_tree_host; 86 return layer_tree_host;
85 } 87 }
86 88
87 LayerTreeHost::LayerTreeHost(InitParams* params) 89 LayerTreeHost::LayerTreeHost(InitParams* params, CompositorMode mode)
88 : micro_benchmark_controller_(this), 90 : micro_benchmark_controller_(this),
89 next_ui_resource_id_(1), 91 next_ui_resource_id_(1),
92 compositor_mode_(mode),
90 needs_full_tree_sync_(true), 93 needs_full_tree_sync_(true),
91 needs_meta_info_recomputation_(true), 94 needs_meta_info_recomputation_(true),
92 client_(params->client), 95 client_(params->client),
93 source_frame_number_(0), 96 source_frame_number_(0),
94 meta_information_sequence_number_(1), 97 meta_information_sequence_number_(1),
95 rendering_stats_instrumentation_(RenderingStatsInstrumentation::Create()), 98 rendering_stats_instrumentation_(RenderingStatsInstrumentation::Create()),
96 output_surface_lost_(true), 99 output_surface_lost_(true),
97 settings_(*params->settings), 100 settings_(*params->settings),
98 debug_state_(settings_.initial_debug_state), 101 debug_state_(settings_.initial_debug_state),
99 top_controls_shrink_blink_size_(false), 102 top_controls_shrink_blink_size_(false),
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 duration)); 670 duration));
668 671
669 SetNeedsCommit(); 672 SetNeedsCommit();
670 } 673 }
671 674
672 void LayerTreeHost::NotifyInputThrottledUntilCommit() { 675 void LayerTreeHost::NotifyInputThrottledUntilCommit() {
673 proxy_->NotifyInputThrottledUntilCommit(); 676 proxy_->NotifyInputThrottledUntilCommit();
674 } 677 }
675 678
676 void LayerTreeHost::LayoutAndUpdateLayers() { 679 void LayerTreeHost::LayoutAndUpdateLayers() {
677 DCHECK(!task_runner_provider_->HasImplThread()); 680 DCHECK(IsSingleThreaded());
678 // This function is only valid when not using the scheduler. 681 // This function is only valid when not using the scheduler.
679 DCHECK(!settings_.single_thread_proxy_scheduler); 682 DCHECK(!settings_.single_thread_proxy_scheduler);
680 SingleThreadProxy* proxy = static_cast<SingleThreadProxy*>(proxy_.get()); 683 SingleThreadProxy* proxy = static_cast<SingleThreadProxy*>(proxy_.get());
681 684
682 if (output_surface_lost()) { 685 if (output_surface_lost()) {
683 proxy->RequestNewOutputSurface(); 686 proxy->RequestNewOutputSurface();
684 // RequestNewOutputSurface could have synchronously created an output 687 // RequestNewOutputSurface could have synchronously created an output
685 // surface, so check again before returning. 688 // surface, so check again before returning.
686 if (output_surface_lost()) 689 if (output_surface_lost())
687 return; 690 return;
688 } 691 }
689 692
690 RequestMainFrameUpdate(); 693 RequestMainFrameUpdate();
691 UpdateLayers(); 694 UpdateLayers();
692 } 695 }
693 696
694 void LayerTreeHost::Composite(base::TimeTicks frame_begin_time) { 697 void LayerTreeHost::Composite(base::TimeTicks frame_begin_time) {
695 DCHECK(!task_runner_provider_->HasImplThread()); 698 DCHECK(IsSingleThreaded());
696 // This function is only valid when not using the scheduler. 699 // This function is only valid when not using the scheduler.
697 DCHECK(!settings_.single_thread_proxy_scheduler); 700 DCHECK(!settings_.single_thread_proxy_scheduler);
698 SingleThreadProxy* proxy = static_cast<SingleThreadProxy*>(proxy_.get()); 701 SingleThreadProxy* proxy = static_cast<SingleThreadProxy*>(proxy_.get());
699 702
700 proxy->CompositeImmediately(frame_begin_time); 703 proxy->CompositeImmediately(frame_begin_time);
701 } 704 }
702 705
703 bool LayerTreeHost::UpdateLayers() { 706 bool LayerTreeHost::UpdateLayers() {
704 DCHECK(!output_surface_lost_); 707 DCHECK(!output_surface_lost_);
705 if (!root_layer()) 708 if (!root_layer())
(...skipping 19 matching lines...) Expand all
725 Layer* found = FindFirstScrollableLayer(layer->children()[i].get()); 728 Layer* found = FindFirstScrollableLayer(layer->children()[i].get());
726 if (found) 729 if (found)
727 return found; 730 return found;
728 } 731 }
729 732
730 return NULL; 733 return NULL;
731 } 734 }
732 735
733 void LayerTreeHost::RecordGpuRasterizationHistogram() { 736 void LayerTreeHost::RecordGpuRasterizationHistogram() {
734 // Gpu rasterization is only supported for Renderer compositors. 737 // Gpu rasterization is only supported for Renderer compositors.
735 // Checking for proxy_->HasImplThread() to exclude Browser compositors. 738 // Checking for IsThreaded() to exclude Browser compositors.
736 if (gpu_rasterization_histogram_recorded_ || 739 if (gpu_rasterization_histogram_recorded_ || IsThreaded())
737 !task_runner_provider_->HasImplThread())
738 return; 740 return;
739 741
740 // Record how widely gpu rasterization is enabled. 742 // Record how widely gpu rasterization is enabled.
741 // This number takes device/gpu whitelisting/backlisting into account. 743 // This number takes device/gpu whitelisting/backlisting into account.
742 // Note that we do not consider the forced gpu rasterization mode, which is 744 // Note that we do not consider the forced gpu rasterization mode, which is
743 // mostly used for debugging purposes. 745 // mostly used for debugging purposes.
744 UMA_HISTOGRAM_BOOLEAN("Renderer4.GpuRasterizationEnabled", 746 UMA_HISTOGRAM_BOOLEAN("Renderer4.GpuRasterizationEnabled",
745 settings_.gpu_rasterization_enabled); 747 settings_.gpu_rasterization_enabled);
746 if (settings_.gpu_rasterization_enabled) { 748 if (settings_.gpu_rasterization_enabled) {
747 UMA_HISTOGRAM_BOOLEAN("Renderer4.GpuRasterizationTriggered", 749 UMA_HISTOGRAM_BOOLEAN("Renderer4.GpuRasterizationTriggered",
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 return; 895 return;
894 painted_device_scale_factor_ = painted_device_scale_factor; 896 painted_device_scale_factor_ = painted_device_scale_factor;
895 897
896 SetNeedsCommit(); 898 SetNeedsCommit();
897 } 899 }
898 900
899 void LayerTreeHost::UpdateTopControlsState(TopControlsState constraints, 901 void LayerTreeHost::UpdateTopControlsState(TopControlsState constraints,
900 TopControlsState current, 902 TopControlsState current,
901 bool animate) { 903 bool animate) {
902 // Top controls are only used in threaded mode. 904 // Top controls are only used in threaded mode.
903 DCHECK(task_runner_provider_->HasImplThread()); 905 DCHECK(IsThreaded());
904 proxy_->UpdateTopControlsState(constraints, current, animate); 906 proxy_->UpdateTopControlsState(constraints, current, animate);
905 } 907 }
906 908
907 void LayerTreeHost::AnimateLayers(base::TimeTicks monotonic_time) { 909 void LayerTreeHost::AnimateLayers(base::TimeTicks monotonic_time) {
908 if (!settings_.accelerated_animation_enabled) 910 if (!settings_.accelerated_animation_enabled)
909 return; 911 return;
910 912
911 AnimationEventsVector events; 913 AnimationEventsVector events;
912 if (animation_host_) { 914 if (animation_host_) {
913 if (animation_host_->AnimateLayers(monotonic_time)) 915 if (animation_host_->AnimateLayers(monotonic_time))
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 bool LayerTreeHost::HasAnyAnimation(const Layer* layer) const { 1246 bool LayerTreeHost::HasAnyAnimation(const Layer* layer) const {
1245 return animation_host_ ? animation_host_->HasAnyAnimation(layer->id()) 1247 return animation_host_ ? animation_host_->HasAnyAnimation(layer->id())
1246 : false; 1248 : false;
1247 } 1249 }
1248 1250
1249 bool LayerTreeHost::HasActiveAnimation(const Layer* layer) const { 1251 bool LayerTreeHost::HasActiveAnimation(const Layer* layer) const {
1250 return animation_host_ ? animation_host_->HasActiveAnimation(layer->id()) 1252 return animation_host_ ? animation_host_->HasActiveAnimation(layer->id())
1251 : false; 1253 : false;
1252 } 1254 }
1253 1255
1256 bool LayerTreeHost::IsSingleThreaded() const {
1257 DCHECK(compositor_mode_ != CompositorMode::SingleThreaded ||
1258 !task_runner_provider_->HasImplThread());
1259 return compositor_mode_ == CompositorMode::SingleThreaded;
1260 }
1261
1262 bool LayerTreeHost::IsThreaded() const {
1263 DCHECK(compositor_mode_ != CompositorMode::Threaded ||
1264 task_runner_provider_->HasImplThread());
1265 return compositor_mode_ == CompositorMode::Threaded;
1266 }
1267
1254 } // namespace cc 1268 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host.h ('k') | ui/android/resources/resource_manager_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698