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

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

Issue 88033002: Add RGB565 Texture readback support in gl_helper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased to ToT! Created 6 years, 11 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
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 4f53cd0bf5291fbf61c8648ea3c666ceb0d03ab1..66dcff23c33df2eecd21aec15ee49c7937d0a720 100644
--- a/content/browser/renderer_host/render_widget_host_view_android.cc
+++ b/content/browser/renderer_host/render_widget_host_view_android.cc
@@ -305,7 +305,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);
blink::WebGraphicsContext3D* context =
ImageTransportFactoryAndroid::GetInstance()->GetContext3D();
@@ -625,12 +626,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();
@@ -646,7 +658,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(
@@ -657,6 +668,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);
@@ -1360,6 +1372,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());
@@ -1370,8 +1383,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;
@@ -1402,6 +1419,7 @@ void RenderWidgetHostViewAndroid::PrepareTextureCopyOutputResult(
gfx::Rect(result->size()),
dst_size_in_pixel,
pixels,
+ readback_config_rgb565,
base::Bind(&CopyFromCompositingSurfaceFinished,
callback,
base::Passed(&release_callback),

Powered by Google App Engine
This is Rietveld 408576698