Implement RenderWidgetHostViewMac::CopyFromCompositingSurface.

This adds the support of the browser side thumbailing to Mac Chrome.

BUG=120001
TEST=Manually tested that thumbnails are properly generated on GPU composited pages with --enable-in-browser-thumbnailing.


Review URL: http://codereview.chromium.org/10022007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131710 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/content/browser/renderer_host/compositing_iosurface_mac.h b/content/browser/renderer_host/compositing_iosurface_mac.h
index b81b286c..6f0d8da 100644
--- a/content/browser/renderer_host/compositing_iosurface_mac.h
+++ b/content/browser/renderer_host/compositing_iosurface_mac.h
@@ -32,6 +32,12 @@
   // be white.
   void DrawIOSurface(NSView* view);
 
+  // Copy the data of the "live" OpenGL texture referring to this IOSurfaceRef
+  // into |out|. The image data is transformed so that it fits in |dst_size|.
+  // Caller must ensure that |out| is allocated with the size no less than
+  // |4 * dst_size.width() * dst_size.height()| bytes.
+  bool CopyTo(const gfx::Size& dst_size, void* out);
+
   // Unref the IOSurface and delete the associated GL texture. If the GPU
   // process is no longer referencing it, this will delete the IOSurface.
   void UnrefIOSurface();
@@ -66,15 +72,17 @@
 
   // Counter-clockwise verts starting from upper-left corner (0, 0).
   struct SurfaceQuad {
-    void set_size(gfx::Size size) {
+    void set_size(gfx::Size vertex_size, gfx::Size texcoord_size) {
       // Texture coordinates are flipped vertically so they can be drawn on
       // a projection with a flipped y-axis (origin is top left).
-      float w = static_cast<float>(size.width());
-      float h = static_cast<float>(size.height());
-      verts_[0].set(0.0f, 0.0f, 0.0f, h);
-      verts_[1].set(0.0f, h, 0.0f, 0.0f);
-      verts_[2].set(w, h, w, 0.0f);
-      verts_[3].set(w, 0.0f, w, h);
+      float vw = static_cast<float>(vertex_size.width());
+      float vh = static_cast<float>(vertex_size.height());
+      float tw = static_cast<float>(texcoord_size.width());
+      float th = static_cast<float>(texcoord_size.height());
+      verts_[0].set(0.0f, 0.0f, 0.0f, th);
+      verts_[1].set(0.0f, vh, 0.0f, 0.0f);
+      verts_[2].set(vw, vh, tw, 0.0f);
+      verts_[3].set(vw, 0.0f, tw, th);
     }
     SurfaceVertex verts_[4];
   };
@@ -88,6 +96,8 @@
 
   void UnrefIOSurfaceWithContextCurrent();
 
+  void DrawQuad(const SurfaceQuad& quad);
+
   // Cached pointer to IOSurfaceSupport Singleton.
   IOSurfaceSupport* io_surface_support_;