Chromium Code Reviews| Index: content/browser/renderer_host/render_widget_host_view_android.cc |
| diff --git a/content/browser/renderer_host/render_widget_host_view_android.cc b/content/browser/renderer_host/render_widget_host_view_android.cc |
| index 2770268a62a0fe42250f75ddc8fddca5ba1fe238..04f8aaab9ed93489866ff77cca8c2b35112d3ec4 100644 |
| --- a/content/browser/renderer_host/render_widget_host_view_android.cc |
| +++ b/content/browser/renderer_host/render_widget_host_view_android.cc |
| @@ -968,7 +968,8 @@ void RenderWidgetHostViewAndroid::CopyFromCompositingSurface( |
| start_time, |
| readback_layer, |
| callback)); |
| - request->set_area(src_subrect_in_pixel); |
| + if (!src_subrect_in_pixel.IsEmpty()) |
| + request->set_area(src_subrect_in_pixel); |
| readback_layer->RequestCopyOfOutput(request.Pass()); |
| } |
| @@ -1282,6 +1283,14 @@ void RenderWidgetHostViewAndroid::SynchronousCopyContents( |
| const gfx::Size& dst_size_in_pixel, |
| ReadbackRequestCallback& callback, |
| const SkColorType color_type) { |
| + gfx::Size output_size_in_pixel; |
| + if (dst_size_in_pixel.IsEmpty()) |
| + output_size_in_pixel = src_subrect_in_pixel.size(); |
|
no sievers
2014/12/18 19:23:20
So we don't handle |src_subrect_in_pixel| being em
eustas
2014/12/18 19:59:17
Ooops! I'll take a closer look at this case.
Thank
|
| + else |
| + output_size_in_pixel = dst_size_in_pixel; |
| + int output_width = output_size_in_pixel.width(); |
| + int output_height = output_size_in_pixel.height(); |
| + |
| SynchronousCompositor* compositor = |
| SynchronousCompositorImpl::FromID(host_->GetProcess()->GetID(), |
| host_->GetRoutingID()); |
| @@ -1291,14 +1300,14 @@ void RenderWidgetHostViewAndroid::SynchronousCopyContents( |
| } |
| SkBitmap bitmap; |
| - bitmap.allocPixels(SkImageInfo::Make(dst_size_in_pixel.width(), |
| - dst_size_in_pixel.height(), |
| + bitmap.allocPixels(SkImageInfo::Make(output_width, |
| + output_height, |
| color_type, |
| kPremul_SkAlphaType)); |
| SkCanvas canvas(bitmap); |
| canvas.scale( |
| - (float)dst_size_in_pixel.width() / (float)src_subrect_in_pixel.width(), |
| - (float)dst_size_in_pixel.height() / (float)src_subrect_in_pixel.height()); |
| + (float)output_width / (float)src_subrect_in_pixel.width(), |
| + (float)output_height / (float)src_subrect_in_pixel.height()); |
| compositor->DemandDrawSw(&canvas); |
| callback.Run(bitmap, READBACK_SUCCESS); |
| } |
| @@ -1802,9 +1811,15 @@ void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult( |
| if (!result->HasTexture() || result->IsEmpty() || result->size().IsEmpty()) |
| return; |
| + gfx::Size output_size_in_pixel; |
| + if (dst_size_in_pixel.IsEmpty()) |
| + output_size_in_pixel = result->size(); |
| + else |
| + output_size_in_pixel = dst_size_in_pixel; |
| + |
| scoped_ptr<SkBitmap> bitmap(new SkBitmap); |
| - if (!bitmap->tryAllocPixels(SkImageInfo::Make(dst_size_in_pixel.width(), |
| - dst_size_in_pixel.height(), |
| + if (!bitmap->tryAllocPixels(SkImageInfo::Make(output_size_in_pixel.width(), |
| + output_size_in_pixel.height(), |
| color_type, |
| kOpaque_SkAlphaType))) { |
| return; |
| @@ -1832,7 +1847,7 @@ void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult( |
| texture_mailbox.sync_point(), |
| result->size(), |
| gfx::Rect(result->size()), |
| - dst_size_in_pixel, |
| + output_size_in_pixel, |
| pixels, |
| color_type, |
| base::Bind(&CopyFromCompositingSurfaceFinished, |