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 5341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5352 if (info->enabled() && attrib_0_used) { | 5352 if (info->enabled() && attrib_0_used) { |
5353 return true; | 5353 return true; |
5354 } | 5354 } |
5355 | 5355 |
5356 // Make a buffer with a single repeated vec4 value enough to | 5356 // Make a buffer with a single repeated vec4 value enough to |
5357 // simulate the constant value that is supposed to be here. | 5357 // simulate the constant value that is supposed to be here. |
5358 // This is required to emulate GLES2 on GL. | 5358 // This is required to emulate GLES2 on GL. |
5359 typedef VertexAttribManager::VertexAttribInfo::Vec4 Vec4; | 5359 typedef VertexAttribManager::VertexAttribInfo::Vec4 Vec4; |
5360 | 5360 |
5361 GLuint num_vertices = max_vertex_accessed + 1; | 5361 GLuint num_vertices = max_vertex_accessed + 1; |
5362 GLuint size_needed = 0; | 5362 uint32 size_needed = 0; |
5363 | 5363 |
5364 if (num_vertices == 0 || | 5364 if (num_vertices == 0 || |
5365 !SafeMultiply(num_vertices, static_cast<GLuint>(sizeof(Vec4)), | 5365 !SafeMultiplyUint32(num_vertices, sizeof(Vec4), &size_needed) || |
5366 &size_needed) || | |
5367 size_needed > 0x7FFFFFFFU) { | 5366 size_needed > 0x7FFFFFFFU) { |
5368 SetGLError(GL_OUT_OF_MEMORY, function_name, "Simulating attrib 0"); | 5367 SetGLError(GL_OUT_OF_MEMORY, function_name, "Simulating attrib 0"); |
5369 return false; | 5368 return false; |
5370 } | 5369 } |
5371 | 5370 |
5372 PerformanceWarning( | 5371 PerformanceWarning( |
5373 "Attribute 0 is disabled. This has signficant performance penalty"); | 5372 "Attribute 0 is disabled. This has signficant performance penalty"); |
5374 | 5373 |
5375 CopyRealGLErrorsToWrapper(); | 5374 CopyRealGLErrorsToWrapper(); |
5376 glBindBuffer(GL_ARRAY_BUFFER, attrib_0_buffer_id_); | 5375 glBindBuffer(GL_ARRAY_BUFFER, attrib_0_buffer_id_); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5466 GLuint max_accessed = info->MaxVertexAccessed(primcount, | 5465 GLuint max_accessed = info->MaxVertexAccessed(primcount, |
5467 max_vertex_accessed); | 5466 max_vertex_accessed); |
5468 GLuint num_vertices = max_accessed + 1; | 5467 GLuint num_vertices = max_accessed + 1; |
5469 if (num_vertices == 0) { | 5468 if (num_vertices == 0) { |
5470 SetGLError(GL_OUT_OF_MEMORY, function_name, "Simulating attrib 0"); | 5469 SetGLError(GL_OUT_OF_MEMORY, function_name, "Simulating attrib 0"); |
5471 return false; | 5470 return false; |
5472 } | 5471 } |
5473 if (attrib_info && | 5472 if (attrib_info && |
5474 info->CanAccess(max_accessed) && | 5473 info->CanAccess(max_accessed) && |
5475 info->type() == GL_FIXED) { | 5474 info->type() == GL_FIXED) { |
5476 GLuint elements_used = 0; | 5475 uint32 elements_used = 0; |
5477 if (!SafeMultiply(num_vertices, | 5476 if (!SafeMultiplyUint32(num_vertices, info->size(), &elements_used) || |
5478 static_cast<GLuint>(info->size()), &elements_used) || | 5477 !SafeAddUint32(elements_needed, elements_used, &elements_needed)) { |
5479 !SafeAdd(elements_needed, elements_used, &elements_needed)) { | |
5480 SetGLError( | 5478 SetGLError( |
5481 GL_OUT_OF_MEMORY, function_name, "simulating GL_FIXED attribs"); | 5479 GL_OUT_OF_MEMORY, function_name, "simulating GL_FIXED attribs"); |
5482 return false; | 5480 return false; |
5483 } | 5481 } |
5484 } | 5482 } |
5485 } | 5483 } |
5486 | 5484 |
5487 const GLuint kSizeOfFloat = sizeof(float); // NOLINT | 5485 const uint32 kSizeOfFloat = sizeof(float); // NOLINT |
5488 GLuint size_needed = 0; | 5486 uint32 size_needed = 0; |
5489 if (!SafeMultiply(elements_needed, kSizeOfFloat, &size_needed) || | 5487 if (!SafeMultiplyUint32(elements_needed, kSizeOfFloat, &size_needed) || |
5490 size_needed > 0x7FFFFFFFU) { | 5488 size_needed > 0x7FFFFFFFU) { |
5491 SetGLError(GL_OUT_OF_MEMORY, function_name, "simulating GL_FIXED attribs"); | 5489 SetGLError(GL_OUT_OF_MEMORY, function_name, "simulating GL_FIXED attribs"); |
5492 return false; | 5490 return false; |
5493 } | 5491 } |
5494 | 5492 |
5495 CopyRealGLErrorsToWrapper(); | 5493 CopyRealGLErrorsToWrapper(); |
5496 | 5494 |
5497 glBindBuffer(GL_ARRAY_BUFFER, fixed_attrib_buffer_id_); | 5495 glBindBuffer(GL_ARRAY_BUFFER, fixed_attrib_buffer_id_); |
5498 if (static_cast<GLsizei>(size_needed) > fixed_attrib_buffer_size_) { | 5496 if (static_cast<GLsizei>(size_needed) > fixed_attrib_buffer_size_) { |
5499 glBufferData(GL_ARRAY_BUFFER, size_needed, NULL, GL_DYNAMIC_DRAW); | 5497 glBufferData(GL_ARRAY_BUFFER, size_needed, NULL, GL_DYNAMIC_DRAW); |
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6399 SetGLError(GL_INVALID_ENUM, "glReadPixels", "type GL_INVALID_ENUM"); | 6397 SetGLError(GL_INVALID_ENUM, "glReadPixels", "type GL_INVALID_ENUM"); |
6400 return error::kNoError; | 6398 return error::kNoError; |
6401 } | 6399 } |
6402 if (width == 0 || height == 0) { | 6400 if (width == 0 || height == 0) { |
6403 return error::kNoError; | 6401 return error::kNoError; |
6404 } | 6402 } |
6405 | 6403 |
6406 // Get the size of the current fbo or backbuffer. | 6404 // Get the size of the current fbo or backbuffer. |
6407 gfx::Size max_size = GetBoundReadFrameBufferSize(); | 6405 gfx::Size max_size = GetBoundReadFrameBufferSize(); |
6408 | 6406 |
6409 GLint max_x; | 6407 int32 max_x; |
6410 GLint max_y; | 6408 int32 max_y; |
6411 if (!SafeAdd(x, width, &max_x) || !SafeAdd(y, height, &max_y)) { | 6409 if (!SafeAddInt32(x, width, &max_x) || !SafeAddInt32(y, height, &max_y)) { |
6412 SetGLError(GL_INVALID_VALUE, "glReadPixels", "dimensions out of range"); | 6410 SetGLError(GL_INVALID_VALUE, "glReadPixels", "dimensions out of range"); |
6413 return error::kNoError; | 6411 return error::kNoError; |
6414 } | 6412 } |
6415 | 6413 |
6416 if (!CheckBoundFramebuffersValid("glReadPixels")) { | 6414 if (!CheckBoundFramebuffersValid("glReadPixels")) { |
6417 return error::kNoError; | 6415 return error::kNoError; |
6418 } | 6416 } |
6419 | 6417 |
6420 CopyRealGLErrorsToWrapper(); | 6418 CopyRealGLErrorsToWrapper(); |
6421 | 6419 |
(...skipping 2030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8452 uint32 num_results = 0; | 8450 uint32 num_results = 0; |
8453 for (GLuint ii = 0; ii < count; ++ii) { | 8451 for (GLuint ii = 0; ii < count; ++ii) { |
8454 uint32 num = util_.GLGetNumValuesReturned(enums[ii]); | 8452 uint32 num = util_.GLGetNumValuesReturned(enums[ii]); |
8455 if (num == 0) { | 8453 if (num == 0) { |
8456 SetGLError(GL_INVALID_ENUM, | 8454 SetGLError(GL_INVALID_ENUM, |
8457 "glGetMulitpleCHROMIUM", "pname GL_INVALID_ENUM"); | 8455 "glGetMulitpleCHROMIUM", "pname GL_INVALID_ENUM"); |
8458 return error::kNoError; | 8456 return error::kNoError; |
8459 } | 8457 } |
8460 // Num will never be more than 4. | 8458 // Num will never be more than 4. |
8461 DCHECK_LE(num, 4u); | 8459 DCHECK_LE(num, 4u); |
8462 if (!SafeAdd(num_results, num, &num_results)) { | 8460 if (!SafeAddUint32(num_results, num, &num_results)) { |
8463 return error::kOutOfBounds; | 8461 return error::kOutOfBounds; |
8464 } | 8462 } |
8465 } | 8463 } |
8466 | 8464 |
8467 uint32 result_size = 0; | 8465 uint32 result_size = 0; |
8468 if (!SafeMultiplyUint32(num_results, sizeof(GLint), &result_size)) { | 8466 if (!SafeMultiplyUint32(num_results, sizeof(GLint), &result_size)) { |
8469 return error::kOutOfBounds; | 8467 return error::kOutOfBounds; |
8470 } | 8468 } |
8471 | 8469 |
8472 if (result_size != static_cast<uint32>(c.size)) { | 8470 if (result_size != static_cast<uint32>(c.size)) { |
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9194 BindAndApplyTextureParameters(info); | 9192 BindAndApplyTextureParameters(info); |
9195 } | 9193 } |
9196 | 9194 |
9197 // Include the auto-generated part of this file. We split this because it means | 9195 // Include the auto-generated part of this file. We split this because it means |
9198 // we can easily edit the non-auto generated parts right here in this file | 9196 // we can easily edit the non-auto generated parts right here in this file |
9199 // instead of having to edit some template or the code generator. | 9197 // instead of having to edit some template or the code generator. |
9200 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 9198 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
9201 | 9199 |
9202 } // namespace gles2 | 9200 } // namespace gles2 |
9203 } // namespace gpu | 9201 } // namespace gpu |
OLD | NEW |