| 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 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 , m_isWebGL2InternalFormatsCopyTexImageAdded(false) | 852 , m_isWebGL2InternalFormatsCopyTexImageAdded(false) |
| 853 , m_isOESTextureFloatFormatsTypesAdded(false) | 853 , m_isOESTextureFloatFormatsTypesAdded(false) |
| 854 , m_isOESTextureHalfFloatFormatsTypesAdded(false) | 854 , m_isOESTextureHalfFloatFormatsTypesAdded(false) |
| 855 , m_isWebGLDepthTextureFormatsTypesAdded(false) | 855 , m_isWebGLDepthTextureFormatsTypesAdded(false) |
| 856 , m_isEXTsRGBFormatsTypesAdded(false) | 856 , m_isEXTsRGBFormatsTypesAdded(false) |
| 857 #if !ENABLE(OILPAN) | 857 #if !ENABLE(OILPAN) |
| 858 , m_weakPtrFactory(this) | 858 , m_weakPtrFactory(this) |
| 859 #endif | 859 #endif |
| 860 { | 860 { |
| 861 ASSERT(context); | 861 ASSERT(context); |
| 862 gpu::gles2::GLES2Interface* gl = context->getGLES2Interface(); |
| 862 | 863 |
| 863 m_contextGroup = WebGLContextGroup::create(); | 864 m_contextGroup = WebGLContextGroup::create(); |
| 864 m_contextGroup->addContext(this); | 865 m_contextGroup->addContext(this); |
| 865 | 866 |
| 866 m_maxViewportDims[0] = m_maxViewportDims[1] = 0; | 867 m_maxViewportDims[0] = m_maxViewportDims[1] = 0; |
| 867 context->getIntegerv(GL_MAX_VIEWPORT_DIMS, m_maxViewportDims); | 868 gl->GetIntegerv(GL_MAX_VIEWPORT_DIMS, m_maxViewportDims); |
| 868 | 869 |
| 869 RefPtr<DrawingBuffer> buffer = createDrawingBuffer(context); | 870 RefPtr<DrawingBuffer> buffer = createDrawingBuffer(context); |
| 870 if (!buffer) { | 871 if (!buffer) { |
| 871 m_contextLostMode = SyntheticLostContext; | 872 m_contextLostMode = SyntheticLostContext; |
| 872 return; | 873 return; |
| 873 } | 874 } |
| 874 | 875 |
| 875 m_drawingBuffer = buffer.release(); | 876 m_drawingBuffer = buffer.release(); |
| 876 m_drawingBuffer->addNewMailboxCallback(WTF::bind(&WebGLRenderingContextBase:
:notifyCanvasContextChanged, createWeakThisPointer())); | 877 m_drawingBuffer->addNewMailboxCallback(WTF::bind(&WebGLRenderingContextBase:
:notifyCanvasContextChanged, createWeakThisPointer())); |
| 877 drawingBuffer()->bind(GL_FRAMEBUFFER); | 878 drawingBuffer()->bind(GL_FRAMEBUFFER); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 m_stencilFuncMaskBack = 0xFFFFFFFF; | 928 m_stencilFuncMaskBack = 0xFFFFFFFF; |
| 928 m_numGLErrorsToConsoleAllowed = maxGLErrorsAllowedToConsole; | 929 m_numGLErrorsToConsoleAllowed = maxGLErrorsAllowedToConsole; |
| 929 | 930 |
| 930 m_clearColor[0] = m_clearColor[1] = m_clearColor[2] = m_clearColor[3] = 0; | 931 m_clearColor[0] = m_clearColor[1] = m_clearColor[2] = m_clearColor[3] = 0; |
| 931 m_scissorEnabled = false; | 932 m_scissorEnabled = false; |
| 932 m_clearDepth = 1; | 933 m_clearDepth = 1; |
| 933 m_clearStencil = 0; | 934 m_clearStencil = 0; |
| 934 m_colorMask[0] = m_colorMask[1] = m_colorMask[2] = m_colorMask[3] = true; | 935 m_colorMask[0] = m_colorMask[1] = m_colorMask[2] = m_colorMask[3] = true; |
| 935 | 936 |
| 936 GLint numCombinedTextureImageUnits = 0; | 937 GLint numCombinedTextureImageUnits = 0; |
| 937 webContext()->getIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &numCombinedT
extureImageUnits); | 938 contextGL()->GetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &numCombinedTe
xtureImageUnits); |
| 938 m_textureUnits.clear(); | 939 m_textureUnits.clear(); |
| 939 m_textureUnits.resize(numCombinedTextureImageUnits); | 940 m_textureUnits.resize(numCombinedTextureImageUnits); |
| 940 | 941 |
| 941 GLint numVertexAttribs = 0; | 942 GLint numVertexAttribs = 0; |
| 942 webContext()->getIntegerv(GL_MAX_VERTEX_ATTRIBS, &numVertexAttribs); | 943 contextGL()->GetIntegerv(GL_MAX_VERTEX_ATTRIBS, &numVertexAttribs); |
| 943 m_maxVertexAttribs = numVertexAttribs; | 944 m_maxVertexAttribs = numVertexAttribs; |
| 944 | 945 |
| 945 m_maxTextureSize = 0; | 946 m_maxTextureSize = 0; |
| 946 webContext()->getIntegerv(GL_MAX_TEXTURE_SIZE, &m_maxTextureSize); | 947 contextGL()->GetIntegerv(GL_MAX_TEXTURE_SIZE, &m_maxTextureSize); |
| 947 m_maxTextureLevel = WebGLTexture::computeLevelCount(m_maxTextureSize, m_maxT
extureSize, 1); | 948 m_maxTextureLevel = WebGLTexture::computeLevelCount(m_maxTextureSize, m_maxT
extureSize, 1); |
| 948 m_maxCubeMapTextureSize = 0; | 949 m_maxCubeMapTextureSize = 0; |
| 949 webContext()->getIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &m_maxCubeMapTexture
Size); | 950 contextGL()->GetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &m_maxCubeMapTextureS
ize); |
| 950 m_max3DTextureSize = 0; | 951 m_max3DTextureSize = 0; |
| 951 m_max3DTextureLevel = 0; | 952 m_max3DTextureLevel = 0; |
| 952 m_maxArrayTextureLayers = 0; | 953 m_maxArrayTextureLayers = 0; |
| 953 if (isWebGL2OrHigher()) { | 954 if (isWebGL2OrHigher()) { |
| 954 webContext()->getIntegerv(GL_MAX_3D_TEXTURE_SIZE, &m_max3DTextureSize); | 955 contextGL()->GetIntegerv(GL_MAX_3D_TEXTURE_SIZE, &m_max3DTextureSize); |
| 955 m_max3DTextureLevel = WebGLTexture::computeLevelCount(m_max3DTextureSize
, m_max3DTextureSize, m_max3DTextureSize); | 956 m_max3DTextureLevel = WebGLTexture::computeLevelCount(m_max3DTextureSize
, m_max3DTextureSize, m_max3DTextureSize); |
| 956 webContext()->getIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &m_maxArrayTextur
eLayers); | 957 contextGL()->GetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &m_maxArrayTexture
Layers); |
| 957 } | 958 } |
| 958 m_maxCubeMapTextureLevel = WebGLTexture::computeLevelCount(m_maxCubeMapTextu
reSize, m_maxCubeMapTextureSize, 1); | 959 m_maxCubeMapTextureLevel = WebGLTexture::computeLevelCount(m_maxCubeMapTextu
reSize, m_maxCubeMapTextureSize, 1); |
| 959 m_maxRenderbufferSize = 0; | 960 m_maxRenderbufferSize = 0; |
| 960 webContext()->getIntegerv(GL_MAX_RENDERBUFFER_SIZE, &m_maxRenderbufferSize); | 961 contextGL()->GetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &m_maxRenderbufferSize); |
| 961 | 962 |
| 962 // These two values from EXT_draw_buffers are lazily queried. | 963 // These two values from EXT_draw_buffers are lazily queried. |
| 963 m_maxDrawBuffers = 0; | 964 m_maxDrawBuffers = 0; |
| 964 m_maxColorAttachments = 0; | 965 m_maxColorAttachments = 0; |
| 965 | 966 |
| 966 m_backDrawBuffer = GL_BACK; | 967 m_backDrawBuffer = GL_BACK; |
| 967 | 968 |
| 968 m_readBufferOfDefaultFramebuffer = GL_BACK; | 969 m_readBufferOfDefaultFramebuffer = GL_BACK; |
| 969 | 970 |
| 970 m_defaultVertexArrayObject = WebGLVertexArrayObject::create(this, WebGLVerte
xArrayObjectBase::VaoTypeDefault); | 971 m_defaultVertexArrayObject = WebGLVertexArrayObject::create(this, WebGLVerte
xArrayObjectBase::VaoTypeDefault); |
| 971 addContextObject(m_defaultVertexArrayObject.get()); | 972 addContextObject(m_defaultVertexArrayObject.get()); |
| 972 // It's not convenient or necessary to pass a ScriptState this far down; whi
le one is available | 973 // It's not convenient or necessary to pass a ScriptState this far down; whi
le one is available |
| 973 // during WebGLRenderingContext construction, the wrapper for the context it
self hasn't been | 974 // during WebGLRenderingContext construction, the wrapper for the context it
self hasn't been |
| 974 // created yet. It's simpler to instead lazily instantiate and preserve the
JavaScript wrapper | 975 // created yet. It's simpler to instead lazily instantiate and preserve the
JavaScript wrapper |
| 975 // for the default VAO. (This object is never exposed to JavaScript, but we
need to link other | 976 // for the default VAO. (This object is never exposed to JavaScript, but we
need to link other |
| 976 // JavaScript wrappers to it.) | 977 // JavaScript wrappers to it.) |
| 977 m_preservedDefaultVAOObjectWrapper = false; | 978 m_preservedDefaultVAOObjectWrapper = false; |
| 978 m_boundVertexArrayObject = m_defaultVertexArrayObject; | 979 m_boundVertexArrayObject = m_defaultVertexArrayObject; |
| 979 | 980 |
| 980 m_vertexAttribType.resize(m_maxVertexAttribs); | 981 m_vertexAttribType.resize(m_maxVertexAttribs); |
| 981 | 982 |
| 982 webContext()->viewport(0, 0, drawingBufferWidth(), drawingBufferHeight()); | 983 webContext()->viewport(0, 0, drawingBufferWidth(), drawingBufferHeight()); |
| 983 webContext()->scissor(0, 0, drawingBufferWidth(), drawingBufferHeight()); | 984 contextGL()->Scissor(0, 0, drawingBufferWidth(), drawingBufferHeight()); |
| 984 | 985 |
| 985 m_contextLostCallbackAdapter = WebGLRenderingContextLostCallback::create(thi
s); | 986 m_contextLostCallbackAdapter = WebGLRenderingContextLostCallback::create(thi
s); |
| 986 m_errorMessageCallbackAdapter = WebGLRenderingContextErrorMessageCallback::c
reate(this); | 987 m_errorMessageCallbackAdapter = WebGLRenderingContextErrorMessageCallback::c
reate(this); |
| 987 | 988 |
| 988 webContext()->setContextLostCallback(m_contextLostCallbackAdapter.get()); | 989 webContext()->setContextLostCallback(m_contextLostCallbackAdapter.get()); |
| 989 webContext()->setErrorMessageCallback(m_errorMessageCallbackAdapter.get()); | 990 webContext()->setErrorMessageCallback(m_errorMessageCallbackAdapter.get()); |
| 990 | 991 |
| 991 // This ensures that the context has a valid "lastFlushID" and won't be mist
akenly identified as the "least recently used" context. | 992 // This ensures that the context has a valid "lastFlushID" and won't be mist
akenly identified as the "least recently used" context. |
| 992 webContext()->flush(); | 993 contextGL()->Flush(); |
| 993 | 994 |
| 994 for (int i = 0; i < WebGLExtensionNameCount; ++i) | 995 for (int i = 0; i < WebGLExtensionNameCount; ++i) |
| 995 m_extensionEnabled[i] = false; | 996 m_extensionEnabled[i] = false; |
| 996 | 997 |
| 997 m_isWebGL2FormatsTypesAdded = false; | 998 m_isWebGL2FormatsTypesAdded = false; |
| 998 m_isWebGL2InternalFormatsCopyTexImageAdded = false; | 999 m_isWebGL2InternalFormatsCopyTexImageAdded = false; |
| 999 m_isOESTextureFloatFormatsTypesAdded = false; | 1000 m_isOESTextureFloatFormatsTypesAdded = false; |
| 1000 m_isOESTextureHalfFloatFormatsTypesAdded = false; | 1001 m_isOESTextureHalfFloatFormatsTypesAdded = false; |
| 1001 m_isWebGLDepthTextureFormatsTypesAdded = false; | 1002 m_isWebGLDepthTextureFormatsTypesAdded = false; |
| 1002 m_isEXTsRGBFormatsTypesAdded = false; | 1003 m_isEXTsRGBFormatsTypesAdded = false; |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1171 contextGL()->ClearDepthf(1.0f); | 1172 contextGL()->ClearDepthf(1.0f); |
| 1172 clearMask |= GL_DEPTH_BUFFER_BIT; | 1173 clearMask |= GL_DEPTH_BUFFER_BIT; |
| 1173 contextGL()->DepthMask(true); | 1174 contextGL()->DepthMask(true); |
| 1174 } | 1175 } |
| 1175 if (contextAttributes.get().stencil() || drawingBuffer()->hasImplicitStencil
Buffer()) { | 1176 if (contextAttributes.get().stencil() || drawingBuffer()->hasImplicitStencil
Buffer()) { |
| 1176 if (combinedClear && (mask & GL_STENCIL_BUFFER_BIT)) | 1177 if (combinedClear && (mask & GL_STENCIL_BUFFER_BIT)) |
| 1177 contextGL()->ClearStencil(m_clearStencil & m_stencilMask); | 1178 contextGL()->ClearStencil(m_clearStencil & m_stencilMask); |
| 1178 else | 1179 else |
| 1179 contextGL()->ClearStencil(0); | 1180 contextGL()->ClearStencil(0); |
| 1180 clearMask |= GL_STENCIL_BUFFER_BIT; | 1181 clearMask |= GL_STENCIL_BUFFER_BIT; |
| 1181 webContext()->stencilMaskSeparate(GL_FRONT, 0xFFFFFFFF); | 1182 contextGL()->StencilMaskSeparate(GL_FRONT, 0xFFFFFFFF); |
| 1182 } | 1183 } |
| 1183 | 1184 |
| 1184 drawingBuffer()->clearFramebuffers(clearMask); | 1185 drawingBuffer()->clearFramebuffers(clearMask); |
| 1185 | 1186 |
| 1186 restoreStateAfterClear(); | 1187 restoreStateAfterClear(); |
| 1187 drawingBuffer()->restoreFramebufferBindings(); | 1188 drawingBuffer()->restoreFramebufferBindings(); |
| 1188 drawingBuffer()->setBufferClearNeeded(false); | 1189 drawingBuffer()->setBufferClearNeeded(false); |
| 1189 | 1190 |
| 1190 return combinedClear ? CombinedClear : JustClear; | 1191 return combinedClear ? CombinedClear : JustClear; |
| 1191 } | 1192 } |
| 1192 | 1193 |
| 1193 void WebGLRenderingContextBase::restoreStateAfterClear() | 1194 void WebGLRenderingContextBase::restoreStateAfterClear() |
| 1194 { | 1195 { |
| 1195 if (isContextLost()) | 1196 if (isContextLost()) |
| 1196 return; | 1197 return; |
| 1197 | 1198 |
| 1198 // Restore the state that the context set. | 1199 // Restore the state that the context set. |
| 1199 if (m_scissorEnabled) | 1200 if (m_scissorEnabled) |
| 1200 contextGL()->Enable(GL_SCISSOR_TEST); | 1201 contextGL()->Enable(GL_SCISSOR_TEST); |
| 1201 contextGL()->ClearColor(m_clearColor[0], m_clearColor[1], | 1202 contextGL()->ClearColor(m_clearColor[0], m_clearColor[1], |
| 1202 m_clearColor[2], m_clearColor[3]); | 1203 m_clearColor[2], m_clearColor[3]); |
| 1203 contextGL()->ColorMask(m_colorMask[0], m_colorMask[1], | 1204 contextGL()->ColorMask(m_colorMask[0], m_colorMask[1], |
| 1204 m_colorMask[2], m_colorMask[3]); | 1205 m_colorMask[2], m_colorMask[3]); |
| 1205 contextGL()->ClearDepthf(m_clearDepth); | 1206 contextGL()->ClearDepthf(m_clearDepth); |
| 1206 contextGL()->ClearStencil(m_clearStencil); | 1207 contextGL()->ClearStencil(m_clearStencil); |
| 1207 webContext()->stencilMaskSeparate(GL_FRONT, m_stencilMask); | 1208 contextGL()->StencilMaskSeparate(GL_FRONT, m_stencilMask); |
| 1208 contextGL()->DepthMask(m_depthMask); | 1209 contextGL()->DepthMask(m_depthMask); |
| 1209 } | 1210 } |
| 1210 | 1211 |
| 1211 void WebGLRenderingContextBase::markLayerComposited() | 1212 void WebGLRenderingContextBase::markLayerComposited() |
| 1212 { | 1213 { |
| 1213 if (!isContextLost()) | 1214 if (!isContextLost()) |
| 1214 drawingBuffer()->setBufferClearNeeded(true); | 1215 drawingBuffer()->setBufferClearNeeded(true); |
| 1215 } | 1216 } |
| 1216 | 1217 |
| 1217 void WebGLRenderingContextBase::setIsHidden(bool hidden) | 1218 void WebGLRenderingContextBase::setIsHidden(bool hidden) |
| (...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2178 return; | 2179 return; |
| 2179 } | 2180 } |
| 2180 | 2181 |
| 2181 contextGL()->EnableVertexAttribArray(index); | 2182 contextGL()->EnableVertexAttribArray(index); |
| 2182 } | 2183 } |
| 2183 | 2184 |
| 2184 void WebGLRenderingContextBase::finish() | 2185 void WebGLRenderingContextBase::finish() |
| 2185 { | 2186 { |
| 2186 if (isContextLost()) | 2187 if (isContextLost()) |
| 2187 return; | 2188 return; |
| 2188 webContext()->flush(); // Intentionally a flush, not a finish. | 2189 contextGL()->Flush(); // Intentionally a flush, not a finish. |
| 2189 } | 2190 } |
| 2190 | 2191 |
| 2191 void WebGLRenderingContextBase::flush() | 2192 void WebGLRenderingContextBase::flush() |
| 2192 { | 2193 { |
| 2193 if (isContextLost()) | 2194 if (isContextLost()) |
| 2194 return; | 2195 return; |
| 2195 webContext()->flush(); | 2196 contextGL()->Flush(); |
| 2196 } | 2197 } |
| 2197 | 2198 |
| 2198 void WebGLRenderingContextBase::framebufferRenderbuffer(ScriptState* scriptState
, GLenum target, GLenum attachment, GLenum renderbuffertarget, WebGLRenderbuffer
* buffer) | 2199 void WebGLRenderingContextBase::framebufferRenderbuffer(ScriptState* scriptState
, GLenum target, GLenum attachment, GLenum renderbuffertarget, WebGLRenderbuffer
* buffer) |
| 2199 { | 2200 { |
| 2200 if (isContextLost() || !validateFramebufferFuncParameters("framebufferRender
buffer", target, attachment)) | 2201 if (isContextLost() || !validateFramebufferFuncParameters("framebufferRender
buffer", target, attachment)) |
| 2201 return; | 2202 return; |
| 2202 if (renderbuffertarget != GL_RENDERBUFFER) { | 2203 if (renderbuffertarget != GL_RENDERBUFFER) { |
| 2203 synthesizeGLError(GL_INVALID_ENUM, "framebufferRenderbuffer", "invalid t
arget"); | 2204 synthesizeGLError(GL_INVALID_ENUM, "framebufferRenderbuffer", "invalid t
arget"); |
| 2204 return; | 2205 return; |
| 2205 } | 2206 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2264 framebufferBinding->setAttachmentForBoundFramebuffer(target, attachment,
textarget, texture, level, 0); | 2265 framebufferBinding->setAttachmentForBoundFramebuffer(target, attachment,
textarget, texture, level, 0); |
| 2265 preserveObjectWrapper(scriptState, framebufferBinding, "attachment", att
achment, texture); | 2266 preserveObjectWrapper(scriptState, framebufferBinding, "attachment", att
achment, texture); |
| 2266 } | 2267 } |
| 2267 applyStencilTest(); | 2268 applyStencilTest(); |
| 2268 } | 2269 } |
| 2269 | 2270 |
| 2270 void WebGLRenderingContextBase::frontFace(GLenum mode) | 2271 void WebGLRenderingContextBase::frontFace(GLenum mode) |
| 2271 { | 2272 { |
| 2272 if (isContextLost()) | 2273 if (isContextLost()) |
| 2273 return; | 2274 return; |
| 2274 webContext()->frontFace(mode); | 2275 contextGL()->FrontFace(mode); |
| 2275 } | 2276 } |
| 2276 | 2277 |
| 2277 void WebGLRenderingContextBase::generateMipmap(GLenum target) | 2278 void WebGLRenderingContextBase::generateMipmap(GLenum target) |
| 2278 { | 2279 { |
| 2279 if (isContextLost()) | 2280 if (isContextLost()) |
| 2280 return; | 2281 return; |
| 2281 if (!validateTextureBinding("generateMipmap", target)) | 2282 if (!validateTextureBinding("generateMipmap", target)) |
| 2282 return; | 2283 return; |
| 2283 webContext()->generateMipmap(target); | 2284 contextGL()->GenerateMipmap(target); |
| 2284 } | 2285 } |
| 2285 | 2286 |
| 2286 WebGLActiveInfo* WebGLRenderingContextBase::getActiveAttrib(WebGLProgram* progra
m, GLuint index) | 2287 WebGLActiveInfo* WebGLRenderingContextBase::getActiveAttrib(WebGLProgram* progra
m, GLuint index) |
| 2287 { | 2288 { |
| 2288 if (isContextLost() || !validateWebGLObject("getActiveAttrib", program)) | 2289 if (isContextLost() || !validateWebGLObject("getActiveAttrib", program)) |
| 2289 return nullptr; | 2290 return nullptr; |
| 2290 WebGraphicsContext3D::ActiveInfo info; | 2291 WebGraphicsContext3D::ActiveInfo info; |
| 2291 if (!webContext()->getActiveAttrib(objectOrZero(program), index, info)) | 2292 if (!webContext()->getActiveAttrib(objectOrZero(program), index, info)) |
| 2292 return nullptr; | 2293 return nullptr; |
| 2293 return WebGLActiveInfo::create(info.name, info.type, info.size); | 2294 return WebGLActiveInfo::create(info.name, info.type, info.size); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2328 if (!validateLocationLength("getAttribLocation", name)) | 2329 if (!validateLocationLength("getAttribLocation", name)) |
| 2329 return -1; | 2330 return -1; |
| 2330 if (!validateString("getAttribLocation", name)) | 2331 if (!validateString("getAttribLocation", name)) |
| 2331 return -1; | 2332 return -1; |
| 2332 if (isPrefixReserved(name)) | 2333 if (isPrefixReserved(name)) |
| 2333 return -1; | 2334 return -1; |
| 2334 if (!program->linkStatus()) { | 2335 if (!program->linkStatus()) { |
| 2335 synthesizeGLError(GL_INVALID_OPERATION, "getAttribLocation", "program no
t linked"); | 2336 synthesizeGLError(GL_INVALID_OPERATION, "getAttribLocation", "program no
t linked"); |
| 2336 return 0; | 2337 return 0; |
| 2337 } | 2338 } |
| 2338 return webContext()->getAttribLocation(objectOrZero(program), name.utf8().da
ta()); | 2339 return contextGL()->GetAttribLocation(objectOrZero(program), name.utf8().dat
a()); |
| 2339 } | 2340 } |
| 2340 | 2341 |
| 2341 bool WebGLRenderingContextBase::validateBufferTarget(const char* functionName, G
Lenum target) | 2342 bool WebGLRenderingContextBase::validateBufferTarget(const char* functionName, G
Lenum target) |
| 2342 { | 2343 { |
| 2343 switch (target) { | 2344 switch (target) { |
| 2344 case GL_ARRAY_BUFFER: | 2345 case GL_ARRAY_BUFFER: |
| 2345 case GL_ELEMENT_ARRAY_BUFFER: | 2346 case GL_ELEMENT_ARRAY_BUFFER: |
| 2346 return true; | 2347 return true; |
| 2347 default: | 2348 default: |
| 2348 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid target"); | 2349 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid target"); |
| 2349 return false; | 2350 return false; |
| 2350 } | 2351 } |
| 2351 } | 2352 } |
| 2352 | 2353 |
| 2353 ScriptValue WebGLRenderingContextBase::getBufferParameter(ScriptState* scriptSta
te, GLenum target, GLenum pname) | 2354 ScriptValue WebGLRenderingContextBase::getBufferParameter(ScriptState* scriptSta
te, GLenum target, GLenum pname) |
| 2354 { | 2355 { |
| 2355 if (isContextLost() || !validateBufferTarget("getBufferParameter", target)) | 2356 if (isContextLost() || !validateBufferTarget("getBufferParameter", target)) |
| 2356 return ScriptValue::createNull(scriptState); | 2357 return ScriptValue::createNull(scriptState); |
| 2357 | 2358 |
| 2358 switch (pname) { | 2359 switch (pname) { |
| 2359 case GL_BUFFER_USAGE: | 2360 case GL_BUFFER_USAGE: |
| 2360 { | 2361 { |
| 2361 GLint value = 0; | 2362 GLint value = 0; |
| 2362 webContext()->getBufferParameteriv(target, pname, &value); | 2363 contextGL()->GetBufferParameteriv(target, pname, &value); |
| 2363 return WebGLAny(scriptState, static_cast<unsigned>(value)); | 2364 return WebGLAny(scriptState, static_cast<unsigned>(value)); |
| 2364 } | 2365 } |
| 2365 case GL_BUFFER_SIZE: | 2366 case GL_BUFFER_SIZE: |
| 2366 { | 2367 { |
| 2367 GLint value = 0; | 2368 GLint value = 0; |
| 2368 webContext()->getBufferParameteriv(target, pname, &value); | 2369 contextGL()->GetBufferParameteriv(target, pname, &value); |
| 2369 if (!isWebGL2OrHigher()) | 2370 if (!isWebGL2OrHigher()) |
| 2370 return WebGLAny(scriptState, value); | 2371 return WebGLAny(scriptState, value); |
| 2371 return WebGLAny(scriptState, static_cast<GLint64>(value)); | 2372 return WebGLAny(scriptState, static_cast<GLint64>(value)); |
| 2372 } | 2373 } |
| 2373 default: | 2374 default: |
| 2374 synthesizeGLError(GL_INVALID_ENUM, "getBufferParameter", "invalid parame
ter name"); | 2375 synthesizeGLError(GL_INVALID_ENUM, "getBufferParameter", "invalid parame
ter name"); |
| 2375 return ScriptValue::createNull(scriptState); | 2376 return ScriptValue::createNull(scriptState); |
| 2376 } | 2377 } |
| 2377 } | 2378 } |
| 2378 | 2379 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2490 if (attachmentObject->isTexture()) { | 2491 if (attachmentObject->isTexture()) { |
| 2491 switch (pname) { | 2492 switch (pname) { |
| 2492 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: | 2493 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: |
| 2493 return WebGLAny(scriptState, GL_TEXTURE); | 2494 return WebGLAny(scriptState, GL_TEXTURE); |
| 2494 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: | 2495 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: |
| 2495 return WebGLAny(scriptState, attachmentObject); | 2496 return WebGLAny(scriptState, attachmentObject); |
| 2496 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: | 2497 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: |
| 2497 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: | 2498 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: |
| 2498 { | 2499 { |
| 2499 GLint value = 0; | 2500 GLint value = 0; |
| 2500 webContext()->getFramebufferAttachmentParameteriv(target, attach
ment, pname, &value); | 2501 contextGL()->GetFramebufferAttachmentParameteriv(target, attachm
ent, pname, &value); |
| 2501 return WebGLAny(scriptState, value); | 2502 return WebGLAny(scriptState, value); |
| 2502 } | 2503 } |
| 2503 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT: | 2504 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT: |
| 2504 if (extensionEnabled(EXTsRGBName)) { | 2505 if (extensionEnabled(EXTsRGBName)) { |
| 2505 GLint value = 0; | 2506 GLint value = 0; |
| 2506 webContext()->getFramebufferAttachmentParameteriv(target, attach
ment, pname, &value); | 2507 contextGL()->GetFramebufferAttachmentParameteriv(target, attachm
ent, pname, &value); |
| 2507 return WebGLAny(scriptState, static_cast<unsigned>(value)); | 2508 return WebGLAny(scriptState, static_cast<unsigned>(value)); |
| 2508 } | 2509 } |
| 2509 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete
r", "invalid parameter name for renderbuffer attachment"); | 2510 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete
r", "invalid parameter name for renderbuffer attachment"); |
| 2510 return ScriptValue::createNull(scriptState); | 2511 return ScriptValue::createNull(scriptState); |
| 2511 default: | 2512 default: |
| 2512 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete
r", "invalid parameter name for texture attachment"); | 2513 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete
r", "invalid parameter name for texture attachment"); |
| 2513 return ScriptValue::createNull(scriptState); | 2514 return ScriptValue::createNull(scriptState); |
| 2514 } | 2515 } |
| 2515 } else { | 2516 } else { |
| 2516 switch (pname) { | 2517 switch (pname) { |
| 2517 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: | 2518 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: |
| 2518 return WebGLAny(scriptState, GL_RENDERBUFFER); | 2519 return WebGLAny(scriptState, GL_RENDERBUFFER); |
| 2519 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: | 2520 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: |
| 2520 return WebGLAny(scriptState, attachmentObject); | 2521 return WebGLAny(scriptState, attachmentObject); |
| 2521 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT: | 2522 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT: |
| 2522 if (extensionEnabled(EXTsRGBName)) { | 2523 if (extensionEnabled(EXTsRGBName)) { |
| 2523 GLint value = 0; | 2524 GLint value = 0; |
| 2524 webContext()->getFramebufferAttachmentParameteriv(target, attach
ment, pname, &value); | 2525 contextGL()->GetFramebufferAttachmentParameteriv(target, attachm
ent, pname, &value); |
| 2525 return WebGLAny(scriptState, value); | 2526 return WebGLAny(scriptState, value); |
| 2526 } | 2527 } |
| 2527 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete
r", "invalid parameter name for renderbuffer attachment"); | 2528 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete
r", "invalid parameter name for renderbuffer attachment"); |
| 2528 return ScriptValue::createNull(scriptState); | 2529 return ScriptValue::createNull(scriptState); |
| 2529 default: | 2530 default: |
| 2530 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete
r", "invalid parameter name for renderbuffer attachment"); | 2531 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete
r", "invalid parameter name for renderbuffer attachment"); |
| 2531 return ScriptValue::createNull(scriptState); | 2532 return ScriptValue::createNull(scriptState); |
| 2532 } | 2533 } |
| 2533 } | 2534 } |
| 2534 } | 2535 } |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2788 ScriptValue WebGLRenderingContextBase::getProgramParameter(ScriptState* scriptSt
ate, WebGLProgram* program, GLenum pname) | 2789 ScriptValue WebGLRenderingContextBase::getProgramParameter(ScriptState* scriptSt
ate, WebGLProgram* program, GLenum pname) |
| 2789 { | 2790 { |
| 2790 if (isContextLost() || !validateWebGLObject("getProgramParameter", program)) | 2791 if (isContextLost() || !validateWebGLObject("getProgramParameter", program)) |
| 2791 return ScriptValue::createNull(scriptState); | 2792 return ScriptValue::createNull(scriptState); |
| 2792 | 2793 |
| 2793 GLint value = 0; | 2794 GLint value = 0; |
| 2794 switch (pname) { | 2795 switch (pname) { |
| 2795 case GL_DELETE_STATUS: | 2796 case GL_DELETE_STATUS: |
| 2796 return WebGLAny(scriptState, program->isDeleted()); | 2797 return WebGLAny(scriptState, program->isDeleted()); |
| 2797 case GL_VALIDATE_STATUS: | 2798 case GL_VALIDATE_STATUS: |
| 2798 webContext()->getProgramiv(objectOrZero(program), pname, &value); | 2799 contextGL()->GetProgramiv(objectOrZero(program), pname, &value); |
| 2799 return WebGLAny(scriptState, static_cast<bool>(value)); | 2800 return WebGLAny(scriptState, static_cast<bool>(value)); |
| 2800 case GL_LINK_STATUS: | 2801 case GL_LINK_STATUS: |
| 2801 return WebGLAny(scriptState, program->linkStatus()); | 2802 return WebGLAny(scriptState, program->linkStatus()); |
| 2802 case GL_ACTIVE_UNIFORM_BLOCKS: | 2803 case GL_ACTIVE_UNIFORM_BLOCKS: |
| 2803 case GL_TRANSFORM_FEEDBACK_VARYINGS: | 2804 case GL_TRANSFORM_FEEDBACK_VARYINGS: |
| 2804 if (!isWebGL2OrHigher()) { | 2805 if (!isWebGL2OrHigher()) { |
| 2805 synthesizeGLError(GL_INVALID_ENUM, "getProgramParameter", "invalid p
arameter name"); | 2806 synthesizeGLError(GL_INVALID_ENUM, "getProgramParameter", "invalid p
arameter name"); |
| 2806 return ScriptValue::createNull(scriptState); | 2807 return ScriptValue::createNull(scriptState); |
| 2807 } | 2808 } |
| 2808 case GL_ATTACHED_SHADERS: | 2809 case GL_ATTACHED_SHADERS: |
| 2809 case GL_ACTIVE_ATTRIBUTES: | 2810 case GL_ACTIVE_ATTRIBUTES: |
| 2810 case GL_ACTIVE_UNIFORMS: | 2811 case GL_ACTIVE_UNIFORMS: |
| 2811 webContext()->getProgramiv(objectOrZero(program), pname, &value); | 2812 contextGL()->GetProgramiv(objectOrZero(program), pname, &value); |
| 2812 return WebGLAny(scriptState, value); | 2813 return WebGLAny(scriptState, value); |
| 2813 case GL_TRANSFORM_FEEDBACK_BUFFER_MODE: | 2814 case GL_TRANSFORM_FEEDBACK_BUFFER_MODE: |
| 2814 if (isWebGL2OrHigher()) { | 2815 if (isWebGL2OrHigher()) { |
| 2815 webContext()->getProgramiv(objectOrZero(program), pname, &value); | 2816 contextGL()->GetProgramiv(objectOrZero(program), pname, &value); |
| 2816 return WebGLAny(scriptState, static_cast<unsigned>(value)); | 2817 return WebGLAny(scriptState, static_cast<unsigned>(value)); |
| 2817 } | 2818 } |
| 2818 default: | 2819 default: |
| 2819 synthesizeGLError(GL_INVALID_ENUM, "getProgramParameter", "invalid param
eter name"); | 2820 synthesizeGLError(GL_INVALID_ENUM, "getProgramParameter", "invalid param
eter name"); |
| 2820 return ScriptValue::createNull(scriptState); | 2821 return ScriptValue::createNull(scriptState); |
| 2821 } | 2822 } |
| 2822 } | 2823 } |
| 2823 | 2824 |
| 2824 String WebGLRenderingContextBase::getProgramInfoLog(WebGLProgram* program) | 2825 String WebGLRenderingContextBase::getProgramInfoLog(WebGLProgram* program) |
| 2825 { | 2826 { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2848 synthesizeGLError(GL_INVALID_ENUM, "getRenderbufferParameter", "inva
lid parameter name"); | 2849 synthesizeGLError(GL_INVALID_ENUM, "getRenderbufferParameter", "inva
lid parameter name"); |
| 2849 return ScriptValue::createNull(scriptState); | 2850 return ScriptValue::createNull(scriptState); |
| 2850 } | 2851 } |
| 2851 case GL_RENDERBUFFER_WIDTH: | 2852 case GL_RENDERBUFFER_WIDTH: |
| 2852 case GL_RENDERBUFFER_HEIGHT: | 2853 case GL_RENDERBUFFER_HEIGHT: |
| 2853 case GL_RENDERBUFFER_RED_SIZE: | 2854 case GL_RENDERBUFFER_RED_SIZE: |
| 2854 case GL_RENDERBUFFER_GREEN_SIZE: | 2855 case GL_RENDERBUFFER_GREEN_SIZE: |
| 2855 case GL_RENDERBUFFER_BLUE_SIZE: | 2856 case GL_RENDERBUFFER_BLUE_SIZE: |
| 2856 case GL_RENDERBUFFER_ALPHA_SIZE: | 2857 case GL_RENDERBUFFER_ALPHA_SIZE: |
| 2857 case GL_RENDERBUFFER_DEPTH_SIZE: | 2858 case GL_RENDERBUFFER_DEPTH_SIZE: |
| 2858 webContext()->getRenderbufferParameteriv(target, pname, &value); | 2859 contextGL()->GetRenderbufferParameteriv(target, pname, &value); |
| 2859 return WebGLAny(scriptState, value); | 2860 return WebGLAny(scriptState, value); |
| 2860 case GL_RENDERBUFFER_STENCIL_SIZE: | 2861 case GL_RENDERBUFFER_STENCIL_SIZE: |
| 2861 webContext()->getRenderbufferParameteriv(target, pname, &value); | 2862 contextGL()->GetRenderbufferParameteriv(target, pname, &value); |
| 2862 return WebGLAny(scriptState, value); | 2863 return WebGLAny(scriptState, value); |
| 2863 case GL_RENDERBUFFER_INTERNAL_FORMAT: | 2864 case GL_RENDERBUFFER_INTERNAL_FORMAT: |
| 2864 return WebGLAny(scriptState, m_renderbufferBinding->internalFormat()); | 2865 return WebGLAny(scriptState, m_renderbufferBinding->internalFormat()); |
| 2865 default: | 2866 default: |
| 2866 synthesizeGLError(GL_INVALID_ENUM, "getRenderbufferParameter", "invalid
parameter name"); | 2867 synthesizeGLError(GL_INVALID_ENUM, "getRenderbufferParameter", "invalid
parameter name"); |
| 2867 return ScriptValue::createNull(scriptState); | 2868 return ScriptValue::createNull(scriptState); |
| 2868 } | 2869 } |
| 2869 } | 2870 } |
| 2870 | 2871 |
| 2871 ScriptValue WebGLRenderingContextBase::getShaderParameter(ScriptState* scriptSta
te, WebGLShader* shader, GLenum pname) | 2872 ScriptValue WebGLRenderingContextBase::getShaderParameter(ScriptState* scriptSta
te, WebGLShader* shader, GLenum pname) |
| 2872 { | 2873 { |
| 2873 if (isContextLost() || !validateWebGLObject("getShaderParameter", shader)) | 2874 if (isContextLost() || !validateWebGLObject("getShaderParameter", shader)) |
| 2874 return ScriptValue::createNull(scriptState); | 2875 return ScriptValue::createNull(scriptState); |
| 2875 GLint value = 0; | 2876 GLint value = 0; |
| 2876 switch (pname) { | 2877 switch (pname) { |
| 2877 case GL_DELETE_STATUS: | 2878 case GL_DELETE_STATUS: |
| 2878 return WebGLAny(scriptState, shader->isDeleted()); | 2879 return WebGLAny(scriptState, shader->isDeleted()); |
| 2879 case GL_COMPILE_STATUS: | 2880 case GL_COMPILE_STATUS: |
| 2880 webContext()->getShaderiv(objectOrZero(shader), pname, &value); | 2881 contextGL()->GetShaderiv(objectOrZero(shader), pname, &value); |
| 2881 return WebGLAny(scriptState, static_cast<bool>(value)); | 2882 return WebGLAny(scriptState, static_cast<bool>(value)); |
| 2882 case GL_SHADER_TYPE: | 2883 case GL_SHADER_TYPE: |
| 2883 webContext()->getShaderiv(objectOrZero(shader), pname, &value); | 2884 contextGL()->GetShaderiv(objectOrZero(shader), pname, &value); |
| 2884 return WebGLAny(scriptState, static_cast<unsigned>(value)); | 2885 return WebGLAny(scriptState, static_cast<unsigned>(value)); |
| 2885 default: | 2886 default: |
| 2886 synthesizeGLError(GL_INVALID_ENUM, "getShaderParameter", "invalid parame
ter name"); | 2887 synthesizeGLError(GL_INVALID_ENUM, "getShaderParameter", "invalid parame
ter name"); |
| 2887 return ScriptValue::createNull(scriptState); | 2888 return ScriptValue::createNull(scriptState); |
| 2888 } | 2889 } |
| 2889 } | 2890 } |
| 2890 | 2891 |
| 2891 String WebGLRenderingContextBase::getShaderInfoLog(WebGLShader* shader) | 2892 String WebGLRenderingContextBase::getShaderInfoLog(WebGLShader* shader) |
| 2892 { | 2893 { |
| 2893 if (isContextLost() || !validateWebGLObject("getShaderInfoLog", shader)) | 2894 if (isContextLost() || !validateWebGLObject("getShaderInfoLog", shader)) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2915 case GL_MEDIUM_INT: | 2916 case GL_MEDIUM_INT: |
| 2916 case GL_HIGH_INT: | 2917 case GL_HIGH_INT: |
| 2917 break; | 2918 break; |
| 2918 default: | 2919 default: |
| 2919 synthesizeGLError(GL_INVALID_ENUM, "getShaderPrecisionFormat", "invalid
precision type"); | 2920 synthesizeGLError(GL_INVALID_ENUM, "getShaderPrecisionFormat", "invalid
precision type"); |
| 2920 return nullptr; | 2921 return nullptr; |
| 2921 } | 2922 } |
| 2922 | 2923 |
| 2923 GLint range[2] = {0, 0}; | 2924 GLint range[2] = {0, 0}; |
| 2924 GLint precision = 0; | 2925 GLint precision = 0; |
| 2925 webContext()->getShaderPrecisionFormat(shaderType, precisionType, range, &pr
ecision); | 2926 contextGL()->GetShaderPrecisionFormat(shaderType, precisionType, range, &pre
cision); |
| 2926 return WebGLShaderPrecisionFormat::create(range[0], range[1], precision); | 2927 return WebGLShaderPrecisionFormat::create(range[0], range[1], precision); |
| 2927 } | 2928 } |
| 2928 | 2929 |
| 2929 String WebGLRenderingContextBase::getShaderSource(WebGLShader* shader) | 2930 String WebGLRenderingContextBase::getShaderSource(WebGLShader* shader) |
| 2930 { | 2931 { |
| 2931 if (isContextLost() || !validateWebGLObject("getShaderSource", shader)) | 2932 if (isContextLost() || !validateWebGLObject("getShaderSource", shader)) |
| 2932 return String(); | 2933 return String(); |
| 2933 return ensureNotNull(shader->source()); | 2934 return ensureNotNull(shader->source()); |
| 2934 } | 2935 } |
| 2935 | 2936 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2960 return ScriptValue::createNull(scriptState); | 2961 return ScriptValue::createNull(scriptState); |
| 2961 if (!validateTextureBinding("getTexParameter", target)) | 2962 if (!validateTextureBinding("getTexParameter", target)) |
| 2962 return ScriptValue::createNull(scriptState); | 2963 return ScriptValue::createNull(scriptState); |
| 2963 switch (pname) { | 2964 switch (pname) { |
| 2964 case GL_TEXTURE_MAG_FILTER: | 2965 case GL_TEXTURE_MAG_FILTER: |
| 2965 case GL_TEXTURE_MIN_FILTER: | 2966 case GL_TEXTURE_MIN_FILTER: |
| 2966 case GL_TEXTURE_WRAP_S: | 2967 case GL_TEXTURE_WRAP_S: |
| 2967 case GL_TEXTURE_WRAP_T: | 2968 case GL_TEXTURE_WRAP_T: |
| 2968 { | 2969 { |
| 2969 GLint value = 0; | 2970 GLint value = 0; |
| 2970 webContext()->getTexParameteriv(target, pname, &value); | 2971 contextGL()->GetTexParameteriv(target, pname, &value); |
| 2971 return WebGLAny(scriptState, static_cast<unsigned>(value)); | 2972 return WebGLAny(scriptState, static_cast<unsigned>(value)); |
| 2972 } | 2973 } |
| 2973 case GL_TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_anisotropic | 2974 case GL_TEXTURE_MAX_ANISOTROPY_EXT: // EXT_texture_filter_anisotropic |
| 2974 if (extensionEnabled(EXTTextureFilterAnisotropicName)) { | 2975 if (extensionEnabled(EXTTextureFilterAnisotropicName)) { |
| 2975 GLfloat value = 0.f; | 2976 GLfloat value = 0.f; |
| 2976 webContext()->getTexParameterfv(target, pname, &value); | 2977 contextGL()->GetTexParameterfv(target, pname, &value); |
| 2977 return WebGLAny(scriptState, value); | 2978 return WebGLAny(scriptState, value); |
| 2978 } | 2979 } |
| 2979 synthesizeGLError(GL_INVALID_ENUM, "getTexParameter", "invalid parameter
name, EXT_texture_filter_anisotropic not enabled"); | 2980 synthesizeGLError(GL_INVALID_ENUM, "getTexParameter", "invalid parameter
name, EXT_texture_filter_anisotropic not enabled"); |
| 2980 return ScriptValue::createNull(scriptState); | 2981 return ScriptValue::createNull(scriptState); |
| 2981 default: | 2982 default: |
| 2982 synthesizeGLError(GL_INVALID_ENUM, "getTexParameter", "invalid parameter
name"); | 2983 synthesizeGLError(GL_INVALID_ENUM, "getTexParameter", "invalid parameter
name"); |
| 2983 return ScriptValue::createNull(scriptState); | 2984 return ScriptValue::createNull(scriptState); |
| 2984 } | 2985 } |
| 2985 } | 2986 } |
| 2986 | 2987 |
| 2987 ScriptValue WebGLRenderingContextBase::getUniform(ScriptState* scriptState, WebG
LProgram* program, const WebGLUniformLocation* uniformLocation) | 2988 ScriptValue WebGLRenderingContextBase::getUniform(ScriptState* scriptState, WebG
LProgram* program, const WebGLUniformLocation* uniformLocation) |
| 2988 { | 2989 { |
| 2989 if (isContextLost() || !validateWebGLObject("getUniform", program)) | 2990 if (isContextLost() || !validateWebGLObject("getUniform", program)) |
| 2990 return ScriptValue::createNull(scriptState); | 2991 return ScriptValue::createNull(scriptState); |
| 2991 if (!uniformLocation || uniformLocation->program() != program) { | 2992 if (!uniformLocation || uniformLocation->program() != program) { |
| 2992 synthesizeGLError(GL_INVALID_OPERATION, "getUniform", "no uniformlocatio
n or not valid for this program"); | 2993 synthesizeGLError(GL_INVALID_OPERATION, "getUniform", "no uniformlocatio
n or not valid for this program"); |
| 2993 return ScriptValue::createNull(scriptState); | 2994 return ScriptValue::createNull(scriptState); |
| 2994 } | 2995 } |
| 2995 GLint location = uniformLocation->location(); | 2996 GLint location = uniformLocation->location(); |
| 2996 | 2997 |
| 2997 // FIXME: make this more efficient using WebGLUniformLocation and caching ty
pes in it | 2998 // FIXME: make this more efficient using WebGLUniformLocation and caching ty
pes in it |
| 2998 GLint activeUniforms = 0; | 2999 GLint activeUniforms = 0; |
| 2999 webContext()->getProgramiv(objectOrZero(program), GL_ACTIVE_UNIFORMS, &activ
eUniforms); | 3000 contextGL()->GetProgramiv(objectOrZero(program), GL_ACTIVE_UNIFORMS, &active
Uniforms); |
| 3000 for (GLint i = 0; i < activeUniforms; i++) { | 3001 for (GLint i = 0; i < activeUniforms; i++) { |
| 3001 WebGraphicsContext3D::ActiveInfo info; | 3002 WebGraphicsContext3D::ActiveInfo info; |
| 3002 if (!webContext()->getActiveUniform(objectOrZero(program), i, info)) | 3003 if (!webContext()->getActiveUniform(objectOrZero(program), i, info)) |
| 3003 return ScriptValue::createNull(scriptState); | 3004 return ScriptValue::createNull(scriptState); |
| 3004 String name = info.name; | 3005 String name = info.name; |
| 3005 StringBuilder nameBuilder; | 3006 StringBuilder nameBuilder; |
| 3006 // Strip "[0]" from the name if it's an array. | 3007 // Strip "[0]" from the name if it's an array. |
| 3007 if (info.size > 1 && name.endsWith("[0]")) | 3008 if (info.size > 1 && name.endsWith("[0]")) |
| 3008 info.name = name.left(name.length() - 3); | 3009 info.name = name.left(name.length() - 3); |
| 3009 // If it's an array, we need to iterate through each element, appending
"[index]" to the name. | 3010 // If it's an array, we need to iterate through each element, appending
"[index]" to the name. |
| 3010 for (GLint index = 0; index < info.size; ++index) { | 3011 for (GLint index = 0; index < info.size; ++index) { |
| 3011 nameBuilder.clear(); | 3012 nameBuilder.clear(); |
| 3012 nameBuilder.append(info.name); | 3013 nameBuilder.append(info.name); |
| 3013 if (info.size > 1 && index >= 1) { | 3014 if (info.size > 1 && index >= 1) { |
| 3014 nameBuilder.append('['); | 3015 nameBuilder.append('['); |
| 3015 nameBuilder.appendNumber(index); | 3016 nameBuilder.appendNumber(index); |
| 3016 nameBuilder.append(']'); | 3017 nameBuilder.append(']'); |
| 3017 } | 3018 } |
| 3018 // Now need to look this up by name again to find its location | 3019 // Now need to look this up by name again to find its location |
| 3019 GLint loc = webContext()->getUniformLocation(objectOrZero(program),
nameBuilder.toString().utf8().data()); | 3020 GLint loc = contextGL()->GetUniformLocation(objectOrZero(program), n
ameBuilder.toString().utf8().data()); |
| 3020 if (loc == location) { | 3021 if (loc == location) { |
| 3021 // Found it. Use the type in the ActiveInfo to determine the ret
urn type. | 3022 // Found it. Use the type in the ActiveInfo to determine the ret
urn type. |
| 3022 GLenum baseType; | 3023 GLenum baseType; |
| 3023 unsigned length; | 3024 unsigned length; |
| 3024 switch (info.type) { | 3025 switch (info.type) { |
| 3025 case GL_BOOL: | 3026 case GL_BOOL: |
| 3026 baseType = GL_BOOL; | 3027 baseType = GL_BOOL; |
| 3027 length = 1; | 3028 length = 1; |
| 3028 break; | 3029 break; |
| 3029 case GL_BOOL_VEC2: | 3030 case GL_BOOL_VEC2: |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3142 break; | 3143 break; |
| 3143 default: | 3144 default: |
| 3144 // Can't handle this type | 3145 // Can't handle this type |
| 3145 synthesizeGLError(GL_INVALID_VALUE, "getUniform", "unhan
dled type"); | 3146 synthesizeGLError(GL_INVALID_VALUE, "getUniform", "unhan
dled type"); |
| 3146 return ScriptValue::createNull(scriptState); | 3147 return ScriptValue::createNull(scriptState); |
| 3147 } | 3148 } |
| 3148 } | 3149 } |
| 3149 switch (baseType) { | 3150 switch (baseType) { |
| 3150 case GL_FLOAT: { | 3151 case GL_FLOAT: { |
| 3151 GLfloat value[16] = {0}; | 3152 GLfloat value[16] = {0}; |
| 3152 webContext()->getUniformfv(objectOrZero(program), location,
value); | 3153 contextGL()->GetUniformfv(objectOrZero(program), location, v
alue); |
| 3153 if (length == 1) | 3154 if (length == 1) |
| 3154 return WebGLAny(scriptState, value[0]); | 3155 return WebGLAny(scriptState, value[0]); |
| 3155 return WebGLAny(scriptState, DOMFloat32Array::create(value,
length)); | 3156 return WebGLAny(scriptState, DOMFloat32Array::create(value,
length)); |
| 3156 } | 3157 } |
| 3157 case GL_INT: { | 3158 case GL_INT: { |
| 3158 GLint value[4] = {0}; | 3159 GLint value[4] = {0}; |
| 3159 webContext()->getUniformiv(objectOrZero(program), location,
value); | 3160 contextGL()->GetUniformiv(objectOrZero(program), location, v
alue); |
| 3160 if (length == 1) | 3161 if (length == 1) |
| 3161 return WebGLAny(scriptState, value[0]); | 3162 return WebGLAny(scriptState, value[0]); |
| 3162 return WebGLAny(scriptState, DOMInt32Array::create(value, le
ngth)); | 3163 return WebGLAny(scriptState, DOMInt32Array::create(value, le
ngth)); |
| 3163 } | 3164 } |
| 3164 case GL_UNSIGNED_INT: { | 3165 case GL_UNSIGNED_INT: { |
| 3165 GLuint value[4] = {0}; | 3166 GLuint value[4] = {0}; |
| 3166 webContext()->getUniformuiv(objectOrZero(program), location,
value); | 3167 contextGL()->GetUniformuiv(objectOrZero(program), location,
value); |
| 3167 if (length == 1) | 3168 if (length == 1) |
| 3168 return WebGLAny(scriptState, value[0]); | 3169 return WebGLAny(scriptState, value[0]); |
| 3169 return WebGLAny(scriptState, DOMUint32Array::create(value, l
ength)); | 3170 return WebGLAny(scriptState, DOMUint32Array::create(value, l
ength)); |
| 3170 } | 3171 } |
| 3171 case GL_BOOL: { | 3172 case GL_BOOL: { |
| 3172 GLint value[4] = {0}; | 3173 GLint value[4] = {0}; |
| 3173 webContext()->getUniformiv(objectOrZero(program), location,
value); | 3174 contextGL()->GetUniformiv(objectOrZero(program), location, v
alue); |
| 3174 if (length > 1) { | 3175 if (length > 1) { |
| 3175 bool boolValue[16] = {0}; | 3176 bool boolValue[16] = {0}; |
| 3176 for (unsigned j = 0; j < length; j++) | 3177 for (unsigned j = 0; j < length; j++) |
| 3177 boolValue[j] = static_cast<bool>(value[j]); | 3178 boolValue[j] = static_cast<bool>(value[j]); |
| 3178 return WebGLAny(scriptState, boolValue, length); | 3179 return WebGLAny(scriptState, boolValue, length); |
| 3179 } | 3180 } |
| 3180 return WebGLAny(scriptState, static_cast<bool>(value[0])); | 3181 return WebGLAny(scriptState, static_cast<bool>(value[0])); |
| 3181 } | 3182 } |
| 3182 default: | 3183 default: |
| 3183 notImplemented(); | 3184 notImplemented(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 3197 if (!validateLocationLength("getUniformLocation", name)) | 3198 if (!validateLocationLength("getUniformLocation", name)) |
| 3198 return nullptr; | 3199 return nullptr; |
| 3199 if (!validateString("getUniformLocation", name)) | 3200 if (!validateString("getUniformLocation", name)) |
| 3200 return nullptr; | 3201 return nullptr; |
| 3201 if (isPrefixReserved(name)) | 3202 if (isPrefixReserved(name)) |
| 3202 return nullptr; | 3203 return nullptr; |
| 3203 if (!program->linkStatus()) { | 3204 if (!program->linkStatus()) { |
| 3204 synthesizeGLError(GL_INVALID_OPERATION, "getUniformLocation", "program n
ot linked"); | 3205 synthesizeGLError(GL_INVALID_OPERATION, "getUniformLocation", "program n
ot linked"); |
| 3205 return nullptr; | 3206 return nullptr; |
| 3206 } | 3207 } |
| 3207 GLint uniformLocation = webContext()->getUniformLocation(objectOrZero(progra
m), name.utf8().data()); | 3208 GLint uniformLocation = contextGL()->GetUniformLocation(objectOrZero(program
), name.utf8().data()); |
| 3208 if (uniformLocation == -1) | 3209 if (uniformLocation == -1) |
| 3209 return nullptr; | 3210 return nullptr; |
| 3210 return WebGLUniformLocation::create(program, uniformLocation); | 3211 return WebGLUniformLocation::create(program, uniformLocation); |
| 3211 } | 3212 } |
| 3212 | 3213 |
| 3213 ScriptValue WebGLRenderingContextBase::getVertexAttrib(ScriptState* scriptState,
GLuint index, GLenum pname) | 3214 ScriptValue WebGLRenderingContextBase::getVertexAttrib(ScriptState* scriptState,
GLuint index, GLenum pname) |
| 3214 { | 3215 { |
| 3215 if (isContextLost()) | 3216 if (isContextLost()) |
| 3216 return ScriptValue::createNull(scriptState); | 3217 return ScriptValue::createNull(scriptState); |
| 3217 if (index >= m_maxVertexAttribs) { | 3218 if (index >= m_maxVertexAttribs) { |
| 3218 synthesizeGLError(GL_INVALID_VALUE, "getVertexAttrib", "index out of ran
ge"); | 3219 synthesizeGLError(GL_INVALID_VALUE, "getVertexAttrib", "index out of ran
ge"); |
| 3219 return ScriptValue::createNull(scriptState); | 3220 return ScriptValue::createNull(scriptState); |
| 3220 } | 3221 } |
| 3221 | 3222 |
| 3222 if ((extensionEnabled(ANGLEInstancedArraysName) || isWebGL2OrHigher()) | 3223 if ((extensionEnabled(ANGLEInstancedArraysName) || isWebGL2OrHigher()) |
| 3223 && pname == GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE) | 3224 && pname == GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE) |
| 3224 { | 3225 { |
| 3225 GLint value = 0; | 3226 GLint value = 0; |
| 3226 webContext()->getVertexAttribiv(index, pname, &value); | 3227 contextGL()->GetVertexAttribiv(index, pname, &value); |
| 3227 return WebGLAny(scriptState, value); | 3228 return WebGLAny(scriptState, value); |
| 3228 } | 3229 } |
| 3229 | 3230 |
| 3230 switch (pname) { | 3231 switch (pname) { |
| 3231 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: | 3232 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: |
| 3232 return WebGLAny(scriptState, m_boundVertexArrayObject->getArrayBufferFor
Attrib(index)); | 3233 return WebGLAny(scriptState, m_boundVertexArrayObject->getArrayBufferFor
Attrib(index)); |
| 3233 case GL_VERTEX_ATTRIB_ARRAY_ENABLED: | 3234 case GL_VERTEX_ATTRIB_ARRAY_ENABLED: |
| 3234 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: | 3235 case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: |
| 3235 { | 3236 { |
| 3236 GLint value = 0; | 3237 GLint value = 0; |
| 3237 webContext()->getVertexAttribiv(index, pname, &value); | 3238 contextGL()->GetVertexAttribiv(index, pname, &value); |
| 3238 return WebGLAny(scriptState, static_cast<bool>(value)); | 3239 return WebGLAny(scriptState, static_cast<bool>(value)); |
| 3239 } | 3240 } |
| 3240 case GL_VERTEX_ATTRIB_ARRAY_SIZE: | 3241 case GL_VERTEX_ATTRIB_ARRAY_SIZE: |
| 3241 case GL_VERTEX_ATTRIB_ARRAY_STRIDE: | 3242 case GL_VERTEX_ATTRIB_ARRAY_STRIDE: |
| 3242 { | 3243 { |
| 3243 GLint value = 0; | 3244 GLint value = 0; |
| 3244 webContext()->getVertexAttribiv(index, pname, &value); | 3245 contextGL()->GetVertexAttribiv(index, pname, &value); |
| 3245 return WebGLAny(scriptState, value); | 3246 return WebGLAny(scriptState, value); |
| 3246 } | 3247 } |
| 3247 case GL_VERTEX_ATTRIB_ARRAY_TYPE: | 3248 case GL_VERTEX_ATTRIB_ARRAY_TYPE: |
| 3248 { | 3249 { |
| 3249 GLint value = 0; | 3250 GLint value = 0; |
| 3250 webContext()->getVertexAttribiv(index, pname, &value); | 3251 contextGL()->GetVertexAttribiv(index, pname, &value); |
| 3251 return WebGLAny(scriptState, static_cast<GLenum>(value)); | 3252 return WebGLAny(scriptState, static_cast<GLenum>(value)); |
| 3252 } | 3253 } |
| 3253 case GL_CURRENT_VERTEX_ATTRIB: | 3254 case GL_CURRENT_VERTEX_ATTRIB: |
| 3254 { | 3255 { |
| 3255 switch (m_vertexAttribType[index]) { | 3256 switch (m_vertexAttribType[index]) { |
| 3256 case Float32ArrayType: { | 3257 case Float32ArrayType: { |
| 3257 GLfloat floatValue[4]; | 3258 GLfloat floatValue[4]; |
| 3258 webContext()->getVertexAttribfv(index, pname, floatValue); | 3259 contextGL()->GetVertexAttribfv(index, pname, floatValue); |
| 3259 return WebGLAny(scriptState, DOMFloat32Array::create(floatValue,
4)); | 3260 return WebGLAny(scriptState, DOMFloat32Array::create(floatValue,
4)); |
| 3260 } | 3261 } |
| 3261 case Int32ArrayType: { | 3262 case Int32ArrayType: { |
| 3262 GLint intValue[4]; | 3263 GLint intValue[4]; |
| 3263 webContext()->getVertexAttribIiv(index, pname, intValue); | 3264 contextGL()->GetVertexAttribIiv(index, pname, intValue); |
| 3264 return WebGLAny(scriptState, DOMInt32Array::create(intValue, 4))
; | 3265 return WebGLAny(scriptState, DOMInt32Array::create(intValue, 4))
; |
| 3265 } | 3266 } |
| 3266 case Uint32ArrayType: { | 3267 case Uint32ArrayType: { |
| 3267 GLuint uintValue[4]; | 3268 GLuint uintValue[4]; |
| 3268 webContext()->getVertexAttribIuiv(index, pname, uintValue); | 3269 contextGL()->GetVertexAttribIuiv(index, pname, uintValue); |
| 3269 return WebGLAny(scriptState, DOMUint32Array::create(uintValue, 4
)); | 3270 return WebGLAny(scriptState, DOMUint32Array::create(uintValue, 4
)); |
| 3270 } | 3271 } |
| 3271 default: | 3272 default: |
| 3272 ASSERT_NOT_REACHED(); | 3273 ASSERT_NOT_REACHED(); |
| 3273 break; | 3274 break; |
| 3274 } | 3275 } |
| 3275 return ScriptValue::createNull(scriptState); | 3276 return ScriptValue::createNull(scriptState); |
| 3276 } | 3277 } |
| 3277 case GL_VERTEX_ATTRIB_ARRAY_INTEGER: | 3278 case GL_VERTEX_ATTRIB_ARRAY_INTEGER: |
| 3278 if (isWebGL2OrHigher()) { | 3279 if (isWebGL2OrHigher()) { |
| 3279 GLint value = 0; | 3280 GLint value = 0; |
| 3280 webContext()->getVertexAttribiv(index, pname, &value); | 3281 contextGL()->GetVertexAttribiv(index, pname, &value); |
| 3281 return WebGLAny(scriptState, static_cast<bool>(value)); | 3282 return WebGLAny(scriptState, static_cast<bool>(value)); |
| 3282 } | 3283 } |
| 3283 // fall through to default error case | 3284 // fall through to default error case |
| 3284 default: | 3285 default: |
| 3285 synthesizeGLError(GL_INVALID_ENUM, "getVertexAttrib", "invalid parameter
name"); | 3286 synthesizeGLError(GL_INVALID_ENUM, "getVertexAttrib", "invalid parameter
name"); |
| 3286 return ScriptValue::createNull(scriptState); | 3287 return ScriptValue::createNull(scriptState); |
| 3287 } | 3288 } |
| 3288 } | 3289 } |
| 3289 | 3290 |
| 3290 long long WebGLRenderingContextBase::getVertexAttribOffset(GLuint index, GLenum
pname) | 3291 long long WebGLRenderingContextBase::getVertexAttribOffset(GLuint index, GLenum
pname) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 3306 break; | 3307 break; |
| 3307 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: // OES_standard_derivatives | 3308 case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: // OES_standard_derivatives |
| 3308 if (extensionEnabled(OESStandardDerivativesName) || isWebGL2OrHigher()) | 3309 if (extensionEnabled(OESStandardDerivativesName) || isWebGL2OrHigher()) |
| 3309 isValid = true; | 3310 isValid = true; |
| 3310 break; | 3311 break; |
| 3311 } | 3312 } |
| 3312 if (!isValid) { | 3313 if (!isValid) { |
| 3313 synthesizeGLError(GL_INVALID_ENUM, "hint", "invalid target"); | 3314 synthesizeGLError(GL_INVALID_ENUM, "hint", "invalid target"); |
| 3314 return; | 3315 return; |
| 3315 } | 3316 } |
| 3316 webContext()->hint(target, mode); | 3317 contextGL()->Hint(target, mode); |
| 3317 } | 3318 } |
| 3318 | 3319 |
| 3319 GLboolean WebGLRenderingContextBase::isBuffer(WebGLBuffer* buffer) | 3320 GLboolean WebGLRenderingContextBase::isBuffer(WebGLBuffer* buffer) |
| 3320 { | 3321 { |
| 3321 if (!buffer || isContextLost()) | 3322 if (!buffer || isContextLost()) |
| 3322 return 0; | 3323 return 0; |
| 3323 | 3324 |
| 3324 if (!buffer->hasEverBeenBound()) | 3325 if (!buffer->hasEverBeenBound()) |
| 3325 return 0; | 3326 return 0; |
| 3326 if (buffer->isDeleted()) | 3327 if (buffer->isDeleted()) |
| 3327 return 0; | 3328 return 0; |
| 3328 | 3329 |
| 3329 return webContext()->isBuffer(buffer->object()); | 3330 return contextGL()->IsBuffer(buffer->object()); |
| 3330 } | 3331 } |
| 3331 | 3332 |
| 3332 bool WebGLRenderingContextBase::isContextLost() const | 3333 bool WebGLRenderingContextBase::isContextLost() const |
| 3333 { | 3334 { |
| 3334 return m_contextLostMode != NotLostContext; | 3335 return m_contextLostMode != NotLostContext; |
| 3335 } | 3336 } |
| 3336 | 3337 |
| 3337 GLboolean WebGLRenderingContextBase::isEnabled(GLenum cap) | 3338 GLboolean WebGLRenderingContextBase::isEnabled(GLenum cap) |
| 3338 { | 3339 { |
| 3339 if (isContextLost() || !validateCapability("isEnabled", cap)) | 3340 if (isContextLost() || !validateCapability("isEnabled", cap)) |
| 3340 return 0; | 3341 return 0; |
| 3341 if (cap == GL_STENCIL_TEST) | 3342 if (cap == GL_STENCIL_TEST) |
| 3342 return m_stencilEnabled; | 3343 return m_stencilEnabled; |
| 3343 return webContext()->isEnabled(cap); | 3344 return contextGL()->IsEnabled(cap); |
| 3344 } | 3345 } |
| 3345 | 3346 |
| 3346 GLboolean WebGLRenderingContextBase::isFramebuffer(WebGLFramebuffer* framebuffer
) | 3347 GLboolean WebGLRenderingContextBase::isFramebuffer(WebGLFramebuffer* framebuffer
) |
| 3347 { | 3348 { |
| 3348 if (!framebuffer || isContextLost()) | 3349 if (!framebuffer || isContextLost()) |
| 3349 return 0; | 3350 return 0; |
| 3350 | 3351 |
| 3351 if (!framebuffer->hasEverBeenBound()) | 3352 if (!framebuffer->hasEverBeenBound()) |
| 3352 return 0; | 3353 return 0; |
| 3353 if (framebuffer->isDeleted()) | 3354 if (framebuffer->isDeleted()) |
| 3354 return 0; | 3355 return 0; |
| 3355 | 3356 |
| 3356 return webContext()->isFramebuffer(framebuffer->object()); | 3357 return contextGL()->IsFramebuffer(framebuffer->object()); |
| 3357 } | 3358 } |
| 3358 | 3359 |
| 3359 GLboolean WebGLRenderingContextBase::isProgram(WebGLProgram* program) | 3360 GLboolean WebGLRenderingContextBase::isProgram(WebGLProgram* program) |
| 3360 { | 3361 { |
| 3361 if (!program || isContextLost()) | 3362 if (!program || isContextLost()) |
| 3362 return 0; | 3363 return 0; |
| 3363 | 3364 |
| 3364 return webContext()->isProgram(program->object()); | 3365 return contextGL()->IsProgram(program->object()); |
| 3365 } | 3366 } |
| 3366 | 3367 |
| 3367 GLboolean WebGLRenderingContextBase::isRenderbuffer(WebGLRenderbuffer* renderbuf
fer) | 3368 GLboolean WebGLRenderingContextBase::isRenderbuffer(WebGLRenderbuffer* renderbuf
fer) |
| 3368 { | 3369 { |
| 3369 if (!renderbuffer || isContextLost()) | 3370 if (!renderbuffer || isContextLost()) |
| 3370 return 0; | 3371 return 0; |
| 3371 | 3372 |
| 3372 if (!renderbuffer->hasEverBeenBound()) | 3373 if (!renderbuffer->hasEverBeenBound()) |
| 3373 return 0; | 3374 return 0; |
| 3374 if (renderbuffer->isDeleted()) | 3375 if (renderbuffer->isDeleted()) |
| 3375 return 0; | 3376 return 0; |
| 3376 | 3377 |
| 3377 return webContext()->isRenderbuffer(renderbuffer->object()); | 3378 return contextGL()->IsRenderbuffer(renderbuffer->object()); |
| 3378 } | 3379 } |
| 3379 | 3380 |
| 3380 GLboolean WebGLRenderingContextBase::isShader(WebGLShader* shader) | 3381 GLboolean WebGLRenderingContextBase::isShader(WebGLShader* shader) |
| 3381 { | 3382 { |
| 3382 if (!shader || isContextLost()) | 3383 if (!shader || isContextLost()) |
| 3383 return 0; | 3384 return 0; |
| 3384 | 3385 |
| 3385 return webContext()->isShader(shader->object()); | 3386 return contextGL()->IsShader(shader->object()); |
| 3386 } | 3387 } |
| 3387 | 3388 |
| 3388 GLboolean WebGLRenderingContextBase::isTexture(WebGLTexture* texture) | 3389 GLboolean WebGLRenderingContextBase::isTexture(WebGLTexture* texture) |
| 3389 { | 3390 { |
| 3390 if (!texture || isContextLost()) | 3391 if (!texture || isContextLost()) |
| 3391 return 0; | 3392 return 0; |
| 3392 | 3393 |
| 3393 if (!texture->hasEverBeenBound()) | 3394 if (!texture->hasEverBeenBound()) |
| 3394 return 0; | 3395 return 0; |
| 3395 if (texture->isDeleted()) | 3396 if (texture->isDeleted()) |
| 3396 return 0; | 3397 return 0; |
| 3397 | 3398 |
| 3398 return webContext()->isTexture(texture->object()); | 3399 return contextGL()->IsTexture(texture->object()); |
| 3399 } | 3400 } |
| 3400 | 3401 |
| 3401 void WebGLRenderingContextBase::lineWidth(GLfloat width) | 3402 void WebGLRenderingContextBase::lineWidth(GLfloat width) |
| 3402 { | 3403 { |
| 3403 if (isContextLost()) | 3404 if (isContextLost()) |
| 3404 return; | 3405 return; |
| 3405 webContext()->lineWidth(width); | 3406 contextGL()->LineWidth(width); |
| 3406 } | 3407 } |
| 3407 | 3408 |
| 3408 void WebGLRenderingContextBase::linkProgram(WebGLProgram* program) | 3409 void WebGLRenderingContextBase::linkProgram(WebGLProgram* program) |
| 3409 { | 3410 { |
| 3410 if (isContextLost() || !validateWebGLObject("linkProgram", program)) | 3411 if (isContextLost() || !validateWebGLObject("linkProgram", program)) |
| 3411 return; | 3412 return; |
| 3412 | 3413 |
| 3413 if (program->activeTransformFeedbackCount() > 0) { | 3414 if (program->activeTransformFeedbackCount() > 0) { |
| 3414 synthesizeGLError(GL_INVALID_OPERATION, "linkProgram", "program being us
ed by one or more active transform feedback objects"); | 3415 synthesizeGLError(GL_INVALID_OPERATION, "linkProgram", "program being us
ed by one or more active transform feedback objects"); |
| 3415 return; | 3416 return; |
| 3416 } | 3417 } |
| 3417 | 3418 |
| 3418 webContext()->linkProgram(objectOrZero(program)); | 3419 contextGL()->LinkProgram(objectOrZero(program)); |
| 3419 program->increaseLinkCount(); | 3420 program->increaseLinkCount(); |
| 3420 } | 3421 } |
| 3421 | 3422 |
| 3422 void WebGLRenderingContextBase::pixelStorei(GLenum pname, GLint param) | 3423 void WebGLRenderingContextBase::pixelStorei(GLenum pname, GLint param) |
| 3423 { | 3424 { |
| 3424 if (isContextLost()) | 3425 if (isContextLost()) |
| 3425 return; | 3426 return; |
| 3426 switch (pname) { | 3427 switch (pname) { |
| 3427 case GC3D_UNPACK_FLIP_Y_WEBGL: | 3428 case GC3D_UNPACK_FLIP_Y_WEBGL: |
| 3428 m_unpackFlipY = param; | 3429 m_unpackFlipY = param; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 3440 break; | 3441 break; |
| 3441 case GL_PACK_ALIGNMENT: | 3442 case GL_PACK_ALIGNMENT: |
| 3442 case GL_UNPACK_ALIGNMENT: | 3443 case GL_UNPACK_ALIGNMENT: |
| 3443 if (param == 1 || param == 2 || param == 4 || param == 8) { | 3444 if (param == 1 || param == 2 || param == 4 || param == 8) { |
| 3444 if (pname == GL_PACK_ALIGNMENT) { | 3445 if (pname == GL_PACK_ALIGNMENT) { |
| 3445 m_packAlignment = param; | 3446 m_packAlignment = param; |
| 3446 drawingBuffer()->setPackAlignment(param); | 3447 drawingBuffer()->setPackAlignment(param); |
| 3447 } else { // GL_UNPACK_ALIGNMENT: | 3448 } else { // GL_UNPACK_ALIGNMENT: |
| 3448 m_unpackAlignment = param; | 3449 m_unpackAlignment = param; |
| 3449 } | 3450 } |
| 3450 webContext()->pixelStorei(pname, param); | 3451 contextGL()->PixelStorei(pname, param); |
| 3451 } else { | 3452 } else { |
| 3452 synthesizeGLError(GL_INVALID_VALUE, "pixelStorei", "invalid paramete
r for alignment"); | 3453 synthesizeGLError(GL_INVALID_VALUE, "pixelStorei", "invalid paramete
r for alignment"); |
| 3453 return; | 3454 return; |
| 3454 } | 3455 } |
| 3455 break; | 3456 break; |
| 3456 default: | 3457 default: |
| 3457 synthesizeGLError(GL_INVALID_ENUM, "pixelStorei", "invalid parameter nam
e"); | 3458 synthesizeGLError(GL_INVALID_ENUM, "pixelStorei", "invalid parameter nam
e"); |
| 3458 return; | 3459 return; |
| 3459 } | 3460 } |
| 3460 } | 3461 } |
| 3461 | 3462 |
| 3462 void WebGLRenderingContextBase::polygonOffset(GLfloat factor, GLfloat units) | 3463 void WebGLRenderingContextBase::polygonOffset(GLfloat factor, GLfloat units) |
| 3463 { | 3464 { |
| 3464 if (isContextLost()) | 3465 if (isContextLost()) |
| 3465 return; | 3466 return; |
| 3466 webContext()->polygonOffset(factor, units); | 3467 contextGL()->PolygonOffset(factor, units); |
| 3467 } | 3468 } |
| 3468 | 3469 |
| 3469 bool WebGLRenderingContextBase::validateReadBufferAndGetInfo(const char* functio
nName, WebGLFramebuffer*& readFramebufferBinding) | 3470 bool WebGLRenderingContextBase::validateReadBufferAndGetInfo(const char* functio
nName, WebGLFramebuffer*& readFramebufferBinding) |
| 3470 { | 3471 { |
| 3471 readFramebufferBinding = getReadFramebufferBinding(); | 3472 readFramebufferBinding = getReadFramebufferBinding(); |
| 3472 if (readFramebufferBinding) { | 3473 if (readFramebufferBinding) { |
| 3473 const char* reason = "framebuffer incomplete"; | 3474 const char* reason = "framebuffer incomplete"; |
| 3474 if (readFramebufferBinding->checkDepthStencilStatus(&reason) != GL_FRAME
BUFFER_COMPLETE) { | 3475 if (readFramebufferBinding->checkDepthStencilStatus(&reason) != GL_FRAME
BUFFER_COMPLETE) { |
| 3475 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, functionName, re
ason); | 3476 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, functionName, re
ason); |
| 3476 return false; | 3477 return false; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3590 return; | 3591 return; |
| 3591 } | 3592 } |
| 3592 if (!validateReadPixelsFuncParameters(width, height, format, type, pixels, s
tatic_cast<long long>(pixels->byteLength()))) | 3593 if (!validateReadPixelsFuncParameters(width, height, format, type, pixels, s
tatic_cast<long long>(pixels->byteLength()))) |
| 3593 return; | 3594 return; |
| 3594 | 3595 |
| 3595 clearIfComposited(); | 3596 clearIfComposited(); |
| 3596 void* data = pixels->baseAddress(); | 3597 void* data = pixels->baseAddress(); |
| 3597 | 3598 |
| 3598 { | 3599 { |
| 3599 ScopedDrawingBufferBinder binder(drawingBuffer(), framebuffer); | 3600 ScopedDrawingBufferBinder binder(drawingBuffer(), framebuffer); |
| 3600 webContext()->readPixels(x, y, width, height, format, type, data); | 3601 contextGL()->ReadPixels(x, y, width, height, format, type, data); |
| 3601 } | 3602 } |
| 3602 } | 3603 } |
| 3603 | 3604 |
| 3604 void WebGLRenderingContextBase::renderbufferStorageImpl( | 3605 void WebGLRenderingContextBase::renderbufferStorageImpl( |
| 3605 GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsize
i height, | 3606 GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsize
i height, |
| 3606 const char* functionName) | 3607 const char* functionName) |
| 3607 { | 3608 { |
| 3608 ASSERT(!samples); // |samples| > 0 is only valid in WebGL2's renderbufferSto
rageMultisample(). | 3609 ASSERT(!samples); // |samples| > 0 is only valid in WebGL2's renderbufferSto
rageMultisample(). |
| 3609 ASSERT(!isWebGL2OrHigher()); // Make sure this is overridden in WebGL 2. | 3610 ASSERT(!isWebGL2OrHigher()); // Make sure this is overridden in WebGL 2. |
| 3610 switch (internalformat) { | 3611 switch (internalformat) { |
| 3611 case GL_DEPTH_COMPONENT16: | 3612 case GL_DEPTH_COMPONENT16: |
| 3612 case GL_RGBA4: | 3613 case GL_RGBA4: |
| 3613 case GL_RGB5_A1: | 3614 case GL_RGB5_A1: |
| 3614 case GL_RGB565: | 3615 case GL_RGB565: |
| 3615 case GL_STENCIL_INDEX8: | 3616 case GL_STENCIL_INDEX8: |
| 3616 webContext()->renderbufferStorage(target, internalformat, width, height)
; | 3617 contextGL()->RenderbufferStorage(target, internalformat, width, height); |
| 3617 m_renderbufferBinding->setInternalFormat(internalformat); | 3618 m_renderbufferBinding->setInternalFormat(internalformat); |
| 3618 m_renderbufferBinding->setSize(width, height); | 3619 m_renderbufferBinding->setSize(width, height); |
| 3619 break; | 3620 break; |
| 3620 case GL_SRGB8_ALPHA8_EXT: | 3621 case GL_SRGB8_ALPHA8_EXT: |
| 3621 if (!extensionEnabled(EXTsRGBName)) { | 3622 if (!extensionEnabled(EXTsRGBName)) { |
| 3622 synthesizeGLError(GL_INVALID_ENUM, functionName, "sRGB not enabled")
; | 3623 synthesizeGLError(GL_INVALID_ENUM, functionName, "sRGB not enabled")
; |
| 3623 break; | 3624 break; |
| 3624 } | 3625 } |
| 3625 webContext()->renderbufferStorage(target, internalformat, width, height)
; | 3626 contextGL()->RenderbufferStorage(target, internalformat, width, height); |
| 3626 m_renderbufferBinding->setInternalFormat(internalformat); | 3627 m_renderbufferBinding->setInternalFormat(internalformat); |
| 3627 m_renderbufferBinding->setSize(width, height); | 3628 m_renderbufferBinding->setSize(width, height); |
| 3628 break; | 3629 break; |
| 3629 case GL_DEPTH_STENCIL_OES: | 3630 case GL_DEPTH_STENCIL_OES: |
| 3630 ASSERT(isDepthStencilSupported()); | 3631 ASSERT(isDepthStencilSupported()); |
| 3631 webContext()->renderbufferStorage(target, GL_DEPTH24_STENCIL8_OES, width
, height); | 3632 contextGL()->RenderbufferStorage(target, GL_DEPTH24_STENCIL8_OES, width,
height); |
| 3632 m_renderbufferBinding->setSize(width, height); | 3633 m_renderbufferBinding->setSize(width, height); |
| 3633 m_renderbufferBinding->setInternalFormat(internalformat); | 3634 m_renderbufferBinding->setInternalFormat(internalformat); |
| 3634 break; | 3635 break; |
| 3635 default: | 3636 default: |
| 3636 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid internalformat
"); | 3637 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid internalformat
"); |
| 3637 break; | 3638 break; |
| 3638 } | 3639 } |
| 3639 } | 3640 } |
| 3640 | 3641 |
| 3641 void WebGLRenderingContextBase::renderbufferStorage(GLenum target, GLenum intern
alformat, GLsizei width, GLsizei height) | 3642 void WebGLRenderingContextBase::renderbufferStorage(GLenum target, GLenum intern
alformat, GLsizei width, GLsizei height) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3654 if (!validateSize(functionName, width, height)) | 3655 if (!validateSize(functionName, width, height)) |
| 3655 return; | 3656 return; |
| 3656 renderbufferStorageImpl(target, 0, internalformat, width, height, functionNa
me); | 3657 renderbufferStorageImpl(target, 0, internalformat, width, height, functionNa
me); |
| 3657 applyStencilTest(); | 3658 applyStencilTest(); |
| 3658 } | 3659 } |
| 3659 | 3660 |
| 3660 void WebGLRenderingContextBase::sampleCoverage(GLfloat value, GLboolean invert) | 3661 void WebGLRenderingContextBase::sampleCoverage(GLfloat value, GLboolean invert) |
| 3661 { | 3662 { |
| 3662 if (isContextLost()) | 3663 if (isContextLost()) |
| 3663 return; | 3664 return; |
| 3664 webContext()->sampleCoverage(value, invert); | 3665 contextGL()->SampleCoverage(value, invert); |
| 3665 } | 3666 } |
| 3666 | 3667 |
| 3667 void WebGLRenderingContextBase::scissor(GLint x, GLint y, GLsizei width, GLsizei
height) | 3668 void WebGLRenderingContextBase::scissor(GLint x, GLint y, GLsizei width, GLsizei
height) |
| 3668 { | 3669 { |
| 3669 if (isContextLost()) | 3670 if (isContextLost()) |
| 3670 return; | 3671 return; |
| 3671 webContext()->scissor(x, y, width, height); | 3672 contextGL()->Scissor(x, y, width, height); |
| 3672 } | 3673 } |
| 3673 | 3674 |
| 3674 void WebGLRenderingContextBase::shaderSource(WebGLShader* shader, const String&
string) | 3675 void WebGLRenderingContextBase::shaderSource(WebGLShader* shader, const String&
string) |
| 3675 { | 3676 { |
| 3676 if (isContextLost() || !validateWebGLObject("shaderSource", shader)) | 3677 if (isContextLost() || !validateWebGLObject("shaderSource", shader)) |
| 3677 return; | 3678 return; |
| 3678 String stringWithoutComments = StripComments(string).result(); | 3679 String stringWithoutComments = StripComments(string).result(); |
| 3679 if (!validateString("shaderSource", stringWithoutComments)) | 3680 if (!validateString("shaderSource", stringWithoutComments)) |
| 3680 return; | 3681 return; |
| 3681 shader->setSource(string); | 3682 shader->setSource(string); |
| 3682 webContext()->shaderSource(objectOrZero(shader), stringWithoutComments.utf8(
).data()); | 3683 webContext()->shaderSource(objectOrZero(shader), stringWithoutComments.utf8(
).data()); |
| 3683 } | 3684 } |
| 3684 | 3685 |
| 3685 void WebGLRenderingContextBase::stencilFunc(GLenum func, GLint ref, GLuint mask) | 3686 void WebGLRenderingContextBase::stencilFunc(GLenum func, GLint ref, GLuint mask) |
| 3686 { | 3687 { |
| 3687 if (isContextLost()) | 3688 if (isContextLost()) |
| 3688 return; | 3689 return; |
| 3689 if (!validateStencilOrDepthFunc("stencilFunc", func)) | 3690 if (!validateStencilOrDepthFunc("stencilFunc", func)) |
| 3690 return; | 3691 return; |
| 3691 m_stencilFuncRef = ref; | 3692 m_stencilFuncRef = ref; |
| 3692 m_stencilFuncRefBack = ref; | 3693 m_stencilFuncRefBack = ref; |
| 3693 m_stencilFuncMask = mask; | 3694 m_stencilFuncMask = mask; |
| 3694 m_stencilFuncMaskBack = mask; | 3695 m_stencilFuncMaskBack = mask; |
| 3695 webContext()->stencilFunc(func, ref, mask); | 3696 contextGL()->StencilFunc(func, ref, mask); |
| 3696 } | 3697 } |
| 3697 | 3698 |
| 3698 void WebGLRenderingContextBase::stencilFuncSeparate(GLenum face, GLenum func, GL
int ref, GLuint mask) | 3699 void WebGLRenderingContextBase::stencilFuncSeparate(GLenum face, GLenum func, GL
int ref, GLuint mask) |
| 3699 { | 3700 { |
| 3700 if (isContextLost()) | 3701 if (isContextLost()) |
| 3701 return; | 3702 return; |
| 3702 if (!validateStencilOrDepthFunc("stencilFuncSeparate", func)) | 3703 if (!validateStencilOrDepthFunc("stencilFuncSeparate", func)) |
| 3703 return; | 3704 return; |
| 3704 switch (face) { | 3705 switch (face) { |
| 3705 case GL_FRONT_AND_BACK: | 3706 case GL_FRONT_AND_BACK: |
| 3706 m_stencilFuncRef = ref; | 3707 m_stencilFuncRef = ref; |
| 3707 m_stencilFuncRefBack = ref; | 3708 m_stencilFuncRefBack = ref; |
| 3708 m_stencilFuncMask = mask; | 3709 m_stencilFuncMask = mask; |
| 3709 m_stencilFuncMaskBack = mask; | 3710 m_stencilFuncMaskBack = mask; |
| 3710 break; | 3711 break; |
| 3711 case GL_FRONT: | 3712 case GL_FRONT: |
| 3712 m_stencilFuncRef = ref; | 3713 m_stencilFuncRef = ref; |
| 3713 m_stencilFuncMask = mask; | 3714 m_stencilFuncMask = mask; |
| 3714 break; | 3715 break; |
| 3715 case GL_BACK: | 3716 case GL_BACK: |
| 3716 m_stencilFuncRefBack = ref; | 3717 m_stencilFuncRefBack = ref; |
| 3717 m_stencilFuncMaskBack = mask; | 3718 m_stencilFuncMaskBack = mask; |
| 3718 break; | 3719 break; |
| 3719 default: | 3720 default: |
| 3720 synthesizeGLError(GL_INVALID_ENUM, "stencilFuncSeparate", "invalid face"
); | 3721 synthesizeGLError(GL_INVALID_ENUM, "stencilFuncSeparate", "invalid face"
); |
| 3721 return; | 3722 return; |
| 3722 } | 3723 } |
| 3723 webContext()->stencilFuncSeparate(face, func, ref, mask); | 3724 contextGL()->StencilFuncSeparate(face, func, ref, mask); |
| 3724 } | 3725 } |
| 3725 | 3726 |
| 3726 void WebGLRenderingContextBase::stencilMask(GLuint mask) | 3727 void WebGLRenderingContextBase::stencilMask(GLuint mask) |
| 3727 { | 3728 { |
| 3728 if (isContextLost()) | 3729 if (isContextLost()) |
| 3729 return; | 3730 return; |
| 3730 m_stencilMask = mask; | 3731 m_stencilMask = mask; |
| 3731 m_stencilMaskBack = mask; | 3732 m_stencilMaskBack = mask; |
| 3732 webContext()->stencilMask(mask); | 3733 contextGL()->StencilMask(mask); |
| 3733 } | 3734 } |
| 3734 | 3735 |
| 3735 void WebGLRenderingContextBase::stencilMaskSeparate(GLenum face, GLuint mask) | 3736 void WebGLRenderingContextBase::stencilMaskSeparate(GLenum face, GLuint mask) |
| 3736 { | 3737 { |
| 3737 if (isContextLost()) | 3738 if (isContextLost()) |
| 3738 return; | 3739 return; |
| 3739 switch (face) { | 3740 switch (face) { |
| 3740 case GL_FRONT_AND_BACK: | 3741 case GL_FRONT_AND_BACK: |
| 3741 m_stencilMask = mask; | 3742 m_stencilMask = mask; |
| 3742 m_stencilMaskBack = mask; | 3743 m_stencilMaskBack = mask; |
| 3743 break; | 3744 break; |
| 3744 case GL_FRONT: | 3745 case GL_FRONT: |
| 3745 m_stencilMask = mask; | 3746 m_stencilMask = mask; |
| 3746 break; | 3747 break; |
| 3747 case GL_BACK: | 3748 case GL_BACK: |
| 3748 m_stencilMaskBack = mask; | 3749 m_stencilMaskBack = mask; |
| 3749 break; | 3750 break; |
| 3750 default: | 3751 default: |
| 3751 synthesizeGLError(GL_INVALID_ENUM, "stencilMaskSeparate", "invalid face"
); | 3752 synthesizeGLError(GL_INVALID_ENUM, "stencilMaskSeparate", "invalid face"
); |
| 3752 return; | 3753 return; |
| 3753 } | 3754 } |
| 3754 webContext()->stencilMaskSeparate(face, mask); | 3755 contextGL()->StencilMaskSeparate(face, mask); |
| 3755 } | 3756 } |
| 3756 | 3757 |
| 3757 void WebGLRenderingContextBase::stencilOp(GLenum fail, GLenum zfail, GLenum zpas
s) | 3758 void WebGLRenderingContextBase::stencilOp(GLenum fail, GLenum zfail, GLenum zpas
s) |
| 3758 { | 3759 { |
| 3759 if (isContextLost()) | 3760 if (isContextLost()) |
| 3760 return; | 3761 return; |
| 3761 webContext()->stencilOp(fail, zfail, zpass); | 3762 contextGL()->StencilOp(fail, zfail, zpass); |
| 3762 } | 3763 } |
| 3763 | 3764 |
| 3764 void WebGLRenderingContextBase::stencilOpSeparate(GLenum face, GLenum fail, GLen
um zfail, GLenum zpass) | 3765 void WebGLRenderingContextBase::stencilOpSeparate(GLenum face, GLenum fail, GLen
um zfail, GLenum zpass) |
| 3765 { | 3766 { |
| 3766 if (isContextLost()) | 3767 if (isContextLost()) |
| 3767 return; | 3768 return; |
| 3768 webContext()->stencilOpSeparate(face, fail, zfail, zpass); | 3769 contextGL()->StencilOpSeparate(face, fail, zfail, zpass); |
| 3769 } | 3770 } |
| 3770 | 3771 |
| 3771 CHROMIUMValuebuffer* WebGLRenderingContextBase::createValuebufferCHROMIUM() | 3772 CHROMIUMValuebuffer* WebGLRenderingContextBase::createValuebufferCHROMIUM() |
| 3772 { | 3773 { |
| 3773 if (isContextLost()) | 3774 if (isContextLost()) |
| 3774 return nullptr; | 3775 return nullptr; |
| 3775 CHROMIUMValuebuffer* o = CHROMIUMValuebuffer::create(this); | 3776 CHROMIUMValuebuffer* o = CHROMIUMValuebuffer::create(this); |
| 3776 addSharedObject(o); | 3777 addSharedObject(o); |
| 3777 return o; | 3778 return o; |
| 3778 } | 3779 } |
| 3779 | 3780 |
| 3780 void WebGLRenderingContextBase::deleteValuebufferCHROMIUM(CHROMIUMValuebuffer *v
aluebuffer) | 3781 void WebGLRenderingContextBase::deleteValuebufferCHROMIUM(CHROMIUMValuebuffer *v
aluebuffer) |
| 3781 { | 3782 { |
| 3782 if (!deleteObject(valuebuffer)) | 3783 if (!deleteObject(valuebuffer)) |
| 3783 return; | 3784 return; |
| 3784 if (valuebuffer == m_valuebufferBinding) | 3785 if (valuebuffer == m_valuebufferBinding) |
| 3785 m_valuebufferBinding = nullptr; | 3786 m_valuebufferBinding = nullptr; |
| 3786 } | 3787 } |
| 3787 | 3788 |
| 3788 GLboolean WebGLRenderingContextBase::isValuebufferCHROMIUM(CHROMIUMValuebuffer*
valuebuffer) | 3789 GLboolean WebGLRenderingContextBase::isValuebufferCHROMIUM(CHROMIUMValuebuffer*
valuebuffer) |
| 3789 { | 3790 { |
| 3790 if (!valuebuffer || isContextLost()) | 3791 if (!valuebuffer || isContextLost()) |
| 3791 return 0; | 3792 return 0; |
| 3792 if (!valuebuffer->hasEverBeenBound()) | 3793 if (!valuebuffer->hasEverBeenBound()) |
| 3793 return 0; | 3794 return 0; |
| 3794 if (valuebuffer->isDeleted()) | 3795 if (valuebuffer->isDeleted()) |
| 3795 return 0; | 3796 return 0; |
| 3796 return webContext()->isValuebufferCHROMIUM(valuebuffer->object()); | 3797 return contextGL()->IsValuebufferCHROMIUM(valuebuffer->object()); |
| 3797 } | 3798 } |
| 3798 | 3799 |
| 3799 void WebGLRenderingContextBase::bindValuebufferCHROMIUM(GLenum target, CHROMIUMV
aluebuffer* valuebuffer) | 3800 void WebGLRenderingContextBase::bindValuebufferCHROMIUM(GLenum target, CHROMIUMV
aluebuffer* valuebuffer) |
| 3800 { | 3801 { |
| 3801 bool deleted; | 3802 bool deleted; |
| 3802 if (!checkObjectToBeBound("bindValuebufferCHROMIUM", valuebuffer, deleted)) | 3803 if (!checkObjectToBeBound("bindValuebufferCHROMIUM", valuebuffer, deleted)) |
| 3803 return; | 3804 return; |
| 3804 if (deleted) | 3805 if (deleted) |
| 3805 valuebuffer = 0; | 3806 valuebuffer = 0; |
| 3806 m_valuebufferBinding = valuebuffer; | 3807 m_valuebufferBinding = valuebuffer; |
| (...skipping 1312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5119 if (!isContextLost()) { | 5120 if (!isContextLost()) { |
| 5120 // Never attempt to restore the context because the page is being torn d
own. | 5121 // Never attempt to restore the context because the page is being torn d
own. |
| 5121 forceLostContext(SyntheticLostContext, Manual); | 5122 forceLostContext(SyntheticLostContext, Manual); |
| 5122 } | 5123 } |
| 5123 } | 5124 } |
| 5124 | 5125 |
| 5125 ScriptValue WebGLRenderingContextBase::getBooleanParameter(ScriptState* scriptSt
ate, GLenum pname) | 5126 ScriptValue WebGLRenderingContextBase::getBooleanParameter(ScriptState* scriptSt
ate, GLenum pname) |
| 5126 { | 5127 { |
| 5127 GLboolean value = 0; | 5128 GLboolean value = 0; |
| 5128 if (!isContextLost()) | 5129 if (!isContextLost()) |
| 5129 webContext()->getBooleanv(pname, &value); | 5130 contextGL()->GetBooleanv(pname, &value); |
| 5130 return WebGLAny(scriptState, static_cast<bool>(value)); | 5131 return WebGLAny(scriptState, static_cast<bool>(value)); |
| 5131 } | 5132 } |
| 5132 | 5133 |
| 5133 ScriptValue WebGLRenderingContextBase::getBooleanArrayParameter(ScriptState* scr
iptState, GLenum pname) | 5134 ScriptValue WebGLRenderingContextBase::getBooleanArrayParameter(ScriptState* scr
iptState, GLenum pname) |
| 5134 { | 5135 { |
| 5135 if (pname != GL_COLOR_WRITEMASK) { | 5136 if (pname != GL_COLOR_WRITEMASK) { |
| 5136 notImplemented(); | 5137 notImplemented(); |
| 5137 return WebGLAny(scriptState, 0, 0); | 5138 return WebGLAny(scriptState, 0, 0); |
| 5138 } | 5139 } |
| 5139 GLboolean value[4] = {0}; | 5140 GLboolean value[4] = {0}; |
| 5140 if (!isContextLost()) | 5141 if (!isContextLost()) |
| 5141 webContext()->getBooleanv(pname, value); | 5142 contextGL()->GetBooleanv(pname, value); |
| 5142 bool boolValue[4]; | 5143 bool boolValue[4]; |
| 5143 for (int ii = 0; ii < 4; ++ii) | 5144 for (int ii = 0; ii < 4; ++ii) |
| 5144 boolValue[ii] = static_cast<bool>(value[ii]); | 5145 boolValue[ii] = static_cast<bool>(value[ii]); |
| 5145 return WebGLAny(scriptState, boolValue, 4); | 5146 return WebGLAny(scriptState, boolValue, 4); |
| 5146 } | 5147 } |
| 5147 | 5148 |
| 5148 ScriptValue WebGLRenderingContextBase::getFloatParameter(ScriptState* scriptStat
e, GLenum pname) | 5149 ScriptValue WebGLRenderingContextBase::getFloatParameter(ScriptState* scriptStat
e, GLenum pname) |
| 5149 { | 5150 { |
| 5150 GLfloat value = 0; | 5151 GLfloat value = 0; |
| 5151 if (!isContextLost()) | 5152 if (!isContextLost()) |
| 5152 webContext()->getFloatv(pname, &value); | 5153 contextGL()->GetFloatv(pname, &value); |
| 5153 return WebGLAny(scriptState, value); | 5154 return WebGLAny(scriptState, value); |
| 5154 } | 5155 } |
| 5155 | 5156 |
| 5156 ScriptValue WebGLRenderingContextBase::getIntParameter(ScriptState* scriptState,
GLenum pname) | 5157 ScriptValue WebGLRenderingContextBase::getIntParameter(ScriptState* scriptState,
GLenum pname) |
| 5157 { | 5158 { |
| 5158 GLint value = 0; | 5159 GLint value = 0; |
| 5159 if (!isContextLost()) | 5160 if (!isContextLost()) |
| 5160 webContext()->getIntegerv(pname, &value); | 5161 contextGL()->GetIntegerv(pname, &value); |
| 5161 return WebGLAny(scriptState, value); | 5162 return WebGLAny(scriptState, value); |
| 5162 } | 5163 } |
| 5163 | 5164 |
| 5164 ScriptValue WebGLRenderingContextBase::getInt64Parameter(ScriptState* scriptStat
e, GLenum pname) | 5165 ScriptValue WebGLRenderingContextBase::getInt64Parameter(ScriptState* scriptStat
e, GLenum pname) |
| 5165 { | 5166 { |
| 5166 GLint64 value = 0; | 5167 GLint64 value = 0; |
| 5167 if (!isContextLost()) | 5168 if (!isContextLost()) |
| 5168 webContext()->getInteger64v(pname, &value); | 5169 contextGL()->GetInteger64v(pname, &value); |
| 5169 return WebGLAny(scriptState, value); | 5170 return WebGLAny(scriptState, value); |
| 5170 } | 5171 } |
| 5171 | 5172 |
| 5172 ScriptValue WebGLRenderingContextBase::getUnsignedIntParameter(ScriptState* scri
ptState, GLenum pname) | 5173 ScriptValue WebGLRenderingContextBase::getUnsignedIntParameter(ScriptState* scri
ptState, GLenum pname) |
| 5173 { | 5174 { |
| 5174 GLint value = 0; | 5175 GLint value = 0; |
| 5175 if (!isContextLost()) | 5176 if (!isContextLost()) |
| 5176 webContext()->getIntegerv(pname, &value); | 5177 contextGL()->GetIntegerv(pname, &value); |
| 5177 return WebGLAny(scriptState, static_cast<unsigned>(value)); | 5178 return WebGLAny(scriptState, static_cast<unsigned>(value)); |
| 5178 } | 5179 } |
| 5179 | 5180 |
| 5180 ScriptValue WebGLRenderingContextBase::getWebGLFloatArrayParameter(ScriptState*
scriptState, GLenum pname) | 5181 ScriptValue WebGLRenderingContextBase::getWebGLFloatArrayParameter(ScriptState*
scriptState, GLenum pname) |
| 5181 { | 5182 { |
| 5182 GLfloat value[4] = {0}; | 5183 GLfloat value[4] = {0}; |
| 5183 if (!isContextLost()) | 5184 if (!isContextLost()) |
| 5184 webContext()->getFloatv(pname, value); | 5185 contextGL()->GetFloatv(pname, value); |
| 5185 unsigned length = 0; | 5186 unsigned length = 0; |
| 5186 switch (pname) { | 5187 switch (pname) { |
| 5187 case GL_ALIASED_POINT_SIZE_RANGE: | 5188 case GL_ALIASED_POINT_SIZE_RANGE: |
| 5188 case GL_ALIASED_LINE_WIDTH_RANGE: | 5189 case GL_ALIASED_LINE_WIDTH_RANGE: |
| 5189 case GL_DEPTH_RANGE: | 5190 case GL_DEPTH_RANGE: |
| 5190 length = 2; | 5191 length = 2; |
| 5191 break; | 5192 break; |
| 5192 case GL_BLEND_COLOR: | 5193 case GL_BLEND_COLOR: |
| 5193 case GL_COLOR_CLEAR_VALUE: | 5194 case GL_COLOR_CLEAR_VALUE: |
| 5194 length = 4; | 5195 length = 4; |
| 5195 break; | 5196 break; |
| 5196 default: | 5197 default: |
| 5197 notImplemented(); | 5198 notImplemented(); |
| 5198 } | 5199 } |
| 5199 return WebGLAny(scriptState, DOMFloat32Array::create(value, length)); | 5200 return WebGLAny(scriptState, DOMFloat32Array::create(value, length)); |
| 5200 } | 5201 } |
| 5201 | 5202 |
| 5202 ScriptValue WebGLRenderingContextBase::getWebGLIntArrayParameter(ScriptState* sc
riptState, GLenum pname) | 5203 ScriptValue WebGLRenderingContextBase::getWebGLIntArrayParameter(ScriptState* sc
riptState, GLenum pname) |
| 5203 { | 5204 { |
| 5204 GLint value[4] = {0}; | 5205 GLint value[4] = {0}; |
| 5205 if (!isContextLost()) | 5206 if (!isContextLost()) |
| 5206 webContext()->getIntegerv(pname, value); | 5207 contextGL()->GetIntegerv(pname, value); |
| 5207 unsigned length = 0; | 5208 unsigned length = 0; |
| 5208 switch (pname) { | 5209 switch (pname) { |
| 5209 case GL_MAX_VIEWPORT_DIMS: | 5210 case GL_MAX_VIEWPORT_DIMS: |
| 5210 length = 2; | 5211 length = 2; |
| 5211 break; | 5212 break; |
| 5212 case GL_SCISSOR_BOX: | 5213 case GL_SCISSOR_BOX: |
| 5213 case GL_VIEWPORT: | 5214 case GL_VIEWPORT: |
| 5214 length = 4; | 5215 length = 4; |
| 5215 break; | 5216 break; |
| 5216 default: | 5217 default: |
| (...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6099 { | 6100 { |
| 6100 return IntSize(clamp(canvas()->width(), 1, m_maxViewportDims[0]), | 6101 return IntSize(clamp(canvas()->width(), 1, m_maxViewportDims[0]), |
| 6101 clamp(canvas()->height(), 1, m_maxViewportDims[1])); | 6102 clamp(canvas()->height(), 1, m_maxViewportDims[1])); |
| 6102 } | 6103 } |
| 6103 | 6104 |
| 6104 GLint WebGLRenderingContextBase::maxDrawBuffers() | 6105 GLint WebGLRenderingContextBase::maxDrawBuffers() |
| 6105 { | 6106 { |
| 6106 if (isContextLost() || !(extensionEnabled(WebGLDrawBuffersName) || isWebGL2O
rHigher())) | 6107 if (isContextLost() || !(extensionEnabled(WebGLDrawBuffersName) || isWebGL2O
rHigher())) |
| 6107 return 0; | 6108 return 0; |
| 6108 if (!m_maxDrawBuffers) | 6109 if (!m_maxDrawBuffers) |
| 6109 webContext()->getIntegerv(GL_MAX_DRAW_BUFFERS_EXT, &m_maxDrawBuffers); | 6110 contextGL()->GetIntegerv(GL_MAX_DRAW_BUFFERS_EXT, &m_maxDrawBuffers); |
| 6110 if (!m_maxColorAttachments) | 6111 if (!m_maxColorAttachments) |
| 6111 webContext()->getIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &m_maxColorAttac
hments); | 6112 contextGL()->GetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &m_maxColorAttach
ments); |
| 6112 // WEBGL_draw_buffers requires MAX_COLOR_ATTACHMENTS >= MAX_DRAW_BUFFERS. | 6113 // WEBGL_draw_buffers requires MAX_COLOR_ATTACHMENTS >= MAX_DRAW_BUFFERS. |
| 6113 return std::min(m_maxDrawBuffers, m_maxColorAttachments); | 6114 return std::min(m_maxDrawBuffers, m_maxColorAttachments); |
| 6114 } | 6115 } |
| 6115 | 6116 |
| 6116 GLint WebGLRenderingContextBase::maxColorAttachments() | 6117 GLint WebGLRenderingContextBase::maxColorAttachments() |
| 6117 { | 6118 { |
| 6118 if (isContextLost() || !(extensionEnabled(WebGLDrawBuffersName) || isWebGL2O
rHigher())) | 6119 if (isContextLost() || !(extensionEnabled(WebGLDrawBuffersName) || isWebGL2O
rHigher())) |
| 6119 return 0; | 6120 return 0; |
| 6120 if (!m_maxColorAttachments) | 6121 if (!m_maxColorAttachments) |
| 6121 webContext()->getIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &m_maxColorAttac
hments); | 6122 contextGL()->GetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &m_maxColorAttach
ments); |
| 6122 return m_maxColorAttachments; | 6123 return m_maxColorAttachments; |
| 6123 } | 6124 } |
| 6124 | 6125 |
| 6125 void WebGLRenderingContextBase::setBackDrawBuffer(GLenum buf) | 6126 void WebGLRenderingContextBase::setBackDrawBuffer(GLenum buf) |
| 6126 { | 6127 { |
| 6127 m_backDrawBuffer = buf; | 6128 m_backDrawBuffer = buf; |
| 6128 } | 6129 } |
| 6129 | 6130 |
| 6130 void WebGLRenderingContextBase::setFramebuffer(GLenum target, WebGLFramebuffer*
buffer) | 6131 void WebGLRenderingContextBase::setFramebuffer(GLenum target, WebGLFramebuffer*
buffer) |
| 6131 { | 6132 { |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6278 } | 6279 } |
| 6279 | 6280 |
| 6280 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const | 6281 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const |
| 6281 { | 6282 { |
| 6282 return m_drawingBuffer.get(); | 6283 return m_drawingBuffer.get(); |
| 6283 } | 6284 } |
| 6284 | 6285 |
| 6285 void WebGLRenderingContextBase::resetUnpackParameters() | 6286 void WebGLRenderingContextBase::resetUnpackParameters() |
| 6286 { | 6287 { |
| 6287 if (m_unpackAlignment != 1) | 6288 if (m_unpackAlignment != 1) |
| 6288 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, 1); | 6289 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| 6289 } | 6290 } |
| 6290 | 6291 |
| 6291 void WebGLRenderingContextBase::restoreUnpackParameters() | 6292 void WebGLRenderingContextBase::restoreUnpackParameters() |
| 6292 { | 6293 { |
| 6293 if (m_unpackAlignment != 1) | 6294 if (m_unpackAlignment != 1) |
| 6294 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 6295 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); |
| 6295 } | 6296 } |
| 6296 | 6297 |
| 6297 } // namespace blink | 6298 } // namespace blink |
| OLD | NEW |