Chromium Code Reviews| 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 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 866 | 866 |
| 867 } // namespace anonymous | 867 } // namespace anonymous |
| 868 | 868 |
| 869 WebGLRenderingContextBase::WebGLRenderingContextBase(HTMLCanvasElement* passedCa nvas, PassOwnPtr<WebGraphicsContext3D> context, const WebGLContextAttributes& re questedAttributes) | 869 WebGLRenderingContextBase::WebGLRenderingContextBase(HTMLCanvasElement* passedCa nvas, PassOwnPtr<WebGraphicsContext3D> context, const WebGLContextAttributes& re questedAttributes) |
| 870 : CanvasRenderingContext(passedCanvas) | 870 : CanvasRenderingContext(passedCanvas) |
| 871 , m_contextLostMode(NotLostContext) | 871 , m_contextLostMode(NotLostContext) |
| 872 , m_autoRecoveryMethod(Manual) | 872 , m_autoRecoveryMethod(Manual) |
| 873 , m_dispatchContextLostEventTimer(this, &WebGLRenderingContextBase::dispatch ContextLostEvent) | 873 , m_dispatchContextLostEventTimer(this, &WebGLRenderingContextBase::dispatch ContextLostEvent) |
| 874 , m_restoreAllowed(false) | 874 , m_restoreAllowed(false) |
| 875 , m_restoreTimer(this, &WebGLRenderingContextBase::maybeRestoreContext) | 875 , m_restoreTimer(this, &WebGLRenderingContextBase::maybeRestoreContext) |
| 876 , m_preservedDefaultVAOObjectWrapper(false) | |
| 876 , m_generatedImageCache(4) | 877 , m_generatedImageCache(4) |
| 877 , m_requestedAttributes(requestedAttributes) | 878 , m_requestedAttributes(requestedAttributes) |
| 878 , m_synthesizedErrorsToConsole(true) | 879 , m_synthesizedErrorsToConsole(true) |
| 879 , m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole) | 880 , m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole) |
| 880 , m_multisamplingAllowed(false) | 881 , m_multisamplingAllowed(false) |
| 881 , m_multisamplingObserverRegistered(false) | 882 , m_multisamplingObserverRegistered(false) |
| 882 , m_onePlusMaxNonDefaultTextureUnit(0) | 883 , m_onePlusMaxNonDefaultTextureUnit(0) |
| 883 , m_isWebGL2FormatsTypesAdded(false) | 884 , m_isWebGL2FormatsTypesAdded(false) |
| 884 , m_isOESTextureFloatFormatsTypesAdded(false) | 885 , m_isOESTextureFloatFormatsTypesAdded(false) |
| 885 , m_isOESTextureHalfFloatFormatsTypesAdded(false) | 886 , m_isOESTextureHalfFloatFormatsTypesAdded(false) |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 986 m_backDrawBuffer = GL_BACK; | 987 m_backDrawBuffer = GL_BACK; |
| 987 | 988 |
| 988 m_readBufferOfDefaultFramebuffer = GL_BACK; | 989 m_readBufferOfDefaultFramebuffer = GL_BACK; |
| 989 | 990 |
| 990 if (isWebGL2OrHigher()) { | 991 if (isWebGL2OrHigher()) { |
| 991 m_defaultVertexArrayObject = WebGLVertexArrayObject::create(this, WebGLV ertexArrayObjectBase::VaoTypeDefault); | 992 m_defaultVertexArrayObject = WebGLVertexArrayObject::create(this, WebGLV ertexArrayObjectBase::VaoTypeDefault); |
| 992 } else { | 993 } else { |
| 993 m_defaultVertexArrayObject = WebGLVertexArrayObjectOES::create(this, Web GLVertexArrayObjectBase::VaoTypeDefault); | 994 m_defaultVertexArrayObject = WebGLVertexArrayObjectOES::create(this, Web GLVertexArrayObjectBase::VaoTypeDefault); |
| 994 } | 995 } |
| 995 addContextObject(m_defaultVertexArrayObject.get()); | 996 addContextObject(m_defaultVertexArrayObject.get()); |
| 997 // We can't preserve this object's wrapper yet since there's no ScriptState available. | |
| 998 m_preservedDefaultVAOObjectWrapper = false; | |
| 996 m_boundVertexArrayObject = m_defaultVertexArrayObject; | 999 m_boundVertexArrayObject = m_defaultVertexArrayObject; |
| 997 | 1000 |
| 998 m_vertexAttribValue.resize(m_maxVertexAttribs); | 1001 m_vertexAttribValue.resize(m_maxVertexAttribs); |
| 999 | 1002 |
| 1000 createFallbackBlackTextures1x1(); | 1003 createFallbackBlackTextures1x1(); |
| 1001 | 1004 |
| 1002 webContext()->viewport(0, 0, drawingBufferWidth(), drawingBufferHeight()); | 1005 webContext()->viewport(0, 0, drawingBufferWidth(), drawingBufferHeight()); |
| 1003 webContext()->scissor(0, 0, drawingBufferWidth(), drawingBufferHeight()); | 1006 webContext()->scissor(0, 0, drawingBufferWidth(), drawingBufferHeight()); |
| 1004 | 1007 |
| 1005 m_contextLostCallbackAdapter = WebGLRenderingContextLostCallback::create(thi s); | 1008 m_contextLostCallbackAdapter = WebGLRenderingContextLostCallback::create(thi s); |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1357 synthesizeGLError(GL_INVALID_ENUM, "activeTexture", "texture unit out of range"); | 1360 synthesizeGLError(GL_INVALID_ENUM, "activeTexture", "texture unit out of range"); |
| 1358 return; | 1361 return; |
| 1359 } | 1362 } |
| 1360 m_activeTextureUnit = texture - GL_TEXTURE0; | 1363 m_activeTextureUnit = texture - GL_TEXTURE0; |
| 1361 webContext()->activeTexture(texture); | 1364 webContext()->activeTexture(texture); |
| 1362 | 1365 |
| 1363 drawingBuffer()->setActiveTextureUnit(texture); | 1366 drawingBuffer()->setActiveTextureUnit(texture); |
| 1364 | 1367 |
| 1365 } | 1368 } |
| 1366 | 1369 |
| 1367 void WebGLRenderingContextBase::attachShader(WebGLProgram* program, WebGLShader* shader) | 1370 void WebGLRenderingContextBase::attachShader(ScriptState* scriptState, WebGLProg ram* program, WebGLShader* shader) |
| 1368 { | 1371 { |
| 1369 if (isContextLost() || !validateWebGLObject("attachShader", program) || !val idateWebGLObject("attachShader", shader)) | 1372 if (isContextLost() || !validateWebGLObject("attachShader", program) || !val idateWebGLObject("attachShader", shader)) |
| 1370 return; | 1373 return; |
| 1371 if (!program->attachShader(shader)) { | 1374 if (!program->attachShader(shader)) { |
| 1372 synthesizeGLError(GL_INVALID_OPERATION, "attachShader", "shader attachme nt already has shader"); | 1375 synthesizeGLError(GL_INVALID_OPERATION, "attachShader", "shader attachme nt already has shader"); |
| 1373 return; | 1376 return; |
| 1374 } | 1377 } |
| 1375 webContext()->attachShader(objectOrZero(program), objectOrZero(shader)); | 1378 webContext()->attachShader(objectOrZero(program), objectOrZero(shader)); |
| 1376 shader->onAttached(); | 1379 shader->onAttached(); |
| 1380 preserveObjectWrapper(scriptState, program, "shader", shader->type(), shader ); | |
| 1377 } | 1381 } |
| 1378 | 1382 |
| 1379 void WebGLRenderingContextBase::bindAttribLocation(WebGLProgram* program, GLuint index, const String& name) | 1383 void WebGLRenderingContextBase::bindAttribLocation(WebGLProgram* program, GLuint index, const String& name) |
| 1380 { | 1384 { |
| 1381 if (isContextLost() || !validateWebGLObject("bindAttribLocation", program)) | 1385 if (isContextLost() || !validateWebGLObject("bindAttribLocation", program)) |
| 1382 return; | 1386 return; |
| 1383 if (!validateLocationLength("bindAttribLocation", name)) | 1387 if (!validateLocationLength("bindAttribLocation", name)) |
| 1384 return; | 1388 return; |
| 1385 if (!validateString("bindAttribLocation", name)) | 1389 if (!validateString("bindAttribLocation", name)) |
| 1386 return; | 1390 return; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1430 default: | 1434 default: |
| 1431 ASSERT_NOT_REACHED(); | 1435 ASSERT_NOT_REACHED(); |
| 1432 return false; | 1436 return false; |
| 1433 } | 1437 } |
| 1434 | 1438 |
| 1435 if (buffer && !buffer->getInitialTarget()) | 1439 if (buffer && !buffer->getInitialTarget()) |
| 1436 buffer->setInitialTarget(target); | 1440 buffer->setInitialTarget(target); |
| 1437 return true; | 1441 return true; |
| 1438 } | 1442 } |
| 1439 | 1443 |
| 1440 void WebGLRenderingContextBase::bindBuffer(GLenum target, WebGLBuffer* buffer) | 1444 void WebGLRenderingContextBase::bindBuffer(ScriptState* scriptState, GLenum targ et, WebGLBuffer* buffer) |
| 1441 { | 1445 { |
| 1442 bool deleted; | 1446 bool deleted; |
| 1443 if (!checkObjectToBeBound("bindBuffer", buffer, deleted)) | 1447 if (!checkObjectToBeBound("bindBuffer", buffer, deleted)) |
| 1444 return; | 1448 return; |
| 1445 if (deleted) | 1449 if (deleted) |
| 1446 buffer = 0; | 1450 buffer = 0; |
| 1447 if (!validateAndUpdateBufferBindTarget("bindBuffer", target, buffer)) | 1451 if (!validateAndUpdateBufferBindTarget("bindBuffer", target, buffer)) |
| 1448 return; | 1452 return; |
| 1449 | 1453 |
| 1450 webContext()->bindBuffer(target, objectOrZero(buffer)); | 1454 webContext()->bindBuffer(target, objectOrZero(buffer)); |
| 1455 preserveObjectWrapper(scriptState, this, "buffer", target, buffer); | |
| 1456 maybePreserveDefaultVAOObjectWrapper(scriptState); | |
| 1451 } | 1457 } |
| 1452 | 1458 |
| 1453 void WebGLRenderingContextBase::bindFramebuffer(GLenum target, WebGLFramebuffer* buffer) | 1459 void WebGLRenderingContextBase::bindFramebuffer(ScriptState* scriptState, GLenum target, WebGLFramebuffer* buffer) |
| 1454 { | 1460 { |
| 1455 bool deleted; | 1461 bool deleted; |
| 1456 if (!checkObjectToBeBound("bindFramebuffer", buffer, deleted)) | 1462 if (!checkObjectToBeBound("bindFramebuffer", buffer, deleted)) |
| 1457 return; | 1463 return; |
| 1458 | 1464 |
| 1459 if (deleted) | 1465 if (deleted) |
| 1460 buffer = 0; | 1466 buffer = 0; |
| 1461 | 1467 |
| 1462 if (target != GL_FRAMEBUFFER) { | 1468 if (target != GL_FRAMEBUFFER) { |
| 1463 synthesizeGLError(GL_INVALID_ENUM, "bindFramebuffer", "invalid target"); | 1469 synthesizeGLError(GL_INVALID_ENUM, "bindFramebuffer", "invalid target"); |
| 1464 return; | 1470 return; |
| 1465 } | 1471 } |
| 1466 | 1472 |
| 1467 setFramebuffer(target, buffer); | 1473 setFramebuffer(target, buffer); |
| 1474 if (scriptState) | |
| 1475 preserveObjectWrapper(scriptState, this, "framebuffer", 0, buffer); | |
| 1468 } | 1476 } |
| 1469 | 1477 |
| 1470 void WebGLRenderingContextBase::bindRenderbuffer(GLenum target, WebGLRenderbuffe r* renderBuffer) | 1478 void WebGLRenderingContextBase::bindRenderbuffer(ScriptState* scriptState, GLenu m target, WebGLRenderbuffer* renderBuffer) |
| 1471 { | 1479 { |
| 1472 bool deleted; | 1480 bool deleted; |
| 1473 if (!checkObjectToBeBound("bindRenderbuffer", renderBuffer, deleted)) | 1481 if (!checkObjectToBeBound("bindRenderbuffer", renderBuffer, deleted)) |
| 1474 return; | 1482 return; |
| 1475 if (deleted) | 1483 if (deleted) |
| 1476 renderBuffer = 0; | 1484 renderBuffer = 0; |
| 1477 if (target != GL_RENDERBUFFER) { | 1485 if (target != GL_RENDERBUFFER) { |
| 1478 synthesizeGLError(GL_INVALID_ENUM, "bindRenderbuffer", "invalid target") ; | 1486 synthesizeGLError(GL_INVALID_ENUM, "bindRenderbuffer", "invalid target") ; |
| 1479 return; | 1487 return; |
| 1480 } | 1488 } |
| 1481 m_renderbufferBinding = renderBuffer; | 1489 m_renderbufferBinding = renderBuffer; |
| 1482 webContext()->bindRenderbuffer(target, objectOrZero(renderBuffer)); | 1490 webContext()->bindRenderbuffer(target, objectOrZero(renderBuffer)); |
| 1491 preserveObjectWrapper(scriptState, this, "renderbuffer", 0, renderBuffer); | |
| 1483 if (renderBuffer) | 1492 if (renderBuffer) |
| 1484 renderBuffer->setHasEverBeenBound(); | 1493 renderBuffer->setHasEverBeenBound(); |
| 1485 } | 1494 } |
| 1486 | 1495 |
| 1487 void WebGLRenderingContextBase::bindTexture(GLenum target, WebGLTexture* texture ) | 1496 void WebGLRenderingContextBase::bindTexture(ScriptState* scriptState, GLenum tar get, WebGLTexture* texture) |
| 1488 { | 1497 { |
| 1489 bool deleted; | 1498 bool deleted; |
| 1490 if (!checkObjectToBeBound("bindTexture", texture, deleted)) | 1499 if (!checkObjectToBeBound("bindTexture", texture, deleted)) |
| 1491 return; | 1500 return; |
| 1492 if (deleted) | 1501 if (deleted) |
| 1493 texture = 0; | 1502 texture = 0; |
| 1494 if (texture && texture->getTarget() && texture->getTarget() != target) { | 1503 if (texture && texture->getTarget() && texture->getTarget() != target) { |
| 1495 synthesizeGLError(GL_INVALID_OPERATION, "bindTexture", "textures can not be used with multiple targets"); | 1504 synthesizeGLError(GL_INVALID_OPERATION, "bindTexture", "textures can not be used with multiple targets"); |
| 1496 return; | 1505 return; |
| 1497 } | 1506 } |
| 1507 | |
| 1508 const char* bindingPointName = nullptr; | |
| 1498 if (target == GL_TEXTURE_2D) { | 1509 if (target == GL_TEXTURE_2D) { |
| 1499 m_textureUnits[m_activeTextureUnit].m_texture2DBinding = texture; | 1510 m_textureUnits[m_activeTextureUnit].m_texture2DBinding = texture; |
| 1500 | 1511 |
| 1501 if (!m_activeTextureUnit) | 1512 if (!m_activeTextureUnit) |
| 1502 drawingBuffer()->setTexture2DBinding(objectOrZero(texture)); | 1513 drawingBuffer()->setTexture2DBinding(objectOrZero(texture)); |
| 1514 bindingPointName = "texture_2d"; | |
| 1503 } else if (target == GL_TEXTURE_CUBE_MAP) { | 1515 } else if (target == GL_TEXTURE_CUBE_MAP) { |
| 1504 m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding = texture; | 1516 m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding = texture; |
| 1517 bindingPointName = "texture_cube_map"; | |
| 1505 } else if (isWebGL2OrHigher() && target == GL_TEXTURE_2D_ARRAY) { | 1518 } else if (isWebGL2OrHigher() && target == GL_TEXTURE_2D_ARRAY) { |
| 1506 m_textureUnits[m_activeTextureUnit].m_texture2DArrayBinding = texture; | 1519 m_textureUnits[m_activeTextureUnit].m_texture2DArrayBinding = texture; |
| 1520 bindingPointName = "texture_2d_array"; | |
| 1507 } else if (isWebGL2OrHigher() && target == GL_TEXTURE_3D) { | 1521 } else if (isWebGL2OrHigher() && target == GL_TEXTURE_3D) { |
| 1508 m_textureUnits[m_activeTextureUnit].m_texture3DBinding = texture; | 1522 m_textureUnits[m_activeTextureUnit].m_texture3DBinding = texture; |
| 1523 bindingPointName = "texture_3d"; | |
| 1509 } else { | 1524 } else { |
| 1510 synthesizeGLError(GL_INVALID_ENUM, "bindTexture", "invalid target"); | 1525 synthesizeGLError(GL_INVALID_ENUM, "bindTexture", "invalid target"); |
| 1511 return; | 1526 return; |
| 1512 } | 1527 } |
| 1513 | 1528 |
| 1514 webContext()->bindTexture(target, objectOrZero(texture)); | 1529 webContext()->bindTexture(target, objectOrZero(texture)); |
| 1530 // This is called both internally and externally (from JavaScript). We only update which wrapper | |
| 1531 // is preserved when it's called from JavaScript. | |
| 1532 if (scriptState) { | |
| 1533 preserveObjectWrapper(scriptState, this, bindingPointName, m_activeTextu reUnit, texture); | |
| 1534 } | |
| 1515 if (texture) { | 1535 if (texture) { |
| 1516 texture->setTarget(target, getMaxTextureLevelForTarget(target)); | 1536 texture->setTarget(target, getMaxTextureLevelForTarget(target)); |
| 1517 m_onePlusMaxNonDefaultTextureUnit = max(m_activeTextureUnit + 1, m_onePl usMaxNonDefaultTextureUnit); | 1537 m_onePlusMaxNonDefaultTextureUnit = max(m_activeTextureUnit + 1, m_onePl usMaxNonDefaultTextureUnit); |
| 1518 } else { | 1538 } else { |
| 1519 // If the disabled index is the current maximum, trace backwards to find the new max enabled texture index | 1539 // If the disabled index is the current maximum, trace backwards to find the new max enabled texture index |
| 1520 if (m_onePlusMaxNonDefaultTextureUnit == m_activeTextureUnit + 1) { | 1540 if (m_onePlusMaxNonDefaultTextureUnit == m_activeTextureUnit + 1) { |
| 1521 findNewMaxNonDefaultTextureUnit(); | 1541 findNewMaxNonDefaultTextureUnit(); |
| 1522 } | 1542 } |
| 1523 } | 1543 } |
| 1524 | 1544 |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1934 if (isContextLost()) | 1954 if (isContextLost()) |
| 1935 return nullptr; | 1955 return nullptr; |
| 1936 if (!renderbuffer->emulatedStencilBuffer()) { | 1956 if (!renderbuffer->emulatedStencilBuffer()) { |
| 1937 renderbuffer->setEmulatedStencilBuffer(createRenderbuffer()); | 1957 renderbuffer->setEmulatedStencilBuffer(createRenderbuffer()); |
| 1938 webContext()->bindRenderbuffer(target, objectOrZero(renderbuffer->emulat edStencilBuffer())); | 1958 webContext()->bindRenderbuffer(target, objectOrZero(renderbuffer->emulat edStencilBuffer())); |
| 1939 webContext()->bindRenderbuffer(target, objectOrZero(m_renderbufferBindin g.get())); | 1959 webContext()->bindRenderbuffer(target, objectOrZero(m_renderbufferBindin g.get())); |
| 1940 } | 1960 } |
| 1941 return renderbuffer->emulatedStencilBuffer(); | 1961 return renderbuffer->emulatedStencilBuffer(); |
| 1942 } | 1962 } |
| 1943 | 1963 |
| 1964 void WebGLRenderingContextBase::setBoundVertexArrayObject(ScriptState* scriptSta te, WebGLVertexArrayObjectBase* arrayObject) | |
| 1965 { | |
| 1966 if (arrayObject) | |
| 1967 m_boundVertexArrayObject = arrayObject; | |
| 1968 else | |
| 1969 m_boundVertexArrayObject = m_defaultVertexArrayObject; | |
| 1970 | |
| 1971 preserveObjectWrapper(scriptState, this, "boundvao", 0, arrayObject); | |
| 1972 } | |
| 1973 | |
| 1944 WebGLShader* WebGLRenderingContextBase::createShader(GLenum type) | 1974 WebGLShader* WebGLRenderingContextBase::createShader(GLenum type) |
| 1945 { | 1975 { |
| 1946 if (isContextLost()) | 1976 if (isContextLost()) |
| 1947 return nullptr; | 1977 return nullptr; |
| 1948 if (type != GL_VERTEX_SHADER && type != GL_FRAGMENT_SHADER) { | 1978 if (type != GL_VERTEX_SHADER && type != GL_FRAGMENT_SHADER) { |
| 1949 synthesizeGLError(GL_INVALID_ENUM, "createShader", "invalid shader type" ); | 1979 synthesizeGLError(GL_INVALID_ENUM, "createShader", "invalid shader type" ); |
| 1950 return nullptr; | 1980 return nullptr; |
| 1951 } | 1981 } |
| 1952 | 1982 |
| 1953 WebGLShader* o = WebGLShader::create(this, type); | 1983 WebGLShader* o = WebGLShader::create(this, type); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2090 { | 2120 { |
| 2091 if (isContextLost()) | 2121 if (isContextLost()) |
| 2092 return; | 2122 return; |
| 2093 if (zNear > zFar) { | 2123 if (zNear > zFar) { |
| 2094 synthesizeGLError(GL_INVALID_OPERATION, "depthRange", "zNear > zFar"); | 2124 synthesizeGLError(GL_INVALID_OPERATION, "depthRange", "zNear > zFar"); |
| 2095 return; | 2125 return; |
| 2096 } | 2126 } |
| 2097 webContext()->depthRange(zNear, zFar); | 2127 webContext()->depthRange(zNear, zFar); |
| 2098 } | 2128 } |
| 2099 | 2129 |
| 2100 void WebGLRenderingContextBase::detachShader(WebGLProgram* program, WebGLShader* shader) | 2130 void WebGLRenderingContextBase::detachShader(ScriptState* scriptState, WebGLProg ram* program, WebGLShader* shader) |
| 2101 { | 2131 { |
| 2102 if (isContextLost() || !validateWebGLObject("detachShader", program) || !val idateWebGLObject("detachShader", shader)) | 2132 if (isContextLost() || !validateWebGLObject("detachShader", program) || !val idateWebGLObject("detachShader", shader)) |
| 2103 return; | 2133 return; |
| 2104 if (!program->detachShader(shader)) { | 2134 if (!program->detachShader(shader)) { |
| 2105 synthesizeGLError(GL_INVALID_OPERATION, "detachShader", "shader not atta ched"); | 2135 synthesizeGLError(GL_INVALID_OPERATION, "detachShader", "shader not atta ched"); |
| 2106 return; | 2136 return; |
| 2107 } | 2137 } |
| 2108 webContext()->detachShader(objectOrZero(program), objectOrZero(shader)); | 2138 webContext()->detachShader(objectOrZero(program), objectOrZero(shader)); |
| 2109 shader->onDetached(webContext()); | 2139 shader->onDetached(webContext()); |
| 2140 preserveObjectWrapper(scriptState, program, "shader", shader->type(), nullpt r); | |
| 2110 } | 2141 } |
| 2111 | 2142 |
| 2112 void WebGLRenderingContextBase::disable(GLenum cap) | 2143 void WebGLRenderingContextBase::disable(GLenum cap) |
| 2113 { | 2144 { |
| 2114 if (isContextLost() || !validateCapability("disable", cap)) | 2145 if (isContextLost() || !validateCapability("disable", cap)) |
| 2115 return; | 2146 return; |
| 2116 if (cap == GL_STENCIL_TEST) { | 2147 if (cap == GL_STENCIL_TEST) { |
| 2117 m_stencilEnabled = false; | 2148 m_stencilEnabled = false; |
| 2118 applyStencilTest(); | 2149 applyStencilTest(); |
| 2119 return; | 2150 return; |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2259 webContext()->flush(); // Intentionally a flush, not a finish. | 2290 webContext()->flush(); // Intentionally a flush, not a finish. |
| 2260 } | 2291 } |
| 2261 | 2292 |
| 2262 void WebGLRenderingContextBase::flush() | 2293 void WebGLRenderingContextBase::flush() |
| 2263 { | 2294 { |
| 2264 if (isContextLost()) | 2295 if (isContextLost()) |
| 2265 return; | 2296 return; |
| 2266 webContext()->flush(); | 2297 webContext()->flush(); |
| 2267 } | 2298 } |
| 2268 | 2299 |
| 2269 void WebGLRenderingContextBase::framebufferRenderbuffer(GLenum target, GLenum at tachment, GLenum renderbuffertarget, WebGLRenderbuffer* buffer) | 2300 void WebGLRenderingContextBase::framebufferRenderbuffer(ScriptState* scriptState , GLenum target, GLenum attachment, GLenum renderbuffertarget, WebGLRenderbuffer * buffer) |
| 2270 { | 2301 { |
| 2271 if (isContextLost() || !validateFramebufferFuncParameters("framebufferRender buffer", target, attachment)) | 2302 if (isContextLost() || !validateFramebufferFuncParameters("framebufferRender buffer", target, attachment)) |
| 2272 return; | 2303 return; |
| 2273 if (renderbuffertarget != GL_RENDERBUFFER) { | 2304 if (renderbuffertarget != GL_RENDERBUFFER) { |
| 2274 synthesizeGLError(GL_INVALID_ENUM, "framebufferRenderbuffer", "invalid t arget"); | 2305 synthesizeGLError(GL_INVALID_ENUM, "framebufferRenderbuffer", "invalid t arget"); |
| 2275 return; | 2306 return; |
| 2276 } | 2307 } |
| 2277 if (buffer && !buffer->validate(contextGroup(), this)) { | 2308 if (buffer && !buffer->validate(contextGroup(), this)) { |
| 2278 synthesizeGLError(GL_INVALID_OPERATION, "framebufferRenderbuffer", "no b uffer or buffer not from this context"); | 2309 synthesizeGLError(GL_INVALID_OPERATION, "framebufferRenderbuffer", "no b uffer or buffer not from this context"); |
| 2279 return; | 2310 return; |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 2307 } | 2338 } |
| 2308 if (isWebGL2OrHigher() && attachment == GL_DEPTH_STENCIL_ATTACHMENT) { | 2339 if (isWebGL2OrHigher() && attachment == GL_DEPTH_STENCIL_ATTACHMENT) { |
| 2309 // On ES3, DEPTH_STENCIL_ATTACHMENT is like an alias for DEPTH_ATTACHMEN T + STENCIL_ATTACHMENT. | 2340 // On ES3, DEPTH_STENCIL_ATTACHMENT is like an alias for DEPTH_ATTACHMEN T + STENCIL_ATTACHMENT. |
| 2310 // We divide it here so in WebGLFramebuffer, we don't have to handle DEP TH_STENCIL_ATTACHMENT in WebGL 2. | 2341 // We divide it here so in WebGLFramebuffer, we don't have to handle DEP TH_STENCIL_ATTACHMENT in WebGL 2. |
| 2311 framebufferBinding->setAttachmentForBoundFramebuffer(target, GL_DEPTH_AT TACHMENT, buffer); | 2342 framebufferBinding->setAttachmentForBoundFramebuffer(target, GL_DEPTH_AT TACHMENT, buffer); |
| 2312 framebufferBinding->setAttachmentForBoundFramebuffer(target, GL_STENCIL_ ATTACHMENT, buffer); | 2343 framebufferBinding->setAttachmentForBoundFramebuffer(target, GL_STENCIL_ ATTACHMENT, buffer); |
| 2313 } else { | 2344 } else { |
| 2314 framebufferBinding->setAttachmentForBoundFramebuffer(target, attachment, buffer); | 2345 framebufferBinding->setAttachmentForBoundFramebuffer(target, attachment, buffer); |
| 2315 } | 2346 } |
| 2316 applyStencilTest(); | 2347 applyStencilTest(); |
| 2348 preserveObjectWrapper(scriptState, framebufferBinding, "renderbuffer", attac hment, buffer); | |
| 2317 } | 2349 } |
| 2318 | 2350 |
| 2319 void WebGLRenderingContextBase::framebufferTexture2D(GLenum target, GLenum attac hment, GLenum textarget, WebGLTexture* texture, GLint level) | 2351 void WebGLRenderingContextBase::framebufferTexture2D(ScriptState* scriptState, G Lenum target, GLenum attachment, GLenum textarget, WebGLTexture* texture, GLint level) |
| 2320 { | 2352 { |
| 2321 if (isContextLost() || !validateFramebufferFuncParameters("framebufferTextur e2D", target, attachment)) | 2353 if (isContextLost() || !validateFramebufferFuncParameters("framebufferTextur e2D", target, attachment)) |
| 2322 return; | 2354 return; |
| 2323 if (isWebGL2OrHigher()) { | 2355 if (isWebGL2OrHigher()) { |
| 2324 if (!validateTexFuncLevel("framebufferTexture2D", textarget, level)) | 2356 if (!validateTexFuncLevel("framebufferTexture2D", textarget, level)) |
| 2325 return; | 2357 return; |
| 2326 } else if (level) { | 2358 } else if (level) { |
| 2327 synthesizeGLError(GL_INVALID_VALUE, "framebufferTexture2D", "level not 0 "); | 2359 synthesizeGLError(GL_INVALID_VALUE, "framebufferTexture2D", "level not 0 "); |
| 2328 return; | 2360 return; |
| 2329 } | 2361 } |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 2349 webContext()->framebufferTexture2D(target, attachment, textarget, textur eObject, level); | 2381 webContext()->framebufferTexture2D(target, attachment, textarget, textur eObject, level); |
| 2350 break; | 2382 break; |
| 2351 case GL_STENCIL_ATTACHMENT: | 2383 case GL_STENCIL_ATTACHMENT: |
| 2352 webContext()->framebufferTexture2D(target, attachment, textarget, textur eObject, level); | 2384 webContext()->framebufferTexture2D(target, attachment, textarget, textur eObject, level); |
| 2353 break; | 2385 break; |
| 2354 default: | 2386 default: |
| 2355 webContext()->framebufferTexture2D(target, attachment, textarget, textur eObject, level); | 2387 webContext()->framebufferTexture2D(target, attachment, textarget, textur eObject, level); |
| 2356 } | 2388 } |
| 2357 framebufferBinding->setAttachmentForBoundFramebuffer(target, attachment, tex target, texture, level); | 2389 framebufferBinding->setAttachmentForBoundFramebuffer(target, attachment, tex target, texture, level); |
| 2358 applyStencilTest(); | 2390 applyStencilTest(); |
| 2391 preserveObjectWrapper(scriptState, framebufferBinding, "texture2d", attachme nt, texture); | |
| 2359 } | 2392 } |
| 2360 | 2393 |
| 2361 void WebGLRenderingContextBase::frontFace(GLenum mode) | 2394 void WebGLRenderingContextBase::frontFace(GLenum mode) |
| 2362 { | 2395 { |
| 2363 if (isContextLost()) | 2396 if (isContextLost()) |
| 2364 return; | 2397 return; |
| 2365 switch (mode) { | 2398 switch (mode) { |
| 2366 case GL_CW: | 2399 case GL_CW: |
| 2367 case GL_CCW: | 2400 case GL_CCW: |
| 2368 break; | 2401 break; |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2553 if (tracker->draft() && !RuntimeEnabledFeatures::webGLDraftExtensionsEnabled ()) | 2586 if (tracker->draft() && !RuntimeEnabledFeatures::webGLDraftExtensionsEnabled ()) |
| 2554 return false; | 2587 return false; |
| 2555 if (!tracker->supported(this)) | 2588 if (!tracker->supported(this)) |
| 2556 return false; | 2589 return false; |
| 2557 return true; | 2590 return true; |
| 2558 } | 2591 } |
| 2559 | 2592 |
| 2560 ScriptValue WebGLRenderingContextBase::getExtension(ScriptState* scriptState, co nst String& name) | 2593 ScriptValue WebGLRenderingContextBase::getExtension(ScriptState* scriptState, co nst String& name) |
| 2561 { | 2594 { |
| 2562 WebGLExtension* extension = nullptr; | 2595 WebGLExtension* extension = nullptr; |
| 2596 bool linkContextToExtension = false; | |
| 2563 | 2597 |
| 2564 if (!isContextLost()) { | 2598 if (!isContextLost()) { |
| 2565 for (size_t i = 0; i < m_extensions.size(); ++i) { | 2599 for (size_t i = 0; i < m_extensions.size(); ++i) { |
| 2566 ExtensionTracker* tracker = m_extensions[i]; | 2600 ExtensionTracker* tracker = m_extensions[i]; |
| 2567 if (tracker->matchesNameWithPrefixes(name)) { | 2601 if (tracker->matchesNameWithPrefixes(name)) { |
| 2568 if (extensionSupportedAndAllowed(tracker)) { | 2602 if (extensionSupportedAndAllowed(tracker)) { |
| 2569 extension = tracker->getExtension(this); | 2603 extension = tracker->getExtension(this); |
| 2570 if (extension) | 2604 if (extension) { |
| 2571 m_extensionEnabled[extension->name()] = true; | 2605 if (!m_extensionEnabled[extension->name()]) { |
| 2606 linkContextToExtension = true; | |
| 2607 m_extensionEnabled[extension->name()] = true; | |
| 2608 } | |
| 2609 } | |
| 2572 } | 2610 } |
| 2573 break; | 2611 break; |
| 2574 } | 2612 } |
| 2575 } | 2613 } |
| 2576 } | 2614 } |
| 2577 | 2615 |
| 2578 return ScriptValue(scriptState, toV8(extension, scriptState->context()->Glob al(), scriptState->isolate())); | 2616 v8::Local<v8::Value> wrappedExtension = toV8(extension, scriptState->context ()->Global(), scriptState->isolate()); |
| 2617 | |
| 2618 if (linkContextToExtension) { | |
| 2619 // Keep the extension's JavaScript wrapper alive as long as the context is alive, so that | |
| 2620 // expando properties that are added to the extension persist. | |
| 2621 preserveObjectWrapper(scriptState, this, "extension", static_cast<unsign ed long>(extension->name()), extension); | |
| 2622 } | |
| 2623 | |
| 2624 return ScriptValue(scriptState, wrappedExtension); | |
| 2579 } | 2625 } |
| 2580 | 2626 |
| 2581 ScriptValue WebGLRenderingContextBase::getFramebufferAttachmentParameter(ScriptS tate* scriptState, GLenum target, GLenum attachment, GLenum pname) | 2627 ScriptValue WebGLRenderingContextBase::getFramebufferAttachmentParameter(ScriptS tate* scriptState, GLenum target, GLenum attachment, GLenum pname) |
| 2582 { | 2628 { |
| 2583 if (isContextLost() || !validateFramebufferFuncParameters("getFramebufferAtt achmentParameter", target, attachment)) | 2629 if (isContextLost() || !validateFramebufferFuncParameters("getFramebufferAtt achmentParameter", target, attachment)) |
| 2584 return ScriptValue::createNull(scriptState); | 2630 return ScriptValue::createNull(scriptState); |
| 2585 | 2631 |
| 2586 if (!m_framebufferBinding || !m_framebufferBinding->object()) { | 2632 if (!m_framebufferBinding || !m_framebufferBinding->object()) { |
| 2587 synthesizeGLError(GL_INVALID_OPERATION, "getFramebufferAttachmentParamet er", "no framebuffer bound"); | 2633 synthesizeGLError(GL_INVALID_OPERATION, "getFramebufferAttachmentParamet er", "no framebuffer bound"); |
| 2588 return ScriptValue::createNull(scriptState); | 2634 return ScriptValue::createNull(scriptState); |
| (...skipping 2257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4846 webContext()->uniformMatrix4fv(location->location(), v->length() >> 4, trans pose, v->data()); | 4892 webContext()->uniformMatrix4fv(location->location(), v->length() >> 4, trans pose, v->data()); |
| 4847 } | 4893 } |
| 4848 | 4894 |
| 4849 void WebGLRenderingContextBase::uniformMatrix4fv(const WebGLUniformLocation* loc ation, GLboolean transpose, Vector<GLfloat>& v) | 4895 void WebGLRenderingContextBase::uniformMatrix4fv(const WebGLUniformLocation* loc ation, GLboolean transpose, Vector<GLfloat>& v) |
| 4850 { | 4896 { |
| 4851 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix4fv", location, transpose, v.data(), v.size(), 16)) | 4897 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix4fv", location, transpose, v.data(), v.size(), 16)) |
| 4852 return; | 4898 return; |
| 4853 webContext()->uniformMatrix4fv(location->location(), v.size() >> 4, transpos e, v.data()); | 4899 webContext()->uniformMatrix4fv(location->location(), v.size() >> 4, transpos e, v.data()); |
| 4854 } | 4900 } |
| 4855 | 4901 |
| 4856 void WebGLRenderingContextBase::useProgram(WebGLProgram* program) | 4902 void WebGLRenderingContextBase::useProgram(ScriptState* scriptState, WebGLProgra m* program) |
| 4857 { | 4903 { |
| 4858 bool deleted; | 4904 bool deleted; |
| 4859 if (!checkObjectToBeBound("useProgram", program, deleted)) | 4905 if (!checkObjectToBeBound("useProgram", program, deleted)) |
| 4860 return; | 4906 return; |
| 4861 if (deleted) | 4907 if (deleted) |
| 4862 program = 0; | 4908 program = 0; |
| 4863 if (program && !program->linkStatus()) { | 4909 if (program && !program->linkStatus()) { |
| 4864 synthesizeGLError(GL_INVALID_OPERATION, "useProgram", "program not valid "); | 4910 synthesizeGLError(GL_INVALID_OPERATION, "useProgram", "program not valid "); |
| 4865 return; | 4911 return; |
| 4866 } | 4912 } |
| 4867 if (m_currentProgram != program) { | 4913 if (m_currentProgram != program) { |
| 4868 if (m_currentProgram) | 4914 if (m_currentProgram) |
| 4869 m_currentProgram->onDetached(webContext()); | 4915 m_currentProgram->onDetached(webContext()); |
| 4870 m_currentProgram = program; | 4916 m_currentProgram = program; |
| 4871 webContext()->useProgram(objectOrZero(program)); | 4917 webContext()->useProgram(objectOrZero(program)); |
| 4872 if (program) | 4918 if (program) |
| 4873 program->onAttached(); | 4919 program->onAttached(); |
| 4920 preserveObjectWrapper(scriptState, this, "program", 0, program); | |
| 4874 } | 4921 } |
| 4875 } | 4922 } |
| 4876 | 4923 |
| 4877 void WebGLRenderingContextBase::validateProgram(WebGLProgram* program) | 4924 void WebGLRenderingContextBase::validateProgram(WebGLProgram* program) |
| 4878 { | 4925 { |
| 4879 if (isContextLost() || !validateWebGLObject("validateProgram", program)) | 4926 if (isContextLost() || !validateWebGLObject("validateProgram", program)) |
| 4880 return; | 4927 return; |
| 4881 webContext()->validateProgram(objectOrZero(program)); | 4928 webContext()->validateProgram(objectOrZero(program)); |
| 4882 } | 4929 } |
| 4883 | 4930 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4934 void WebGLRenderingContextBase::vertexAttrib4fv(GLuint index, const DOMFloat32Ar ray* v) | 4981 void WebGLRenderingContextBase::vertexAttrib4fv(GLuint index, const DOMFloat32Ar ray* v) |
| 4935 { | 4982 { |
| 4936 vertexAttribfvImpl("vertexAttrib4fv", index, v, 4); | 4983 vertexAttribfvImpl("vertexAttrib4fv", index, v, 4); |
| 4937 } | 4984 } |
| 4938 | 4985 |
| 4939 void WebGLRenderingContextBase::vertexAttrib4fv(GLuint index, const Vector<GLflo at>& v) | 4986 void WebGLRenderingContextBase::vertexAttrib4fv(GLuint index, const Vector<GLflo at>& v) |
| 4940 { | 4987 { |
| 4941 vertexAttribfvImpl("vertexAttrib4fv", index, v.data(), v.size(), 4); | 4988 vertexAttribfvImpl("vertexAttrib4fv", index, v.data(), v.size(), 4); |
| 4942 } | 4989 } |
| 4943 | 4990 |
| 4944 void WebGLRenderingContextBase::vertexAttribPointer(GLuint index, GLint size, GL enum type, GLboolean normalized, GLsizei stride, long long offset) | 4991 void WebGLRenderingContextBase::vertexAttribPointer(ScriptState* scriptState, GL uint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, long long offset) |
| 4945 { | 4992 { |
| 4946 if (isContextLost()) | 4993 if (isContextLost()) |
| 4947 return; | 4994 return; |
| 4948 switch (type) { | 4995 switch (type) { |
| 4949 case GL_BYTE: | 4996 case GL_BYTE: |
| 4950 case GL_UNSIGNED_BYTE: | 4997 case GL_UNSIGNED_BYTE: |
| 4951 case GL_SHORT: | 4998 case GL_SHORT: |
| 4952 case GL_UNSIGNED_SHORT: | 4999 case GL_UNSIGNED_SHORT: |
| 4953 case GL_FLOAT: | 5000 case GL_FLOAT: |
| 4954 break; | 5001 break; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 4973 unsigned typeSize = sizeInBytes(type); | 5020 unsigned typeSize = sizeInBytes(type); |
| 4974 ASSERT((typeSize & (typeSize - 1)) == 0); // Ensure that the value is POT. | 5021 ASSERT((typeSize & (typeSize - 1)) == 0); // Ensure that the value is POT. |
| 4975 if ((stride & (typeSize - 1)) || (static_cast<GLintptr>(offset) & (typeSize - 1))) { | 5022 if ((stride & (typeSize - 1)) || (static_cast<GLintptr>(offset) & (typeSize - 1))) { |
| 4976 synthesizeGLError(GL_INVALID_OPERATION, "vertexAttribPointer", "stride o r offset not valid for type"); | 5023 synthesizeGLError(GL_INVALID_OPERATION, "vertexAttribPointer", "stride o r offset not valid for type"); |
| 4977 return; | 5024 return; |
| 4978 } | 5025 } |
| 4979 GLsizei bytesPerElement = size * typeSize; | 5026 GLsizei bytesPerElement = size * typeSize; |
| 4980 | 5027 |
| 4981 m_boundVertexArrayObject->setVertexAttribState(index, bytesPerElement, size, type, normalized, stride, static_cast<GLintptr>(offset), m_boundArrayBuffer); | 5028 m_boundVertexArrayObject->setVertexAttribState(index, bytesPerElement, size, type, normalized, stride, static_cast<GLintptr>(offset), m_boundArrayBuffer); |
| 4982 webContext()->vertexAttribPointer(index, size, type, normalized, stride, sta tic_cast<GLintptr>(offset)); | 5029 webContext()->vertexAttribPointer(index, size, type, normalized, stride, sta tic_cast<GLintptr>(offset)); |
| 5030 maybePreserveDefaultVAOObjectWrapper(scriptState); | |
| 5031 preserveObjectWrapper(scriptState, m_boundVertexArrayObject, "arraybuffer", index, m_boundArrayBuffer); | |
|
bajones
2015/10/03 14:39:23
I don't think so, but just so we're clear: This wo
Ken Russell (switch to Gerrit)
2015/10/05 22:42:03
No. These properties don't show up on the object.
| |
| 4983 } | 5032 } |
| 4984 | 5033 |
| 4985 void WebGLRenderingContextBase::vertexAttribDivisorANGLE(GLuint index, GLuint di visor) | 5034 void WebGLRenderingContextBase::vertexAttribDivisorANGLE(GLuint index, GLuint di visor) |
| 4986 { | 5035 { |
| 4987 if (isContextLost()) | 5036 if (isContextLost()) |
| 4988 return; | 5037 return; |
| 4989 | 5038 |
| 4990 if (index >= m_maxVertexAttribs) { | 5039 if (index >= m_maxVertexAttribs) { |
| 4991 synthesizeGLError(GL_INVALID_VALUE, "vertexAttribDivisorANGLE", "index o ut of range"); | 5040 synthesizeGLError(GL_INVALID_VALUE, "vertexAttribDivisorANGLE", "index o ut of range"); |
| 4992 return; | 5041 return; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5094 return isContextLost() ? 0 : drawingBuffer()->platformLayer(); | 5143 return isContextLost() ? 0 : drawingBuffer()->platformLayer(); |
| 5095 } | 5144 } |
| 5096 | 5145 |
| 5097 void WebGLRenderingContextBase::setFilterQuality(SkFilterQuality filterQuality) | 5146 void WebGLRenderingContextBase::setFilterQuality(SkFilterQuality filterQuality) |
| 5098 { | 5147 { |
| 5099 if (!isContextLost() && drawingBuffer()) { | 5148 if (!isContextLost() && drawingBuffer()) { |
| 5100 drawingBuffer()->setFilterQuality(filterQuality); | 5149 drawingBuffer()->setFilterQuality(filterQuality); |
| 5101 } | 5150 } |
| 5102 } | 5151 } |
| 5103 | 5152 |
| 5153 void WebGLRenderingContextBase::preserveObjectWrapper(ScriptState* scriptState, ScriptWrappable* sourceObject, const char* baseName, unsigned long index, Script Wrappable* targetObject) | |
| 5154 { | |
| 5155 v8::Local<v8::Value> value; | |
| 5156 | |
| 5157 StringBuilder builder; | |
| 5158 builder.append(baseName); | |
| 5159 builder.appendNumber(static_cast<unsigned>(index)); | |
| 5160 CString name = builder.toString().utf8(); | |
| 5161 if (targetObject) { | |
| 5162 value = targetObject->newLocalWrapper(scriptState->isolate()); | |
| 5163 } else { | |
| 5164 value = v8::Null(scriptState->isolate()); | |
| 5165 } | |
| 5166 | |
| 5167 V8HiddenValue::setHiddenValue( | |
| 5168 scriptState->isolate(), | |
| 5169 sourceObject->newLocalWrapper(scriptState->isolate()), | |
| 5170 v8::String::NewFromUtf8( | |
| 5171 scriptState->isolate(), | |
| 5172 name.data(), | |
| 5173 v8::NewStringType::kNormal, | |
| 5174 name.length()).ToLocalChecked(), | |
| 5175 value); | |
| 5176 } | |
| 5177 | |
| 5104 Extensions3DUtil* WebGLRenderingContextBase::extensionsUtil() | 5178 Extensions3DUtil* WebGLRenderingContextBase::extensionsUtil() |
| 5105 { | 5179 { |
| 5106 if (!m_extensionsUtil) { | 5180 if (!m_extensionsUtil) { |
| 5107 m_extensionsUtil = Extensions3DUtil::create(webContext()); | 5181 m_extensionsUtil = Extensions3DUtil::create(webContext()); |
| 5108 // The only reason the ExtensionsUtil should be invalid is if the webCon text is lost. | 5182 // The only reason the ExtensionsUtil should be invalid is if the webCon text is lost. |
| 5109 ASSERT(m_extensionsUtil->isValid() || webContext()->isContextLost()); | 5183 ASSERT(m_extensionsUtil->isValid() || webContext()->isContextLost()); |
| 5110 } | 5184 } |
| 5111 return m_extensionsUtil.get(); | 5185 return m_extensionsUtil.get(); |
| 5112 } | 5186 } |
| 5113 | 5187 |
| (...skipping 1521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6635 if (!buffer) { | 6709 if (!buffer) { |
| 6636 // Instead of binding fb 0, bind the drawing buffer. | 6710 // Instead of binding fb 0, bind the drawing buffer. |
| 6637 drawingBuffer()->bind(target); | 6711 drawingBuffer()->bind(target); |
| 6638 } else { | 6712 } else { |
| 6639 webContext()->bindFramebuffer(target, buffer->object()); | 6713 webContext()->bindFramebuffer(target, buffer->object()); |
| 6640 } | 6714 } |
| 6641 } | 6715 } |
| 6642 | 6716 |
| 6643 void WebGLRenderingContextBase::restoreCurrentFramebuffer() | 6717 void WebGLRenderingContextBase::restoreCurrentFramebuffer() |
| 6644 { | 6718 { |
| 6645 bindFramebuffer(GL_FRAMEBUFFER, m_framebufferBinding.get()); | 6719 bindFramebuffer(nullptr, GL_FRAMEBUFFER, m_framebufferBinding.get()); |
| 6646 } | 6720 } |
| 6647 | 6721 |
| 6648 void WebGLRenderingContextBase::restoreCurrentTexture2D() | 6722 void WebGLRenderingContextBase::restoreCurrentTexture2D() |
| 6649 { | 6723 { |
| 6650 bindTexture(GL_TEXTURE_2D, m_textureUnits[m_activeTextureUnit].m_texture2DBi nding.get()); | 6724 bindTexture(nullptr, GL_TEXTURE_2D, m_textureUnits[m_activeTextureUnit].m_te xture2DBinding.get()); |
| 6651 } | 6725 } |
| 6652 | 6726 |
| 6653 void WebGLRenderingContextBase::multisamplingChanged(bool enabled) | 6727 void WebGLRenderingContextBase::multisamplingChanged(bool enabled) |
| 6654 { | 6728 { |
| 6655 if (m_multisamplingAllowed != enabled) { | 6729 if (m_multisamplingAllowed != enabled) { |
| 6656 m_multisamplingAllowed = enabled; | 6730 m_multisamplingAllowed = enabled; |
| 6657 forceLostContext(WebGLRenderingContextBase::SyntheticLostContext, WebGLR enderingContextBase::Auto); | 6731 forceLostContext(WebGLRenderingContextBase::SyntheticLostContext, WebGLR enderingContextBase::Auto); |
| 6658 } | 6732 } |
| 6659 } | 6733 } |
| 6660 | 6734 |
| 6661 void WebGLRenderingContextBase::findNewMaxNonDefaultTextureUnit() | 6735 void WebGLRenderingContextBase::findNewMaxNonDefaultTextureUnit() |
| 6662 { | 6736 { |
| 6663 // Trace backwards from the current max to find the new max non-default text ure unit | 6737 // Trace backwards from the current max to find the new max non-default text ure unit |
| 6664 int startIndex = m_onePlusMaxNonDefaultTextureUnit - 1; | 6738 int startIndex = m_onePlusMaxNonDefaultTextureUnit - 1; |
| 6665 for (int i = startIndex; i >= 0; --i) { | 6739 for (int i = startIndex; i >= 0; --i) { |
| 6666 if (m_textureUnits[i].m_texture2DBinding | 6740 if (m_textureUnits[i].m_texture2DBinding |
| 6667 || m_textureUnits[i].m_textureCubeMapBinding) { | 6741 || m_textureUnits[i].m_textureCubeMapBinding) { |
| 6668 m_onePlusMaxNonDefaultTextureUnit = i + 1; | 6742 m_onePlusMaxNonDefaultTextureUnit = i + 1; |
| 6669 return; | 6743 return; |
| 6670 } | 6744 } |
| 6671 } | 6745 } |
| 6672 m_onePlusMaxNonDefaultTextureUnit = 0; | 6746 m_onePlusMaxNonDefaultTextureUnit = 0; |
| 6673 } | 6747 } |
| 6674 | 6748 |
| 6749 void WebGLRenderingContextBase::maybePreserveDefaultVAOObjectWrapper(ScriptState * scriptState) | |
| 6750 { | |
| 6751 if (!m_preservedDefaultVAOObjectWrapper) { | |
| 6752 // The default VAO does not have a JavaScript wrapper created for it, bu t one is needed to | |
| 6753 // link up the WebGLBuffers associated with the vertex attributes. | |
| 6754 m_defaultVertexArrayObject->wrap(scriptState->isolate(), scriptState->co ntext()->Global()); | |
| 6755 preserveObjectWrapper(scriptState, this, "defaultvao", 0, m_defaultVerte xArrayObject); | |
| 6756 m_preservedDefaultVAOObjectWrapper = true; | |
| 6757 } | |
| 6758 } | |
| 6759 | |
| 6675 DEFINE_TRACE(WebGLRenderingContextBase::TextureUnitState) | 6760 DEFINE_TRACE(WebGLRenderingContextBase::TextureUnitState) |
| 6676 { | 6761 { |
| 6677 visitor->trace(m_texture2DBinding); | 6762 visitor->trace(m_texture2DBinding); |
| 6678 visitor->trace(m_textureCubeMapBinding); | 6763 visitor->trace(m_textureCubeMapBinding); |
| 6679 visitor->trace(m_texture3DBinding); | 6764 visitor->trace(m_texture3DBinding); |
| 6680 visitor->trace(m_texture2DArrayBinding); | 6765 visitor->trace(m_texture2DArrayBinding); |
| 6681 } | 6766 } |
| 6682 | 6767 |
| 6683 DEFINE_TRACE(WebGLRenderingContextBase) | 6768 DEFINE_TRACE(WebGLRenderingContextBase) |
| 6684 { | 6769 { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6727 | 6812 |
| 6728 return totalBytesPerPixel; | 6813 return totalBytesPerPixel; |
| 6729 } | 6814 } |
| 6730 | 6815 |
| 6731 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const | 6816 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const |
| 6732 { | 6817 { |
| 6733 return m_drawingBuffer.get(); | 6818 return m_drawingBuffer.get(); |
| 6734 } | 6819 } |
| 6735 | 6820 |
| 6736 } // namespace blink | 6821 } // namespace blink |
| OLD | NEW |