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 5934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5945 !validateUniformParameters("uniform4iv", location, v.data(), v.size(), 4, | 5945 !validateUniformParameters("uniform4iv", location, v.data(), v.size(), 4, |
5946 0, v.size())) | 5946 0, v.size())) |
5947 return; | 5947 return; |
5948 | 5948 |
5949 contextGL()->Uniform4iv(location->location(), v.size() >> 2, v.data()); | 5949 contextGL()->Uniform4iv(location->location(), v.size() >> 2, v.data()); |
5950 } | 5950 } |
5951 | 5951 |
5952 void WebGLRenderingContextBase::uniformMatrix2fv( | 5952 void WebGLRenderingContextBase::uniformMatrix2fv( |
5953 const WebGLUniformLocation* location, | 5953 const WebGLUniformLocation* location, |
5954 GLboolean transpose, | 5954 GLboolean transpose, |
5955 DOMFloat32Array* v) { | 5955 const MaybeShared<DOMFloat32Array>& v) { |
5956 if (isContextLost() || | 5956 if (isContextLost() || |
5957 !validateUniformMatrixParameters("uniformMatrix2fv", location, transpose, | 5957 !validateUniformMatrixParameters("uniformMatrix2fv", location, transpose, |
5958 v, 4, 0, v->length())) | 5958 v, 4, 0, v->length())) |
5959 return; | 5959 return; |
5960 contextGL()->UniformMatrix2fv(location->location(), v->length() >> 2, | 5960 contextGL()->UniformMatrix2fv(location->location(), |
5961 transpose, v->data()); | 5961 v.viewNotShared()->length() >> 2, transpose, |
| 5962 v.viewNotShared()->data()); |
5962 } | 5963 } |
5963 | 5964 |
5964 void WebGLRenderingContextBase::uniformMatrix2fv( | 5965 void WebGLRenderingContextBase::uniformMatrix2fv( |
5965 const WebGLUniformLocation* location, | 5966 const WebGLUniformLocation* location, |
5966 GLboolean transpose, | 5967 GLboolean transpose, |
5967 Vector<GLfloat>& v) { | 5968 Vector<GLfloat>& v) { |
5968 if (isContextLost() || | 5969 if (isContextLost() || |
5969 !validateUniformMatrixParameters("uniformMatrix2fv", location, transpose, | 5970 !validateUniformMatrixParameters("uniformMatrix2fv", location, transpose, |
5970 v.data(), v.size(), 4, 0, v.size())) | 5971 v.data(), v.size(), 4, 0, v.size())) |
5971 return; | 5972 return; |
5972 contextGL()->UniformMatrix2fv(location->location(), v.size() >> 2, transpose, | 5973 contextGL()->UniformMatrix2fv(location->location(), v.size() >> 2, transpose, |
5973 v.data()); | 5974 v.data()); |
5974 } | 5975 } |
5975 | 5976 |
5976 void WebGLRenderingContextBase::uniformMatrix3fv( | 5977 void WebGLRenderingContextBase::uniformMatrix3fv( |
5977 const WebGLUniformLocation* location, | 5978 const WebGLUniformLocation* location, |
5978 GLboolean transpose, | 5979 GLboolean transpose, |
5979 DOMFloat32Array* v) { | 5980 const MaybeShared<DOMFloat32Array>& v) { |
5980 if (isContextLost() || | 5981 if (isContextLost() || |
5981 !validateUniformMatrixParameters("uniformMatrix3fv", location, transpose, | 5982 !validateUniformMatrixParameters("uniformMatrix3fv", location, transpose, |
5982 v, 9, 0, v->length())) | 5983 v, 9, 0, v->length())) |
5983 return; | 5984 return; |
5984 contextGL()->UniformMatrix3fv(location->location(), v->length() / 9, | 5985 contextGL()->UniformMatrix3fv(location->location(), |
5985 transpose, v->data()); | 5986 v.viewNotShared()->length() / 9, transpose, |
| 5987 v.viewNotShared()->data()); |
5986 } | 5988 } |
5987 | 5989 |
5988 void WebGLRenderingContextBase::uniformMatrix3fv( | 5990 void WebGLRenderingContextBase::uniformMatrix3fv( |
5989 const WebGLUniformLocation* location, | 5991 const WebGLUniformLocation* location, |
5990 GLboolean transpose, | 5992 GLboolean transpose, |
5991 Vector<GLfloat>& v) { | 5993 Vector<GLfloat>& v) { |
5992 if (isContextLost() || | 5994 if (isContextLost() || |
5993 !validateUniformMatrixParameters("uniformMatrix3fv", location, transpose, | 5995 !validateUniformMatrixParameters("uniformMatrix3fv", location, transpose, |
5994 v.data(), v.size(), 9, 0, v.size())) | 5996 v.data(), v.size(), 9, 0, v.size())) |
5995 return; | 5997 return; |
5996 contextGL()->UniformMatrix3fv(location->location(), v.size() / 9, transpose, | 5998 contextGL()->UniformMatrix3fv(location->location(), v.size() / 9, transpose, |
5997 v.data()); | 5999 v.data()); |
5998 } | 6000 } |
5999 | 6001 |
6000 void WebGLRenderingContextBase::uniformMatrix4fv( | 6002 void WebGLRenderingContextBase::uniformMatrix4fv( |
6001 const WebGLUniformLocation* location, | 6003 const WebGLUniformLocation* location, |
6002 GLboolean transpose, | 6004 GLboolean transpose, |
6003 DOMFloat32Array* v) { | 6005 const MaybeShared<DOMFloat32Array>& v) { |
6004 if (isContextLost() || | 6006 if (isContextLost() || |
6005 !validateUniformMatrixParameters("uniformMatrix4fv", location, transpose, | 6007 !validateUniformMatrixParameters("uniformMatrix4fv", location, transpose, |
6006 v, 16, 0, v->length())) | 6008 v, 16, 0, v->length())) |
6007 return; | 6009 return; |
6008 contextGL()->UniformMatrix4fv(location->location(), v->length() >> 4, | 6010 contextGL()->UniformMatrix4fv(location->location(), |
6009 transpose, v->data()); | 6011 v.viewNotShared()->length() >> 4, transpose, |
| 6012 v.viewNotShared()->data()); |
6010 } | 6013 } |
6011 | 6014 |
6012 void WebGLRenderingContextBase::uniformMatrix4fv( | 6015 void WebGLRenderingContextBase::uniformMatrix4fv( |
6013 const WebGLUniformLocation* location, | 6016 const WebGLUniformLocation* location, |
6014 GLboolean transpose, | 6017 GLboolean transpose, |
6015 Vector<GLfloat>& v) { | 6018 Vector<GLfloat>& v) { |
6016 if (isContextLost() || | 6019 if (isContextLost() || |
6017 !validateUniformMatrixParameters("uniformMatrix4fv", location, transpose, | 6020 !validateUniformMatrixParameters("uniformMatrix4fv", location, transpose, |
6018 v.data(), v.size(), 16, 0, v.size())) | 6021 v.data(), v.size(), 16, 0, v.size())) |
6019 return; | 6022 return; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6055 m_vertexAttribType[index] = type; | 6058 m_vertexAttribType[index] = type; |
6056 } | 6059 } |
6057 | 6060 |
6058 void WebGLRenderingContextBase::vertexAttrib1f(GLuint index, GLfloat v0) { | 6061 void WebGLRenderingContextBase::vertexAttrib1f(GLuint index, GLfloat v0) { |
6059 if (isContextLost()) | 6062 if (isContextLost()) |
6060 return; | 6063 return; |
6061 contextGL()->VertexAttrib1f(index, v0); | 6064 contextGL()->VertexAttrib1f(index, v0); |
6062 setVertexAttribType(index, Float32ArrayType); | 6065 setVertexAttribType(index, Float32ArrayType); |
6063 } | 6066 } |
6064 | 6067 |
6065 void WebGLRenderingContextBase::vertexAttrib1fv(GLuint index, | 6068 void WebGLRenderingContextBase::vertexAttrib1fv( |
6066 const DOMFloat32Array* v) { | 6069 GLuint index, |
6067 if (isContextLost()) | 6070 const MaybeShared<const DOMFloat32Array>& v) { |
| 6071 if (isContextLost() || !validateNotSharedArrayBuffer("vertexAttrib1fv", v)) |
6068 return; | 6072 return; |
6069 if (!v || v->length() < 1) { | 6073 if (!v || v.viewNotShared()->length() < 1) { |
6070 synthesizeGLError(GL_INVALID_VALUE, "vertexAttrib1fv", "invalid array"); | 6074 synthesizeGLError(GL_INVALID_VALUE, "vertexAttrib1fv", "invalid array"); |
6071 return; | 6075 return; |
6072 } | 6076 } |
6073 contextGL()->VertexAttrib1fv(index, v->data()); | 6077 contextGL()->VertexAttrib1fv(index, v.viewNotShared()->data()); |
6074 setVertexAttribType(index, Float32ArrayType); | 6078 setVertexAttribType(index, Float32ArrayType); |
6075 } | 6079 } |
6076 | 6080 |
6077 void WebGLRenderingContextBase::vertexAttrib1fv(GLuint index, | 6081 void WebGLRenderingContextBase::vertexAttrib1fv(GLuint index, |
6078 const Vector<GLfloat>& v) { | 6082 const Vector<GLfloat>& v) { |
6079 if (isContextLost()) | 6083 if (isContextLost()) |
6080 return; | 6084 return; |
6081 if (v.size() < 1) { | 6085 if (v.size() < 1) { |
6082 synthesizeGLError(GL_INVALID_VALUE, "vertexAttrib1fv", "invalid array"); | 6086 synthesizeGLError(GL_INVALID_VALUE, "vertexAttrib1fv", "invalid array"); |
6083 return; | 6087 return; |
6084 } | 6088 } |
6085 contextGL()->VertexAttrib1fv(index, v.data()); | 6089 contextGL()->VertexAttrib1fv(index, v.data()); |
6086 setVertexAttribType(index, Float32ArrayType); | 6090 setVertexAttribType(index, Float32ArrayType); |
6087 } | 6091 } |
6088 | 6092 |
6089 void WebGLRenderingContextBase::vertexAttrib2f(GLuint index, | 6093 void WebGLRenderingContextBase::vertexAttrib2f(GLuint index, |
6090 GLfloat v0, | 6094 GLfloat v0, |
6091 GLfloat v1) { | 6095 GLfloat v1) { |
6092 if (isContextLost()) | 6096 if (isContextLost()) |
6093 return; | 6097 return; |
6094 contextGL()->VertexAttrib2f(index, v0, v1); | 6098 contextGL()->VertexAttrib2f(index, v0, v1); |
6095 setVertexAttribType(index, Float32ArrayType); | 6099 setVertexAttribType(index, Float32ArrayType); |
6096 } | 6100 } |
6097 | 6101 |
6098 void WebGLRenderingContextBase::vertexAttrib2fv(GLuint index, | 6102 void WebGLRenderingContextBase::vertexAttrib2fv( |
6099 const DOMFloat32Array* v) { | 6103 GLuint index, |
6100 if (isContextLost()) | 6104 const MaybeShared<const DOMFloat32Array>& v) { |
| 6105 if (isContextLost() || !validateNotSharedArrayBuffer("vertexAttrib2fv", v)) |
6101 return; | 6106 return; |
6102 if (!v || v->length() < 2) { | 6107 if (!v || v.viewNotShared()->length() < 2) { |
6103 synthesizeGLError(GL_INVALID_VALUE, "vertexAttrib2fv", "invalid array"); | 6108 synthesizeGLError(GL_INVALID_VALUE, "vertexAttrib2fv", "invalid array"); |
6104 return; | 6109 return; |
6105 } | 6110 } |
6106 contextGL()->VertexAttrib2fv(index, v->data()); | 6111 contextGL()->VertexAttrib2fv(index, v.viewNotShared()->data()); |
6107 setVertexAttribType(index, Float32ArrayType); | 6112 setVertexAttribType(index, Float32ArrayType); |
6108 } | 6113 } |
6109 | 6114 |
6110 void WebGLRenderingContextBase::vertexAttrib2fv(GLuint index, | 6115 void WebGLRenderingContextBase::vertexAttrib2fv(GLuint index, |
6111 const Vector<GLfloat>& v) { | 6116 const Vector<GLfloat>& v) { |
6112 if (isContextLost()) | 6117 if (isContextLost()) |
6113 return; | 6118 return; |
6114 if (v.size() < 2) { | 6119 if (v.size() < 2) { |
6115 synthesizeGLError(GL_INVALID_VALUE, "vertexAttrib2fv", "invalid array"); | 6120 synthesizeGLError(GL_INVALID_VALUE, "vertexAttrib2fv", "invalid array"); |
6116 return; | 6121 return; |
6117 } | 6122 } |
6118 contextGL()->VertexAttrib2fv(index, v.data()); | 6123 contextGL()->VertexAttrib2fv(index, v.data()); |
6119 setVertexAttribType(index, Float32ArrayType); | 6124 setVertexAttribType(index, Float32ArrayType); |
6120 } | 6125 } |
6121 | 6126 |
6122 void WebGLRenderingContextBase::vertexAttrib3f(GLuint index, | 6127 void WebGLRenderingContextBase::vertexAttrib3f(GLuint index, |
6123 GLfloat v0, | 6128 GLfloat v0, |
6124 GLfloat v1, | 6129 GLfloat v1, |
6125 GLfloat v2) { | 6130 GLfloat v2) { |
6126 if (isContextLost()) | 6131 if (isContextLost()) |
6127 return; | 6132 return; |
6128 contextGL()->VertexAttrib3f(index, v0, v1, v2); | 6133 contextGL()->VertexAttrib3f(index, v0, v1, v2); |
6129 setVertexAttribType(index, Float32ArrayType); | 6134 setVertexAttribType(index, Float32ArrayType); |
6130 } | 6135 } |
6131 | 6136 |
6132 void WebGLRenderingContextBase::vertexAttrib3fv(GLuint index, | 6137 void WebGLRenderingContextBase::vertexAttrib3fv( |
6133 const DOMFloat32Array* v) { | 6138 GLuint index, |
6134 if (isContextLost()) | 6139 const MaybeShared<const DOMFloat32Array>& v) { |
| 6140 if (isContextLost() || !validateNotSharedArrayBuffer("vertexAttrib3fv", v)) |
6135 return; | 6141 return; |
6136 if (!v || v->length() < 3) { | 6142 if (!v || v.viewNotShared()->length() < 3) { |
6137 synthesizeGLError(GL_INVALID_VALUE, "vertexAttrib3fv", "invalid array"); | 6143 synthesizeGLError(GL_INVALID_VALUE, "vertexAttrib3fv", "invalid array"); |
6138 return; | 6144 return; |
6139 } | 6145 } |
6140 contextGL()->VertexAttrib3fv(index, v->data()); | 6146 contextGL()->VertexAttrib3fv(index, v.viewNotShared()->data()); |
6141 setVertexAttribType(index, Float32ArrayType); | 6147 setVertexAttribType(index, Float32ArrayType); |
6142 } | 6148 } |
6143 | 6149 |
6144 void WebGLRenderingContextBase::vertexAttrib3fv(GLuint index, | 6150 void WebGLRenderingContextBase::vertexAttrib3fv(GLuint index, |
6145 const Vector<GLfloat>& v) { | 6151 const Vector<GLfloat>& v) { |
6146 if (isContextLost()) | 6152 if (isContextLost()) |
6147 return; | 6153 return; |
6148 if (v.size() < 3) { | 6154 if (v.size() < 3) { |
6149 synthesizeGLError(GL_INVALID_VALUE, "vertexAttrib3fv", "invalid array"); | 6155 synthesizeGLError(GL_INVALID_VALUE, "vertexAttrib3fv", "invalid array"); |
6150 return; | 6156 return; |
6151 } | 6157 } |
6152 contextGL()->VertexAttrib3fv(index, v.data()); | 6158 contextGL()->VertexAttrib3fv(index, v.data()); |
6153 setVertexAttribType(index, Float32ArrayType); | 6159 setVertexAttribType(index, Float32ArrayType); |
6154 } | 6160 } |
6155 | 6161 |
6156 void WebGLRenderingContextBase::vertexAttrib4f(GLuint index, | 6162 void WebGLRenderingContextBase::vertexAttrib4f(GLuint index, |
6157 GLfloat v0, | 6163 GLfloat v0, |
6158 GLfloat v1, | 6164 GLfloat v1, |
6159 GLfloat v2, | 6165 GLfloat v2, |
6160 GLfloat v3) { | 6166 GLfloat v3) { |
6161 if (isContextLost()) | 6167 if (isContextLost()) |
6162 return; | 6168 return; |
6163 contextGL()->VertexAttrib4f(index, v0, v1, v2, v3); | 6169 contextGL()->VertexAttrib4f(index, v0, v1, v2, v3); |
6164 setVertexAttribType(index, Float32ArrayType); | 6170 setVertexAttribType(index, Float32ArrayType); |
6165 } | 6171 } |
6166 | 6172 |
6167 void WebGLRenderingContextBase::vertexAttrib4fv(GLuint index, | 6173 void WebGLRenderingContextBase::vertexAttrib4fv( |
6168 const DOMFloat32Array* v) { | 6174 GLuint index, |
6169 if (isContextLost()) | 6175 const MaybeShared<const DOMFloat32Array>& v) { |
| 6176 if (isContextLost() || !validateNotSharedArrayBuffer("vertexAttrib4fv", v)) |
6170 return; | 6177 return; |
6171 if (!v || v->length() < 4) { | 6178 if (!v || v.viewNotShared()->length() < 4) { |
6172 synthesizeGLError(GL_INVALID_VALUE, "vertexAttrib4fv", "invalid array"); | 6179 synthesizeGLError(GL_INVALID_VALUE, "vertexAttrib4fv", "invalid array"); |
6173 return; | 6180 return; |
6174 } | 6181 } |
6175 contextGL()->VertexAttrib4fv(index, v->data()); | 6182 contextGL()->VertexAttrib4fv(index, v.viewNotShared()->data()); |
6176 setVertexAttribType(index, Float32ArrayType); | 6183 setVertexAttribType(index, Float32ArrayType); |
6177 } | 6184 } |
6178 | 6185 |
6179 void WebGLRenderingContextBase::vertexAttrib4fv(GLuint index, | 6186 void WebGLRenderingContextBase::vertexAttrib4fv(GLuint index, |
6180 const Vector<GLfloat>& v) { | 6187 const Vector<GLfloat>& v) { |
6181 if (isContextLost()) | 6188 if (isContextLost()) |
6182 return; | 6189 return; |
6183 if (v.size() < 4) { | 6190 if (v.size() < 4) { |
6184 synthesizeGLError(GL_INVALID_VALUE, "vertexAttrib4fv", "invalid array"); | 6191 synthesizeGLError(GL_INVALID_VALUE, "vertexAttrib4fv", "invalid array"); |
6185 return; | 6192 return; |
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7206 GLuint srcOffset, | 7213 GLuint srcOffset, |
7207 GLuint srcLength) { | 7214 GLuint srcLength) { |
7208 return validateUniformMatrixParameters(functionName, location, false, v, size, | 7215 return validateUniformMatrixParameters(functionName, location, false, v, size, |
7209 requiredMinSize, srcOffset, srcLength); | 7216 requiredMinSize, srcOffset, srcLength); |
7210 } | 7217 } |
7211 | 7218 |
7212 bool WebGLRenderingContextBase::validateUniformMatrixParameters( | 7219 bool WebGLRenderingContextBase::validateUniformMatrixParameters( |
7213 const char* functionName, | 7220 const char* functionName, |
7214 const WebGLUniformLocation* location, | 7221 const WebGLUniformLocation* location, |
7215 GLboolean transpose, | 7222 GLboolean transpose, |
7216 DOMFloat32Array* v, | 7223 const MaybeShared<DOMFloat32Array>& v, |
7217 GLsizei requiredMinSize, | 7224 GLsizei requiredMinSize, |
7218 GLuint srcOffset, | 7225 GLuint srcOffset, |
7219 GLuint srcLength) { | 7226 GLuint srcLength) { |
7220 if (!v) { | 7227 if (!v) { |
7221 synthesizeGLError(GL_INVALID_VALUE, functionName, "no array"); | 7228 synthesizeGLError(GL_INVALID_VALUE, functionName, "no array"); |
7222 return false; | 7229 return false; |
7223 } | 7230 } |
7224 return validateUniformMatrixParameters(functionName, location, transpose, | 7231 return validateNotSharedArrayBuffer(functionName, v) && |
7225 v->data(), v->length(), | 7232 validateUniformMatrixParameters(functionName, location, transpose, |
| 7233 v.viewNotShared()->data(), |
| 7234 v.viewNotShared()->length(), |
7226 requiredMinSize, srcOffset, srcLength); | 7235 requiredMinSize, srcOffset, srcLength); |
7227 } | 7236 } |
7228 | 7237 |
7229 bool WebGLRenderingContextBase::validateUniformMatrixParameters( | 7238 bool WebGLRenderingContextBase::validateUniformMatrixParameters( |
7230 const char* functionName, | 7239 const char* functionName, |
7231 const WebGLUniformLocation* location, | 7240 const WebGLUniformLocation* location, |
7232 GLboolean transpose, | 7241 GLboolean transpose, |
7233 void* v, | 7242 void* v, |
7234 GLsizei size, | 7243 GLsizei size, |
7235 GLsizei requiredMinSize, | 7244 GLsizei requiredMinSize, |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7836 | 7845 |
7837 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( | 7846 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( |
7838 HTMLCanvasElementOrOffscreenCanvas& result) const { | 7847 HTMLCanvasElementOrOffscreenCanvas& result) const { |
7839 if (canvas()) | 7848 if (canvas()) |
7840 result.setHTMLCanvasElement(canvas()); | 7849 result.setHTMLCanvasElement(canvas()); |
7841 else | 7850 else |
7842 result.setOffscreenCanvas(offscreenCanvas()); | 7851 result.setOffscreenCanvas(offscreenCanvas()); |
7843 } | 7852 } |
7844 | 7853 |
7845 } // namespace blink | 7854 } // namespace blink |
OLD | NEW |