Chromium Code Reviews| 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 "gpu/command_buffer/client/gles2_implementation.h" | 7 #include "gpu/command_buffer/client/gles2_implementation.h" |
| 8 | 8 |
| 9 #include <GLES2/gl2ext.h> | 9 #include <GLES2/gl2ext.h> |
| 10 #include <GLES2/gl2extchromium.h> | 10 #include <GLES2/gl2extchromium.h> |
| (...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 809 } | 809 } |
| 810 | 810 |
| 811 void GLES2Implementation::DrawElements( | 811 void GLES2Implementation::DrawElements( |
| 812 GLenum mode, GLsizei count, GLenum type, const void* indices) { | 812 GLenum mode, GLsizei count, GLenum type, const void* indices) { |
| 813 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 813 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 814 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glDrawElements(" | 814 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glDrawElements(" |
| 815 << GLES2Util::GetStringDrawMode(mode) << ", " | 815 << GLES2Util::GetStringDrawMode(mode) << ", " |
| 816 << count << ", " | 816 << count << ", " |
| 817 << GLES2Util::GetStringIndexType(type) << ", " | 817 << GLES2Util::GetStringIndexType(type) << ", " |
| 818 << static_cast<const void*>(indices) << ")"); | 818 << static_cast<const void*>(indices) << ")"); |
| 819 if (count < 0) { | 819 DrawElementsImpl(mode, count, type, indices, "glDrawRangeElements"); |
| 820 SetGLError(GL_INVALID_VALUE, "glDrawElements", "count less than 0."); | 820 } |
| 821 | |
| 822 void GLES2Implementation::DrawRangeElements( | |
| 823 GLenum mode, GLuint start, GLuint end, | |
| 824 GLsizei count, GLenum type, const void* indices) { | |
| 825 GPU_CLIENT_SINGLE_THREAD_CHECK(); | |
| 826 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glDrawRangeElements(" | |
| 827 << GLES2Util::GetStringDrawMode(mode) << ", " | |
| 828 << start << ", " << end << ", " << count << ", " | |
| 829 << GLES2Util::GetStringIndexType(type) << ", " | |
| 830 << static_cast<const void*>(indices) << ")"); | |
| 831 if (end < start) { | |
| 832 SetGLError(GL_INVALID_VALUE, "glDrawRangeElements", "end < start"); | |
| 821 return; | 833 return; |
| 822 } | 834 } |
| 823 if (count == 0) { | 835 DrawElementsImpl(mode, count, type, indices, "glDrawRangeElements"); |
|
piman
2015/03/12 01:01:05
We're now inserting a command for the count==0 cas
| |
| 836 } | |
| 837 | |
| 838 void GLES2Implementation::DrawElementsImpl( | |
| 839 GLenum mode, GLsizei count, GLenum type, const void* indices, | |
| 840 const char* func_name) { | |
| 841 if (count < 0) { | |
| 842 SetGLError(GL_INVALID_VALUE, func_name, "count < 0"); | |
| 824 return; | 843 return; |
| 825 } | 844 } |
| 826 if (vertex_array_object_manager_->bound_element_array_buffer() != 0 && | |
| 827 !ValidateOffset("glDrawElements", reinterpret_cast<GLintptr>(indices))) { | |
| 828 return; | |
| 829 } | |
| 830 GLuint offset = 0; | |
| 831 bool simulated = false; | 845 bool simulated = false; |
| 832 if (!vertex_array_object_manager_->SetupSimulatedIndexAndClientSideBuffers( | 846 GLuint offset = ToGLuint(indices); |
| 833 "glDrawElements", this, helper_, count, type, 0, indices, | 847 if (count > 0) { |
| 834 &offset, &simulated)) { | 848 if (vertex_array_object_manager_->bound_element_array_buffer() != 0 && |
| 835 return; | 849 !ValidateOffset(func_name, reinterpret_cast<GLintptr>(indices))) { |
| 850 return; | |
| 851 } | |
| 852 if (!vertex_array_object_manager_->SetupSimulatedIndexAndClientSideBuffers( | |
| 853 func_name, this, helper_, count, type, 0, indices, | |
| 854 &offset, &simulated)) { | |
| 855 return; | |
| 856 } | |
| 836 } | 857 } |
| 837 helper_->DrawElements(mode, count, type, offset); | 858 helper_->DrawElements(mode, count, type, offset); |
| 838 RestoreElementAndArrayBuffers(simulated); | 859 RestoreElementAndArrayBuffers(simulated); |
| 839 CheckGLError(); | 860 CheckGLError(); |
| 840 } | 861 } |
| 841 | 862 |
| 842 void GLES2Implementation::Flush() { | 863 void GLES2Implementation::Flush() { |
| 843 GPU_CLIENT_SINGLE_THREAD_CHECK(); | 864 GPU_CLIENT_SINGLE_THREAD_CHECK(); |
| 844 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glFlush()"); | 865 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glFlush()"); |
| 845 // Insert the cmd to call glFlush | 866 // Insert the cmd to call glFlush |
| (...skipping 4221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5067 CheckGLError(); | 5088 CheckGLError(); |
| 5068 } | 5089 } |
| 5069 | 5090 |
| 5070 // Include the auto-generated part of this file. We split this because it means | 5091 // Include the auto-generated part of this file. We split this because it means |
| 5071 // we can easily edit the non-auto generated parts right here in this file | 5092 // we can easily edit the non-auto generated parts right here in this file |
| 5072 // instead of having to edit some template or the code generator. | 5093 // instead of having to edit some template or the code generator. |
| 5073 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" | 5094 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" |
| 5074 | 5095 |
| 5075 } // namespace gles2 | 5096 } // namespace gles2 |
| 5076 } // namespace gpu | 5097 } // namespace gpu |
| OLD | NEW |