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
3 // found in the LICENSE file.
5 #include "cc/trees/layer_tree_host.h"
11 #include "base/atomic_sequence_num.h"
12 #include "base/auto_reset.h"
13 #include "base/bind.h"
14 #include "base/command_line.h"
15 #include "base/location.h"
16 #include "base/metrics/histogram.h"
17 #include "base/single_thread_task_runner.h"
18 #include "base/stl_util.h"
19 #include "base/strings/string_number_conversions.h"
20 #include "base/thread_task_runner_handle.h"
21 #include "base/trace_event/trace_event.h"
22 #include "base/trace_event/trace_event_argument.h"
23 #include "cc/animation/animation_registrar.h"
24 #include "cc/animation/layer_animation_controller.h"
25 #include "cc/base/math_util.h"
26 #include "cc/debug/devtools_instrumentation.h"
27 #include "cc/debug/frame_viewer_instrumentation.h"
28 #include "cc/debug/rendering_stats_instrumentation.h"
29 #include "cc/input/layer_selection_bound.h"
30 #include "cc/input/page_scale_animation.h"
31 #include "cc/input/top_controls_manager.h"
32 #include "cc/layers/heads_up_display_layer.h"
33 #include "cc/layers/heads_up_display_layer_impl.h"
34 #include "cc/layers/layer.h"
35 #include "cc/layers/layer_iterator.h"
36 #include "cc/layers/painted_scrollbar_layer.h"
37 #include "cc/layers/render_surface.h"
38 #include "cc/resources/prioritized_resource_manager.h"
39 #include "cc/resources/ui_resource_request.h"
40 #include "cc/scheduler/begin_frame_source.h"
41 #include "cc/trees/draw_property_utils.h"
42 #include "cc/trees/layer_tree_host_client.h"
43 #include "cc/trees/layer_tree_host_common.h"
44 #include "cc/trees/layer_tree_host_impl.h"
45 #include "cc/trees/layer_tree_impl.h"
46 #include "cc/trees/occlusion_tracker.h"
47 #include "cc/trees/single_thread_proxy.h"
48 #include "cc/trees/thread_proxy.h"
49 #include "cc/trees/tree_synchronizer.h"
50 #include "ui/gfx/geometry/size_conversions.h"
51 #include "ui/gfx/geometry/vector2d_conversions.h"
54 static base::StaticAtomicSequenceNumber s_layer_tree_host_sequence_number
;
59 LayerTreeHost::InitParams::InitParams() {
62 LayerTreeHost::InitParams::~InitParams() {
65 scoped_ptr
<LayerTreeHost
> LayerTreeHost::CreateThreaded(
66 scoped_refptr
<base::SingleThreadTaskRunner
> impl_task_runner
,
68 DCHECK(params
->main_task_runner
.get());
69 DCHECK(impl_task_runner
.get());
70 DCHECK(params
->settings
);
71 scoped_ptr
<LayerTreeHost
> layer_tree_host(new LayerTreeHost(params
));
72 layer_tree_host
->InitializeThreaded(
73 params
->main_task_runner
, impl_task_runner
,
74 params
->external_begin_frame_source
.Pass());
75 return layer_tree_host
.Pass();
78 scoped_ptr
<LayerTreeHost
> LayerTreeHost::CreateSingleThreaded(
79 LayerTreeHostSingleThreadClient
* single_thread_client
,
81 DCHECK(params
->settings
);
82 scoped_ptr
<LayerTreeHost
> layer_tree_host(new LayerTreeHost(params
));
83 layer_tree_host
->InitializeSingleThreaded(
84 single_thread_client
, params
->main_task_runner
,
85 params
->external_begin_frame_source
.Pass());
86 return layer_tree_host
.Pass();
89 LayerTreeHost::LayerTreeHost(InitParams
* params
)
90 : micro_benchmark_controller_(this),
91 next_ui_resource_id_(1),
92 inside_begin_main_frame_(false),
93 needs_full_tree_sync_(true),
94 needs_meta_info_recomputation_(true),
95 client_(params
->client
),
96 source_frame_number_(0),
97 meta_information_sequence_number_(1),
98 rendering_stats_instrumentation_(RenderingStatsInstrumentation::Create()),
99 output_surface_lost_(true),
100 settings_(*params
->settings
),
101 debug_state_(settings_
.initial_debug_state
),
102 top_controls_shrink_blink_size_(false),
103 top_controls_height_(0.f
),
104 top_controls_shown_ratio_(0.f
),
105 device_scale_factor_(1.f
),
107 page_scale_factor_(1.f
),
108 min_page_scale_factor_(1.f
),
109 max_page_scale_factor_(1.f
),
110 has_gpu_rasterization_trigger_(false),
111 content_is_suitable_for_gpu_rasterization_(true),
112 gpu_rasterization_histogram_recorded_(false),
113 background_color_(SK_ColorWHITE
),
114 has_transparent_background_(false),
115 partial_texture_update_requests_(0),
116 did_complete_scale_animation_(false),
117 in_paint_layer_contents_(false),
118 id_(s_layer_tree_host_sequence_number
.GetNext() + 1),
119 next_commit_forces_redraw_(false),
120 shared_bitmap_manager_(params
->shared_bitmap_manager
),
121 gpu_memory_buffer_manager_(params
->gpu_memory_buffer_manager
),
122 task_graph_runner_(params
->task_graph_runner
),
123 surface_id_namespace_(0u),
124 next_surface_sequence_(1u) {
125 if (settings_
.accelerated_animation_enabled
)
126 animation_registrar_
= AnimationRegistrar::Create();
127 rendering_stats_instrumentation_
->set_record_rendering_stats(
128 debug_state_
.RecordRenderingStats());
131 void LayerTreeHost::InitializeThreaded(
132 scoped_refptr
<base::SingleThreadTaskRunner
> main_task_runner
,
133 scoped_refptr
<base::SingleThreadTaskRunner
> impl_task_runner
,
134 scoped_ptr
<BeginFrameSource
> external_begin_frame_source
) {
135 InitializeProxy(ThreadProxy::Create(this,
138 external_begin_frame_source
.Pass()));
141 void LayerTreeHost::InitializeSingleThreaded(
142 LayerTreeHostSingleThreadClient
* single_thread_client
,
143 scoped_refptr
<base::SingleThreadTaskRunner
> main_task_runner
,
144 scoped_ptr
<BeginFrameSource
> external_begin_frame_source
) {
146 SingleThreadProxy::Create(this,
147 single_thread_client
,
149 external_begin_frame_source
.Pass()));
152 void LayerTreeHost::InitializeForTesting(scoped_ptr
<Proxy
> proxy_for_testing
) {
153 InitializeProxy(proxy_for_testing
.Pass());
156 void LayerTreeHost::InitializeProxy(scoped_ptr
<Proxy
> proxy
) {
157 TRACE_EVENT0("cc", "LayerTreeHost::InitializeForReal");
159 proxy_
= proxy
.Pass();
161 if (settings_
.accelerated_animation_enabled
) {
162 animation_registrar_
->set_supports_scroll_animations(
163 proxy_
->SupportsImplScrolling());
167 LayerTreeHost::~LayerTreeHost() {
168 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost");
170 if (root_layer_
.get())
171 root_layer_
->SetLayerTreeHost(NULL
);
173 DCHECK(swap_promise_monitor_
.empty());
175 BreakSwapPromises(SwapPromise::COMMIT_FAILS
);
178 DCHECK(proxy_
->IsMainThread());
182 // We must clear any pointers into the layer tree prior to destroying it.
183 RegisterViewportLayers(NULL
, NULL
, NULL
, NULL
);
185 if (root_layer_
.get()) {
186 // The layer tree must be destroyed before the layer tree host. We've
187 // made a contract with our animation controllers that the registrar
188 // will outlive them, and we must make good.
193 void LayerTreeHost::SetLayerTreeHostClientReady() {
194 proxy_
->SetLayerTreeHostClientReady();
197 void LayerTreeHost::DeleteContentsTexturesOnImplThread(
198 ResourceProvider
* resource_provider
) {
199 DCHECK(proxy_
->IsImplThread());
200 if (contents_texture_manager_
)
201 contents_texture_manager_
->ClearAllMemory(resource_provider
);
204 void LayerTreeHost::WillBeginMainFrame() {
205 devtools_instrumentation::WillBeginMainThreadFrame(id(),
206 source_frame_number());
207 client_
->WillBeginMainFrame();
210 void LayerTreeHost::DidBeginMainFrame() {
211 client_
->DidBeginMainFrame();
214 void LayerTreeHost::BeginMainFrameNotExpectedSoon() {
215 client_
->BeginMainFrameNotExpectedSoon();
218 void LayerTreeHost::BeginMainFrame(const BeginFrameArgs
& args
) {
219 inside_begin_main_frame_
= true;
220 client_
->BeginMainFrame(args
);
221 inside_begin_main_frame_
= false;
224 void LayerTreeHost::DidStopFlinging() {
225 proxy_
->MainThreadHasStoppedFlinging();
228 void LayerTreeHost::Layout() {
232 void LayerTreeHost::BeginCommitOnImplThread(LayerTreeHostImpl
* host_impl
) {
233 DCHECK(proxy_
->IsImplThread());
234 TRACE_EVENT0("cc", "LayerTreeHost::CommitTo");
237 // This function commits the LayerTreeHost to an impl tree. When modifying
238 // this function, keep in mind that the function *runs* on the impl thread! Any
239 // code that is logically a main thread operation, e.g. deletion of a Layer,
240 // should be delayed until the LayerTreeHost::CommitComplete, which will run
241 // after the commit, but on the main thread.
242 void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl
* host_impl
) {
243 DCHECK(proxy_
->IsImplThread());
245 // If there are linked evicted backings, these backings' resources may be put
246 // into the impl tree, so we can't draw yet. Determine this before clearing
247 // all evicted backings.
248 bool new_impl_tree_has_no_evicted_resources
= false;
249 if (contents_texture_manager_
) {
250 new_impl_tree_has_no_evicted_resources
=
251 !contents_texture_manager_
->LinkedEvictedBackingsExist();
253 // If the memory limit has been increased since this now-finishing
254 // commit began, and the extra now-available memory would have been used,
255 // then request another commit.
256 if (contents_texture_manager_
->MaxMemoryLimitBytes() <
257 host_impl
->memory_allocation_limit_bytes() &&
258 contents_texture_manager_
->MaxMemoryLimitBytes() <
259 contents_texture_manager_
->MaxMemoryNeededBytes()) {
260 host_impl
->SetNeedsCommit();
263 host_impl
->set_max_memory_needed_bytes(
264 contents_texture_manager_
->MaxMemoryNeededBytes());
266 contents_texture_manager_
->UpdateBackingsState(
267 host_impl
->resource_provider());
268 contents_texture_manager_
->ReduceMemory(host_impl
->resource_provider());
272 TRACE_EVENT_IS_NEW_TRACE(&is_new_trace
);
274 frame_viewer_instrumentation::IsTracingLayerTreeSnapshots() &&
276 LayerTreeHostCommon::CallFunctionForSubtree(
277 root_layer(), [](Layer
* layer
) { layer
->DidBeginTracing(); });
280 LayerTreeImpl
* sync_tree
= host_impl
->sync_tree();
282 if (next_commit_forces_redraw_
) {
283 sync_tree
->ForceRedrawNextActivation();
284 next_commit_forces_redraw_
= false;
287 sync_tree
->set_source_frame_number(source_frame_number());
289 if (needs_full_tree_sync_
) {
290 sync_tree
->SetRootLayer(TreeSynchronizer::SynchronizeTrees(
291 root_layer(), sync_tree
->DetachLayerTree(), sync_tree
));
293 sync_tree
->set_needs_full_tree_sync(needs_full_tree_sync_
);
294 needs_full_tree_sync_
= false;
296 if (hud_layer_
.get()) {
297 LayerImpl
* hud_impl
= LayerTreeHostCommon::FindLayerInSubtree(
298 sync_tree
->root_layer(), hud_layer_
->id());
299 sync_tree
->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl
*>(hud_impl
));
301 sync_tree
->set_hud_layer(NULL
);
304 sync_tree
->set_background_color(background_color_
);
305 sync_tree
->set_has_transparent_background(has_transparent_background_
);
307 if (page_scale_layer_
.get() && inner_viewport_scroll_layer_
.get()) {
308 sync_tree
->SetViewportLayersFromIds(
309 overscroll_elasticity_layer_
.get() ? overscroll_elasticity_layer_
->id()
311 page_scale_layer_
->id(), inner_viewport_scroll_layer_
->id(),
312 outer_viewport_scroll_layer_
.get() ? outer_viewport_scroll_layer_
->id()
313 : Layer::INVALID_ID
);
314 DCHECK(inner_viewport_scroll_layer_
->IsContainerForFixedPositionLayers());
316 sync_tree
->ClearViewportLayers();
319 sync_tree
->RegisterSelection(selection_
);
321 sync_tree
->PushPageScaleFromMainThread(
322 page_scale_factor_
, min_page_scale_factor_
, max_page_scale_factor_
);
323 sync_tree
->elastic_overscroll()->PushFromMainThread(elastic_overscroll_
);
324 if (sync_tree
->IsActiveTree())
325 sync_tree
->elastic_overscroll()->PushPendingToActive();
327 sync_tree
->PassSwapPromises(&swap_promise_list_
);
329 sync_tree
->set_top_controls_shrink_blink_size(
330 top_controls_shrink_blink_size_
);
331 sync_tree
->set_top_controls_height(top_controls_height_
);
332 sync_tree
->PushTopControlsFromMainThread(top_controls_shown_ratio_
);
334 host_impl
->SetHasGpuRasterizationTrigger(has_gpu_rasterization_trigger_
);
335 host_impl
->SetContentIsSuitableForGpuRasterization(
336 content_is_suitable_for_gpu_rasterization_
);
337 RecordGpuRasterizationHistogram();
339 host_impl
->SetViewportSize(device_viewport_size_
);
340 host_impl
->SetDeviceScaleFactor(device_scale_factor_
);
341 host_impl
->SetDebugState(debug_state_
);
342 if (pending_page_scale_animation_
) {
343 sync_tree
->SetPendingPageScaleAnimation(
344 pending_page_scale_animation_
.Pass());
347 if (!ui_resource_request_queue_
.empty()) {
348 sync_tree
->set_ui_resource_request_queue(ui_resource_request_queue_
);
349 ui_resource_request_queue_
.clear();
352 DCHECK(!sync_tree
->ViewportSizeInvalid());
354 if (new_impl_tree_has_no_evicted_resources
) {
355 if (sync_tree
->ContentsTexturesPurged())
356 sync_tree
->ResetContentsTexturesPurged();
359 sync_tree
->set_has_ever_been_drawn(false);
360 sync_tree
->SetPropertyTrees(property_trees_
);
363 TRACE_EVENT0("cc", "LayerTreeHost::PushProperties");
364 TreeSynchronizer::PushProperties(root_layer(), sync_tree
->root_layer());
367 micro_benchmark_controller_
.ScheduleImplBenchmarks(host_impl
);
370 void LayerTreeHost::WillCommit() {
371 client_
->WillCommit();
374 void LayerTreeHost::UpdateHudLayer() {
375 if (debug_state_
.ShowHudInfo()) {
376 if (!hud_layer_
.get())
377 hud_layer_
= HeadsUpDisplayLayer::Create(settings_
.hud_layer_settings
);
379 if (root_layer_
.get() && !hud_layer_
->parent())
380 root_layer_
->AddChild(hud_layer_
);
381 } else if (hud_layer_
.get()) {
382 hud_layer_
->RemoveFromParent();
387 void LayerTreeHost::CommitComplete() {
388 source_frame_number_
++;
389 client_
->DidCommit();
390 if (did_complete_scale_animation_
) {
391 client_
->DidCompletePageScaleAnimation();
392 did_complete_scale_animation_
= false;
396 void LayerTreeHost::SetOutputSurface(scoped_ptr
<OutputSurface
> surface
) {
397 TRACE_EVENT0("cc", "LayerTreeHost::SetOutputSurface");
398 DCHECK(output_surface_lost_
);
401 proxy_
->SetOutputSurface(surface
.Pass());
404 void LayerTreeHost::RequestNewOutputSurface() {
405 client_
->RequestNewOutputSurface();
408 void LayerTreeHost::DidInitializeOutputSurface() {
409 output_surface_lost_
= false;
411 if (!contents_texture_manager_
&& !settings_
.impl_side_painting
) {
412 contents_texture_manager_
=
413 PrioritizedResourceManager::Create(proxy_
.get());
414 surface_memory_placeholder_
=
415 contents_texture_manager_
->CreateTexture(gfx::Size(), RGBA_8888
);
419 LayerTreeHostCommon::CallFunctionForSubtree(
420 root_layer(), [](Layer
* layer
) { layer
->OnOutputSurfaceCreated(); });
423 client_
->DidInitializeOutputSurface();
426 void LayerTreeHost::DidFailToInitializeOutputSurface() {
427 DCHECK(output_surface_lost_
);
428 client_
->DidFailToInitializeOutputSurface();
431 scoped_ptr
<LayerTreeHostImpl
> LayerTreeHost::CreateLayerTreeHostImpl(
432 LayerTreeHostImplClient
* client
) {
433 DCHECK(proxy_
->IsImplThread());
434 scoped_ptr
<LayerTreeHostImpl
> host_impl
= LayerTreeHostImpl::Create(
435 settings_
, client
, proxy_
.get(), rendering_stats_instrumentation_
.get(),
436 shared_bitmap_manager_
, gpu_memory_buffer_manager_
, task_graph_runner_
,
438 host_impl
->SetHasGpuRasterizationTrigger(has_gpu_rasterization_trigger_
);
439 host_impl
->SetContentIsSuitableForGpuRasterization(
440 content_is_suitable_for_gpu_rasterization_
);
441 shared_bitmap_manager_
= NULL
;
442 gpu_memory_buffer_manager_
= NULL
;
443 task_graph_runner_
= NULL
;
444 top_controls_manager_weak_ptr_
=
445 host_impl
->top_controls_manager()->AsWeakPtr();
446 input_handler_weak_ptr_
= host_impl
->AsWeakPtr();
447 return host_impl
.Pass();
450 void LayerTreeHost::DidLoseOutputSurface() {
451 TRACE_EVENT0("cc", "LayerTreeHost::DidLoseOutputSurface");
452 DCHECK(proxy_
->IsMainThread());
454 if (output_surface_lost_
)
457 output_surface_lost_
= true;
461 void LayerTreeHost::FinishAllRendering() {
462 proxy_
->FinishAllRendering();
465 void LayerTreeHost::SetDeferCommits(bool defer_commits
) {
466 proxy_
->SetDeferCommits(defer_commits
);
469 void LayerTreeHost::SetNeedsDisplayOnAllLayers() {
470 std::stack
<Layer
*> layer_stack
;
471 layer_stack
.push(root_layer());
472 while (!layer_stack
.empty()) {
473 Layer
* current_layer
= layer_stack
.top();
475 current_layer
->SetNeedsDisplay();
476 for (unsigned int i
= 0; i
< current_layer
->children().size(); i
++) {
477 layer_stack
.push(current_layer
->child_at(i
));
482 const RendererCapabilities
& LayerTreeHost::GetRendererCapabilities() const {
483 return proxy_
->GetRendererCapabilities();
486 void LayerTreeHost::SetNeedsAnimate() {
487 proxy_
->SetNeedsAnimate();
488 NotifySwapPromiseMonitorsOfSetNeedsCommit();
491 void LayerTreeHost::SetNeedsUpdateLayers() {
492 proxy_
->SetNeedsUpdateLayers();
493 NotifySwapPromiseMonitorsOfSetNeedsCommit();
496 void LayerTreeHost::SetNeedsCommit() {
497 if (!prepaint_callback_
.IsCancelled()) {
498 TRACE_EVENT_INSTANT0("cc",
499 "LayerTreeHost::SetNeedsCommit::cancel prepaint",
500 TRACE_EVENT_SCOPE_THREAD
);
501 prepaint_callback_
.Cancel();
503 proxy_
->SetNeedsCommit();
504 NotifySwapPromiseMonitorsOfSetNeedsCommit();
507 void LayerTreeHost::SetNeedsFullTreeSync() {
508 needs_full_tree_sync_
= true;
509 needs_meta_info_recomputation_
= true;
511 property_trees_
.needs_rebuild
= true;
515 void LayerTreeHost::SetNeedsMetaInfoRecomputation(bool needs_recomputation
) {
516 needs_meta_info_recomputation_
= needs_recomputation
;
519 void LayerTreeHost::SetNeedsRedraw() {
520 SetNeedsRedrawRect(gfx::Rect(device_viewport_size_
));
523 void LayerTreeHost::SetNeedsRedrawRect(const gfx::Rect
& damage_rect
) {
524 proxy_
->SetNeedsRedraw(damage_rect
);
527 bool LayerTreeHost::CommitRequested() const {
528 return proxy_
->CommitRequested();
531 bool LayerTreeHost::BeginMainFrameRequested() const {
532 return proxy_
->BeginMainFrameRequested();
536 void LayerTreeHost::SetNextCommitWaitsForActivation() {
537 proxy_
->SetNextCommitWaitsForActivation();
540 void LayerTreeHost::SetNextCommitForcesRedraw() {
541 next_commit_forces_redraw_
= true;
544 void LayerTreeHost::SetAnimationEvents(
545 scoped_ptr
<AnimationEventsVector
> events
) {
546 DCHECK(proxy_
->IsMainThread());
547 animation_registrar_
->SetAnimationEvents(events
.Pass());
550 void LayerTreeHost::SetRootLayer(scoped_refptr
<Layer
> root_layer
) {
551 if (root_layer_
.get() == root_layer
.get())
554 if (root_layer_
.get())
555 root_layer_
->SetLayerTreeHost(NULL
);
556 root_layer_
= root_layer
;
557 if (root_layer_
.get()) {
558 DCHECK(!root_layer_
->parent());
559 root_layer_
->SetLayerTreeHost(this);
562 if (hud_layer_
.get())
563 hud_layer_
->RemoveFromParent();
565 // Reset gpu rasterization flag.
566 // This flag is sticky until a new tree comes along.
567 content_is_suitable_for_gpu_rasterization_
= true;
568 gpu_rasterization_histogram_recorded_
= false;
570 SetNeedsFullTreeSync();
573 void LayerTreeHost::SetDebugState(const LayerTreeDebugState
& debug_state
) {
574 LayerTreeDebugState new_debug_state
=
575 LayerTreeDebugState::Unite(settings_
.initial_debug_state
, debug_state
);
577 if (LayerTreeDebugState::Equal(debug_state_
, new_debug_state
))
580 debug_state_
= new_debug_state
;
582 rendering_stats_instrumentation_
->set_record_rendering_stats(
583 debug_state_
.RecordRenderingStats());
586 proxy_
->SetDebugState(debug_state
);
589 void LayerTreeHost::SetHasGpuRasterizationTrigger(bool has_trigger
) {
590 if (has_trigger
== has_gpu_rasterization_trigger_
)
593 has_gpu_rasterization_trigger_
= has_trigger
;
594 TRACE_EVENT_INSTANT1("cc",
595 "LayerTreeHost::SetHasGpuRasterizationTrigger",
596 TRACE_EVENT_SCOPE_THREAD
,
598 has_gpu_rasterization_trigger_
);
601 void LayerTreeHost::SetViewportSize(const gfx::Size
& device_viewport_size
) {
602 if (device_viewport_size
== device_viewport_size_
)
605 device_viewport_size_
= device_viewport_size
;
607 property_trees_
.needs_rebuild
= true;
611 void LayerTreeHost::SetTopControlsHeight(float height
, bool shrink
) {
612 if (top_controls_height_
== height
&&
613 top_controls_shrink_blink_size_
== shrink
)
616 top_controls_height_
= height
;
617 top_controls_shrink_blink_size_
= shrink
;
621 void LayerTreeHost::SetTopControlsShownRatio(float ratio
) {
622 if (top_controls_shown_ratio_
== ratio
)
625 top_controls_shown_ratio_
= ratio
;
629 void LayerTreeHost::ApplyPageScaleDeltaFromImplSide(float page_scale_delta
) {
630 DCHECK(CommitRequested());
631 if (page_scale_delta
== 1.f
)
633 page_scale_factor_
*= page_scale_delta
;
634 property_trees_
.needs_rebuild
= true;
637 void LayerTreeHost::SetPageScaleFactorAndLimits(float page_scale_factor
,
638 float min_page_scale_factor
,
639 float max_page_scale_factor
) {
640 if (page_scale_factor
== page_scale_factor_
&&
641 min_page_scale_factor
== min_page_scale_factor_
&&
642 max_page_scale_factor
== max_page_scale_factor_
)
645 page_scale_factor_
= page_scale_factor
;
646 min_page_scale_factor_
= min_page_scale_factor
;
647 max_page_scale_factor_
= max_page_scale_factor
;
648 property_trees_
.needs_rebuild
= true;
652 void LayerTreeHost::SetVisible(bool visible
) {
653 if (visible_
== visible
)
658 proxy_
->SetVisible(visible
);
661 void LayerTreeHost::SetThrottleFrameProduction(bool throttle
) {
662 proxy_
->SetThrottleFrameProduction(throttle
);
665 void LayerTreeHost::StartPageScaleAnimation(const gfx::Vector2d
& target_offset
,
668 base::TimeDelta duration
) {
669 pending_page_scale_animation_
.reset(
670 new PendingPageScaleAnimation(
679 void LayerTreeHost::NotifyInputThrottledUntilCommit() {
680 proxy_
->NotifyInputThrottledUntilCommit();
683 void LayerTreeHost::Composite(base::TimeTicks frame_begin_time
) {
684 DCHECK(!proxy_
->HasImplThread());
685 // This function is only valid when not using the scheduler.
686 DCHECK(!settings_
.single_thread_proxy_scheduler
);
687 SingleThreadProxy
* proxy
= static_cast<SingleThreadProxy
*>(proxy_
.get());
689 SetLayerTreeHostClientReady();
690 proxy
->CompositeImmediately(frame_begin_time
);
693 bool LayerTreeHost::UpdateLayers(ResourceUpdateQueue
* queue
) {
694 DCHECK(!output_surface_lost_
);
699 DCHECK(!root_layer()->parent());
701 bool result
= UpdateLayers(root_layer(), queue
);
703 micro_benchmark_controller_
.DidUpdateLayers();
705 return result
|| next_commit_forces_redraw_
;
708 void LayerTreeHost::DidCompletePageScaleAnimation() {
709 did_complete_scale_animation_
= true;
712 static Layer
* FindFirstScrollableLayer(Layer
* layer
) {
716 if (layer
->scrollable())
719 for (size_t i
= 0; i
< layer
->children().size(); ++i
) {
720 Layer
* found
= FindFirstScrollableLayer(layer
->children()[i
].get());
728 void LayerTreeHost::RecordGpuRasterizationHistogram() {
729 // Gpu rasterization is only supported when impl-side painting is enabled.
730 if (gpu_rasterization_histogram_recorded_
|| !settings_
.impl_side_painting
)
733 // Record how widely gpu rasterization is enabled.
734 // This number takes device/gpu whitelisting/backlisting into account.
735 // Note that we do not consider the forced gpu rasterization mode, which is
736 // mostly used for debugging purposes.
737 UMA_HISTOGRAM_BOOLEAN("Renderer4.GpuRasterizationEnabled",
738 settings_
.gpu_rasterization_enabled
);
739 if (settings_
.gpu_rasterization_enabled
) {
740 UMA_HISTOGRAM_BOOLEAN("Renderer4.GpuRasterizationTriggered",
741 has_gpu_rasterization_trigger_
);
742 UMA_HISTOGRAM_BOOLEAN("Renderer4.GpuRasterizationSuitableContent",
743 content_is_suitable_for_gpu_rasterization_
);
744 // Record how many pages actually get gpu rasterization when enabled.
745 UMA_HISTOGRAM_BOOLEAN("Renderer4.GpuRasterizationUsed",
746 (has_gpu_rasterization_trigger_
&&
747 content_is_suitable_for_gpu_rasterization_
));
750 gpu_rasterization_histogram_recorded_
= true;
753 bool LayerTreeHost::UsingSharedMemoryResources() {
754 return GetRendererCapabilities().using_shared_memory_resources
;
757 bool LayerTreeHost::UpdateLayers(Layer
* root_layer
,
758 ResourceUpdateQueue
* queue
) {
759 TRACE_EVENT1("cc", "LayerTreeHost::UpdateLayers",
760 "source_frame_number", source_frame_number());
762 RenderSurfaceLayerList render_surface_layer_list
;
766 Layer
* root_scroll
= FindFirstScrollableLayer(root_layer
);
767 Layer
* page_scale_layer
= page_scale_layer_
.get();
768 if (!page_scale_layer
&& root_scroll
)
769 page_scale_layer
= root_scroll
->parent();
771 if (hud_layer_
.get()) {
772 hud_layer_
->PrepareForCalculateDrawProperties(device_viewport_size(),
773 device_scale_factor_
);
776 bool can_render_to_separate_surface
= true;
777 // TODO(vmpstr): Passing 0 as the current render surface layer list id means
778 // that we won't be able to detect if a layer is part of
779 // |render_surface_layer_list|. Change this if this information is
781 int render_surface_layer_list_id
= 0;
782 LayerTreeHostCommon::CalcDrawPropsMainInputs
inputs(
783 root_layer
, device_viewport_size(), gfx::Transform(),
784 device_scale_factor_
, page_scale_factor_
, page_scale_layer
,
785 elastic_overscroll_
, overscroll_elasticity_layer_
.get(),
786 GetRendererCapabilities().max_texture_size
, settings_
.can_use_lcd_text
,
787 settings_
.layers_always_allowed_lcd_text
, can_render_to_separate_surface
,
788 settings_
.layer_transforms_should_scale_layer_contents
,
789 settings_
.verify_property_trees
, &render_surface_layer_list
,
790 render_surface_layer_list_id
, &property_trees_
);
792 // This is a temporary state of affairs until impl-side painting is shipped
793 // everywhere and main thread property trees can be used in all cases.
794 // This code here implies that even if verify property trees is on,
795 // no verification will occur and only property trees will be used on the
797 if (using_only_property_trees()) {
798 TRACE_EVENT0("cc", "LayerTreeHost::UpdateLayers::CalcDrawProps");
800 LayerTreeHostCommon::PreCalculateMetaInformation(root_layer
);
802 bool preserves_2d_axis_alignment
= false;
803 gfx::Transform identity_transform
;
804 LayerList update_layer_list
;
806 LayerTreeHostCommon::UpdateRenderSurfaces(
807 root_layer
, can_render_to_separate_surface
, identity_transform
,
808 preserves_2d_axis_alignment
);
810 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"),
811 "LayerTreeHostCommon::ComputeVisibleRectsWithPropertyTrees");
812 BuildPropertyTreesAndComputeVisibleRects(
813 root_layer
, page_scale_layer
, page_scale_factor_
,
814 device_scale_factor_
, gfx::Rect(device_viewport_size_
),
815 identity_transform
, &property_trees_
, &update_layer_list
);
818 for (const auto& layer
: update_layer_list
)
819 layer
->SavePaintProperties();
821 base::AutoReset
<bool> painting(&in_paint_layer_contents_
, true);
822 bool did_paint_content
= false;
823 for (const auto& layer
: update_layer_list
) {
824 // TODO(enne): temporarily clobber draw properties visible rect.
825 layer
->draw_properties().visible_content_rect
=
826 layer
->visible_rect_from_property_trees();
827 did_paint_content
|= layer
->Update(queue
, nullptr);
828 content_is_suitable_for_gpu_rasterization_
&=
829 layer
->IsSuitableForGpuRasterization();
831 return did_paint_content
;
835 TRACE_EVENT0("cc", "LayerTreeHost::UpdateLayers::CalcDrawProps");
836 LayerTreeHostCommon::CalculateDrawProperties(&inputs
);
839 // Reset partial texture update requests.
840 partial_texture_update_requests_
= 0;
842 bool did_paint_content
= false;
843 bool need_more_updates
= false;
844 PaintLayerContents(render_surface_layer_list
, queue
, &did_paint_content
,
846 if (need_more_updates
) {
847 TRACE_EVENT0("cc", "LayerTreeHost::UpdateLayers::posting prepaint task");
848 prepaint_callback_
.Reset(base::Bind(&LayerTreeHost::TriggerPrepaint
,
849 base::Unretained(this)));
850 static base::TimeDelta prepaint_delay
=
851 base::TimeDelta::FromMilliseconds(100);
852 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
853 FROM_HERE
, prepaint_callback_
.callback(), prepaint_delay
);
856 return did_paint_content
;
859 void LayerTreeHost::TriggerPrepaint() {
860 prepaint_callback_
.Cancel();
861 TRACE_EVENT0("cc", "LayerTreeHost::TriggerPrepaint");
865 void LayerTreeHost::ReduceMemoryUsage() {
869 LayerTreeHostCommon::CallFunctionForSubtree(
870 root_layer(), [](Layer
* layer
) { layer
->ReduceMemoryUsage(); });
873 void LayerTreeHost::SetPrioritiesForSurfaces(size_t surface_memory_bytes
) {
874 DCHECK(surface_memory_placeholder_
);
876 // Surfaces have a place holder for their memory since they are managed
877 // independantly but should still be tracked and reduce other memory usage.
878 surface_memory_placeholder_
->SetTextureManager(
879 contents_texture_manager_
.get());
880 surface_memory_placeholder_
->set_request_priority(
881 PriorityCalculator::RenderSurfacePriority());
882 surface_memory_placeholder_
->SetToSelfManagedMemoryPlaceholder(
883 surface_memory_bytes
);
886 void LayerTreeHost::SetPrioritiesForLayers(
887 const RenderSurfaceLayerList
& update_list
) {
888 PriorityCalculator calculator
;
889 typedef LayerIterator
<Layer
> LayerIteratorType
;
890 LayerIteratorType end
= LayerIteratorType::End(&update_list
);
891 for (LayerIteratorType it
= LayerIteratorType::Begin(&update_list
);
894 if (it
.represents_itself()) {
895 it
->SetTexturePriorities(calculator
);
896 } else if (it
.represents_target_render_surface()) {
897 if (it
->mask_layer())
898 it
->mask_layer()->SetTexturePriorities(calculator
);
899 if (it
->replica_layer() && it
->replica_layer()->mask_layer())
900 it
->replica_layer()->mask_layer()->SetTexturePriorities(calculator
);
905 void LayerTreeHost::PrioritizeTextures(
906 const RenderSurfaceLayerList
& render_surface_layer_list
) {
907 if (!contents_texture_manager_
)
910 contents_texture_manager_
->ClearPriorities();
912 size_t memory_for_render_surfaces_metric
=
913 CalculateMemoryForRenderSurfaces(render_surface_layer_list
);
915 SetPrioritiesForLayers(render_surface_layer_list
);
916 SetPrioritiesForSurfaces(memory_for_render_surfaces_metric
);
918 contents_texture_manager_
->PrioritizeTextures();
921 size_t LayerTreeHost::CalculateMemoryForRenderSurfaces(
922 const RenderSurfaceLayerList
& update_list
) {
923 size_t readback_bytes
= 0;
924 size_t contents_texture_bytes
= 0;
926 // Start iteration at 1 to skip the root surface as it does not have a texture
928 for (size_t i
= 1; i
< update_list
.size(); ++i
) {
929 Layer
* render_surface_layer
= update_list
.at(i
);
930 RenderSurface
* render_surface
= render_surface_layer
->render_surface();
933 Resource::MemorySizeBytes(render_surface
->content_rect().size(),
935 contents_texture_bytes
+= bytes
;
937 if (render_surface_layer
->background_filters().IsEmpty() &&
938 render_surface_layer
->uses_default_blend_mode())
941 if (!readback_bytes
) {
942 readback_bytes
= Resource::MemorySizeBytes(device_viewport_size_
,
946 return readback_bytes
+ contents_texture_bytes
;
949 void LayerTreeHost::PaintMasksForRenderSurface(Layer
* render_surface_layer
,
950 ResourceUpdateQueue
* queue
,
951 bool* did_paint_content
,
952 bool* need_more_updates
) {
953 // Note: Masks and replicas only exist for layers that own render surfaces. If
954 // we reach this point in code, we already know that at least something will
955 // be drawn into this render surface, so the mask and replica should be
958 Layer
* mask_layer
= render_surface_layer
->mask_layer();
960 *did_paint_content
|= mask_layer
->Update(queue
, NULL
);
961 *need_more_updates
|= mask_layer
->NeedMoreUpdates();
964 Layer
* replica_mask_layer
=
965 render_surface_layer
->replica_layer() ?
966 render_surface_layer
->replica_layer()->mask_layer() : NULL
;
967 if (replica_mask_layer
) {
968 *did_paint_content
|= replica_mask_layer
->Update(queue
, NULL
);
969 *need_more_updates
|= replica_mask_layer
->NeedMoreUpdates();
973 void LayerTreeHost::PaintLayerContents(
974 const RenderSurfaceLayerList
& render_surface_layer_list
,
975 ResourceUpdateQueue
* queue
,
976 bool* did_paint_content
,
977 bool* need_more_updates
) {
978 OcclusionTracker
<Layer
> occlusion_tracker(
979 root_layer_
->render_surface()->content_rect());
980 occlusion_tracker
.set_minimum_tracking_size(
981 settings_
.minimum_occlusion_tracking_size
);
983 PrioritizeTextures(render_surface_layer_list
);
985 in_paint_layer_contents_
= true;
987 // Iterates front-to-back to allow for testing occlusion and performing
988 // culling during the tree walk.
989 typedef LayerIterator
<Layer
> LayerIteratorType
;
990 LayerIteratorType end
= LayerIteratorType::End(&render_surface_layer_list
);
991 for (LayerIteratorType it
=
992 LayerIteratorType::Begin(&render_surface_layer_list
);
995 occlusion_tracker
.EnterLayer(it
);
997 if (it
.represents_target_render_surface()) {
998 PaintMasksForRenderSurface(
999 *it
, queue
, did_paint_content
, need_more_updates
);
1000 } else if (it
.represents_itself()) {
1001 DCHECK(!it
->paint_properties().bounds
.IsEmpty());
1002 *did_paint_content
|= it
->Update(queue
, &occlusion_tracker
);
1003 *need_more_updates
|= it
->NeedMoreUpdates();
1004 // Note the '&&' with previous is-suitable state.
1005 // This means that once the layer-tree becomes unsuitable for gpu
1006 // rasterization due to some content, it will continue to be unsuitable
1007 // even if that content is replaced by gpu-friendly content.
1008 // This is to avoid switching back-and-forth between gpu and sw
1009 // rasterization which may be both bad for performance and visually
1011 content_is_suitable_for_gpu_rasterization_
&=
1012 it
->IsSuitableForGpuRasterization();
1015 occlusion_tracker
.LeaveLayer(it
);
1018 in_paint_layer_contents_
= false;
1021 void LayerTreeHost::ApplyScrollAndScale(ScrollAndScaleSet
* info
) {
1022 ScopedPtrVector
<SwapPromise
>::iterator it
= info
->swap_promises
.begin();
1023 for (; it
!= info
->swap_promises
.end(); ++it
) {
1024 scoped_ptr
<SwapPromise
> swap_promise(info
->swap_promises
.take(it
));
1025 TRACE_EVENT_FLOW_STEP0("input",
1027 TRACE_ID_DONT_MANGLE(swap_promise
->TraceId()),
1028 "Main thread scroll update");
1029 QueueSwapPromise(swap_promise
.Pass());
1032 gfx::Vector2dF inner_viewport_scroll_delta
;
1033 gfx::Vector2dF outer_viewport_scroll_delta
;
1035 if (root_layer_
.get()) {
1036 for (size_t i
= 0; i
< info
->scrolls
.size(); ++i
) {
1037 Layer
* layer
= LayerTreeHostCommon::FindLayerInSubtree(
1038 root_layer_
.get(), info
->scrolls
[i
].layer_id
);
1041 if (layer
== outer_viewport_scroll_layer_
.get()) {
1042 outer_viewport_scroll_delta
+= info
->scrolls
[i
].scroll_delta
;
1043 } else if (layer
== inner_viewport_scroll_layer_
.get()) {
1044 inner_viewport_scroll_delta
+= info
->scrolls
[i
].scroll_delta
;
1046 layer
->SetScrollOffsetFromImplSide(
1047 gfx::ScrollOffsetWithDelta(layer
->scroll_offset(),
1048 info
->scrolls
[i
].scroll_delta
));
1053 if (!inner_viewport_scroll_delta
.IsZero() ||
1054 !outer_viewport_scroll_delta
.IsZero() || info
->page_scale_delta
!= 1.f
||
1055 !info
->elastic_overscroll_delta
.IsZero() || info
->top_controls_delta
) {
1056 // Preemptively apply the scroll offset and scale delta here before sending
1057 // it to the client. If the client comes back and sets it to the same
1058 // value, then the layer can early out without needing a full commit.
1059 if (inner_viewport_scroll_layer_
.get()) {
1060 inner_viewport_scroll_layer_
->SetScrollOffsetFromImplSide(
1061 gfx::ScrollOffsetWithDelta(
1062 inner_viewport_scroll_layer_
->scroll_offset(),
1063 inner_viewport_scroll_delta
));
1066 if (outer_viewport_scroll_layer_
.get()) {
1067 outer_viewport_scroll_layer_
->SetScrollOffsetFromImplSide(
1068 gfx::ScrollOffsetWithDelta(
1069 outer_viewport_scroll_layer_
->scroll_offset(),
1070 outer_viewport_scroll_delta
));
1073 ApplyPageScaleDeltaFromImplSide(info
->page_scale_delta
);
1074 elastic_overscroll_
+= info
->elastic_overscroll_delta
;
1075 // TODO(ccameron): pass the elastic overscroll here so that input events
1076 // may be translated appropriately.
1077 client_
->ApplyViewportDeltas(
1078 inner_viewport_scroll_delta
, outer_viewport_scroll_delta
,
1079 info
->elastic_overscroll_delta
, info
->page_scale_delta
,
1080 info
->top_controls_delta
);
1084 void LayerTreeHost::StartRateLimiter() {
1085 if (inside_begin_main_frame_
)
1088 if (!rate_limit_timer_
.IsRunning()) {
1089 rate_limit_timer_
.Start(FROM_HERE
,
1092 &LayerTreeHost::RateLimit
);
1096 void LayerTreeHost::StopRateLimiter() {
1097 rate_limit_timer_
.Stop();
1100 void LayerTreeHost::RateLimit() {
1101 // Force a no-op command on the compositor context, so that any ratelimiting
1102 // commands will wait for the compositing context, and therefore for the
1104 proxy_
->ForceSerializeOnSwapBuffers();
1105 client_
->RateLimitSharedMainThreadContext();
1108 bool LayerTreeHost::AlwaysUsePartialTextureUpdates() {
1109 if (!proxy_
->GetRendererCapabilities().allow_partial_texture_updates
)
1111 return !proxy_
->HasImplThread();
1114 size_t LayerTreeHost::MaxPartialTextureUpdates() const {
1115 size_t max_partial_texture_updates
= 0;
1116 if (proxy_
->GetRendererCapabilities().allow_partial_texture_updates
&&
1117 !settings_
.impl_side_painting
) {
1118 max_partial_texture_updates
=
1119 std::min(settings_
.max_partial_texture_updates
,
1120 proxy_
->MaxPartialTextureUpdates());
1122 return max_partial_texture_updates
;
1125 bool LayerTreeHost::RequestPartialTextureUpdate() {
1126 if (partial_texture_update_requests_
>= MaxPartialTextureUpdates())
1129 partial_texture_update_requests_
++;
1133 void LayerTreeHost::SetDeviceScaleFactor(float device_scale_factor
) {
1134 if (device_scale_factor
== device_scale_factor_
)
1136 device_scale_factor_
= device_scale_factor
;
1138 property_trees_
.needs_rebuild
= true;
1142 void LayerTreeHost::UpdateTopControlsState(TopControlsState constraints
,
1143 TopControlsState current
,
1145 // Top controls are only used in threaded mode.
1146 proxy_
->ImplThreadTaskRunner()->PostTask(
1148 base::Bind(&TopControlsManager::UpdateTopControlsState
,
1149 top_controls_manager_weak_ptr_
,
1155 void LayerTreeHost::AnimateLayers(base::TimeTicks monotonic_time
) {
1156 if (!settings_
.accelerated_animation_enabled
)
1159 AnimationEventsVector events
;
1160 if (animation_registrar_
->AnimateLayers(monotonic_time
)) {
1161 animation_registrar_
->UpdateAnimationState(true, &events
);
1162 if (!events
.empty())
1163 property_trees_
.needs_rebuild
= true;
1167 UIResourceId
LayerTreeHost::CreateUIResource(UIResourceClient
* client
) {
1170 UIResourceId next_id
= next_ui_resource_id_
++;
1171 DCHECK(ui_resource_client_map_
.find(next_id
) ==
1172 ui_resource_client_map_
.end());
1174 bool resource_lost
= false;
1175 UIResourceRequest
request(UIResourceRequest::UI_RESOURCE_CREATE
, next_id
,
1176 client
->GetBitmap(next_id
, resource_lost
));
1177 ui_resource_request_queue_
.push_back(request
);
1179 UIResourceClientData data
;
1180 data
.client
= client
;
1181 data
.size
= request
.GetBitmap().GetSize();
1183 ui_resource_client_map_
[request
.GetId()] = data
;
1184 return request
.GetId();
1187 // Deletes a UI resource. May safely be called more than once.
1188 void LayerTreeHost::DeleteUIResource(UIResourceId uid
) {
1189 UIResourceClientMap::iterator iter
= ui_resource_client_map_
.find(uid
);
1190 if (iter
== ui_resource_client_map_
.end())
1193 UIResourceRequest
request(UIResourceRequest::UI_RESOURCE_DELETE
, uid
);
1194 ui_resource_request_queue_
.push_back(request
);
1195 ui_resource_client_map_
.erase(iter
);
1198 void LayerTreeHost::RecreateUIResources() {
1199 for (UIResourceClientMap::iterator iter
= ui_resource_client_map_
.begin();
1200 iter
!= ui_resource_client_map_
.end();
1202 UIResourceId uid
= iter
->first
;
1203 const UIResourceClientData
& data
= iter
->second
;
1204 bool resource_lost
= true;
1205 UIResourceRequest
request(UIResourceRequest::UI_RESOURCE_CREATE
, uid
,
1206 data
.client
->GetBitmap(uid
, resource_lost
));
1207 ui_resource_request_queue_
.push_back(request
);
1211 // Returns the size of a resource given its id.
1212 gfx::Size
LayerTreeHost::GetUIResourceSize(UIResourceId uid
) const {
1213 UIResourceClientMap::const_iterator iter
= ui_resource_client_map_
.find(uid
);
1214 if (iter
== ui_resource_client_map_
.end())
1217 const UIResourceClientData
& data
= iter
->second
;
1221 void LayerTreeHost::RegisterViewportLayers(
1222 scoped_refptr
<Layer
> overscroll_elasticity_layer
,
1223 scoped_refptr
<Layer
> page_scale_layer
,
1224 scoped_refptr
<Layer
> inner_viewport_scroll_layer
,
1225 scoped_refptr
<Layer
> outer_viewport_scroll_layer
) {
1226 overscroll_elasticity_layer_
= overscroll_elasticity_layer
;
1227 page_scale_layer_
= page_scale_layer
;
1228 inner_viewport_scroll_layer_
= inner_viewport_scroll_layer
;
1229 outer_viewport_scroll_layer_
= outer_viewport_scroll_layer
;
1232 void LayerTreeHost::RegisterSelection(const LayerSelection
& selection
) {
1233 if (selection_
== selection
)
1236 selection_
= selection
;
1240 int LayerTreeHost::ScheduleMicroBenchmark(
1241 const std::string
& benchmark_name
,
1242 scoped_ptr
<base::Value
> value
,
1243 const MicroBenchmark::DoneCallback
& callback
) {
1244 return micro_benchmark_controller_
.ScheduleRun(
1245 benchmark_name
, value
.Pass(), callback
);
1248 bool LayerTreeHost::SendMessageToMicroBenchmark(int id
,
1249 scoped_ptr
<base::Value
> value
) {
1250 return micro_benchmark_controller_
.SendMessage(id
, value
.Pass());
1253 void LayerTreeHost::InsertSwapPromiseMonitor(SwapPromiseMonitor
* monitor
) {
1254 swap_promise_monitor_
.insert(monitor
);
1257 void LayerTreeHost::RemoveSwapPromiseMonitor(SwapPromiseMonitor
* monitor
) {
1258 swap_promise_monitor_
.erase(monitor
);
1261 void LayerTreeHost::NotifySwapPromiseMonitorsOfSetNeedsCommit() {
1262 std::set
<SwapPromiseMonitor
*>::iterator it
= swap_promise_monitor_
.begin();
1263 for (; it
!= swap_promise_monitor_
.end(); it
++)
1264 (*it
)->OnSetNeedsCommitOnMain();
1267 void LayerTreeHost::QueueSwapPromise(scoped_ptr
<SwapPromise
> swap_promise
) {
1268 DCHECK(swap_promise
);
1269 swap_promise_list_
.push_back(swap_promise
.Pass());
1272 void LayerTreeHost::BreakSwapPromises(SwapPromise::DidNotSwapReason reason
) {
1273 for (auto* swap_promise
: swap_promise_list_
)
1274 swap_promise
->DidNotSwap(reason
);
1275 swap_promise_list_
.clear();
1278 void LayerTreeHost::set_surface_id_namespace(uint32_t id_namespace
) {
1279 surface_id_namespace_
= id_namespace
;
1282 SurfaceSequence
LayerTreeHost::CreateSurfaceSequence() {
1283 return SurfaceSequence(surface_id_namespace_
, next_surface_sequence_
++);
1286 void LayerTreeHost::SetChildrenNeedBeginFrames(
1287 bool children_need_begin_frames
) const {
1288 proxy_
->SetChildrenNeedBeginFrames(children_need_begin_frames
);
1291 void LayerTreeHost::SendBeginFramesToChildren(
1292 const BeginFrameArgs
& args
) const {
1293 client_
->SendBeginFramesToChildren(args
);
1296 void LayerTreeHost::SetAuthoritativeVSyncInterval(
1297 const base::TimeDelta
& interval
) {
1298 proxy_
->SetAuthoritativeVSyncInterval(interval
);