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

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: Corrected indentation. 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 64edead900919062273824bdf24593f586479459..100cb62e23e1fb2d36cb1976940452f0bb291fff 100644
--- a/content/browser/renderer_host/render_widget_host_view_android.cc
+++ b/content/browser/renderer_host/render_widget_host_view_android.cc
@@ -604,12 +604,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;
+ static bool check_rgb565_support = gl_helper->CanUseRgb565Readback();
piman 2014/01/09 18:12:15 Why static? Maybe you want to cache this in the GL
sivag 2014/01/10 12:20:01 Done. Cached the 565 support status using member v
+ if(readback_config_rgb565 && !check_rgb565_support){
piman 2014/01/09 18:12:15 nit: space before ( and after )
sivag 2014/01/10 12:20:01 Done
+ 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();
@@ -625,7 +636,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(
@@ -636,6 +646,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);
@@ -1339,6 +1350,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());
@@ -1349,8 +1361,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;
@@ -1381,6 +1397,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