Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // A class to emulate GLES2 over command buffers. | 5 // A class to emulate GLES2 over command buffers. |
| 6 | 6 |
| 7 #include "../client/gles2_implementation.h" | 7 #include "../client/gles2_implementation.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 3641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3652 } | 3652 } |
| 3653 if (!buffer->mapped()) { | 3653 if (!buffer->mapped()) { |
| 3654 SetGLError(GL_INVALID_OPERATION, "glMapBufferCHROMIUM", "not mapped"); | 3654 SetGLError(GL_INVALID_OPERATION, "glMapBufferCHROMIUM", "not mapped"); |
| 3655 return false; | 3655 return false; |
| 3656 } | 3656 } |
| 3657 buffer->set_mapped(false); | 3657 buffer->set_mapped(false); |
| 3658 | 3658 |
| 3659 return true; | 3659 return true; |
| 3660 } | 3660 } |
| 3661 | 3661 |
| 3662 GLboolean GLES2Implementation::AsyncTexImage2DCHROMIUM( | |
| 3663 GLenum target, GLint level, GLint internalformat, GLsizei width, | |
| 3664 GLsizei height, GLint border, GLenum format, GLenum type, | |
| 3665 const void* pixels) { | |
| 3666 GPU_CLIENT_SINGLE_THREAD_CHECK(); | |
| 3667 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glTexImage2D(" | |
| 3668 << GLES2Util::GetStringTextureTarget(target) << ", " | |
| 3669 << level << ", " | |
| 3670 << GLES2Util::GetStringTextureInternalFormat(internalformat) << ", " | |
| 3671 << width << ", " << height << ", " << border << ", " | |
| 3672 << GLES2Util::GetStringTextureFormat(format) << ", " | |
| 3673 << GLES2Util::GetStringPixelType(type) << ", " | |
| 3674 << static_cast<const void*>(pixels) << ")"); | |
| 3675 if (level < 0 || height < 0 || width < 0) { | |
| 3676 SetGLError(GL_INVALID_VALUE, "glTexImage2D", "dimension < 0"); | |
| 3677 return false; | |
| 3678 } | |
| 3679 uint32 size; | |
| 3680 uint32 unpadded_row_size; | |
| 3681 uint32 padded_row_size; | |
| 3682 if (!GLES2Util::ComputeImageDataSizes( | |
| 3683 width, height, format, type, unpack_alignment_, &size, | |
| 3684 &unpadded_row_size, &padded_row_size)) { | |
| 3685 SetGLError(GL_INVALID_VALUE, "glTexImage2D", "image size too large"); | |
| 3686 return false; | |
| 3687 } | |
| 3688 | |
| 3689 // If there's no data just issue the AsyncTexImage2D. | |
| 3690 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
| |
| 3691 helper_->AsyncTexImage2DCHROMIUM( | |
| 3692 target, level, internalformat, width, height, border, format, type, | |
| 3693 0, 0); | |
| 3694 return true; | |
| 3695 } | |
| 3696 | |
| 3697 // Async uploads require a transfer buffer to be bound. | |
| 3698 GLuint offset = ToGLuint(pixels); | |
| 3699 BufferTracker::Buffer* buffer = GetBoundPixelUnpackTransferBufferIfValid( | |
| 3700 "glAsyncTexImage2DCHROMIUM", offset, size); | |
| 3701 if (!bound_pixel_unpack_transfer_buffer_id_ || !buffer) { | |
| 3702 SetGLError( | |
| 3703 GL_INVALID_VALUE, "glAsyncTexImage2DCHROMIUM", "invalid buffer"); | |
| 3704 return false; | |
| 3705 } | |
| 3706 | |
| 3707 helper_->AsyncTexImage2DCHROMIUM( | |
| 3708 target, level, internalformat, width, height, border, format, type, | |
| 3709 buffer->shm_id(), buffer->shm_offset() + offset); | |
| 3710 return true; | |
| 3711 } | |
| 3712 | |
| 3713 GLboolean GLES2Implementation::AsyncTexSubImage2DCHROMIUM( | |
| 3714 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, | |
| 3715 GLsizei height, GLenum format, GLenum type, const void* pixels) { | |
| 3716 GPU_CLIENT_SINGLE_THREAD_CHECK(); | |
| 3717 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glAsyncTexSubImage2DCHROMIUM(" | |
| 3718 << GLES2Util::GetStringTextureTarget(target) << ", " | |
| 3719 << level << ", " | |
| 3720 << xoffset << ", " << yoffset << ", " | |
| 3721 << width << ", " << height << ", " | |
| 3722 << GLES2Util::GetStringTextureFormat(format) << ", " | |
| 3723 << GLES2Util::GetStringPixelType(type) << ", " | |
| 3724 << static_cast<const void*>(pixels) << ")"); | |
| 3725 if (level < 0 || height < 0 || width < 0) { | |
| 3726 SetGLError( | |
| 3727 GL_INVALID_VALUE, "glAsyncTexSubImage2DCHROMIUM", "dimension < 0"); | |
| 3728 return false; | |
| 3729 } | |
| 3730 if (height == 0 || width == 0) { | |
| 3731 return false; | |
| 3732 } | |
| 3733 | |
| 3734 uint32 size; | |
| 3735 uint32 unpadded_row_size; | |
| 3736 uint32 padded_row_size; | |
| 3737 if (!GLES2Util::ComputeImageDataSizes( | |
| 3738 width, height, format, type, unpack_alignment_, &size, | |
| 3739 &unpadded_row_size, &padded_row_size)) { | |
| 3740 SetGLError( | |
| 3741 GL_INVALID_VALUE, "glAsyncTexSubImage2DCHROMIUM", "size to large"); | |
| 3742 return false; | |
| 3743 } | |
| 3744 | |
| 3745 // Async uploads require a transfer buffer to be bound. | |
| 3746 GLuint offset = ToGLuint(pixels); | |
| 3747 BufferTracker::Buffer* buffer = GetBoundPixelUnpackTransferBufferIfValid( | |
| 3748 "glAsyncTexSubImage2DCHROMIUM", offset, size); | |
| 3749 if (!bound_pixel_unpack_transfer_buffer_id_ || !buffer) { | |
| 3750 SetGLError( | |
| 3751 GL_INVALID_VALUE, "glAsyncTexSubImage2DCHROMIUM", "invalid buffer"); | |
| 3752 return false; | |
| 3753 } | |
| 3754 | |
| 3755 helper_->AsyncTexSubImage2DCHROMIUM( | |
| 3756 target, level, xoffset, yoffset, width, height, format, type, | |
| 3757 buffer->shm_id(), buffer->shm_offset() + offset); | |
| 3758 return true; | |
| 3759 } | |
| 3760 | |
| 3662 // Include the auto-generated part of this file. We split this because it means | 3761 // Include the auto-generated part of this file. We split this because it means |
| 3663 // we can easily edit the non-auto generated parts right here in this file | 3762 // we can easily edit the non-auto generated parts right here in this file |
| 3664 // instead of having to edit some template or the code generator. | 3763 // instead of having to edit some template or the code generator. |
| 3665 #include "../client/gles2_implementation_impl_autogen.h" | 3764 #include "../client/gles2_implementation_impl_autogen.h" |
| 3666 | 3765 |
| 3667 } // namespace gles2 | 3766 } // namespace gles2 |
| 3668 } // namespace gpu | 3767 } // namespace gpu |
| OLD | NEW |