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

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

Issue 61823008: Introduce separate client and init path for single-threaded cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « cc/trees/layer_tree_host.h ('k') | cc/trees/layer_tree_host_client.h » ('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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 bitmap_ = make_scoped_ptr(new UIResourceBitmap(*request.bitmap_.get())); 91 bitmap_ = make_scoped_ptr(new UIResourceBitmap(*request.bitmap_.get()));
92 } else { 92 } else {
93 bitmap_.reset(); 93 bitmap_.reset();
94 } 94 }
95 95
96 return *this; 96 return *this;
97 } 97 }
98 98
99 UIResourceRequest::~UIResourceRequest() {} 99 UIResourceRequest::~UIResourceRequest() {}
100 100
101 scoped_ptr<LayerTreeHost> LayerTreeHost::Create( 101 scoped_ptr<LayerTreeHost> LayerTreeHost::CreateThreaded(
102 LayerTreeHostClient* client, 102 LayerTreeHostClient* client,
103 SharedBitmapManager* manager, 103 SharedBitmapManager* manager,
104 const LayerTreeSettings& settings, 104 const LayerTreeSettings& settings,
105 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { 105 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) {
106 DCHECK(impl_task_runner);
106 scoped_ptr<LayerTreeHost> layer_tree_host( 107 scoped_ptr<LayerTreeHost> layer_tree_host(
107 new LayerTreeHost(client, manager, settings)); 108 new LayerTreeHost(client, manager, settings));
108 if (!layer_tree_host->Initialize(impl_task_runner)) 109 if (!layer_tree_host->InitializeThreaded(impl_task_runner))
109 return scoped_ptr<LayerTreeHost>(); 110 return scoped_ptr<LayerTreeHost>();
110 return layer_tree_host.Pass(); 111 return layer_tree_host.Pass();
111 } 112 }
112 113
113 LayerTreeHost::LayerTreeHost(LayerTreeHostClient* client, 114 scoped_ptr<LayerTreeHost> LayerTreeHost::CreateSingleThreaded(
114 SharedBitmapManager* manager, 115 LayerTreeHostClient* client,
115 const LayerTreeSettings& settings) 116 LayerTreeHostSingleThreadClient* single_thread_client,
117 SharedBitmapManager* manager,
118 const LayerTreeSettings& settings) {
119 scoped_ptr<LayerTreeHost> layer_tree_host(
120 new LayerTreeHost(client, manager, settings));
121 if (!layer_tree_host->InitializeSingleThreaded(single_thread_client))
122 return scoped_ptr<LayerTreeHost>();
123 return layer_tree_host.Pass();
124 }
125
126
127 LayerTreeHost::LayerTreeHost(
128 LayerTreeHostClient* client,
129 SharedBitmapManager* manager,
130 const LayerTreeSettings& settings)
116 : next_ui_resource_id_(1), 131 : next_ui_resource_id_(1),
117 animating_(false), 132 animating_(false),
118 needs_full_tree_sync_(true), 133 needs_full_tree_sync_(true),
119 needs_filter_context_(false), 134 needs_filter_context_(false),
120 client_(client), 135 client_(client),
121 source_frame_number_(0), 136 source_frame_number_(0),
122 rendering_stats_instrumentation_(RenderingStatsInstrumentation::Create()), 137 rendering_stats_instrumentation_(RenderingStatsInstrumentation::Create()),
123 micro_benchmark_controller_(this), 138 micro_benchmark_controller_(this),
124 output_surface_can_be_initialized_(true), 139 output_surface_can_be_initialized_(true),
125 output_surface_lost_(true), 140 output_surface_lost_(true),
(...skipping 14 matching lines...) Expand all
140 total_frames_used_for_lcd_text_metrics_(0), 155 total_frames_used_for_lcd_text_metrics_(0),
141 tree_id_(GetNextTreeId()), 156 tree_id_(GetNextTreeId()),
142 next_commit_forces_redraw_(false), 157 next_commit_forces_redraw_(false),
143 shared_bitmap_manager_(manager) { 158 shared_bitmap_manager_(manager) {
144 if (settings_.accelerated_animation_enabled) 159 if (settings_.accelerated_animation_enabled)
145 animation_registrar_ = AnimationRegistrar::Create(); 160 animation_registrar_ = AnimationRegistrar::Create();
146 rendering_stats_instrumentation_->set_record_rendering_stats( 161 rendering_stats_instrumentation_->set_record_rendering_stats(
147 debug_state_.RecordRenderingStats()); 162 debug_state_.RecordRenderingStats());
148 } 163 }
149 164
150 bool LayerTreeHost::Initialize( 165 bool LayerTreeHost::InitializeThreaded(
151 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { 166 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) {
152 if (impl_task_runner.get()) 167 return InitializeProxy(ThreadProxy::Create(this, impl_task_runner));
153 return InitializeProxy(ThreadProxy::Create(this, impl_task_runner)); 168 }
154 else 169
155 return InitializeProxy(SingleThreadProxy::Create(this)); 170 bool LayerTreeHost::InitializeSingleThreaded(
171 LayerTreeHostSingleThreadClient* single_thread_client) {
172 return InitializeProxy(
173 SingleThreadProxy::Create(this, single_thread_client));
156 } 174 }
157 175
158 bool LayerTreeHost::InitializeForTesting(scoped_ptr<Proxy> proxy_for_testing) { 176 bool LayerTreeHost::InitializeForTesting(scoped_ptr<Proxy> proxy_for_testing) {
159 return InitializeProxy(proxy_for_testing.Pass()); 177 return InitializeProxy(proxy_for_testing.Pass());
160 } 178 }
161 179
162 bool LayerTreeHost::InitializeProxy(scoped_ptr<Proxy> proxy) { 180 bool LayerTreeHost::InitializeProxy(scoped_ptr<Proxy> proxy) {
163 TRACE_EVENT0("cc", "LayerTreeHost::InitializeForReal"); 181 TRACE_EVENT0("cc", "LayerTreeHost::InitializeForReal");
164 182
165 scoped_ptr<OutputSurface> output_surface(CreateOutputSurface()); 183 scoped_ptr<OutputSurface> output_surface(CreateOutputSurface());
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 needs_full_tree_sync_ = true; 573 needs_full_tree_sync_ = true;
556 SetNeedsCommit(); 574 SetNeedsCommit();
557 } 575 }
558 576
559 void LayerTreeHost::SetNeedsRedraw() { 577 void LayerTreeHost::SetNeedsRedraw() {
560 SetNeedsRedrawRect(gfx::Rect(device_viewport_size_)); 578 SetNeedsRedrawRect(gfx::Rect(device_viewport_size_));
561 } 579 }
562 580
563 void LayerTreeHost::SetNeedsRedrawRect(gfx::Rect damage_rect) { 581 void LayerTreeHost::SetNeedsRedrawRect(gfx::Rect damage_rect) {
564 proxy_->SetNeedsRedraw(damage_rect); 582 proxy_->SetNeedsRedraw(damage_rect);
565 if (!proxy_->HasImplThread())
566 client_->ScheduleComposite();
567 } 583 }
568 584
569 bool LayerTreeHost::CommitRequested() const { 585 bool LayerTreeHost::CommitRequested() const {
570 return proxy_->CommitRequested(); 586 return proxy_->CommitRequested();
571 } 587 }
572 588
573 bool LayerTreeHost::BeginMainFrameRequested() const { 589 bool LayerTreeHost::BeginMainFrameRequested() const {
574 return proxy_->BeginMainFrameRequested(); 590 return proxy_->BeginMainFrameRequested();
575 } 591 }
576 592
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 } 748 }
733 749
734 void LayerTreeHost::Composite(base::TimeTicks frame_begin_time) { 750 void LayerTreeHost::Composite(base::TimeTicks frame_begin_time) {
735 if (!proxy_->HasImplThread()) 751 if (!proxy_->HasImplThread())
736 static_cast<SingleThreadProxy*>(proxy_.get())->CompositeImmediately( 752 static_cast<SingleThreadProxy*>(proxy_.get())->CompositeImmediately(
737 frame_begin_time); 753 frame_begin_time);
738 else 754 else
739 SetNeedsCommit(); 755 SetNeedsCommit();
740 } 756 }
741 757
742 void LayerTreeHost::ScheduleComposite() {
743 client_->ScheduleComposite();
744 }
745
746 bool LayerTreeHost::InitializeOutputSurfaceIfNeeded() { 758 bool LayerTreeHost::InitializeOutputSurfaceIfNeeded() {
747 if (!output_surface_can_be_initialized_) 759 if (!output_surface_can_be_initialized_)
748 return false; 760 return false;
749 761
750 if (output_surface_lost_) 762 if (output_surface_lost_)
751 proxy_->CreateAndInitializeOutputSurface(); 763 proxy_->CreateAndInitializeOutputSurface();
752 return !output_surface_lost_; 764 return !output_surface_lost_;
753 } 765 }
754 766
755 bool LayerTreeHost::UpdateLayers(ResourceUpdateQueue* queue) { 767 bool LayerTreeHost::UpdateLayers(ResourceUpdateQueue* queue) {
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
1274 1286
1275 bool LayerTreeHost::ScheduleMicroBenchmark( 1287 bool LayerTreeHost::ScheduleMicroBenchmark(
1276 const std::string& benchmark_name, 1288 const std::string& benchmark_name,
1277 scoped_ptr<base::Value> value, 1289 scoped_ptr<base::Value> value,
1278 const MicroBenchmark::DoneCallback& callback) { 1290 const MicroBenchmark::DoneCallback& callback) {
1279 return micro_benchmark_controller_.ScheduleRun( 1291 return micro_benchmark_controller_.ScheduleRun(
1280 benchmark_name, value.Pass(), callback); 1292 benchmark_name, value.Pass(), callback);
1281 } 1293 }
1282 1294
1283 } // namespace cc 1295 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host.h ('k') | cc/trees/layer_tree_host_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698