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 // It's not convenient or necessary to pass a ScriptState this far down; whi le one is available | |
| 998 // during WebGLRenderingContext construction, the wrapper for the context it self hasn't been | |
| 999 // created yet. It's simpler to instead lazily instantiate and preserve the JavaScript wrapper | |
| 1000 // for the default VAO. (This object is never exposed to JavaScript, but we need to link other | |
| 1001 // JavaScript wrappers to it.) | |
| 1002 m_preservedDefaultVAOObjectWrapper = false; | |
|
haraken
2015/10/13 06:40:58
Wouldn't it be better to call this when the contex
Ken Russell (switch to Gerrit)
2015/10/13 17:56:57
It's best to keep it close to the logic which actu
| |
| 996 m_boundVertexArrayObject = m_defaultVertexArrayObject; | 1003 m_boundVertexArrayObject = m_defaultVertexArrayObject; |
| 997 | 1004 |
| 998 m_vertexAttribValue.resize(m_maxVertexAttribs); | 1005 m_vertexAttribValue.resize(m_maxVertexAttribs); |
| 999 | 1006 |
| 1000 createFallbackBlackTextures1x1(); | 1007 createFallbackBlackTextures1x1(); |
| 1001 | 1008 |
| 1002 webContext()->viewport(0, 0, drawingBufferWidth(), drawingBufferHeight()); | 1009 webContext()->viewport(0, 0, drawingBufferWidth(), drawingBufferHeight()); |
| 1003 webContext()->scissor(0, 0, drawingBufferWidth(), drawingBufferHeight()); | 1010 webContext()->scissor(0, 0, drawingBufferWidth(), drawingBufferHeight()); |
| 1004 | 1011 |
| 1005 m_contextLostCallbackAdapter = WebGLRenderingContextLostCallback::create(thi s); | 1012 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"); | 1364 synthesizeGLError(GL_INVALID_ENUM, "activeTexture", "texture unit out of range"); |
| 1358 return; | 1365 return; |
| 1359 } | 1366 } |
| 1360 m_activeTextureUnit = texture - GL_TEXTURE0; | 1367 m_activeTextureUnit = texture - GL_TEXTURE0; |
| 1361 webContext()->activeTexture(texture); | 1368 webContext()->activeTexture(texture); |
| 1362 | 1369 |
| 1363 drawingBuffer()->setActiveTextureUnit(texture); | 1370 drawingBuffer()->setActiveTextureUnit(texture); |
| 1364 | 1371 |
| 1365 } | 1372 } |
| 1366 | 1373 |
| 1367 void WebGLRenderingContextBase::attachShader(WebGLProgram* program, WebGLShader* shader) | 1374 void WebGLRenderingContextBase::attachShader(ScriptState* scriptState, WebGLProg ram* program, WebGLShader* shader) |
| 1368 { | 1375 { |
| 1369 if (isContextLost() || !validateWebGLObject("attachShader", program) || !val idateWebGLObject("attachShader", shader)) | 1376 if (isContextLost() || !validateWebGLObject("attachShader", program) || !val idateWebGLObject("attachShader", shader)) |
| 1370 return; | 1377 return; |
| 1371 if (!program->attachShader(shader)) { | 1378 if (!program->attachShader(shader)) { |
| 1372 synthesizeGLError(GL_INVALID_OPERATION, "attachShader", "shader attachme nt already has shader"); | 1379 synthesizeGLError(GL_INVALID_OPERATION, "attachShader", "shader attachme nt already has shader"); |
| 1373 return; | 1380 return; |
| 1374 } | 1381 } |
| 1375 webContext()->attachShader(objectOrZero(program), objectOrZero(shader)); | 1382 webContext()->attachShader(objectOrZero(program), objectOrZero(shader)); |
| 1376 shader->onAttached(); | 1383 shader->onAttached(); |
| 1384 preserveObjectWrapper(scriptState, program, "shader", shader->type(), shader ); | |
| 1377 } | 1385 } |
| 1378 | 1386 |
| 1379 void WebGLRenderingContextBase::bindAttribLocation(WebGLProgram* program, GLuint index, const String& name) | 1387 void WebGLRenderingContextBase::bindAttribLocation(WebGLProgram* program, GLuint index, const String& name) |
| 1380 { | 1388 { |
| 1381 if (isContextLost() || !validateWebGLObject("bindAttribLocation", program)) | 1389 if (isContextLost() || !validateWebGLObject("bindAttribLocation", program)) |
| 1382 return; | 1390 return; |
| 1383 if (!validateLocationLength("bindAttribLocation", name)) | 1391 if (!validateLocationLength("bindAttribLocation", name)) |
| 1384 return; | 1392 return; |
| 1385 if (!validateString("bindAttribLocation", name)) | 1393 if (!validateString("bindAttribLocation", name)) |
| 1386 return; | 1394 return; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1430 default: | 1438 default: |
| 1431 ASSERT_NOT_REACHED(); | 1439 ASSERT_NOT_REACHED(); |
| 1432 return false; | 1440 return false; |
| 1433 } | 1441 } |
| 1434 | 1442 |
| 1435 if (buffer && !buffer->getInitialTarget()) | 1443 if (buffer && !buffer->getInitialTarget()) |
| 1436 buffer->setInitialTarget(target); | 1444 buffer->setInitialTarget(target); |
| 1437 return true; | 1445 return true; |
| 1438 } | 1446 } |
| 1439 | 1447 |
| 1440 void WebGLRenderingContextBase::bindBuffer(GLenum target, WebGLBuffer* buffer) | 1448 void WebGLRenderingContextBase::bindBuffer(ScriptState* scriptState, GLenum targ et, WebGLBuffer* buffer) |
| 1441 { | 1449 { |
| 1442 bool deleted; | 1450 bool deleted; |
| 1443 if (!checkObjectToBeBound("bindBuffer", buffer, deleted)) | 1451 if (!checkObjectToBeBound("bindBuffer", buffer, deleted)) |
| 1444 return; | 1452 return; |
| 1445 if (deleted) | 1453 if (deleted) |
| 1446 buffer = 0; | 1454 buffer = 0; |
| 1447 if (!validateAndUpdateBufferBindTarget("bindBuffer", target, buffer)) | 1455 if (!validateAndUpdateBufferBindTarget("bindBuffer", target, buffer)) |
| 1448 return; | 1456 return; |
| 1449 | 1457 |
| 1450 webContext()->bindBuffer(target, objectOrZero(buffer)); | 1458 webContext()->bindBuffer(target, objectOrZero(buffer)); |
| 1459 preserveObjectWrapper(scriptState, this, "buffer", target, buffer); | |
| 1460 maybePreserveDefaultVAOObjectWrapper(scriptState); | |
| 1451 } | 1461 } |
| 1452 | 1462 |
| 1453 void WebGLRenderingContextBase::bindFramebuffer(GLenum target, WebGLFramebuffer* buffer) | 1463 void WebGLRenderingContextBase::bindFramebuffer(ScriptState* scriptState, GLenum target, WebGLFramebuffer* buffer) |
| 1454 { | 1464 { |
| 1455 bool deleted; | 1465 bool deleted; |
| 1456 if (!checkObjectToBeBound("bindFramebuffer", buffer, deleted)) | 1466 if (!checkObjectToBeBound("bindFramebuffer", buffer, deleted)) |
| 1457 return; | 1467 return; |
| 1458 | 1468 |
| 1459 if (deleted) | 1469 if (deleted) |
| 1460 buffer = 0; | 1470 buffer = 0; |
| 1461 | 1471 |
| 1462 if (target != GL_FRAMEBUFFER) { | 1472 if (target != GL_FRAMEBUFFER) { |
| 1463 synthesizeGLError(GL_INVALID_ENUM, "bindFramebuffer", "invalid target"); | 1473 synthesizeGLError(GL_INVALID_ENUM, "bindFramebuffer", "invalid target"); |
| 1464 return; | 1474 return; |
| 1465 } | 1475 } |
| 1466 | 1476 |
| 1467 setFramebuffer(target, buffer); | 1477 setFramebuffer(target, buffer); |
| 1478 // This is called both internally and externally (from JavaScript). We only update which wrapper | |
| 1479 // is preserved when it's called from JavaScript. | |
| 1480 if (scriptState) | |
| 1481 preserveObjectWrapper(scriptState, this, "framebuffer", 0, buffer); | |
| 1468 } | 1482 } |
| 1469 | 1483 |
| 1470 void WebGLRenderingContextBase::bindRenderbuffer(GLenum target, WebGLRenderbuffe r* renderBuffer) | 1484 void WebGLRenderingContextBase::bindRenderbuffer(ScriptState* scriptState, GLenu m target, WebGLRenderbuffer* renderBuffer) |
| 1471 { | 1485 { |
| 1472 bool deleted; | 1486 bool deleted; |
| 1473 if (!checkObjectToBeBound("bindRenderbuffer", renderBuffer, deleted)) | 1487 if (!checkObjectToBeBound("bindRenderbuffer", renderBuffer, deleted)) |
| 1474 return; | 1488 return; |
| 1475 if (deleted) | 1489 if (deleted) |
| 1476 renderBuffer = 0; | 1490 renderBuffer = 0; |
| 1477 if (target != GL_RENDERBUFFER) { | 1491 if (target != GL_RENDERBUFFER) { |
| 1478 synthesizeGLError(GL_INVALID_ENUM, "bindRenderbuffer", "invalid target") ; | 1492 synthesizeGLError(GL_INVALID_ENUM, "bindRenderbuffer", "invalid target") ; |
| 1479 return; | 1493 return; |
| 1480 } | 1494 } |
| 1481 m_renderbufferBinding = renderBuffer; | 1495 m_renderbufferBinding = renderBuffer; |
| 1482 webContext()->bindRenderbuffer(target, objectOrZero(renderBuffer)); | 1496 webContext()->bindRenderbuffer(target, objectOrZero(renderBuffer)); |
| 1497 preserveObjectWrapper(scriptState, this, "renderbuffer", 0, renderBuffer); | |
| 1483 if (renderBuffer) | 1498 if (renderBuffer) |
| 1484 renderBuffer->setHasEverBeenBound(); | 1499 renderBuffer->setHasEverBeenBound(); |
| 1485 } | 1500 } |
| 1486 | 1501 |
| 1487 void WebGLRenderingContextBase::bindTexture(GLenum target, WebGLTexture* texture ) | 1502 void WebGLRenderingContextBase::bindTexture(ScriptState* scriptState, GLenum tar get, WebGLTexture* texture) |
| 1488 { | 1503 { |
| 1489 bool deleted; | 1504 bool deleted; |
| 1490 if (!checkObjectToBeBound("bindTexture", texture, deleted)) | 1505 if (!checkObjectToBeBound("bindTexture", texture, deleted)) |
| 1491 return; | 1506 return; |
| 1492 if (deleted) | 1507 if (deleted) |
| 1493 texture = 0; | 1508 texture = 0; |
| 1494 if (texture && texture->getTarget() && texture->getTarget() != target) { | 1509 if (texture && texture->getTarget() && texture->getTarget() != target) { |
| 1495 synthesizeGLError(GL_INVALID_OPERATION, "bindTexture", "textures can not be used with multiple targets"); | 1510 synthesizeGLError(GL_INVALID_OPERATION, "bindTexture", "textures can not be used with multiple targets"); |
| 1496 return; | 1511 return; |
| 1497 } | 1512 } |
| 1513 | |
| 1514 const char* bindingPointName = nullptr; | |
| 1498 if (target == GL_TEXTURE_2D) { | 1515 if (target == GL_TEXTURE_2D) { |
| 1499 m_textureUnits[m_activeTextureUnit].m_texture2DBinding = texture; | 1516 m_textureUnits[m_activeTextureUnit].m_texture2DBinding = texture; |
| 1500 | 1517 |
| 1501 if (!m_activeTextureUnit) | 1518 if (!m_activeTextureUnit) |
| 1502 drawingBuffer()->setTexture2DBinding(objectOrZero(texture)); | 1519 drawingBuffer()->setTexture2DBinding(objectOrZero(texture)); |
| 1520 bindingPointName = "texture_2d"; | |
| 1503 } else if (target == GL_TEXTURE_CUBE_MAP) { | 1521 } else if (target == GL_TEXTURE_CUBE_MAP) { |
| 1504 m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding = texture; | 1522 m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding = texture; |
| 1523 bindingPointName = "texture_cube_map"; | |
| 1505 } else if (isWebGL2OrHigher() && target == GL_TEXTURE_2D_ARRAY) { | 1524 } else if (isWebGL2OrHigher() && target == GL_TEXTURE_2D_ARRAY) { |
| 1506 m_textureUnits[m_activeTextureUnit].m_texture2DArrayBinding = texture; | 1525 m_textureUnits[m_activeTextureUnit].m_texture2DArrayBinding = texture; |
| 1526 bindingPointName = "texture_2d_array"; | |
| 1507 } else if (isWebGL2OrHigher() && target == GL_TEXTURE_3D) { | 1527 } else if (isWebGL2OrHigher() && target == GL_TEXTURE_3D) { |
| 1508 m_textureUnits[m_activeTextureUnit].m_texture3DBinding = texture; | 1528 m_textureUnits[m_activeTextureUnit].m_texture3DBinding = texture; |
| 1529 bindingPointName = "texture_3d"; | |
| 1509 } else { | 1530 } else { |
| 1510 synthesizeGLError(GL_INVALID_ENUM, "bindTexture", "invalid target"); | 1531 synthesizeGLError(GL_INVALID_ENUM, "bindTexture", "invalid target"); |
| 1511 return; | 1532 return; |
| 1512 } | 1533 } |
| 1513 | 1534 |
| 1514 webContext()->bindTexture(target, objectOrZero(texture)); | 1535 webContext()->bindTexture(target, objectOrZero(texture)); |
| 1536 // This is called both internally and externally (from JavaScript). We only update which wrapper | |
| 1537 // is preserved when it's called from JavaScript. | |
| 1538 if (scriptState) { | |
| 1539 preserveObjectWrapper(scriptState, this, bindingPointName, m_activeTextu reUnit, texture); | |
| 1540 } | |
| 1515 if (texture) { | 1541 if (texture) { |
| 1516 texture->setTarget(target, getMaxTextureLevelForTarget(target)); | 1542 texture->setTarget(target, getMaxTextureLevelForTarget(target)); |
| 1517 m_onePlusMaxNonDefaultTextureUnit = max(m_activeTextureUnit + 1, m_onePl usMaxNonDefaultTextureUnit); | 1543 m_onePlusMaxNonDefaultTextureUnit = max(m_activeTextureUnit + 1, m_onePl usMaxNonDefaultTextureUnit); |
| 1518 } else { | 1544 } else { |
| 1519 // If the disabled index is the current maximum, trace backwards to find the new max enabled texture index | 1545 // 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) { | 1546 if (m_onePlusMaxNonDefaultTextureUnit == m_activeTextureUnit + 1) { |
| 1521 findNewMaxNonDefaultTextureUnit(); | 1547 findNewMaxNonDefaultTextureUnit(); |
| 1522 } | 1548 } |
| 1523 } | 1549 } |
| 1524 | 1550 |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1938 if (isContextLost()) | 1964 if (isContextLost()) |
| 1939 return nullptr; | 1965 return nullptr; |
| 1940 if (!renderbuffer->emulatedStencilBuffer()) { | 1966 if (!renderbuffer->emulatedStencilBuffer()) { |
| 1941 renderbuffer->setEmulatedStencilBuffer(createRenderbuffer()); | 1967 renderbuffer->setEmulatedStencilBuffer(createRenderbuffer()); |
| 1942 webContext()->bindRenderbuffer(target, objectOrZero(renderbuffer->emulat edStencilBuffer())); | 1968 webContext()->bindRenderbuffer(target, objectOrZero(renderbuffer->emulat edStencilBuffer())); |
| 1943 webContext()->bindRenderbuffer(target, objectOrZero(m_renderbufferBindin g.get())); | 1969 webContext()->bindRenderbuffer(target, objectOrZero(m_renderbufferBindin g.get())); |
| 1944 } | 1970 } |
| 1945 return renderbuffer->emulatedStencilBuffer(); | 1971 return renderbuffer->emulatedStencilBuffer(); |
| 1946 } | 1972 } |
| 1947 | 1973 |
| 1974 void WebGLRenderingContextBase::setBoundVertexArrayObject(ScriptState* scriptSta te, WebGLVertexArrayObjectBase* arrayObject) | |
| 1975 { | |
| 1976 if (arrayObject) | |
| 1977 m_boundVertexArrayObject = arrayObject; | |
| 1978 else | |
| 1979 m_boundVertexArrayObject = m_defaultVertexArrayObject; | |
| 1980 | |
| 1981 preserveObjectWrapper(scriptState, this, "boundvao", 0, arrayObject); | |
|
haraken
2015/10/13 06:40:58
Can we move this into the if(arrayObject) block?
Ken Russell (switch to Gerrit)
2015/10/13 17:56:57
No, we want to delete the hidden value for "boundv
| |
| 1982 } | |
| 1983 | |
| 1948 WebGLShader* WebGLRenderingContextBase::createShader(GLenum type) | 1984 WebGLShader* WebGLRenderingContextBase::createShader(GLenum type) |
| 1949 { | 1985 { |
| 1950 if (isContextLost()) | 1986 if (isContextLost()) |
| 1951 return nullptr; | 1987 return nullptr; |
| 1952 if (type != GL_VERTEX_SHADER && type != GL_FRAGMENT_SHADER) { | 1988 if (type != GL_VERTEX_SHADER && type != GL_FRAGMENT_SHADER) { |
| 1953 synthesizeGLError(GL_INVALID_ENUM, "createShader", "invalid shader type" ); | 1989 synthesizeGLError(GL_INVALID_ENUM, "createShader", "invalid shader type" ); |
| 1954 return nullptr; | 1990 return nullptr; |
| 1955 } | 1991 } |
| 1956 | 1992 |
| 1957 WebGLShader* o = WebGLShader::create(this, type); | 1993 WebGLShader* o = WebGLShader::create(this, type); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2094 { | 2130 { |
| 2095 if (isContextLost()) | 2131 if (isContextLost()) |
| 2096 return; | 2132 return; |
| 2097 if (zNear > zFar) { | 2133 if (zNear > zFar) { |
| 2098 synthesizeGLError(GL_INVALID_OPERATION, "depthRange", "zNear > zFar"); | 2134 synthesizeGLError(GL_INVALID_OPERATION, "depthRange", "zNear > zFar"); |
| 2099 return; | 2135 return; |
| 2100 } | 2136 } |
| 2101 webContext()->depthRange(zNear, zFar); | 2137 webContext()->depthRange(zNear, zFar); |
| 2102 } | 2138 } |
| 2103 | 2139 |
| 2104 void WebGLRenderingContextBase::detachShader(WebGLProgram* program, WebGLShader* shader) | 2140 void WebGLRenderingContextBase::detachShader(ScriptState* scriptState, WebGLProg ram* program, WebGLShader* shader) |
| 2105 { | 2141 { |
| 2106 if (isContextLost() || !validateWebGLObject("detachShader", program) || !val idateWebGLObject("detachShader", shader)) | 2142 if (isContextLost() || !validateWebGLObject("detachShader", program) || !val idateWebGLObject("detachShader", shader)) |
| 2107 return; | 2143 return; |
| 2108 if (!program->detachShader(shader)) { | 2144 if (!program->detachShader(shader)) { |
| 2109 synthesizeGLError(GL_INVALID_OPERATION, "detachShader", "shader not atta ched"); | 2145 synthesizeGLError(GL_INVALID_OPERATION, "detachShader", "shader not atta ched"); |
| 2110 return; | 2146 return; |
| 2111 } | 2147 } |
| 2112 webContext()->detachShader(objectOrZero(program), objectOrZero(shader)); | 2148 webContext()->detachShader(objectOrZero(program), objectOrZero(shader)); |
| 2113 shader->onDetached(webContext()); | 2149 shader->onDetached(webContext()); |
| 2150 preserveObjectWrapper(scriptState, program, "shader", shader->type(), nullpt r); | |
| 2114 } | 2151 } |
| 2115 | 2152 |
| 2116 void WebGLRenderingContextBase::disable(GLenum cap) | 2153 void WebGLRenderingContextBase::disable(GLenum cap) |
| 2117 { | 2154 { |
| 2118 if (isContextLost() || !validateCapability("disable", cap)) | 2155 if (isContextLost() || !validateCapability("disable", cap)) |
| 2119 return; | 2156 return; |
| 2120 if (cap == GL_STENCIL_TEST) { | 2157 if (cap == GL_STENCIL_TEST) { |
| 2121 m_stencilEnabled = false; | 2158 m_stencilEnabled = false; |
| 2122 applyStencilTest(); | 2159 applyStencilTest(); |
| 2123 return; | 2160 return; |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2263 webContext()->flush(); // Intentionally a flush, not a finish. | 2300 webContext()->flush(); // Intentionally a flush, not a finish. |
| 2264 } | 2301 } |
| 2265 | 2302 |
| 2266 void WebGLRenderingContextBase::flush() | 2303 void WebGLRenderingContextBase::flush() |
| 2267 { | 2304 { |
| 2268 if (isContextLost()) | 2305 if (isContextLost()) |
| 2269 return; | 2306 return; |
| 2270 webContext()->flush(); | 2307 webContext()->flush(); |
| 2271 } | 2308 } |
| 2272 | 2309 |
| 2273 void WebGLRenderingContextBase::framebufferRenderbuffer(GLenum target, GLenum at tachment, GLenum renderbuffertarget, WebGLRenderbuffer* buffer) | 2310 void WebGLRenderingContextBase::framebufferRenderbuffer(ScriptState* scriptState , GLenum target, GLenum attachment, GLenum renderbuffertarget, WebGLRenderbuffer * buffer) |
| 2274 { | 2311 { |
| 2275 if (isContextLost() || !validateFramebufferFuncParameters("framebufferRender buffer", target, attachment)) | 2312 if (isContextLost() || !validateFramebufferFuncParameters("framebufferRender buffer", target, attachment)) |
| 2276 return; | 2313 return; |
| 2277 if (renderbuffertarget != GL_RENDERBUFFER) { | 2314 if (renderbuffertarget != GL_RENDERBUFFER) { |
| 2278 synthesizeGLError(GL_INVALID_ENUM, "framebufferRenderbuffer", "invalid t arget"); | 2315 synthesizeGLError(GL_INVALID_ENUM, "framebufferRenderbuffer", "invalid t arget"); |
| 2279 return; | 2316 return; |
| 2280 } | 2317 } |
| 2281 if (buffer && !buffer->validate(contextGroup(), this)) { | 2318 if (buffer && !buffer->validate(contextGroup(), this)) { |
| 2282 synthesizeGLError(GL_INVALID_OPERATION, "framebufferRenderbuffer", "no b uffer or buffer not from this context"); | 2319 synthesizeGLError(GL_INVALID_OPERATION, "framebufferRenderbuffer", "no b uffer or buffer not from this context"); |
| 2283 return; | 2320 return; |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 2311 } | 2348 } |
| 2312 if (isWebGL2OrHigher() && attachment == GL_DEPTH_STENCIL_ATTACHMENT) { | 2349 if (isWebGL2OrHigher() && attachment == GL_DEPTH_STENCIL_ATTACHMENT) { |
| 2313 // On ES3, DEPTH_STENCIL_ATTACHMENT is like an alias for DEPTH_ATTACHMEN T + STENCIL_ATTACHMENT. | 2350 // On ES3, DEPTH_STENCIL_ATTACHMENT is like an alias for DEPTH_ATTACHMEN T + STENCIL_ATTACHMENT. |
| 2314 // We divide it here so in WebGLFramebuffer, we don't have to handle DEP TH_STENCIL_ATTACHMENT in WebGL 2. | 2351 // We divide it here so in WebGLFramebuffer, we don't have to handle DEP TH_STENCIL_ATTACHMENT in WebGL 2. |
| 2315 framebufferBinding->setAttachmentForBoundFramebuffer(target, GL_DEPTH_AT TACHMENT, buffer); | 2352 framebufferBinding->setAttachmentForBoundFramebuffer(target, GL_DEPTH_AT TACHMENT, buffer); |
| 2316 framebufferBinding->setAttachmentForBoundFramebuffer(target, GL_STENCIL_ ATTACHMENT, buffer); | 2353 framebufferBinding->setAttachmentForBoundFramebuffer(target, GL_STENCIL_ ATTACHMENT, buffer); |
| 2317 } else { | 2354 } else { |
| 2318 framebufferBinding->setAttachmentForBoundFramebuffer(target, attachment, buffer); | 2355 framebufferBinding->setAttachmentForBoundFramebuffer(target, attachment, buffer); |
| 2319 } | 2356 } |
| 2320 applyStencilTest(); | 2357 applyStencilTest(); |
| 2358 preserveObjectWrapper(scriptState, framebufferBinding, "renderbuffer", attac hment, buffer); | |
| 2321 } | 2359 } |
| 2322 | 2360 |
| 2323 void WebGLRenderingContextBase::framebufferTexture2D(GLenum target, GLenum attac hment, GLenum textarget, WebGLTexture* texture, GLint level) | 2361 void WebGLRenderingContextBase::framebufferTexture2D(ScriptState* scriptState, G Lenum target, GLenum attachment, GLenum textarget, WebGLTexture* texture, GLint level) |
| 2324 { | 2362 { |
| 2325 if (isContextLost() || !validateFramebufferFuncParameters("framebufferTextur e2D", target, attachment)) | 2363 if (isContextLost() || !validateFramebufferFuncParameters("framebufferTextur e2D", target, attachment)) |
| 2326 return; | 2364 return; |
| 2327 if (isWebGL2OrHigher()) { | 2365 if (isWebGL2OrHigher()) { |
| 2328 if (!validateTexFuncLevel("framebufferTexture2D", textarget, level)) | 2366 if (!validateTexFuncLevel("framebufferTexture2D", textarget, level)) |
| 2329 return; | 2367 return; |
| 2330 } else if (level) { | 2368 } else if (level) { |
| 2331 synthesizeGLError(GL_INVALID_VALUE, "framebufferTexture2D", "level not 0 "); | 2369 synthesizeGLError(GL_INVALID_VALUE, "framebufferTexture2D", "level not 0 "); |
| 2332 return; | 2370 return; |
| 2333 } | 2371 } |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 2353 webContext()->framebufferTexture2D(target, attachment, textarget, textur eObject, level); | 2391 webContext()->framebufferTexture2D(target, attachment, textarget, textur eObject, level); |
| 2354 break; | 2392 break; |
| 2355 case GL_STENCIL_ATTACHMENT: | 2393 case GL_STENCIL_ATTACHMENT: |
| 2356 webContext()->framebufferTexture2D(target, attachment, textarget, textur eObject, level); | 2394 webContext()->framebufferTexture2D(target, attachment, textarget, textur eObject, level); |
| 2357 break; | 2395 break; |
| 2358 default: | 2396 default: |
| 2359 webContext()->framebufferTexture2D(target, attachment, textarget, textur eObject, level); | 2397 webContext()->framebufferTexture2D(target, attachment, textarget, textur eObject, level); |
| 2360 } | 2398 } |
| 2361 framebufferBinding->setAttachmentForBoundFramebuffer(target, attachment, tex target, texture, level); | 2399 framebufferBinding->setAttachmentForBoundFramebuffer(target, attachment, tex target, texture, level); |
| 2362 applyStencilTest(); | 2400 applyStencilTest(); |
| 2401 preserveObjectWrapper(scriptState, framebufferBinding, "texture2d", attachme nt, texture); | |
| 2363 } | 2402 } |
| 2364 | 2403 |
| 2365 void WebGLRenderingContextBase::frontFace(GLenum mode) | 2404 void WebGLRenderingContextBase::frontFace(GLenum mode) |
| 2366 { | 2405 { |
| 2367 if (isContextLost()) | 2406 if (isContextLost()) |
| 2368 return; | 2407 return; |
| 2369 switch (mode) { | 2408 switch (mode) { |
| 2370 case GL_CW: | 2409 case GL_CW: |
| 2371 case GL_CCW: | 2410 case GL_CCW: |
| 2372 break; | 2411 break; |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2557 if (tracker->draft() && !RuntimeEnabledFeatures::webGLDraftExtensionsEnabled ()) | 2596 if (tracker->draft() && !RuntimeEnabledFeatures::webGLDraftExtensionsEnabled ()) |
| 2558 return false; | 2597 return false; |
| 2559 if (!tracker->supported(this)) | 2598 if (!tracker->supported(this)) |
| 2560 return false; | 2599 return false; |
| 2561 return true; | 2600 return true; |
| 2562 } | 2601 } |
| 2563 | 2602 |
| 2564 ScriptValue WebGLRenderingContextBase::getExtension(ScriptState* scriptState, co nst String& name) | 2603 ScriptValue WebGLRenderingContextBase::getExtension(ScriptState* scriptState, co nst String& name) |
| 2565 { | 2604 { |
| 2566 WebGLExtension* extension = nullptr; | 2605 WebGLExtension* extension = nullptr; |
| 2606 bool linkContextToExtension = false; | |
| 2567 | 2607 |
| 2568 if (!isContextLost()) { | 2608 if (!isContextLost()) { |
| 2569 for (size_t i = 0; i < m_extensions.size(); ++i) { | 2609 for (size_t i = 0; i < m_extensions.size(); ++i) { |
| 2570 ExtensionTracker* tracker = m_extensions[i]; | 2610 ExtensionTracker* tracker = m_extensions[i]; |
| 2571 if (tracker->matchesNameWithPrefixes(name)) { | 2611 if (tracker->matchesNameWithPrefixes(name)) { |
| 2572 if (extensionSupportedAndAllowed(tracker)) { | 2612 if (extensionSupportedAndAllowed(tracker)) { |
| 2573 extension = tracker->getExtension(this); | 2613 extension = tracker->getExtension(this); |
| 2574 if (extension) | 2614 if (extension) { |
| 2575 m_extensionEnabled[extension->name()] = true; | 2615 if (!m_extensionEnabled[extension->name()]) { |
| 2616 linkContextToExtension = true; | |
| 2617 m_extensionEnabled[extension->name()] = true; | |
| 2618 } | |
| 2619 } | |
| 2576 } | 2620 } |
| 2577 break; | 2621 break; |
| 2578 } | 2622 } |
| 2579 } | 2623 } |
| 2580 } | 2624 } |
| 2581 | 2625 |
| 2582 return ScriptValue(scriptState, toV8(extension, scriptState->context()->Glob al(), scriptState->isolate())); | 2626 v8::Local<v8::Value> wrappedExtension = toV8(extension, scriptState->context ()->Global(), scriptState->isolate()); |
| 2627 | |
| 2628 if (linkContextToExtension) { | |
| 2629 // Keep the extension's JavaScript wrapper alive as long as the context is alive, so that | |
| 2630 // expando properties that are added to the extension persist. | |
| 2631 preserveObjectWrapper(scriptState, this, "extension", static_cast<unsign ed long>(extension->name()), extension); | |
| 2632 } | |
| 2633 | |
| 2634 return ScriptValue(scriptState, wrappedExtension); | |
| 2583 } | 2635 } |
| 2584 | 2636 |
| 2585 ScriptValue WebGLRenderingContextBase::getFramebufferAttachmentParameter(ScriptS tate* scriptState, GLenum target, GLenum attachment, GLenum pname) | 2637 ScriptValue WebGLRenderingContextBase::getFramebufferAttachmentParameter(ScriptS tate* scriptState, GLenum target, GLenum attachment, GLenum pname) |
| 2586 { | 2638 { |
| 2587 if (isContextLost() || !validateFramebufferFuncParameters("getFramebufferAtt achmentParameter", target, attachment)) | 2639 if (isContextLost() || !validateFramebufferFuncParameters("getFramebufferAtt achmentParameter", target, attachment)) |
| 2588 return ScriptValue::createNull(scriptState); | 2640 return ScriptValue::createNull(scriptState); |
| 2589 | 2641 |
| 2590 if (!m_framebufferBinding || !m_framebufferBinding->object()) { | 2642 if (!m_framebufferBinding || !m_framebufferBinding->object()) { |
| 2591 synthesizeGLError(GL_INVALID_OPERATION, "getFramebufferAttachmentParamet er", "no framebuffer bound"); | 2643 synthesizeGLError(GL_INVALID_OPERATION, "getFramebufferAttachmentParamet er", "no framebuffer bound"); |
| 2592 return ScriptValue::createNull(scriptState); | 2644 return ScriptValue::createNull(scriptState); |
| (...skipping 2257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4850 webContext()->uniformMatrix4fv(location->location(), v->length() >> 4, trans pose, v->data()); | 4902 webContext()->uniformMatrix4fv(location->location(), v->length() >> 4, trans pose, v->data()); |
| 4851 } | 4903 } |
| 4852 | 4904 |
| 4853 void WebGLRenderingContextBase::uniformMatrix4fv(const WebGLUniformLocation* loc ation, GLboolean transpose, Vector<GLfloat>& v) | 4905 void WebGLRenderingContextBase::uniformMatrix4fv(const WebGLUniformLocation* loc ation, GLboolean transpose, Vector<GLfloat>& v) |
| 4854 { | 4906 { |
| 4855 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix4fv", location, transpose, v.data(), v.size(), 16)) | 4907 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix4fv", location, transpose, v.data(), v.size(), 16)) |
| 4856 return; | 4908 return; |
| 4857 webContext()->uniformMatrix4fv(location->location(), v.size() >> 4, transpos e, v.data()); | 4909 webContext()->uniformMatrix4fv(location->location(), v.size() >> 4, transpos e, v.data()); |
| 4858 } | 4910 } |
| 4859 | 4911 |
| 4860 void WebGLRenderingContextBase::useProgram(WebGLProgram* program) | 4912 void WebGLRenderingContextBase::useProgram(ScriptState* scriptState, WebGLProgra m* program) |
| 4861 { | 4913 { |
| 4862 bool deleted; | 4914 bool deleted; |
| 4863 if (!checkObjectToBeBound("useProgram", program, deleted)) | 4915 if (!checkObjectToBeBound("useProgram", program, deleted)) |
| 4864 return; | 4916 return; |
| 4865 if (deleted) | 4917 if (deleted) |
| 4866 program = 0; | 4918 program = 0; |
| 4867 if (program && !program->linkStatus()) { | 4919 if (program && !program->linkStatus()) { |
| 4868 synthesizeGLError(GL_INVALID_OPERATION, "useProgram", "program not valid "); | 4920 synthesizeGLError(GL_INVALID_OPERATION, "useProgram", "program not valid "); |
| 4869 return; | 4921 return; |
| 4870 } | 4922 } |
| 4871 if (m_currentProgram != program) { | 4923 if (m_currentProgram != program) { |
| 4872 if (m_currentProgram) | 4924 if (m_currentProgram) |
| 4873 m_currentProgram->onDetached(webContext()); | 4925 m_currentProgram->onDetached(webContext()); |
| 4874 m_currentProgram = program; | 4926 m_currentProgram = program; |
| 4875 webContext()->useProgram(objectOrZero(program)); | 4927 webContext()->useProgram(objectOrZero(program)); |
| 4876 if (program) | 4928 if (program) |
| 4877 program->onAttached(); | 4929 program->onAttached(); |
| 4930 preserveObjectWrapper(scriptState, this, "program", 0, program); | |
| 4878 } | 4931 } |
| 4879 } | 4932 } |
| 4880 | 4933 |
| 4881 void WebGLRenderingContextBase::validateProgram(WebGLProgram* program) | 4934 void WebGLRenderingContextBase::validateProgram(WebGLProgram* program) |
| 4882 { | 4935 { |
| 4883 if (isContextLost() || !validateWebGLObject("validateProgram", program)) | 4936 if (isContextLost() || !validateWebGLObject("validateProgram", program)) |
| 4884 return; | 4937 return; |
| 4885 webContext()->validateProgram(objectOrZero(program)); | 4938 webContext()->validateProgram(objectOrZero(program)); |
| 4886 } | 4939 } |
| 4887 | 4940 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4938 void WebGLRenderingContextBase::vertexAttrib4fv(GLuint index, const DOMFloat32Ar ray* v) | 4991 void WebGLRenderingContextBase::vertexAttrib4fv(GLuint index, const DOMFloat32Ar ray* v) |
| 4939 { | 4992 { |
| 4940 vertexAttribfvImpl("vertexAttrib4fv", index, v, 4); | 4993 vertexAttribfvImpl("vertexAttrib4fv", index, v, 4); |
| 4941 } | 4994 } |
| 4942 | 4995 |
| 4943 void WebGLRenderingContextBase::vertexAttrib4fv(GLuint index, const Vector<GLflo at>& v) | 4996 void WebGLRenderingContextBase::vertexAttrib4fv(GLuint index, const Vector<GLflo at>& v) |
| 4944 { | 4997 { |
| 4945 vertexAttribfvImpl("vertexAttrib4fv", index, v.data(), v.size(), 4); | 4998 vertexAttribfvImpl("vertexAttrib4fv", index, v.data(), v.size(), 4); |
| 4946 } | 4999 } |
| 4947 | 5000 |
| 4948 void WebGLRenderingContextBase::vertexAttribPointer(GLuint index, GLint size, GL enum type, GLboolean normalized, GLsizei stride, long long offset) | 5001 void WebGLRenderingContextBase::vertexAttribPointer(ScriptState* scriptState, GL uint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, long long offset) |
| 4949 { | 5002 { |
| 4950 if (isContextLost()) | 5003 if (isContextLost()) |
| 4951 return; | 5004 return; |
| 4952 switch (type) { | 5005 switch (type) { |
| 4953 case GL_BYTE: | 5006 case GL_BYTE: |
| 4954 case GL_UNSIGNED_BYTE: | 5007 case GL_UNSIGNED_BYTE: |
| 4955 case GL_SHORT: | 5008 case GL_SHORT: |
| 4956 case GL_UNSIGNED_SHORT: | 5009 case GL_UNSIGNED_SHORT: |
| 4957 case GL_FLOAT: | 5010 case GL_FLOAT: |
| 4958 break; | 5011 break; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 4977 unsigned typeSize = sizeInBytes(type); | 5030 unsigned typeSize = sizeInBytes(type); |
| 4978 ASSERT((typeSize & (typeSize - 1)) == 0); // Ensure that the value is POT. | 5031 ASSERT((typeSize & (typeSize - 1)) == 0); // Ensure that the value is POT. |
| 4979 if ((stride & (typeSize - 1)) || (static_cast<GLintptr>(offset) & (typeSize - 1))) { | 5032 if ((stride & (typeSize - 1)) || (static_cast<GLintptr>(offset) & (typeSize - 1))) { |
| 4980 synthesizeGLError(GL_INVALID_OPERATION, "vertexAttribPointer", "stride o r offset not valid for type"); | 5033 synthesizeGLError(GL_INVALID_OPERATION, "vertexAttribPointer", "stride o r offset not valid for type"); |
| 4981 return; | 5034 return; |
| 4982 } | 5035 } |
| 4983 GLsizei bytesPerElement = size * typeSize; | 5036 GLsizei bytesPerElement = size * typeSize; |
| 4984 | 5037 |
| 4985 m_boundVertexArrayObject->setVertexAttribState(index, bytesPerElement, size, type, normalized, stride, static_cast<GLintptr>(offset), m_boundArrayBuffer); | 5038 m_boundVertexArrayObject->setVertexAttribState(index, bytesPerElement, size, type, normalized, stride, static_cast<GLintptr>(offset), m_boundArrayBuffer); |
| 4986 webContext()->vertexAttribPointer(index, size, type, normalized, stride, sta tic_cast<GLintptr>(offset)); | 5039 webContext()->vertexAttribPointer(index, size, type, normalized, stride, sta tic_cast<GLintptr>(offset)); |
| 5040 maybePreserveDefaultVAOObjectWrapper(scriptState); | |
| 5041 preserveObjectWrapper(scriptState, m_boundVertexArrayObject, "arraybuffer", index, m_boundArrayBuffer); | |
| 4987 } | 5042 } |
| 4988 | 5043 |
| 4989 void WebGLRenderingContextBase::vertexAttribDivisorANGLE(GLuint index, GLuint di visor) | 5044 void WebGLRenderingContextBase::vertexAttribDivisorANGLE(GLuint index, GLuint di visor) |
| 4990 { | 5045 { |
| 4991 if (isContextLost()) | 5046 if (isContextLost()) |
| 4992 return; | 5047 return; |
| 4993 | 5048 |
| 4994 if (index >= m_maxVertexAttribs) { | 5049 if (index >= m_maxVertexAttribs) { |
| 4995 synthesizeGLError(GL_INVALID_VALUE, "vertexAttribDivisorANGLE", "index o ut of range"); | 5050 synthesizeGLError(GL_INVALID_VALUE, "vertexAttribDivisorANGLE", "index o ut of range"); |
| 4996 return; | 5051 return; |
| (...skipping 1642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6639 if (!buffer) { | 6694 if (!buffer) { |
| 6640 // Instead of binding fb 0, bind the drawing buffer. | 6695 // Instead of binding fb 0, bind the drawing buffer. |
| 6641 drawingBuffer()->bind(target); | 6696 drawingBuffer()->bind(target); |
| 6642 } else { | 6697 } else { |
| 6643 webContext()->bindFramebuffer(target, buffer->object()); | 6698 webContext()->bindFramebuffer(target, buffer->object()); |
| 6644 } | 6699 } |
| 6645 } | 6700 } |
| 6646 | 6701 |
| 6647 void WebGLRenderingContextBase::restoreCurrentFramebuffer() | 6702 void WebGLRenderingContextBase::restoreCurrentFramebuffer() |
| 6648 { | 6703 { |
| 6649 bindFramebuffer(GL_FRAMEBUFFER, m_framebufferBinding.get()); | 6704 bindFramebuffer(nullptr, GL_FRAMEBUFFER, m_framebufferBinding.get()); |
| 6650 } | 6705 } |
| 6651 | 6706 |
| 6652 void WebGLRenderingContextBase::restoreCurrentTexture2D() | 6707 void WebGLRenderingContextBase::restoreCurrentTexture2D() |
| 6653 { | 6708 { |
| 6654 bindTexture(GL_TEXTURE_2D, m_textureUnits[m_activeTextureUnit].m_texture2DBi nding.get()); | 6709 bindTexture(nullptr, GL_TEXTURE_2D, m_textureUnits[m_activeTextureUnit].m_te xture2DBinding.get()); |
| 6655 } | 6710 } |
| 6656 | 6711 |
| 6657 void WebGLRenderingContextBase::multisamplingChanged(bool enabled) | 6712 void WebGLRenderingContextBase::multisamplingChanged(bool enabled) |
| 6658 { | 6713 { |
| 6659 if (m_multisamplingAllowed != enabled) { | 6714 if (m_multisamplingAllowed != enabled) { |
| 6660 m_multisamplingAllowed = enabled; | 6715 m_multisamplingAllowed = enabled; |
| 6661 forceLostContext(WebGLRenderingContextBase::SyntheticLostContext, WebGLR enderingContextBase::Auto); | 6716 forceLostContext(WebGLRenderingContextBase::SyntheticLostContext, WebGLR enderingContextBase::Auto); |
| 6662 } | 6717 } |
| 6663 } | 6718 } |
| 6664 | 6719 |
| 6665 void WebGLRenderingContextBase::findNewMaxNonDefaultTextureUnit() | 6720 void WebGLRenderingContextBase::findNewMaxNonDefaultTextureUnit() |
| 6666 { | 6721 { |
| 6667 // Trace backwards from the current max to find the new max non-default text ure unit | 6722 // Trace backwards from the current max to find the new max non-default text ure unit |
| 6668 int startIndex = m_onePlusMaxNonDefaultTextureUnit - 1; | 6723 int startIndex = m_onePlusMaxNonDefaultTextureUnit - 1; |
| 6669 for (int i = startIndex; i >= 0; --i) { | 6724 for (int i = startIndex; i >= 0; --i) { |
| 6670 if (m_textureUnits[i].m_texture2DBinding | 6725 if (m_textureUnits[i].m_texture2DBinding |
| 6671 || m_textureUnits[i].m_textureCubeMapBinding) { | 6726 || m_textureUnits[i].m_textureCubeMapBinding) { |
| 6672 m_onePlusMaxNonDefaultTextureUnit = i + 1; | 6727 m_onePlusMaxNonDefaultTextureUnit = i + 1; |
| 6673 return; | 6728 return; |
| 6674 } | 6729 } |
| 6675 } | 6730 } |
| 6676 m_onePlusMaxNonDefaultTextureUnit = 0; | 6731 m_onePlusMaxNonDefaultTextureUnit = 0; |
| 6677 } | 6732 } |
| 6678 | 6733 |
| 6734 void WebGLRenderingContextBase::preserveObjectWrapper(ScriptState* scriptState, ScriptWrappable* sourceObject, const char* baseName, unsigned long index, Script Wrappable* targetObject) | |
|
haraken
2015/10/13 06:40:58
Add ASSERT(scriptState)
Ken Russell (switch to Gerrit)
2015/10/13 17:56:57
Done.
| |
| 6735 { | |
| 6736 v8::Local<v8::Value> value; | |
| 6737 v8::Isolate* isolate = scriptState->isolate(); | |
| 6738 | |
| 6739 // TODO (kbr): move this logic to V8HiddenValue. The difficulty in doing so is that the index | |
| 6740 // may vary, so it'd be necessary to lazily instantiate the V8 internalized strings, and have | |
| 6741 // efficient lookup for already-created ones. | |
| 6742 StringBuilder builder; | |
| 6743 builder.append(baseName); | |
| 6744 builder.appendNumber(static_cast<unsigned>(index)); | |
| 6745 CString name = builder.toString().utf8(); | |
| 6746 v8::Local<v8::String> jsName = v8::String::NewFromUtf8( | |
| 6747 isolate, | |
| 6748 name.data(), | |
| 6749 v8::NewStringType::kNormal, | |
| 6750 name.length()).ToLocalChecked(); | |
| 6751 if (targetObject) { | |
| 6752 V8HiddenValue::setHiddenValue( | |
| 6753 isolate, | |
| 6754 sourceObject->newLocalWrapper(isolate), | |
| 6755 jsName, | |
| 6756 targetObject->newLocalWrapper(isolate)); | |
| 6757 } else { | |
| 6758 V8HiddenValue::deleteHiddenValue( | |
| 6759 isolate, | |
| 6760 sourceObject->newLocalWrapper(isolate), | |
| 6761 jsName); | |
| 6762 } | |
| 6763 } | |
| 6764 | |
| 6765 void WebGLRenderingContextBase::maybePreserveDefaultVAOObjectWrapper(ScriptState * scriptState) | |
|
haraken
2015/10/13 06:40:58
Add ASSERT(scriptState)
Ken Russell (switch to Gerrit)
2015/10/13 17:56:57
Done.
| |
| 6766 { | |
| 6767 if (!m_preservedDefaultVAOObjectWrapper) { | |
| 6768 // The default VAO does not have a JavaScript wrapper created for it, bu t one is needed to | |
| 6769 // link up the WebGLBuffers associated with the vertex attributes. | |
| 6770 toV8(m_defaultVertexArrayObject, scriptState->context()->Global(), scrip tState->isolate()); | |
| 6771 preserveObjectWrapper(scriptState, this, "defaultvao", 0, m_defaultVerte xArrayObject); | |
| 6772 m_preservedDefaultVAOObjectWrapper = true; | |
| 6773 } | |
| 6774 } | |
| 6775 | |
| 6679 DEFINE_TRACE(WebGLRenderingContextBase::TextureUnitState) | 6776 DEFINE_TRACE(WebGLRenderingContextBase::TextureUnitState) |
| 6680 { | 6777 { |
| 6681 visitor->trace(m_texture2DBinding); | 6778 visitor->trace(m_texture2DBinding); |
| 6682 visitor->trace(m_textureCubeMapBinding); | 6779 visitor->trace(m_textureCubeMapBinding); |
| 6683 visitor->trace(m_texture3DBinding); | 6780 visitor->trace(m_texture3DBinding); |
| 6684 visitor->trace(m_texture2DArrayBinding); | 6781 visitor->trace(m_texture2DArrayBinding); |
| 6685 } | 6782 } |
| 6686 | 6783 |
| 6687 DEFINE_TRACE(WebGLRenderingContextBase) | 6784 DEFINE_TRACE(WebGLRenderingContextBase) |
| 6688 { | 6785 { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6731 | 6828 |
| 6732 return totalBytesPerPixel; | 6829 return totalBytesPerPixel; |
| 6733 } | 6830 } |
| 6734 | 6831 |
| 6735 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const | 6832 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const |
| 6736 { | 6833 { |
| 6737 return m_drawingBuffer.get(); | 6834 return m_drawingBuffer.get(); |
| 6738 } | 6835 } |
| 6739 | 6836 |
| 6740 } // namespace blink | 6837 } // namespace blink |
| OLD | NEW |