Chromium Code Reviews| Index: gpu/command_buffer/client/gles2_implementation.cc |
| diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc |
| index 74e79efdcae08934069e5c31190a05b50005179e..1d4cd6f2bad1d30650d7062d4dcc0863f1731786 100644 |
| --- a/gpu/command_buffer/client/gles2_implementation.cc |
| +++ b/gpu/command_buffer/client/gles2_implementation.cc |
| @@ -816,23 +816,44 @@ void GLES2Implementation::DrawElements( |
| << count << ", " |
| << GLES2Util::GetStringIndexType(type) << ", " |
| << static_cast<const void*>(indices) << ")"); |
| - if (count < 0) { |
| - SetGLError(GL_INVALID_VALUE, "glDrawElements", "count less than 0."); |
| - return; |
| - } |
| - if (count == 0) { |
|
piman
2015/03/12 01:01:05
We're now inserting a command for the count==0 cas
|
| + DrawElementsImpl(mode, count, type, indices, "glDrawRangeElements"); |
| +} |
| + |
| +void GLES2Implementation::DrawRangeElements( |
| + GLenum mode, GLuint start, GLuint end, |
| + GLsizei count, GLenum type, const void* indices) { |
| + GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| + GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glDrawRangeElements(" |
| + << GLES2Util::GetStringDrawMode(mode) << ", " |
| + << start << ", " << end << ", " << count << ", " |
| + << GLES2Util::GetStringIndexType(type) << ", " |
| + << static_cast<const void*>(indices) << ")"); |
| + if (end < start) { |
| + SetGLError(GL_INVALID_VALUE, "glDrawRangeElements", "end < start"); |
| return; |
| } |
| - if (vertex_array_object_manager_->bound_element_array_buffer() != 0 && |
| - !ValidateOffset("glDrawElements", reinterpret_cast<GLintptr>(indices))) { |
| + DrawElementsImpl(mode, count, type, indices, "glDrawRangeElements"); |
| +} |
| + |
| +void GLES2Implementation::DrawElementsImpl( |
| + GLenum mode, GLsizei count, GLenum type, const void* indices, |
| + const char* func_name) { |
| + if (count < 0) { |
| + SetGLError(GL_INVALID_VALUE, func_name, "count < 0"); |
| return; |
| } |
| - GLuint offset = 0; |
| bool simulated = false; |
| - if (!vertex_array_object_manager_->SetupSimulatedIndexAndClientSideBuffers( |
| - "glDrawElements", this, helper_, count, type, 0, indices, |
| - &offset, &simulated)) { |
| - return; |
| + GLuint offset = ToGLuint(indices); |
| + if (count > 0) { |
| + if (vertex_array_object_manager_->bound_element_array_buffer() != 0 && |
| + !ValidateOffset(func_name, reinterpret_cast<GLintptr>(indices))) { |
| + return; |
| + } |
| + if (!vertex_array_object_manager_->SetupSimulatedIndexAndClientSideBuffers( |
| + func_name, this, helper_, count, type, 0, indices, |
| + &offset, &simulated)) { |
| + return; |
| + } |
| } |
| helper_->DrawElements(mode, count, type, offset); |
| RestoreElementAndArrayBuffers(simulated); |