Chromium Code Reviews| 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..9e60530fa748f411ad8be53daeae0f562cc38259 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,38 @@ 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 readback_config_rgb565 = (config == SkBitmap::kRGB_565_Config); |
| + int bytes_per_pixel = readback_config_rgb565 ? 2 : 4; |
|
piman
2014/01/24 20:26:31
nit: you're not otherwise using readback_config_rg
sivag
2014/01/25 08:34:02
Done.
|
| + 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 +701,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( |