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 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
859 { GL_RGBA32UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT }, | 859 { GL_RGBA32UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT }, |
860 { GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT }, | 860 { GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT }, |
861 { GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT }, | 861 { GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT }, |
862 { GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT }, | 862 { GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT }, |
863 { GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT }, | 863 { GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT }, |
864 { GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8 }, | 864 { GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8 }, |
865 }; | 865 }; |
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, ScriptState* scriptState, PassOwnPtr<WebGraphicsContext3D> context, const WebGLContextAttributes& requestedAttributes) |
870 : CanvasRenderingContext(passedCanvas) | 870 : CanvasRenderingContext(passedCanvas) |
871 , m_scriptState(scriptState) | |
871 , m_contextLostMode(NotLostContext) | 872 , m_contextLostMode(NotLostContext) |
872 , m_autoRecoveryMethod(Manual) | 873 , m_autoRecoveryMethod(Manual) |
873 , m_dispatchContextLostEventTimer(this, &WebGLRenderingContextBase::dispatch ContextLostEvent) | 874 , m_dispatchContextLostEventTimer(this, &WebGLRenderingContextBase::dispatch ContextLostEvent) |
874 , m_restoreAllowed(false) | 875 , m_restoreAllowed(false) |
875 , m_restoreTimer(this, &WebGLRenderingContextBase::maybeRestoreContext) | 876 , m_restoreTimer(this, &WebGLRenderingContextBase::maybeRestoreContext) |
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) |
(...skipping 105 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 // The default VAO is never exposed to JavaScript, but a wrapper is needed i n order to link | |
998 // buffer objects' wrappers to it. The wrapper for the context itself might not have been | |
999 // created by this point. | |
1000 toV8(this, m_scriptState->context()->Global(), m_scriptState->isolate()); | |
1001 toV8(m_defaultVertexArrayObject, m_scriptState->context()->Global(), m_scrip tState->isolate()); | |
haraken
2015/10/13 02:02:04
Just for the record: We don't need to enter the Sc
Ken Russell (switch to Gerrit)
2015/10/13 06:11:44
Actually, this code is called from a timer after t
| |
1002 preserveObjectWrapper(m_scriptState.get(), this, "defaultvao", 0, m_defaultV ertexArrayObject); | |
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); | |
1451 } | 1460 } |
1452 | 1461 |
1453 void WebGLRenderingContextBase::bindFramebuffer(GLenum target, WebGLFramebuffer* buffer) | 1462 void WebGLRenderingContextBase::bindFramebuffer(ScriptState* scriptState, GLenum target, WebGLFramebuffer* buffer) |
1454 { | 1463 { |
1455 bool deleted; | 1464 bool deleted; |
1456 if (!checkObjectToBeBound("bindFramebuffer", buffer, deleted)) | 1465 if (!checkObjectToBeBound("bindFramebuffer", buffer, deleted)) |
1457 return; | 1466 return; |
1458 | 1467 |
1459 if (deleted) | 1468 if (deleted) |
1460 buffer = 0; | 1469 buffer = 0; |
1461 | 1470 |
1462 if (target != GL_FRAMEBUFFER) { | 1471 if (target != GL_FRAMEBUFFER) { |
1463 synthesizeGLError(GL_INVALID_ENUM, "bindFramebuffer", "invalid target"); | 1472 synthesizeGLError(GL_INVALID_ENUM, "bindFramebuffer", "invalid target"); |
1464 return; | 1473 return; |
1465 } | 1474 } |
1466 | 1475 |
1467 setFramebuffer(target, buffer); | 1476 setFramebuffer(target, buffer); |
1477 if (scriptState) | |
haraken
2015/10/13 02:02:04
It would be great if we could remove the null chec
Ken Russell (switch to Gerrit)
2015/10/13 06:11:44
There's no need to do this work if we're calling t
| |
1478 preserveObjectWrapper(scriptState, this, "framebuffer", 0, buffer); | |
1468 } | 1479 } |
1469 | 1480 |
1470 void WebGLRenderingContextBase::bindRenderbuffer(GLenum target, WebGLRenderbuffe r* renderBuffer) | 1481 void WebGLRenderingContextBase::bindRenderbuffer(ScriptState* scriptState, GLenu m target, WebGLRenderbuffer* renderBuffer) |
1471 { | 1482 { |
1472 bool deleted; | 1483 bool deleted; |
1473 if (!checkObjectToBeBound("bindRenderbuffer", renderBuffer, deleted)) | 1484 if (!checkObjectToBeBound("bindRenderbuffer", renderBuffer, deleted)) |
1474 return; | 1485 return; |
1475 if (deleted) | 1486 if (deleted) |
1476 renderBuffer = 0; | 1487 renderBuffer = 0; |
1477 if (target != GL_RENDERBUFFER) { | 1488 if (target != GL_RENDERBUFFER) { |
1478 synthesizeGLError(GL_INVALID_ENUM, "bindRenderbuffer", "invalid target") ; | 1489 synthesizeGLError(GL_INVALID_ENUM, "bindRenderbuffer", "invalid target") ; |
1479 return; | 1490 return; |
1480 } | 1491 } |
1481 m_renderbufferBinding = renderBuffer; | 1492 m_renderbufferBinding = renderBuffer; |
1482 webContext()->bindRenderbuffer(target, objectOrZero(renderBuffer)); | 1493 webContext()->bindRenderbuffer(target, objectOrZero(renderBuffer)); |
1494 preserveObjectWrapper(scriptState, this, "renderbuffer", 0, renderBuffer); | |
1483 if (renderBuffer) | 1495 if (renderBuffer) |
1484 renderBuffer->setHasEverBeenBound(); | 1496 renderBuffer->setHasEverBeenBound(); |
1485 } | 1497 } |
1486 | 1498 |
1487 void WebGLRenderingContextBase::bindTexture(GLenum target, WebGLTexture* texture ) | 1499 void WebGLRenderingContextBase::bindTexture(ScriptState* scriptState, GLenum tar get, WebGLTexture* texture) |
1488 { | 1500 { |
1489 bool deleted; | 1501 bool deleted; |
1490 if (!checkObjectToBeBound("bindTexture", texture, deleted)) | 1502 if (!checkObjectToBeBound("bindTexture", texture, deleted)) |
1491 return; | 1503 return; |
1492 if (deleted) | 1504 if (deleted) |
1493 texture = 0; | 1505 texture = 0; |
1494 if (texture && texture->getTarget() && texture->getTarget() != target) { | 1506 if (texture && texture->getTarget() && texture->getTarget() != target) { |
1495 synthesizeGLError(GL_INVALID_OPERATION, "bindTexture", "textures can not be used with multiple targets"); | 1507 synthesizeGLError(GL_INVALID_OPERATION, "bindTexture", "textures can not be used with multiple targets"); |
1496 return; | 1508 return; |
1497 } | 1509 } |
1510 | |
1511 const char* bindingPointName = nullptr; | |
1498 if (target == GL_TEXTURE_2D) { | 1512 if (target == GL_TEXTURE_2D) { |
1499 m_textureUnits[m_activeTextureUnit].m_texture2DBinding = texture; | 1513 m_textureUnits[m_activeTextureUnit].m_texture2DBinding = texture; |
1500 | 1514 |
1501 if (!m_activeTextureUnit) | 1515 if (!m_activeTextureUnit) |
1502 drawingBuffer()->setTexture2DBinding(objectOrZero(texture)); | 1516 drawingBuffer()->setTexture2DBinding(objectOrZero(texture)); |
1517 bindingPointName = "texture_2d"; | |
1503 } else if (target == GL_TEXTURE_CUBE_MAP) { | 1518 } else if (target == GL_TEXTURE_CUBE_MAP) { |
1504 m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding = texture; | 1519 m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding = texture; |
1520 bindingPointName = "texture_cube_map"; | |
1505 } else if (isWebGL2OrHigher() && target == GL_TEXTURE_2D_ARRAY) { | 1521 } else if (isWebGL2OrHigher() && target == GL_TEXTURE_2D_ARRAY) { |
1506 m_textureUnits[m_activeTextureUnit].m_texture2DArrayBinding = texture; | 1522 m_textureUnits[m_activeTextureUnit].m_texture2DArrayBinding = texture; |
1523 bindingPointName = "texture_2d_array"; | |
1507 } else if (isWebGL2OrHigher() && target == GL_TEXTURE_3D) { | 1524 } else if (isWebGL2OrHigher() && target == GL_TEXTURE_3D) { |
1508 m_textureUnits[m_activeTextureUnit].m_texture3DBinding = texture; | 1525 m_textureUnits[m_activeTextureUnit].m_texture3DBinding = texture; |
1526 bindingPointName = "texture_3d"; | |
1509 } else { | 1527 } else { |
1510 synthesizeGLError(GL_INVALID_ENUM, "bindTexture", "invalid target"); | 1528 synthesizeGLError(GL_INVALID_ENUM, "bindTexture", "invalid target"); |
1511 return; | 1529 return; |
1512 } | 1530 } |
1513 | 1531 |
1514 webContext()->bindTexture(target, objectOrZero(texture)); | 1532 webContext()->bindTexture(target, objectOrZero(texture)); |
1533 // This is called both internally and externally (from JavaScript). We only update which wrapper | |
1534 // is preserved when it's called from JavaScript. | |
1535 if (scriptState) { | |
haraken
2015/10/13 02:02:04
Ditto.
Ken Russell (switch to Gerrit)
2015/10/13 06:11:44
Same answer.
| |
1536 preserveObjectWrapper(scriptState, this, bindingPointName, m_activeTextu reUnit, texture); | |
1537 } | |
1515 if (texture) { | 1538 if (texture) { |
1516 texture->setTarget(target, getMaxTextureLevelForTarget(target)); | 1539 texture->setTarget(target, getMaxTextureLevelForTarget(target)); |
1517 m_onePlusMaxNonDefaultTextureUnit = max(m_activeTextureUnit + 1, m_onePl usMaxNonDefaultTextureUnit); | 1540 m_onePlusMaxNonDefaultTextureUnit = max(m_activeTextureUnit + 1, m_onePl usMaxNonDefaultTextureUnit); |
1518 } else { | 1541 } else { |
1519 // If the disabled index is the current maximum, trace backwards to find the new max enabled texture index | 1542 // 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) { | 1543 if (m_onePlusMaxNonDefaultTextureUnit == m_activeTextureUnit + 1) { |
1521 findNewMaxNonDefaultTextureUnit(); | 1544 findNewMaxNonDefaultTextureUnit(); |
1522 } | 1545 } |
1523 } | 1546 } |
1524 | 1547 |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1938 if (isContextLost()) | 1961 if (isContextLost()) |
1939 return nullptr; | 1962 return nullptr; |
1940 if (!renderbuffer->emulatedStencilBuffer()) { | 1963 if (!renderbuffer->emulatedStencilBuffer()) { |
1941 renderbuffer->setEmulatedStencilBuffer(createRenderbuffer()); | 1964 renderbuffer->setEmulatedStencilBuffer(createRenderbuffer()); |
1942 webContext()->bindRenderbuffer(target, objectOrZero(renderbuffer->emulat edStencilBuffer())); | 1965 webContext()->bindRenderbuffer(target, objectOrZero(renderbuffer->emulat edStencilBuffer())); |
1943 webContext()->bindRenderbuffer(target, objectOrZero(m_renderbufferBindin g.get())); | 1966 webContext()->bindRenderbuffer(target, objectOrZero(m_renderbufferBindin g.get())); |
1944 } | 1967 } |
1945 return renderbuffer->emulatedStencilBuffer(); | 1968 return renderbuffer->emulatedStencilBuffer(); |
1946 } | 1969 } |
1947 | 1970 |
1971 void WebGLRenderingContextBase::setBoundVertexArrayObject(ScriptState* scriptSta te, WebGLVertexArrayObjectBase* arrayObject) | |
1972 { | |
1973 if (arrayObject) | |
1974 m_boundVertexArrayObject = arrayObject; | |
1975 else | |
1976 m_boundVertexArrayObject = m_defaultVertexArrayObject; | |
1977 | |
1978 preserveObjectWrapper(scriptState, this, "boundvao", 0, arrayObject); | |
1979 } | |
1980 | |
1948 WebGLShader* WebGLRenderingContextBase::createShader(GLenum type) | 1981 WebGLShader* WebGLRenderingContextBase::createShader(GLenum type) |
1949 { | 1982 { |
1950 if (isContextLost()) | 1983 if (isContextLost()) |
1951 return nullptr; | 1984 return nullptr; |
1952 if (type != GL_VERTEX_SHADER && type != GL_FRAGMENT_SHADER) { | 1985 if (type != GL_VERTEX_SHADER && type != GL_FRAGMENT_SHADER) { |
1953 synthesizeGLError(GL_INVALID_ENUM, "createShader", "invalid shader type" ); | 1986 synthesizeGLError(GL_INVALID_ENUM, "createShader", "invalid shader type" ); |
1954 return nullptr; | 1987 return nullptr; |
1955 } | 1988 } |
1956 | 1989 |
1957 WebGLShader* o = WebGLShader::create(this, type); | 1990 WebGLShader* o = WebGLShader::create(this, type); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2094 { | 2127 { |
2095 if (isContextLost()) | 2128 if (isContextLost()) |
2096 return; | 2129 return; |
2097 if (zNear > zFar) { | 2130 if (zNear > zFar) { |
2098 synthesizeGLError(GL_INVALID_OPERATION, "depthRange", "zNear > zFar"); | 2131 synthesizeGLError(GL_INVALID_OPERATION, "depthRange", "zNear > zFar"); |
2099 return; | 2132 return; |
2100 } | 2133 } |
2101 webContext()->depthRange(zNear, zFar); | 2134 webContext()->depthRange(zNear, zFar); |
2102 } | 2135 } |
2103 | 2136 |
2104 void WebGLRenderingContextBase::detachShader(WebGLProgram* program, WebGLShader* shader) | 2137 void WebGLRenderingContextBase::detachShader(ScriptState* scriptState, WebGLProg ram* program, WebGLShader* shader) |
2105 { | 2138 { |
2106 if (isContextLost() || !validateWebGLObject("detachShader", program) || !val idateWebGLObject("detachShader", shader)) | 2139 if (isContextLost() || !validateWebGLObject("detachShader", program) || !val idateWebGLObject("detachShader", shader)) |
2107 return; | 2140 return; |
2108 if (!program->detachShader(shader)) { | 2141 if (!program->detachShader(shader)) { |
2109 synthesizeGLError(GL_INVALID_OPERATION, "detachShader", "shader not atta ched"); | 2142 synthesizeGLError(GL_INVALID_OPERATION, "detachShader", "shader not atta ched"); |
2110 return; | 2143 return; |
2111 } | 2144 } |
2112 webContext()->detachShader(objectOrZero(program), objectOrZero(shader)); | 2145 webContext()->detachShader(objectOrZero(program), objectOrZero(shader)); |
2113 shader->onDetached(webContext()); | 2146 shader->onDetached(webContext()); |
2147 preserveObjectWrapper(scriptState, program, "shader", shader->type(), nullpt r); | |
2114 } | 2148 } |
2115 | 2149 |
2116 void WebGLRenderingContextBase::disable(GLenum cap) | 2150 void WebGLRenderingContextBase::disable(GLenum cap) |
2117 { | 2151 { |
2118 if (isContextLost() || !validateCapability("disable", cap)) | 2152 if (isContextLost() || !validateCapability("disable", cap)) |
2119 return; | 2153 return; |
2120 if (cap == GL_STENCIL_TEST) { | 2154 if (cap == GL_STENCIL_TEST) { |
2121 m_stencilEnabled = false; | 2155 m_stencilEnabled = false; |
2122 applyStencilTest(); | 2156 applyStencilTest(); |
2123 return; | 2157 return; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2263 webContext()->flush(); // Intentionally a flush, not a finish. | 2297 webContext()->flush(); // Intentionally a flush, not a finish. |
2264 } | 2298 } |
2265 | 2299 |
2266 void WebGLRenderingContextBase::flush() | 2300 void WebGLRenderingContextBase::flush() |
2267 { | 2301 { |
2268 if (isContextLost()) | 2302 if (isContextLost()) |
2269 return; | 2303 return; |
2270 webContext()->flush(); | 2304 webContext()->flush(); |
2271 } | 2305 } |
2272 | 2306 |
2273 void WebGLRenderingContextBase::framebufferRenderbuffer(GLenum target, GLenum at tachment, GLenum renderbuffertarget, WebGLRenderbuffer* buffer) | 2307 void WebGLRenderingContextBase::framebufferRenderbuffer(ScriptState* scriptState , GLenum target, GLenum attachment, GLenum renderbuffertarget, WebGLRenderbuffer * buffer) |
2274 { | 2308 { |
2275 if (isContextLost() || !validateFramebufferFuncParameters("framebufferRender buffer", target, attachment)) | 2309 if (isContextLost() || !validateFramebufferFuncParameters("framebufferRender buffer", target, attachment)) |
2276 return; | 2310 return; |
2277 if (renderbuffertarget != GL_RENDERBUFFER) { | 2311 if (renderbuffertarget != GL_RENDERBUFFER) { |
2278 synthesizeGLError(GL_INVALID_ENUM, "framebufferRenderbuffer", "invalid t arget"); | 2312 synthesizeGLError(GL_INVALID_ENUM, "framebufferRenderbuffer", "invalid t arget"); |
2279 return; | 2313 return; |
2280 } | 2314 } |
2281 if (buffer && !buffer->validate(contextGroup(), this)) { | 2315 if (buffer && !buffer->validate(contextGroup(), this)) { |
2282 synthesizeGLError(GL_INVALID_OPERATION, "framebufferRenderbuffer", "no b uffer or buffer not from this context"); | 2316 synthesizeGLError(GL_INVALID_OPERATION, "framebufferRenderbuffer", "no b uffer or buffer not from this context"); |
2283 return; | 2317 return; |
(...skipping 27 matching lines...) Expand all Loading... | |
2311 } | 2345 } |
2312 if (isWebGL2OrHigher() && attachment == GL_DEPTH_STENCIL_ATTACHMENT) { | 2346 if (isWebGL2OrHigher() && attachment == GL_DEPTH_STENCIL_ATTACHMENT) { |
2313 // On ES3, DEPTH_STENCIL_ATTACHMENT is like an alias for DEPTH_ATTACHMEN T + STENCIL_ATTACHMENT. | 2347 // 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. | 2348 // 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); | 2349 framebufferBinding->setAttachmentForBoundFramebuffer(target, GL_DEPTH_AT TACHMENT, buffer); |
2316 framebufferBinding->setAttachmentForBoundFramebuffer(target, GL_STENCIL_ ATTACHMENT, buffer); | 2350 framebufferBinding->setAttachmentForBoundFramebuffer(target, GL_STENCIL_ ATTACHMENT, buffer); |
2317 } else { | 2351 } else { |
2318 framebufferBinding->setAttachmentForBoundFramebuffer(target, attachment, buffer); | 2352 framebufferBinding->setAttachmentForBoundFramebuffer(target, attachment, buffer); |
2319 } | 2353 } |
2320 applyStencilTest(); | 2354 applyStencilTest(); |
2355 preserveObjectWrapper(scriptState, framebufferBinding, "renderbuffer", attac hment, buffer); | |
2321 } | 2356 } |
2322 | 2357 |
2323 void WebGLRenderingContextBase::framebufferTexture2D(GLenum target, GLenum attac hment, GLenum textarget, WebGLTexture* texture, GLint level) | 2358 void WebGLRenderingContextBase::framebufferTexture2D(ScriptState* scriptState, G Lenum target, GLenum attachment, GLenum textarget, WebGLTexture* texture, GLint level) |
2324 { | 2359 { |
2325 if (isContextLost() || !validateFramebufferFuncParameters("framebufferTextur e2D", target, attachment)) | 2360 if (isContextLost() || !validateFramebufferFuncParameters("framebufferTextur e2D", target, attachment)) |
2326 return; | 2361 return; |
2327 if (isWebGL2OrHigher()) { | 2362 if (isWebGL2OrHigher()) { |
2328 if (!validateTexFuncLevel("framebufferTexture2D", textarget, level)) | 2363 if (!validateTexFuncLevel("framebufferTexture2D", textarget, level)) |
2329 return; | 2364 return; |
2330 } else if (level) { | 2365 } else if (level) { |
2331 synthesizeGLError(GL_INVALID_VALUE, "framebufferTexture2D", "level not 0 "); | 2366 synthesizeGLError(GL_INVALID_VALUE, "framebufferTexture2D", "level not 0 "); |
2332 return; | 2367 return; |
2333 } | 2368 } |
(...skipping 19 matching lines...) Expand all Loading... | |
2353 webContext()->framebufferTexture2D(target, attachment, textarget, textur eObject, level); | 2388 webContext()->framebufferTexture2D(target, attachment, textarget, textur eObject, level); |
2354 break; | 2389 break; |
2355 case GL_STENCIL_ATTACHMENT: | 2390 case GL_STENCIL_ATTACHMENT: |
2356 webContext()->framebufferTexture2D(target, attachment, textarget, textur eObject, level); | 2391 webContext()->framebufferTexture2D(target, attachment, textarget, textur eObject, level); |
2357 break; | 2392 break; |
2358 default: | 2393 default: |
2359 webContext()->framebufferTexture2D(target, attachment, textarget, textur eObject, level); | 2394 webContext()->framebufferTexture2D(target, attachment, textarget, textur eObject, level); |
2360 } | 2395 } |
2361 framebufferBinding->setAttachmentForBoundFramebuffer(target, attachment, tex target, texture, level); | 2396 framebufferBinding->setAttachmentForBoundFramebuffer(target, attachment, tex target, texture, level); |
2362 applyStencilTest(); | 2397 applyStencilTest(); |
2398 preserveObjectWrapper(scriptState, framebufferBinding, "texture2d", attachme nt, texture); | |
2363 } | 2399 } |
2364 | 2400 |
2365 void WebGLRenderingContextBase::frontFace(GLenum mode) | 2401 void WebGLRenderingContextBase::frontFace(GLenum mode) |
2366 { | 2402 { |
2367 if (isContextLost()) | 2403 if (isContextLost()) |
2368 return; | 2404 return; |
2369 switch (mode) { | 2405 switch (mode) { |
2370 case GL_CW: | 2406 case GL_CW: |
2371 case GL_CCW: | 2407 case GL_CCW: |
2372 break; | 2408 break; |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2557 if (tracker->draft() && !RuntimeEnabledFeatures::webGLDraftExtensionsEnabled ()) | 2593 if (tracker->draft() && !RuntimeEnabledFeatures::webGLDraftExtensionsEnabled ()) |
2558 return false; | 2594 return false; |
2559 if (!tracker->supported(this)) | 2595 if (!tracker->supported(this)) |
2560 return false; | 2596 return false; |
2561 return true; | 2597 return true; |
2562 } | 2598 } |
2563 | 2599 |
2564 ScriptValue WebGLRenderingContextBase::getExtension(ScriptState* scriptState, co nst String& name) | 2600 ScriptValue WebGLRenderingContextBase::getExtension(ScriptState* scriptState, co nst String& name) |
2565 { | 2601 { |
2566 WebGLExtension* extension = nullptr; | 2602 WebGLExtension* extension = nullptr; |
2603 bool linkContextToExtension = false; | |
2567 | 2604 |
2568 if (!isContextLost()) { | 2605 if (!isContextLost()) { |
2569 for (size_t i = 0; i < m_extensions.size(); ++i) { | 2606 for (size_t i = 0; i < m_extensions.size(); ++i) { |
2570 ExtensionTracker* tracker = m_extensions[i]; | 2607 ExtensionTracker* tracker = m_extensions[i]; |
2571 if (tracker->matchesNameWithPrefixes(name)) { | 2608 if (tracker->matchesNameWithPrefixes(name)) { |
2572 if (extensionSupportedAndAllowed(tracker)) { | 2609 if (extensionSupportedAndAllowed(tracker)) { |
2573 extension = tracker->getExtension(this); | 2610 extension = tracker->getExtension(this); |
2574 if (extension) | 2611 if (extension) { |
2575 m_extensionEnabled[extension->name()] = true; | 2612 if (!m_extensionEnabled[extension->name()]) { |
2613 linkContextToExtension = true; | |
2614 m_extensionEnabled[extension->name()] = true; | |
2615 } | |
2616 } | |
2576 } | 2617 } |
2577 break; | 2618 break; |
2578 } | 2619 } |
2579 } | 2620 } |
2580 } | 2621 } |
2581 | 2622 |
2582 return ScriptValue(scriptState, toV8(extension, scriptState->context()->Glob al(), scriptState->isolate())); | 2623 v8::Local<v8::Value> wrappedExtension = toV8(extension, scriptState->context ()->Global(), scriptState->isolate()); |
haraken
2015/10/13 02:02:04
toV8 does ScriptState-dependent operations, so we
Ken Russell (switch to Gerrit)
2015/10/13 06:11:44
This function is always called from JavaScript, so
| |
2624 | |
2625 if (linkContextToExtension) { | |
2626 // Keep the extension's JavaScript wrapper alive as long as the context is alive, so that | |
2627 // expando properties that are added to the extension persist. | |
2628 preserveObjectWrapper(scriptState, this, "extension", static_cast<unsign ed long>(extension->name()), extension); | |
2629 } | |
2630 | |
2631 return ScriptValue(scriptState, wrappedExtension); | |
2583 } | 2632 } |
2584 | 2633 |
2585 ScriptValue WebGLRenderingContextBase::getFramebufferAttachmentParameter(ScriptS tate* scriptState, GLenum target, GLenum attachment, GLenum pname) | 2634 ScriptValue WebGLRenderingContextBase::getFramebufferAttachmentParameter(ScriptS tate* scriptState, GLenum target, GLenum attachment, GLenum pname) |
2586 { | 2635 { |
2587 if (isContextLost() || !validateFramebufferFuncParameters("getFramebufferAtt achmentParameter", target, attachment)) | 2636 if (isContextLost() || !validateFramebufferFuncParameters("getFramebufferAtt achmentParameter", target, attachment)) |
2588 return ScriptValue::createNull(scriptState); | 2637 return ScriptValue::createNull(scriptState); |
2589 | 2638 |
2590 if (!m_framebufferBinding || !m_framebufferBinding->object()) { | 2639 if (!m_framebufferBinding || !m_framebufferBinding->object()) { |
2591 synthesizeGLError(GL_INVALID_OPERATION, "getFramebufferAttachmentParamet er", "no framebuffer bound"); | 2640 synthesizeGLError(GL_INVALID_OPERATION, "getFramebufferAttachmentParamet er", "no framebuffer bound"); |
2592 return ScriptValue::createNull(scriptState); | 2641 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()); | 4899 webContext()->uniformMatrix4fv(location->location(), v->length() >> 4, trans pose, v->data()); |
4851 } | 4900 } |
4852 | 4901 |
4853 void WebGLRenderingContextBase::uniformMatrix4fv(const WebGLUniformLocation* loc ation, GLboolean transpose, Vector<GLfloat>& v) | 4902 void WebGLRenderingContextBase::uniformMatrix4fv(const WebGLUniformLocation* loc ation, GLboolean transpose, Vector<GLfloat>& v) |
4854 { | 4903 { |
4855 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix4fv", location, transpose, v.data(), v.size(), 16)) | 4904 if (isContextLost() || !validateUniformMatrixParameters("uniformMatrix4fv", location, transpose, v.data(), v.size(), 16)) |
4856 return; | 4905 return; |
4857 webContext()->uniformMatrix4fv(location->location(), v.size() >> 4, transpos e, v.data()); | 4906 webContext()->uniformMatrix4fv(location->location(), v.size() >> 4, transpos e, v.data()); |
4858 } | 4907 } |
4859 | 4908 |
4860 void WebGLRenderingContextBase::useProgram(WebGLProgram* program) | 4909 void WebGLRenderingContextBase::useProgram(ScriptState* scriptState, WebGLProgra m* program) |
4861 { | 4910 { |
4862 bool deleted; | 4911 bool deleted; |
4863 if (!checkObjectToBeBound("useProgram", program, deleted)) | 4912 if (!checkObjectToBeBound("useProgram", program, deleted)) |
4864 return; | 4913 return; |
4865 if (deleted) | 4914 if (deleted) |
4866 program = 0; | 4915 program = 0; |
4867 if (program && !program->linkStatus()) { | 4916 if (program && !program->linkStatus()) { |
4868 synthesizeGLError(GL_INVALID_OPERATION, "useProgram", "program not valid "); | 4917 synthesizeGLError(GL_INVALID_OPERATION, "useProgram", "program not valid "); |
4869 return; | 4918 return; |
4870 } | 4919 } |
4871 if (m_currentProgram != program) { | 4920 if (m_currentProgram != program) { |
4872 if (m_currentProgram) | 4921 if (m_currentProgram) |
4873 m_currentProgram->onDetached(webContext()); | 4922 m_currentProgram->onDetached(webContext()); |
4874 m_currentProgram = program; | 4923 m_currentProgram = program; |
4875 webContext()->useProgram(objectOrZero(program)); | 4924 webContext()->useProgram(objectOrZero(program)); |
4876 if (program) | 4925 if (program) |
4877 program->onAttached(); | 4926 program->onAttached(); |
4927 preserveObjectWrapper(scriptState, this, "program", 0, program); | |
4878 } | 4928 } |
4879 } | 4929 } |
4880 | 4930 |
4881 void WebGLRenderingContextBase::validateProgram(WebGLProgram* program) | 4931 void WebGLRenderingContextBase::validateProgram(WebGLProgram* program) |
4882 { | 4932 { |
4883 if (isContextLost() || !validateWebGLObject("validateProgram", program)) | 4933 if (isContextLost() || !validateWebGLObject("validateProgram", program)) |
4884 return; | 4934 return; |
4885 webContext()->validateProgram(objectOrZero(program)); | 4935 webContext()->validateProgram(objectOrZero(program)); |
4886 } | 4936 } |
4887 | 4937 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4938 void WebGLRenderingContextBase::vertexAttrib4fv(GLuint index, const DOMFloat32Ar ray* v) | 4988 void WebGLRenderingContextBase::vertexAttrib4fv(GLuint index, const DOMFloat32Ar ray* v) |
4939 { | 4989 { |
4940 vertexAttribfvImpl("vertexAttrib4fv", index, v, 4); | 4990 vertexAttribfvImpl("vertexAttrib4fv", index, v, 4); |
4941 } | 4991 } |
4942 | 4992 |
4943 void WebGLRenderingContextBase::vertexAttrib4fv(GLuint index, const Vector<GLflo at>& v) | 4993 void WebGLRenderingContextBase::vertexAttrib4fv(GLuint index, const Vector<GLflo at>& v) |
4944 { | 4994 { |
4945 vertexAttribfvImpl("vertexAttrib4fv", index, v.data(), v.size(), 4); | 4995 vertexAttribfvImpl("vertexAttrib4fv", index, v.data(), v.size(), 4); |
4946 } | 4996 } |
4947 | 4997 |
4948 void WebGLRenderingContextBase::vertexAttribPointer(GLuint index, GLint size, GL enum type, GLboolean normalized, GLsizei stride, long long offset) | 4998 void WebGLRenderingContextBase::vertexAttribPointer(ScriptState* scriptState, GL uint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, long long offset) |
4949 { | 4999 { |
4950 if (isContextLost()) | 5000 if (isContextLost()) |
4951 return; | 5001 return; |
4952 switch (type) { | 5002 switch (type) { |
4953 case GL_BYTE: | 5003 case GL_BYTE: |
4954 case GL_UNSIGNED_BYTE: | 5004 case GL_UNSIGNED_BYTE: |
4955 case GL_SHORT: | 5005 case GL_SHORT: |
4956 case GL_UNSIGNED_SHORT: | 5006 case GL_UNSIGNED_SHORT: |
4957 case GL_FLOAT: | 5007 case GL_FLOAT: |
4958 break; | 5008 break; |
(...skipping 18 matching lines...) Expand all Loading... | |
4977 unsigned typeSize = sizeInBytes(type); | 5027 unsigned typeSize = sizeInBytes(type); |
4978 ASSERT((typeSize & (typeSize - 1)) == 0); // Ensure that the value is POT. | 5028 ASSERT((typeSize & (typeSize - 1)) == 0); // Ensure that the value is POT. |
4979 if ((stride & (typeSize - 1)) || (static_cast<GLintptr>(offset) & (typeSize - 1))) { | 5029 if ((stride & (typeSize - 1)) || (static_cast<GLintptr>(offset) & (typeSize - 1))) { |
4980 synthesizeGLError(GL_INVALID_OPERATION, "vertexAttribPointer", "stride o r offset not valid for type"); | 5030 synthesizeGLError(GL_INVALID_OPERATION, "vertexAttribPointer", "stride o r offset not valid for type"); |
4981 return; | 5031 return; |
4982 } | 5032 } |
4983 GLsizei bytesPerElement = size * typeSize; | 5033 GLsizei bytesPerElement = size * typeSize; |
4984 | 5034 |
4985 m_boundVertexArrayObject->setVertexAttribState(index, bytesPerElement, size, type, normalized, stride, static_cast<GLintptr>(offset), m_boundArrayBuffer); | 5035 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)); | 5036 webContext()->vertexAttribPointer(index, size, type, normalized, stride, sta tic_cast<GLintptr>(offset)); |
5037 preserveObjectWrapper(scriptState, m_boundVertexArrayObject, "arraybuffer", index, m_boundArrayBuffer); | |
4987 } | 5038 } |
4988 | 5039 |
4989 void WebGLRenderingContextBase::vertexAttribDivisorANGLE(GLuint index, GLuint di visor) | 5040 void WebGLRenderingContextBase::vertexAttribDivisorANGLE(GLuint index, GLuint di visor) |
4990 { | 5041 { |
4991 if (isContextLost()) | 5042 if (isContextLost()) |
4992 return; | 5043 return; |
4993 | 5044 |
4994 if (index >= m_maxVertexAttribs) { | 5045 if (index >= m_maxVertexAttribs) { |
4995 synthesizeGLError(GL_INVALID_VALUE, "vertexAttribDivisorANGLE", "index o ut of range"); | 5046 synthesizeGLError(GL_INVALID_VALUE, "vertexAttribDivisorANGLE", "index o ut of range"); |
4996 return; | 5047 return; |
(...skipping 1642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6639 if (!buffer) { | 6690 if (!buffer) { |
6640 // Instead of binding fb 0, bind the drawing buffer. | 6691 // Instead of binding fb 0, bind the drawing buffer. |
6641 drawingBuffer()->bind(target); | 6692 drawingBuffer()->bind(target); |
6642 } else { | 6693 } else { |
6643 webContext()->bindFramebuffer(target, buffer->object()); | 6694 webContext()->bindFramebuffer(target, buffer->object()); |
6644 } | 6695 } |
6645 } | 6696 } |
6646 | 6697 |
6647 void WebGLRenderingContextBase::restoreCurrentFramebuffer() | 6698 void WebGLRenderingContextBase::restoreCurrentFramebuffer() |
6648 { | 6699 { |
6649 bindFramebuffer(GL_FRAMEBUFFER, m_framebufferBinding.get()); | 6700 bindFramebuffer(nullptr, GL_FRAMEBUFFER, m_framebufferBinding.get()); |
haraken
2015/10/13 02:02:04
I'm wondering why we can't use m_scriptState.
Ken Russell (switch to Gerrit)
2015/10/13 06:11:44
There's no need to update the references between t
| |
6650 } | 6701 } |
6651 | 6702 |
6652 void WebGLRenderingContextBase::restoreCurrentTexture2D() | 6703 void WebGLRenderingContextBase::restoreCurrentTexture2D() |
6653 { | 6704 { |
6654 bindTexture(GL_TEXTURE_2D, m_textureUnits[m_activeTextureUnit].m_texture2DBi nding.get()); | 6705 bindTexture(nullptr, GL_TEXTURE_2D, m_textureUnits[m_activeTextureUnit].m_te xture2DBinding.get()); |
haraken
2015/10/13 02:02:04
Ditto.
Ken Russell (switch to Gerrit)
2015/10/13 06:11:44
Same thing for the TEXTURE_2D binding on the activ
| |
6655 } | 6706 } |
6656 | 6707 |
6657 void WebGLRenderingContextBase::multisamplingChanged(bool enabled) | 6708 void WebGLRenderingContextBase::multisamplingChanged(bool enabled) |
6658 { | 6709 { |
6659 if (m_multisamplingAllowed != enabled) { | 6710 if (m_multisamplingAllowed != enabled) { |
6660 m_multisamplingAllowed = enabled; | 6711 m_multisamplingAllowed = enabled; |
6661 forceLostContext(WebGLRenderingContextBase::SyntheticLostContext, WebGLR enderingContextBase::Auto); | 6712 forceLostContext(WebGLRenderingContextBase::SyntheticLostContext, WebGLR enderingContextBase::Auto); |
6662 } | 6713 } |
6663 } | 6714 } |
6664 | 6715 |
6665 void WebGLRenderingContextBase::findNewMaxNonDefaultTextureUnit() | 6716 void WebGLRenderingContextBase::findNewMaxNonDefaultTextureUnit() |
6666 { | 6717 { |
6667 // Trace backwards from the current max to find the new max non-default text ure unit | 6718 // Trace backwards from the current max to find the new max non-default text ure unit |
6668 int startIndex = m_onePlusMaxNonDefaultTextureUnit - 1; | 6719 int startIndex = m_onePlusMaxNonDefaultTextureUnit - 1; |
6669 for (int i = startIndex; i >= 0; --i) { | 6720 for (int i = startIndex; i >= 0; --i) { |
6670 if (m_textureUnits[i].m_texture2DBinding | 6721 if (m_textureUnits[i].m_texture2DBinding |
6671 || m_textureUnits[i].m_textureCubeMapBinding) { | 6722 || m_textureUnits[i].m_textureCubeMapBinding) { |
6672 m_onePlusMaxNonDefaultTextureUnit = i + 1; | 6723 m_onePlusMaxNonDefaultTextureUnit = i + 1; |
6673 return; | 6724 return; |
6674 } | 6725 } |
6675 } | 6726 } |
6676 m_onePlusMaxNonDefaultTextureUnit = 0; | 6727 m_onePlusMaxNonDefaultTextureUnit = 0; |
6677 } | 6728 } |
6678 | 6729 |
6730 void WebGLRenderingContextBase::preserveObjectWrapper(ScriptState* scriptState, ScriptWrappable* sourceObject, const char* baseName, unsigned long index, Script Wrappable* targetObject) | |
haraken
2015/10/13 02:02:04
Actually preserveObjectWrapper doesn't need to tak
Ken Russell (switch to Gerrit)
2015/10/13 06:11:43
Thanks for that hint. I'll change its signature.
| |
6731 { | |
6732 v8::Local<v8::Value> value; | |
6733 | |
6734 StringBuilder builder; | |
haraken
2015/10/13 02:02:04
Add a TODO: This logic should be moved to V8Hidden
Ken Russell (switch to Gerrit)
2015/10/13 06:11:44
OK.
| |
6735 builder.append(baseName); | |
6736 builder.appendNumber(static_cast<unsigned>(index)); | |
6737 CString name = builder.toString().utf8(); | |
6738 v8::Local<v8::String> jsName = v8::String::NewFromUtf8( | |
6739 scriptState->isolate(), | |
6740 name.data(), | |
6741 v8::NewStringType::kNormal, | |
6742 name.length()).ToLocalChecked(); | |
6743 if (targetObject) { | |
6744 V8HiddenValue::setHiddenValue( | |
6745 scriptState->isolate(), | |
6746 sourceObject->newLocalWrapper(scriptState->isolate()), | |
6747 jsName, | |
6748 targetObject->newLocalWrapper(scriptState->isolate())); | |
6749 } else { | |
6750 V8HiddenValue::deleteHiddenValue( | |
6751 scriptState->isolate(), | |
6752 sourceObject->newLocalWrapper(scriptState->isolate()), | |
6753 jsName); | |
6754 } | |
6755 } | |
6756 | |
6679 DEFINE_TRACE(WebGLRenderingContextBase::TextureUnitState) | 6757 DEFINE_TRACE(WebGLRenderingContextBase::TextureUnitState) |
6680 { | 6758 { |
6681 visitor->trace(m_texture2DBinding); | 6759 visitor->trace(m_texture2DBinding); |
6682 visitor->trace(m_textureCubeMapBinding); | 6760 visitor->trace(m_textureCubeMapBinding); |
6683 visitor->trace(m_texture3DBinding); | 6761 visitor->trace(m_texture3DBinding); |
6684 visitor->trace(m_texture2DArrayBinding); | 6762 visitor->trace(m_texture2DArrayBinding); |
6685 } | 6763 } |
6686 | 6764 |
6687 DEFINE_TRACE(WebGLRenderingContextBase) | 6765 DEFINE_TRACE(WebGLRenderingContextBase) |
6688 { | 6766 { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6731 | 6809 |
6732 return totalBytesPerPixel; | 6810 return totalBytesPerPixel; |
6733 } | 6811 } |
6734 | 6812 |
6735 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const | 6813 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const |
6736 { | 6814 { |
6737 return m_drawingBuffer.get(); | 6815 return m_drawingBuffer.get(); |
6738 } | 6816 } |
6739 | 6817 |
6740 } // namespace blink | 6818 } // namespace blink |
OLD | NEW |