| 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 2278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2289 if (!validateTextureBinding("generateMipmap", target)) | 2289 if (!validateTextureBinding("generateMipmap", target)) |
| 2290 return; | 2290 return; |
| 2291 contextGL()->GenerateMipmap(target); | 2291 contextGL()->GenerateMipmap(target); |
| 2292 } | 2292 } |
| 2293 | 2293 |
| 2294 WebGLActiveInfo* WebGLRenderingContextBase::getActiveAttrib(WebGLProgram* progra
m, GLuint index) | 2294 WebGLActiveInfo* WebGLRenderingContextBase::getActiveAttrib(WebGLProgram* progra
m, GLuint index) |
| 2295 { | 2295 { |
| 2296 if (isContextLost() || !validateWebGLObject("getActiveAttrib", program)) | 2296 if (isContextLost() || !validateWebGLObject("getActiveAttrib", program)) |
| 2297 return nullptr; | 2297 return nullptr; |
| 2298 WebGraphicsContext3D::ActiveInfo info; | 2298 WebGraphicsContext3D::ActiveInfo info; |
| 2299 GLuint programId = objectNonZero(program); |
| 2300 GLint maxNameLength = -1; |
| 2301 contextGL()->GetProgramiv(programId, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &maxNam
eLength); |
| 2302 if (maxNameLength < 0) |
| 2303 return nullptr; |
| 2304 if (maxNameLength == 0) { |
| 2305 synthesizeGLError(GL_INVALID_VALUE, "getActiveAttrib", "no active attrib
utes exist"); |
| 2306 return nullptr; |
| 2307 } |
| 2299 if (!webContext()->getActiveAttrib(objectOrZero(program), index, info)) | 2308 if (!webContext()->getActiveAttrib(objectOrZero(program), index, info)) |
| 2300 return nullptr; | 2309 return nullptr; |
| 2301 return WebGLActiveInfo::create(info.name, info.type, info.size); | 2310 return WebGLActiveInfo::create(info.name, info.type, info.size); |
| 2302 } | 2311 } |
| 2303 | 2312 |
| 2304 WebGLActiveInfo* WebGLRenderingContextBase::getActiveUniform(WebGLProgram* progr
am, GLuint index) | 2313 WebGLActiveInfo* WebGLRenderingContextBase::getActiveUniform(WebGLProgram* progr
am, GLuint index) |
| 2305 { | 2314 { |
| 2306 if (isContextLost() || !validateWebGLObject("getActiveUniform", program)) | 2315 if (isContextLost() || !validateWebGLObject("getActiveUniform", program)) |
| 2307 return nullptr; | 2316 return nullptr; |
| 2317 GLuint programId = objectNonZero(program); |
| 2318 GLint maxNameLength = -1; |
| 2319 contextGL()->GetProgramiv(programId, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxNameL
ength); |
| 2320 if (maxNameLength < 0) |
| 2321 return nullptr; |
| 2322 if (maxNameLength == 0) { |
| 2323 synthesizeGLError(GL_INVALID_VALUE, "getActiveUniform", "no active unifo
rms exist"); |
| 2324 return nullptr; |
| 2325 } |
| 2308 WebGraphicsContext3D::ActiveInfo info; | 2326 WebGraphicsContext3D::ActiveInfo info; |
| 2309 if (!webContext()->getActiveUniform(objectOrZero(program), index, info)) | 2327 if (!webContext()->getActiveUniform(programId, index, info)) |
| 2310 return nullptr; | 2328 return nullptr; |
| 2311 return WebGLActiveInfo::create(info.name, info.type, info.size); | 2329 return WebGLActiveInfo::create(info.name, info.type, info.size); |
| 2312 } | 2330 } |
| 2313 | 2331 |
| 2314 Nullable<HeapVector<Member<WebGLShader>>> WebGLRenderingContextBase::getAttached
Shaders(WebGLProgram* program) | 2332 Nullable<HeapVector<Member<WebGLShader>>> WebGLRenderingContextBase::getAttached
Shaders(WebGLProgram* program) |
| 2315 { | 2333 { |
| 2316 if (isContextLost() || !validateWebGLObject("getAttachedShaders", program)) | 2334 if (isContextLost() || !validateWebGLObject("getAttachedShaders", program)) |
| 2317 return nullptr; | 2335 return nullptr; |
| 2318 | 2336 |
| 2319 HeapVector<Member<WebGLShader>> shaderObjects; | 2337 HeapVector<Member<WebGLShader>> shaderObjects; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2332 GLint WebGLRenderingContextBase::getAttribLocation(WebGLProgram* program, const
String& name) | 2350 GLint WebGLRenderingContextBase::getAttribLocation(WebGLProgram* program, const
String& name) |
| 2333 { | 2351 { |
| 2334 if (isContextLost() || !validateWebGLObject("getAttribLocation", program)) | 2352 if (isContextLost() || !validateWebGLObject("getAttribLocation", program)) |
| 2335 return -1; | 2353 return -1; |
| 2336 if (!validateLocationLength("getAttribLocation", name)) | 2354 if (!validateLocationLength("getAttribLocation", name)) |
| 2337 return -1; | 2355 return -1; |
| 2338 if (!validateString("getAttribLocation", name)) | 2356 if (!validateString("getAttribLocation", name)) |
| 2339 return -1; | 2357 return -1; |
| 2340 if (isPrefixReserved(name)) | 2358 if (isPrefixReserved(name)) |
| 2341 return -1; | 2359 return -1; |
| 2342 if (!program->linkStatus()) { | 2360 if (!program->linkStatus(this)) { |
| 2343 synthesizeGLError(GL_INVALID_OPERATION, "getAttribLocation", "program no
t linked"); | 2361 synthesizeGLError(GL_INVALID_OPERATION, "getAttribLocation", "program no
t linked"); |
| 2344 return 0; | 2362 return 0; |
| 2345 } | 2363 } |
| 2346 return contextGL()->GetAttribLocation(objectOrZero(program), name.utf8().dat
a()); | 2364 return contextGL()->GetAttribLocation(objectOrZero(program), name.utf8().dat
a()); |
| 2347 } | 2365 } |
| 2348 | 2366 |
| 2349 bool WebGLRenderingContextBase::validateBufferTarget(const char* functionName, G
Lenum target) | 2367 bool WebGLRenderingContextBase::validateBufferTarget(const char* functionName, G
Lenum target) |
| 2350 { | 2368 { |
| 2351 switch (target) { | 2369 switch (target) { |
| 2352 case GL_ARRAY_BUFFER: | 2370 case GL_ARRAY_BUFFER: |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2394 WebGraphicsContext3D::Attributes attrs = drawingBuffer()->getActualAttribute
s(); | 2412 WebGraphicsContext3D::Attributes attrs = drawingBuffer()->getActualAttribute
s(); |
| 2395 if (m_requestedAttributes.depth() && !attrs.depth) | 2413 if (m_requestedAttributes.depth() && !attrs.depth) |
| 2396 result.get().setDepth(false); | 2414 result.get().setDepth(false); |
| 2397 if (m_requestedAttributes.stencil() && !attrs.stencil) | 2415 if (m_requestedAttributes.stencil() && !attrs.stencil) |
| 2398 result.get().setStencil(false); | 2416 result.get().setStencil(false); |
| 2399 result.get().setAntialias(drawingBuffer()->multisample()); | 2417 result.get().setAntialias(drawingBuffer()->multisample()); |
| 2400 } | 2418 } |
| 2401 | 2419 |
| 2402 GLenum WebGLRenderingContextBase::getError() | 2420 GLenum WebGLRenderingContextBase::getError() |
| 2403 { | 2421 { |
| 2404 if (m_lostContextErrors.size()) { | 2422 if (!m_lostContextErrors.isEmpty()) { |
| 2405 GLenum err = m_lostContextErrors.first(); | 2423 GLenum error = m_lostContextErrors.first(); |
| 2406 m_lostContextErrors.remove(0); | 2424 m_lostContextErrors.remove(0); |
| 2407 return err; | 2425 return error; |
| 2408 } | 2426 } |
| 2409 | 2427 |
| 2410 if (isContextLost()) | 2428 if (isContextLost()) |
| 2411 return GL_NO_ERROR; | 2429 return GL_NO_ERROR; |
| 2412 | 2430 |
| 2413 return webContext()->getError(); | 2431 if (!m_syntheticErrors.isEmpty()) { |
| 2432 GLenum error = m_syntheticErrors.first(); |
| 2433 m_syntheticErrors.remove(0); |
| 2434 return error; |
| 2435 } |
| 2436 |
| 2437 return contextGL()->GetError(); |
| 2414 } | 2438 } |
| 2415 | 2439 |
| 2416 const char* const* WebGLRenderingContextBase::ExtensionTracker::prefixes() const | 2440 const char* const* WebGLRenderingContextBase::ExtensionTracker::prefixes() const |
| 2417 { | 2441 { |
| 2418 static const char* const unprefixed[] = { "", 0, }; | 2442 static const char* const unprefixed[] = { "", 0, }; |
| 2419 return m_prefixes ? m_prefixes : unprefixed; | 2443 return m_prefixes ? m_prefixes : unprefixed; |
| 2420 } | 2444 } |
| 2421 | 2445 |
| 2422 bool WebGLRenderingContextBase::ExtensionTracker::matchesNameWithPrefixes(const
String& name) const | 2446 bool WebGLRenderingContextBase::ExtensionTracker::matchesNameWithPrefixes(const
String& name) const |
| 2423 { | 2447 { |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2799 return ScriptValue::createNull(scriptState); | 2823 return ScriptValue::createNull(scriptState); |
| 2800 | 2824 |
| 2801 GLint value = 0; | 2825 GLint value = 0; |
| 2802 switch (pname) { | 2826 switch (pname) { |
| 2803 case GL_DELETE_STATUS: | 2827 case GL_DELETE_STATUS: |
| 2804 return WebGLAny(scriptState, program->isDeleted()); | 2828 return WebGLAny(scriptState, program->isDeleted()); |
| 2805 case GL_VALIDATE_STATUS: | 2829 case GL_VALIDATE_STATUS: |
| 2806 contextGL()->GetProgramiv(objectOrZero(program), pname, &value); | 2830 contextGL()->GetProgramiv(objectOrZero(program), pname, &value); |
| 2807 return WebGLAny(scriptState, static_cast<bool>(value)); | 2831 return WebGLAny(scriptState, static_cast<bool>(value)); |
| 2808 case GL_LINK_STATUS: | 2832 case GL_LINK_STATUS: |
| 2809 return WebGLAny(scriptState, program->linkStatus()); | 2833 return WebGLAny(scriptState, program->linkStatus(this)); |
| 2810 case GL_ACTIVE_UNIFORM_BLOCKS: | 2834 case GL_ACTIVE_UNIFORM_BLOCKS: |
| 2811 case GL_TRANSFORM_FEEDBACK_VARYINGS: | 2835 case GL_TRANSFORM_FEEDBACK_VARYINGS: |
| 2812 if (!isWebGL2OrHigher()) { | 2836 if (!isWebGL2OrHigher()) { |
| 2813 synthesizeGLError(GL_INVALID_ENUM, "getProgramParameter", "invalid p
arameter name"); | 2837 synthesizeGLError(GL_INVALID_ENUM, "getProgramParameter", "invalid p
arameter name"); |
| 2814 return ScriptValue::createNull(scriptState); | 2838 return ScriptValue::createNull(scriptState); |
| 2815 } | 2839 } |
| 2816 case GL_ATTACHED_SHADERS: | 2840 case GL_ATTACHED_SHADERS: |
| 2817 case GL_ACTIVE_ATTRIBUTES: | 2841 case GL_ACTIVE_ATTRIBUTES: |
| 2818 case GL_ACTIVE_UNIFORMS: | 2842 case GL_ACTIVE_UNIFORMS: |
| 2819 contextGL()->GetProgramiv(objectOrZero(program), pname, &value); | 2843 contextGL()->GetProgramiv(objectOrZero(program), pname, &value); |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3201 WebGLUniformLocation* WebGLRenderingContextBase::getUniformLocation(WebGLProgram
* program, const String& name) | 3225 WebGLUniformLocation* WebGLRenderingContextBase::getUniformLocation(WebGLProgram
* program, const String& name) |
| 3202 { | 3226 { |
| 3203 if (isContextLost() || !validateWebGLObject("getUniformLocation", program)) | 3227 if (isContextLost() || !validateWebGLObject("getUniformLocation", program)) |
| 3204 return nullptr; | 3228 return nullptr; |
| 3205 if (!validateLocationLength("getUniformLocation", name)) | 3229 if (!validateLocationLength("getUniformLocation", name)) |
| 3206 return nullptr; | 3230 return nullptr; |
| 3207 if (!validateString("getUniformLocation", name)) | 3231 if (!validateString("getUniformLocation", name)) |
| 3208 return nullptr; | 3232 return nullptr; |
| 3209 if (isPrefixReserved(name)) | 3233 if (isPrefixReserved(name)) |
| 3210 return nullptr; | 3234 return nullptr; |
| 3211 if (!program->linkStatus()) { | 3235 if (!program->linkStatus(this)) { |
| 3212 synthesizeGLError(GL_INVALID_OPERATION, "getUniformLocation", "program n
ot linked"); | 3236 synthesizeGLError(GL_INVALID_OPERATION, "getUniformLocation", "program n
ot linked"); |
| 3213 return nullptr; | 3237 return nullptr; |
| 3214 } | 3238 } |
| 3215 GLint uniformLocation = contextGL()->GetUniformLocation(objectOrZero(program
), name.utf8().data()); | 3239 GLint uniformLocation = contextGL()->GetUniformLocation(objectOrZero(program
), name.utf8().data()); |
| 3216 if (uniformLocation == -1) | 3240 if (uniformLocation == -1) |
| 3217 return nullptr; | 3241 return nullptr; |
| 3218 return WebGLUniformLocation::create(program, uniformLocation); | 3242 return WebGLUniformLocation::create(program, uniformLocation); |
| 3219 } | 3243 } |
| 3220 | 3244 |
| 3221 ScriptValue WebGLRenderingContextBase::getVertexAttrib(ScriptState* scriptState,
GLuint index, GLenum pname) | 3245 ScriptValue WebGLRenderingContextBase::getVertexAttrib(ScriptState* scriptState,
GLuint index, GLenum pname) |
| (...skipping 1550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4772 contextGL()->UniformMatrix4fv(location->location(), v.size() >> 4, transpose
, v.data()); | 4796 contextGL()->UniformMatrix4fv(location->location(), v.size() >> 4, transpose
, v.data()); |
| 4773 } | 4797 } |
| 4774 | 4798 |
| 4775 void WebGLRenderingContextBase::useProgram(ScriptState* scriptState, WebGLProgra
m* program) | 4799 void WebGLRenderingContextBase::useProgram(ScriptState* scriptState, WebGLProgra
m* program) |
| 4776 { | 4800 { |
| 4777 bool deleted; | 4801 bool deleted; |
| 4778 if (!checkObjectToBeBound("useProgram", program, deleted)) | 4802 if (!checkObjectToBeBound("useProgram", program, deleted)) |
| 4779 return; | 4803 return; |
| 4780 if (deleted) | 4804 if (deleted) |
| 4781 program = 0; | 4805 program = 0; |
| 4782 if (program && !program->linkStatus()) { | 4806 if (program && !program->linkStatus(this)) { |
| 4783 synthesizeGLError(GL_INVALID_OPERATION, "useProgram", "program not valid
"); | 4807 synthesizeGLError(GL_INVALID_OPERATION, "useProgram", "program not valid
"); |
| 4784 return; | 4808 return; |
| 4785 } | 4809 } |
| 4786 | 4810 |
| 4787 if (transformFeedbackActive() && !transformFeedbackPaused()) { | 4811 if (transformFeedbackActive() && !transformFeedbackPaused()) { |
| 4788 synthesizeGLError(GL_INVALID_OPERATION, "useProgram", "transform feedbac
k is active and not paused"); | 4812 synthesizeGLError(GL_INVALID_OPERATION, "useProgram", "transform feedbac
k is active and not paused"); |
| 4789 return; | 4813 return; |
| 4790 } | 4814 } |
| 4791 | 4815 |
| 4792 if (m_currentProgram != program) { | 4816 if (m_currentProgram != program) { |
| (...skipping 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6055 } // namespace | 6079 } // namespace |
| 6056 | 6080 |
| 6057 void WebGLRenderingContextBase::synthesizeGLError(GLenum error, const char* func
tionName, const char* description, ConsoleDisplayPreference display) | 6081 void WebGLRenderingContextBase::synthesizeGLError(GLenum error, const char* func
tionName, const char* description, ConsoleDisplayPreference display) |
| 6058 { | 6082 { |
| 6059 String errorType = GetErrorString(error); | 6083 String errorType = GetErrorString(error); |
| 6060 if (m_synthesizedErrorsToConsole && display == DisplayInConsole) { | 6084 if (m_synthesizedErrorsToConsole && display == DisplayInConsole) { |
| 6061 String message = String("WebGL: ") + errorType + ": " + String(function
Name) + ": " + String(description); | 6085 String message = String("WebGL: ") + errorType + ": " + String(function
Name) + ": " + String(description); |
| 6062 printGLErrorToConsole(message); | 6086 printGLErrorToConsole(message); |
| 6063 } | 6087 } |
| 6064 if (!isContextLost()) { | 6088 if (!isContextLost()) { |
| 6065 webContext()->synthesizeGLError(error); | 6089 if (!m_syntheticErrors.contains(error)) |
| 6090 m_syntheticErrors.append(error); |
| 6066 } else { | 6091 } else { |
| 6067 if (m_lostContextErrors.find(error) == WTF::kNotFound) | 6092 if (!m_lostContextErrors.contains(error)) |
| 6068 m_lostContextErrors.append(error); | 6093 m_lostContextErrors.append(error); |
| 6069 } | 6094 } |
| 6070 InspectorInstrumentation::didFireWebGLError(canvas(), errorType); | 6095 InspectorInstrumentation::didFireWebGLError(canvas(), errorType); |
| 6071 } | 6096 } |
| 6072 | 6097 |
| 6073 void WebGLRenderingContextBase::emitGLWarning(const char* functionName, const ch
ar* description) | 6098 void WebGLRenderingContextBase::emitGLWarning(const char* functionName, const ch
ar* description) |
| 6074 { | 6099 { |
| 6075 if (m_synthesizedErrorsToConsole) { | 6100 if (m_synthesizedErrorsToConsole) { |
| 6076 String message = String("WebGL: ") + String(functionName) + ": " + Strin
g(description); | 6101 String message = String("WebGL: ") + String(functionName) + ": " + Strin
g(description); |
| 6077 printGLErrorToConsole(message); | 6102 printGLErrorToConsole(message); |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6296 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); | 6321 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| 6297 } | 6322 } |
| 6298 | 6323 |
| 6299 void WebGLRenderingContextBase::restoreUnpackParameters() | 6324 void WebGLRenderingContextBase::restoreUnpackParameters() |
| 6300 { | 6325 { |
| 6301 if (m_unpackAlignment != 1) | 6326 if (m_unpackAlignment != 1) |
| 6302 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 6327 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); |
| 6303 } | 6328 } |
| 6304 | 6329 |
| 6305 } // namespace blink | 6330 } // namespace blink |
| OLD | NEW |