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"); |
| 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 4260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5106 CheckGLError(); | 5127 CheckGLError(); |
5107 } | 5128 } |
5108 | 5129 |
5109 // Include the auto-generated part of this file. We split this because it means | 5130 // Include the auto-generated part of this file. We split this because it means |
5110 // we can easily edit the non-auto generated parts right here in this file | 5131 // we can easily edit the non-auto generated parts right here in this file |
5111 // instead of having to edit some template or the code generator. | 5132 // instead of having to edit some template or the code generator. |
5112 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" | 5133 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" |
5113 | 5134 |
5114 } // namespace gles2 | 5135 } // namespace gles2 |
5115 } // namespace gpu | 5136 } // namespace gpu |
OLD | NEW |