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 2b781679cec771c3a82a23a52c026c41d64ed0b9..dc9ea5fd8c8a7dac9225ca44357061c093b3bfa9 100644 |
--- a/content/browser/renderer_host/render_widget_host_view_android.cc |
+++ b/content/browser/renderer_host/render_widget_host_view_android.cc |
@@ -306,7 +306,8 @@ bool RenderWidgetHostViewAndroid::PopulateBitmapWithContents(jobject jbitmap) { |
helper->ReadbackTextureSync(texture, |
gfx::Rect(bitmap.size()), |
- static_cast<unsigned char*> (bitmap.pixels())); |
+ static_cast<unsigned char*> (bitmap.pixels()), |
+ SkBitmap::kARGB_8888_Config); |
gpu::gles2::GLES2Interface* gl = |
ImageTransportFactoryAndroid::GetInstance()->GetContextGL(); |
@@ -626,12 +627,23 @@ void RenderWidgetHostViewAndroid::SetBackground(const SkBitmap& background) { |
void RenderWidgetHostViewAndroid::CopyFromCompositingSurface( |
const gfx::Rect& src_subrect, |
const gfx::Size& dst_size, |
- const base::Callback<void(bool, const SkBitmap&)>& callback) { |
+ const base::Callback<void(bool, const SkBitmap&)>& callback, |
+ bool readback_config_rgb565) { |
if (!using_synchronous_compositor_ && !IsSurfaceAvailableForCopy()) { |
callback.Run(false, SkBitmap()); |
return; |
} |
- |
+ ImageTransportFactoryAndroid* factory = |
+ ImageTransportFactoryAndroid::GetInstance(); |
+ GLHelper* gl_helper = factory->GetGLHelper(); |
+ if (!gl_helper) |
+ return; |
+ bool check_rgb565_support = gl_helper->CanUseRgb565Readback(); |
+ if (readback_config_rgb565 && !check_rgb565_support) { |
+ LOG(ERROR) << "Readbackformat rgb565 not supported"; |
+ callback.Run(false, SkBitmap()); |
+ return; |
+ } |
const gfx::Display& display = |
gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); |
float device_scale_factor = display.device_scale_factor(); |
@@ -647,7 +659,6 @@ void RenderWidgetHostViewAndroid::CopyFromCompositingSurface( |
SynchronousCopyContents(src_subrect_in_pixel, dst_size_in_pixel, callback); |
return; |
} |
- |
scoped_ptr<cc::CopyOutputRequest> request; |
if (src_subrect_in_pixel.size() == dst_size_in_pixel) { |
request = cc::CopyOutputRequest::CreateBitmapRequest(base::Bind( |
@@ -658,6 +669,7 @@ void RenderWidgetHostViewAndroid::CopyFromCompositingSurface( |
request = cc::CopyOutputRequest::CreateRequest(base::Bind( |
&RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult, |
dst_size_in_pixel, |
+ readback_config_rgb565, |
callback)); |
} |
request->set_area(src_subrect_in_pixel); |
@@ -1370,6 +1382,7 @@ void RenderWidgetHostViewAndroid::OnLostResources() { |
// static |
void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult( |
const gfx::Size& dst_size_in_pixel, |
+ bool readback_config_rgb565, |
const base::Callback<void(bool, const SkBitmap&)>& callback, |
scoped_ptr<cc::CopyOutputResult> result) { |
DCHECK(result->HasTexture()); |
@@ -1380,8 +1393,12 @@ void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult( |
return; |
scoped_ptr<SkBitmap> bitmap(new SkBitmap); |
- bitmap->setConfig(SkBitmap::kARGB_8888_Config, |
- dst_size_in_pixel.width(), dst_size_in_pixel.height(), |
+ SkBitmap::Config bitmap_config = readback_config_rgb565 ? |
+ SkBitmap::kRGB_565_Config : |
+ SkBitmap::kARGB_8888_Config; |
+ bitmap->setConfig(bitmap_config, |
+ dst_size_in_pixel.width(), |
+ dst_size_in_pixel.height(), |
0, kOpaque_SkAlphaType); |
if (!bitmap->allocPixels()) |
return; |
@@ -1412,6 +1429,7 @@ void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult( |
gfx::Rect(result->size()), |
dst_size_in_pixel, |
pixels, |
+ readback_config_rgb565, |
base::Bind(&CopyFromCompositingSurfaceFinished, |
callback, |
base::Passed(&release_callback), |