| 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 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 11366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11377 return error::kInvalidArguments; | 11377 return error::kInvalidArguments; |
| 11378 } | 11378 } |
| 11379 std::string name_str; | 11379 std::string name_str; |
| 11380 if (!bucket->GetAsString(&name_str)) { | 11380 if (!bucket->GetAsString(&name_str)) { |
| 11381 return error::kInvalidArguments; | 11381 return error::kInvalidArguments; |
| 11382 } | 11382 } |
| 11383 return GetAttribLocationHelper( | 11383 return GetAttribLocationHelper( |
| 11384 c.program, c.location_shm_id, c.location_shm_offset, name_str); | 11384 c.program, c.location_shm_id, c.location_shm_offset, name_str); |
| 11385 } | 11385 } |
| 11386 | 11386 |
| 11387 error::Error GLES2DecoderImpl::HandleGetBufferSubDataAsyncCHROMIUM( |
| 11388 uint32_t immediate_data_size, |
| 11389 const volatile void* cmd_data) { |
| 11390 if (!unsafe_es3_apis_enabled()) { |
| 11391 return error::kUnknownCommand; |
| 11392 } |
| 11393 const volatile gles2::cmds::GetBufferSubDataAsyncCHROMIUM& c = |
| 11394 *static_cast<const volatile gles2::cmds::GetBufferSubDataAsyncCHROMIUM*>( |
| 11395 cmd_data); |
| 11396 GLenum target = static_cast<GLenum>(c.target); |
| 11397 GLintptr offset = static_cast<GLintptr>(c.offset); |
| 11398 GLsizeiptr size = static_cast<GLsizeiptr>(c.size); |
| 11399 uint32_t data_shm_id = static_cast<uint32_t>(c.data_shm_id); |
| 11400 |
| 11401 int8_t* mem = |
| 11402 GetSharedMemoryAs<int8_t*>(data_shm_id, c.data_shm_offset, size); |
| 11403 if (!mem) { |
| 11404 return error::kOutOfBounds; |
| 11405 } |
| 11406 |
| 11407 if (!validators_->buffer_target.IsValid(target)) { |
| 11408 return error::kInvalidArguments; |
| 11409 } |
| 11410 |
| 11411 Buffer* buffer = buffer_manager()->GetBufferInfoForTarget(&state_, target); |
| 11412 if (!buffer) { |
| 11413 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glGetBufferSubDataAsyncCHROMIUM", |
| 11414 "no buffer bound to target"); |
| 11415 return error::kNoError; |
| 11416 } |
| 11417 if (!buffer->CheckRange(offset, size)) { |
| 11418 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glGetBufferSubDataAsyncCHROMIUM", |
| 11419 "invalid range"); |
| 11420 return error::kNoError; |
| 11421 } |
| 11422 |
| 11423 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glGetBufferSubDataAsyncCHROMIUM"); |
| 11424 |
| 11425 void* ptr = glMapBufferRange(target, offset, size, GL_MAP_READ_BIT); |
| 11426 if (ptr == nullptr) { |
| 11427 return error::kInvalidArguments; |
| 11428 } |
| 11429 memcpy(mem, ptr, size); |
| 11430 glUnmapBuffer(target); |
| 11431 |
| 11432 GLenum error = LOCAL_PEEK_GL_ERROR("glGetBufferSubDataAsyncCHROMIUM"); |
| 11433 if (error != GL_NO_ERROR) { |
| 11434 return error::kInvalidArguments; |
| 11435 } |
| 11436 return error::kNoError; |
| 11437 } |
| 11438 |
| 11387 error::Error GLES2DecoderImpl::GetUniformLocationHelper( | 11439 error::Error GLES2DecoderImpl::GetUniformLocationHelper( |
| 11388 GLuint client_id, | 11440 GLuint client_id, |
| 11389 uint32_t location_shm_id, | 11441 uint32_t location_shm_id, |
| 11390 uint32_t location_shm_offset, | 11442 uint32_t location_shm_offset, |
| 11391 const std::string& name_str) { | 11443 const std::string& name_str) { |
| 11392 if (!StringIsValidForGLES(name_str)) { | 11444 if (!StringIsValidForGLES(name_str)) { |
| 11393 LOCAL_SET_GL_ERROR( | 11445 LOCAL_SET_GL_ERROR( |
| 11394 GL_INVALID_VALUE, "glGetUniformLocation", "Invalid character"); | 11446 GL_INVALID_VALUE, "glGetUniformLocation", "Invalid character"); |
| 11395 return error::kNoError; | 11447 return error::kNoError; |
| 11396 } | 11448 } |
| (...skipping 6712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18109 } | 18161 } |
| 18110 | 18162 |
| 18111 // Include the auto-generated part of this file. We split this because it means | 18163 // Include the auto-generated part of this file. We split this because it means |
| 18112 // we can easily edit the non-auto generated parts right here in this file | 18164 // we can easily edit the non-auto generated parts right here in this file |
| 18113 // instead of having to edit some template or the code generator. | 18165 // instead of having to edit some template or the code generator. |
| 18114 #include "base/macros.h" | 18166 #include "base/macros.h" |
| 18115 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 18167 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 18116 | 18168 |
| 18117 } // namespace gles2 | 18169 } // namespace gles2 |
| 18118 } // namespace gpu | 18170 } // namespace gpu |
| OLD | NEW |