| 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 775a651e76451422630cc2dc61299c4606dbeae5..b733218ed3ca9ebad08d15c8de0c092e4dc9f361 100644
|
| --- a/content/common/gpu/client/gl_helper.cc
|
| +++ b/content/common/gpu/client/gl_helper.cc
|
| @@ -263,7 +263,13 @@ class GLHelper::CopyTextureToImpl {
|
| unsigned char* out,
|
| const base::Callback<void(bool)>& callback);
|
|
|
| - WebKit::WebGLId CopyTexture(WebGLId src_texture, const gfx::Size& size);
|
| + void SyncCopyRawTextureTo(WebGLId texture,
|
| + const gfx::Size& size,
|
| + unsigned char* out);
|
| +
|
| + WebKit::WebGLId CopyTexture(WebGLId texture,
|
| + const gfx::Size& src_size,
|
| + const gfx::Size& dst_size);
|
|
|
| private:
|
| // A single request to CopyTextureTo.
|
| @@ -517,12 +523,32 @@ void GLHelper::CopyTextureToImpl::CopyTextureTo(
|
| base::MessageLoopProxy::current()));
|
| }
|
|
|
| +void GLHelper::CopyTextureToImpl::SyncCopyRawTextureTo(WebGLId texture,
|
| + const gfx::Size& size,
|
| + unsigned char* out) {
|
| + ScopedFramebuffer dst_framebuffer(context_, context_->createFramebuffer());
|
| + ScopedFramebufferBinder<GL_FRAMEBUFFER> framebuffer_binder(
|
| + context_, dst_framebuffer);
|
| + ScopedTextureBinder<GL_TEXTURE_2D> texture_binder(context_, texture);
|
| + context_->framebufferTexture2D(GL_FRAMEBUFFER,
|
| + GL_COLOR_ATTACHMENT0,
|
| + GL_TEXTURE_2D,
|
| + texture,
|
| + 0);
|
| + context_->readPixels(0,
|
| + 0,
|
| + size.width(),
|
| + size.height(),
|
| + GL_RGBA,
|
| + GL_UNSIGNED_BYTE,
|
| + out);
|
| +}
|
| +
|
| WebKit::WebGLId GLHelper::CopyTextureToImpl::CopyTexture(
|
| WebGLId src_texture,
|
| - const gfx::Size& size) {
|
| - if (!context_for_thread_)
|
| - return 0;
|
| - return ScaleTexture(src_texture, size, gfx::Rect(size), size);
|
| + const gfx::Size& src_size,
|
| + const gfx::Size& dst_size) {
|
| + return ScaleTexture(src_texture, src_size, gfx::Rect(src_size), dst_size);
|
| }
|
|
|
| void GLHelper::CopyTextureToImpl::ReadBackFramebuffer(
|
| @@ -673,10 +699,27 @@ void GLHelper::CopyTextureTo(WebGLId src_texture,
|
| callback);
|
| }
|
|
|
| +void GLHelper::SyncCopyRawTextureTo(WebKit::WebGLId texture,
|
| + const gfx::Size& size,
|
| + unsigned char* out) {
|
| + InitCopyTextToImpl();
|
| + copy_texture_to_impl_->SyncCopyRawTextureTo(texture,
|
| + size,
|
| + out);
|
| +}
|
| +
|
| WebKit::WebGLId GLHelper::CopyTexture(WebKit::WebGLId texture,
|
| const gfx::Size& size) {
|
| + return CopyTexture(texture,
|
| + size,
|
| + size);
|
| +}
|
| +
|
| +WebKit::WebGLId GLHelper::CopyTexture(WebKit::WebGLId texture,
|
| + const gfx::Size& src_size,
|
| + const gfx::Size& dst_size) {
|
| InitCopyTextToImpl();
|
| - return copy_texture_to_impl_->CopyTexture(texture, size);
|
| + return copy_texture_to_impl_->CopyTexture(texture, src_size, dst_size);
|
| }
|
|
|
| WebGLId GLHelper::CompileShaderFromSource(
|
|
|