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

Unified Diff: content/common/gpu/client/gl_helper.cc

Issue 133813003: Add Async API unittests to readback format. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes done as per review comments. 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
« no previous file with comments | « content/common/gpu/client/gl_helper.h ('k') | content/common/gpu/client/gl_helper_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/gpu/client/gl_helper.cc
diff --git a/content/common/gpu/client/gl_helper.cc b/content/common/gpu/client/gl_helper.cc
index c436542c8a10fc7d7b16ebdfb493820b4f8633ff..8d9dbac3b152f0318f523d20330b410c3b83478d 100644
--- a/content/common/gpu/client/gl_helper.cc
+++ b/content/common/gpu/client/gl_helper.cc
@@ -136,6 +136,12 @@ class GLHelper::CopyTextureToImpl
unsigned char* out,
SkBitmap::Config format);
+ void ReadbackTextureAsync(GLuint texture,
+ const gfx::Size& dst_size,
+ unsigned char* out,
+ SkBitmap::Config config,
+ const base::Callback<void(bool)>& callback);
+
// Reads back bytes from the currently bound frame buffer.
// Note that dst_size is specified in bytes, not pixels.
void ReadbackAsync(const gfx::Size& dst_size,
@@ -529,6 +535,37 @@ void GLHelper::CopyTextureToImpl::ReadbackTextureSync(GLuint texture,
out);
}
+void GLHelper::CopyTextureToImpl::ReadbackTextureAsync(
+ GLuint texture,
+ const gfx::Size& dst_size,
+ unsigned char* out,
+ SkBitmap::Config config,
+ const base::Callback<void(bool)>& callback) {
+ // Only ARGB888 and RGB565 supported as of now.
+ bool format_support = ((config == SkBitmap::kRGB_565_Config) ||
+ (config == SkBitmap::kARGB_8888_Config));
+ if (!format_support) {
+ DCHECK(format_support);
+ return;
+ }
+ 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);
+ int bytes_per_pixel = (config == SkBitmap::kRGB_565_Config) ? 2 : 4;
+ ReadbackAsync(dst_size,
+ dst_size.width() * bytes_per_pixel,
+ dst_size.width() * bytes_per_pixel,
+ out,
+ config,
+ callback);
+}
+
GLuint GLHelper::CopyTextureToImpl::CopyAndScaleTexture(
GLuint src_texture,
const gfx::Size& src_size,
@@ -663,6 +700,20 @@ void GLHelper::ReadbackTextureSync(GLuint texture,
copy_texture_to_impl_->ReadbackTextureSync(texture, src_rect, out, format);
}
+void GLHelper::ReadbackTextureAsync(
+ GLuint texture,
+ const gfx::Size& dst_size,
+ unsigned char* out,
+ SkBitmap::Config config,
+ const base::Callback<void(bool)>& callback) {
+ InitCopyTextToImpl();
+ copy_texture_to_impl_->ReadbackTextureAsync(texture,
+ dst_size,
+ out,
+ config,
+ callback);
+}
+
GLuint GLHelper::CopyTexture(GLuint texture, const gfx::Size& size) {
InitCopyTextToImpl();
return copy_texture_to_impl_->CopyAndScaleTexture(
« no previous file with comments | « content/common/gpu/client/gl_helper.h ('k') | content/common/gpu/client/gl_helper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698