Implement transform/clip support for Android WebView.

Transforms are applied above the root-layer.  I fixed LTHCommon to forward
root-layer transforms to sublayers, as the RenderSurface-based logic was previously
clearing transforms and copying over only the scale portion.

The clip rect is treated as the viewport for the purposes of DrawQuads and Renderer
(this is required to avoid awful performance when the WebView is much larger than
the screen).  Because y-flipping the clip rect depends on knowledge of the true
surface size, I also needed to add a new OutputSurface::SurfaceSize() getter and refactored
viewport size throughout the Renderers to separate render-pass draw rect, glViewport rect,
and surface size.

Scale and translate transforms work with this patch, but rotation is still broken.

New tests: LayerTreeHostCommonTest.TransformAboveRootLayer,
GLRendererTest2.ScissorAndViewportWithinNonreshapableSurface,
RendererPixelTest/2* and 3*

NOTRY=true
BUG=230463

Review URL: https://chromiumcodereview.appspot.com/15579002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@204650 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h
index f65922aa..e3671cf 100644
--- a/cc/trees/layer_tree_host_impl.h
+++ b/cc/trees/layer_tree_host_impl.h
@@ -176,8 +176,8 @@
   gfx::SizeF VisibleViewportSize() const;
 
   // RendererClient implementation
+  virtual gfx::Rect DeviceViewport() const OVERRIDE;
  private:
-  virtual gfx::Size DeviceViewportSize() const OVERRIDE;
   virtual float DeviceScaleFactor() const OVERRIDE;
   virtual const LayerTreeSettings& Settings() const OVERRIDE;
  public:
@@ -207,6 +207,8 @@
       OVERRIDE;
   virtual void OnSendFrameToParentCompositorAck(const CompositorFrameAck& ack)
       OVERRIDE;
+  virtual void SetExternalDrawConstraints(const gfx::Transform& transform,
+                                          gfx::Rect viewport) OVERRIDE;
 
   // Called from LayerTreeImpl.
   void OnCanDrawStateChangedForTree();
@@ -267,6 +269,8 @@
   void SetDeviceScaleFactor(float device_scale_factor);
   float device_scale_factor() const { return device_scale_factor_; }
 
+  const gfx::Transform& DeviceTransform() const;
+
   scoped_ptr<ScrollAndScaleSet> ProcessScrollDeltas();
 
   bool needs_animate_layers() const {
@@ -457,9 +461,6 @@
   LayerScrollOffsetDelegate* root_layer_scroll_offset_delegate_;
   LayerTreeSettings settings_;
   LayerTreeDebugState debug_state_;
-  gfx::Size device_viewport_size_;
-  float overdraw_bottom_height_;
-  float device_scale_factor_;
   bool visible_;
   ManagedMemoryPolicy managed_memory_policy_;
 
@@ -493,6 +494,26 @@
   size_t last_sent_memory_visible_and_nearby_bytes_;
   size_t last_sent_memory_use_bytes_;
 
+  // Viewport size passed in from the main thread, in physical pixels.
+  gfx::Size device_viewport_size_;
+
+  // Conversion factor from CSS pixels to physical pixels when
+  // pageScaleFactor=1.
+  float device_scale_factor_;
+
+  // Vertical amount of the viewport size that's known to covered by a
+  // browser-side UI element, such as an on-screen-keyboard.  This affects
+  // scrollable size since we want to still be able to scroll to the bottom of
+  // the page when the keyboard is up.
+  float overdraw_bottom_height_;
+
+  // Optional top-level constraints that can be set by the OutputSurface.  The
+  // external_viewport_'s size takes precedence over device_viewport_size_ for
+  // DrawQuad generation and Renderer; however, device_viewport_size_ is still
+  // used for scrollable size.
+  gfx::Transform external_transform_;
+  gfx::Rect external_viewport_;
+
   gfx::Rect viewport_damage_rect_;
 
   base::TimeTicks current_frame_timeticks_;