Cherry-pick: aw: Skip hardware onDraw when visible rect is empty

Clean cherry-pick of crrev.com/693c6a04c69d69a1240e4b83e2ec7fea459acda4

BUG: 17403173

Original description:

Framework does not clamp onDraw to only the visible area. However must
still request functor in this case to support rt-side animation, and to
obtain the correct draw matrix. This means HardwareRenderer must be able
to handle not having a parent frame available.

Review URL: https://codereview.chromium.org/551023002

Change-Id: I83b2b9c8bf553a5b11f0a87af8fe5b4329a9fabc
Cr-Commit-Position: refs/heads/master@{#294093}
diff --git a/android_webview/browser/browser_view_renderer.cc b/android_webview/browser/browser_view_renderer.cc
index 1bf4f3d..29d475c 100644
--- a/android_webview/browser/browser_view_renderer.cc
+++ b/android_webview/browser/browser_view_renderer.cc
@@ -248,6 +248,9 @@
   if (!compositor_)
     return false;
 
+  if (last_on_draw_global_visible_rect_.IsEmpty())
+    return client_->RequestDrawGL(java_canvas, false);
+
   if (!hardware_enabled_) {
     hardware_enabled_ = compositor_->InitializeHwDraw();
     if (hardware_enabled_) {
diff --git a/android_webview/browser/hardware_renderer.cc b/android_webview/browser/hardware_renderer.cc
index 47e84bb..43d38e2 100644
--- a/android_webview/browser/hardware_renderer.cc
+++ b/android_webview/browser/hardware_renderer.cc
@@ -133,10 +133,9 @@
 
 void HardwareRenderer::CommitFrame() {
   scoped_ptr<DrawGLInput> input = shared_renderer_state_->PassDrawGLInput();
-  if (!input.get()) {
-    DLOG(WARNING) << "No frame to commit";
+  // Happens with empty global visible rect.
+  if (!input.get())
     return;
-  }
 
   DCHECK(!input->frame.gl_frame_data);
   DCHECK(!input->frame.software_frame_data);
@@ -186,11 +185,6 @@
     return;
   }
 
-  if (!delegated_layer_.get()) {
-    DLOG(ERROR) << "No frame committed";
-    return;
-  }
-
   // TODO(boliu): Handle context loss.
   if (last_egl_context_ != current_context)
     DLOG(WARNING) << "EGLContextChanged";
@@ -210,6 +204,9 @@
         draw_constraints);
   }
 
+  if (!delegated_layer_.get())
+    return;
+
   viewport_.SetSize(draw_info->width, draw_info->height);
   layer_tree_host_->SetViewportSize(viewport_);
   clip_.SetRect(draw_info->clip_left,