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 3182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3193 } | 3193 } |
| 3194 if (!buffer->mapped()) { | 3194 if (!buffer->mapped()) { |
| 3195 SetGLError(GL_INVALID_OPERATION, "glMapBufferCHROMIUM", "not mapped"); | 3195 SetGLError(GL_INVALID_OPERATION, "glMapBufferCHROMIUM", "not mapped"); |
| 3196 return false; | 3196 return false; |
| 3197 } | 3197 } |
| 3198 buffer->set_mapped(false); | 3198 buffer->set_mapped(false); |
| 3199 | 3199 |
| 3200 return true; | 3200 return true; |
| 3201 } | 3201 } |
| 3202 | 3202 |
| 3203 GLboolean GLES2Implementation::AsyncTexImage2DCHROMIUM( | |
| 3204 GLenum target, GLint level, GLint internalformat, GLsizei width, | |
| 3205 GLsizei height, GLint border, GLenum format, GLenum type, | |
| 3206 const void* pixels) { | |
| 3207 GPU_CLIENT_SINGLE_THREAD_CHECK(); | |
| 3208 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glTexImage2D(" | |
| 3209 << GLES2Util::GetStringTextureTarget(target) << ", " | |
| 3210 << level << ", " | |
| 3211 << GLES2Util::GetStringTextureInternalFormat(internalformat) << ", " | |
| 3212 << width << ", " << height << ", " << border << ", " | |
| 3213 << GLES2Util::GetStringTextureFormat(format) << ", " | |
| 3214 << GLES2Util::GetStringPixelType(type) << ", " | |
| 3215 << static_cast<const void*>(pixels) << ")"); | |
| 3216 if (level < 0 || height < 0 || width < 0) { | |
| 3217 SetGLError(GL_INVALID_VALUE, "glTexImage2D", "dimension < 0"); | |
| 3218 return false; | |
| 3219 } | |
| 3220 uint32 size; | |
| 3221 uint32 unpadded_row_size; | |
| 3222 uint32 padded_row_size; | |
| 3223 if (!GLES2Util::ComputeImageDataSizes( | |
| 3224 width, height, format, type, unpack_alignment_, &size, | |
| 3225 &unpadded_row_size, &padded_row_size)) { | |
| 3226 SetGLError(GL_INVALID_VALUE, "glTexImage2D", "image size too large"); | |
| 3227 return false; | |
| 3228 } | |
| 3229 | |
| 3230 // If there's no data/buffer just issue the AsyncTexImage2D | |
| 3231 if (!pixels && !bound_pixel_unpack_transfer_buffer_id_) { | |
| 3232 helper_->AsyncTexImage2DCHROMIUM( | |
| 3233 target, level, internalformat, width, height, border, format, type, | |
| 3234 0, 0); | |
| 3235 return true; | |
| 3236 } | |
| 3237 | |
| 3238 // Otherwise, async uploads require a transfer buffer to be bound. | |
| 3239 GLuint offset = ToGLuint(pixels); | |
| 3240 BufferTracker::Buffer* buffer = GetBoundPixelUnpackTransferBufferIfValid( | |
| 3241 "glAsyncTexImage2DCHROMIUM", offset, size); | |
| 3242 if (!buffer) | |
| 3243 return false; | |
| 3244 | |
| 3245 helper_->AsyncTexImage2DCHROMIUM( | |
| 3246 target, level, internalformat, width, height, border, format, type, | |
| 3247 buffer->shm_id(), buffer->shm_offset() + offset); | |
| 3248 return true; | |
| 3249 } | |
| 3250 | |
| 3251 GLboolean GLES2Implementation::AsyncTexSubImage2DCHROMIUM( | |
| 3252 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, | |
| 3253 GLsizei height, GLenum format, GLenum type, const void* pixels) { | |
| 3254 GPU_CLIENT_SINGLE_THREAD_CHECK(); | |
| 3255 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glAsyncTexSubImage2DCHROMIUM(" | |
| 3256 << GLES2Util::GetStringTextureTarget(target) << ", " | |
| 3257 << level << ", " | |
| 3258 << xoffset << ", " << yoffset << ", " | |
| 3259 << width << ", " << height << ", " | |
| 3260 << GLES2Util::GetStringTextureFormat(format) << ", " | |
| 3261 << GLES2Util::GetStringPixelType(type) << ", " | |
| 3262 << static_cast<const void*>(pixels) << ")"); | |
| 3263 if (level < 0 || height < 0 || width < 0) { | |
| 3264 SetGLError( | |
| 3265 GL_INVALID_VALUE, "glAsyncTexSubImage2DCHROMIUM", "dimension < 0"); | |
| 3266 return false; | |
| 3267 } | |
| 3268 if (height == 0 || width == 0) { | |
|
greggman
2012/11/30 04:32:12
It seems like it would be best not to exit early h
epennerAtGoogle
2012/11/30 06:16:27
Done.
| |
| 3269 return false; | |
| 3270 } | |
| 3271 | |
| 3272 uint32 size; | |
| 3273 uint32 unpadded_row_size; | |
| 3274 uint32 padded_row_size; | |
| 3275 if (!GLES2Util::ComputeImageDataSizes( | |
| 3276 width, height, format, type, unpack_alignment_, &size, | |
| 3277 &unpadded_row_size, &padded_row_size)) { | |
| 3278 SetGLError( | |
| 3279 GL_INVALID_VALUE, "glAsyncTexSubImage2DCHROMIUM", "size to large"); | |
| 3280 return false; | |
| 3281 } | |
| 3282 | |
| 3283 // Async uploads require a transfer buffer to be bound. | |
| 3284 GLuint offset = ToGLuint(pixels); | |
| 3285 BufferTracker::Buffer* buffer = GetBoundPixelUnpackTransferBufferIfValid( | |
| 3286 "glAsyncTexSubImage2DCHROMIUM", offset, size); | |
| 3287 if (!buffer) | |
| 3288 return false; | |
| 3289 | |
| 3290 helper_->AsyncTexSubImage2DCHROMIUM( | |
| 3291 target, level, xoffset, yoffset, width, height, format, type, | |
| 3292 buffer->shm_id(), buffer->shm_offset() + offset); | |
| 3293 return true; | |
| 3294 } | |
| 3295 | |
| 3203 // Include the auto-generated part of this file. We split this because it means | 3296 // Include the auto-generated part of this file. We split this because it means |
| 3204 // we can easily edit the non-auto generated parts right here in this file | 3297 // we can easily edit the non-auto generated parts right here in this file |
| 3205 // instead of having to edit some template or the code generator. | 3298 // instead of having to edit some template or the code generator. |
| 3206 #include "../client/gles2_implementation_impl_autogen.h" | 3299 #include "../client/gles2_implementation_impl_autogen.h" |
| 3207 | 3300 |
| 3208 } // namespace gles2 | 3301 } // namespace gles2 |
| 3209 } // namespace gpu | 3302 } // namespace gpu |
| OLD | NEW |