summaryrefslogtreecommitdiff
path: root/chromium/cc/trees/layer_tree_host.cc
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-08-24 12:15:48 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-08-28 13:30:04 +0000
commitb014812705fc80bff0a5c120dfcef88f349816dc (patch)
tree25a2e2d9fa285f1add86aa333389a839f81a39ae /chromium/cc/trees/layer_tree_host.cc
parent9f4560b1027ae06fdb497023cdcaf91b8511fa74 (diff)
downloadqtwebengine-chromium-b014812705fc80bff0a5c120dfcef88f349816dc.tar.gz
BASELINE: Update Chromium to 68.0.3440.125
Change-Id: I23f19369e01f688e496f5bf179abb521ad73874f Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/cc/trees/layer_tree_host.cc')
-rw-r--r--chromium/cc/trees/layer_tree_host.cc125
1 files changed, 74 insertions, 51 deletions
diff --git a/chromium/cc/trees/layer_tree_host.cc b/chromium/cc/trees/layer_tree_host.cc
index d8bf091317a..b47182219c0 100644
--- a/chromium/cc/trees/layer_tree_host.cc
+++ b/chromium/cc/trees/layer_tree_host.cc
@@ -159,7 +159,7 @@ void LayerTreeHost::SetUIResourceManagerForTesting(
}
void LayerTreeHost::InitializeProxy(std::unique_ptr<Proxy> proxy) {
- TRACE_EVENT0("cc", "LayerTreeHostInProcess::InitializeForReal");
+ TRACE_EVENT0("cc", "LayerTreeHost::InitializeForReal");
DCHECK(task_runner_provider_);
proxy_ = std::move(proxy);
@@ -174,7 +174,7 @@ LayerTreeHost::~LayerTreeHost() {
// Track when we're inside a main frame to see if compositor is being
// destroyed midway which causes a crash. crbug.com/654672
DCHECK(!inside_main_frame_);
- TRACE_EVENT0("cc", "LayerTreeHostInProcess::~LayerTreeHostInProcess");
+ TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost");
// Clear any references into the LayerTreeHost.
mutator_host_->SetMutatorHostClient(nullptr);
@@ -280,25 +280,12 @@ void LayerTreeHost::RequestMainFrameUpdate(VisualStateUpdate requested_update) {
// This function commits the LayerTreeHost to an impl tree. When modifying
// this function, keep in mind that the function *runs* on the impl thread! Any
// code that is logically a main thread operation, e.g. deletion of a Layer,
-// should be delayed until the LayerTreeHostInProcess::CommitComplete, which
-// will run after the commit, but on the main thread.
+// should be delayed until the LayerTreeHost::CommitComplete, which will run
+// after the commit, but on the main thread.
void LayerTreeHost::FinishCommitOnImplThread(
LayerTreeHostImpl* host_impl) {
DCHECK(task_runner_provider_->IsImplThread());
- bool is_new_trace;
- TRACE_EVENT_IS_NEW_TRACE(&is_new_trace);
- if (is_new_trace &&
- frame_viewer_instrumentation::IsTracingLayerTreeSnapshots() &&
- root_layer()) {
- // We'll be dumping layer trees as part of trace, so make sure
- // PushPropertiesTo() propagates layer debug info to the impl side --
- // otherwise this won't happen for the layers that remain unchanged since
- // tracing started.
- LayerTreeHostCommon::CallFunctionForEveryLayer(
- this, [](Layer* layer) { layer->SetNeedsPushProperties(); });
- }
-
LayerTreeImpl* sync_tree = host_impl->sync_tree();
sync_tree->lifecycle().AdvanceTo(LayerTreeLifecycle::kBeginningSync);
@@ -341,7 +328,7 @@ void LayerTreeHost::FinishCommitOnImplThread(
}
{
- TRACE_EVENT0("cc", "LayerTreeHostInProcess::PushProperties");
+ TRACE_EVENT0("cc", "LayerTreeHost::PushProperties");
PushPropertyTreesTo(sync_tree);
sync_tree->lifecycle().AdvanceTo(LayerTreeLifecycle::kSyncedPropertyTrees);
@@ -377,7 +364,7 @@ void LayerTreeHost::FinishCommitOnImplThread(
// TODO(pdr): Enforce this comment with DCHECKS and a lifecycle state.
sync_tree->UpdatePropertyTreeAnimationFromMainThread();
- TRACE_EVENT0("cc", "LayerTreeHostInProcess::AnimationHost::PushProperties");
+ TRACE_EVENT0("cc", "LayerTreeHost::AnimationHost::PushProperties");
DCHECK(host_impl->mutator_host());
mutator_host_->PushPropertiesTo(host_impl->mutator_host());
@@ -427,13 +414,29 @@ void LayerTreeHost::PushPropertyTreesTo(LayerTreeImpl* tree_impl) {
void LayerTreeHost::WillCommit() {
swap_promise_manager_.WillCommit();
client_->WillCommit();
+
+ if (frame_viewer_instrumentation::IsTracingLayerTreeSnapshots()) {
+ bool is_new_trace;
+ TRACE_EVENT_IS_NEW_TRACE(&is_new_trace);
+ if (is_new_trace) {
+ // We'll be dumping layer trees as part of trace, so make sure
+ // PushPropertiesTo() propagates layer debug info to the impl side --
+ // otherwise this won't happen for the layers that remain unchanged since
+ // tracing started.
+ LayerTreeHostCommon::CallFunctionForEveryLayer(
+ this, [](Layer* layer) { layer->SetNeedsPushProperties(); });
+ }
+
+ for (Layer* layer : LayersThatShouldPushProperties())
+ layer->UpdateDebugInfo();
+ }
}
void LayerTreeHost::UpdateDeferCommitsInternal() {
proxy_->SetDeferCommits(defer_commits_ ||
(settings_.enable_surface_synchronization &&
- !local_surface_id_.is_valid()));
+ !local_surface_id_from_parent_.is_valid()));
}
bool LayerTreeHost::IsUsingLayerLists() const {
@@ -451,7 +454,7 @@ void LayerTreeHost::CommitComplete() {
void LayerTreeHost::SetLayerTreeFrameSink(
std::unique_ptr<LayerTreeFrameSink> surface) {
- TRACE_EVENT0("cc", "LayerTreeHostInProcess::SetLayerTreeFrameSink");
+ TRACE_EVENT0("cc", "LayerTreeHost::SetLayerTreeFrameSink");
DCHECK(surface);
DCHECK(!new_layer_tree_frame_sink_);
@@ -514,7 +517,7 @@ LayerTreeHost::CreateLayerTreeHostImpl(
}
void LayerTreeHost::DidLoseLayerTreeFrameSink() {
- TRACE_EVENT0("cc", "LayerTreeHostInProcess::DidLoseLayerTreeFrameSink");
+ TRACE_EVENT0("cc", "LayerTreeHost::DidLoseLayerTreeFrameSink");
DCHECK(task_runner_provider_->IsMainThread());
SetNeedsCommit();
}
@@ -598,9 +601,9 @@ void LayerTreeHost::SetHasGpuRasterizationTrigger(bool has_trigger) {
return;
has_gpu_rasterization_trigger_ = has_trigger;
- TRACE_EVENT_INSTANT1(
- "cc", "LayerTreeHostInProcess::SetHasGpuRasterizationTrigger",
- TRACE_EVENT_SCOPE_THREAD, "has_trigger", has_gpu_rasterization_trigger_);
+ TRACE_EVENT_INSTANT1("cc", "LayerTreeHost::SetHasGpuRasterizationTrigger",
+ TRACE_EVENT_SCOPE_THREAD, "has_trigger",
+ has_gpu_rasterization_trigger_);
}
void LayerTreeHost::ApplyPageScaleDeltaFromImplSide(
@@ -745,8 +748,8 @@ void LayerTreeHost::RecordGpuRasterizationHistogram(
}
bool LayerTreeHost::DoUpdateLayers(Layer* root_layer) {
- TRACE_EVENT1("cc", "LayerTreeHostInProcess::DoUpdateLayers",
- "source_frame_number", SourceFrameNumber());
+ TRACE_EVENT1("cc", "LayerTreeHost::DoUpdateLayers", "source_frame_number",
+ SourceFrameNumber());
UpdateHudLayer(debug_state_.ShowHudInfo());
@@ -777,11 +780,9 @@ bool LayerTreeHost::DoUpdateLayers(Layer* root_layer) {
{
base::AutoReset<bool> update_property_trees(&in_update_property_trees_,
true);
- TRACE_EVENT0("cc",
- "LayerTreeHostInProcess::UpdateLayers::BuildPropertyTrees");
- TRACE_EVENT0(
- TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"),
- "LayerTreeHostInProcessCommon::ComputeVisibleRectsWithPropertyTrees");
+ TRACE_EVENT0("cc", "LayerTreeHost::UpdateLayers::BuildPropertyTrees");
+ TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"),
+ "LayerTreeHostCommon::ComputeVisibleRectsWithPropertyTrees");
PropertyTrees* property_trees = &property_trees_;
if (!IsUsingLayerLists()) {
// In SPv2 the property trees should have been built by the
@@ -791,15 +792,15 @@ bool LayerTreeHost::DoUpdateLayers(Layer* root_layer) {
outer_viewport_scroll_layer(), overscroll_elasticity_layer(),
elastic_overscroll_, page_scale_factor_, device_scale_factor_,
gfx::Rect(device_viewport_size_), identity_transform, property_trees);
- TRACE_EVENT_INSTANT1(
- "cc", "LayerTreeHostInProcess::UpdateLayers_BuiltPropertyTrees",
- TRACE_EVENT_SCOPE_THREAD, "property_trees",
- property_trees->AsTracedValue());
+ TRACE_EVENT_INSTANT1("cc",
+ "LayerTreeHost::UpdateLayers_BuiltPropertyTrees",
+ TRACE_EVENT_SCOPE_THREAD, "property_trees",
+ property_trees->AsTracedValue());
} else {
- TRACE_EVENT_INSTANT1(
- "cc", "LayerTreeHostInProcess::UpdateLayers_ReceivedPropertyTrees",
- TRACE_EVENT_SCOPE_THREAD, "property_trees",
- property_trees->AsTracedValue());
+ TRACE_EVENT_INSTANT1("cc",
+ "LayerTreeHost::UpdateLayers_ReceivedPropertyTrees",
+ TRACE_EVENT_SCOPE_THREAD, "property_trees",
+ property_trees->AsTracedValue());
}
draw_property_utils::UpdatePropertyTrees(this, property_trees);
@@ -1054,9 +1055,8 @@ void LayerTreeHost::SetEventListenerProperties(
void LayerTreeHost::SetViewportSizeAndScale(
const gfx::Size& device_viewport_size,
float device_scale_factor,
- const viz::LocalSurfaceId& local_surface_id) {
- if (settings_.enable_surface_synchronization)
- SetLocalSurfaceId(local_surface_id);
+ const viz::LocalSurfaceId& local_surface_id_from_parent) {
+ SetLocalSurfaceIdFromParent(local_surface_id_from_parent);
bool changed = false;
if (device_viewport_size_ != device_viewport_size) {
@@ -1083,7 +1083,9 @@ void LayerTreeHost::SetViewportSizeAndScale(
#if defined(OS_MACOSX)
// TODO(ccameron): This check is not valid on Aura or Mus yet, but should
// be.
- CHECK(!has_pushed_local_surface_id_ || !local_surface_id_.is_valid());
+ CHECK(!has_pushed_local_surface_id_from_parent_ ||
+ new_local_surface_id_request_ ||
+ !local_surface_id_from_parent_.is_valid());
#endif
}
}
@@ -1180,16 +1182,34 @@ void LayerTreeHost::SetContentSourceId(uint32_t id) {
SetNeedsCommit();
}
-void LayerTreeHost::SetLocalSurfaceId(
- const viz::LocalSurfaceId& local_surface_id) {
- if (local_surface_id_ == local_surface_id)
+void LayerTreeHost::SetLocalSurfaceIdFromParent(
+ const viz::LocalSurfaceId& local_surface_id_from_parent) {
+ if (local_surface_id_from_parent_ == local_surface_id_from_parent)
return;
- local_surface_id_ = local_surface_id;
- has_pushed_local_surface_id_ = false;
+ local_surface_id_from_parent_ = local_surface_id_from_parent;
+ has_pushed_local_surface_id_from_parent_ = false;
UpdateDeferCommitsInternal();
SetNeedsCommit();
}
+void LayerTreeHost::RequestNewLocalSurfaceId() {
+ // If surface synchronization is enabled, then we can still request a new
+ // viz::LocalSurfaceId but that request will be deferred until we have a valid
+ // viz::LocalSurfaceId from the parent.
+ DCHECK(settings_.enable_surface_synchronization ||
+ local_surface_id_from_parent_.is_valid());
+ if (new_local_surface_id_request_)
+ return;
+ new_local_surface_id_request_ = true;
+ SetNeedsCommit();
+}
+
+bool LayerTreeHost::TakeNewLocalSurfaceIdRequest() {
+ bool new_local_surface_id_request = new_local_surface_id_request_;
+ new_local_surface_id_request_ = false;
+ return new_local_surface_id_request;
+}
+
void LayerTreeHost::RegisterLayer(Layer* layer) {
DCHECK(!LayerById(layer->id()));
DCHECK(!in_paint_layer_contents_);
@@ -1375,8 +1395,11 @@ void LayerTreeHost::PushLayerTreePropertiesTo(LayerTreeImpl* tree_impl) {
tree_impl->set_content_source_id(content_source_id_);
- tree_impl->set_local_surface_id(local_surface_id_);
- has_pushed_local_surface_id_ = true;
+ if (TakeNewLocalSurfaceIdRequest())
+ tree_impl->RequestNewLocalSurfaceId();
+
+ tree_impl->SetLocalSurfaceIdFromParent(local_surface_id_from_parent_);
+ has_pushed_local_surface_id_from_parent_ = true;
if (pending_page_scale_animation_) {
tree_impl->SetPendingPageScaleAnimation(