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 7da9389bc10ef9c31f001eb5757a344f3ba69f30..96e483f1f0eb00a12b3f91a5ee890dbfc50e2401 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, |
@@ -473,6 +479,31 @@ 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) { |
piman
2014/01/23 20:43:57
Can you add DCHECKs on the supported formats?
sivag
2014/01/24 15:56:40
Done.
|
+ 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 readback_config_rgb565 = (config == SkBitmap::kRGB_565_Config); |
+ 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, |
piman
2014/01/23 20:43:57
This would change when rebasing on top of your htt
sivag
2014/01/24 15:56:40
Thanks for sharing this tip :). As my branches are
|
+ callback); |
+} |
+ |
GLuint GLHelper::CopyTextureToImpl::CopyAndScaleTexture( |
GLuint src_texture, |
const gfx::Size& src_size, |
@@ -607,6 +638,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( |