| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1032 | 1032 |
| 1033 // Validates the program and location for a glGetUniform call and returns | 1033 // Validates the program and location for a glGetUniform call and returns |
| 1034 // a SizeResult setup to receive the result. Returns true if glGetUniform | 1034 // a SizeResult setup to receive the result. Returns true if glGetUniform |
| 1035 // should be called. | 1035 // should be called. |
| 1036 bool GetUniformSetup( | 1036 bool GetUniformSetup( |
| 1037 GLuint program, GLint location, | 1037 GLuint program, GLint location, |
| 1038 uint32 shm_id, uint32 shm_offset, | 1038 uint32 shm_id, uint32 shm_offset, |
| 1039 error::Error* error, GLuint* service_id, void** result, | 1039 error::Error* error, GLuint* service_id, void** result, |
| 1040 GLenum* result_type); | 1040 GLenum* result_type); |
| 1041 | 1041 |
| 1042 bool ValidateGLenumCompressedTextureInternalFormat(GLenum format); | |
| 1043 | |
| 1044 // Generate a member function prototype for each command in an automated and | 1042 // Generate a member function prototype for each command in an automated and |
| 1045 // typesafe way. | 1043 // typesafe way. |
| 1046 #define GLES2_CMD_OP(name) \ | 1044 #define GLES2_CMD_OP(name) \ |
| 1047 Error Handle ## name( \ | 1045 Error Handle ## name( \ |
| 1048 uint32 immediate_data_size, \ | 1046 uint32 immediate_data_size, \ |
| 1049 const gles2::name& args); \ | 1047 const gles2::name& args); \ |
| 1050 | 1048 |
| 1051 GLES2_COMMAND_LIST(GLES2_CMD_OP) | 1049 GLES2_COMMAND_LIST(GLES2_CMD_OP) |
| 1052 | 1050 |
| 1053 #undef GLES2_CMD_OP | 1051 #undef GLES2_CMD_OP |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1139 // The copy that is saved when SwapBuffers is called. | 1137 // The copy that is saved when SwapBuffers is called. |
| 1140 scoped_ptr<Texture> offscreen_saved_color_texture_; | 1138 scoped_ptr<Texture> offscreen_saved_color_texture_; |
| 1141 | 1139 |
| 1142 scoped_ptr<Callback0::Type> swap_buffers_callback_; | 1140 scoped_ptr<Callback0::Type> swap_buffers_callback_; |
| 1143 | 1141 |
| 1144 // The last error message set. | 1142 // The last error message set. |
| 1145 std::string last_error_; | 1143 std::string last_error_; |
| 1146 | 1144 |
| 1147 bool use_shader_translator_; | 1145 bool use_shader_translator_; |
| 1148 | 1146 |
| 1147 // Cached from the context group. |
| 1148 const Validators* validators_; |
| 1149 |
| 1149 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); | 1150 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); |
| 1150 }; | 1151 }; |
| 1151 | 1152 |
| 1152 ScopedGLErrorSuppressor::ScopedGLErrorSuppressor(GLES2DecoderImpl* decoder) | 1153 ScopedGLErrorSuppressor::ScopedGLErrorSuppressor(GLES2DecoderImpl* decoder) |
| 1153 : decoder_(decoder) { | 1154 : decoder_(decoder) { |
| 1154 decoder_->CopyRealGLErrorsToWrapper(); | 1155 decoder_->CopyRealGLErrorsToWrapper(); |
| 1155 } | 1156 } |
| 1156 | 1157 |
| 1157 ScopedGLErrorSuppressor::~ScopedGLErrorSuppressor() { | 1158 ScopedGLErrorSuppressor::~ScopedGLErrorSuppressor() { |
| 1158 decoder_->ClearRealGLErrors(); | 1159 decoder_->ClearRealGLErrors(); |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1400 error_bits_(0), | 1401 error_bits_(0), |
| 1401 util_(0), // TODO(gman): Set to actual num compress texture formats. | 1402 util_(0), // TODO(gman): Set to actual num compress texture formats. |
| 1402 pack_alignment_(4), | 1403 pack_alignment_(4), |
| 1403 unpack_alignment_(4), | 1404 unpack_alignment_(4), |
| 1404 attrib_0_buffer_id_(0), | 1405 attrib_0_buffer_id_(0), |
| 1405 attrib_0_size_(0), | 1406 attrib_0_size_(0), |
| 1406 active_texture_unit_(0), | 1407 active_texture_unit_(0), |
| 1407 black_2d_texture_id_(0), | 1408 black_2d_texture_id_(0), |
| 1408 black_cube_texture_id_(0), | 1409 black_cube_texture_id_(0), |
| 1409 anti_aliased_(false), | 1410 anti_aliased_(false), |
| 1410 use_shader_translator_(true) { | 1411 use_shader_translator_(true), |
| 1412 validators_(group->validators()) { |
| 1411 attrib_0_value_.v[0] = 0.0f; | 1413 attrib_0_value_.v[0] = 0.0f; |
| 1412 attrib_0_value_.v[1] = 0.0f; | 1414 attrib_0_value_.v[1] = 0.0f; |
| 1413 attrib_0_value_.v[2] = 0.0f; | 1415 attrib_0_value_.v[2] = 0.0f; |
| 1414 attrib_0_value_.v[3] = 1.0f; | 1416 attrib_0_value_.v[3] = 1.0f; |
| 1415 | 1417 |
| 1416 // The shader translator is not needed for EGL because it already uses the | 1418 // The shader translator is not needed for EGL because it already uses the |
| 1417 // GLSL ES syntax. It is translated for the unit tests because | 1419 // GLSL ES syntax. It is translated for the unit tests because |
| 1418 // GLES2DecoderWithShaderTest.GetShaderInfoLogValidArgs passes the empty | 1420 // GLES2DecoderWithShaderTest.GetShaderInfoLogValidArgs passes the empty |
| 1419 // string to CompileShader and this is not a valid shader. TODO(apatrick): | 1421 // string to CompileShader and this is not a valid shader. TODO(apatrick): |
| 1420 // fix this test. | 1422 // fix this test. |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2021 if (GetShaderInfo(client_id)) { | 2023 if (GetShaderInfo(client_id)) { |
| 2022 return false; | 2024 return false; |
| 2023 } | 2025 } |
| 2024 GLuint service_id = glCreateShader(type); | 2026 GLuint service_id = glCreateShader(type); |
| 2025 if (service_id != 0) { | 2027 if (service_id != 0) { |
| 2026 CreateShaderInfo(client_id, service_id, type); | 2028 CreateShaderInfo(client_id, service_id, type); |
| 2027 } | 2029 } |
| 2028 return true; | 2030 return true; |
| 2029 } | 2031 } |
| 2030 | 2032 |
| 2031 bool GLES2DecoderImpl::ValidateGLenumCompressedTextureInternalFormat(GLenum) { | |
| 2032 // TODO(gman): Add support for compressed texture formats. | |
| 2033 return false; | |
| 2034 } | |
| 2035 | |
| 2036 void GLES2DecoderImpl::DoActiveTexture(GLenum texture_unit) { | 2033 void GLES2DecoderImpl::DoActiveTexture(GLenum texture_unit) { |
| 2037 GLuint texture_index = texture_unit - GL_TEXTURE0; | 2034 GLuint texture_index = texture_unit - GL_TEXTURE0; |
| 2038 if (texture_index > group_->max_texture_units()) { | 2035 if (texture_index > group_->max_texture_units()) { |
| 2039 SetGLError(GL_INVALID_ENUM, "glActiveTexture: texture_unit out of range."); | 2036 SetGLError(GL_INVALID_ENUM, "glActiveTexture: texture_unit out of range."); |
| 2040 return; | 2037 return; |
| 2041 } | 2038 } |
| 2042 active_texture_unit_ = texture_index; | 2039 active_texture_unit_ = texture_index; |
| 2043 glActiveTexture(texture_unit); | 2040 glActiveTexture(texture_unit); |
| 2044 } | 2041 } |
| 2045 | 2042 |
| (...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3148 GLenum type = c.type; | 3145 GLenum type = c.type; |
| 3149 int32 offset = c.index_offset; | 3146 int32 offset = c.index_offset; |
| 3150 if (count < 0) { | 3147 if (count < 0) { |
| 3151 SetGLError(GL_INVALID_VALUE, "glDrawElements: count < 0"); | 3148 SetGLError(GL_INVALID_VALUE, "glDrawElements: count < 0"); |
| 3152 return error::kNoError; | 3149 return error::kNoError; |
| 3153 } | 3150 } |
| 3154 if (offset < 0) { | 3151 if (offset < 0) { |
| 3155 SetGLError(GL_INVALID_VALUE, "glDrawElements: offset < 0"); | 3152 SetGLError(GL_INVALID_VALUE, "glDrawElements: offset < 0"); |
| 3156 return error::kNoError; | 3153 return error::kNoError; |
| 3157 } | 3154 } |
| 3158 if (!ValidateGLenumDrawMode(mode)) { | 3155 if (!validators_->draw_mode.IsValid(mode)) { |
| 3159 SetGLError(GL_INVALID_ENUM, "glDrawElements: mode GL_INVALID_ENUM"); | 3156 SetGLError(GL_INVALID_ENUM, "glDrawElements: mode GL_INVALID_ENUM"); |
| 3160 return error::kNoError; | 3157 return error::kNoError; |
| 3161 } | 3158 } |
| 3162 if (!ValidateGLenumIndexType(type)) { | 3159 if (!validators_->index_type.IsValid(type)) { |
| 3163 SetGLError(GL_INVALID_ENUM, "glDrawElements: type GL_INVALID_ENUM"); | 3160 SetGLError(GL_INVALID_ENUM, "glDrawElements: type GL_INVALID_ENUM"); |
| 3164 return error::kNoError; | 3161 return error::kNoError; |
| 3165 } | 3162 } |
| 3166 | 3163 |
| 3167 GLuint max_vertex_accessed; | 3164 GLuint max_vertex_accessed; |
| 3168 if (!bound_element_array_buffer_->GetMaxValueForRange( | 3165 if (!bound_element_array_buffer_->GetMaxValueForRange( |
| 3169 offset, count, type, &max_vertex_accessed)) { | 3166 offset, count, type, &max_vertex_accessed)) { |
| 3170 SetGLError(GL_INVALID_OPERATION, | 3167 SetGLError(GL_INVALID_OPERATION, |
| 3171 "glDrawElements: range out of bounds for buffer"); | 3168 "glDrawElements: range out of bounds for buffer"); |
| 3172 return error::kNoError; | 3169 return error::kNoError; |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3678 return error::kNoError; | 3675 return error::kNoError; |
| 3679 } | 3676 } |
| 3680 | 3677 |
| 3681 GLuint indx = c.indx; | 3678 GLuint indx = c.indx; |
| 3682 GLint size = c.size; | 3679 GLint size = c.size; |
| 3683 GLenum type = c.type; | 3680 GLenum type = c.type; |
| 3684 GLboolean normalized = c.normalized; | 3681 GLboolean normalized = c.normalized; |
| 3685 GLsizei stride = c.stride; | 3682 GLsizei stride = c.stride; |
| 3686 GLsizei offset = c.offset; | 3683 GLsizei offset = c.offset; |
| 3687 const void* ptr = reinterpret_cast<const void*>(offset); | 3684 const void* ptr = reinterpret_cast<const void*>(offset); |
| 3688 if (!ValidateGLenumVertexAttribType(type)) { | 3685 if (!validators_->vertex_attrib_type.IsValid(type)) { |
| 3689 SetGLError(GL_INVALID_ENUM, | 3686 SetGLError(GL_INVALID_ENUM, |
| 3690 "glVertexAttribPointer: type GL_INVALID_ENUM"); | 3687 "glVertexAttribPointer: type GL_INVALID_ENUM"); |
| 3691 return error::kNoError; | 3688 return error::kNoError; |
| 3692 } | 3689 } |
| 3693 if (!ValidateGLintVertexAttribSize(size)) { | 3690 if (!validators_->vertex_attrib_size.IsValid(size)) { |
| 3694 SetGLError(GL_INVALID_ENUM, | 3691 SetGLError(GL_INVALID_ENUM, |
| 3695 "glVertexAttribPointer: size GL_INVALID_VALUE"); | 3692 "glVertexAttribPointer: size GL_INVALID_VALUE"); |
| 3696 return error::kNoError; | 3693 return error::kNoError; |
| 3697 } | 3694 } |
| 3698 if (indx >= group_->max_vertex_attribs()) { | 3695 if (indx >= group_->max_vertex_attribs()) { |
| 3699 SetGLError(GL_INVALID_VALUE, "glVertexAttribPointer: index out of range"); | 3696 SetGLError(GL_INVALID_VALUE, "glVertexAttribPointer: index out of range"); |
| 3700 return error::kNoError; | 3697 return error::kNoError; |
| 3701 } | 3698 } |
| 3702 if (stride < 0) { | 3699 if (stride < 0) { |
| 3703 SetGLError(GL_INVALID_VALUE, | 3700 SetGLError(GL_INVALID_VALUE, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3752 return error::kOutOfBounds; | 3749 return error::kOutOfBounds; |
| 3753 } | 3750 } |
| 3754 void* pixels = GetSharedMemoryAs<void*>( | 3751 void* pixels = GetSharedMemoryAs<void*>( |
| 3755 c.pixels_shm_id, c.pixels_shm_offset, pixels_size); | 3752 c.pixels_shm_id, c.pixels_shm_offset, pixels_size); |
| 3756 Result* result = GetSharedMemoryAs<Result*>( | 3753 Result* result = GetSharedMemoryAs<Result*>( |
| 3757 c.result_shm_id, c.result_shm_offset, sizeof(*result)); | 3754 c.result_shm_id, c.result_shm_offset, sizeof(*result)); |
| 3758 if (!pixels || !result) { | 3755 if (!pixels || !result) { |
| 3759 return error::kOutOfBounds; | 3756 return error::kOutOfBounds; |
| 3760 } | 3757 } |
| 3761 | 3758 |
| 3762 if (!ValidateGLenumReadPixelFormat(format)) { | 3759 if (!validators_->read_pixel_format.IsValid(format)) { |
| 3763 SetGLError(GL_INVALID_ENUM, "glReadPixels: format GL_INVALID_ENUM"); | 3760 SetGLError(GL_INVALID_ENUM, "glReadPixels: format GL_INVALID_ENUM"); |
| 3764 return error::kNoError; | 3761 return error::kNoError; |
| 3765 } | 3762 } |
| 3766 if (!ValidateGLenumPixelType(type)) { | 3763 if (!validators_->pixel_type.IsValid(type)) { |
| 3767 SetGLError(GL_INVALID_ENUM, "glReadPixels: type GL_INVALID_ENUM"); | 3764 SetGLError(GL_INVALID_ENUM, "glReadPixels: type GL_INVALID_ENUM"); |
| 3768 return error::kNoError; | 3765 return error::kNoError; |
| 3769 } | 3766 } |
| 3770 if (width == 0 || height == 0) { | 3767 if (width == 0 || height == 0) { |
| 3771 return error::kNoError; | 3768 return error::kNoError; |
| 3772 } | 3769 } |
| 3773 | 3770 |
| 3774 CopyRealGLErrorsToWrapper(); | 3771 CopyRealGLErrorsToWrapper(); |
| 3775 | 3772 |
| 3776 // Get the size of the current fbo or backbuffer. | 3773 // Get the size of the current fbo or backbuffer. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3839 } else { | 3836 } else { |
| 3840 SetGLError(error, NULL); | 3837 SetGLError(error, NULL); |
| 3841 } | 3838 } |
| 3842 return error::kNoError; | 3839 return error::kNoError; |
| 3843 } | 3840 } |
| 3844 | 3841 |
| 3845 error::Error GLES2DecoderImpl::HandlePixelStorei( | 3842 error::Error GLES2DecoderImpl::HandlePixelStorei( |
| 3846 uint32 immediate_data_size, const gles2::PixelStorei& c) { | 3843 uint32 immediate_data_size, const gles2::PixelStorei& c) { |
| 3847 GLenum pname = c.pname; | 3844 GLenum pname = c.pname; |
| 3848 GLenum param = c.param; | 3845 GLenum param = c.param; |
| 3849 if (!ValidateGLenumPixelStore(pname)) { | 3846 if (!validators_->pixel_store.IsValid(pname)) { |
| 3850 SetGLError(GL_INVALID_ENUM, "glPixelStorei: pname GL_INVALID_ENUM"); | 3847 SetGLError(GL_INVALID_ENUM, "glPixelStorei: pname GL_INVALID_ENUM"); |
| 3851 return error::kNoError; | 3848 return error::kNoError; |
| 3852 } | 3849 } |
| 3853 if (!ValidateGLintPixelStoreAlignment(param)) { | 3850 if (!validators_->pixel_store_alignment.IsValid(param)) { |
| 3854 SetGLError(GL_INVALID_VALUE, "glPixelSTore: param GL_INVALID_VALUE"); | 3851 SetGLError(GL_INVALID_VALUE, "glPixelSTore: param GL_INVALID_VALUE"); |
| 3855 return error::kNoError; | 3852 return error::kNoError; |
| 3856 } | 3853 } |
| 3857 glPixelStorei(pname, param); | 3854 glPixelStorei(pname, param); |
| 3858 switch (pname) { | 3855 switch (pname) { |
| 3859 case GL_PACK_ALIGNMENT: | 3856 case GL_PACK_ALIGNMENT: |
| 3860 pack_alignment_ = param; | 3857 pack_alignment_ = param; |
| 3861 break; | 3858 break; |
| 3862 case GL_UNPACK_ALIGNMENT: | 3859 case GL_UNPACK_ALIGNMENT: |
| 3863 unpack_alignment_ = param; | 3860 unpack_alignment_ = param; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3999 if (!bucket->GetAsString(&name_str)) { | 3996 if (!bucket->GetAsString(&name_str)) { |
| 4000 return error::kInvalidArguments; | 3997 return error::kInvalidArguments; |
| 4001 } | 3998 } |
| 4002 return GetUniformLocationHelper( | 3999 return GetUniformLocationHelper( |
| 4003 c.program, c.location_shm_id, c.location_shm_offset, name_str); | 4000 c.program, c.location_shm_id, c.location_shm_offset, name_str); |
| 4004 } | 4001 } |
| 4005 | 4002 |
| 4006 error::Error GLES2DecoderImpl::HandleGetString( | 4003 error::Error GLES2DecoderImpl::HandleGetString( |
| 4007 uint32 immediate_data_size, const gles2::GetString& c) { | 4004 uint32 immediate_data_size, const gles2::GetString& c) { |
| 4008 GLenum name = static_cast<GLenum>(c.name); | 4005 GLenum name = static_cast<GLenum>(c.name); |
| 4009 if (!ValidateGLenumStringType(name)) { | 4006 if (!validators_->string_type.IsValid(name)) { |
| 4010 SetGLError(GL_INVALID_ENUM, "glGetString: name GL_INVALID_ENUM"); | 4007 SetGLError(GL_INVALID_ENUM, "glGetString: name GL_INVALID_ENUM"); |
| 4011 return error::kNoError; | 4008 return error::kNoError; |
| 4012 } | 4009 } |
| 4013 const char* gl_str = reinterpret_cast<const char*>(glGetString(name)); | 4010 const char* gl_str = reinterpret_cast<const char*>(glGetString(name)); |
| 4014 const char* str = NULL; | 4011 const char* str = NULL; |
| 4015 switch (name) { | 4012 switch (name) { |
| 4016 case GL_VERSION: | 4013 case GL_VERSION: |
| 4017 str = "OpenGL ES 2.0 Chromium"; | 4014 str = "OpenGL ES 2.0 Chromium"; |
| 4018 break; | 4015 break; |
| 4019 case GL_SHADING_LANGUAGE_VERSION: | 4016 case GL_SHADING_LANGUAGE_VERSION: |
| 4020 str = "OpenGL ES GLSL ES 1.0 Chromium"; | 4017 str = "OpenGL ES GLSL ES 1.0 Chromium"; |
| 4021 break; | 4018 break; |
| 4022 case GL_EXTENSIONS: | 4019 case GL_EXTENSIONS: |
| 4023 str = ""; | 4020 str = ""; |
| 4024 break; | 4021 break; |
| 4025 default: | 4022 default: |
| 4026 str = gl_str; | 4023 str = gl_str; |
| 4027 break; | 4024 break; |
| 4028 } | 4025 } |
| 4029 Bucket* bucket = CreateBucket(c.bucket_id); | 4026 Bucket* bucket = CreateBucket(c.bucket_id); |
| 4030 bucket->SetFromString(str); | 4027 bucket->SetFromString(str); |
| 4031 return error::kNoError; | 4028 return error::kNoError; |
| 4032 } | 4029 } |
| 4033 | 4030 |
| 4034 void GLES2DecoderImpl::DoBufferData( | 4031 void GLES2DecoderImpl::DoBufferData( |
| 4035 GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage) { | 4032 GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage) { |
| 4036 if (!ValidateGLenumBufferTarget(target)) { | 4033 if (!validators_->buffer_target.IsValid(target)) { |
| 4037 SetGLError(GL_INVALID_ENUM, "glBufferData: target GL_INVALID_ENUM"); | 4034 SetGLError(GL_INVALID_ENUM, "glBufferData: target GL_INVALID_ENUM"); |
| 4038 return; | 4035 return; |
| 4039 } | 4036 } |
| 4040 if (!ValidateGLenumBufferUsage(usage)) { | 4037 if (!validators_->buffer_usage.IsValid(usage)) { |
| 4041 SetGLError(GL_INVALID_ENUM, "glBufferData: usage GL_INVALID_ENUM"); | 4038 SetGLError(GL_INVALID_ENUM, "glBufferData: usage GL_INVALID_ENUM"); |
| 4042 return; | 4039 return; |
| 4043 } | 4040 } |
| 4044 if (size < 0) { | 4041 if (size < 0) { |
| 4045 SetGLError(GL_INVALID_VALUE, "glBufferData: size < 0"); | 4042 SetGLError(GL_INVALID_VALUE, "glBufferData: size < 0"); |
| 4046 return; | 4043 return; |
| 4047 } | 4044 } |
| 4048 BufferManager::BufferInfo* info = GetBufferInfoForTarget(target); | 4045 BufferManager::BufferInfo* info = GetBufferInfoForTarget(target); |
| 4049 if (!info) { | 4046 if (!info) { |
| 4050 SetGLError(GL_INVALID_VALUE, "glBufferData: unknown buffer"); | 4047 SetGLError(GL_INVALID_VALUE, "glBufferData: unknown buffer"); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4117 error::Error GLES2DecoderImpl::DoCompressedTexImage2D( | 4114 error::Error GLES2DecoderImpl::DoCompressedTexImage2D( |
| 4118 GLenum target, | 4115 GLenum target, |
| 4119 GLint level, | 4116 GLint level, |
| 4120 GLenum internal_format, | 4117 GLenum internal_format, |
| 4121 GLsizei width, | 4118 GLsizei width, |
| 4122 GLsizei height, | 4119 GLsizei height, |
| 4123 GLint border, | 4120 GLint border, |
| 4124 GLsizei image_size, | 4121 GLsizei image_size, |
| 4125 const void* data) { | 4122 const void* data) { |
| 4126 // TODO(gman): Validate image_size is correct for width, height and format. | 4123 // TODO(gman): Validate image_size is correct for width, height and format. |
| 4127 if (!ValidateGLenumTextureTarget(target)) { | 4124 if (!validators_->texture_target.IsValid(target)) { |
| 4128 SetGLError(GL_INVALID_ENUM, | 4125 SetGLError(GL_INVALID_ENUM, |
| 4129 "glCompressedTexImage2D: target GL_INVALID_ENUM"); | 4126 "glCompressedTexImage2D: target GL_INVALID_ENUM"); |
| 4130 return error::kNoError; | 4127 return error::kNoError; |
| 4131 } | 4128 } |
| 4132 if (!ValidateGLenumCompressedTextureInternalFormat(internal_format)) { | 4129 if (!validators_->compressed_texture_format.IsValid( |
| 4130 internal_format)) { |
| 4133 SetGLError(GL_INVALID_ENUM, | 4131 SetGLError(GL_INVALID_ENUM, |
| 4134 "glCompressedTexImage2D: internal_format GL_INVALID_ENUM"); | 4132 "glCompressedTexImage2D: internal_format GL_INVALID_ENUM"); |
| 4135 return error::kNoError; | 4133 return error::kNoError; |
| 4136 } | 4134 } |
| 4137 if (!texture_manager()->ValidForTarget(target, level, width, height, 1) || | 4135 if (!texture_manager()->ValidForTarget(target, level, width, height, 1) || |
| 4138 border != 0) { | 4136 border != 0) { |
| 4139 SetGLError(GL_INVALID_VALUE, | 4137 SetGLError(GL_INVALID_VALUE, |
| 4140 "glCompressedTexImage2D: dimensions out of range"); | 4138 "glCompressedTexImage2D: dimensions out of range"); |
| 4141 return error::kNoError; | 4139 return error::kNoError; |
| 4142 } | 4140 } |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4221 GLint level = static_cast<GLint>(c.level); | 4219 GLint level = static_cast<GLint>(c.level); |
| 4222 GLint xoffset = static_cast<GLint>(c.xoffset); | 4220 GLint xoffset = static_cast<GLint>(c.xoffset); |
| 4223 GLint yoffset = static_cast<GLint>(c.yoffset); | 4221 GLint yoffset = static_cast<GLint>(c.yoffset); |
| 4224 GLsizei width = static_cast<GLsizei>(c.width); | 4222 GLsizei width = static_cast<GLsizei>(c.width); |
| 4225 GLsizei height = static_cast<GLsizei>(c.height); | 4223 GLsizei height = static_cast<GLsizei>(c.height); |
| 4226 GLenum format = static_cast<GLenum>(c.format); | 4224 GLenum format = static_cast<GLenum>(c.format); |
| 4227 Bucket* bucket = GetBucket(c.bucket_id); | 4225 Bucket* bucket = GetBucket(c.bucket_id); |
| 4228 uint32 data_size = bucket->size(); | 4226 uint32 data_size = bucket->size(); |
| 4229 GLsizei imageSize = data_size; | 4227 GLsizei imageSize = data_size; |
| 4230 const void* data = bucket->GetData(0, data_size); | 4228 const void* data = bucket->GetData(0, data_size); |
| 4231 if (!ValidateGLenumTextureTarget(target)) { | 4229 if (!validators_->texture_target.IsValid(target)) { |
| 4232 SetGLError( | 4230 SetGLError( |
| 4233 GL_INVALID_ENUM, "glCompressedTexSubImage2D: target GL_INVALID_ENUM"); | 4231 GL_INVALID_ENUM, "glCompressedTexSubImage2D: target GL_INVALID_ENUM"); |
| 4234 return error::kNoError; | 4232 return error::kNoError; |
| 4235 } | 4233 } |
| 4234 if (!validators_->compressed_texture_format.IsValid(format)) { |
| 4235 SetGLError(GL_INVALID_ENUM, |
| 4236 "glCompressedTexSubImage2D: format GL_INVALID_ENUM"); |
| 4237 return error::kNoError; |
| 4238 } |
| 4236 if (width < 0) { | 4239 if (width < 0) { |
| 4237 SetGLError(GL_INVALID_VALUE, "glCompressedTexSubImage2D: width < 0"); | 4240 SetGLError(GL_INVALID_VALUE, "glCompressedTexSubImage2D: width < 0"); |
| 4238 return error::kNoError; | 4241 return error::kNoError; |
| 4239 } | 4242 } |
| 4240 if (height < 0) { | 4243 if (height < 0) { |
| 4241 SetGLError(GL_INVALID_VALUE, "glCompressedTexSubImage2D: height < 0"); | 4244 SetGLError(GL_INVALID_VALUE, "glCompressedTexSubImage2D: height < 0"); |
| 4242 return error::kNoError; | 4245 return error::kNoError; |
| 4243 } | 4246 } |
| 4244 if (imageSize < 0) { | 4247 if (imageSize < 0) { |
| 4245 SetGLError(GL_INVALID_VALUE, "glCompressedTexSubImage2D: imageSize < 0"); | 4248 SetGLError(GL_INVALID_VALUE, "glCompressedTexSubImage2D: imageSize < 0"); |
| 4246 return error::kNoError; | 4249 return error::kNoError; |
| 4247 } | 4250 } |
| 4248 glCompressedTexSubImage2D( | 4251 glCompressedTexSubImage2D( |
| 4249 target, level, xoffset, yoffset, width, height, format, imageSize, data); | 4252 target, level, xoffset, yoffset, width, height, format, imageSize, data); |
| 4250 return error::kNoError; | 4253 return error::kNoError; |
| 4251 } | 4254 } |
| 4252 | 4255 |
| 4253 error::Error GLES2DecoderImpl::DoTexImage2D( | 4256 error::Error GLES2DecoderImpl::DoTexImage2D( |
| 4254 GLenum target, | 4257 GLenum target, |
| 4255 GLint level, | 4258 GLint level, |
| 4256 GLenum internal_format, | 4259 GLenum internal_format, |
| 4257 GLsizei width, | 4260 GLsizei width, |
| 4258 GLsizei height, | 4261 GLsizei height, |
| 4259 GLint border, | 4262 GLint border, |
| 4260 GLenum format, | 4263 GLenum format, |
| 4261 GLenum type, | 4264 GLenum type, |
| 4262 const void* pixels, | 4265 const void* pixels, |
| 4263 uint32 pixels_size) { | 4266 uint32 pixels_size) { |
| 4264 if (!ValidateGLenumTextureTarget(target)) { | 4267 if (!validators_->texture_target.IsValid(target)) { |
| 4265 SetGLError(GL_INVALID_ENUM, "glTexImage2D: target GL_INVALID_ENUM"); | 4268 SetGLError(GL_INVALID_ENUM, "glTexImage2D: target GL_INVALID_ENUM"); |
| 4266 return error::kNoError; | 4269 return error::kNoError; |
| 4267 } | 4270 } |
| 4268 if (!ValidateGLenumTextureFormat(internal_format)) { | 4271 if (!validators_->texture_format.IsValid(internal_format)) { |
| 4269 SetGLError(GL_INVALID_ENUM, | 4272 SetGLError(GL_INVALID_ENUM, |
| 4270 "glTexImage2D: internal_format GL_INVALID_ENUM"); | 4273 "glTexImage2D: internal_format GL_INVALID_ENUM"); |
| 4271 return error::kNoError; | 4274 return error::kNoError; |
| 4272 } | 4275 } |
| 4273 if (!ValidateGLenumTextureFormat(format)) { | 4276 if (!validators_->texture_format.IsValid(format)) { |
| 4274 SetGLError(GL_INVALID_ENUM, "glTexImage2D: format GL_INVALID_ENUM"); | 4277 SetGLError(GL_INVALID_ENUM, "glTexImage2D: format GL_INVALID_ENUM"); |
| 4275 return error::kNoError; | 4278 return error::kNoError; |
| 4276 } | 4279 } |
| 4277 if (!ValidateGLenumPixelType(type)) { | 4280 if (!validators_->pixel_type.IsValid(type)) { |
| 4278 SetGLError(GL_INVALID_ENUM, "glTexImage2D: type GL_INVALID_ENUM"); | 4281 SetGLError(GL_INVALID_ENUM, "glTexImage2D: type GL_INVALID_ENUM"); |
| 4279 return error::kNoError; | 4282 return error::kNoError; |
| 4280 } | 4283 } |
| 4281 if (!texture_manager()->ValidForTarget(target, level, width, height, 1) || | 4284 if (!texture_manager()->ValidForTarget(target, level, width, height, 1) || |
| 4282 border != 0) { | 4285 border != 0) { |
| 4283 SetGLError(GL_INVALID_VALUE, "glTexImage2D: dimensions out of range"); | 4286 SetGLError(GL_INVALID_VALUE, "glTexImage2D: dimensions out of range"); |
| 4284 return error::kNoError; | 4287 return error::kNoError; |
| 4285 } | 4288 } |
| 4286 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); | 4289 TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); |
| 4287 if (!info) { | 4290 if (!info) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4366 typedef gles2::GetVertexAttribPointerv::Result Result; | 4369 typedef gles2::GetVertexAttribPointerv::Result Result; |
| 4367 Result* result = GetSharedMemoryAs<Result*>( | 4370 Result* result = GetSharedMemoryAs<Result*>( |
| 4368 c.pointer_shm_id, c.pointer_shm_offset, Result::ComputeSize(1)); | 4371 c.pointer_shm_id, c.pointer_shm_offset, Result::ComputeSize(1)); |
| 4369 if (!result) { | 4372 if (!result) { |
| 4370 return error::kOutOfBounds; | 4373 return error::kOutOfBounds; |
| 4371 } | 4374 } |
| 4372 // Check that the client initialized the result. | 4375 // Check that the client initialized the result. |
| 4373 if (result->size != 0) { | 4376 if (result->size != 0) { |
| 4374 return error::kInvalidArguments; | 4377 return error::kInvalidArguments; |
| 4375 } | 4378 } |
| 4376 if (!ValidateGLenumVertexPointer(pname)) { | 4379 if (!validators_->vertex_pointer.IsValid(pname)) { |
| 4377 SetGLError(GL_INVALID_ENUM, | 4380 SetGLError(GL_INVALID_ENUM, |
| 4378 "glGetVertexAttribPointerv: pname GL_INVALID_ENUM"); | 4381 "glGetVertexAttribPointerv: pname GL_INVALID_ENUM"); |
| 4379 return error::kNoError; | 4382 return error::kNoError; |
| 4380 } | 4383 } |
| 4381 if (index >= group_->max_vertex_attribs()) { | 4384 if (index >= group_->max_vertex_attribs()) { |
| 4382 SetGLError(GL_INVALID_VALUE, | 4385 SetGLError(GL_INVALID_VALUE, |
| 4383 "glGetVertexAttribPointerv: index out of range."); | 4386 "glGetVertexAttribPointerv: index out of range."); |
| 4384 return error::kNoError; | 4387 return error::kNoError; |
| 4385 } | 4388 } |
| 4386 result->SetNumResults(1); | 4389 result->SetNumResults(1); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4496 typedef gles2::GetShaderPrecisionFormat::Result Result; | 4499 typedef gles2::GetShaderPrecisionFormat::Result Result; |
| 4497 Result* result = GetSharedMemoryAs<Result*>( | 4500 Result* result = GetSharedMemoryAs<Result*>( |
| 4498 c.result_shm_id, c.result_shm_offset, sizeof(*result)); | 4501 c.result_shm_id, c.result_shm_offset, sizeof(*result)); |
| 4499 if (!result) { | 4502 if (!result) { |
| 4500 return error::kOutOfBounds; | 4503 return error::kOutOfBounds; |
| 4501 } | 4504 } |
| 4502 // Check that the client initialized the result. | 4505 // Check that the client initialized the result. |
| 4503 if (result->success != 0) { | 4506 if (result->success != 0) { |
| 4504 return error::kInvalidArguments; | 4507 return error::kInvalidArguments; |
| 4505 } | 4508 } |
| 4506 if (!ValidateGLenumShaderType(shader_type)) { | 4509 if (!validators_->shader_type.IsValid(shader_type)) { |
| 4507 SetGLError(GL_INVALID_ENUM, | 4510 SetGLError(GL_INVALID_ENUM, |
| 4508 "glGetShaderPrecisionFormat: shader_type GL_INVALID_ENUM"); | 4511 "glGetShaderPrecisionFormat: shader_type GL_INVALID_ENUM"); |
| 4509 return error::kNoError; | 4512 return error::kNoError; |
| 4510 } | 4513 } |
| 4511 if (!ValidateGLenumShaderPrecision(precision_type)) { | 4514 if (!validators_->shader_precision.IsValid(precision_type)) { |
| 4512 SetGLError(GL_INVALID_ENUM, | 4515 SetGLError(GL_INVALID_ENUM, |
| 4513 "glGetShaderPrecisionFormat: precision_type GL_INVALID_ENUM"); | 4516 "glGetShaderPrecisionFormat: precision_type GL_INVALID_ENUM"); |
| 4514 return error::kNoError; | 4517 return error::kNoError; |
| 4515 } | 4518 } |
| 4516 | 4519 |
| 4517 result->success = 1; // true | 4520 result->success = 1; // true |
| 4518 switch (precision_type) { | 4521 switch (precision_type) { |
| 4519 case GL_LOW_INT: | 4522 case GL_LOW_INT: |
| 4520 case GL_MEDIUM_INT: | 4523 case GL_MEDIUM_INT: |
| 4521 case GL_HIGH_INT: | 4524 case GL_HIGH_INT: |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4746 return error::kNoError; | 4749 return error::kNoError; |
| 4747 } | 4750 } |
| 4748 | 4751 |
| 4749 // Include the auto-generated part of this file. We split this because it means | 4752 // Include the auto-generated part of this file. We split this because it means |
| 4750 // we can easily edit the non-auto generated parts right here in this file | 4753 // we can easily edit the non-auto generated parts right here in this file |
| 4751 // instead of having to edit some template or the code generator. | 4754 // instead of having to edit some template or the code generator. |
| 4752 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 4755 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 4753 | 4756 |
| 4754 } // namespace gles2 | 4757 } // namespace gles2 |
| 4755 } // namespace gpu | 4758 } // namespace gpu |
| OLD | NEW |