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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1938 if (isContextLost()) | 1958 if (isContextLost()) |
| 1939 return nullptr; | 1959 return nullptr; |
| 1940 if (!renderbuffer->emulatedStencilBuffer()) { | 1960 if (!renderbuffer->emulatedStencilBuffer()) { |
| 1941 renderbuffer->setEmulatedStencilBuffer(createRenderbuffer()); | 1961 renderbuffer->setEmulatedStencilBuffer(createRenderbuffer()); |
| 1942 webContext()->bindRenderbuffer(target, objectOrZero(renderbuffer->emulat edStencilBuffer())); | 1962 webContext()->bindRenderbuffer(target, objectOrZero(renderbuffer->emulat edStencilBuffer())); |
| 1943 webContext()->bindRenderbuffer(target, objectOrZero(m_renderbufferBindin g.get())); | 1963 webContext()->bindRenderbuffer(target, objectOrZero(m_renderbufferBindin g.get())); |
| 1944 } | 1964 } |
| 1945 return renderbuffer->emulatedStencilBuffer(); | 1965 return renderbuffer->emulatedStencilBuffer(); |
| 1946 } | 1966 } |
| 1947 | 1967 |
| 1968 void WebGLRenderingContextBase::setBoundVertexArrayObject(ScriptState* scriptSta te, WebGLVertexArrayObjectBase* arrayObject) | |
| 1969 { | |
| 1970 if (arrayObject) | |
| 1971 m_boundVertexArrayObject = arrayObject; | |
| 1972 else | |
| 1973 m_boundVertexArrayObject = m_defaultVertexArrayObject; | |
| 1974 | |
| 1975 preserveObjectWrapper(scriptState, this, "boundvao", 0, arrayObject); | |
| 1976 } | |
| 1977 | |
| 1948 WebGLShader* WebGLRenderingContextBase::createShader(GLenum type) | 1978 WebGLShader* WebGLRenderingContextBase::createShader(GLenum type) |
| 1949 { | 1979 { |
| 1950 if (isContextLost()) | 1980 if (isContextLost()) |
| 1951 return nullptr; | 1981 return nullptr; |
| 1952 if (type != GL_VERTEX_SHADER && type != GL_FRAGMENT_SHADER) { | 1982 if (type != GL_VERTEX_SHADER && type != GL_FRAGMENT_SHADER) { |
| 1953 synthesizeGLError(GL_INVALID_ENUM, "createShader", "invalid shader type" ); | 1983 synthesizeGLError(GL_INVALID_ENUM, "createShader", "invalid shader type" ); |
| 1954 return nullptr; | 1984 return nullptr; |
| 1955 } | 1985 } |
| 1956 | 1986 |
| 1957 WebGLShader* o = WebGLShader::create(this, type); | 1987 WebGLShader* o = WebGLShader::create(this, type); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2094 { | 2124 { |
| 2095 if (isContextLost()) | 2125 if (isContextLost()) |
| 2096 return; | 2126 return; |
| 2097 if (zNear > zFar) { | 2127 if (zNear > zFar) { |
| 2098 synthesizeGLError(GL_INVALID_OPERATION, "depthRange", "zNear > zFar"); | 2128 synthesizeGLError(GL_INVALID_OPERATION, "depthRange", "zNear > zFar"); |
| 2099 return; | 2129 return; |
| 2100 } | 2130 } |
| 2101 webContext()->depthRange(zNear, zFar); | 2131 webContext()->depthRange(zNear, zFar); |
| 2102 } | 2132 } |
| 2103 | 2133 |
| 2104 void WebGLRenderingContextBase::detachShader(WebGLProgram* program, WebGLShader* shader) | 2134 void WebGLRenderingContextBase::detachShader(ScriptState* scriptState, WebGLProg ram* program, WebGLShader* shader) |
| 2105 { | 2135 { |
| 2106 if (isContextLost() || !validateWebGLObject("detachShader", program) || !val idateWebGLObject("detachShader", shader)) | 2136 if (isContextLost() || !validateWebGLObject("detachShader", program) || !val idateWebGLObject("detachShader", shader)) |
| 2107 return; | 2137 return; |
| 2108 if (!program->detachShader(shader)) { | 2138 if (!program->detachShader(shader)) { |
| 2109 synthesizeGLError(GL_INVALID_OPERATION, "detachShader", "shader not atta ched"); | 2139 synthesizeGLError(GL_INVALID_OPERATION, "detachShader", "shader not atta ched"); |
| 2110 return; | 2140 return; |
| 2111 } | 2141 } |
| 2112 webContext()->detachShader(objectOrZero(program), objectOrZero(shader)); | 2142 webContext()->detachShader(objectOrZero(program), objectOrZero(shader)); |
| 2113 shader->onDetached(webContext()); | 2143 shader->onDetached(webContext()); |
| 2144 preserveObjectWrapper(scriptState, program, "shader", shader->type(), nullpt r); | |
| 2114 } | 2145 } |
| 2115 | 2146 |
| 2116 void WebGLRenderingContextBase::disable(GLenum cap) | 2147 void WebGLRenderingContextBase::disable(GLenum cap) |
| 2117 { | 2148 { |
| 2118 if (isContextLost() || !validateCapability("disable", cap)) | 2149 if (isContextLost() || !validateCapability("disable", cap)) |
| 2119 return; | 2150 return; |
| 2120 if (cap == GL_STENCIL_TEST) { | 2151 if (cap == GL_STENCIL_TEST) { |
| 2121 m_stencilEnabled = false; | 2152 m_stencilEnabled = false; |
| 2122 applyStencilTest(); | 2153 applyStencilTest(); |
| 2123 return; | 2154 return; |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2263 webContext()->flush(); // Intentionally a flush, not a finish. | 2294 webContext()->flush(); // Intentionally a flush, not a finish. |
| 2264 } | 2295 } |
| 2265 | 2296 |
| 2266 void WebGLRenderingContextBase::flush() | 2297 void WebGLRenderingContextBase::flush() |
| 2267 { | 2298 { |
| 2268 if (isContextLost()) | 2299 if (isContextLost()) |
| 2269 return; | 2300 return; |
| 2270 webContext()->flush(); | 2301 webContext()->flush(); |
| 2271 } | 2302 } |
| 2272 | 2303 |
| 2273 void WebGLRenderingContextBase::framebufferRenderbuffer(GLenum target, GLenum at tachment, GLenum renderbuffertarget, WebGLRenderbuffer* buffer) | 2304 void WebGLRenderingContextBase::framebufferRenderbuffer(ScriptState* scriptState , GLenum target, GLenum attachment, GLenum renderbuffertarget, WebGLRenderbuffer * buffer) |
| 2274 { | 2305 { |
| 2275 if (isContextLost() || !validateFramebufferFuncParameters("framebufferRender buffer", target, attachment)) | 2306 if (isContextLost() || !validateFramebufferFuncParameters("framebufferRender buffer", target, attachment)) |
| 2276 return; | 2307 return; |
| 2277 if (renderbuffertarget != GL_RENDERBUFFER) { | 2308 if (renderbuffertarget != GL_RENDERBUFFER) { |
| 2278 synthesizeGLError(GL_INVALID_ENUM, "framebufferRenderbuffer", "invalid t arget"); | 2309 synthesizeGLError(GL_INVALID_ENUM, "framebufferRenderbuffer", "invalid t arget"); |
| 2279 return; | 2310 return; |
| 2280 } | 2311 } |
| 2281 if (buffer && !buffer->validate(contextGroup(), this)) { | 2312 if (buffer && !buffer->validate(contextGroup(), this)) { |
| 2282 synthesizeGLError(GL_INVALID_OPERATION, "framebufferRenderbuffer", "no b uffer or buffer not from this context"); | 2313 synthesizeGLError(GL_INVALID_OPERATION, "framebufferRenderbuffer", "no b uffer or buffer not from this context"); |
| 2283 return; | 2314 return; |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 2311 } | 2342 } |
| 2312 if (isWebGL2OrHigher() && attachment == GL_DEPTH_STENCIL_ATTACHMENT) { | 2343 if (isWebGL2OrHigher() && attachment == GL_DEPTH_STENCIL_ATTACHMENT) { |
| 2313 // On ES3, DEPTH_STENCIL_ATTACHMENT is like an alias for DEPTH_ATTACHMEN T + STENCIL_ATTACHMENT. | 2344 // 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. | 2345 // 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); | 2346 framebufferBinding->setAttachmentForBoundFramebuffer(target, GL_DEPTH_AT TACHMENT, buffer); |
| 2316 framebufferBinding->setAttachmentForBoundFramebuffer(target, GL_STENCIL_ ATTACHMENT, buffer); | 2347 framebufferBinding->setAttachmentForBoundFramebuffer(target, GL_STENCIL_ ATTACHMENT, buffer); |
| 2317 } else { | 2348 } else { |
| 2318 framebufferBinding->setAttachmentForBoundFramebuffer(target, attachment, buffer); | 2349 framebufferBinding->setAttachmentForBoundFramebuffer(target, attachment, buffer); |
| 2319 } | 2350 } |
| 2320 applyStencilTest(); | 2351 applyStencilTest(); |
| 2352 preserveObjectWrapper(scriptState, framebufferBinding, "renderbuffer", attac hment, buffer); | |
| 2321 } | 2353 } |
| 2322 | 2354 |
| 2323 void WebGLRenderingContextBase::framebufferTexture2D(GLenum target, GLenum attac hment, GLenum textarget, WebGLTexture* texture, GLint level) | 2355 void WebGLRenderingContextBase::framebufferTexture2D(ScriptState* scriptState, G Lenum target, GLenum attachment, GLenum textarget, WebGLTexture* texture, GLint level) |
| 2324 { | 2356 { |
| 2325 if (isContextLost() || !validateFramebufferFuncParameters("framebufferTextur e2D", target, attachment)) | 2357 if (isContextLost() || !validateFramebufferFuncParameters("framebufferTextur e2D", target, attachment)) |
| 2326 return; | 2358 return; |
| 2327 if (isWebGL2OrHigher()) { | 2359 if (isWebGL2OrHigher()) { |
| 2328 if (!validateTexFuncLevel("framebufferTexture2D", textarget, level)) | 2360 if (!validateTexFuncLevel("framebufferTexture2D", textarget, level)) |
| 2329 return; | 2361 return; |
| 2330 } else if (level) { | 2362 } else if (level) { |
| 2331 synthesizeGLError(GL_INVALID_VALUE, "framebufferTexture2D", "level not 0 "); | 2363 synthesizeGLError(GL_INVALID_VALUE, "framebufferTexture2D", "level not 0 "); |
| 2332 return; | 2364 return; |
| 2333 } | 2365 } |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 2353 webContext()->framebufferTexture2D(target, attachment, textarget, textur eObject, level); | 2385 webContext()->framebufferTexture2D(target, attachment, textarget, textur eObject, level); |
| 2354 break; | 2386 break; |
| 2355 case GL_STENCIL_ATTACHMENT: | 2387 case GL_STENCIL_ATTACHMENT: |
| 2356 webContext()->framebufferTexture2D(target, attachment, textarget, textur eObject, level); | 2388 webContext()->framebufferTexture2D(target, attachment, textarget, textur eObject, level); |
| 2357 break; | 2389 break; |
| 2358 default: | 2390 default: |
| 2359 webContext()->framebufferTexture2D(target, attachment, textarget, textur eObject, level); | 2391 webContext()->framebufferTexture2D(target, attachment, textarget, textur eObject, level); |
| 2360 } | 2392 } |
| 2361 framebufferBinding->setAttachmentForBoundFramebuffer(target, attachment, tex target, texture, level); | 2393 framebufferBinding->setAttachmentForBoundFramebuffer(target, attachment, tex target, texture, level); |
| 2362 applyStencilTest(); | 2394 applyStencilTest(); |
| 2395 preserveObjectWrapper(scriptState, framebufferBinding, "texture2d", attachme nt, texture); | |
| 2363 } | 2396 } |
| 2364 | 2397 |
| 2365 void WebGLRenderingContextBase::frontFace(GLenum mode) | 2398 void WebGLRenderingContextBase::frontFace(GLenum mode) |
| 2366 { | 2399 { |
| 2367 if (isContextLost()) | 2400 if (isContextLost()) |
| 2368 return; | 2401 return; |
| 2369 switch (mode) { | 2402 switch (mode) { |
| 2370 case GL_CW: | 2403 case GL_CW: |
| 2371 case GL_CCW: | 2404 case GL_CCW: |
| 2372 break; | 2405 break; |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2557 if (tracker->draft() && !RuntimeEnabledFeatures::webGLDraftExtensionsEnabled ()) | 2590 if (tracker->draft() && !RuntimeEnabledFeatures::webGLDraftExtensionsEnabled ()) |
| 2558 return false; | 2591 return false; |
| 2559 if (!tracker->supported(this)) | 2592 if (!tracker->supported(this)) |
| 2560 return false; | 2593 return false; |
| 2561 return true; | 2594 return true; |
| 2562 } | 2595 } |
| 2563 | 2596 |
| 2564 ScriptValue WebGLRenderingContextBase::getExtension(ScriptState* scriptState, co nst String& name) | 2597 ScriptValue WebGLRenderingContextBase::getExtension(ScriptState* scriptState, co nst String& name) |
| 2565 { | 2598 { |
| 2566 WebGLExtension* extension = nullptr; | 2599 WebGLExtension* extension = nullptr; |
| 2600 bool linkContextToExtension = false; | |
| 2567 | 2601 |
| 2568 if (!isContextLost()) { | 2602 if (!isContextLost()) { |
| 2569 for (size_t i = 0; i < m_extensions.size(); ++i) { | 2603 for (size_t i = 0; i < m_extensions.size(); ++i) { |
| 2570 ExtensionTracker* tracker = m_extensions[i]; | 2604 ExtensionTracker* tracker = m_extensions[i]; |
| 2571 if (tracker->matchesNameWithPrefixes(name)) { | 2605 if (tracker->matchesNameWithPrefixes(name)) { |
| 2572 if (extensionSupportedAndAllowed(tracker)) { | 2606 if (extensionSupportedAndAllowed(tracker)) { |
| 2573 extension = tracker->getExtension(this); | 2607 extension = tracker->getExtension(this); |
| 2574 if (extension) | 2608 if (extension) { |
| 2575 m_extensionEnabled[extension->name()] = true; | 2609 if (!m_extensionEnabled[extension->name()]) { |
| 2610 linkContextToExtension = true; | |
| 2611 m_extensionEnabled[extension->name()] = true; | |
| 2612 } | |
| 2613 } | |
| 2576 } | 2614 } |
| 2577 break; | 2615 break; |
| 2578 } | 2616 } |
| 2579 } | 2617 } |
| 2580 } | 2618 } |
| 2581 | 2619 |
| 2582 return ScriptValue(scriptState, toV8(extension, scriptState->context()->Glob al(), scriptState->isolate())); | 2620 v8::Local<v8::Value> wrappedExtension = toV8(extension, scriptState->context ()->Global(), scriptState->isolate()); |
|
haraken
2015/10/05 23:40:07
It is sad we have to write v8:: outside bindings/,
| |
| 2621 | |
| 2622 if (linkContextToExtension) { | |
| 2623 // Keep the extension's JavaScript wrapper alive as long as the context is alive, so that | |
| 2624 // expando properties that are added to the extension persist. | |
| 2625 preserveObjectWrapper(scriptState, this, "extension", static_cast<unsign ed long>(extension->name()), extension); | |
| 2626 } | |
| 2627 | |
| 2628 return ScriptValue(scriptState, wrappedExtension); | |
| 2583 } | 2629 } |
| 2584 | 2630 |
| 2585 ScriptValue WebGLRenderingContextBase::getFramebufferAttachmentParameter(ScriptS tate* scriptState, GLenum target, GLenum attachment, GLenum pname) | 2631 ScriptValue WebGLRenderingContextBase::getFramebufferAttachmentParameter(ScriptS tate* scriptState, GLenum target, GLenum attachment, GLenum pname) |
| 2586 { | 2632 { |
| 2587 if (isContextLost() || !validateFramebufferFuncParameters("getFramebufferAtt achmentParameter", target, attachment)) | 2633 if (isContextLost() || !validateFramebufferFuncParameters("getFramebufferAtt achmentParameter", target, attachment)) |
| 2588 return ScriptValue::createNull(scriptState); | 2634 return ScriptValue::createNull(scriptState); |
| 2589 | 2635 |
| 2590 if (!m_framebufferBinding || !m_framebufferBinding->object()) { | 2636 if (!m_framebufferBinding || !m_framebufferBinding->object()) { |
| 2591 synthesizeGLError(GL_INVALID_OPERATION, "getFramebufferAttachmentParamet er", "no framebuffer bound"); | 2637 synthesizeGLError(GL_INVALID_OPERATION, "getFramebufferAttachmentParamet er", "no framebuffer bound"); |
| 2592 return ScriptValue::createNull(scriptState); | 2638 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()); | 4896 webContext()->uniformMatrix4fv(location->location(), v->length() >> 4, trans pose, v->data()); |
| 4851 } | 4897 } |
| 4852 | 4898 |
| 4853 void WebGLRenderingContextBase::uniformMatrix4fv(const WebGLUniformLocation* loc ation, GLboolean transpose, Vector<GLfloat>& v) | 4899 void WebGLRenderingContextBase::uniformMatrix4fv(const WebGLUniformLocation* loc ation, GLboolean transpose, Vector<GLfloat>& v) |
| 4854 { | 4900 { |
| 4855 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix4fv", location, transpose, v.data(), v.size(), 16)) | 4901 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix4fv", location, transpose, v.data(), v.size(), 16)) |
| 4856 return; | 4902 return; |
| 4857 webContext()->uniformMatrix4fv(location->location(), v.size() >> 4, transpos e, v.data()); | 4903 webContext()->uniformMatrix4fv(location->location(), v.size() >> 4, transpos e, v.data()); |
| 4858 } | 4904 } |
| 4859 | 4905 |
| 4860 void WebGLRenderingContextBase::useProgram(WebGLProgram* program) | 4906 void WebGLRenderingContextBase::useProgram(ScriptState* scriptState, WebGLProgra m* program) |
| 4861 { | 4907 { |
| 4862 bool deleted; | 4908 bool deleted; |
| 4863 if (!checkObjectToBeBound("useProgram", program, deleted)) | 4909 if (!checkObjectToBeBound("useProgram", program, deleted)) |
| 4864 return; | 4910 return; |
| 4865 if (deleted) | 4911 if (deleted) |
| 4866 program = 0; | 4912 program = 0; |
| 4867 if (program && !program->linkStatus()) { | 4913 if (program && !program->linkStatus()) { |
| 4868 synthesizeGLError(GL_INVALID_OPERATION, "useProgram", "program not valid "); | 4914 synthesizeGLError(GL_INVALID_OPERATION, "useProgram", "program not valid "); |
| 4869 return; | 4915 return; |
| 4870 } | 4916 } |
| 4871 if (m_currentProgram != program) { | 4917 if (m_currentProgram != program) { |
| 4872 if (m_currentProgram) | 4918 if (m_currentProgram) |
| 4873 m_currentProgram->onDetached(webContext()); | 4919 m_currentProgram->onDetached(webContext()); |
| 4874 m_currentProgram = program; | 4920 m_currentProgram = program; |
| 4875 webContext()->useProgram(objectOrZero(program)); | 4921 webContext()->useProgram(objectOrZero(program)); |
| 4876 if (program) | 4922 if (program) |
| 4877 program->onAttached(); | 4923 program->onAttached(); |
| 4924 preserveObjectWrapper(scriptState, this, "program", 0, program); | |
| 4878 } | 4925 } |
| 4879 } | 4926 } |
| 4880 | 4927 |
| 4881 void WebGLRenderingContextBase::validateProgram(WebGLProgram* program) | 4928 void WebGLRenderingContextBase::validateProgram(WebGLProgram* program) |
| 4882 { | 4929 { |
| 4883 if (isContextLost() || !validateWebGLObject("validateProgram", program)) | 4930 if (isContextLost() || !validateWebGLObject("validateProgram", program)) |
| 4884 return; | 4931 return; |
| 4885 webContext()->validateProgram(objectOrZero(program)); | 4932 webContext()->validateProgram(objectOrZero(program)); |
| 4886 } | 4933 } |
| 4887 | 4934 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4938 void WebGLRenderingContextBase::vertexAttrib4fv(GLuint index, const DOMFloat32Ar ray* v) | 4985 void WebGLRenderingContextBase::vertexAttrib4fv(GLuint index, const DOMFloat32Ar ray* v) |
| 4939 { | 4986 { |
| 4940 vertexAttribfvImpl("vertexAttrib4fv", index, v, 4); | 4987 vertexAttribfvImpl("vertexAttrib4fv", index, v, 4); |
| 4941 } | 4988 } |
| 4942 | 4989 |
| 4943 void WebGLRenderingContextBase::vertexAttrib4fv(GLuint index, const Vector<GLflo at>& v) | 4990 void WebGLRenderingContextBase::vertexAttrib4fv(GLuint index, const Vector<GLflo at>& v) |
| 4944 { | 4991 { |
| 4945 vertexAttribfvImpl("vertexAttrib4fv", index, v.data(), v.size(), 4); | 4992 vertexAttribfvImpl("vertexAttrib4fv", index, v.data(), v.size(), 4); |
| 4946 } | 4993 } |
| 4947 | 4994 |
| 4948 void WebGLRenderingContextBase::vertexAttribPointer(GLuint index, GLint size, GL enum type, GLboolean normalized, GLsizei stride, long long offset) | 4995 void WebGLRenderingContextBase::vertexAttribPointer(ScriptState* scriptState, GL uint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, long long offset) |
| 4949 { | 4996 { |
| 4950 if (isContextLost()) | 4997 if (isContextLost()) |
| 4951 return; | 4998 return; |
| 4952 switch (type) { | 4999 switch (type) { |
| 4953 case GL_BYTE: | 5000 case GL_BYTE: |
| 4954 case GL_UNSIGNED_BYTE: | 5001 case GL_UNSIGNED_BYTE: |
| 4955 case GL_SHORT: | 5002 case GL_SHORT: |
| 4956 case GL_UNSIGNED_SHORT: | 5003 case GL_UNSIGNED_SHORT: |
| 4957 case GL_FLOAT: | 5004 case GL_FLOAT: |
| 4958 break; | 5005 break; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 4977 unsigned typeSize = sizeInBytes(type); | 5024 unsigned typeSize = sizeInBytes(type); |
| 4978 ASSERT((typeSize & (typeSize - 1)) == 0); // Ensure that the value is POT. | 5025 ASSERT((typeSize & (typeSize - 1)) == 0); // Ensure that the value is POT. |
| 4979 if ((stride & (typeSize - 1)) || (static_cast<GLintptr>(offset) & (typeSize - 1))) { | 5026 if ((stride & (typeSize - 1)) || (static_cast<GLintptr>(offset) & (typeSize - 1))) { |
| 4980 synthesizeGLError(GL_INVALID_OPERATION, "vertexAttribPointer", "stride o r offset not valid for type"); | 5027 synthesizeGLError(GL_INVALID_OPERATION, "vertexAttribPointer", "stride o r offset not valid for type"); |
| 4981 return; | 5028 return; |
| 4982 } | 5029 } |
| 4983 GLsizei bytesPerElement = size * typeSize; | 5030 GLsizei bytesPerElement = size * typeSize; |
| 4984 | 5031 |
| 4985 m_boundVertexArrayObject->setVertexAttribState(index, bytesPerElement, size, type, normalized, stride, static_cast<GLintptr>(offset), m_boundArrayBuffer); | 5032 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)); | 5033 webContext()->vertexAttribPointer(index, size, type, normalized, stride, sta tic_cast<GLintptr>(offset)); |
| 5034 maybePreserveDefaultVAOObjectWrapper(scriptState); | |
| 5035 preserveObjectWrapper(scriptState, m_boundVertexArrayObject, "arraybuffer", index, m_boundArrayBuffer); | |
| 4987 } | 5036 } |
| 4988 | 5037 |
| 4989 void WebGLRenderingContextBase::vertexAttribDivisorANGLE(GLuint index, GLuint di visor) | 5038 void WebGLRenderingContextBase::vertexAttribDivisorANGLE(GLuint index, GLuint di visor) |
| 4990 { | 5039 { |
| 4991 if (isContextLost()) | 5040 if (isContextLost()) |
| 4992 return; | 5041 return; |
| 4993 | 5042 |
| 4994 if (index >= m_maxVertexAttribs) { | 5043 if (index >= m_maxVertexAttribs) { |
| 4995 synthesizeGLError(GL_INVALID_VALUE, "vertexAttribDivisorANGLE", "index o ut of range"); | 5044 synthesizeGLError(GL_INVALID_VALUE, "vertexAttribDivisorANGLE", "index o ut of range"); |
| 4996 return; | 5045 return; |
| (...skipping 1642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6639 if (!buffer) { | 6688 if (!buffer) { |
| 6640 // Instead of binding fb 0, bind the drawing buffer. | 6689 // Instead of binding fb 0, bind the drawing buffer. |
| 6641 drawingBuffer()->bind(target); | 6690 drawingBuffer()->bind(target); |
| 6642 } else { | 6691 } else { |
| 6643 webContext()->bindFramebuffer(target, buffer->object()); | 6692 webContext()->bindFramebuffer(target, buffer->object()); |
| 6644 } | 6693 } |
| 6645 } | 6694 } |
| 6646 | 6695 |
| 6647 void WebGLRenderingContextBase::restoreCurrentFramebuffer() | 6696 void WebGLRenderingContextBase::restoreCurrentFramebuffer() |
| 6648 { | 6697 { |
| 6649 bindFramebuffer(GL_FRAMEBUFFER, m_framebufferBinding.get()); | 6698 bindFramebuffer(nullptr, GL_FRAMEBUFFER, m_framebufferBinding.get()); |
| 6650 } | 6699 } |
| 6651 | 6700 |
| 6652 void WebGLRenderingContextBase::restoreCurrentTexture2D() | 6701 void WebGLRenderingContextBase::restoreCurrentTexture2D() |
| 6653 { | 6702 { |
| 6654 bindTexture(GL_TEXTURE_2D, m_textureUnits[m_activeTextureUnit].m_texture2DBi nding.get()); | 6703 bindTexture(nullptr, GL_TEXTURE_2D, m_textureUnits[m_activeTextureUnit].m_te xture2DBinding.get()); |
| 6655 } | 6704 } |
| 6656 | 6705 |
| 6657 void WebGLRenderingContextBase::multisamplingChanged(bool enabled) | 6706 void WebGLRenderingContextBase::multisamplingChanged(bool enabled) |
| 6658 { | 6707 { |
| 6659 if (m_multisamplingAllowed != enabled) { | 6708 if (m_multisamplingAllowed != enabled) { |
| 6660 m_multisamplingAllowed = enabled; | 6709 m_multisamplingAllowed = enabled; |
| 6661 forceLostContext(WebGLRenderingContextBase::SyntheticLostContext, WebGLR enderingContextBase::Auto); | 6710 forceLostContext(WebGLRenderingContextBase::SyntheticLostContext, WebGLR enderingContextBase::Auto); |
| 6662 } | 6711 } |
| 6663 } | 6712 } |
| 6664 | 6713 |
| 6665 void WebGLRenderingContextBase::findNewMaxNonDefaultTextureUnit() | 6714 void WebGLRenderingContextBase::findNewMaxNonDefaultTextureUnit() |
| 6666 { | 6715 { |
| 6667 // Trace backwards from the current max to find the new max non-default text ure unit | 6716 // Trace backwards from the current max to find the new max non-default text ure unit |
| 6668 int startIndex = m_onePlusMaxNonDefaultTextureUnit - 1; | 6717 int startIndex = m_onePlusMaxNonDefaultTextureUnit - 1; |
| 6669 for (int i = startIndex; i >= 0; --i) { | 6718 for (int i = startIndex; i >= 0; --i) { |
| 6670 if (m_textureUnits[i].m_texture2DBinding | 6719 if (m_textureUnits[i].m_texture2DBinding |
| 6671 || m_textureUnits[i].m_textureCubeMapBinding) { | 6720 || m_textureUnits[i].m_textureCubeMapBinding) { |
| 6672 m_onePlusMaxNonDefaultTextureUnit = i + 1; | 6721 m_onePlusMaxNonDefaultTextureUnit = i + 1; |
| 6673 return; | 6722 return; |
| 6674 } | 6723 } |
| 6675 } | 6724 } |
| 6676 m_onePlusMaxNonDefaultTextureUnit = 0; | 6725 m_onePlusMaxNonDefaultTextureUnit = 0; |
| 6677 } | 6726 } |
| 6678 | 6727 |
| 6728 void WebGLRenderingContextBase::preserveObjectWrapper(ScriptState* scriptState, ScriptWrappable* sourceObject, const char* baseName, unsigned long index, Script Wrappable* targetObject) | |
| 6729 { | |
| 6730 v8::Local<v8::Value> value; | |
| 6731 | |
| 6732 StringBuilder builder; | |
| 6733 builder.append(baseName); | |
| 6734 builder.appendNumber(static_cast<unsigned>(index)); | |
| 6735 CString name = builder.toString().utf8(); | |
|
haraken
2015/10/05 23:40:07
It is inefficient to build up a hidden name string
Ken Russell (switch to Gerrit)
2015/10/06 00:14:19
Not with the current code structure in V8HiddenVal
haraken
2015/10/06 00:29:10
Yes, it will be great if you can encapsulate the l
Ken Russell (switch to Gerrit)
2015/10/06 02:41:51
Sorry, I should have replied here rather than glob
haraken
2015/10/06 03:46:17
Yes, a follow-up CL is fine.
| |
| 6736 v8::Local<v8::String> jsName = v8::String::NewFromUtf8( | |
| 6737 scriptState->isolate(), | |
| 6738 name.data(), | |
| 6739 v8::NewStringType::kNormal, | |
| 6740 name.length()).ToLocalChecked(); | |
| 6741 if (targetObject) { | |
| 6742 V8HiddenValue::setHiddenValue( | |
| 6743 scriptState->isolate(), | |
| 6744 sourceObject->newLocalWrapper(scriptState->isolate()), | |
| 6745 jsName, | |
| 6746 targetObject->newLocalWrapper(scriptState->isolate())); | |
| 6747 } else { | |
| 6748 V8HiddenValue::deleteHiddenValue( | |
| 6749 scriptState->isolate(), | |
| 6750 sourceObject->newLocalWrapper(scriptState->isolate()), | |
| 6751 jsName); | |
| 6752 } | |
| 6753 } | |
| 6754 | |
| 6755 void WebGLRenderingContextBase::maybePreserveDefaultVAOObjectWrapper(ScriptState * scriptState) | |
|
haraken
2015/10/06 00:31:29
Just to confirm: maybePreserveDefaultVAOObjectWrap
Ken Russell (switch to Gerrit)
2015/10/06 02:39:42
Yes, it's only called from other methods in this c
| |
| 6756 { | |
| 6757 if (!m_preservedDefaultVAOObjectWrapper) { | |
| 6758 // The default VAO does not have a JavaScript wrapper created for it, bu t one is needed to | |
| 6759 // link up the WebGLBuffers associated with the vertex attributes. | |
| 6760 m_defaultVertexArrayObject->wrap(scriptState->isolate(), scriptState->co ntext()->Global()); | |
|
haraken
2015/10/05 23:40:07
Why do you use wrap instead of toV8?
Ken Russell (switch to Gerrit)
2015/10/06 00:14:19
Thanks, good point. I didn't know that was preferr
| |
| 6761 preserveObjectWrapper(scriptState, this, "defaultvao", 0, m_defaultVerte xArrayObject); | |
| 6762 m_preservedDefaultVAOObjectWrapper = true; | |
|
haraken
2015/10/05 23:40:07
How is it guaranteed that m_preservedDefaultVAOObj
Ken Russell (switch to Gerrit)
2015/10/06 00:14:19
That's not how it's handled -- the default VAO's o
| |
| 6763 } | |
| 6764 } | |
| 6765 | |
| 6679 DEFINE_TRACE(WebGLRenderingContextBase::TextureUnitState) | 6766 DEFINE_TRACE(WebGLRenderingContextBase::TextureUnitState) |
| 6680 { | 6767 { |
| 6681 visitor->trace(m_texture2DBinding); | 6768 visitor->trace(m_texture2DBinding); |
| 6682 visitor->trace(m_textureCubeMapBinding); | 6769 visitor->trace(m_textureCubeMapBinding); |
| 6683 visitor->trace(m_texture3DBinding); | 6770 visitor->trace(m_texture3DBinding); |
| 6684 visitor->trace(m_texture2DArrayBinding); | 6771 visitor->trace(m_texture2DArrayBinding); |
| 6685 } | 6772 } |
| 6686 | 6773 |
| 6687 DEFINE_TRACE(WebGLRenderingContextBase) | 6774 DEFINE_TRACE(WebGLRenderingContextBase) |
| 6688 { | 6775 { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6731 | 6818 |
| 6732 return totalBytesPerPixel; | 6819 return totalBytesPerPixel; |
| 6733 } | 6820 } |
| 6734 | 6821 |
| 6735 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const | 6822 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const |
| 6736 { | 6823 { |
| 6737 return m_drawingBuffer.get(); | 6824 return m_drawingBuffer.get(); |
| 6738 } | 6825 } |
| 6739 | 6826 |
| 6740 } // namespace blink | 6827 } // namespace blink |
| OLD | NEW |