Chromium Code Reviews| Index: gpu/command_buffer/client/gles2_implementation.cc |
| diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc |
| index 8fc6e752c3e4ba08e547a8de9510afaaaf6e810e..dcbaa3eee176dd120bc06cedc5b75b21898cb4f4 100644 |
| --- a/gpu/command_buffer/client/gles2_implementation.cc |
| +++ b/gpu/command_buffer/client/gles2_implementation.cc |
| @@ -3659,6 +3659,105 @@ GLboolean GLES2Implementation::UnmapBufferCHROMIUM(GLuint target) { |
| return true; |
| } |
| +GLboolean GLES2Implementation::AsyncTexImage2DCHROMIUM( |
| + GLenum target, GLint level, GLint internalformat, GLsizei width, |
| + GLsizei height, GLint border, GLenum format, GLenum type, |
| + const void* pixels) { |
| + GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| + GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glTexImage2D(" |
| + << GLES2Util::GetStringTextureTarget(target) << ", " |
| + << level << ", " |
| + << GLES2Util::GetStringTextureInternalFormat(internalformat) << ", " |
| + << width << ", " << height << ", " << border << ", " |
| + << GLES2Util::GetStringTextureFormat(format) << ", " |
| + << GLES2Util::GetStringPixelType(type) << ", " |
| + << static_cast<const void*>(pixels) << ")"); |
| + if (level < 0 || height < 0 || width < 0) { |
| + SetGLError(GL_INVALID_VALUE, "glTexImage2D", "dimension < 0"); |
| + return false; |
| + } |
| + uint32 size; |
| + uint32 unpadded_row_size; |
| + uint32 padded_row_size; |
| + if (!GLES2Util::ComputeImageDataSizes( |
| + width, height, format, type, unpack_alignment_, &size, |
| + &unpadded_row_size, &padded_row_size)) { |
| + SetGLError(GL_INVALID_VALUE, "glTexImage2D", "image size too large"); |
| + return false; |
| + } |
| + |
| + // If there's no data just issue the AsyncTexImage2D. |
| + if (!pixels) { |
|
reveman
2012/11/29 00:25:23
this won't work. |pixels| is an offset when a tran
epennerAtGoogle
2012/11/29 00:38:11
Good point. It does seem a tad awkward, but I thin
|
| + helper_->AsyncTexImage2DCHROMIUM( |
| + target, level, internalformat, width, height, border, format, type, |
| + 0, 0); |
| + return true; |
| + } |
| + |
| + // Async uploads require a transfer buffer to be bound. |
| + GLuint offset = ToGLuint(pixels); |
| + BufferTracker::Buffer* buffer = GetBoundPixelUnpackTransferBufferIfValid( |
| + "glAsyncTexImage2DCHROMIUM", offset, size); |
| + if (!bound_pixel_unpack_transfer_buffer_id_ || !buffer) { |
| + SetGLError( |
| + GL_INVALID_VALUE, "glAsyncTexImage2DCHROMIUM", "invalid buffer"); |
| + return false; |
| + } |
| + |
| + helper_->AsyncTexImage2DCHROMIUM( |
| + target, level, internalformat, width, height, border, format, type, |
| + buffer->shm_id(), buffer->shm_offset() + offset); |
| + return true; |
| +} |
| + |
| +GLboolean GLES2Implementation::AsyncTexSubImage2DCHROMIUM( |
| + GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, |
| + GLsizei height, GLenum format, GLenum type, const void* pixels) { |
| + GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| + GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glAsyncTexSubImage2DCHROMIUM(" |
| + << GLES2Util::GetStringTextureTarget(target) << ", " |
| + << level << ", " |
| + << xoffset << ", " << yoffset << ", " |
| + << width << ", " << height << ", " |
| + << GLES2Util::GetStringTextureFormat(format) << ", " |
| + << GLES2Util::GetStringPixelType(type) << ", " |
| + << static_cast<const void*>(pixels) << ")"); |
| + if (level < 0 || height < 0 || width < 0) { |
| + SetGLError( |
| + GL_INVALID_VALUE, "glAsyncTexSubImage2DCHROMIUM", "dimension < 0"); |
| + return false; |
| + } |
| + if (height == 0 || width == 0) { |
| + return false; |
| + } |
| + |
| + uint32 size; |
| + uint32 unpadded_row_size; |
| + uint32 padded_row_size; |
| + if (!GLES2Util::ComputeImageDataSizes( |
| + width, height, format, type, unpack_alignment_, &size, |
| + &unpadded_row_size, &padded_row_size)) { |
| + SetGLError( |
| + GL_INVALID_VALUE, "glAsyncTexSubImage2DCHROMIUM", "size to large"); |
| + return false; |
| + } |
| + |
| + // Async uploads require a transfer buffer to be bound. |
| + GLuint offset = ToGLuint(pixels); |
| + BufferTracker::Buffer* buffer = GetBoundPixelUnpackTransferBufferIfValid( |
| + "glAsyncTexSubImage2DCHROMIUM", offset, size); |
| + if (!bound_pixel_unpack_transfer_buffer_id_ || !buffer) { |
| + SetGLError( |
| + GL_INVALID_VALUE, "glAsyncTexSubImage2DCHROMIUM", "invalid buffer"); |
| + return false; |
| + } |
| + |
| + helper_->AsyncTexSubImage2DCHROMIUM( |
| + target, level, xoffset, yoffset, width, height, format, type, |
| + buffer->shm_id(), buffer->shm_offset() + offset); |
| + return true; |
| +} |
| + |
| // Include the auto-generated part of this file. We split this because it means |
| // we can easily edit the non-auto generated parts right here in this file |
| // instead of having to edit some template or the code generator. |