Cherry-pick: aw: Reset parent draw constraints on tear down

Clean cherry-pick of chromium crrev.com/r290450

BUG: 16948043

Original description:

Without this, the same webview getting attached again but at a different
part of the view tree would be getting stale and completely wrong parent
draw constraints.

A classic example of this is when webview going into full screen video
mode.

Change-Id: I9d6eafcb83b5fdee4bd9fe17c0f0392ac2d8fd52
diff --git a/android_webview/browser/hardware_renderer.cc b/android_webview/browser/hardware_renderer.cc
index e0dab89..47e84bb 100644
--- a/android_webview/browser/hardware_renderer.cc
+++ b/android_webview/browser/hardware_renderer.cc
@@ -116,6 +116,10 @@
 #endif  // DCHECK_IS_ON
 
   resource_collection_->SetClient(NULL);
+
+  // Reset draw constraints.
+  shared_renderer_state_->UpdateDrawConstraints(
+      ParentCompositorDrawConstraints());
 }
 
 void HardwareRenderer::DidBeginMainFrame() {
diff --git a/android_webview/browser/shared_renderer_state.cc b/android_webview/browser/shared_renderer_state.cc
index 6ee07ab..508fdc4 100644
--- a/android_webview/browser/shared_renderer_state.cc
+++ b/android_webview/browser/shared_renderer_state.cc
@@ -146,12 +146,15 @@
   return draw_gl_input_.Pass();
 }
 
+void SharedRendererState::UpdateDrawConstraints(
+    const ParentCompositorDrawConstraints& parent_draw_constraints) {
+  base::AutoLock lock(lock_);
+  parent_draw_constraints_ = parent_draw_constraints;
+}
+
 void SharedRendererState::PostExternalDrawConstraintsToChildCompositor(
     const ParentCompositorDrawConstraints& parent_draw_constraints) {
-  {
-    base::AutoLock lock(lock_);
-    parent_draw_constraints_ = parent_draw_constraints;
-  }
+  UpdateDrawConstraints(parent_draw_constraints);
 
   // No need to hold the lock_ during the post task.
   ui_loop_->PostTask(
diff --git a/android_webview/browser/shared_renderer_state.h b/android_webview/browser/shared_renderer_state.h
index 43acfde..2245f73 100644
--- a/android_webview/browser/shared_renderer_state.h
+++ b/android_webview/browser/shared_renderer_state.h
@@ -57,6 +57,8 @@
   scoped_ptr<DrawGLInput> PassDrawGLInput();
 
   bool IsInsideHardwareRelease() const;
+  void UpdateDrawConstraints(
+      const ParentCompositorDrawConstraints& parent_draw_constraints);
   void PostExternalDrawConstraintsToChildCompositor(
       const ParentCompositorDrawConstraints& parent_draw_constraints);