cc: Take in LocalSurfaceId with a new size for LayerTreeHost.

Specify a new LocalSurfaceId when changing the size of the LayerTreeHost.
In case a new LocalSurfaceId is not already available, it is reset to an
invalid id, so that commits are deferred until a valid id is available
(the renderer gets this id from the browser, the browser receives this
id from mus (when running with mus)).

BUG=733694

Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel
Change-Id: If73bce29747cc60379630377e7e74953e02f3f9f
Reviewed-on: https://chromium-review.googlesource.com/606507
Commit-Queue: Sadrul Chowdhury <[email protected]>
Reviewed-by: Fady Samuel <[email protected]>
Reviewed-by: Antoine Labour <[email protected]>
Cr-Commit-Position: refs/heads/master@{#493222}
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
index f5a8d1b..8b007888 100644
--- a/content/renderer/render_widget.cc
+++ b/content/renderer/render_widget.cc
@@ -1256,18 +1256,18 @@
     local_surface_id_ = *params.local_surface_id;
 
   if (compositor_) {
-    compositor_->SetViewportSize(params.physical_backing_size);
-    compositor_->SetBrowserControlsHeight(
-        params.top_controls_height, params.bottom_controls_height,
-        params.browser_controls_shrink_blink_size);
-    compositor_->SetRasterColorSpace(
-        screen_info_.color_space.GetRasterColorSpace());
     // If surface synchronization is enable, then this will use the provided
     // |local_surface_id_| to submit the next generated CompositorFrame.
     // If the ID is not valid, then the compositor will defer commits until
     // it receives a valid surface ID. This is a no-op if surface
     // synchronization is disabled.
-    compositor_->SetLocalSurfaceId(local_surface_id_);
+    compositor_->SetViewportSize(params.physical_backing_size,
+                                 local_surface_id_);
+    compositor_->SetBrowserControlsHeight(
+        params.top_controls_height, params.bottom_controls_height,
+        params.browser_controls_shrink_blink_size);
+    compositor_->SetRasterColorSpace(
+        screen_info_.color_space.GetRasterColorSpace());
   }
 
   visible_viewport_size_ = params.visible_viewport_size;
@@ -1338,8 +1338,11 @@
 
 void RenderWidget::AutoResizeCompositor()  {
   physical_backing_size_ = gfx::ScaleToCeiledSize(size_, device_scale_factor_);
+  // A new LocalSurfaceId will need to be allocated by the browser for the new
+  // size.
+  local_surface_id_ = viz::LocalSurfaceId();
   if (compositor_)
-    compositor_->SetViewportSize(physical_backing_size_);
+    compositor_->SetViewportSize(physical_backing_size_, local_surface_id_);
 }
 
 blink::WebLayerTreeView* RenderWidget::InitializeLayerTreeView() {
@@ -1356,12 +1359,11 @@
   compositor_->Initialize(std::move(layer_tree_host),
                           std::move(animation_host));
 
-  compositor_->SetViewportSize(physical_backing_size_);
+  compositor_->SetViewportSize(physical_backing_size_, local_surface_id_);
   OnDeviceScaleFactorChanged();
   compositor_->SetRasterColorSpace(
       screen_info_.color_space.GetRasterColorSpace());
   compositor_->SetContentSourceId(current_content_source_id_);
-  compositor_->SetLocalSurfaceId(local_surface_id_);
   // For background pages and certain tests, we don't want to trigger
   // LayerTreeFrameSink creation.
   bool should_generate_frame_sink =