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

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

Issue 2650303002: cc: Remove the LayerTreeHost abstraction. (Closed)
Patch Set: missed ui Created 3 years, 11 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.h ('k') | cc/trees/layer_tree_host_in_process.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_in_process.h" 5 #include "cc/trees/layer_tree_host.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>
11 #include <memory> 11 #include <memory>
12 #include <stack> 12 #include <stack>
13 #include <string> 13 #include <string>
14 #include <unordered_map> 14 #include <unordered_map>
15 15
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 #include "cc/trees/tree_synchronizer.h" 54 #include "cc/trees/tree_synchronizer.h"
55 #include "ui/gfx/geometry/size_conversions.h" 55 #include "ui/gfx/geometry/size_conversions.h"
56 #include "ui/gfx/geometry/vector2d_conversions.h" 56 #include "ui/gfx/geometry/vector2d_conversions.h"
57 57
58 namespace { 58 namespace {
59 static base::StaticAtomicSequenceNumber s_layer_tree_host_sequence_number; 59 static base::StaticAtomicSequenceNumber s_layer_tree_host_sequence_number;
60 } 60 }
61 61
62 namespace cc { 62 namespace cc {
63 63
64 LayerTreeHostInProcess::InitParams::InitParams() {} 64 LayerTreeHost::InitParams::InitParams() {}
65 65
66 LayerTreeHostInProcess::InitParams::~InitParams() {} 66 LayerTreeHost::InitParams::~InitParams() {}
67 67
68 std::unique_ptr<LayerTreeHostInProcess> LayerTreeHostInProcess::CreateThreaded( 68 std::unique_ptr<LayerTreeHost> LayerTreeHost::CreateThreaded(
69 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, 69 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner,
70 InitParams* params) { 70 InitParams* params) {
71 DCHECK(params->main_task_runner.get()); 71 DCHECK(params->main_task_runner.get());
72 DCHECK(impl_task_runner.get()); 72 DCHECK(impl_task_runner.get());
73 DCHECK(params->settings); 73 DCHECK(params->settings);
74 std::unique_ptr<LayerTreeHostInProcess> layer_tree_host( 74 std::unique_ptr<LayerTreeHost> layer_tree_host(
75 new LayerTreeHostInProcess(params, CompositorMode::THREADED)); 75 new LayerTreeHost(params, CompositorMode::THREADED));
76 layer_tree_host->InitializeThreaded(params->main_task_runner, 76 layer_tree_host->InitializeThreaded(params->main_task_runner,
77 impl_task_runner); 77 impl_task_runner);
78 return layer_tree_host; 78 return layer_tree_host;
79 } 79 }
80 80
81 std::unique_ptr<LayerTreeHostInProcess> 81 std::unique_ptr<LayerTreeHost>
82 LayerTreeHostInProcess::CreateSingleThreaded( 82 LayerTreeHost::CreateSingleThreaded(
83 LayerTreeHostSingleThreadClient* single_thread_client, 83 LayerTreeHostSingleThreadClient* single_thread_client,
84 InitParams* params) { 84 InitParams* params) {
85 DCHECK(params->settings); 85 DCHECK(params->settings);
86 std::unique_ptr<LayerTreeHostInProcess> layer_tree_host( 86 std::unique_ptr<LayerTreeHost> layer_tree_host(
87 new LayerTreeHostInProcess(params, CompositorMode::SINGLE_THREADED)); 87 new LayerTreeHost(params, CompositorMode::SINGLE_THREADED));
88 layer_tree_host->InitializeSingleThreaded(single_thread_client, 88 layer_tree_host->InitializeSingleThreaded(single_thread_client,
89 params->main_task_runner); 89 params->main_task_runner);
90 return layer_tree_host; 90 return layer_tree_host;
91 } 91 }
92 92
93 LayerTreeHostInProcess::LayerTreeHostInProcess(InitParams* params, 93 LayerTreeHost::LayerTreeHost(InitParams* params,
94 CompositorMode mode) 94 CompositorMode mode)
95 : LayerTreeHostInProcess( 95 : LayerTreeHost(
96 params, 96 params,
97 mode, 97 mode,
98 base::MakeUnique<LayerTree>(params->mutator_host, this)) {} 98 base::MakeUnique<LayerTree>(params->mutator_host, this)) {}
99 99
100 LayerTreeHostInProcess::LayerTreeHostInProcess( 100 LayerTreeHost::LayerTreeHost(
101 InitParams* params, 101 InitParams* params,
102 CompositorMode mode, 102 CompositorMode mode,
103 std::unique_ptr<LayerTree> layer_tree) 103 std::unique_ptr<LayerTree> layer_tree)
104 : micro_benchmark_controller_(this), 104 : micro_benchmark_controller_(this),
105 layer_tree_(std::move(layer_tree)), 105 layer_tree_(std::move(layer_tree)),
106 compositor_mode_(mode), 106 compositor_mode_(mode),
107 ui_resource_manager_(base::MakeUnique<UIResourceManager>()), 107 ui_resource_manager_(base::MakeUnique<UIResourceManager>()),
108 client_(params->client), 108 client_(params->client),
109 source_frame_number_(0), 109 source_frame_number_(0),
110 rendering_stats_instrumentation_(RenderingStatsInstrumentation::Create()), 110 rendering_stats_instrumentation_(RenderingStatsInstrumentation::Create()),
111 settings_(*params->settings), 111 settings_(*params->settings),
112 debug_state_(settings_.initial_debug_state), 112 debug_state_(settings_.initial_debug_state),
113 visible_(false), 113 visible_(false),
114 has_gpu_rasterization_trigger_(false), 114 has_gpu_rasterization_trigger_(false),
115 content_is_suitable_for_gpu_rasterization_(true), 115 content_is_suitable_for_gpu_rasterization_(true),
116 gpu_rasterization_histogram_recorded_(false), 116 gpu_rasterization_histogram_recorded_(false),
117 did_complete_scale_animation_(false), 117 did_complete_scale_animation_(false),
118 id_(s_layer_tree_host_sequence_number.GetNext() + 1), 118 id_(s_layer_tree_host_sequence_number.GetNext() + 1),
119 task_graph_runner_(params->task_graph_runner), 119 task_graph_runner_(params->task_graph_runner),
120 image_worker_task_runner_(params->image_worker_task_runner) { 120 image_worker_task_runner_(params->image_worker_task_runner) {
121 DCHECK(task_graph_runner_); 121 DCHECK(task_graph_runner_);
122 DCHECK(layer_tree_); 122 DCHECK(layer_tree_);
123 123
124 rendering_stats_instrumentation_->set_record_rendering_stats( 124 rendering_stats_instrumentation_->set_record_rendering_stats(
125 debug_state_.RecordRenderingStats()); 125 debug_state_.RecordRenderingStats());
126 } 126 }
127 127
128 void LayerTreeHostInProcess::InitializeThreaded( 128 void LayerTreeHost::InitializeThreaded(
129 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 129 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
130 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { 130 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) {
131 task_runner_provider_ = 131 task_runner_provider_ =
132 TaskRunnerProvider::Create(main_task_runner, impl_task_runner); 132 TaskRunnerProvider::Create(main_task_runner, impl_task_runner);
133 std::unique_ptr<ProxyMain> proxy_main = 133 std::unique_ptr<ProxyMain> proxy_main =
134 base::MakeUnique<ProxyMain>(this, task_runner_provider_.get()); 134 base::MakeUnique<ProxyMain>(this, task_runner_provider_.get());
135 InitializeProxy(std::move(proxy_main)); 135 InitializeProxy(std::move(proxy_main));
136 } 136 }
137 137
138 void LayerTreeHostInProcess::InitializeSingleThreaded( 138 void LayerTreeHost::InitializeSingleThreaded(
139 LayerTreeHostSingleThreadClient* single_thread_client, 139 LayerTreeHostSingleThreadClient* single_thread_client,
140 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) { 140 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) {
141 task_runner_provider_ = TaskRunnerProvider::Create(main_task_runner, nullptr); 141 task_runner_provider_ = TaskRunnerProvider::Create(main_task_runner, nullptr);
142 InitializeProxy(SingleThreadProxy::Create(this, single_thread_client, 142 InitializeProxy(SingleThreadProxy::Create(this, single_thread_client,
143 task_runner_provider_.get())); 143 task_runner_provider_.get()));
144 } 144 }
145 145
146 void LayerTreeHostInProcess::InitializeForTesting( 146 void LayerTreeHost::InitializeForTesting(
147 std::unique_ptr<TaskRunnerProvider> task_runner_provider, 147 std::unique_ptr<TaskRunnerProvider> task_runner_provider,
148 std::unique_ptr<Proxy> proxy_for_testing) { 148 std::unique_ptr<Proxy> proxy_for_testing) {
149 task_runner_provider_ = std::move(task_runner_provider); 149 task_runner_provider_ = std::move(task_runner_provider);
150 InitializeProxy(std::move(proxy_for_testing)); 150 InitializeProxy(std::move(proxy_for_testing));
151 } 151 }
152 152
153 void LayerTreeHostInProcess::SetTaskRunnerProviderForTesting( 153 void LayerTreeHost::SetTaskRunnerProviderForTesting(
154 std::unique_ptr<TaskRunnerProvider> task_runner_provider) { 154 std::unique_ptr<TaskRunnerProvider> task_runner_provider) {
155 DCHECK(!task_runner_provider_); 155 DCHECK(!task_runner_provider_);
156 task_runner_provider_ = std::move(task_runner_provider); 156 task_runner_provider_ = std::move(task_runner_provider);
157 } 157 }
158 158
159 void LayerTreeHostInProcess::SetUIResourceManagerForTesting( 159 void LayerTreeHost::SetUIResourceManagerForTesting(
160 std::unique_ptr<UIResourceManager> ui_resource_manager) { 160 std::unique_ptr<UIResourceManager> ui_resource_manager) {
161 ui_resource_manager_ = std::move(ui_resource_manager); 161 ui_resource_manager_ = std::move(ui_resource_manager);
162 } 162 }
163 163
164 void LayerTreeHostInProcess::InitializeProxy(std::unique_ptr<Proxy> proxy) { 164 void LayerTreeHost::InitializeProxy(std::unique_ptr<Proxy> proxy) {
165 TRACE_EVENT0("cc", "LayerTreeHostInProcess::InitializeForReal"); 165 TRACE_EVENT0("cc", "LayerTreeHostInProcess::InitializeForReal");
166 DCHECK(task_runner_provider_); 166 DCHECK(task_runner_provider_);
167 167
168 proxy_ = std::move(proxy); 168 proxy_ = std::move(proxy);
169 proxy_->Start(); 169 proxy_->Start();
170 170
171 layer_tree_->mutator_host()->SetSupportsScrollAnimations( 171 layer_tree_->mutator_host()->SetSupportsScrollAnimations(
172 proxy_->SupportsImplScrolling()); 172 proxy_->SupportsImplScrolling());
173 } 173 }
174 174
175 LayerTreeHostInProcess::~LayerTreeHostInProcess() { 175 LayerTreeHost::~LayerTreeHost() {
176 // Track when we're inside a main frame to see if compositor is being 176 // Track when we're inside a main frame to see if compositor is being
177 // destroyed midway which causes a crash. crbug.com/654672 177 // destroyed midway which causes a crash. crbug.com/654672
178 CHECK(!inside_main_frame_); 178 CHECK(!inside_main_frame_);
179 TRACE_EVENT0("cc", "LayerTreeHostInProcess::~LayerTreeHostInProcess"); 179 TRACE_EVENT0("cc", "LayerTreeHostInProcess::~LayerTreeHostInProcess");
180 180
181 // Clear any references into the LayerTreeHostInProcess. 181 // Clear any references into the LayerTreeHostInProcess.
182 layer_tree_.reset(); 182 layer_tree_.reset();
183 183
184 if (proxy_) { 184 if (proxy_) {
185 DCHECK(task_runner_provider_->IsMainThread()); 185 DCHECK(task_runner_provider_->IsMainThread());
186 proxy_->Stop(); 186 proxy_->Stop();
187 187
188 // Proxy must be destroyed before the Task Runner Provider. 188 // Proxy must be destroyed before the Task Runner Provider.
189 proxy_ = nullptr; 189 proxy_ = nullptr;
190 } 190 }
191 } 191 }
192 192
193 int LayerTreeHostInProcess::GetId() const { 193 int LayerTreeHost::GetId() const {
194 return id_; 194 return id_;
195 } 195 }
196 196
197 int LayerTreeHostInProcess::SourceFrameNumber() const { 197 int LayerTreeHost::SourceFrameNumber() const {
198 return source_frame_number_; 198 return source_frame_number_;
199 } 199 }
200 200
201 LayerTree* LayerTreeHostInProcess::GetLayerTree() { 201 LayerTree* LayerTreeHost::GetLayerTree() {
202 return layer_tree_.get(); 202 return layer_tree_.get();
203 } 203 }
204 204
205 const LayerTree* LayerTreeHostInProcess::GetLayerTree() const { 205 const LayerTree* LayerTreeHost::GetLayerTree() const {
206 return layer_tree_.get(); 206 return layer_tree_.get();
207 } 207 }
208 208
209 UIResourceManager* LayerTreeHostInProcess::GetUIResourceManager() const { 209 UIResourceManager* LayerTreeHost::GetUIResourceManager() const {
210 return ui_resource_manager_.get(); 210 return ui_resource_manager_.get();
211 } 211 }
212 212
213 TaskRunnerProvider* LayerTreeHostInProcess::GetTaskRunnerProvider() const { 213 TaskRunnerProvider* LayerTreeHost::GetTaskRunnerProvider() const {
214 return task_runner_provider_.get(); 214 return task_runner_provider_.get();
215 } 215 }
216 216
217 SwapPromiseManager* LayerTreeHostInProcess::GetSwapPromiseManager() { 217 SwapPromiseManager* LayerTreeHost::GetSwapPromiseManager() {
218 return &swap_promise_manager_; 218 return &swap_promise_manager_;
219 } 219 }
220 220
221 const LayerTreeSettings& LayerTreeHostInProcess::GetSettings() const { 221 const LayerTreeSettings& LayerTreeHost::GetSettings() const {
222 return settings_; 222 return settings_;
223 } 223 }
224 224
225 void LayerTreeHostInProcess::SetFrameSinkId(const FrameSinkId& frame_sink_id) { 225 void LayerTreeHost::SetFrameSinkId(const FrameSinkId& frame_sink_id) {
226 surface_sequence_generator_.set_frame_sink_id(frame_sink_id); 226 surface_sequence_generator_.set_frame_sink_id(frame_sink_id);
227 } 227 }
228 228
229 void LayerTreeHostInProcess::QueueSwapPromise( 229 void LayerTreeHost::QueueSwapPromise(
230 std::unique_ptr<SwapPromise> swap_promise) { 230 std::unique_ptr<SwapPromise> swap_promise) {
231 swap_promise_manager_.QueueSwapPromise(std::move(swap_promise)); 231 swap_promise_manager_.QueueSwapPromise(std::move(swap_promise));
232 } 232 }
233 233
234 SurfaceSequenceGenerator* 234 SurfaceSequenceGenerator*
235 LayerTreeHostInProcess::GetSurfaceSequenceGenerator() { 235 LayerTreeHost::GetSurfaceSequenceGenerator() {
236 return &surface_sequence_generator_; 236 return &surface_sequence_generator_;
237 } 237 }
238 238
239 void LayerTreeHostInProcess::WillBeginMainFrame() { 239 void LayerTreeHost::WillBeginMainFrame() {
240 inside_main_frame_ = true; 240 inside_main_frame_ = true;
241 devtools_instrumentation::WillBeginMainThreadFrame(GetId(), 241 devtools_instrumentation::WillBeginMainThreadFrame(GetId(),
242 SourceFrameNumber()); 242 SourceFrameNumber());
243 client_->WillBeginMainFrame(); 243 client_->WillBeginMainFrame();
244 } 244 }
245 245
246 void LayerTreeHostInProcess::DidBeginMainFrame() { 246 void LayerTreeHost::DidBeginMainFrame() {
247 inside_main_frame_ = false; 247 inside_main_frame_ = false;
248 client_->DidBeginMainFrame(); 248 client_->DidBeginMainFrame();
249 } 249 }
250 250
251 void LayerTreeHostInProcess::BeginMainFrameNotExpectedSoon() { 251 void LayerTreeHost::BeginMainFrameNotExpectedSoon() {
252 client_->BeginMainFrameNotExpectedSoon(); 252 client_->BeginMainFrameNotExpectedSoon();
253 } 253 }
254 254
255 void LayerTreeHostInProcess::BeginMainFrame(const BeginFrameArgs& args) { 255 void LayerTreeHost::BeginMainFrame(const BeginFrameArgs& args) {
256 client_->BeginMainFrame(args); 256 client_->BeginMainFrame(args);
257 } 257 }
258 258
259 void LayerTreeHostInProcess::DidStopFlinging() { 259 void LayerTreeHost::DidStopFlinging() {
260 proxy_->MainThreadHasStoppedFlinging(); 260 proxy_->MainThreadHasStoppedFlinging();
261 } 261 }
262 262
263 const LayerTreeDebugState& LayerTreeHostInProcess::GetDebugState() const { 263 const LayerTreeDebugState& LayerTreeHost::GetDebugState() const {
264 return debug_state_; 264 return debug_state_;
265 } 265 }
266 266
267 void LayerTreeHostInProcess::RequestMainFrameUpdate() { 267 void LayerTreeHost::RequestMainFrameUpdate() {
268 client_->UpdateLayerTreeHost(); 268 client_->UpdateLayerTreeHost();
269 } 269 }
270 270
271 // This function commits the LayerTreeHost to an impl tree. When modifying 271 // This function commits the LayerTreeHost to an impl tree. When modifying
272 // this function, keep in mind that the function *runs* on the impl thread! Any 272 // this function, keep in mind that the function *runs* on the impl thread! Any
273 // code that is logically a main thread operation, e.g. deletion of a Layer, 273 // code that is logically a main thread operation, e.g. deletion of a Layer,
274 // should be delayed until the LayerTreeHostInProcess::CommitComplete, which 274 // should be delayed until the LayerTreeHostInProcess::CommitComplete, which
275 // will run after the commit, but on the main thread. 275 // will run after the commit, but on the main thread.
276 void LayerTreeHostInProcess::FinishCommitOnImplThread( 276 void LayerTreeHost::FinishCommitOnImplThread(
277 LayerTreeHostImpl* host_impl) { 277 LayerTreeHostImpl* host_impl) {
278 DCHECK(task_runner_provider_->IsImplThread()); 278 DCHECK(task_runner_provider_->IsImplThread());
279 279
280 bool is_new_trace; 280 bool is_new_trace;
281 TRACE_EVENT_IS_NEW_TRACE(&is_new_trace); 281 TRACE_EVENT_IS_NEW_TRACE(&is_new_trace);
282 if (is_new_trace && 282 if (is_new_trace &&
283 frame_viewer_instrumentation::IsTracingLayerTreeSnapshots() && 283 frame_viewer_instrumentation::IsTracingLayerTreeSnapshots() &&
284 layer_tree_->root_layer()) { 284 layer_tree_->root_layer()) {
285 LayerTreeHostCommon::CallFunctionForEveryLayer( 285 LayerTreeHostCommon::CallFunctionForEveryLayer(
286 layer_tree_.get(), [](Layer* layer) { layer->DidBeginTracing(); }); 286 layer_tree_.get(), [](Layer* layer) { layer->DidBeginTracing(); });
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 337
338 TRACE_EVENT0("cc", "LayerTreeHostInProcess::AnimationHost::PushProperties"); 338 TRACE_EVENT0("cc", "LayerTreeHostInProcess::AnimationHost::PushProperties");
339 DCHECK(host_impl->mutator_host()); 339 DCHECK(host_impl->mutator_host());
340 layer_tree_->mutator_host()->PushPropertiesTo(host_impl->mutator_host()); 340 layer_tree_->mutator_host()->PushPropertiesTo(host_impl->mutator_host());
341 } 341 }
342 342
343 micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl); 343 micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl);
344 layer_tree_->property_trees()->ResetAllChangeTracking(); 344 layer_tree_->property_trees()->ResetAllChangeTracking();
345 } 345 }
346 346
347 void LayerTreeHostInProcess::WillCommit() { 347 void LayerTreeHost::WillCommit() {
348 swap_promise_manager_.WillCommit(); 348 swap_promise_manager_.WillCommit();
349 client_->WillCommit(); 349 client_->WillCommit();
350 } 350 }
351 351
352 void LayerTreeHostInProcess::UpdateHudLayer() {} 352 void LayerTreeHost::UpdateHudLayer() {}
353 353
354 void LayerTreeHostInProcess::CommitComplete() { 354 void LayerTreeHost::CommitComplete() {
355 source_frame_number_++; 355 source_frame_number_++;
356 client_->DidCommit(); 356 client_->DidCommit();
357 if (did_complete_scale_animation_) { 357 if (did_complete_scale_animation_) {
358 client_->DidCompletePageScaleAnimation(); 358 client_->DidCompletePageScaleAnimation();
359 did_complete_scale_animation_ = false; 359 did_complete_scale_animation_ = false;
360 } 360 }
361 } 361 }
362 362
363 void LayerTreeHostInProcess::SetCompositorFrameSink( 363 void LayerTreeHost::SetCompositorFrameSink(
364 std::unique_ptr<CompositorFrameSink> surface) { 364 std::unique_ptr<CompositorFrameSink> surface) {
365 TRACE_EVENT0("cc", "LayerTreeHostInProcess::SetCompositorFrameSink"); 365 TRACE_EVENT0("cc", "LayerTreeHostInProcess::SetCompositorFrameSink");
366 DCHECK(surface); 366 DCHECK(surface);
367 367
368 DCHECK(!new_compositor_frame_sink_); 368 DCHECK(!new_compositor_frame_sink_);
369 new_compositor_frame_sink_ = std::move(surface); 369 new_compositor_frame_sink_ = std::move(surface);
370 proxy_->SetCompositorFrameSink(new_compositor_frame_sink_.get()); 370 proxy_->SetCompositorFrameSink(new_compositor_frame_sink_.get());
371 } 371 }
372 372
373 std::unique_ptr<CompositorFrameSink> 373 std::unique_ptr<CompositorFrameSink>
374 LayerTreeHostInProcess::ReleaseCompositorFrameSink() { 374 LayerTreeHost::ReleaseCompositorFrameSink() {
375 DCHECK(!visible_); 375 DCHECK(!visible_);
376 376
377 DidLoseCompositorFrameSink(); 377 DidLoseCompositorFrameSink();
378 proxy_->ReleaseCompositorFrameSink(); 378 proxy_->ReleaseCompositorFrameSink();
379 return std::move(current_compositor_frame_sink_); 379 return std::move(current_compositor_frame_sink_);
380 } 380 }
381 381
382 void LayerTreeHostInProcess::RequestNewCompositorFrameSink() { 382 void LayerTreeHost::RequestNewCompositorFrameSink() {
383 client_->RequestNewCompositorFrameSink(); 383 client_->RequestNewCompositorFrameSink();
384 } 384 }
385 385
386 void LayerTreeHostInProcess::DidInitializeCompositorFrameSink() { 386 void LayerTreeHost::DidInitializeCompositorFrameSink() {
387 DCHECK(new_compositor_frame_sink_); 387 DCHECK(new_compositor_frame_sink_);
388 current_compositor_frame_sink_ = std::move(new_compositor_frame_sink_); 388 current_compositor_frame_sink_ = std::move(new_compositor_frame_sink_);
389 client_->DidInitializeCompositorFrameSink(); 389 client_->DidInitializeCompositorFrameSink();
390 } 390 }
391 391
392 void LayerTreeHostInProcess::DidFailToInitializeCompositorFrameSink() { 392 void LayerTreeHost::DidFailToInitializeCompositorFrameSink() {
393 DCHECK(new_compositor_frame_sink_); 393 DCHECK(new_compositor_frame_sink_);
394 // Note: It is safe to drop all output surface references here as 394 // Note: It is safe to drop all output surface references here as
395 // LayerTreeHostImpl will not keep a pointer to either the old or 395 // LayerTreeHostImpl will not keep a pointer to either the old or
396 // new CompositorFrameSink after failing to initialize the new one. 396 // new CompositorFrameSink after failing to initialize the new one.
397 current_compositor_frame_sink_ = nullptr; 397 current_compositor_frame_sink_ = nullptr;
398 new_compositor_frame_sink_ = nullptr; 398 new_compositor_frame_sink_ = nullptr;
399 client_->DidFailToInitializeCompositorFrameSink(); 399 client_->DidFailToInitializeCompositorFrameSink();
400 } 400 }
401 401
402 std::unique_ptr<LayerTreeHostImpl> 402 std::unique_ptr<LayerTreeHostImpl>
403 LayerTreeHostInProcess::CreateLayerTreeHostImpl( 403 LayerTreeHost::CreateLayerTreeHostImpl(
404 LayerTreeHostImplClient* client) { 404 LayerTreeHostImplClient* client) {
405 DCHECK(task_runner_provider_->IsImplThread()); 405 DCHECK(task_runner_provider_->IsImplThread());
406 406
407 const bool supports_impl_scrolling = task_runner_provider_->HasImplThread(); 407 const bool supports_impl_scrolling = task_runner_provider_->HasImplThread();
408 std::unique_ptr<MutatorHost> mutator_host_impl = 408 std::unique_ptr<MutatorHost> mutator_host_impl =
409 layer_tree_->mutator_host()->CreateImplInstance(supports_impl_scrolling); 409 layer_tree_->mutator_host()->CreateImplInstance(supports_impl_scrolling);
410 410
411 std::unique_ptr<LayerTreeHostImpl> host_impl = LayerTreeHostImpl::Create( 411 std::unique_ptr<LayerTreeHostImpl> host_impl = LayerTreeHostImpl::Create(
412 settings_, client, task_runner_provider_.get(), 412 settings_, client, task_runner_provider_.get(),
413 rendering_stats_instrumentation_.get(), task_graph_runner_, 413 rendering_stats_instrumentation_.get(), task_graph_runner_,
414 std::move(mutator_host_impl), id_, std::move(image_worker_task_runner_)); 414 std::move(mutator_host_impl), id_, std::move(image_worker_task_runner_));
415 host_impl->SetHasGpuRasterizationTrigger(has_gpu_rasterization_trigger_); 415 host_impl->SetHasGpuRasterizationTrigger(has_gpu_rasterization_trigger_);
416 host_impl->SetContentIsSuitableForGpuRasterization( 416 host_impl->SetContentIsSuitableForGpuRasterization(
417 content_is_suitable_for_gpu_rasterization_); 417 content_is_suitable_for_gpu_rasterization_);
418 task_graph_runner_ = NULL; 418 task_graph_runner_ = NULL;
419 input_handler_weak_ptr_ = host_impl->AsWeakPtr(); 419 input_handler_weak_ptr_ = host_impl->AsWeakPtr();
420 return host_impl; 420 return host_impl;
421 } 421 }
422 422
423 void LayerTreeHostInProcess::DidLoseCompositorFrameSink() { 423 void LayerTreeHost::DidLoseCompositorFrameSink() {
424 TRACE_EVENT0("cc", "LayerTreeHostInProcess::DidLoseCompositorFrameSink"); 424 TRACE_EVENT0("cc", "LayerTreeHostInProcess::DidLoseCompositorFrameSink");
425 DCHECK(task_runner_provider_->IsMainThread()); 425 DCHECK(task_runner_provider_->IsMainThread());
426 SetNeedsCommit(); 426 SetNeedsCommit();
427 } 427 }
428 428
429 void LayerTreeHostInProcess::SetDeferCommits(bool defer_commits) { 429 void LayerTreeHost::SetDeferCommits(bool defer_commits) {
430 proxy_->SetDeferCommits(defer_commits); 430 proxy_->SetDeferCommits(defer_commits);
431 } 431 }
432 432
433 DISABLE_CFI_PERF 433 DISABLE_CFI_PERF
434 void LayerTreeHostInProcess::SetNeedsAnimate() { 434 void LayerTreeHost::SetNeedsAnimate() {
435 proxy_->SetNeedsAnimate(); 435 proxy_->SetNeedsAnimate();
436 swap_promise_manager_.NotifySwapPromiseMonitorsOfSetNeedsCommit(); 436 swap_promise_manager_.NotifySwapPromiseMonitorsOfSetNeedsCommit();
437 } 437 }
438 438
439 DISABLE_CFI_PERF 439 DISABLE_CFI_PERF
440 void LayerTreeHostInProcess::SetNeedsUpdateLayers() { 440 void LayerTreeHost::SetNeedsUpdateLayers() {
441 proxy_->SetNeedsUpdateLayers(); 441 proxy_->SetNeedsUpdateLayers();
442 swap_promise_manager_.NotifySwapPromiseMonitorsOfSetNeedsCommit(); 442 swap_promise_manager_.NotifySwapPromiseMonitorsOfSetNeedsCommit();
443 } 443 }
444 444
445 void LayerTreeHostInProcess::SetNeedsCommit() { 445 void LayerTreeHost::SetNeedsCommit() {
446 proxy_->SetNeedsCommit(); 446 proxy_->SetNeedsCommit();
447 swap_promise_manager_.NotifySwapPromiseMonitorsOfSetNeedsCommit(); 447 swap_promise_manager_.NotifySwapPromiseMonitorsOfSetNeedsCommit();
448 } 448 }
449 449
450 void LayerTreeHostInProcess::SetNeedsRecalculateRasterScales() { 450 void LayerTreeHost::SetNeedsRecalculateRasterScales() {
451 next_commit_forces_recalculate_raster_scales_ = true; 451 next_commit_forces_recalculate_raster_scales_ = true;
452 proxy_->SetNeedsCommit(); 452 proxy_->SetNeedsCommit();
453 } 453 }
454 454
455 void LayerTreeHostInProcess::SetNeedsRedrawRect(const gfx::Rect& damage_rect) { 455 void LayerTreeHost::SetNeedsRedrawRect(const gfx::Rect& damage_rect) {
456 proxy_->SetNeedsRedraw(damage_rect); 456 proxy_->SetNeedsRedraw(damage_rect);
457 } 457 }
458 458
459 bool LayerTreeHostInProcess::CommitRequested() const { 459 bool LayerTreeHost::CommitRequested() const {
460 return proxy_->CommitRequested(); 460 return proxy_->CommitRequested();
461 } 461 }
462 462
463 void LayerTreeHostInProcess::SetNextCommitWaitsForActivation() { 463 void LayerTreeHost::SetNextCommitWaitsForActivation() {
464 proxy_->SetNextCommitWaitsForActivation(); 464 proxy_->SetNextCommitWaitsForActivation();
465 } 465 }
466 466
467 void LayerTreeHostInProcess::SetNextCommitForcesRedraw() { 467 void LayerTreeHost::SetNextCommitForcesRedraw() {
468 next_commit_forces_redraw_ = true; 468 next_commit_forces_redraw_ = true;
469 proxy_->SetNeedsUpdateLayers(); 469 proxy_->SetNeedsUpdateLayers();
470 } 470 }
471 471
472 void LayerTreeHostInProcess::SetAnimationEvents( 472 void LayerTreeHost::SetAnimationEvents(
473 std::unique_ptr<MutatorEvents> events) { 473 std::unique_ptr<MutatorEvents> events) {
474 DCHECK(task_runner_provider_->IsMainThread()); 474 DCHECK(task_runner_provider_->IsMainThread());
475 layer_tree_->mutator_host()->SetAnimationEvents(std::move(events)); 475 layer_tree_->mutator_host()->SetAnimationEvents(std::move(events));
476 } 476 }
477 477
478 void LayerTreeHostInProcess::SetDebugState( 478 void LayerTreeHost::SetDebugState(
479 const LayerTreeDebugState& debug_state) { 479 const LayerTreeDebugState& debug_state) {
480 LayerTreeDebugState new_debug_state = 480 LayerTreeDebugState new_debug_state =
481 LayerTreeDebugState::Unite(settings_.initial_debug_state, debug_state); 481 LayerTreeDebugState::Unite(settings_.initial_debug_state, debug_state);
482 482
483 if (LayerTreeDebugState::Equal(debug_state_, new_debug_state)) 483 if (LayerTreeDebugState::Equal(debug_state_, new_debug_state))
484 return; 484 return;
485 485
486 debug_state_ = new_debug_state; 486 debug_state_ = new_debug_state;
487 487
488 rendering_stats_instrumentation_->set_record_rendering_stats( 488 rendering_stats_instrumentation_->set_record_rendering_stats(
489 debug_state_.RecordRenderingStats()); 489 debug_state_.RecordRenderingStats());
490 490
491 SetNeedsCommit(); 491 SetNeedsCommit();
492 } 492 }
493 493
494 void LayerTreeHostInProcess::ResetGpuRasterizationTracking() { 494 void LayerTreeHost::ResetGpuRasterizationTracking() {
495 content_is_suitable_for_gpu_rasterization_ = true; 495 content_is_suitable_for_gpu_rasterization_ = true;
496 gpu_rasterization_histogram_recorded_ = false; 496 gpu_rasterization_histogram_recorded_ = false;
497 } 497 }
498 498
499 void LayerTreeHostInProcess::SetHasGpuRasterizationTrigger(bool has_trigger) { 499 void LayerTreeHost::SetHasGpuRasterizationTrigger(bool has_trigger) {
500 if (has_trigger == has_gpu_rasterization_trigger_) 500 if (has_trigger == has_gpu_rasterization_trigger_)
501 return; 501 return;
502 502
503 has_gpu_rasterization_trigger_ = has_trigger; 503 has_gpu_rasterization_trigger_ = has_trigger;
504 TRACE_EVENT_INSTANT1( 504 TRACE_EVENT_INSTANT1(
505 "cc", "LayerTreeHostInProcess::SetHasGpuRasterizationTrigger", 505 "cc", "LayerTreeHostInProcess::SetHasGpuRasterizationTrigger",
506 TRACE_EVENT_SCOPE_THREAD, "has_trigger", has_gpu_rasterization_trigger_); 506 TRACE_EVENT_SCOPE_THREAD, "has_trigger", has_gpu_rasterization_trigger_);
507 } 507 }
508 508
509 void LayerTreeHostInProcess::ApplyPageScaleDeltaFromImplSide( 509 void LayerTreeHost::ApplyPageScaleDeltaFromImplSide(
510 float page_scale_delta) { 510 float page_scale_delta) {
511 DCHECK(CommitRequested()); 511 DCHECK(CommitRequested());
512 if (page_scale_delta == 1.f) 512 if (page_scale_delta == 1.f)
513 return; 513 return;
514 float page_scale = layer_tree_->page_scale_factor() * page_scale_delta; 514 float page_scale = layer_tree_->page_scale_factor() * page_scale_delta;
515 layer_tree_->SetPageScaleFromImplSide(page_scale); 515 layer_tree_->SetPageScaleFromImplSide(page_scale);
516 } 516 }
517 517
518 void LayerTreeHostInProcess::SetVisible(bool visible) { 518 void LayerTreeHost::SetVisible(bool visible) {
519 if (visible_ == visible) 519 if (visible_ == visible)
520 return; 520 return;
521 visible_ = visible; 521 visible_ = visible;
522 proxy_->SetVisible(visible); 522 proxy_->SetVisible(visible);
523 } 523 }
524 524
525 bool LayerTreeHostInProcess::IsVisible() const { 525 bool LayerTreeHost::IsVisible() const {
526 return visible_; 526 return visible_;
527 } 527 }
528 528
529 void LayerTreeHostInProcess::NotifyInputThrottledUntilCommit() { 529 void LayerTreeHost::NotifyInputThrottledUntilCommit() {
530 proxy_->NotifyInputThrottledUntilCommit(); 530 proxy_->NotifyInputThrottledUntilCommit();
531 } 531 }
532 532
533 void LayerTreeHostInProcess::LayoutAndUpdateLayers() { 533 void LayerTreeHost::LayoutAndUpdateLayers() {
534 DCHECK(IsSingleThreaded()); 534 DCHECK(IsSingleThreaded());
535 // This function is only valid when not using the scheduler. 535 // This function is only valid when not using the scheduler.
536 DCHECK(!settings_.single_thread_proxy_scheduler); 536 DCHECK(!settings_.single_thread_proxy_scheduler);
537 RequestMainFrameUpdate(); 537 RequestMainFrameUpdate();
538 UpdateLayers(); 538 UpdateLayers();
539 } 539 }
540 540
541 void LayerTreeHostInProcess::Composite(base::TimeTicks frame_begin_time) { 541 void LayerTreeHost::Composite(base::TimeTicks frame_begin_time) {
542 DCHECK(IsSingleThreaded()); 542 DCHECK(IsSingleThreaded());
543 // This function is only valid when not using the scheduler. 543 // This function is only valid when not using the scheduler.
544 DCHECK(!settings_.single_thread_proxy_scheduler); 544 DCHECK(!settings_.single_thread_proxy_scheduler);
545 SingleThreadProxy* proxy = static_cast<SingleThreadProxy*>(proxy_.get()); 545 SingleThreadProxy* proxy = static_cast<SingleThreadProxy*>(proxy_.get());
546 546
547 proxy->CompositeImmediately(frame_begin_time); 547 proxy->CompositeImmediately(frame_begin_time);
548 } 548 }
549 549
550 static int GetLayersUpdateTimeHistogramBucket(size_t numLayers) { 550 static int GetLayersUpdateTimeHistogramBucket(size_t numLayers) {
551 // We uses the following exponential (ratio 2) bucketization: 551 // We uses the following exponential (ratio 2) bucketization:
552 // [0, 10), [10, 30), [30, 70), [70, 150), [150, infinity) 552 // [0, 10), [10, 30), [30, 70), [70, 150), [150, infinity)
553 if (numLayers < 10) 553 if (numLayers < 10)
554 return 0; 554 return 0;
555 if (numLayers < 30) 555 if (numLayers < 30)
556 return 1; 556 return 1;
557 if (numLayers < 70) 557 if (numLayers < 70)
558 return 2; 558 return 2;
559 if (numLayers < 150) 559 if (numLayers < 150)
560 return 3; 560 return 3;
561 return 4; 561 return 4;
562 } 562 }
563 563
564 bool LayerTreeHostInProcess::UpdateLayers() { 564 bool LayerTreeHost::UpdateLayers() {
565 if (!layer_tree_->root_layer()) { 565 if (!layer_tree_->root_layer()) {
566 layer_tree_->property_trees()->clear(); 566 layer_tree_->property_trees()->clear();
567 return false; 567 return false;
568 } 568 }
569 DCHECK(!layer_tree_->root_layer()->parent()); 569 DCHECK(!layer_tree_->root_layer()->parent());
570 base::ElapsedTimer timer; 570 base::ElapsedTimer timer;
571 571
572 bool result = DoUpdateLayers(layer_tree_->root_layer()); 572 bool result = DoUpdateLayers(layer_tree_->root_layer());
573 micro_benchmark_controller_.DidUpdateLayers(); 573 micro_benchmark_controller_.DidUpdateLayers();
574 574
575 if (const char* client_name = GetClientNameForMetrics()) { 575 if (const char* client_name = GetClientNameForMetrics()) {
576 std::string histogram_name = base::StringPrintf( 576 std::string histogram_name = base::StringPrintf(
577 "Compositing.%s.LayersUpdateTime.%d", client_name, 577 "Compositing.%s.LayersUpdateTime.%d", client_name,
578 GetLayersUpdateTimeHistogramBucket(layer_tree_->NumLayers())); 578 GetLayersUpdateTimeHistogramBucket(layer_tree_->NumLayers()));
579 base::Histogram::FactoryGet(histogram_name, 0, 10000000, 50, 579 base::Histogram::FactoryGet(histogram_name, 0, 10000000, 50,
580 base::HistogramBase::kUmaTargetedHistogramFlag) 580 base::HistogramBase::kUmaTargetedHistogramFlag)
581 ->Add(timer.Elapsed().InMicroseconds()); 581 ->Add(timer.Elapsed().InMicroseconds());
582 } 582 }
583 583
584 return result || next_commit_forces_redraw_; 584 return result || next_commit_forces_redraw_;
585 } 585 }
586 586
587 void LayerTreeHostInProcess::DidCompletePageScaleAnimation() { 587 void LayerTreeHost::DidCompletePageScaleAnimation() {
588 did_complete_scale_animation_ = true; 588 did_complete_scale_animation_ = true;
589 } 589 }
590 590
591 void LayerTreeHostInProcess::RecordGpuRasterizationHistogram() { 591 void LayerTreeHost::RecordGpuRasterizationHistogram() {
592 // Gpu rasterization is only supported for Renderer compositors. 592 // Gpu rasterization is only supported for Renderer compositors.
593 // Checking for IsSingleThreaded() to exclude Browser compositors. 593 // Checking for IsSingleThreaded() to exclude Browser compositors.
594 if (gpu_rasterization_histogram_recorded_ || IsSingleThreaded()) 594 if (gpu_rasterization_histogram_recorded_ || IsSingleThreaded())
595 return; 595 return;
596 596
597 // Record how widely gpu rasterization is enabled. 597 // Record how widely gpu rasterization is enabled.
598 // This number takes device/gpu whitelisting/backlisting into account. 598 // This number takes device/gpu whitelisting/backlisting into account.
599 // Note that we do not consider the forced gpu rasterization mode, which is 599 // Note that we do not consider the forced gpu rasterization mode, which is
600 // mostly used for debugging purposes. 600 // mostly used for debugging purposes.
601 UMA_HISTOGRAM_BOOLEAN("Renderer4.GpuRasterizationEnabled", 601 UMA_HISTOGRAM_BOOLEAN("Renderer4.GpuRasterizationEnabled",
602 settings_.gpu_rasterization_enabled); 602 settings_.gpu_rasterization_enabled);
603 if (settings_.gpu_rasterization_enabled) { 603 if (settings_.gpu_rasterization_enabled) {
604 UMA_HISTOGRAM_BOOLEAN("Renderer4.GpuRasterizationTriggered", 604 UMA_HISTOGRAM_BOOLEAN("Renderer4.GpuRasterizationTriggered",
605 has_gpu_rasterization_trigger_); 605 has_gpu_rasterization_trigger_);
606 UMA_HISTOGRAM_BOOLEAN("Renderer4.GpuRasterizationSuitableContent", 606 UMA_HISTOGRAM_BOOLEAN("Renderer4.GpuRasterizationSuitableContent",
607 content_is_suitable_for_gpu_rasterization_); 607 content_is_suitable_for_gpu_rasterization_);
608 // Record how many pages actually get gpu rasterization when enabled. 608 // Record how many pages actually get gpu rasterization when enabled.
609 UMA_HISTOGRAM_BOOLEAN("Renderer4.GpuRasterizationUsed", 609 UMA_HISTOGRAM_BOOLEAN("Renderer4.GpuRasterizationUsed",
610 (has_gpu_rasterization_trigger_ && 610 (has_gpu_rasterization_trigger_ &&
611 content_is_suitable_for_gpu_rasterization_)); 611 content_is_suitable_for_gpu_rasterization_));
612 } 612 }
613 613
614 gpu_rasterization_histogram_recorded_ = true; 614 gpu_rasterization_histogram_recorded_ = true;
615 } 615 }
616 616
617 bool LayerTreeHostInProcess::DoUpdateLayers(Layer* root_layer) { 617 bool LayerTreeHost::DoUpdateLayers(Layer* root_layer) {
618 TRACE_EVENT1("cc", "LayerTreeHostInProcess::DoUpdateLayers", 618 TRACE_EVENT1("cc", "LayerTreeHostInProcess::DoUpdateLayers",
619 "source_frame_number", SourceFrameNumber()); 619 "source_frame_number", SourceFrameNumber());
620 620
621 layer_tree_->UpdateHudLayer(debug_state_.ShowHudInfo()); 621 layer_tree_->UpdateHudLayer(debug_state_.ShowHudInfo());
622 UpdateHudLayer(); 622 UpdateHudLayer();
623 623
624 Layer* root_scroll = 624 Layer* root_scroll =
625 PropertyTreeBuilder::FindFirstScrollableLayer(root_layer); 625 PropertyTreeBuilder::FindFirstScrollableLayer(root_layer);
626 Layer* page_scale_layer = layer_tree_->page_scale_layer(); 626 Layer* page_scale_layer = layer_tree_->page_scale_layer();
627 if (!page_scale_layer && root_scroll) 627 if (!page_scale_layer && root_scroll)
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 kNumFramesToConsiderBeforeGpuRasterization) { 686 kNumFramesToConsiderBeforeGpuRasterization) {
687 content_is_suitable_for_gpu_rasterization_ = true; 687 content_is_suitable_for_gpu_rasterization_ = true;
688 } 688 }
689 } else { 689 } else {
690 num_consecutive_frames_suitable_for_gpu_ = 0; 690 num_consecutive_frames_suitable_for_gpu_ = 0;
691 content_is_suitable_for_gpu_rasterization_ = false; 691 content_is_suitable_for_gpu_rasterization_ = false;
692 } 692 }
693 return did_paint_content; 693 return did_paint_content;
694 } 694 }
695 695
696 void LayerTreeHostInProcess::ApplyViewportDeltas(ScrollAndScaleSet* info) { 696 void LayerTreeHost::ApplyViewportDeltas(ScrollAndScaleSet* info) {
697 gfx::Vector2dF inner_viewport_scroll_delta; 697 gfx::Vector2dF inner_viewport_scroll_delta;
698 if (info->inner_viewport_scroll.layer_id != Layer::INVALID_ID) 698 if (info->inner_viewport_scroll.layer_id != Layer::INVALID_ID)
699 inner_viewport_scroll_delta = info->inner_viewport_scroll.scroll_delta; 699 inner_viewport_scroll_delta = info->inner_viewport_scroll.scroll_delta;
700 700
701 if (inner_viewport_scroll_delta.IsZero() && info->page_scale_delta == 1.f && 701 if (inner_viewport_scroll_delta.IsZero() && info->page_scale_delta == 1.f &&
702 info->elastic_overscroll_delta.IsZero() && !info->top_controls_delta) 702 info->elastic_overscroll_delta.IsZero() && !info->top_controls_delta)
703 return; 703 return;
704 704
705 // Preemptively apply the scroll offset and scale delta here before sending 705 // Preemptively apply the scroll offset and scale delta here before sending
706 // it to the client. If the client comes back and sets it to the same 706 // it to the client. If the client comes back and sets it to the same
(...skipping 10 matching lines...) Expand all
717 layer_tree_->elastic_overscroll() + info->elastic_overscroll_delta); 717 layer_tree_->elastic_overscroll() + info->elastic_overscroll_delta);
718 // TODO(ccameron): pass the elastic overscroll here so that input events 718 // TODO(ccameron): pass the elastic overscroll here so that input events
719 // may be translated appropriately. 719 // may be translated appropriately.
720 client_->ApplyViewportDeltas(inner_viewport_scroll_delta, gfx::Vector2dF(), 720 client_->ApplyViewportDeltas(inner_viewport_scroll_delta, gfx::Vector2dF(),
721 info->elastic_overscroll_delta, 721 info->elastic_overscroll_delta,
722 info->page_scale_delta, 722 info->page_scale_delta,
723 info->top_controls_delta); 723 info->top_controls_delta);
724 SetNeedsUpdateLayers(); 724 SetNeedsUpdateLayers();
725 } 725 }
726 726
727 void LayerTreeHostInProcess::ApplyScrollAndScale(ScrollAndScaleSet* info) { 727 void LayerTreeHost::ApplyScrollAndScale(ScrollAndScaleSet* info) {
728 for (auto& swap_promise : info->swap_promises) { 728 for (auto& swap_promise : info->swap_promises) {
729 TRACE_EVENT_WITH_FLOW1("input,benchmark", "LatencyInfo.Flow", 729 TRACE_EVENT_WITH_FLOW1("input,benchmark", "LatencyInfo.Flow",
730 TRACE_ID_DONT_MANGLE(swap_promise->TraceId()), 730 TRACE_ID_DONT_MANGLE(swap_promise->TraceId()),
731 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT, 731 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT,
732 "step", "Main thread scroll update"); 732 "step", "Main thread scroll update");
733 swap_promise_manager_.QueueSwapPromise(std::move(swap_promise)); 733 swap_promise_manager_.QueueSwapPromise(std::move(swap_promise));
734 } 734 }
735 735
736 if (layer_tree_->root_layer()) { 736 if (layer_tree_->root_layer()) {
737 for (size_t i = 0; i < info->scrolls.size(); ++i) { 737 for (size_t i = 0; i < info->scrolls.size(); ++i) {
(...skipping 11 matching lines...) Expand all
749 layer->SetScrollbarsHiddenFromImplSide(info->scrollbars[i].hidden); 749 layer->SetScrollbarsHiddenFromImplSide(info->scrollbars[i].hidden);
750 } 750 }
751 } 751 }
752 752
753 // This needs to happen after scroll deltas have been sent to prevent top 753 // This needs to happen after scroll deltas have been sent to prevent top
754 // controls from clamping the layout viewport both on the compositor and 754 // controls from clamping the layout viewport both on the compositor and
755 // on the main thread. 755 // on the main thread.
756 ApplyViewportDeltas(info); 756 ApplyViewportDeltas(info);
757 } 757 }
758 758
759 const base::WeakPtr<InputHandler>& LayerTreeHostInProcess::GetInputHandler() 759 const base::WeakPtr<InputHandler>& LayerTreeHost::GetInputHandler()
760 const { 760 const {
761 return input_handler_weak_ptr_; 761 return input_handler_weak_ptr_;
762 } 762 }
763 763
764 void LayerTreeHostInProcess::UpdateBrowserControlsState( 764 void LayerTreeHost::UpdateBrowserControlsState(
765 BrowserControlsState constraints, 765 BrowserControlsState constraints,
766 BrowserControlsState current, 766 BrowserControlsState current,
767 bool animate) { 767 bool animate) {
768 // Browser controls are only used in threaded mode. 768 // Browser controls are only used in threaded mode.
769 DCHECK(IsThreaded()); 769 DCHECK(IsThreaded());
770 proxy_->UpdateBrowserControlsState(constraints, current, animate); 770 proxy_->UpdateBrowserControlsState(constraints, current, animate);
771 } 771 }
772 772
773 void LayerTreeHostInProcess::AnimateLayers(base::TimeTicks monotonic_time) { 773 void LayerTreeHost::AnimateLayers(base::TimeTicks monotonic_time) {
774 MutatorHost* mutator_host = layer_tree_->mutator_host(); 774 MutatorHost* mutator_host = layer_tree_->mutator_host();
775 std::unique_ptr<MutatorEvents> events = mutator_host->CreateEvents(); 775 std::unique_ptr<MutatorEvents> events = mutator_host->CreateEvents();
776 776
777 if (mutator_host->TickAnimations(monotonic_time)) 777 if (mutator_host->TickAnimations(monotonic_time))
778 mutator_host->UpdateAnimationState(true, events.get()); 778 mutator_host->UpdateAnimationState(true, events.get());
779 779
780 if (!events->IsEmpty()) 780 if (!events->IsEmpty())
781 layer_tree_->property_trees()->needs_rebuild = true; 781 layer_tree_->property_trees()->needs_rebuild = true;
782 } 782 }
783 783
784 int LayerTreeHostInProcess::ScheduleMicroBenchmark( 784 int LayerTreeHost::ScheduleMicroBenchmark(
785 const std::string& benchmark_name, 785 const std::string& benchmark_name,
786 std::unique_ptr<base::Value> value, 786 std::unique_ptr<base::Value> value,
787 const MicroBenchmark::DoneCallback& callback) { 787 const MicroBenchmark::DoneCallback& callback) {
788 return micro_benchmark_controller_.ScheduleRun(benchmark_name, 788 return micro_benchmark_controller_.ScheduleRun(benchmark_name,
789 std::move(value), callback); 789 std::move(value), callback);
790 } 790 }
791 791
792 bool LayerTreeHostInProcess::SendMessageToMicroBenchmark( 792 bool LayerTreeHost::SendMessageToMicroBenchmark(
793 int id, 793 int id,
794 std::unique_ptr<base::Value> value) { 794 std::unique_ptr<base::Value> value) {
795 return micro_benchmark_controller_.SendMessage(id, std::move(value)); 795 return micro_benchmark_controller_.SendMessage(id, std::move(value));
796 } 796 }
797 797
798 void LayerTreeHostInProcess::SetLayerTreeMutator( 798 void LayerTreeHost::SetLayerTreeMutator(
799 std::unique_ptr<LayerTreeMutator> mutator) { 799 std::unique_ptr<LayerTreeMutator> mutator) {
800 proxy_->SetMutator(std::move(mutator)); 800 proxy_->SetMutator(std::move(mutator));
801 } 801 }
802 802
803 bool LayerTreeHostInProcess::IsSingleThreaded() const { 803 bool LayerTreeHost::IsSingleThreaded() const {
804 DCHECK(compositor_mode_ != CompositorMode::SINGLE_THREADED || 804 DCHECK(compositor_mode_ != CompositorMode::SINGLE_THREADED ||
805 !task_runner_provider_->HasImplThread()); 805 !task_runner_provider_->HasImplThread());
806 return compositor_mode_ == CompositorMode::SINGLE_THREADED; 806 return compositor_mode_ == CompositorMode::SINGLE_THREADED;
807 } 807 }
808 808
809 bool LayerTreeHostInProcess::IsThreaded() const { 809 bool LayerTreeHost::IsThreaded() const {
810 DCHECK(compositor_mode_ != CompositorMode::THREADED || 810 DCHECK(compositor_mode_ != CompositorMode::THREADED ||
811 task_runner_provider_->HasImplThread()); 811 task_runner_provider_->HasImplThread());
812 return compositor_mode_ == CompositorMode::THREADED; 812 return compositor_mode_ == CompositorMode::THREADED;
813 } 813 }
814 814
815 } // namespace cc 815 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host.h ('k') | cc/trees/layer_tree_host_in_process.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698