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 <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <list> | 10 #include <list> |
(...skipping 9293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9304 SetGLError(GL_INVALID_OPERATION, | 9304 SetGLError(GL_INVALID_OPERATION, |
9305 "glTraceEndCHROMIUM", "no trace begin found"); | 9305 "glTraceEndCHROMIUM", "no trace begin found"); |
9306 return; | 9306 return; |
9307 } | 9307 } |
9308 | 9308 |
9309 linked_ptr<GPUTrace> trace = gpu_trace_stack_.top(); | 9309 linked_ptr<GPUTrace> trace = gpu_trace_stack_.top(); |
9310 trace->EnableEndTrace(); | 9310 trace->EnableEndTrace(); |
9311 gpu_trace_stack_.pop(); | 9311 gpu_trace_stack_.pop(); |
9312 } | 9312 } |
9313 | 9313 |
| 9314 error::Error GLES2DecoderImpl::HandleAsyncTexImage2DCHROMIUM( |
| 9315 uint32 immediate_data_size, const gles2::AsyncTexImage2DCHROMIUM& c) { |
| 9316 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandleAsyncTexImage2DCHROMIUM"); |
| 9317 |
| 9318 // TODO: This is a copy of HandleTexImage2D validation. Merge |
| 9319 // as much of it as possible. |
| 9320 tex_image_2d_failed_ = true; |
| 9321 GLenum target = static_cast<GLenum>(c.target); |
| 9322 GLint level = static_cast<GLint>(c.level); |
| 9323 GLint internal_format = static_cast<GLint>(c.internalformat); |
| 9324 GLsizei width = static_cast<GLsizei>(c.width); |
| 9325 GLsizei height = static_cast<GLsizei>(c.height); |
| 9326 GLint border = static_cast<GLint>(c.border); |
| 9327 GLenum format = static_cast<GLenum>(c.format); |
| 9328 GLenum type = static_cast<GLenum>(c.type); |
| 9329 uint32 pixels_shm_id = static_cast<uint32>(c.pixels_shm_id); |
| 9330 uint32 pixels_shm_offset = static_cast<uint32>(c.pixels_shm_offset); |
| 9331 uint32 pixels_size; |
| 9332 if (!GLES2Util::ComputeImageDataSizes( |
| 9333 width, height, format, type, state_.unpack_alignment, &pixels_size, NULL, |
| 9334 NULL)) { |
| 9335 return error::kOutOfBounds; |
| 9336 } |
| 9337 const void* pixels = NULL; |
| 9338 if (pixels_shm_id != 0 || pixels_shm_offset != 0) { |
| 9339 pixels = GetSharedMemoryAs<const void*>( |
| 9340 pixels_shm_id, pixels_shm_offset, pixels_size); |
| 9341 if (!pixels) { |
| 9342 return error::kOutOfBounds; |
| 9343 } |
| 9344 } |
| 9345 |
| 9346 // TODO(epenner): Do this via an async task. |
| 9347 return DoTexImage2D( |
| 9348 target, level, internal_format, width, height, border, format, type, |
| 9349 pixels, pixels_size); |
| 9350 } |
| 9351 |
| 9352 error::Error GLES2DecoderImpl::HandleAsyncTexSubImage2DCHROMIUM( |
| 9353 uint32 immediate_data_size, const gles2::AsyncTexSubImage2DCHROMIUM& c) { |
| 9354 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandleAsyncTexSubImage2DCHROMIUM"); |
| 9355 |
| 9356 // TODO: This is a copy of HandleTexSubImage2D validation. Merge |
| 9357 // as much of it as possible. |
| 9358 GLenum target = static_cast<GLenum>(c.target); |
| 9359 GLint level = static_cast<GLint>(c.level); |
| 9360 GLint xoffset = static_cast<GLint>(c.xoffset); |
| 9361 GLint yoffset = static_cast<GLint>(c.yoffset); |
| 9362 GLsizei width = static_cast<GLsizei>(c.width); |
| 9363 GLsizei height = static_cast<GLsizei>(c.height); |
| 9364 GLenum format = static_cast<GLenum>(c.format); |
| 9365 GLenum type = static_cast<GLenum>(c.type); |
| 9366 uint32 data_size; |
| 9367 if (!GLES2Util::ComputeImageDataSizes( |
| 9368 width, height, format, type, state_.unpack_alignment, &data_size, |
| 9369 NULL, NULL)) { |
| 9370 return error::kOutOfBounds; |
| 9371 } |
| 9372 const void* pixels = GetSharedMemoryAs<const void*>( |
| 9373 c.data_shm_id, c.data_shm_offset, data_size); |
| 9374 if (!validators_->texture_target.IsValid(target)) { |
| 9375 SetGLErrorInvalidEnum("glTexSubImage2D", target, "target"); |
| 9376 return error::kNoError; |
| 9377 } |
| 9378 if (width < 0) { |
| 9379 SetGLError(GL_INVALID_VALUE, "glTexSubImage2D", "width < 0"); |
| 9380 return error::kNoError; |
| 9381 } |
| 9382 if (height < 0) { |
| 9383 SetGLError(GL_INVALID_VALUE, "glTexSubImage2D", "height < 0"); |
| 9384 return error::kNoError; |
| 9385 } |
| 9386 if (!validators_->texture_format.IsValid(format)) { |
| 9387 SetGLErrorInvalidEnum("glTexSubImage2D", format, "format"); |
| 9388 return error::kNoError; |
| 9389 } |
| 9390 if (!validators_->pixel_type.IsValid(type)) { |
| 9391 SetGLErrorInvalidEnum("glTexSubImage2D", type, "type"); |
| 9392 return error::kNoError; |
| 9393 } |
| 9394 if (pixels == NULL) { |
| 9395 return error::kOutOfBounds; |
| 9396 } |
| 9397 |
| 9398 // TODO(epenner): Do this via an async task. |
| 9399 DoTexSubImage2D( |
| 9400 target, level, xoffset, yoffset, width, height, format, type, pixels); |
| 9401 return error::kNoError; |
| 9402 } |
| 9403 |
9314 // Include the auto-generated part of this file. We split this because it means | 9404 // Include the auto-generated part of this file. We split this because it means |
9315 // we can easily edit the non-auto generated parts right here in this file | 9405 // we can easily edit the non-auto generated parts right here in this file |
9316 // instead of having to edit some template or the code generator. | 9406 // instead of having to edit some template or the code generator. |
9317 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 9407 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
9318 | 9408 |
9319 } // namespace gles2 | 9409 } // namespace gles2 |
9320 } // namespace gpu | 9410 } // namespace gpu |
OLD | NEW |