summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsiva.gunturi@samsung.com <siva.gunturi@samsung.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-20 10:55:08 +0000
committersiva.gunturi@samsung.com <siva.gunturi@samsung.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-20 10:55:08 +0000
commit739f56c7bf03a4676733dbaa784f2c50034f1549 (patch)
tree788a7ff46940d9f8db8d3280e043e6d0a443239a
parent1f172cbb1bfa19f1f2acaf976f59202289f3edc8 (diff)
downloadchromium_src-739f56c7bf03a4676733dbaa784f2c50034f1549.zip
chromium_src-739f56c7bf03a4676733dbaa784f2c50034f1549.tar.gz
chromium_src-739f56c7bf03a4676733dbaa784f2c50034f1549.tar.bz2
content_gl_tests were failing because, we are checking for rgb565 platform support
on hardware and failing intentionally, which was not correct, the test should be skiped instead. This patch takes care of that along with the base patch. On Aura with Nvidiea drivers the support is not there, so the test fails previously now weare skipping it by displaying the reason. Android the support gets passed. BUG=323150 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=245772 Review URL: https://codereview.chromium.org/133363004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245896 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--AUTHORS1
-rw-r--r--content/browser/devtools/renderer_overrides_handler.cc6
-rw-r--r--content/browser/frame_host/render_widget_host_view_child_frame.cc3
-rw-r--r--content/browser/frame_host/render_widget_host_view_child_frame.h3
-rw-r--r--content/browser/frame_host/render_widget_host_view_guest.cc3
-rw-r--r--content/browser/frame_host/render_widget_host_view_guest.h3
-rw-r--r--content/browser/renderer_host/compositor_impl_android.cc3
-rw-r--r--content/browser/renderer_host/render_widget_host_impl.cc3
-rw-r--r--content/browser/renderer_host/render_widget_host_view_android.cc30
-rw-r--r--content/browser/renderer_host/render_widget_host_view_android.h4
-rw-r--r--content/browser/renderer_host/render_widget_host_view_aura.cc11
-rw-r--r--content/browser/renderer_host/render_widget_host_view_aura.h5
-rw-r--r--content/browser/renderer_host/render_widget_host_view_browsertest.cc5
-rw-r--r--content/browser/renderer_host/render_widget_host_view_gtk.cc7
-rw-r--r--content/browser/renderer_host/render_widget_host_view_gtk.h3
-rw-r--r--content/browser/renderer_host/render_widget_host_view_mac.h3
-rw-r--r--content/browser/renderer_host/render_widget_host_view_mac.mm7
-rw-r--r--content/common/gpu/client/gl_helper.cc140
-rw-r--r--content/common/gpu/client/gl_helper.h11
-rw-r--r--content/common/gpu/client/gl_helper_benchmark.cc3
-rw-r--r--content/common/gpu/client/gl_helper_unittest.cc139
-rw-r--r--content/port/browser/render_widget_host_view_port.h3
-rw-r--r--content/test/test_render_view_host.cc3
-rw-r--r--content/test/test_render_view_host.h3
24 files changed, 346 insertions, 56 deletions
diff --git a/AUTHORS b/AUTHORS
index eab82e3..2aa7ee8 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -282,6 +282,7 @@ Shiliu Wang <aofdwsl@gmail.com>
Shouqun Liu <shouqun.liu@intel.com>
Shreyas VA <v.a.shreyas@gmail.com>
Simon Arlott <simon.arlott@gmail.com>
+Siva Kumar Gunturi <siva.gunturi@samsung.com>
Sohan Jyoti Ghosh <sohan.jyoti@samsung.com>
Song YeWen <ffmpeg@gmail.com>
Soren Dreijer <dreijerbit@gmail.com>
diff --git a/content/browser/devtools/renderer_overrides_handler.cc b/content/browser/devtools/renderer_overrides_handler.cc
index f8d0211..8dfe5bc 100644
--- a/content/browser/devtools/renderer_overrides_handler.cc
+++ b/content/browser/devtools/renderer_overrides_handler.cc
@@ -204,7 +204,8 @@ void RendererOverridesHandler::InnerSwapCompositorFrame() {
base::Bind(&RendererOverridesHandler::ScreenshotCaptured,
weak_factory_.GetWeakPtr(),
scoped_refptr<DevToolsProtocol::Command>(), format, quality,
- last_compositor_frame_metadata_));
+ last_compositor_frame_metadata_),
+ false);
}
void RendererOverridesHandler::ParseCaptureParameters(
@@ -460,7 +461,8 @@ RendererOverridesHandler::PageCaptureScreenshot(
view_bounds, snapshot_size,
base::Bind(&RendererOverridesHandler::ScreenshotCaptured,
weak_factory_.GetWeakPtr(), command, format, quality,
- last_compositor_frame_metadata_));
+ last_compositor_frame_metadata_),
+ false);
return command->AsyncResponsePromise();
}
diff --git a/content/browser/frame_host/render_widget_host_view_child_frame.cc b/content/browser/frame_host/render_widget_host_view_child_frame.cc
index ee0812b..9ee2439 100644
--- a/content/browser/frame_host/render_widget_host_view_child_frame.cc
+++ b/content/browser/frame_host/render_widget_host_view_child_frame.cc
@@ -309,7 +309,8 @@ BackingStore* RenderWidgetHostViewChildFrame::AllocBackingStore(
void RenderWidgetHostViewChildFrame::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) {
callback.Run(false, SkBitmap());
}
diff --git a/content/browser/frame_host/render_widget_host_view_child_frame.h b/content/browser/frame_host/render_widget_host_view_child_frame.h
index 11c26a5..07073e5 100644
--- a/content/browser/frame_host/render_widget_host_view_child_frame.h
+++ b/content/browser/frame_host/render_widget_host_view_child_frame.h
@@ -94,7 +94,8 @@ class CONTENT_EXPORT RenderWidgetHostViewChildFrame
virtual void CopyFromCompositingSurface(
const gfx::Rect& src_subrect,
const gfx::Size& dst_size,
- const base::Callback<void(bool, const SkBitmap&)>& callback) OVERRIDE;
+ const base::Callback<void(bool, const SkBitmap&)>& callback,
+ bool readback_config_rgb565) OVERRIDE;
virtual void CopyFromCompositingSurfaceToVideoFrame(
const gfx::Rect& src_subrect,
const scoped_refptr<media::VideoFrame>& target,
diff --git a/content/browser/frame_host/render_widget_host_view_guest.cc b/content/browser/frame_host/render_widget_host_view_guest.cc
index d841a19..ed1af63 100644
--- a/content/browser/frame_host/render_widget_host_view_guest.cc
+++ b/content/browser/frame_host/render_widget_host_view_guest.cc
@@ -334,7 +334,8 @@ void RenderWidgetHostViewGuest::SelectionBoundsChanged(
void RenderWidgetHostViewGuest::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) {
CHECK(guest_);
guest_->CopyFromCompositingSurface(src_subrect, dst_size, callback);
}
diff --git a/content/browser/frame_host/render_widget_host_view_guest.h b/content/browser/frame_host/render_widget_host_view_guest.h
index e66a328..2fdae4d 100644
--- a/content/browser/frame_host/render_widget_host_view_guest.h
+++ b/content/browser/frame_host/render_widget_host_view_guest.h
@@ -98,7 +98,8 @@ class CONTENT_EXPORT RenderWidgetHostViewGuest
virtual void CopyFromCompositingSurface(
const gfx::Rect& src_subrect,
const gfx::Size& dst_size,
- const base::Callback<void(bool, const SkBitmap&)>& callback) OVERRIDE;
+ const base::Callback<void(bool, const SkBitmap&)>& callback,
+ bool readback_config_rgb565) OVERRIDE;
virtual void AcceleratedSurfaceBuffersSwapped(
const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params,
int gpu_host_id) OVERRIDE;
diff --git a/content/browser/renderer_host/compositor_impl_android.cc b/content/browser/renderer_host/compositor_impl_android.cc
index f9fb802..0b4eb58 100644
--- a/content/browser/renderer_host/compositor_impl_android.cc
+++ b/content/browser/renderer_host/compositor_impl_android.cc
@@ -347,7 +347,8 @@ bool CompositorImpl::CopyTextureToBitmap(GLuint texture_id,
GLHelper* helper = ImageTransportFactoryAndroid::GetInstance()->GetGLHelper();
helper->ReadbackTextureSync(texture_id,
sub_rect,
- static_cast<unsigned char*> (bitmap.pixels()));
+ static_cast<unsigned char*> (bitmap.pixels()),
+ SkBitmap::kARGB_8888_Config);
return true;
}
diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc
index 25380c8..411de18 100644
--- a/content/browser/renderer_host/render_widget_host_impl.cc
+++ b/content/browser/renderer_host/render_widget_host_impl.cc
@@ -724,7 +724,8 @@ void RenderWidgetHostImpl::CopyFromBackingStore(
gfx::Rect(view_->GetViewBounds().size()) : src_subrect;
view_->CopyFromCompositingSurface(accelerated_copy_rect,
accelerated_dst_size,
- callback);
+ callback,
+ false);
return;
}
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 2b78167..dc9ea5f 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),
diff --git a/content/browser/renderer_host/render_widget_host_view_android.h b/content/browser/renderer_host/render_widget_host_view_android.h
index ac4db89..18b9a32 100644
--- a/content/browser/renderer_host/render_widget_host_view_android.h
+++ b/content/browser/renderer_host/render_widget_host_view_android.h
@@ -138,7 +138,8 @@ class RenderWidgetHostViewAndroid
virtual void CopyFromCompositingSurface(
const gfx::Rect& src_subrect,
const gfx::Size& dst_size,
- const base::Callback<void(bool, const SkBitmap&)>& callback) OVERRIDE;
+ const base::Callback<void(bool, const SkBitmap&)>& callback,
+ bool readback_config_rgb565) OVERRIDE;
virtual void CopyFromCompositingSurfaceToVideoFrame(
const gfx::Rect& src_subrect,
const scoped_refptr<media::VideoFrame>& target,
@@ -273,6 +274,7 @@ class RenderWidgetHostViewAndroid
// of the copy.
static void 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);
static void PrepareBitmapCopyOutputResult(
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc
index 27f54ec..174b1e7 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
@@ -1058,7 +1058,8 @@ BackingStore* RenderWidgetHostViewAura::AllocBackingStore(
void RenderWidgetHostViewAura::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 (!CanCopyToBitmap()) {
callback.Run(false, SkBitmap());
return;
@@ -1069,6 +1070,7 @@ void RenderWidgetHostViewAura::CopyFromCompositingSurface(
cc::CopyOutputRequest::CreateRequest(base::Bind(
&RenderWidgetHostViewAura::CopyFromCompositingSurfaceHasResult,
dst_size_in_pixel,
+ readback_config_rgb565,
callback));
gfx::Rect src_subrect_in_pixel =
ConvertRectToPixel(current_device_scale_factor_, src_subrect);
@@ -1803,6 +1805,7 @@ void RenderWidgetHostViewAura::SetSurfaceNotInUseByCompositor(
// static
void RenderWidgetHostViewAura::CopyFromCompositingSurfaceHasResult(
const gfx::Size& dst_size_in_pixel,
+ bool readback_config_rgb565,
const base::Callback<void(bool, const SkBitmap&)>& callback,
scoped_ptr<cc::CopyOutputResult> result) {
if (result->IsEmpty() || result->size().IsEmpty()) {
@@ -1811,7 +1814,9 @@ void RenderWidgetHostViewAura::CopyFromCompositingSurfaceHasResult(
}
if (result->HasTexture()) {
- PrepareTextureCopyOutputResult(dst_size_in_pixel, callback, result.Pass());
+ PrepareTextureCopyOutputResult(dst_size_in_pixel, readback_config_rgb565,
+ callback,
+ result.Pass());
return;
}
@@ -1833,6 +1838,7 @@ static void CopyFromCompositingSurfaceFinished(
// static
void RenderWidgetHostViewAura::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) {
base::ScopedClosureRunner scoped_callback_runner(
@@ -1874,6 +1880,7 @@ void RenderWidgetHostViewAura::PrepareTextureCopyOutputResult(
gfx::Rect(result->size()),
dst_size_in_pixel,
pixels,
+ readback_config_rgb565,
base::Bind(&CopyFromCompositingSurfaceFinished,
callback,
base::Passed(&release_callback),
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.h b/content/browser/renderer_host/render_widget_host_view_aura.h
index 9e11115..0cef4e5 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.h
+++ b/content/browser/renderer_host/render_widget_host_view_aura.h
@@ -210,7 +210,8 @@ class CONTENT_EXPORT RenderWidgetHostViewAura
virtual void CopyFromCompositingSurface(
const gfx::Rect& src_subrect,
const gfx::Size& dst_size,
- const base::Callback<void(bool, const SkBitmap&)>& callback) OVERRIDE;
+ const base::Callback<void(bool, const SkBitmap&)>& callback,
+ bool readback_config_rgb565) OVERRIDE;
virtual void CopyFromCompositingSurfaceToVideoFrame(
const gfx::Rect& src_subrect,
const scoped_refptr<media::VideoFrame>& target,
@@ -491,10 +492,12 @@ class CONTENT_EXPORT RenderWidgetHostViewAura
// of the copy.
static void CopyFromCompositingSurfaceHasResult(
const gfx::Size& dst_size_in_pixel,
+ bool readback_config_rgb565,
const base::Callback<void(bool, const SkBitmap&)>& callback,
scoped_ptr<cc::CopyOutputResult> result);
static void 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);
static void PrepareBitmapCopyOutputResult(
diff --git a/content/browser/renderer_host/render_widget_host_view_browsertest.cc b/content/browser/renderer_host/render_widget_host_view_browsertest.cc
index 79aa718..d1f888c 100644
--- a/content/browser/renderer_host/render_widget_host_view_browsertest.cc
+++ b/content/browser/renderer_host/render_widget_host_view_browsertest.cc
@@ -732,7 +732,10 @@ class CompositingRenderWidgetHostViewBrowserTestTabCapture
CopyFromCompositingSurfaceCallback,
base::Unretained(this),
run_loop.QuitClosure());
- rwhvp->CopyFromCompositingSurface(copy_rect, output_size, callback);
+ rwhvp->CopyFromCompositingSurface(copy_rect,
+ output_size,
+ callback,
+ false);
}
run_loop.Run();
}
diff --git a/content/browser/renderer_host/render_widget_host_view_gtk.cc b/content/browser/renderer_host/render_widget_host_view_gtk.cc
index e08e8d8..b7d6e2e 100644
--- a/content/browser/renderer_host/render_widget_host_view_gtk.cc
+++ b/content/browser/renderer_host/render_widget_host_view_gtk.cc
@@ -1047,7 +1047,12 @@ BackingStore* RenderWidgetHostViewGtk::AllocBackingStore(
void RenderWidgetHostViewGtk::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 (readback_config_rgb565) {
+ NOTIMPLEMENTED();
+ callback.Run(false, SkBitmap());
+ }
// Grab the snapshot from the renderer as that's the only reliable way to
// readback from the GPU for this platform right now.
GetRenderWidgetHost()->GetSnapshotFromRenderer(src_subrect, callback);
diff --git a/content/browser/renderer_host/render_widget_host_view_gtk.h b/content/browser/renderer_host/render_widget_host_view_gtk.h
index b9a18c9..f2ff62e5 100644
--- a/content/browser/renderer_host/render_widget_host_view_gtk.h
+++ b/content/browser/renderer_host/render_widget_host_view_gtk.h
@@ -104,7 +104,8 @@ class CONTENT_EXPORT RenderWidgetHostViewGtk
virtual void CopyFromCompositingSurface(
const gfx::Rect& src_subrect,
const gfx::Size& dst_size,
- const base::Callback<void(bool, const SkBitmap&)>& callback) OVERRIDE;
+ const base::Callback<void(bool, const SkBitmap&)>& callback,
+ bool readback_config_rgb565) OVERRIDE;
virtual void CopyFromCompositingSurfaceToVideoFrame(
const gfx::Rect& src_subrect,
const scoped_refptr<media::VideoFrame>& target,
diff --git a/content/browser/renderer_host/render_widget_host_view_mac.h b/content/browser/renderer_host/render_widget_host_view_mac.h
index 3923fcf..1cebb51 100644
--- a/content/browser/renderer_host/render_widget_host_view_mac.h
+++ b/content/browser/renderer_host/render_widget_host_view_mac.h
@@ -275,7 +275,8 @@ class RenderWidgetHostViewMac : public RenderWidgetHostViewBase,
virtual void CopyFromCompositingSurface(
const gfx::Rect& src_subrect,
const gfx::Size& dst_size,
- const base::Callback<void(bool, const SkBitmap&)>& callback) OVERRIDE;
+ const base::Callback<void(bool, const SkBitmap&)>& callback,
+ bool readback_config_rgb565) OVERRIDE;
virtual void CopyFromCompositingSurfaceToVideoFrame(
const gfx::Rect& src_subrect,
const scoped_refptr<media::VideoFrame>& target,
diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm
index 5a4e688..3b68caf 100644
--- a/content/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
@@ -1134,7 +1134,12 @@ BackingStore* RenderWidgetHostViewMac::AllocBackingStore(
void RenderWidgetHostViewMac::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 (readback_config_rgb565) {
+ NOTIMPLEMENTED();
+ callback.Run(false, SkBitmap());
+ }
base::ScopedClosureRunner scoped_callback_runner(
base::Bind(callback, false, SkBitmap()));
float scale = ScaleFactor(cocoa_view_);
diff --git a/content/common/gpu/client/gl_helper.cc b/content/common/gpu/client/gl_helper.cc
index 13d2913..55f2dad 100644
--- a/content/common/gpu/client/gl_helper.cc
+++ b/content/common/gpu/client/gl_helper.cc
@@ -128,12 +128,14 @@ class GLHelper::CopyTextureToImpl
const gfx::Rect& src_subrect,
const gfx::Size& dst_size,
unsigned char* out,
+ bool readback_config_rgb565,
const base::Callback<void(bool)>& callback,
GLHelper::ScalerQuality quality);
void ReadbackTextureSync(GLuint texture,
const gfx::Rect& src_rect,
- unsigned char* out);
+ unsigned char* out,
+ SkBitmap::Config format);
// Reads back bytes from the currently bound frame buffer.
// Note that dst_size is specified in bytes, not pixels.
@@ -141,6 +143,7 @@ class GLHelper::CopyTextureToImpl
int32 bytes_per_row, // generally dst_size.width() * 4
int32 row_stride_bytes, // generally dst_size.width() * 4
unsigned char* out,
+ bool readback_config_rgb565,
const base::Callback<void(bool)>& callback);
void ReadbackPlane(TextureFrameBufferPair* source,
@@ -286,10 +289,11 @@ class GLHelper::CopyTextureToImpl
const gfx::Size& dst_size,
bool vertically_flip_texture,
bool swizzle,
+ bool readback_config_rgb565,
GLHelper::ScalerQuality quality);
static void nullcallback(bool success) {}
- void ReadbackDone(Request* request);
+ void ReadbackDone(Request *request, int bytes_per_pixel);
void FinishRequest(Request* request, bool result);
void CancelRequests();
@@ -331,6 +335,7 @@ GLuint GLHelper::CopyTextureToImpl::ScaleTexture(
const gfx::Size& dst_size,
bool vertically_flip_texture,
bool swizzle,
+ bool readback_config_rgb565,
GLHelper::ScalerQuality quality) {
scoped_ptr<ScalerInterface> scaler(
helper_->CreateScaler(quality,
@@ -344,14 +349,18 @@ GLuint GLHelper::CopyTextureToImpl::ScaleTexture(
gl_->GenTextures(1, &dst_texture);
{
ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, dst_texture);
+ GLenum format = readback_config_rgb565 ? GL_RGB : GL_RGBA;
+ GLenum type = readback_config_rgb565 ?
+ GL_UNSIGNED_SHORT_5_6_5 :
+ GL_UNSIGNED_BYTE;
gl_->TexImage2D(GL_TEXTURE_2D,
0,
- GL_RGBA,
+ format,
dst_size.width(),
dst_size.height(),
0,
- GL_RGBA,
- GL_UNSIGNED_BYTE,
+ format,
+ type,
NULL);
}
scaler->Scale(src_texture, dst_texture);
@@ -363,41 +372,48 @@ void GLHelper::CopyTextureToImpl::ReadbackAsync(
int32 bytes_per_row,
int32 row_stride_bytes,
unsigned char* out,
+ bool readback_config_rgb565,
const base::Callback<void(bool)>& callback) {
Request* request =
new Request(dst_size, bytes_per_row, row_stride_bytes, out, callback);
request_queue_.push(request);
request->buffer = 0u;
+ int bytes_per_pixel = readback_config_rgb565 ? 2 : 4;
gl_->GenBuffers(1, &request->buffer);
gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, request->buffer);
gl_->BufferData(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM,
- 4 * dst_size.GetArea(),
+ bytes_per_pixel * dst_size.GetArea(),
NULL,
GL_STREAM_READ);
request->query = 0u;
gl_->GenQueriesEXT(1, &request->query);
gl_->BeginQueryEXT(GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM, request->query);
+ GLenum format = readback_config_rgb565 ? GL_RGB : GL_RGBA;
+ GLenum type = readback_config_rgb565 ?
+ GL_UNSIGNED_SHORT_5_6_5 :
+ GL_UNSIGNED_BYTE;
gl_->ReadPixels(0,
0,
dst_size.width(),
dst_size.height(),
- GL_RGBA,
- GL_UNSIGNED_BYTE,
+ format,
+ type,
NULL);
gl_->EndQueryEXT(GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM);
gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, 0);
context_support_->SignalQuery(
request->query,
- base::Bind(&CopyTextureToImpl::ReadbackDone, AsWeakPtr(), request));
+ base::Bind(&CopyTextureToImpl::ReadbackDone, AsWeakPtr(),
+ request, bytes_per_pixel));
}
-
void GLHelper::CopyTextureToImpl::CropScaleReadbackAndCleanTexture(
GLuint src_texture,
const gfx::Size& src_size,
const gfx::Rect& src_subrect,
const gfx::Size& dst_size,
unsigned char* out,
+ bool readback_config_rgb565,
const base::Callback<void(bool)>& callback,
GLHelper::ScalerQuality quality) {
GLuint texture = ScaleTexture(src_texture,
@@ -410,33 +426,51 @@ void GLHelper::CopyTextureToImpl::CropScaleReadbackAndCleanTexture(
#else
false,
#endif
+ readback_config_rgb565,
quality);
ScopedFramebuffer dst_framebuffer(gl_);
ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder(gl_,
dst_framebuffer);
ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, texture);
- gl_->FramebufferTexture2D(
- GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
- ReadbackAsync(
- dst_size, dst_size.width() * 4, dst_size.width() * 4, out, callback);
+ gl_->FramebufferTexture2D(GL_FRAMEBUFFER,
+ GL_COLOR_ATTACHMENT0,
+ GL_TEXTURE_2D,
+ texture,
+ 0);
+ int bytes_per_pixel = readback_config_rgb565 ? 2 : 4;
+ ReadbackAsync(dst_size,
+ dst_size.width() * bytes_per_pixel,
+ dst_size.width() * bytes_per_pixel,
+ out,
+ readback_config_rgb565,
+ callback);
gl_->DeleteTextures(1, &texture);
}
void GLHelper::CopyTextureToImpl::ReadbackTextureSync(GLuint texture,
const gfx::Rect& src_rect,
- unsigned char* out) {
+ unsigned char* out,
+ SkBitmap::Config config) {
ScopedFramebuffer dst_framebuffer(gl_);
ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder(gl_,
dst_framebuffer);
ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, texture);
gl_->FramebufferTexture2D(
GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
+ DCHECK((config == SkBitmap::kRGB_565_Config) ||
+ (config == SkBitmap::kARGB_8888_Config));
+ GLenum format = (config == SkBitmap::kRGB_565_Config) ?
+ GL_RGB :
+ GL_RGBA;
+ GLenum type = (config == SkBitmap::kRGB_565_Config) ?
+ GL_UNSIGNED_SHORT_5_6_5 :
+ GL_UNSIGNED_BYTE;
gl_->ReadPixels(src_rect.x(),
src_rect.y(),
src_rect.width(),
src_rect.height(),
- GL_RGBA,
- GL_UNSIGNED_BYTE,
+ format,
+ type,
out);
}
@@ -452,10 +486,12 @@ GLuint GLHelper::CopyTextureToImpl::CopyAndScaleTexture(
dst_size,
vertically_flip_texture,
false,
+ false,
quality);
}
-void GLHelper::CopyTextureToImpl::ReadbackDone(Request* finished_request) {
+void GLHelper::CopyTextureToImpl::ReadbackDone(Request* finished_request,
+ int bytes_per_pixel) {
TRACE_EVENT0("mirror",
"GLHelper::CopyTextureToImpl::CheckReadbackFramebufferComplete");
finished_request->done = true;
@@ -475,22 +511,22 @@ void GLHelper::CopyTextureToImpl::ReadbackDone(Request* finished_request) {
GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, GL_READ_ONLY));
if (data) {
result = true;
- if (request->bytes_per_row == request->size.width() * 4 &&
+ if (request->bytes_per_row == request->size.width() * bytes_per_pixel &&
request->bytes_per_row == request->row_stride_bytes) {
- memcpy(request->pixels, data, request->size.GetArea() * 4);
+ memcpy(request->pixels, data,
+ request->size.GetArea() * bytes_per_pixel);
} else {
unsigned char* out = request->pixels;
for (int y = 0; y < request->size.height(); y++) {
memcpy(out, data, request->bytes_per_row);
out += request->row_stride_bytes;
- data += request->size.width() * 4;
+ data += request->size.width() * bytes_per_pixel;
}
}
gl_->UnmapBufferCHROMIUM(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM);
}
gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, 0);
}
-
FinishRequest(request, result);
}
}
@@ -520,7 +556,10 @@ void GLHelper::CopyTextureToImpl::CancelRequests() {
}
GLHelper::GLHelper(GLES2Interface* gl, gpu::ContextSupport* context_support)
- : gl_(gl), context_support_(context_support) {}
+ : gl_(gl),
+ context_support_(context_support),
+ initialized_565_format_check_(false),
+ support_565_format_(false) {}
GLHelper::~GLHelper() {}
@@ -530,6 +569,7 @@ void GLHelper::CropScaleReadbackAndCleanTexture(
const gfx::Rect& src_subrect,
const gfx::Size& dst_size,
unsigned char* out,
+ bool readback_config_rgb565,
const base::Callback<void(bool)>& callback) {
InitCopyTextToImpl();
copy_texture_to_impl_->CropScaleReadbackAndCleanTexture(
@@ -538,6 +578,7 @@ void GLHelper::CropScaleReadbackAndCleanTexture(
src_subrect,
dst_size,
out,
+ readback_config_rgb565,
callback,
GLHelper::SCALER_QUALITY_FAST);
}
@@ -549,18 +590,22 @@ void GLHelper::CropScaleReadbackAndCleanMailbox(
const gfx::Rect& src_subrect,
const gfx::Size& dst_size,
unsigned char* out,
+ bool readback_config_rgb565,
const base::Callback<void(bool)>& callback) {
GLuint mailbox_texture = ConsumeMailboxToTexture(src_mailbox, sync_point);
CropScaleReadbackAndCleanTexture(
- mailbox_texture, src_size, src_subrect, dst_size, out, callback);
+ mailbox_texture, src_size, src_subrect, dst_size, out,
+ readback_config_rgb565,
+ callback);
gl_->DeleteTextures(1, &mailbox_texture);
}
void GLHelper::ReadbackTextureSync(GLuint texture,
const gfx::Rect& src_rect,
- unsigned char* out) {
+ unsigned char* out,
+ SkBitmap::Config format) {
InitCopyTextToImpl();
- copy_texture_to_impl_->ReadbackTextureSync(texture, src_rect, out);
+ copy_texture_to_impl_->ReadbackTextureSync(texture, src_rect, out, format);
}
GLuint GLHelper::CopyTexture(GLuint texture, const gfx::Size& size) {
@@ -725,6 +770,46 @@ void GLHelper::CopyTextureFullImage(GLuint texture, const gfx::Size& size) {
GL_TEXTURE_2D, 0, GL_RGB, 0, 0, size.width(), size.height(), 0);
}
+bool GLHelper::CanUseRgb565Readback() {
+ if(initialized_565_format_check_){
+ return support_565_format_;
+ }
+ const int kTestSize = 64;
+ GLuint dst_texture = 0u;
+ gl_->GenTextures(1, &dst_texture);
+ ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(gl_, dst_texture);
+ gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ gl_->TexImage2D(GL_TEXTURE_2D,
+ 0,
+ GL_RGB,
+ kTestSize,
+ kTestSize,
+ 0,
+ GL_RGB,
+ GL_UNSIGNED_SHORT_5_6_5,
+ NULL);
+ ScopedFramebuffer dst_framebuffer(gl_);
+ ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder(gl_,
+ dst_framebuffer);
+ gl_->FramebufferTexture2D(GL_FRAMEBUFFER,
+ GL_COLOR_ATTACHMENT0,
+ GL_TEXTURE_2D,
+ dst_texture,
+ 0);
+ GLint ext_format = 0, ext_type = 0;
+ gl_->GetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &ext_format);
+ gl_->GetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &ext_type);
+ gl_->DeleteTextures(1, &dst_texture);
+ if ((ext_format == GL_RGB) && (ext_type == GL_UNSIGNED_SHORT_5_6_5)) {
+ support_565_format_ = true;
+ }
+ initialized_565_format_check_ = true;
+ return support_565_format_;
+}
+
void GLHelper::CopyTextureToImpl::ReadbackPlane(
TextureFrameBufferPair* source,
const scoped_refptr<media::VideoFrame>& target,
@@ -734,11 +819,12 @@ void GLHelper::CopyTextureToImpl::ReadbackPlane(
const base::Callback<void(bool)>& callback) {
gl_->BindFramebuffer(GL_FRAMEBUFFER, source->framebuffer());
size_t offset = target->stride(plane) * (dst_subrect.y() >> size_shift) +
- (dst_subrect.x() >> size_shift);
+ (dst_subrect.x() >> size_shift);
ReadbackAsync(source->size(),
dst_subrect.width() >> size_shift,
target->stride(plane),
target->data(plane) + offset,
+ false,
callback);
}
diff --git a/content/common/gpu/client/gl_helper.h b/content/common/gpu/client/gl_helper.h
index 7b53268..eaca6cf 100644
--- a/content/common/gpu/client/gl_helper.h
+++ b/content/common/gpu/client/gl_helper.h
@@ -12,6 +12,7 @@
#include "content/common/content_export.h"
#include "gpu/command_buffer/client/gles2_interface.h"
#include "gpu/command_buffer/common/mailbox_holder.h"
+#include "third_party/skia/include/core/SkBitmap.h"
namespace gfx {
class Rect;
@@ -182,6 +183,7 @@ class CONTENT_EXPORT GLHelper {
const gfx::Rect& src_subrect,
const gfx::Size& dst_size,
unsigned char* out,
+ bool readback_config_rgb565,
const base::Callback<void(bool)>& callback);
// Copies the block of pixels specified with |src_subrect| from |src_mailbox|,
@@ -200,6 +202,7 @@ class CONTENT_EXPORT GLHelper {
const gfx::Rect& src_subrect,
const gfx::Size& dst_size,
unsigned char* out,
+ bool readback_config_rgb565,
const base::Callback<void(bool)>& callback);
// Copies the texture data out of |texture| into |out|. |size| is the
@@ -209,7 +212,8 @@ class CONTENT_EXPORT GLHelper {
// current OpenGL context.
void ReadbackTextureSync(GLuint texture,
const gfx::Rect& src_rect,
- unsigned char* out);
+ unsigned char* out,
+ SkBitmap::Config format);
// Creates a copy of the specified texture. |size| is the size of the texture.
// Note that the src_texture will have the min/mag filter set to GL_LINEAR
@@ -267,6 +271,9 @@ class CONTENT_EXPORT GLHelper {
// size of the framebuffer.
void CopyTextureFullImage(GLuint texture, const gfx::Size& size);
+ // Check whether rgb565 readback is supported or not.
+ bool CanUseRgb565Readback();
+
// A scaler will cache all intermediate textures and programs
// needed to scale from a specified size to a destination size.
// If the source or destination sizes changes, you must create
@@ -327,6 +334,8 @@ class CONTENT_EXPORT GLHelper {
gpu::ContextSupport* context_support_;
scoped_ptr<CopyTextureToImpl> copy_texture_to_impl_;
scoped_ptr<GLHelperScaling> scaler_impl_;
+ bool initialized_565_format_check_;
+ bool support_565_format_;
DISALLOW_COPY_AND_ASSIGN(GLHelper);
};
diff --git a/content/common/gpu/client/gl_helper_benchmark.cc b/content/common/gpu/client/gl_helper_benchmark.cc
index 5e098f9..06b4206 100644
--- a/content/common/gpu/client/gl_helper_benchmark.cc
+++ b/content/common/gpu/client/gl_helper_benchmark.cc
@@ -292,7 +292,8 @@ TEST_F(GLHelperTest, DISABLED_ScaleTestImage) {
gfx::Rect(0, 0,
dst_size.width(),
dst_size.height()),
- static_cast<unsigned char *>(output_pixels.getPixels()));
+ static_cast<unsigned char *>(output_pixels.getPixels()),
+ SkBitmap::kARGB_8888_Config);
context_->deleteTexture(dst_texture);
std::string filename = base::StringPrintf("testoutput_%s_%d.ppm",
kQualityNames[q],
diff --git a/content/common/gpu/client/gl_helper_unittest.cc b/content/common/gpu/client/gl_helper_unittest.cc
index 974031f..55d5bbd 100644
--- a/content/common/gpu/client/gl_helper_unittest.cc
+++ b/content/common/gpu/client/gl_helper_unittest.cc
@@ -662,7 +662,8 @@ class GLHelperTest : public testing::Test {
helper_->ReadbackTextureSync(
dst_texture,
gfx::Rect(0, 0, scaled_xsize, scaled_ysize),
- static_cast<unsigned char*>(output_pixels.getPixels()));
+ static_cast<unsigned char*>(output_pixels.getPixels()),
+ SkBitmap::kARGB_8888_Config);
if (flip) {
// Flip the pixels back.
FlipSKBitmap(&output_pixels);
@@ -841,6 +842,128 @@ class GLHelperTest : public testing::Test {
}
}
+ bool ColorComponentsClose(SkColor component1,
+ SkColor component2,
+ SkBitmap::Config config) {
+ int c1 = static_cast<int>(component1);
+ int c2 = static_cast<int>(component2);
+ bool result = false;
+ switch (config) {
+ case SkBitmap::kARGB_8888_Config:
+ result = (std::abs(c1 - c2) == 0);
+ break;
+ case SkBitmap::kRGB_565_Config:
+ result = (std::abs(c1 - c2) <= 7);
+ break;
+ default:
+ break;
+ }
+ return result;
+ }
+
+ bool ColorsClose(SkColor color1, SkColor color2, SkBitmap::Config config) {
+ bool red = ColorComponentsClose(SkColorGetR(color1),
+ SkColorGetR(color2), config);
+ bool green = ColorComponentsClose(SkColorGetG(color1),
+ SkColorGetG(color2), config);
+ bool blue = ColorComponentsClose(SkColorGetB(color1),
+ SkColorGetB(color2), config);
+ bool alpha = ColorComponentsClose(SkColorGetA(color1),
+ SkColorGetA(color2), config);
+ if (config == SkBitmap::kRGB_565_Config) {
+ return red && blue && green;
+ }
+ return red && blue && green && alpha;
+ }
+
+ bool IsEqual(const SkBitmap& bmp1, const SkBitmap& bmp2) {
+ if (bmp1.isNull() && bmp2.isNull())
+ return true;
+ if (bmp1.width() != bmp2.width() ||
+ bmp1.height() != bmp2.height()) {
+ LOG(ERROR) << "Bitmap geometry check failure";
+ return false;
+ }
+ if (bmp1.getConfig() != bmp2.getConfig())
+ return false;
+
+ SkAutoLockPixels lock1(bmp1);
+ SkAutoLockPixels lock2(bmp2);
+ if (!bmp1.getPixels() || !bmp2.getPixels()) {
+ LOG(ERROR) << "Empty Bitmap!";
+ return false;
+ }
+ for (int y = 0; y < bmp1.height(); ++y) {
+ for (int x = 0; x < bmp1.width(); ++x) {
+ if (!ColorsClose(bmp1.getColor(x,y),
+ bmp2.getColor(x,y),
+ bmp1.getConfig())) {
+ LOG(ERROR) << "Bitmap color comparision failure";
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ // Test basic format readback.
+ bool TestTextureFormatReadback(const gfx::Size& src_size,
+ SkBitmap::Config bitmap_config) {
+ DCHECK((bitmap_config == SkBitmap::kRGB_565_Config) ||
+ (bitmap_config == SkBitmap::kARGB_8888_Config));
+ bool rgb565_format = (bitmap_config == SkBitmap::kRGB_565_Config);
+ if (rgb565_format && !helper_->CanUseRgb565Readback()) {
+ LOG(INFO) << "RGB565 Format Not supported on this platform";
+ LOG(INFO) << "Skipping RGB565ReadBackTest";
+ return true;
+ }
+ WebGLId src_texture = context_->createTexture();
+ SkBitmap input_pixels;
+ input_pixels.setConfig(bitmap_config, src_size.width(),
+ src_size.height());
+ input_pixels.allocPixels();
+ SkAutoLockPixels lock1(input_pixels);
+ // Erase the input bitmap with red color.
+ input_pixels.eraseColor(SK_ColorRED);
+ context_->bindTexture(GL_TEXTURE_2D, src_texture);
+ GLenum format = (bitmap_config == SkBitmap::kRGB_565_Config) ?
+ GL_RGB : GL_RGBA;
+ GLenum type = (bitmap_config == SkBitmap::kRGB_565_Config) ?
+ GL_UNSIGNED_SHORT_5_6_5 : GL_UNSIGNED_BYTE;
+ context_->texImage2D(GL_TEXTURE_2D,
+ 0,
+ format,
+ src_size.width(),
+ src_size.height(),
+ 0,
+ format,
+ type,
+ input_pixels.getPixels());
+ SkBitmap output_pixels;
+ output_pixels.setConfig(bitmap_config, src_size.width(),
+ src_size.height());
+ output_pixels.allocPixels();
+ SkAutoLockPixels lock2(output_pixels);
+ // Initialize the output bitmap with Green color.
+ // When the readback is over output bitmap should have the red color.
+ output_pixels.eraseColor(SK_ColorGREEN);
+ uint8* pixels = static_cast<uint8*>(output_pixels.getPixels());
+ helper_->ReadbackTextureSync(src_texture,
+ gfx::Rect(src_size),
+ pixels,
+ bitmap_config);
+ bool result = IsEqual(input_pixels, output_pixels);
+ if (!result) {
+ LOG(ERROR) << "Bitmap comparision failure";
+ return false;
+ }
+ context_->deleteTexture(src_texture);
+ if (HasFailure()) {
+ return false;
+ }
+ return true;
+ }
+
// YUV readback test. Create a test pattern, convert to YUV
// with reference implementation and compare to what gl_helper
// returns.
@@ -1216,6 +1339,20 @@ class GLHelperTest : public testing::Test {
std::deque<GLHelperScaling::ScaleOp> x_ops_, y_ops_;
};
+TEST_F(GLHelperTest, RGBAReadBackTest) {
+ const int kTestSize = 64;
+ bool result = TestTextureFormatReadback(gfx::Size(kTestSize,kTestSize),
+ SkBitmap::kARGB_8888_Config);
+ EXPECT_EQ(result, true);
+}
+
+TEST_F(GLHelperTest, RGB565ReadBackTest) {
+ const int kTestSize = 64;
+ bool result = TestTextureFormatReadback(gfx::Size(kTestSize,kTestSize),
+ SkBitmap::kRGB_565_Config);
+ EXPECT_EQ(result, true);
+}
+
TEST_F(GLHelperTest, YUVReadbackOptTest) {
// This test uses the cb_command tracing events to detect how many
// scaling passes are actually performed by the YUV readback pipeline.
diff --git a/content/port/browser/render_widget_host_view_port.h b/content/port/browser/render_widget_host_view_port.h
index dab8581..0f9ad4c 100644
--- a/content/port/browser/render_widget_host_view_port.h
+++ b/content/port/browser/render_widget_host_view_port.h
@@ -181,7 +181,8 @@ class CONTENT_EXPORT RenderWidgetHostViewPort : public RenderWidgetHostView,
virtual void CopyFromCompositingSurface(
const gfx::Rect& src_subrect,
const gfx::Size& dst_size,
- const base::Callback<void(bool, const SkBitmap&)>& callback) = 0;
+ const base::Callback<void(bool, const SkBitmap&)>& callback,
+ bool readback_config_rgb565) = 0;
// Copies a given subset of the compositing surface's content into a YV12
// VideoFrame, and invokes a callback with a success/fail parameter. |target|
diff --git a/content/test/test_render_view_host.cc b/content/test/test_render_view_host.cc
index 9b79ca6..8b085bf 100644
--- a/content/test/test_render_view_host.cc
+++ b/content/test/test_render_view_host.cc
@@ -114,7 +114,8 @@ BackingStore* TestRenderWidgetHostView::AllocBackingStore(
void TestRenderWidgetHostView::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) {
callback.Run(false, SkBitmap());
}
diff --git a/content/test/test_render_view_host.h b/content/test/test_render_view_host.h
index 308049f..8c3a231 100644
--- a/content/test/test_render_view_host.h
+++ b/content/test/test_render_view_host.h
@@ -127,7 +127,8 @@ class TestRenderWidgetHostView : public RenderWidgetHostViewBase {
virtual void CopyFromCompositingSurface(
const gfx::Rect& src_subrect,
const gfx::Size& dst_size,
- const base::Callback<void(bool, const SkBitmap&)>& callback) OVERRIDE;
+ const base::Callback<void(bool, const SkBitmap&)>& callback,
+ bool readback_config_rgb565) OVERRIDE;
virtual void CopyFromCompositingSurfaceToVideoFrame(
const gfx::Rect& src_subrect,
const scoped_refptr<media::VideoFrame>& target,