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 2166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2177 | 2177 |
2178 void WebGLRenderingContextBase::disableVertexAttribArray(GLuint index) | 2178 void WebGLRenderingContextBase::disableVertexAttribArray(GLuint index) |
2179 { | 2179 { |
2180 if (isContextLost()) | 2180 if (isContextLost()) |
2181 return; | 2181 return; |
2182 if (index >= m_maxVertexAttribs) { | 2182 if (index >= m_maxVertexAttribs) { |
2183 synthesizeGLError(GL_INVALID_VALUE, "disableVertexAttribArray", "index o
ut of range"); | 2183 synthesizeGLError(GL_INVALID_VALUE, "disableVertexAttribArray", "index o
ut of range"); |
2184 return; | 2184 return; |
2185 } | 2185 } |
2186 | 2186 |
| 2187 m_boundVertexArrayObject->setAttribEnabled(index, false); |
2187 contextGL()->DisableVertexAttribArray(index); | 2188 contextGL()->DisableVertexAttribArray(index); |
2188 } | 2189 } |
2189 | 2190 |
2190 bool WebGLRenderingContextBase::validateRenderingState(const char* functionName) | 2191 bool WebGLRenderingContextBase::validateRenderingState(const char* functionName) |
2191 { | 2192 { |
2192 // Command buffer will not error if no program is bound. | 2193 // Command buffer will not error if no program is bound. |
2193 if (!m_currentProgram) { | 2194 if (!m_currentProgram) { |
2194 synthesizeGLError(GL_INVALID_OPERATION, functionName, "no valid shader p
rogram in use"); | 2195 synthesizeGLError(GL_INVALID_OPERATION, functionName, "no valid shader p
rogram in use"); |
2195 return false; | 2196 return false; |
2196 } | 2197 } |
(...skipping 12 matching lines...) Expand all Loading... |
2209 return false; | 2210 return false; |
2210 } | 2211 } |
2211 return true; | 2212 return true; |
2212 } | 2213 } |
2213 | 2214 |
2214 void WebGLRenderingContextBase::drawArrays(GLenum mode, GLint first, GLsizei cou
nt) | 2215 void WebGLRenderingContextBase::drawArrays(GLenum mode, GLint first, GLsizei cou
nt) |
2215 { | 2216 { |
2216 if (!validateDrawArrays("drawArrays")) | 2217 if (!validateDrawArrays("drawArrays")) |
2217 return; | 2218 return; |
2218 | 2219 |
| 2220 if (!m_boundVertexArrayObject->isAllEnabledAttribBufferBound()) { |
| 2221 synthesizeGLError(GL_INVALID_OPERATION, "drawArrays", "no buffer is boun
d to enabled attribute"); |
| 2222 return; |
| 2223 } |
| 2224 |
2219 ScopedRGBEmulationColorMask emulationColorMask(contextGL(), m_colorMask, m_d
rawingBuffer.get()); | 2225 ScopedRGBEmulationColorMask emulationColorMask(contextGL(), m_colorMask, m_d
rawingBuffer.get()); |
2220 clearIfComposited(); | 2226 clearIfComposited(); |
2221 contextGL()->DrawArrays(mode, first, count); | 2227 contextGL()->DrawArrays(mode, first, count); |
2222 markContextChanged(CanvasChanged); | 2228 markContextChanged(CanvasChanged); |
2223 } | 2229 } |
2224 | 2230 |
2225 void WebGLRenderingContextBase::drawElements(GLenum mode, GLsizei count, GLenum
type, long long offset) | 2231 void WebGLRenderingContextBase::drawElements(GLenum mode, GLsizei count, GLenum
type, long long offset) |
2226 { | 2232 { |
2227 if (!validateDrawElements("drawElements", type, offset)) | 2233 if (!validateDrawElements("drawElements", type, offset)) |
2228 return; | 2234 return; |
2229 | 2235 |
| 2236 if (!m_boundVertexArrayObject->isAllEnabledAttribBufferBound()) { |
| 2237 synthesizeGLError(GL_INVALID_OPERATION, "drawElements", "no buffer is bo
und to enabled attribute"); |
| 2238 return; |
| 2239 } |
| 2240 |
2230 if (transformFeedbackActive() && !transformFeedbackPaused()) { | 2241 if (transformFeedbackActive() && !transformFeedbackPaused()) { |
2231 synthesizeGLError(GL_INVALID_OPERATION, "drawElements", "transform feedb
ack is active and not paused"); | 2242 synthesizeGLError(GL_INVALID_OPERATION, "drawElements", "transform feedb
ack is active and not paused"); |
2232 return; | 2243 return; |
2233 } | 2244 } |
2234 | 2245 |
2235 ScopedRGBEmulationColorMask emulationColorMask(contextGL(), m_colorMask, m_d
rawingBuffer.get()); | 2246 ScopedRGBEmulationColorMask emulationColorMask(contextGL(), m_colorMask, m_d
rawingBuffer.get()); |
2236 clearIfComposited(); | 2247 clearIfComposited(); |
2237 contextGL()->DrawElements(mode, count, type, reinterpret_cast<void*>(static_
cast<intptr_t>(offset))); | 2248 contextGL()->DrawElements(mode, count, type, reinterpret_cast<void*>(static_
cast<intptr_t>(offset))); |
2238 markContextChanged(CanvasChanged); | 2249 markContextChanged(CanvasChanged); |
2239 } | 2250 } |
2240 | 2251 |
2241 void WebGLRenderingContextBase::drawArraysInstancedANGLE(GLenum mode, GLint firs
t, GLsizei count, GLsizei primcount) | 2252 void WebGLRenderingContextBase::drawArraysInstancedANGLE(GLenum mode, GLint firs
t, GLsizei count, GLsizei primcount) |
2242 { | 2253 { |
2243 if (!validateDrawArrays("drawArraysInstancedANGLE")) | 2254 if (!validateDrawArrays("drawArraysInstancedANGLE")) |
2244 return; | 2255 return; |
2245 | 2256 |
| 2257 if (!m_boundVertexArrayObject->isAllEnabledAttribBufferBound()) { |
| 2258 synthesizeGLError(GL_INVALID_OPERATION, "drawArraysInstancedANGLE", "no
buffer is bound to enabled attribute"); |
| 2259 return; |
| 2260 } |
| 2261 |
2246 ScopedRGBEmulationColorMask emulationColorMask(contextGL(), m_colorMask, m_d
rawingBuffer.get()); | 2262 ScopedRGBEmulationColorMask emulationColorMask(contextGL(), m_colorMask, m_d
rawingBuffer.get()); |
2247 clearIfComposited(); | 2263 clearIfComposited(); |
2248 contextGL()->DrawArraysInstancedANGLE(mode, first, count, primcount); | 2264 contextGL()->DrawArraysInstancedANGLE(mode, first, count, primcount); |
2249 markContextChanged(CanvasChanged); | 2265 markContextChanged(CanvasChanged); |
2250 } | 2266 } |
2251 | 2267 |
2252 void WebGLRenderingContextBase::drawElementsInstancedANGLE(GLenum mode, GLsizei
count, GLenum type, long long offset, GLsizei primcount) | 2268 void WebGLRenderingContextBase::drawElementsInstancedANGLE(GLenum mode, GLsizei
count, GLenum type, long long offset, GLsizei primcount) |
2253 { | 2269 { |
2254 if (!validateDrawElements("drawElementsInstancedANGLE", type, offset)) | 2270 if (!validateDrawElements("drawElementsInstancedANGLE", type, offset)) |
2255 return; | 2271 return; |
2256 | 2272 |
| 2273 if (!m_boundVertexArrayObject->isAllEnabledAttribBufferBound()) { |
| 2274 synthesizeGLError(GL_INVALID_OPERATION, "drawElementsInstancedANGLE", "n
o buffer is bound to enabled attribute"); |
| 2275 return; |
| 2276 } |
| 2277 |
2257 ScopedRGBEmulationColorMask emulationColorMask(contextGL(), m_colorMask, m_d
rawingBuffer.get()); | 2278 ScopedRGBEmulationColorMask emulationColorMask(contextGL(), m_colorMask, m_d
rawingBuffer.get()); |
2258 clearIfComposited(); | 2279 clearIfComposited(); |
2259 contextGL()->DrawElementsInstancedANGLE(mode, count, type, reinterpret_cast<
void*>(static_cast<intptr_t>(offset)), primcount); | 2280 contextGL()->DrawElementsInstancedANGLE(mode, count, type, reinterpret_cast<
void*>(static_cast<intptr_t>(offset)), primcount); |
2260 markContextChanged(CanvasChanged); | 2281 markContextChanged(CanvasChanged); |
2261 } | 2282 } |
2262 | 2283 |
2263 void WebGLRenderingContextBase::enable(GLenum cap) | 2284 void WebGLRenderingContextBase::enable(GLenum cap) |
2264 { | 2285 { |
2265 if (isContextLost() || !validateCapability("enable", cap)) | 2286 if (isContextLost() || !validateCapability("enable", cap)) |
2266 return; | 2287 return; |
(...skipping 11 matching lines...) Expand all Loading... |
2278 | 2299 |
2279 void WebGLRenderingContextBase::enableVertexAttribArray(GLuint index) | 2300 void WebGLRenderingContextBase::enableVertexAttribArray(GLuint index) |
2280 { | 2301 { |
2281 if (isContextLost()) | 2302 if (isContextLost()) |
2282 return; | 2303 return; |
2283 if (index >= m_maxVertexAttribs) { | 2304 if (index >= m_maxVertexAttribs) { |
2284 synthesizeGLError(GL_INVALID_VALUE, "enableVertexAttribArray", "index ou
t of range"); | 2305 synthesizeGLError(GL_INVALID_VALUE, "enableVertexAttribArray", "index ou
t of range"); |
2285 return; | 2306 return; |
2286 } | 2307 } |
2287 | 2308 |
| 2309 m_boundVertexArrayObject->setAttribEnabled(index, true); |
2288 contextGL()->EnableVertexAttribArray(index); | 2310 contextGL()->EnableVertexAttribArray(index); |
2289 } | 2311 } |
2290 | 2312 |
2291 void WebGLRenderingContextBase::finish() | 2313 void WebGLRenderingContextBase::finish() |
2292 { | 2314 { |
2293 if (isContextLost()) | 2315 if (isContextLost()) |
2294 return; | 2316 return; |
2295 contextGL()->Flush(); // Intentionally a flush, not a finish. | 2317 contextGL()->Flush(); // Intentionally a flush, not a finish. |
2296 } | 2318 } |
2297 | 2319 |
(...skipping 4126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6424 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); | 6446 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); |
6425 } | 6447 } |
6426 | 6448 |
6427 void WebGLRenderingContextBase::restoreUnpackParameters() | 6449 void WebGLRenderingContextBase::restoreUnpackParameters() |
6428 { | 6450 { |
6429 if (m_unpackAlignment != 1) | 6451 if (m_unpackAlignment != 1) |
6430 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 6452 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); |
6431 } | 6453 } |
6432 | 6454 |
6433 } // namespace blink | 6455 } // namespace blink |
OLD | NEW |