Changeset 71274 in webkit
- Timestamp:
- Nov 3, 2010 3:06:52 PM (13 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 3 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r71272 r71274 1 2010-11-03 Adrienne Walker <enne@google.com> 2 3 Reviewed by Kenneth Russell. 4 5 Implement lost, restored, and creation failure context events for 6 WebGLRenderingContext. The lost and restored functions are not hooked 7 up yet, but the context now acts according to the spec as it should 8 during a lost context. Tested manually, as there's no programmatic 9 way to lose a context yet. 10 https://bugs.webkit.org/show_bug.cgi?id=35626 11 12 * WebCore.gypi: 13 * WebCore.xcodeproj/project.pbxproj: 14 * bindings/js/JSWebGLRenderingContextCustom.cpp: 15 (WebCore::JSWebGLRenderingContext::getAttachedShaders): 16 * bindings/v8/custom/V8WebGLRenderingContextCustom.cpp: 17 (WebCore::V8WebGLRenderingContext::getAttachedShadersCallback): 18 * dom/EventNames.h: 19 * html/canvas/WebGLContextEvent.cpp: Added. 20 (WebCore::WebGLContextEvent::WebGLContextEvent): 21 (WebCore::WebGLContextEvent::~WebGLContextEvent): 22 (WebCore::WebGLContextEvent::initEvent): 23 * html/canvas/WebGLContextEvent.h: Added. 24 (WebCore::WebGLContextEvent::create): 25 (WebCore::WebGLContextEvent::statusMessage): 26 * html/canvas/WebGLContextEvent.idl: Added. 27 * html/canvas/WebGLRenderingContext.cpp: 28 (WebCore::WebGLRenderingContext::create): 29 (WebCore::WebGLRenderingContext::WebGLRenderingContext): 30 (WebCore::WebGLRenderingContext::initializeNewContext): 31 (WebCore::WebGLRenderingContext::activeTexture): 32 (WebCore::WebGLRenderingContext::attachShader): 33 (WebCore::WebGLRenderingContext::bindAttribLocation): 34 (WebCore::WebGLRenderingContext::bindBuffer): 35 (WebCore::WebGLRenderingContext::bindFramebuffer): 36 (WebCore::WebGLRenderingContext::bindRenderbuffer): 37 (WebCore::WebGLRenderingContext::bindTexture): 38 (WebCore::WebGLRenderingContext::blendColor): 39 (WebCore::WebGLRenderingContext::blendEquation): 40 (WebCore::WebGLRenderingContext::blendEquationSeparate): 41 (WebCore::WebGLRenderingContext::blendFunc): 42 (WebCore::WebGLRenderingContext::blendFuncSeparate): 43 (WebCore::WebGLRenderingContext::bufferData): 44 (WebCore::WebGLRenderingContext::bufferSubData): 45 (WebCore::WebGLRenderingContext::checkFramebufferStatus): 46 (WebCore::WebGLRenderingContext::clear): 47 (WebCore::WebGLRenderingContext::clearColor): 48 (WebCore::WebGLRenderingContext::clearDepth): 49 (WebCore::WebGLRenderingContext::clearStencil): 50 (WebCore::WebGLRenderingContext::colorMask): 51 (WebCore::WebGLRenderingContext::compileShader): 52 (WebCore::WebGLRenderingContext::copyTexImage2D): 53 (WebCore::WebGLRenderingContext::copyTexSubImage2D): 54 (WebCore::WebGLRenderingContext::createBuffer): 55 (WebCore::WebGLRenderingContext::createFramebuffer): 56 (WebCore::WebGLRenderingContext::createTexture): 57 (WebCore::WebGLRenderingContext::createProgram): 58 (WebCore::WebGLRenderingContext::createRenderbuffer): 59 (WebCore::WebGLRenderingContext::createShader): 60 (WebCore::WebGLRenderingContext::cullFace): 61 (WebCore::WebGLRenderingContext::deleteBuffer): 62 (WebCore::WebGLRenderingContext::deleteFramebuffer): 63 (WebCore::WebGLRenderingContext::deleteProgram): 64 (WebCore::WebGLRenderingContext::deleteRenderbuffer): 65 (WebCore::WebGLRenderingContext::deleteShader): 66 (WebCore::WebGLRenderingContext::deleteTexture): 67 (WebCore::WebGLRenderingContext::depthFunc): 68 (WebCore::WebGLRenderingContext::depthMask): 69 (WebCore::WebGLRenderingContext::depthRange): 70 (WebCore::WebGLRenderingContext::detachShader): 71 (WebCore::WebGLRenderingContext::disable): 72 (WebCore::WebGLRenderingContext::disableVertexAttribArray): 73 (WebCore::WebGLRenderingContext::drawArrays): 74 (WebCore::WebGLRenderingContext::drawElements): 75 (WebCore::WebGLRenderingContext::enable): 76 (WebCore::WebGLRenderingContext::enableVertexAttribArray): 77 (WebCore::WebGLRenderingContext::finish): 78 (WebCore::WebGLRenderingContext::flush): 79 (WebCore::WebGLRenderingContext::framebufferRenderbuffer): 80 (WebCore::WebGLRenderingContext::framebufferTexture2D): 81 (WebCore::WebGLRenderingContext::frontFace): 82 (WebCore::WebGLRenderingContext::generateMipmap): 83 (WebCore::WebGLRenderingContext::getActiveAttrib): 84 (WebCore::WebGLRenderingContext::getActiveUniform): 85 (WebCore::WebGLRenderingContext::getAttachedShaders): 86 (WebCore::WebGLRenderingContext::getAttribLocation): 87 (WebCore::WebGLRenderingContext::getBufferParameter): 88 (WebCore::WebGLRenderingContext::getContextAttributes): 89 (WebCore::WebGLRenderingContext::getFramebufferAttachmentParameter): 90 (WebCore::WebGLRenderingContext::getParameter): 91 (WebCore::WebGLRenderingContext::getProgramParameter): 92 (WebCore::WebGLRenderingContext::getProgramInfoLog): 93 (WebCore::WebGLRenderingContext::getRenderbufferParameter): 94 (WebCore::WebGLRenderingContext::getShaderParameter): 95 (WebCore::WebGLRenderingContext::getShaderInfoLog): 96 (WebCore::WebGLRenderingContext::getShaderSource): 97 (WebCore::WebGLRenderingContext::getTexParameter): 98 (WebCore::WebGLRenderingContext::getUniform): 99 (WebCore::WebGLRenderingContext::getUniformLocation): 100 (WebCore::WebGLRenderingContext::getVertexAttrib): 101 (WebCore::WebGLRenderingContext::getVertexAttribOffset): 102 (WebCore::WebGLRenderingContext::hint): 103 (WebCore::WebGLRenderingContext::isBuffer): 104 (WebCore::WebGLRenderingContext::isContextLost): 105 (WebCore::WebGLRenderingContext::isEnabled): 106 (WebCore::WebGLRenderingContext::isFramebuffer): 107 (WebCore::WebGLRenderingContext::isProgram): 108 (WebCore::WebGLRenderingContext::isRenderbuffer): 109 (WebCore::WebGLRenderingContext::isShader): 110 (WebCore::WebGLRenderingContext::isTexture): 111 (WebCore::WebGLRenderingContext::lineWidth): 112 (WebCore::WebGLRenderingContext::linkProgram): 113 (WebCore::WebGLRenderingContext::pixelStorei): 114 (WebCore::WebGLRenderingContext::polygonOffset): 115 (WebCore::WebGLRenderingContext::readPixels): 116 (WebCore::WebGLRenderingContext::releaseShaderCompiler): 117 (WebCore::WebGLRenderingContext::renderbufferStorage): 118 (WebCore::WebGLRenderingContext::sampleCoverage): 119 (WebCore::WebGLRenderingContext::scissor): 120 (WebCore::WebGLRenderingContext::shaderSource): 121 (WebCore::WebGLRenderingContext::stencilFunc): 122 (WebCore::WebGLRenderingContext::stencilFuncSeparate): 123 (WebCore::WebGLRenderingContext::stencilMask): 124 (WebCore::WebGLRenderingContext::stencilMaskSeparate): 125 (WebCore::WebGLRenderingContext::stencilOp): 126 (WebCore::WebGLRenderingContext::stencilOpSeparate): 127 (WebCore::WebGLRenderingContext::texImage2D): 128 (WebCore::WebGLRenderingContext::texParameter): 129 (WebCore::WebGLRenderingContext::texSubImage2DBase): 130 (WebCore::WebGLRenderingContext::texSubImage2DImpl): 131 (WebCore::WebGLRenderingContext::texSubImage2D): 132 (WebCore::WebGLRenderingContext::uniform1f): 133 (WebCore::WebGLRenderingContext::uniform1fv): 134 (WebCore::WebGLRenderingContext::uniform1i): 135 (WebCore::WebGLRenderingContext::uniform1iv): 136 (WebCore::WebGLRenderingContext::uniform2f): 137 (WebCore::WebGLRenderingContext::uniform2fv): 138 (WebCore::WebGLRenderingContext::uniform2i): 139 (WebCore::WebGLRenderingContext::uniform2iv): 140 (WebCore::WebGLRenderingContext::uniform3f): 141 (WebCore::WebGLRenderingContext::uniform3fv): 142 (WebCore::WebGLRenderingContext::uniform3i): 143 (WebCore::WebGLRenderingContext::uniform3iv): 144 (WebCore::WebGLRenderingContext::uniform4f): 145 (WebCore::WebGLRenderingContext::uniform4fv): 146 (WebCore::WebGLRenderingContext::uniform4i): 147 (WebCore::WebGLRenderingContext::uniform4iv): 148 (WebCore::WebGLRenderingContext::uniformMatrix2fv): 149 (WebCore::WebGLRenderingContext::uniformMatrix3fv): 150 (WebCore::WebGLRenderingContext::uniformMatrix4fv): 151 (WebCore::WebGLRenderingContext::useProgram): 152 (WebCore::WebGLRenderingContext::validateProgram): 153 (WebCore::WebGLRenderingContext::vertexAttribPointer): 154 (WebCore::WebGLRenderingContext::viewport): 155 (WebCore::WebGLRenderingContext::loseContext): 156 (WebCore::WebGLRenderingContext::restoreContext): 157 (WebCore::WebGLRenderingContext::addObject): 158 (WebCore::WebGLRenderingContext::vertexAttribfImpl): 159 (WebCore::WebGLRenderingContext::vertexAttribfvImpl): 160 * html/canvas/WebGLRenderingContext.h: 161 * html/canvas/WebGLRenderingContext.idl: 162 * platform/graphics/GraphicsContext3D.h: 163 1 164 2010-11-03 Kenneth Russell <kbr@google.com> 2 165 -
trunk/WebCore/WebCore.gypi
r71272 r71274 217 217 'html/canvas/WebGLBuffer.idl', 218 218 'html/canvas/WebGLContextAttributes.idl', 219 'html/canvas/WebGLContextEvent.idl', 219 220 'html/canvas/WebGLFramebuffer.idl', 220 221 'html/canvas/WebGLProgram.idl', … … 1870 1871 'html/canvas/WebGLContextAttributes.cpp', 1871 1872 'html/canvas/WebGLContextAttributes.h', 1873 'html/canvas/WebGLContextEvent.cpp', 1874 'html/canvas/WebGLContextEvent.h', 1872 1875 'html/canvas/WebGLFramebuffer.cpp', 1873 1876 'html/canvas/WebGLFramebuffer.h', -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r71272 r71274 2885 2885 93F19B1608245E59001E9ABC /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8216299029F4FB501000131 /* JavaScriptCore.framework */; }; 2886 2886 93F19B1708245E59001E9ABC /* libicucore.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 93F1D31A0558CC5C00821BC0 /* libicucore.dylib */; }; 2887 93F6F1ED127F70B10055CB06 /* WebGLContextEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93F6F1EA127F70B10055CB06 /* WebGLContextEvent.cpp */; }; 2888 93F6F1EE127F70B10055CB06 /* WebGLContextEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 93F6F1EB127F70B10055CB06 /* WebGLContextEvent.h */; }; 2887 2889 93F925430F7EF5B8007E37C9 /* CheckedRadioButtons.h in Headers */ = {isa = PBXBuildFile; fileRef = 93F925410F7EF5B8007E37C9 /* CheckedRadioButtons.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2888 2890 93F925440F7EF5B8007E37C9 /* CheckedRadioButtons.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93F925420F7EF5B8007E37C9 /* CheckedRadioButtons.cpp */; }; … … 8969 8971 93F19B1A08245E5A001E9ABC /* WebCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = WebCore.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 8970 8972 93F1D31A0558CC5C00821BC0 /* libicucore.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libicucore.dylib; path = /usr/lib/libicucore.dylib; sourceTree = "<absolute>"; }; 8973 93F6F1EA127F70B10055CB06 /* WebGLContextEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebGLContextEvent.cpp; path = canvas/WebGLContextEvent.cpp; sourceTree = "<group>"; }; 8974 93F6F1EB127F70B10055CB06 /* WebGLContextEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebGLContextEvent.h; path = canvas/WebGLContextEvent.h; sourceTree = "<group>"; }; 8975 93F6F1EC127F70B10055CB06 /* WebGLContextEvent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = WebGLContextEvent.idl; path = canvas/WebGLContextEvent.idl; sourceTree = "<group>"; }; 8971 8976 93F8B3050A300FE100F61AB8 /* CodeGenerator.pm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.perl; name = CodeGenerator.pm; path = scripts/CodeGenerator.pm; sourceTree = "<group>"; }; 8972 8977 93F8B3060A300FEA00F61AB8 /* CodeGeneratorJS.pm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.perl; name = CodeGeneratorJS.pm; path = ../scripts/CodeGeneratorJS.pm; sourceTree = "<group>"; wrapsLines = 0; }; … … 12584 12589 6E4E91AA10F7FB3100A2779C /* WebGLContextAttributes.h */, 12585 12590 6E4E91AB10F7FB3100A2779C /* WebGLContextAttributes.idl */, 12591 93F6F1EA127F70B10055CB06 /* WebGLContextEvent.cpp */, 12592 93F6F1EB127F70B10055CB06 /* WebGLContextEvent.h */, 12593 93F6F1EC127F70B10055CB06 /* WebGLContextEvent.idl */, 12586 12594 49C7B9AE1042D32E0009D447 /* WebGLFramebuffer.cpp */, 12587 12595 49C7B9AF1042D32E0009D447 /* WebGLFramebuffer.h */, … … 21277 21285 6E67D2A71280E8A4008758F7 /* Extensions3DOpenGL.h in Headers */, 21278 21286 6E67D2A91280E8BD008758F7 /* Extensions3D.h in Headers */, 21287 93F6F1EE127F70B10055CB06 /* WebGLContextEvent.h in Headers */, 21279 21288 ); 21280 21289 runOnlyForDeploymentPostprocessing = 0; … … 23840 23849 97DD4D860FDF4D6E00ECF9A4 /* XSSAuditor.cpp in Sources */, 23841 23850 6E67D2A61280E8A4008758F7 /* Extensions3DOpenGL.cpp in Sources */, 23851 93F6F1ED127F70B10055CB06 /* WebGLContextEvent.cpp in Sources */, 23842 23852 ); 23843 23853 runOnlyForDeploymentPostprocessing = 0; -
trunk/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp
r70496 r71274 172 172 WebGLProgram* program = toWebGLProgram(exec->argument(0)); 173 173 if (exec->hadException()) 174 return js Undefined();174 return jsNull(); 175 175 Vector<WebGLShader*> shaders; 176 176 bool succeed = context->getAttachedShaders(program, shaders, ec); 177 177 if (ec) { 178 178 setDOMException(exec, ec); 179 return js Undefined();179 return jsNull(); 180 180 } 181 181 if (!succeed) 182 return js Undefined();182 return jsNull(); 183 183 MarkedArgumentBuffer list; 184 184 for (size_t ii = 0; ii < shaders.size(); ++ii) -
trunk/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
r65689 r71274 237 237 if (ec) { 238 238 V8Proxy::setDOMException(ec); 239 return v8:: Undefined();239 return v8::Null(); 240 240 } 241 241 if (!succeed) 242 return v8:: Undefined();242 return v8::Null(); 243 243 v8::Local<v8::Array> array = v8::Array::New(shaders.size()); 244 244 for (size_t ii = 0; ii < shaders.size(); ++ii) -
trunk/WebCore/dom/EventNames.h
r69100 r71274 169 169 macro(webkitfullscreenchange) \ 170 170 \ 171 macro(webkitspeechchange) 171 macro(webkitspeechchange) \ 172 \ 173 macro(webglcontextlost) \ 174 macro(webglcontextrestored) \ 175 macro(webglcontextcreationerror) \ 172 176 \ 173 177 // end of DOM_EVENT_NAMES_FOR_EACH -
trunk/WebCore/html/canvas/WebGLRenderingContext.cpp
r71190 r71274 49 49 #include "WebGLBuffer.h" 50 50 #include "WebGLContextAttributes.h" 51 #include "WebGLContextEvent.h" 51 52 #include "WebGLFramebuffer.h" 52 53 #include "WebGLProgram.h" … … 91 92 RefPtr<GraphicsContext3D> context(GraphicsContext3D::create(attrs ? attrs->attributes() : emptyAttributes, hostWindow)); 92 93 93 if (!context) 94 if (!context) { 95 canvas->dispatchEvent(WebGLContextEvent::create(eventNames().webglcontextcreationerrorEvent, false, true, "Could not create a WebGL context.")); 94 96 return 0; 97 } 95 98 96 99 return new WebGLRenderingContext(canvas, context); … … 100 103 : CanvasRenderingContext(passedCanvas) 101 104 , m_context(context) 102 , m_needsUpdate(true)103 , m_markedCanvasDirty(false)104 , m_activeTextureUnit(0)105 105 , m_videoCache(4) 106 , m_packAlignment(4) 107 , m_unpackAlignment(4) 108 , m_unpackFlipY(false) 109 , m_unpackPremultiplyAlpha(false) 106 , m_contextLost(false) 110 107 { 111 108 ASSERT(m_context); 109 initializeNewContext(); 110 } 111 112 void WebGLRenderingContext::initializeNewContext() 113 { 114 m_needsUpdate = true; 115 m_markedCanvasDirty = false; 116 m_activeTextureUnit = 0; 117 m_packAlignment = 4; 118 m_unpackAlignment = 4; 119 m_unpackFlipY = false; 120 m_unpackPremultiplyAlpha = false; 121 m_boundArrayBuffer = 0; 122 m_boundElementArrayBuffer = 0; 123 m_currentProgram = 0; 124 m_framebufferBinding = 0; 125 m_renderbufferBinding = 0; 126 m_vertexAttribState.clear(); 112 127 113 128 int numCombinedTextureImageUnits = 0; 114 129 m_context->getIntegerv(GraphicsContext3D::MAX_COMBINED_TEXTURE_IMAGE_UNITS, &numCombinedTextureImageUnits); 130 m_textureUnits.clear(); 115 131 m_textureUnits.resize(numCombinedTextureImageUnits); 116 132 … … 200 216 { 201 217 UNUSED_PARAM(ec); 218 if (isContextLost()) 219 return; 202 220 if (texture - GraphicsContext3D::TEXTURE0 >= m_textureUnits.size()) { 203 221 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM); … … 212 230 { 213 231 UNUSED_PARAM(ec); 214 if ( !validateWebGLObject(program) || !validateWebGLObject(shader))232 if (isContextLost() || !validateWebGLObject(program) || !validateWebGLObject(shader)) 215 233 return; 216 234 if (!program->attachShader(shader)) { … … 226 244 { 227 245 UNUSED_PARAM(ec); 228 if ( !validateWebGLObject(program))246 if (isContextLost() || !validateWebGLObject(program)) 229 247 return; 230 248 m_context->bindAttribLocation(objectOrZero(program), index, name); … … 235 253 { 236 254 UNUSED_PARAM(ec); 255 if (isContextLost()) 256 return; 237 257 if (buffer && buffer->context() != this) { 238 258 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION); … … 263 283 { 264 284 UNUSED_PARAM(ec); 285 if (isContextLost()) 286 return; 265 287 if (buffer && buffer->context() != this) { 266 288 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION); … … 279 301 { 280 302 UNUSED_PARAM(ec); 303 if (isContextLost()) 304 return; 281 305 if (renderBuffer && renderBuffer->context() != this) { 282 306 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION); … … 296 320 { 297 321 UNUSED_PARAM(ec); 322 if (isContextLost()) 323 return; 298 324 if (texture && texture->context() != this) { 299 325 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION); … … 329 355 void WebGLRenderingContext::blendColor(double red, double green, double blue, double alpha) 330 356 { 357 if (isContextLost()) 358 return; 331 359 m_context->blendColor(red, green, blue, alpha); 332 360 cleanupAfterGraphicsCall(false); … … 335 363 void WebGLRenderingContext::blendEquation(unsigned long mode) 336 364 { 337 if ( !validateBlendEquation(mode))365 if (isContextLost() || !validateBlendEquation(mode)) 338 366 return; 339 367 m_context->blendEquation(mode); … … 343 371 void WebGLRenderingContext::blendEquationSeparate(unsigned long modeRGB, unsigned long modeAlpha) 344 372 { 345 if ( !validateBlendEquation(modeRGB) || !validateBlendEquation(modeAlpha))373 if (isContextLost() || !validateBlendEquation(modeRGB) || !validateBlendEquation(modeAlpha)) 346 374 return; 347 375 m_context->blendEquationSeparate(modeRGB, modeAlpha); … … 352 380 void WebGLRenderingContext::blendFunc(unsigned long sfactor, unsigned long dfactor) 353 381 { 354 if ( !validateBlendFuncFactors(sfactor, dfactor))382 if (isContextLost() || !validateBlendFuncFactors(sfactor, dfactor)) 355 383 return; 356 384 m_context->blendFunc(sfactor, dfactor); … … 360 388 void WebGLRenderingContext::blendFuncSeparate(unsigned long srcRGB, unsigned long dstRGB, unsigned long srcAlpha, unsigned long dstAlpha) 361 389 { 362 if ( !validateBlendFuncFactors(srcRGB, dstRGB))390 if (isContextLost() || !validateBlendFuncFactors(srcRGB, dstRGB)) 363 391 return; 364 392 m_context->blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); … … 369 397 { 370 398 UNUSED_PARAM(ec); 399 if (isContextLost()) 400 return; 371 401 WebGLBuffer* buffer = validateBufferDataParameters(target, usage); 372 402 if (!buffer) … … 386 416 { 387 417 UNUSED_PARAM(ec); 418 if (isContextLost()) 419 return; 388 420 WebGLBuffer* buffer = validateBufferDataParameters(target, usage); 389 421 if (!buffer) … … 403 435 { 404 436 UNUSED_PARAM(ec); 437 if (isContextLost()) 438 return; 405 439 WebGLBuffer* buffer = validateBufferDataParameters(target, usage); 406 440 if (!buffer) … … 420 454 { 421 455 UNUSED_PARAM(ec); 456 if (isContextLost()) 457 return; 422 458 WebGLBuffer* buffer = validateBufferDataParameters(target, GraphicsContext3D::STATIC_DRAW); 423 459 if (!buffer) … … 437 473 { 438 474 UNUSED_PARAM(ec); 475 if (isContextLost()) 476 return; 439 477 WebGLBuffer* buffer = validateBufferDataParameters(target, GraphicsContext3D::STATIC_DRAW); 440 478 if (!buffer) … … 453 491 unsigned long WebGLRenderingContext::checkFramebufferStatus(unsigned long target) 454 492 { 493 if (isContextLost()) 494 return GraphicsContext3D::FRAMEBUFFER_UNSUPPORTED; 455 495 if (target != GraphicsContext3D::FRAMEBUFFER) { 456 496 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM); … … 467 507 void WebGLRenderingContext::clear(unsigned long mask) 468 508 { 509 if (isContextLost()) 510 return; 469 511 if (mask & ~(GraphicsContext3D::COLOR_BUFFER_BIT | GraphicsContext3D::DEPTH_BUFFER_BIT | GraphicsContext3D::STENCIL_BUFFER_BIT)) { 470 512 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE); … … 481 523 void WebGLRenderingContext::clearColor(double r, double g, double b, double a) 482 524 { 525 if (isContextLost()) 526 return; 483 527 if (isnan(r)) 484 528 r = 0; … … 495 539 void WebGLRenderingContext::clearDepth(double depth) 496 540 { 541 if (isContextLost()) 542 return; 497 543 m_context->clearDepth(depth); 498 544 cleanupAfterGraphicsCall(false); … … 501 547 void WebGLRenderingContext::clearStencil(long s) 502 548 { 549 if (isContextLost()) 550 return; 503 551 m_context->clearStencil(s); 504 552 cleanupAfterGraphicsCall(false); … … 507 555 void WebGLRenderingContext::colorMask(bool red, bool green, bool blue, bool alpha) 508 556 { 557 if (isContextLost()) 558 return; 509 559 m_context->colorMask(red, green, blue, alpha); 510 560 cleanupAfterGraphicsCall(false); … … 514 564 { 515 565 UNUSED_PARAM(ec); 516 if ( !validateWebGLObject(shader))566 if (isContextLost() || !validateWebGLObject(shader)) 517 567 return; 518 568 m_context->compileShader(objectOrZero(shader)); … … 522 572 void WebGLRenderingContext::copyTexImage2D(unsigned long target, long level, unsigned long internalformat, long x, long y, unsigned long width, unsigned long height, long border) 523 573 { 574 if (isContextLost()) 575 return; 524 576 if (!validateTexFuncParameters(target, level, internalformat, width, height, border, internalformat, GraphicsContext3D::UNSIGNED_BYTE)) 525 577 return; … … 551 603 void WebGLRenderingContext::copyTexSubImage2D(unsigned long target, long level, long xoffset, long yoffset, long x, long y, unsigned long width, unsigned long height) 552 604 { 605 if (isContextLost()) 606 return; 553 607 WebGLTexture* tex = validateTextureBinding(target, true); 554 608 if (!tex) … … 572 626 PassRefPtr<WebGLBuffer> WebGLRenderingContext::createBuffer() 573 627 { 628 if (isContextLost()) 629 return 0; 574 630 RefPtr<WebGLBuffer> o = WebGLBuffer::create(this); 575 631 addObject(o.get()); … … 579 635 PassRefPtr<WebGLFramebuffer> WebGLRenderingContext::createFramebuffer() 580 636 { 637 if (isContextLost()) 638 return 0; 581 639 RefPtr<WebGLFramebuffer> o = WebGLFramebuffer::create(this); 582 640 addObject(o.get()); … … 586 644 PassRefPtr<WebGLTexture> WebGLRenderingContext::createTexture() 587 645 { 646 if (isContextLost()) 647 return 0; 588 648 RefPtr<WebGLTexture> o = WebGLTexture::create(this); 589 649 addObject(o.get()); … … 593 653 PassRefPtr<WebGLProgram> WebGLRenderingContext::createProgram() 594 654 { 655 if (isContextLost()) 656 return 0; 595 657 RefPtr<WebGLProgram> o = WebGLProgram::create(this); 596 658 addObject(o.get()); … … 600 662 PassRefPtr<WebGLRenderbuffer> WebGLRenderingContext::createRenderbuffer() 601 663 { 664 if (isContextLost()) 665 return 0; 602 666 RefPtr<WebGLRenderbuffer> o = WebGLRenderbuffer::create(this); 603 667 addObject(o.get()); … … 608 672 { 609 673 UNUSED_PARAM(ec); 674 if (isContextLost()) 675 return 0; 610 676 if (type != GraphicsContext3D::VERTEX_SHADER && type != GraphicsContext3D::FRAGMENT_SHADER) { 611 677 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM); … … 620 686 void WebGLRenderingContext::cullFace(unsigned long mode) 621 687 { 688 if (isContextLost()) 689 return; 622 690 m_context->cullFace(mode); 623 691 cleanupAfterGraphicsCall(false); … … 626 694 void WebGLRenderingContext::deleteBuffer(WebGLBuffer* buffer) 627 695 { 628 if ( !buffer)696 if (isContextLost() || !buffer) 629 697 return; 630 698 … … 648 716 void WebGLRenderingContext::deleteFramebuffer(WebGLFramebuffer* framebuffer) 649 717 { 650 if ( !framebuffer)718 if (isContextLost() || !framebuffer) 651 719 return; 652 720 if (framebuffer == m_framebufferBinding) { … … 660 728 void WebGLRenderingContext::deleteProgram(WebGLProgram* program) 661 729 { 662 if ( !program)730 if (isContextLost() || !program) 663 731 return; 664 732 if (program->context() != this) { … … 673 741 void WebGLRenderingContext::deleteRenderbuffer(WebGLRenderbuffer* renderbuffer) 674 742 { 675 if ( !renderbuffer)743 if (isContextLost() || !renderbuffer) 676 744 return; 677 745 if (renderbuffer == m_renderbufferBinding) … … 684 752 void WebGLRenderingContext::deleteShader(WebGLShader* shader) 685 753 { 686 if ( !shader)754 if (isContextLost() || !shader) 687 755 return; 688 756 … … 692 760 void WebGLRenderingContext::deleteTexture(WebGLTexture* texture) 693 761 { 694 if ( !texture)762 if (isContextLost() || !texture) 695 763 return; 696 764 … … 702 770 void WebGLRenderingContext::depthFunc(unsigned long func) 703 771 { 772 if (isContextLost()) 773 return; 704 774 m_context->depthFunc(func); 705 775 cleanupAfterGraphicsCall(false); … … 708 778 void WebGLRenderingContext::depthMask(bool flag) 709 779 { 780 if (isContextLost()) 781 return; 710 782 m_context->depthMask(flag); 711 783 cleanupAfterGraphicsCall(false); … … 714 786 void WebGLRenderingContext::depthRange(double zNear, double zFar) 715 787 { 788 if (isContextLost()) 789 return; 716 790 m_context->depthRange(zNear, zFar); 717 791 cleanupAfterGraphicsCall(false); … … 721 795 { 722 796 UNUSED_PARAM(ec); 723 if ( !validateWebGLObject(program) || !validateWebGLObject(shader))797 if (isContextLost() || !validateWebGLObject(program) || !validateWebGLObject(shader)) 724 798 return; 725 799 if (!program->detachShader(shader)) { … … 735 809 void WebGLRenderingContext::disable(unsigned long cap) 736 810 { 737 if ( !validateCapability(cap))811 if (isContextLost() || !validateCapability(cap)) 738 812 return; 739 813 m_context->disable(cap); … … 744 818 { 745 819 UNUSED_PARAM(ec); 820 if (isContextLost()) 821 return; 746 822 if (index >= m_maxVertexAttribs) { 747 823 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE); … … 940 1016 UNUSED_PARAM(ec); 941 1017 942 if ( !validateDrawMode(mode))1018 if (isContextLost() || !validateDrawMode(mode)) 943 1019 return; 944 1020 … … 989 1065 UNUSED_PARAM(ec); 990 1066 991 if ( !validateDrawMode(mode))1067 if (isContextLost() || !validateDrawMode(mode)) 992 1068 return; 993 1069 … … 1054 1130 void WebGLRenderingContext::enable(unsigned long cap) 1055 1131 { 1056 if ( !validateCapability(cap))1132 if (isContextLost() || !validateCapability(cap)) 1057 1133 return; 1058 1134 m_context->enable(cap); … … 1063 1139 { 1064 1140 UNUSED_PARAM(ec); 1141 if (isContextLost()) 1142 return; 1065 1143 if (index >= m_maxVertexAttribs) { 1066 1144 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE); … … 1079 1157 void WebGLRenderingContext::finish() 1080 1158 { 1159 if (isContextLost()) 1160 return; 1081 1161 m_context->finish(); 1082 1162 cleanupAfterGraphicsCall(true); … … 1086 1166 void WebGLRenderingContext::flush() 1087 1167 { 1168 if (isContextLost()) 1169 return; 1088 1170 m_context->flush(); 1089 1171 cleanupAfterGraphicsCall(true); … … 1093 1175 { 1094 1176 UNUSED_PARAM(ec); 1095 if ( !validateFramebufferFuncParameters(target, attachment))1177 if (isContextLost() || !validateFramebufferFuncParameters(target, attachment)) 1096 1178 return; 1097 1179 if (renderbuffertarget != GraphicsContext3D::RENDERBUFFER) { … … 1118 1200 { 1119 1201 UNUSED_PARAM(ec); 1120 if ( !validateFramebufferFuncParameters(target, attachment))1202 if (isContextLost() || !validateFramebufferFuncParameters(target, attachment)) 1121 1203 return; 1122 1204 if (level) { … … 1142 1224 void WebGLRenderingContext::frontFace(unsigned long mode) 1143 1225 { 1226 if (isContextLost()) 1227 return; 1144 1228 m_context->frontFace(mode); 1145 1229 cleanupAfterGraphicsCall(false); … … 1148 1232 void WebGLRenderingContext::generateMipmap(unsigned long target) 1149 1233 { 1234 if (isContextLost()) 1235 return; 1150 1236 WebGLTexture* tex = validateTextureBinding(target, false); 1151 1237 if (!tex) … … 1176 1262 { 1177 1263 UNUSED_PARAM(ec); 1264 if (isContextLost() || !validateWebGLObject(program)) 1265 return 0; 1178 1266 ActiveInfo info; 1179 if (!validateWebGLObject(program))1180 return 0;1181 1267 if (!m_context->getActiveAttrib(objectOrZero(program), index, info)) 1182 1268 return 0; … … 1187 1273 { 1188 1274 UNUSED_PARAM(ec); 1275 if (isContextLost() || !validateWebGLObject(program)) 1276 return 0; 1189 1277 ActiveInfo info; 1190 if (!validateWebGLObject(program))1191 return 0;1192 1278 if (!m_context->getActiveUniform(objectOrZero(program), index, info)) 1193 1279 return 0; … … 1202 1288 UNUSED_PARAM(ec); 1203 1289 shaderObjects.clear(); 1204 if ( !validateWebGLObject(program))1290 if (isContextLost() || !validateWebGLObject(program)) 1205 1291 return false; 1206 1292 int numShaders = 0; … … 1227 1313 int WebGLRenderingContext::getAttribLocation(WebGLProgram* program, const String& name) 1228 1314 { 1315 if (isContextLost()) 1316 return -1; 1229 1317 return m_context->getAttribLocation(objectOrZero(program), name); 1230 1318 } … … 1233 1321 { 1234 1322 UNUSED_PARAM(ec); 1323 if (isContextLost()) 1324 return WebGLGetInfo(); 1235 1325 if (target != GraphicsContext3D::ARRAY_BUFFER && target != GraphicsContext3D::ELEMENT_ARRAY_BUFFER) { 1236 1326 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM); … … 1253 1343 PassRefPtr<WebGLContextAttributes> WebGLRenderingContext::getContextAttributes() 1254 1344 { 1345 if (isContextLost()) 1346 return 0; 1255 1347 // We always need to return a new WebGLContextAttributes object to 1256 1348 // prevent the user from mutating any cached version. … … 1266 1358 { 1267 1359 UNUSED_PARAM(ec); 1268 if ( !validateFramebufferFuncParameters(target, attachment))1360 if (isContextLost() || !validateFramebufferFuncParameters(target, attachment)) 1269 1361 return WebGLGetInfo(); 1270 1362 switch (pname) { … … 1314 1406 { 1315 1407 UNUSED_PARAM(ec); 1408 if (isContextLost()) 1409 return WebGLGetInfo(); 1316 1410 WebGLStateRestorer(this, false); 1317 1411 switch (pname) { … … 1505 1599 { 1506 1600 UNUSED_PARAM(ec); 1507 if ( !validateWebGLObject(program))1601 if (isContextLost() || !validateWebGLObject(program)) 1508 1602 return WebGLGetInfo(); 1509 1603 … … 1534 1628 { 1535 1629 UNUSED_PARAM(ec); 1536 if ( !validateWebGLObject(program))1537 return "";1630 if (isContextLost() || !validateWebGLObject(program)) 1631 return String(); 1538 1632 WebGLStateRestorer(this, false); 1539 1633 return m_context->getProgramInfoLog(objectOrZero(program)); … … 1543 1637 { 1544 1638 UNUSED_PARAM(ec); 1639 if (isContextLost()) 1640 return WebGLGetInfo(); 1545 1641 if (target != GraphicsContext3D::RENDERBUFFER) { 1546 1642 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM); … … 1576 1672 { 1577 1673 UNUSED_PARAM(ec); 1578 if ( !validateWebGLObject(shader))1674 if (isContextLost() || !validateWebGLObject(shader)) 1579 1675 return WebGLGetInfo(); 1580 1676 WebGLStateRestorer(this, false); … … 1601 1697 { 1602 1698 UNUSED_PARAM(ec); 1603 if ( !validateWebGLObject(shader))1604 return "";1699 if (isContextLost() || !validateWebGLObject(shader)) 1700 return String(); 1605 1701 WebGLStateRestorer(this, false); 1606 1702 return m_context->getShaderInfoLog(objectOrZero(shader)); … … 1610 1706 { 1611 1707 UNUSED_PARAM(ec); 1612 if ( !validateWebGLObject(shader))1613 return "";1708 if (isContextLost() || !validateWebGLObject(shader)) 1709 return String(); 1614 1710 WebGLStateRestorer(this, false); 1615 1711 return m_context->getShaderSource(objectOrZero(shader)); … … 1619 1715 { 1620 1716 UNUSED_PARAM(ec); 1717 if (isContextLost()) 1718 return WebGLGetInfo(); 1621 1719 WebGLTexture* tex = validateTextureBinding(target, false); 1622 1720 if (!tex) … … 1640 1738 { 1641 1739 UNUSED_PARAM(ec); 1642 if ( !validateWebGLObject(program))1740 if (isContextLost() || !validateWebGLObject(program)) 1643 1741 return WebGLGetInfo(); 1644 1742 if (!uniformLocation) { … … 1784 1882 { 1785 1883 UNUSED_PARAM(ec); 1786 if ( !validateWebGLObject(program))1884 if (isContextLost() || !validateWebGLObject(program)) 1787 1885 return 0; 1788 1886 WebGLStateRestorer(this, false); … … 1796 1894 { 1797 1895 UNUSED_PARAM(ec); 1896 if (isContextLost()) 1897 return WebGLGetInfo(); 1798 1898 WebGLStateRestorer(this, false); 1799 1899 if (index >= m_maxVertexAttribs) { … … 1843 1943 long WebGLRenderingContext::getVertexAttribOffset(unsigned long index, unsigned long pname) 1844 1944 { 1945 if (isContextLost()) 1946 return 0; 1845 1947 long result = m_context->getVertexAttribOffset(index, pname); 1846 1948 cleanupAfterGraphicsCall(false); … … 1850 1952 void WebGLRenderingContext::hint(unsigned long target, unsigned long mode) 1851 1953 { 1954 if (isContextLost()) 1955 return; 1852 1956 if (target != GraphicsContext3D::GENERATE_MIPMAP_HINT) { 1853 1957 m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM); … … 1860 1964 bool WebGLRenderingContext::isBuffer(WebGLBuffer* buffer) 1861 1965 { 1862 if (!buffer )1966 if (!buffer || isContextLost()) 1863 1967 return false; 1864 1968 … … 1866 1970 } 1867 1971 1972 bool WebGLRenderingContext::isContextLost() const 1973 { 1974 return m_contextLost; 1975 } 1976 1868 1977 bool WebGLRenderingContext::isEnabled(unsigned long cap) 1869 1978 { 1870 if (!validateCapability(cap) )1979 if (!validateCapability(cap) || isContextLost()) 1871 1980 return false; 1872 1981 return m_context->isEnabled(cap); … … 1875 1984 bool WebGLRenderingContext::isFramebuffer(WebGLFramebuffer* framebuffer) 1876 1985 { 1877 if (!framebuffer )1986 if (!framebuffer || isContextLost()) 1878 1987 return false; 1879 1988 … … 1883 1992 bool WebGLRenderingContext::isProgram(WebGLProgram* program) 1884 1993 { 1885 if (!program )1994 if (!program || isContextLost()) 1886 1995 return false; 1887 1996 … … 1891 2000 bool WebGLRenderingContext::isRenderbuffer(WebGLRenderbuffer* renderbuffer) 1892 2001 { 1893 if (!renderbuffer )2002 if (!renderbuffer || isContextLost()) 1894 2003 return false; 1895 2004 … … 1899 2008 bool WebGLRenderingContext::isShader(WebGLShader* shader) 1900 2009 { 1901 if (!shader )2010 if (!shader || isContextLost()) 1902 2011 return false; 1903 2012 … … 1907 2016 bool WebGLRenderingContext::isTexture(WebGLTexture* texture) 1908 2017 { 1909 if (!texture )2018 if (!texture || isContextLost()) 1910 2019 return false; 1911 2020 … … 1915 2024 void WebGLRenderingContext::lineWidth(double width) 1916 2025 { 2026 if (isContextLost()) 2027 return; 1917 2028 m_context->lineWidth((float) width); 1918 2029 cleanupAfterGraphicsCall(false); … … 1922 2033 { 1923 2034 UNUSED_PARAM(ec); 1924 if ( !validateWebGLObject(program))2035 if (isContextLost() || !validateWebGLObject(program)) 1925 2036 return; 1926 2037 if (!isGLES2Compliant()) { … … 1942 2053 void WebGLRenderingContext::pixelStorei(unsigned long pname, long param) 1943 2054 { 2055 if (isContextLost()) 2056 return; 1944 2057 switch (pname) { 1945 2058 case GraphicsContext3D::UNPACK_FLIP_Y_WEBGL: … … 1968 2081 void WebGLRenderingContext::polygonOffset(double factor, double units) 1969 2082 { 2083 if (isContextLost()) 2084 return; 1970 2085 m_context->polygonOffset((float) factor, (float) units); 1971 2086 cleanupAfterGraphicsCall(false); … … 1974 2089 void WebGLRenderingContext::readPixels(long x, long y, long width, long height, unsigned long format, unsigned long type, ArrayBufferView* pixels, ExceptionCode& ec) 1975 2090 { 2091 if (isContextLost()) 2092 return; 1976 2093 if (!canvas()->originClean()) { 1977 2094 ec = SECURITY_ERR; … … 2045 2162 void WebGLRenderingContext::releaseShaderCompiler() 2046 2163 { 2164 if (isContextLost()) 2165 return; 2047 2166 m_context->releaseShaderCompiler(); 2048 2167 cleanupAfterGraphicsCall(false); … … 2051 2170 void WebGLRenderingContext::renderbufferStorage(unsigned long target, unsigned long internalformat, unsigned long width, unsigned long height) 2052 2171 { 2172 if (isContextLost()) 2173 return; 2053 2174 switch (internalformat) { 2054 2175 case GraphicsContext3D::DEPTH_COMPONENT16: … … 2070 2191 void WebGLRenderingContext::sampleCoverage(double value, bool invert) 2071 2192 { 2193 if (isContextLost()) 2194 return; 2072 2195 m_context->sampleCoverage((float) value, invert); 2073 2196 cleanupAfterGraphicsCall(false); … … 2076 2199 void WebGLRenderingContext::scissor(long x, long y, unsigned long width, unsigned long height) 2077 2200 { 2201 if (isContextLost()) 2202 return; 2078 2203 m_context->scissor(x, y, width, height); 2079 2204 cleanupAfterGraphicsCall(false); … … 2083 2208 { 2084 2209 UNUSED_PARAM(ec); 2085 if ( !validateWebGLObject(shader))2210 if (isContextLost() || !validateWebGLObject(shader)) 2086 2211 return; 2087 2212 m_context->shaderSource(objectOrZero(shader), string); … … 2091 2216 void WebGLRenderingContext::stencilFunc(unsigned long func, long ref, unsigned long mask) 2092 2217 { 2218 if (isContextLost()) 2219 return; 2093 2220 m_context->stencilFunc(func, ref, mask); 2094 2221 cleanupAfterGraphicsCall(false); … … 2097 2224 void WebGLRenderingContext::stencilFuncSeparate(unsigned long face, unsigned long func, long ref, unsigned long mask) 2098 2225 { 2226 if (isContextLost()) 2227 return; 2099 2228 m_context->stencilFuncSeparate(face, func, ref, mask); 2100 2229 cleanupAfterGraphicsCall(false); … … 2103 2232 void WebGLRenderingContext::stencilMask(unsigned long mask) 2104 2233 { 2234 if (isContextLost()) 2235 return; 2105 2236 m_context->stencilMask(mask); 2106 2237 cleanupAfterGraphicsCall(false); … … 2109 2240 void WebGLRenderingContext::stencilMaskSeparate(unsigned long face, unsigned long mask) 2110 2241 { 2242 if (isContextLost()) 2243 return; 2111 2244 m_context->stencilMaskSeparate(face, mask); 2112 2245 cleanupAfterGraphicsCall(false); … … 2115 2248 void WebGLRenderingContext::stencilOp(unsigned long fail, unsigned long zfail, unsigned long zpass) 2116 2249 { 2250 if (isContextLost()) 2251 return; 2117 2252 m_context->stencilOp(fail, zfail, zpass); 2118 2253 cleanupAfterGraphicsCall(false); … … 2121 2256 void WebGLRenderingContext::stencilOpSeparate(unsigned long face, unsigned long fail, unsigned long zfail, unsigned long zpass) 2122 2257 { 2258 if (isContextLost()) 2259 return; 2123 2260 m_context->stencilOpSeparate(face, fail, zfail, zpass); 2124 2261 cleanupAfterGraphicsCall(false); … … 2170 2307 unsigned format, unsigned type, ArrayBufferView* pixels, ExceptionCode& ec) 2171 2308 { 2172 if ( !validateTexFuncData(width, height, format, type, pixels))2309 if (isContextLost() || !validateTexFuncData(width, height, format, type, pixels)) 2173 2310 return; 2174 2311 void* data = pixels ? pixels->baseAddress() : 0; … … 2197 2334 { 2198 2335 ec = 0; 2336 if (isContextLost()) 2337 return; 2199 2338 Vector<uint8_t> data; 2200 2339 if (!m_context->extractImageData(pixels, format, type, m_unpackFlipY, m_unpackPremultiplyAlpha, data)) { … … 2214 2353 { 2215 2354 ec = 0; 2355 if (isContextLost()) 2356 return; 2216 2357 if (!image || !image->cachedImage()) { 2217 2358 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE); … … 2227 2368 { 2228 2369 ec = 0; 2370 if (isContextLost()) 2371 return; 2229 2372 if (!canvas || !canvas->buffer()) { 2230 2373 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE); … … 2259 2402 { 2260 2403 ec = 0; 2404 if (isContextLost()) 2405 return; 2261 2406 RefPtr<Image> image = videoFrameToImage(video); 2262 2407 if (!video) … … 2267 2412 void WebGLRenderingContext::texParameter(unsigned long target, unsigned long pname, float paramf, int parami, bool isFloat) 2268 2413 { 2414 if (isContextLost()) 2415 return; 2269 2416 WebGLTexture* tex = validateTextureBinding(target, false); 2270 2417 if (!tex) … … 2312 2459 // FIXME: For now we ignore any errors returned 2313 2460 ec = 0; 2461 if (isContextLost()) 2462 return; 2314 2463 if (!validateTexFuncFormatAndType(format, type)) 2315 2464 return; … … 2325 2474 { 2326 2475 ec = 0; 2476 if (isContextLost()) 2477 return; 2327 2478 Vector<uint8_t> data; 2328 2479 if (!m_context->extractImageData(image, format, type, flipY, premultiplyAlpha, data)) { … … 2338 2489 unsigned format, unsigned type, ArrayBufferView* pixels, ExceptionCode& ec) 2339 2490 { 2340 if ( !validateTexFuncData(width, height, format, type, pixels))2491 if (isContextLost() || !validateTexFuncData(width, height, format, type, pixels)) 2341 2492 return; 2342 2493 void* data = pixels ? pixels->baseAddress() : 0; … … 2364 2515 { 2365 2516 ec = 0; 2517 if (isContextLost()) 2518 return; 2366 2519 Vector<uint8_t> data; 2367 2520 if (!m_context->extractImageData(pixels, format, type, m_unpackFlipY, m_unpackPremultiplyAlpha, data)) { … … 2377 2530 { 2378 2531 ec = 0; 2532 if (isContextLost()) 2533 return; 2379 2534 if (!image || !image->cachedImage()) { 2380 2535 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE); … … 2390 2545 { 2391 2546 ec = 0; 2547 if (isContextLost()) 2548 return; 2392 2549 if (!canvas || !canvas->buffer()) { 2393 2550 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE); … … 2403 2560 { 2404 2561 ec = 0; 2562 if (isContextLost()) 2563 return; 2405 2564 RefPtr<Image> image = videoFrameToImage(video); 2406 2565 if (!video) … … 2412 2571 { 2413 2572 UNUSED_PARAM(ec); 2414 if ( !location)2573 if (isContextLost() || !location) 2415 2574 return; 2416 2575 … … 2427 2586 { 2428 2587 UNUSED_PARAM(ec); 2429 if ( !validateUniformParameters(location, v, 1))2588 if (isContextLost() || !validateUniformParameters(location, v, 1)) 2430 2589 return; 2431 2590 … … 2437 2596 { 2438 2597 UNUSED_PARAM(ec); 2439 if ( !validateUniformParameters(location, v, size, 1))2598 if (isContextLost() || !validateUniformParameters(location, v, size, 1)) 2440 2599 return; 2441 2600 … … 2447 2606 { 2448 2607 UNUSED_PARAM(ec); 2449 if ( !location)2608 if (isContextLost() || !location) 2450 2609 return; 2451 2610 … … 2462 2621 { 2463 2622 UNUSED_PARAM(ec); 2464 if ( !validateUniformParameters(location, v, 1))2623 if (isContextLost() || !validateUniformParameters(location, v, 1)) 2465 2624 return; 2466 2625 … … 2472 2631 { 2473 2632 UNUSED_PARAM(ec); 2474 if ( !validateUniformParameters(location, v, size, 1))2633 if (isContextLost() || !validateUniformParameters(location, v, size, 1)) 2475 2634 return; 2476 2635 … … 2482 2641 { 2483 2642 UNUSED_PARAM(ec); 2484 if ( !location)2643 if (isContextLost() || !location) 2485 2644 return; 2486 2645 … … 2497 2656 { 2498 2657 UNUSED_PARAM(ec); 2499 if ( !validateUniformParameters(location, v, 2))2658 if (isContextLost() || !validateUniformParameters(location, v, 2)) 2500 2659 return; 2501 2660 … … 2507 2666 { 2508 2667 UNUSED_PARAM(ec); 2509 if ( !validateUniformParameters(location, v, size, 2))2668 if (isContextLost() || !validateUniformParameters(location, v, size, 2)) 2510 2669 return; 2511 2670 … … 2517 2676 { 2518 2677 UNUSED_PARAM(ec); 2519 if ( !location)2678 if (isContextLost() || !location) 2520 2679 return; 2521 2680 … … 2532 2691 { 2533 2692 UNUSED_PARAM(ec); 2534 if ( !validateUniformParameters(location, v, 2))2693 if (isContextLost() || !validateUniformParameters(location, v, 2)) 2535 2694 return; 2536 2695 … … 2542 2701 { 2543 2702 UNUSED_PARAM(ec); 2544 if ( !validateUniformParameters(location, v, size, 2))2703 if (isContextLost() || !validateUniformParameters(location, v, size, 2)) 2545 2704 return; 2546 2705 … … 2552 2711 { 2553 2712 UNUSED_PARAM(ec); 2554 if ( !location)2713 if (isContextLost() || !location) 2555 2714 return; 2556 2715 … … 2567 2726 { 2568 2727 UNUSED_PARAM(ec); 2569 if ( !validateUniformParameters(location, v, 3))2728 if (isContextLost() || !validateUniformParameters(location, v, 3)) 2570 2729 return; 2571 2730 … … 2577 2736 { 2578 2737 UNUSED_PARAM(ec); 2579 if ( !validateUniformParameters(location, v, size, 3))2738 if (isContextLost() || !validateUniformParameters(location, v, size, 3)) 2580 2739 return; 2581 2740 … … 2587 2746 { 2588 2747 UNUSED_PARAM(ec); 2589 if ( !location)2748 if (isContextLost() || !location) 2590 2749 return; 2591 2750 … … 2602 2761 { 2603 2762 UNUSED_PARAM(ec); 2604 if ( !validateUniformParameters(location, v, 3))2763 if (isContextLost() || !validateUniformParameters(location, v, 3)) 2605 2764 return; 2606 2765 … … 2612 2771 { 2613 2772 UNUSED_PARAM(ec); 2614 if ( !validateUniformParameters(location, v, size, 3))2773 if (isContextLost() || !validateUniformParameters(location, v, size, 3)) 2615 2774 return; 2616 2775 … … 2622 2781 { 2623 2782 UNUSED_PARAM(ec); 2624 if ( !location)2783 if (isContextLost() || !location) 2625 2784 return; 2626 2785 … … 2637 2796 { 2638 2797 UNUSED_PARAM(ec); 2639 if ( !validateUniformParameters(location, v, 4))2798 if (isContextLost() || !validateUniformParameters(location, v, 4)) 2640 2799 return; 2641 2800 … … 2647 2806 { 2648 2807 UNUSED_PARAM(ec); 2649 if ( !validateUniformParameters(location, v, size, 4))2808 if (isContextLost() || !validateUniformParameters(location, v, size, 4)) 2650 2809 return; 2651 2810 … … 2657 2816 { 2658 2817 UNUSED_PARAM(ec); 2659 if ( !location)2818 if (isContextLost() || !location) 2660 2819 return; 2661 2820 … … 2672 2831 { 2673 2832 UNUSED_PARAM(ec); 2674 if ( !validateUniformParameters(location, v, 4))2833 if (isContextLost() || !validateUniformParameters(location, v, 4)) 2675 2834 return; 2676 2835 … … 2682 2841 { 2683 2842 UNUSED_PARAM(ec); 2684 if ( !validateUniformParameters(location, v, size, 4))2843 if (isContextLost() || !validateUniformParameters(location, v, size, 4)) 2685 2844 return; 2686 2845 … … 2692 2851 { 2693 2852 UNUSED_PARAM(ec); 2694 if ( !validateUniformMatrixParameters(location, transpose, v, 4))2853 if (isContextLost() || !validateUniformMatrixParameters(location, transpose, v, 4)) 2695 2854 return; 2696 2855 m_context->uniformMatrix2fv(location->location(), transpose, v->data(), v->length() / 4); … … 2701 2860 { 2702 2861 UNUSED_PARAM(ec); 2703 if ( !validateUniformMatrixParameters(location, transpose, v, size, 4))2862 if (isContextLost() || !validateUniformMatrixParameters(location, transpose, v, size, 4)) 2704 2863 return; 2705 2864 m_context->uniformMatrix2fv(location->location(), transpose, v, size / 4); … … 2710 2869 { 2711 2870 UNUSED_PARAM(ec); 2712 if ( !validateUniformMatrixParameters(location, transpose, v, 9))2871 if (isContextLost() || !validateUniformMatrixParameters(location, transpose, v, 9)) 2713 2872 return; 2714 2873 m_context->uniformMatrix3fv(location->location(), transpose, v->data(), v->length() / 9); … … 2719 2878 { 2720 2879 UNUSED_PARAM(ec); 2721 if ( !validateUniformMatrixParameters(location, transpose, v, size, 9))2880 if (isContextLost() || !validateUniformMatrixParameters(location, transpose, v, size, 9)) 2722 2881 return; 2723 2882 m_context->uniformMatrix3fv(location->location(), transpose, v, size / 9); … … 2728 2887 { 2729 2888 UNUSED_PARAM(ec); 2730 if ( !validateUniformMatrixParameters(location, transpose, v, 16))2889 if (isContextLost() || !validateUniformMatrixParameters(location, transpose, v, 16)) 2731 2890 return; 2732 2891 m_context->uniformMatrix4fv(location->location(), transpose, v->data(), v->length() / 16); … … 2737 2896 { 2738 2897 UNUSED_PARAM(ec); 2739 if ( !validateUniformMatrixParameters(location, transpose, v, size, 16))2898 if (isContextLost() || !validateUniformMatrixParameters(location, transpose, v, size, 16)) 2740 2899 return; 2741 2900 m_context->uniformMatrix4fv(location->location(), transpose, v, size / 16); … … 2746 2905 { 2747 2906 UNUSED_PARAM(ec); 2907 if (isContextLost()) 2908 return; 2748 2909 if (program && program->context() != this) { 2749 2910 m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION); … … 2769 2930 { 2770 2931 UNUSED_PARAM(ec); 2771 if ( !validateWebGLObject(program))2932 if (isContextLost() || !validateWebGLObject(program)) 2772 2933 return; 2773 2934 m_context->validateProgram(objectOrZero(program)); … … 2838 2999 { 2839 3000 UNUSED_PARAM(ec); 3001 if (isContextLost()) 3002 return; 2840 3003 if (index >= m_maxVertexAttribs) { 2841 3004 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE); … … 2882 3045 void WebGLRenderingContext::viewport(long x, long y, unsigned long width, unsigned long height) 2883 3046 { 3047 if (isContextLost()) 3048 return; 2884 3049 if (isnan(x)) 2885 3050 x = 0; … … 2894 3059 } 2895 3060 3061 void WebGLRenderingContext::loseContext() 3062 { 3063 if (isContextLost()) 3064 return; 3065 3066 m_contextLost = true; 3067 3068 detachAndRemoveAllObjects(); 3069 3070 // There is no direct way to clear errors from a GL implementation and 3071 // looping until getError() becomes NO_ERROR might cause an infinite loop if 3072 // the driver or context implementation had a bug. So, loop a reasonably 3073 // large number of times to clear any existing errors. 3074 for (int i = 0; i < 100; ++i) { 3075 if (m_context->getError() == GraphicsContext3D::NO_ERROR) 3076 break; 3077 } 3078 m_context->synthesizeGLError(GraphicsContext3D::CONTEXT_LOST_WEBGL); 3079 3080 canvas()->dispatchEvent(WebGLContextEvent::create(eventNames().webglcontextlostEvent, false, true, "")); 3081 } 3082 3083 void WebGLRenderingContext::restoreContext() 3084 { 3085 if (!isContextLost()) 3086 return; 3087 3088 // The rendering context is not restored if there is no handler for 3089 // the context restored event. 3090 if (!canvas()->hasEventListeners(eventNames().webglcontextrestoredEvent)) 3091 return; 3092 3093 m_contextLost = false; 3094 initializeNewContext(); 3095 3096 canvas()->dispatchEvent(WebGLContextEvent::create(eventNames().webglcontextrestoredEvent, false, true, "")); 3097 } 3098 2896 3099 void WebGLRenderingContext::removeObject(WebGLObject* object) 2897 3100 { … … 2901 3104 void WebGLRenderingContext::addObject(WebGLObject* object) 2902 3105 { 3106 ASSERT(!isContextLost()); 2903 3107 removeObject(object); 2904 3108 m_canvasObjects.add(object); … … 3506 3710 void WebGLRenderingContext::vertexAttribfImpl(unsigned long index, int expectedSize, float v0, float v1, float v2, float v3) 3507 3711 { 3712 if (isContextLost()) 3713 return; 3508 3714 if (index >= m_maxVertexAttribs) { 3509 3715 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE); … … 3538 3744 void WebGLRenderingContext::vertexAttribfvImpl(unsigned long index, Float32Array* v, int expectedSize) 3539 3745 { 3746 if (isContextLost()) 3747 return; 3540 3748 if (!v) { 3541 3749 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE); … … 3547 3755 void WebGLRenderingContext::vertexAttribfvImpl(unsigned long index, float* v, int size, int expectedSize) 3548 3756 { 3757 if (isContextLost()) 3758 return; 3549 3759 if (!v) { 3550 3760 m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE); -
trunk/WebCore/html/canvas/WebGLRenderingContext.h
r71185 r71274 177 177 void hint(unsigned long target, unsigned long mode); 178 178 bool isBuffer(WebGLBuffer*); 179 bool isContextLost() const; 179 180 bool isEnabled(unsigned long cap); 180 181 bool isFramebuffer(WebGLFramebuffer*); … … 278 279 void viewport(long x, long y, unsigned long width, unsigned long height); 279 280 281 void loseContext(); 282 void restoreContext(); 283 280 284 GraphicsContext3D* graphicsContext3D() const { return m_context.get(); } 281 285 #if USE(ACCELERATED_COMPOSITING) … … 293 297 294 298 WebGLRenderingContext(HTMLCanvasElement*, PassRefPtr<GraphicsContext3D>); 299 void initializeNewContext(); 295 300 296 301 void addObject(WebGLObject*); … … 334 339 bool m_needsUpdate; 335 340 bool m_markedCanvasDirty; 336 // FIXME: I think this is broken -- it does not increment any337 // reference counts, so may refer to destroyed objects.338 341 HashSet<RefPtr<WebGLObject> > m_canvasObjects; 339 342 … … 422 425 bool m_unpackFlipY; 423 426 bool m_unpackPremultiplyAlpha; 427 bool m_contextLost; 424 428 425 429 // Helpers for getParameter and others -
trunk/WebCore/html/canvas/WebGLRenderingContext.idl
r68460 r71274 464 464 const unsigned int UNPACK_FLIP_Y_WEBGL = 0x9240; 465 465 const unsigned int UNPACK_PREMULTIPLY_ALPHA_WEBGL = 0x9241; 466 const unsigned int CONTEXT_LOST_WEBGL = 0x9242; 466 467 467 468 [StrictTypeChecking] void activeTexture(in unsigned long texture) raises(DOMException); … … 552 553 // any getProgramParameter(in WebGLProgram program, in unsigned long pname) raises(DOMException); 553 554 [StrictTypeChecking, Custom] void getProgramParameter(); 554 [StrictTypeChecking ] DOMString getProgramInfoLog(in WebGLProgram program) raises(DOMException);555 [StrictTypeChecking, ConvertNullStringTo=Null] DOMString getProgramInfoLog(in WebGLProgram program) raises(DOMException); 555 556 // any getRenderbufferParameter(in unsigned long target, in unsigned long pname) raises(DOMException); 556 557 [StrictTypeChecking, Custom] void getRenderbufferParameter(); … … 558 559 [StrictTypeChecking, Custom] void getShaderParameter() raises(DOMException); 559 560 560 [StrictTypeChecking ] DOMString getShaderInfoLog(in WebGLShader shader) raises(DOMException);561 [StrictTypeChecking, ConvertNullStringTo=Null] DOMString getShaderInfoLog(in WebGLShader shader) raises(DOMException); 561 562 562 563 // TBD 563 564 // void glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision); 564 565 565 [StrictTypeChecking ] DOMString getShaderSource(in WebGLShader shader) raises(DOMException);566 [StrictTypeChecking, ConvertNullStringTo=Null] DOMString getShaderSource(in WebGLShader shader) raises(DOMException); 566 567 567 568 // any getTexParameter(in unsigned long target, in unsigned long pname) raises(DOMException); … … 580 581 [StrictTypeChecking] void hint(in unsigned long target, in unsigned long mode); 581 582 [StrictTypeChecking] boolean isBuffer(in WebGLBuffer buffer); 583 [StrictTypeChecking] boolean isContextLost(); 582 584 [StrictTypeChecking] boolean isEnabled(in unsigned long cap); 583 585 [StrictTypeChecking] boolean isFramebuffer(in WebGLFramebuffer framebuffer); -
trunk/WebCore/platform/graphics/GraphicsContext3D.h
r71272 r71274 406 406 UNPACK_FLIP_Y_WEBGL = 0x9240, 407 407 UNPACK_PREMULTIPLY_ALPHA_WEBGL = 0x9241, 408 CONTEXT_LOST_WEBGL = 0x9242, 408 409 }; 409 410
Note: See TracChangeset
for help on using the changeset viewer.