summaryrefslogtreecommitdiffstats
path: root/content/port
diff options
context:
space:
mode:
authornick@chromium.org <nick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-11 23:06:27 +0000
committernick@chromium.org <nick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-11 23:06:27 +0000
commitc02ccccaf7ddfbd5f84dd9f8f057918561660f80 (patch)
treeb25a87a2fdca3c999bf55953bace656202604dcd /content/port
parenta6b73c65a2a8838206b804a65bbbc654c662e934 (diff)
downloadchromium_src-c02ccccaf7ddfbd5f84dd9f8f057918561660f80.zip
chromium_src-c02ccccaf7ddfbd5f84dd9f8f057918561660f80.tar.gz
chromium_src-c02ccccaf7ddfbd5f84dd9f8f057918561660f80.tar.bz2
Tab Capture: Backing store readbacks to YV12 VideoFrames.
Goal here is performance; in tab capture there are significant benefits to doing the readback as YV12: it's less data to copy back, and it's cheap to do on the GPU. VideoFrame is used because it's the most capable YV12 container. [render_widget_host.h] Add a new flavor of CopyFromBackingStore, called CopyFromBackingStoreToVideoFrame. The semantics are slightly different from the RGBA copy in ways that are video-appropriate: aspect ratio is preserved via letterboxing, meaning the output is returned at the target's allocated size, no matter what (whereas CopyFromBackingStore returns whatever it wants, treating |dst_size| as a hint). Callers may only call CopyFromBackingStoreToVideoFrame after checking the result of CanCopyToVideoFrame(). Support is only on Windows now, and only while accelerated compositing is active. But the interface defined here should make it possible to implement VideoFrame readbacks on other platforms without having to touch the callers. [video_capture_controller.h] Amend the interface to allow a VideoFrame to be passed in, as an alternative to void*. The buffer-based interface was inadequate for our needs since stride was not handled. Using VideoFrame allows strides to be accomodated, and paves the way for the interface to pre-reserve the VideoFrames. [web_contents_video_capture_device.cc] Start using CopyFromBackingStoreToVideoFrame. Handling both copy flavors requires a bifurcation of much of the processing pipeline. When dealing with a VideoFrame, the Render stage can is bypassed completely. [accelerated_surface_win.h] Implementation of VideoFrame YV12 readback, using AcceleratedSurfaceTransformer's d3d-accelerated routines. BUG=161537 Review URL: https://chromiumcodereview.appspot.com/12090109 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181785 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/port')
-rw-r--r--content/port/browser/render_widget_host_view_port.h27
1 files changed, 25 insertions, 2 deletions
diff --git a/content/port/browser/render_widget_host_view_port.h b/content/port/browser/render_widget_host_view_port.h
index 9fbdecc..f80ea24 100644
--- a/content/port/browser/render_widget_host_view_port.h
+++ b/content/port/browser/render_widget_host_view_port.h
@@ -26,6 +26,10 @@ struct GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params;
struct ViewHostMsg_TextInputState_Params;
struct ViewHostMsg_SelectionBounds_Params;
+namespace media {
+class VideoFrame;
+}
+
namespace webkit {
namespace npapi {
struct WebPluginGeometry;
@@ -158,13 +162,32 @@ class CONTENT_EXPORT RenderWidgetHostViewPort : public RenderWidgetHostView {
// contents, scaled to |dst_size|, and written to |output|.
// |callback| is invoked with true on success, false otherwise. |output| can
// be initialized even on failure.
- // NOTE: |callback| is called asynchronously on Aura and synchronously on the
- // other platforms.
+ // NOTE: |callback| is called asynchronously.
virtual void CopyFromCompositingSurface(
const gfx::Rect& src_subrect,
const gfx::Size& dst_size,
const base::Callback<void(bool, const SkBitmap&)>& callback) = 0;
+ // Copies a given subset of the compositing surface's content into a YV12
+ // VideoFrame, and invokes a callback with a success/fail parameter. |target|
+ // must contain an allocated, YV12 video frame of the intended size. If the
+ // copy rectangle does not match |target|'s size, the copied content will be
+ // scaled and letterboxed with black borders. The copy will happen
+ // asynchronously. This operation will fail if there is no available
+ // compositing surface.
+ virtual void CopyFromCompositingSurfaceToVideoFrame(
+ const gfx::Rect& src_subrect,
+ const scoped_refptr<media::VideoFrame>& target,
+ const base::Callback<void(bool)>& callback) = 0;
+
+ // Returns true if CopyFromCompositingSurfaceToVideoFrame() is likely to
+ // succeed.
+ //
+ // TODO(nick): When VideoFrame copies are broadly implemented, this method
+ // should be renamed to HasCompositingSurface(), or unified with
+ // IsSurfaceAvailableForCopy() and HasAcceleratedSurface().
+ virtual bool CanCopyToVideoFrame() const = 0;
+
// Called when accelerated compositing state changes.
virtual void OnAcceleratedCompositingStateChange() = 0;
// |params.window| and |params.surface_id| indicate which accelerated