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 2085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2096 int8* dest = reinterpret_cast<int8*>(pixels); | 2096 int8* dest = reinterpret_cast<int8*>(pixels); |
2097 uint32 temp_size; | 2097 uint32 temp_size; |
2098 uint32 unpadded_row_size; | 2098 uint32 unpadded_row_size; |
2099 uint32 padded_row_size; | 2099 uint32 padded_row_size; |
2100 if (!GLES2Util::ComputeImageDataSizes( | 2100 if (!GLES2Util::ComputeImageDataSizes( |
2101 width, 2, format, type, pack_alignment_, &temp_size, &unpadded_row_size, | 2101 width, 2, format, type, pack_alignment_, &temp_size, &unpadded_row_size, |
2102 &padded_row_size)) { | 2102 &padded_row_size)) { |
2103 SetGLError(GL_INVALID_VALUE, "glReadPixels", "size too large."); | 2103 SetGLError(GL_INVALID_VALUE, "glReadPixels", "size too large."); |
2104 return; | 2104 return; |
2105 } | 2105 } |
2106 | |
2107 if (bound_pixel_unpack_transfer_buffer_id_) { | |
greggman
2013/03/19 20:54:11
As pointed out else where, "unpack" is for providi
hubbe
2013/03/19 22:42:42
Done.
| |
2108 GLuint offset = ToGLuint(pixels); | |
2109 BufferTracker::Buffer* buffer = GetBoundPixelUnpackTransferBufferIfValid( | |
2110 "glReadPixels", offset, temp_size); | |
2111 if (buffer) { | |
2112 helper_->ReadPixels(xoffset, yoffset, width, height, format, type, | |
2113 buffer->shm_id(), buffer->shm_offset(), | |
2114 0, 0); | |
2115 buffer->set_transfer_ready_token(helper_->InsertToken()); | |
2116 } | |
2117 return; | |
apatrick_chromium
2013/03/19 18:34:48
Should this not generate INVALID_OPERATION?
hubbe
2013/03/19 22:42:42
Done. (And in other similar places)
| |
2118 } | |
2119 | |
2120 if (!pixels) { | |
2121 SetGLError(GL_INVALID_VALUE, "glReadPixels", "pixels = NULL"); | |
2122 return; | |
2123 } | |
2124 | |
2106 // Transfer by rows. | 2125 // Transfer by rows. |
2107 // The max rows we can transfer. | 2126 // The max rows we can transfer. |
2108 while (height) { | 2127 while (height) { |
2109 GLsizei desired_size = padded_row_size * height - 1 + unpadded_row_size; | 2128 GLsizei desired_size = padded_row_size * height - 1 + unpadded_row_size; |
2110 ScopedTransferBufferPtr buffer(desired_size, helper_, transfer_buffer_); | 2129 ScopedTransferBufferPtr buffer(desired_size, helper_, transfer_buffer_); |
2111 if (!buffer.valid()) { | 2130 if (!buffer.valid()) { |
2112 return; | 2131 return; |
2113 } | 2132 } |
2114 GLint num_rows = ComputeNumRowsThatFitInBuffer( | 2133 GLint num_rows = ComputeNumRowsThatFitInBuffer( |
2115 padded_row_size, unpadded_row_size, buffer.size()); | 2134 padded_row_size, unpadded_row_size, buffer.size()); |
(...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3297 | 3316 |
3298 void* GLES2Implementation::MapBufferCHROMIUM(GLuint target, GLenum access) { | 3317 void* GLES2Implementation::MapBufferCHROMIUM(GLuint target, GLenum access) { |
3299 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 3318 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
3300 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glMapBufferCHROMIUM(" | 3319 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glMapBufferCHROMIUM(" |
3301 << target << ", " << GLES2Util::GetStringEnum(access) << ")"); | 3320 << target << ", " << GLES2Util::GetStringEnum(access) << ")"); |
3302 if (target != GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM) { | 3321 if (target != GL_PIXEL_UNPACK_TRANSFER_BUFFER_CHROMIUM) { |
3303 SetGLError( | 3322 SetGLError( |
3304 GL_INVALID_ENUM, "glMapBufferCHROMIUM", "invalid target"); | 3323 GL_INVALID_ENUM, "glMapBufferCHROMIUM", "invalid target"); |
3305 return NULL; | 3324 return NULL; |
3306 } | 3325 } |
3307 if (access != GL_WRITE_ONLY) { | 3326 if (access != GL_WRITE_ONLY && access != GL_READ_ONLY) { |
3308 SetGLError(GL_INVALID_ENUM, "glMapBufferCHROMIUM", "bad access mode"); | 3327 SetGLError(GL_INVALID_ENUM, "glMapBufferCHROMIUM", "bad access mode"); |
3309 return NULL; | 3328 return NULL; |
3310 } | 3329 } |
3311 BufferTracker::Buffer* buffer = buffer_tracker_->GetBuffer( | 3330 BufferTracker::Buffer* buffer = buffer_tracker_->GetBuffer( |
3312 bound_pixel_unpack_transfer_buffer_id_); | 3331 bound_pixel_unpack_transfer_buffer_id_); |
3313 if (!buffer) { | 3332 if (!buffer) { |
3314 SetGLError(GL_INVALID_OPERATION, "glMapBufferCHROMIUM", "invalid buffer"); | 3333 SetGLError(GL_INVALID_OPERATION, "glMapBufferCHROMIUM", "invalid buffer"); |
3315 return NULL; | 3334 return NULL; |
3316 } | 3335 } |
3317 if (buffer->mapped()) { | 3336 if (buffer->mapped()) { |
3318 SetGLError(GL_INVALID_OPERATION, "glMapBufferCHROMIUM", "already mapped"); | 3337 SetGLError(GL_INVALID_OPERATION, "glMapBufferCHROMIUM", "already mapped"); |
3319 return NULL; | 3338 return NULL; |
3320 } | 3339 } |
3340 if (buffer->transfer_ready_token()) { | |
greggman
2013/03/19 20:54:11
It seems like if you're going to add this check yo
hubbe
2013/03/19 22:42:42
I can do it either way.
I think I prefer implement
| |
3341 helper_->WaitForToken(buffer->transfer_ready_token()); | |
3342 buffer->set_transfer_ready_token(0); | |
3343 } | |
3321 buffer->set_mapped(true); | 3344 buffer->set_mapped(true); |
3322 | 3345 |
3323 GPU_DCHECK(buffer->address()); | 3346 GPU_DCHECK(buffer->address()); |
3324 GPU_CLIENT_LOG(" returned " << buffer->address()); | 3347 GPU_CLIENT_LOG(" returned " << buffer->address()); |
3325 CheckGLError(); | 3348 CheckGLError(); |
3326 return buffer->address(); | 3349 return buffer->address(); |
3327 } | 3350 } |
3328 | 3351 |
3329 GLboolean GLES2Implementation::UnmapBufferCHROMIUM(GLuint target) { | 3352 GLboolean GLES2Implementation::UnmapBufferCHROMIUM(GLuint target) { |
3330 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 3353 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3453 return helper_->InsertSyncPointCHROMIUM(); | 3476 return helper_->InsertSyncPointCHROMIUM(); |
3454 } | 3477 } |
3455 | 3478 |
3456 // Include the auto-generated part of this file. We split this because it means | 3479 // Include the auto-generated part of this file. We split this because it means |
3457 // we can easily edit the non-auto generated parts right here in this file | 3480 // we can easily edit the non-auto generated parts right here in this file |
3458 // instead of having to edit some template or the code generator. | 3481 // instead of having to edit some template or the code generator. |
3459 #include "../client/gles2_implementation_impl_autogen.h" | 3482 #include "../client/gles2_implementation_impl_autogen.h" |
3460 | 3483 |
3461 } // namespace gles2 | 3484 } // namespace gles2 |
3462 } // namespace gpu | 3485 } // namespace gpu |
OLD | NEW |