diff options
author | hubbe@chromium.org <hubbe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-31 03:37:46 +0000 |
---|---|---|
committer | hubbe@chromium.org <hubbe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-31 03:37:46 +0000 |
commit | 9d2839eead7e39387a950b87d626296f9a1f2e51 (patch) | |
tree | 8dcb3a3069fdbd848cf8a9b28e2058b018ce554c /content/browser/renderer_host | |
parent | 49d69ba3a43aa6da00f672d6178dad11d197e94a (diff) | |
download | chromium_src-9d2839eead7e39387a950b87d626296f9a1f2e51.zip chromium_src-9d2839eead7e39387a950b87d626296f9a1f2e51.tar.gz chromium_src-9d2839eead7e39387a950b87d626296f9a1f2e51.tar.bz2 |
GPU RGBA -> Planar YUV conversion + uses new scaler pipeline
Review URL: https://chromiumcodereview.appspot.com/15944003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203322 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/renderer_host')
-rw-r--r-- | content/browser/renderer_host/render_widget_host_view_aura.cc | 76 | ||||
-rw-r--r-- | content/browser/renderer_host/render_widget_host_view_aura.h | 5 |
2 files changed, 52 insertions, 29 deletions
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc index fe288f5..1195f9c 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -345,28 +345,6 @@ void AcknowledgeBufferForGpu( route_id, gpu_host_id, ack); } -void CopySnapshotToVideoFrame(const scoped_refptr<media::VideoFrame>& target, - const gfx::Rect& region_in_frame, - const base::Callback<void(bool)>& callback, - bool succeed, - const SkBitmap& bitmap) { - if (!succeed) { - callback.Run(false); - return; - } - - DCHECK(region_in_frame.size() == gfx::Size(bitmap.width(), bitmap.height())); - { - SkAutoLockPixels lock(bitmap); - media::CopyRGBToVideoFrame( - reinterpret_cast<const uint8*>(bitmap.getPixels()), - bitmap.rowBytes(), - region_in_frame, - target.get()); - } - callback.Run(true); -} - } // namespace // We need to watch for mouse events outside a Web Popup or its parent @@ -1255,15 +1233,55 @@ void RenderWidgetHostViewAura::CopyFromCompositingSurfaceToVideoFrame( region_in_frame.y() & ~1, region_in_frame.width() & ~1, region_in_frame.height() & ~1); + ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); + GLHelper* gl_helper = factory->GetGLHelper(); + if (!gl_helper) { + return; + } + // Convert |src_subrect| from the views coordinate (upper-left origin) into + // the OpenGL coordinate (lower-left origin). + gfx::Rect src_subrect_in_gl = src_subrect; + src_subrect_in_gl.set_y(GetViewBounds().height() - src_subrect.bottom()); + gfx::Rect src_subrect_in_pixel = + ConvertRectToPixel(current_surface_->device_scale_factor(), + src_subrect_in_gl); - scoped_callback_runner.Release(); + if (!yuv_readback_pipeline_ || + yuv_readback_pipeline_->scaler()->SrcSize() != current_surface_->size() || + yuv_readback_pipeline_->scaler()->SrcSubrect() != src_subrect_in_pixel || + yuv_readback_pipeline_->scaler()->DstSize() != region_in_frame.size()) { + GLHelper::ScalerQuality quality = GLHelper::SCALER_QUALITY_FAST; + std::string quality_switch = switches::kTabCaptureDownscaleQuality; + // If we're scaling up, we can use the "best" quality. + if (current_surface_->size().width() < region_in_frame.size().width() && + current_surface_->size().height() < region_in_frame.size().height()) { + quality_switch = switches::kTabCaptureUpscaleQuality; + } - CopyFromCompositingSurfaceHelper(src_subrect, - region_in_frame.size(), - base::Bind(CopySnapshotToVideoFrame, - target, - region_in_frame, - callback)); + std::string switch_value = + CommandLine::ForCurrentProcess()->GetSwitchValueASCII(quality_switch); + if (switch_value == "fast") { + quality = GLHelper::SCALER_QUALITY_FAST; + } else if (switch_value == "good") { + quality = GLHelper::SCALER_QUALITY_GOOD; + } else if (switch_value == "best") { + quality = GLHelper::SCALER_QUALITY_BEST; + } + + yuv_readback_pipeline_.reset( + gl_helper->CreateReadbackPipelineYUV(quality, + current_surface_->size(), + src_subrect_in_pixel, + target->coded_size(), + region_in_frame, + true)); + } + + scoped_callback_runner.Release(); + yuv_readback_pipeline_->ReadbackYUV( + current_surface_->PrepareTexture(), + target, + callback); } bool RenderWidgetHostViewAura::CanCopyToVideoFrame() const { diff --git a/content/browser/renderer_host/render_widget_host_view_aura.h b/content/browser/renderer_host/render_widget_host_view_aura.h index 091cbd1..3d376d1 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.h +++ b/content/browser/renderer_host/render_widget_host_view_aura.h @@ -19,6 +19,7 @@ #include "content/browser/renderer_host/image_transport_factory.h" #include "content/browser/renderer_host/render_widget_host_view_base.h" #include "content/common/content_export.h" +#include "content/common/gpu/client/gl_helper.h" #include "third_party/skia/include/core/SkRegion.h" #include "ui/aura/client/activation_change_observer.h" #include "ui/aura/client/activation_delegate.h" @@ -670,6 +671,10 @@ class RenderWidgetHostViewAura // Subscriber that listens to frame presentation events. scoped_ptr<RenderWidgetHostViewFrameSubscriber> frame_subscriber_; + // YUV readback pipeline. + scoped_ptr<content::ReadbackYUVInterface> + yuv_readback_pipeline_; + TouchEditingClient* touch_editing_client_; DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewAura); |