Chromium Code Reviews| Index: cc/layers/surface_layer.cc |
| diff --git a/cc/layers/surface_layer.cc b/cc/layers/surface_layer.cc |
| index 573f97b9b13280a3c9f5806052f0c7d81e52bd74..a5d17448b80e19a4e48faae3d30764297f75fea4 100644 |
| --- a/cc/layers/surface_layer.cc |
| +++ b/cc/layers/surface_layer.cc |
| @@ -99,11 +99,41 @@ bool SurfaceLayer::HasDrawableContent() const { |
| return primary_surface_info_.is_valid() && Layer::HasDrawableContent(); |
| } |
| +const SurfaceId* SurfaceLayer::GetSurfaceId(LayerTreeHost* new_host) { |
| + LayerTreeHost* old_host = layer_tree_host(); |
| + DCHECK(!old_host || !new_host || |
| + old_host->GetSettings().enable_surface_synchronization == |
| + new_host->GetSettings().enable_surface_synchronization); |
| + |
| + bool enable_surface_synchronization; |
| + if (old_host) { |
| + enable_surface_synchronization = |
| + old_host->GetSettings().enable_surface_synchronization; |
| + } else { |
| + DCHECK(new_host); |
| + enable_surface_synchronization = |
| + new_host->GetSettings().enable_surface_synchronization; |
| + } |
| + |
| + if (enable_surface_synchronization) { |
| + if (fallback_surface_info_.is_valid()) |
| + return &fallback_surface_info_.id(); |
| + } else { |
| + return &primary_surface_info_.id(); |
| + } |
| + return nullptr; |
|
jaydasika
2017/05/23 00:25:14
Not sure if this is correct / there is a simpler w
|
| +} |
| + |
| void SurfaceLayer::SetLayerTreeHost(LayerTreeHost* host) { |
| if (layer_tree_host() == host) { |
| - Layer::SetLayerTreeHost(host); |
| return; |
| } |
| + const SurfaceId* surface_id = GetSurfaceId(host); |
| + |
| + if (layer_tree_host() && surface_id) { |
| + layer_tree_host()->RemoveSurfaceLayerId(*surface_id); |
| + } |
| + |
| RemoveReference(std::move(primary_reference_returner_)); |
| RemoveReference(std::move(fallback_reference_returner_)); |
| Layer::SetLayerTreeHost(host); |
| @@ -116,6 +146,8 @@ void SurfaceLayer::SetLayerTreeHost(LayerTreeHost* host) { |
| fallback_reference_returner_ = ref_factory_->CreateReference( |
| layer_tree_host(), fallback_surface_info_.id()); |
| } |
| + if (surface_id) |
| + layer_tree_host()->AddSurfaceLayerId(*surface_id); |
| } |
| } |