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 7187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7198 GL_INVALID_VALUE, "glVertexAttribPointer", "stride > 255"); | 7198 GL_INVALID_VALUE, "glVertexAttribPointer", "stride > 255"); |
7199 return error::kNoError; | 7199 return error::kNoError; |
7200 } | 7200 } |
7201 if (offset < 0) { | 7201 if (offset < 0) { |
7202 LOCAL_SET_GL_ERROR( | 7202 LOCAL_SET_GL_ERROR( |
7203 GL_INVALID_VALUE, "glVertexAttribPointer", "offset < 0"); | 7203 GL_INVALID_VALUE, "glVertexAttribPointer", "offset < 0"); |
7204 return error::kNoError; | 7204 return error::kNoError; |
7205 } | 7205 } |
7206 GLsizei component_size = | 7206 GLsizei component_size = |
7207 GLES2Util::GetGLTypeSizeForTexturesAndBuffers(type); | 7207 GLES2Util::GetGLTypeSizeForTexturesAndBuffers(type); |
7208 if (offset % component_size > 0) { | 7208 // component_size must be a power of two to use & as optimized modulo. |
| 7209 DCHECK(GLES2Util::IsPOT(component_size)); |
| 7210 if (offset & (component_size - 1)) { |
7209 LOCAL_SET_GL_ERROR( | 7211 LOCAL_SET_GL_ERROR( |
7210 GL_INVALID_OPERATION, | 7212 GL_INVALID_OPERATION, |
7211 "glVertexAttribPointer", "offset not valid for type"); | 7213 "glVertexAttribPointer", "offset not valid for type"); |
7212 return error::kNoError; | 7214 return error::kNoError; |
7213 } | 7215 } |
7214 if (stride % component_size > 0) { | 7216 if (stride & (component_size - 1)) { |
7215 LOCAL_SET_GL_ERROR( | 7217 LOCAL_SET_GL_ERROR( |
7216 GL_INVALID_OPERATION, | 7218 GL_INVALID_OPERATION, |
7217 "glVertexAttribPointer", "stride not valid for type"); | 7219 "glVertexAttribPointer", "stride not valid for type"); |
7218 return error::kNoError; | 7220 return error::kNoError; |
7219 } | 7221 } |
7220 state_.vertex_attrib_manager | 7222 state_.vertex_attrib_manager |
7221 ->SetAttribInfo(indx, | 7223 ->SetAttribInfo(indx, |
7222 state_.bound_array_buffer.get(), | 7224 state_.bound_array_buffer.get(), |
7223 size, | 7225 size, |
7224 type, | 7226 type, |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7977 const int kS3TCBlockHeight = 4; | 7979 const int kS3TCBlockHeight = 4; |
7978 const int kS3TCDXT1BlockSize = 8; | 7980 const int kS3TCDXT1BlockSize = 8; |
7979 const int kS3TCDXT3AndDXT5BlockSize = 16; | 7981 const int kS3TCDXT3AndDXT5BlockSize = 16; |
7980 | 7982 |
7981 bool IsValidDXTSize(GLint level, GLsizei size) { | 7983 bool IsValidDXTSize(GLint level, GLsizei size) { |
7982 return (size == 1) || | 7984 return (size == 1) || |
7983 (size == 2) || !(size % kS3TCBlockWidth); | 7985 (size == 2) || !(size % kS3TCBlockWidth); |
7984 } | 7986 } |
7985 | 7987 |
7986 bool IsValidPVRTCSize(GLint level, GLsizei size) { | 7988 bool IsValidPVRTCSize(GLint level, GLsizei size) { |
7987 // Ensure that the size is a power of two | 7989 return GLES2Util::IsPOT(size); |
7988 return (size & (size - 1)) == 0; | |
7989 } | 7990 } |
7990 | 7991 |
7991 } // anonymous namespace. | 7992 } // anonymous namespace. |
7992 | 7993 |
7993 bool GLES2DecoderImpl::ValidateCompressedTexFuncData( | 7994 bool GLES2DecoderImpl::ValidateCompressedTexFuncData( |
7994 const char* function_name, | 7995 const char* function_name, |
7995 GLsizei width, GLsizei height, GLenum format, size_t size) { | 7996 GLsizei width, GLsizei height, GLenum format, size_t size) { |
7996 unsigned int bytes_required = 0; | 7997 unsigned int bytes_required = 0; |
7997 | 7998 |
7998 switch (format) { | 7999 switch (format) { |
(...skipping 2930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10929 } | 10930 } |
10930 } | 10931 } |
10931 | 10932 |
10932 // Include the auto-generated part of this file. We split this because it means | 10933 // Include the auto-generated part of this file. We split this because it means |
10933 // we can easily edit the non-auto generated parts right here in this file | 10934 // we can easily edit the non-auto generated parts right here in this file |
10934 // instead of having to edit some template or the code generator. | 10935 // instead of having to edit some template or the code generator. |
10935 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 10936 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
10936 | 10937 |
10937 } // namespace gles2 | 10938 } // namespace gles2 |
10938 } // namespace gpu | 10939 } // namespace gpu |
OLD | NEW |