| 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 16e367f02c2a92117c27160011fc4630ff6d6c8c..b0fd37f286625699bde6302a2dc2eca9f9fbeee2 100644
|
| --- a/content/browser/renderer_host/render_widget_host_view_android.cc
|
| +++ b/content/browser/renderer_host/render_widget_host_view_android.cc
|
| @@ -253,13 +253,18 @@ void RenderWidgetHostViewAndroid::SetBounds(const gfx::Rect& rect) {
|
|
|
| void RenderWidgetHostViewAndroid::GetScaledContentBitmap(
|
| float scale,
|
| - const base::Callback<void(bool, const SkBitmap&)>& result_callback) {
|
| + const base::Callback<void(bool, const SkBitmap&)>& result_callback,
|
| + SkBitmap::Config bitmap_config,
|
| + const gfx::Rect& bounding_rect,
|
| + const BitmapAllocator bitmap_allocator) {
|
| if (!IsSurfaceAvailableForCopy()) {
|
| result_callback.Run(false, SkBitmap());
|
| return;
|
| }
|
|
|
| - gfx::Size bounds = layer_->bounds();
|
| + gfx::Size bounds = bounding_rect.IsEmpty() ?
|
| + layer_->bounds() :
|
| + gfx::Size(bounding_rect.width(), bounding_rect.height());
|
| gfx::Rect src_subrect(bounds);
|
| const gfx::Display& display =
|
| gfx::Screen::GetNativeScreen()->GetPrimaryDisplay();
|
| @@ -267,8 +272,21 @@ void RenderWidgetHostViewAndroid::GetScaledContentBitmap(
|
| DCHECK_GT(device_scale_factor, 0);
|
| gfx::Size dst_size(
|
| gfx::ToCeiledSize(gfx::ScaleSize(bounds, scale / device_scale_factor)));
|
| +
|
| + scoped_ptr<SkBitmap> bitmap;
|
| + if (!bitmap_allocator.is_null()) {
|
| + SkBitmap* bitmap_ptr = NULL;
|
| + bitmap_allocator.Run(bitmap_ptr, dst_size, bitmap_config);
|
| + DCHECK(bitmap_ptr);
|
| + DCHECK_EQ(bitmap_ptr->width(), bounds.width());
|
| + DCHECK_EQ(bitmap_ptr->height(), bounds.height());
|
| + DCHECK_EQ(bitmap_ptr->config(), bitmap_config);
|
| + DCHECK_NE(bitmap_ptr->getPixels(), static_cast<void*>(NULL));
|
| + bitmap.reset(bitmap_ptr);
|
| + }
|
| +
|
| CopyFromCompositingSurface(
|
| - src_subrect, dst_size, result_callback, SkBitmap::kARGB_8888_Config);
|
| + src_subrect, dst_size, result_callback, bitmap_config, bitmap.Pass());
|
| }
|
|
|
| bool RenderWidgetHostViewAndroid::PopulateBitmapWithContents(jobject jbitmap) {
|
| @@ -621,7 +639,8 @@ void RenderWidgetHostViewAndroid::CopyFromCompositingSurface(
|
| const gfx::Rect& src_subrect,
|
| const gfx::Size& dst_size,
|
| const base::Callback<void(bool, const SkBitmap&)>& callback,
|
| - const SkBitmap::Config bitmap_config) {
|
| + const SkBitmap::Config bitmap_config,
|
| + scoped_ptr<SkBitmap> bitmap) {
|
| // Only ARGB888 and RGB565 supported as of now.
|
| bool format_support = ((bitmap_config == SkBitmap::kRGB_565_Config) ||
|
| (bitmap_config == SkBitmap::kARGB_8888_Config));
|
| @@ -668,6 +687,7 @@ void RenderWidgetHostViewAndroid::CopyFromCompositingSurface(
|
| dst_size_in_pixel,
|
| bitmap_config,
|
| start_time,
|
| + base::Passed(&bitmap),
|
| callback));
|
| request->set_area(src_subrect_in_pixel);
|
| layer_->RequestCopyOfOutput(request.Pass());
|
| @@ -1335,6 +1355,7 @@ void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult(
|
| const gfx::Size& dst_size_in_pixel,
|
| const SkBitmap::Config bitmap_config,
|
| const base::TimeTicks& start_time,
|
| + scoped_ptr<SkBitmap> bitmap,
|
| const base::Callback<void(bool, const SkBitmap&)>& callback,
|
| scoped_ptr<cc::CopyOutputResult> result) {
|
| base::ScopedClosureRunner scoped_callback_runner(
|
| @@ -1343,13 +1364,15 @@ void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult(
|
| if (!result->HasTexture() || result->IsEmpty() || result->size().IsEmpty())
|
| return;
|
|
|
| - scoped_ptr<SkBitmap> bitmap(new SkBitmap);
|
| - bitmap->setConfig(bitmap_config,
|
| - dst_size_in_pixel.width(),
|
| - dst_size_in_pixel.height(),
|
| - 0, kOpaque_SkAlphaType);
|
| - if (!bitmap->allocPixels())
|
| - return;
|
| + if (!bitmap.get()) {
|
| + bitmap.reset(new SkBitmap);
|
| + bitmap->setConfig(bitmap_config,
|
| + dst_size_in_pixel.width(),
|
| + dst_size_in_pixel.height(),
|
| + 0, kOpaque_SkAlphaType);
|
| + if (!bitmap->allocPixels())
|
| + return;
|
| + }
|
|
|
| ImageTransportFactoryAndroid* factory =
|
| ImageTransportFactoryAndroid::GetInstance();
|
|
|