Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(669)

Unified Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 22284006: Add support for CopyFromCompositingSurfaceToVideoFrame with software compositor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/render_widget_host_view_aura.cc
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 dc239349e4d65a872c5b0bee4f1603740e051823..7b16c5411944d33bb6c8145e37c762130f44f1bd 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
@@ -1241,8 +1241,6 @@ bool RenderWidgetHostViewAura::CanCopyToBitmap() const {
}
bool RenderWidgetHostViewAura::CanCopyToVideoFrame() const {
- // TODO(skaslev): Implement this path for s/w compositing by handling software
- // CopyOutputResult in CopyFromCompositingSurfaceHasResultForVideo().
return GetCompositor() &&
window_->layer()->has_external_content() &&
host_->is_accelerated_compositing_active();
@@ -1386,8 +1384,7 @@ void RenderWidgetHostViewAura::DidReceiveFrameFromRenderer() {
if (frame_subscriber()->ShouldCaptureFrame(present_time,
&frame, &callback)) {
CopyFromCompositingSurfaceToVideoFrame(
- gfx::Rect(ConvertSizeToDIP(current_surface_->device_scale_factor(),
- current_surface_->size())),
+ gfx::Rect(current_frame_size_),
danakj 2013/08/06 15:25:03 Why this change? We want to copy the full layer's
frame,
base::Bind(callback, present_time));
}
@@ -1887,8 +1884,35 @@ void RenderWidgetHostViewAura::CopyFromCompositingSurfaceHasResultForVideo(
// We only handle texture readbacks for now. If the compositor is in software
// mode, we could produce a software-backed VideoFrame here as well.
- if (!result->HasTexture())
+ if (!result->HasTexture()) {
+ DCHECK(result->HasBitmap());
+ scoped_ptr<SkBitmap> bitmap = result->TakeBitmap();
+ // Scale the bitmap to the required size, if necessary.
+ SkBitmap scaled_bitmap;
+ if (result->size().width() != region_in_frame.width() ||
+ result->size().height() != region_in_frame.height()) {
+ skia::ImageOperations::ResizeMethod method =
+ skia::ImageOperations::RESIZE_GOOD;
+ scaled_bitmap = skia::ImageOperations::Resize(*bitmap.get(), method,
+ region_in_frame.width(),
+ region_in_frame.height());
+ } else {
+ scaled_bitmap = *bitmap.get();
+ }
+
+ {
+ SkAutoLockPixels scaled_bitmap_locker(scaled_bitmap);
+
+ media::CopyRGBToVideoFrame(
+ reinterpret_cast<uint8*>(scaled_bitmap.getPixels()),
+ scaled_bitmap.rowBytes(),
+ region_in_frame,
+ video_frame.get());
+ }
+ scoped_callback_runner.Release();
+ callback.Run(true);
return;
+ }
ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
GLHelper* gl_helper = factory->GetGLHelper();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698