| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 1418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1429 return sizeof(GLuint); | 1429 return sizeof(GLuint); |
| 1430 case GL_FLOAT: | 1430 case GL_FLOAT: |
| 1431 return sizeof(GLfloat); | 1431 return sizeof(GLfloat); |
| 1432 case GL_HALF_FLOAT: | 1432 case GL_HALF_FLOAT: |
| 1433 return sizeof(GLushort); | 1433 return sizeof(GLushort); |
| 1434 case GL_INT_2_10_10_10_REV: | 1434 case GL_INT_2_10_10_10_REV: |
| 1435 return sizeof(GLint); | 1435 return sizeof(GLint); |
| 1436 case GL_UNSIGNED_INT_2_10_10_10_REV: | 1436 case GL_UNSIGNED_INT_2_10_10_10_REV: |
| 1437 return sizeof(GLuint); | 1437 return sizeof(GLuint); |
| 1438 } | 1438 } |
| 1439 ASSERT_NOT_REACHED(); | |
| 1440 return 0; | 1439 return 0; |
| 1441 } | 1440 } |
| 1442 | 1441 |
| 1443 void WebGLRenderingContextBase::activeTexture(GLenum texture) | 1442 void WebGLRenderingContextBase::activeTexture(GLenum texture) |
| 1444 { | 1443 { |
| 1445 if (isContextLost()) | 1444 if (isContextLost()) |
| 1446 return; | 1445 return; |
| 1447 if (texture - GL_TEXTURE0 >= m_textureUnits.size()) { | 1446 if (texture - GL_TEXTURE0 >= m_textureUnits.size()) { |
| 1448 synthesizeGLError(GL_INVALID_ENUM, "activeTexture", "texture unit out of
range"); | 1447 synthesizeGLError(GL_INVALID_ENUM, "activeTexture", "texture unit out of
range"); |
| 1449 return; | 1448 return; |
| (...skipping 3683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5133 void WebGLRenderingContextBase::vertexAttrib4fv(GLuint index, const DOMFloat32Ar
ray* v) | 5132 void WebGLRenderingContextBase::vertexAttrib4fv(GLuint index, const DOMFloat32Ar
ray* v) |
| 5134 { | 5133 { |
| 5135 vertexAttribfvImpl("vertexAttrib4fv", index, v, 4); | 5134 vertexAttribfvImpl("vertexAttrib4fv", index, v, 4); |
| 5136 } | 5135 } |
| 5137 | 5136 |
| 5138 void WebGLRenderingContextBase::vertexAttrib4fv(GLuint index, const Vector<GLflo
at>& v) | 5137 void WebGLRenderingContextBase::vertexAttrib4fv(GLuint index, const Vector<GLflo
at>& v) |
| 5139 { | 5138 { |
| 5140 vertexAttribfvImpl("vertexAttrib4fv", index, v.data(), v.size(), 4); | 5139 vertexAttribfvImpl("vertexAttrib4fv", index, v.data(), v.size(), 4); |
| 5141 } | 5140 } |
| 5142 | 5141 |
| 5143 bool WebGLRenderingContextBase::validateVertexAttribPointerTypeAndSize(GLenum ty
pe, GLint size) | |
| 5144 { | |
| 5145 switch (type) { | |
| 5146 case GL_BYTE: | |
| 5147 case GL_UNSIGNED_BYTE: | |
| 5148 case GL_SHORT: | |
| 5149 case GL_UNSIGNED_SHORT: | |
| 5150 case GL_FLOAT: | |
| 5151 if (size < 1 || size > 4) { | |
| 5152 synthesizeGLError(GL_INVALID_VALUE, "vertexAttribPointer", "bad size
"); | |
| 5153 return false; | |
| 5154 } | |
| 5155 return true; | |
| 5156 default: | |
| 5157 synthesizeGLError(GL_INVALID_ENUM, "vertexAttribPointer", "invalid type"
); | |
| 5158 return false; | |
| 5159 } | |
| 5160 } | |
| 5161 | |
| 5162 void WebGLRenderingContextBase::vertexAttribPointer(ScriptState* scriptState, GL
uint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, long
long offset) | 5142 void WebGLRenderingContextBase::vertexAttribPointer(ScriptState* scriptState, GL
uint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, long
long offset) |
| 5163 { | 5143 { |
| 5164 if (isContextLost() || !validateVertexAttribPointerTypeAndSize(type, size)) | 5144 if (isContextLost()) |
| 5165 return; | 5145 return; |
| 5166 if (index >= m_maxVertexAttribs) { | |
| 5167 synthesizeGLError(GL_INVALID_VALUE, "vertexAttribPointer", "index out of
range"); | |
| 5168 return; | |
| 5169 } | |
| 5170 if (stride < 0 || stride > 255) { | |
| 5171 synthesizeGLError(GL_INVALID_VALUE, "vertexAttribPointer", "bad stride")
; | |
| 5172 return; | |
| 5173 } | |
| 5174 if (!validateValueFitNonNegInt32("vertexAttribPointer", "offset", offset)) | |
| 5175 return; | |
| 5176 if (!m_boundArrayBuffer) { | |
| 5177 synthesizeGLError(GL_INVALID_OPERATION, "vertexAttribPointer", "no bound
ARRAY_BUFFER"); | |
| 5178 return; | |
| 5179 } | |
| 5180 unsigned typeSize = sizeInBytes(type); | 5146 unsigned typeSize = sizeInBytes(type); |
| 5181 ASSERT((typeSize & (typeSize - 1)) == 0); // Ensure that the value is POT. | |
| 5182 if ((stride & (typeSize - 1)) || (static_cast<GLintptr>(offset) & (typeSize
- 1))) { | |
| 5183 synthesizeGLError(GL_INVALID_OPERATION, "vertexAttribPointer", "stride o
r offset not valid for type"); | |
| 5184 return; | |
| 5185 } | |
| 5186 GLsizei bytesPerElement = size * typeSize; | 5147 GLsizei bytesPerElement = size * typeSize; |
| 5187 | 5148 |
| 5188 m_boundVertexArrayObject->setVertexAttribState(index, bytesPerElement, size,
type, normalized, stride, static_cast<GLintptr>(offset), m_boundArrayBuffer); | 5149 m_boundVertexArrayObject->setVertexAttribState(index, bytesPerElement, size,
type, normalized, stride, static_cast<GLintptr>(offset), m_boundArrayBuffer); |
| 5189 webContext()->vertexAttribPointer(index, size, type, normalized, stride, sta
tic_cast<GLintptr>(offset)); | 5150 webContext()->vertexAttribPointer(index, size, type, normalized, stride, sta
tic_cast<GLintptr>(offset)); |
| 5190 maybePreserveDefaultVAOObjectWrapper(scriptState); | 5151 maybePreserveDefaultVAOObjectWrapper(scriptState); |
| 5191 preserveObjectWrapper(scriptState, m_boundVertexArrayObject, "arraybuffer",
index, m_boundArrayBuffer); | 5152 preserveObjectWrapper(scriptState, m_boundVertexArrayObject, "arraybuffer",
index, m_boundArrayBuffer); |
| 5192 } | 5153 } |
| 5193 | 5154 |
| 5194 void WebGLRenderingContextBase::vertexAttribDivisorANGLE(GLuint index, GLuint di
visor) | 5155 void WebGLRenderingContextBase::vertexAttribDivisorANGLE(GLuint index, GLuint di
visor) |
| 5195 { | 5156 { |
| (...skipping 1871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7067 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, 1); | 7028 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| 7068 } | 7029 } |
| 7069 | 7030 |
| 7070 void WebGLRenderingContextBase::restoreUnpackParameters() | 7031 void WebGLRenderingContextBase::restoreUnpackParameters() |
| 7071 { | 7032 { |
| 7072 if (m_unpackAlignment != 1) | 7033 if (m_unpackAlignment != 1) |
| 7073 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 7034 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); |
| 7074 } | 7035 } |
| 7075 | 7036 |
| 7076 } // namespace blink | 7037 } // namespace blink |
| OLD | NEW |