summaryrefslogtreecommitdiffstats
path: root/ui/surface/accelerated_surface_transformer_win.cc
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 /ui/surface/accelerated_surface_transformer_win.cc
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 'ui/surface/accelerated_surface_transformer_win.cc')
-rw-r--r--ui/surface/accelerated_surface_transformer_win.cc27
1 files changed, 16 insertions, 11 deletions
diff --git a/ui/surface/accelerated_surface_transformer_win.cc b/ui/surface/accelerated_surface_transformer_win.cc
index 694f169..30fd1af 100644
--- a/ui/surface/accelerated_surface_transformer_win.cc
+++ b/ui/surface/accelerated_surface_transformer_win.cc
@@ -69,8 +69,7 @@ class ScopedRenderTargetRestorer {
// by repeating downsampling of the image of |src_subrect| by a factor no more
// than 2.
int GetResampleCount(const gfx::Rect& src_subrect,
- const gfx::Size& dst_size,
- const gfx::Size& back_buffer_size) {
+ const gfx::Size& dst_size) {
// At least one copy is required, since the back buffer itself is not
// lockable.
int min_resample_count = 1;
@@ -319,17 +318,17 @@ void AcceleratedSurfaceTransformer::DrawScreenAlignedQuad(
bool AcceleratedSurfaceTransformer::ResizeBilinear(
IDirect3DSurface9* src_surface,
const gfx::Rect& src_subrect,
- IDirect3DSurface9* dst_surface) {
- gfx::Size src_size = d3d_utils::GetSize(src_surface);
- gfx::Size dst_size = d3d_utils::GetSize(dst_surface);
+ IDirect3DSurface9* dst_surface,
+ const gfx::Rect& dst_rect) {
+ gfx::Size src_size = src_subrect.size();
+ gfx::Size dst_size = dst_rect.size();
if (src_size.IsEmpty() || dst_size.IsEmpty())
return false;
HRESULT hr = S_OK;
// Set up intermediate buffers needed for downsampling.
- const int resample_count =
- GetResampleCount(src_subrect, dst_size, src_size);
+ const int resample_count = GetResampleCount(src_subrect, dst_size);
base::win::ScopedComPtr<IDirect3DSurface9> temp_buffer[2];
const gfx::Size half_size =
GetHalfSizeNoLessThan(src_subrect.size(), dst_size);
@@ -360,10 +359,16 @@ bool AcceleratedSurfaceTransformer::ResizeBilinear(
TRACE_EVENT0("gpu", "StretchRect");
IDirect3DSurface9* read_buffer =
(i == 0) ? src_surface : temp_buffer[read_buffer_index];
- IDirect3DSurface9* write_buffer =
- (i == resample_count - 1) ? dst_surface :
- temp_buffer[write_buffer_index];
- RECT write_rect = gfx::Rect(write_size).ToRECT();
+ IDirect3DSurface9* write_buffer;
+ RECT write_rect;
+ if (i == resample_count - 1) {
+ write_buffer = dst_surface;
+ write_rect = dst_rect.ToRECT();
+ } else {
+ write_buffer = temp_buffer[write_buffer_index];
+ write_rect = gfx::Rect(write_size).ToRECT();
+ }
+
hr = device()->StretchRect(read_buffer,
&read_rect,
write_buffer,