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 |
11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
12 * | 12 * |
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "modules/webgl/WebGLRenderingContextBase.h" | 26 #include "modules/webgl/WebGLRenderingContextBase.h" |
27 | 27 |
28 #include "bindings/core/v8/ExceptionMessages.h" | 28 #include "bindings/core/v8/ExceptionMessages.h" |
29 #include "bindings/core/v8/ExceptionState.h" | 29 #include "bindings/core/v8/ExceptionState.h" |
| 30 #include "bindings/core/v8/ScriptWrappableVisitor.h" |
30 #include "bindings/core/v8/V8BindingMacros.h" | 31 #include "bindings/core/v8/V8BindingMacros.h" |
31 #include "bindings/modules/v8/HTMLCanvasElementOrOffscreenCanvas.h" | 32 #include "bindings/modules/v8/HTMLCanvasElementOrOffscreenCanvas.h" |
32 #include "bindings/modules/v8/WebGLAny.h" | 33 #include "bindings/modules/v8/WebGLAny.h" |
33 #include "core/dom/DOMArrayBuffer.h" | 34 #include "core/dom/DOMArrayBuffer.h" |
34 #include "core/dom/DOMTypedArray.h" | 35 #include "core/dom/DOMTypedArray.h" |
35 #include "core/dom/FlexibleArrayBufferView.h" | 36 #include "core/dom/FlexibleArrayBufferView.h" |
36 #include "core/fetch/ImageResource.h" | 37 #include "core/fetch/ImageResource.h" |
37 #include "core/frame/ImageBitmap.h" | 38 #include "core/frame/ImageBitmap.h" |
38 #include "core/frame/LocalFrame.h" | 39 #include "core/frame/LocalFrame.h" |
39 #include "core/frame/Settings.h" | 40 #include "core/frame/Settings.h" |
(...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
972 passedOffscreenCanvas, | 973 passedOffscreenCanvas, |
973 requestedAttributes), | 974 requestedAttributes), |
974 m_isHidden(false), | 975 m_isHidden(false), |
975 m_contextLostMode(NotLostContext), | 976 m_contextLostMode(NotLostContext), |
976 m_autoRecoveryMethod(Manual), | 977 m_autoRecoveryMethod(Manual), |
977 m_dispatchContextLostEventTimer( | 978 m_dispatchContextLostEventTimer( |
978 this, | 979 this, |
979 &WebGLRenderingContextBase::dispatchContextLostEvent), | 980 &WebGLRenderingContextBase::dispatchContextLostEvent), |
980 m_restoreAllowed(false), | 981 m_restoreAllowed(false), |
981 m_restoreTimer(this, &WebGLRenderingContextBase::maybeRestoreContext), | 982 m_restoreTimer(this, &WebGLRenderingContextBase::maybeRestoreContext), |
| 983 m_boundArrayBuffer(this, nullptr), |
| 984 m_boundVertexArrayObject(this, nullptr), |
| 985 m_currentProgram(this, nullptr), |
| 986 m_framebufferBinding(this, nullptr), |
| 987 m_renderbufferBinding(this, nullptr), |
982 m_generatedImageCache(4), | 988 m_generatedImageCache(4), |
983 m_synthesizedErrorsToConsole(true), | 989 m_synthesizedErrorsToConsole(true), |
984 m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole), | 990 m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole), |
985 m_onePlusMaxNonDefaultTextureUnit(0), | 991 m_onePlusMaxNonDefaultTextureUnit(0), |
986 m_isWebGL2FormatsTypesAdded(false), | 992 m_isWebGL2FormatsTypesAdded(false), |
987 m_isWebGL2TexImageSourceFormatsTypesAdded(false), | 993 m_isWebGL2TexImageSourceFormatsTypesAdded(false), |
988 m_isWebGL2InternalFormatsCopyTexImageAdded(false), | 994 m_isWebGL2InternalFormatsCopyTexImageAdded(false), |
989 m_isOESTextureFloatFormatsTypesAdded(false), | 995 m_isOESTextureFloatFormatsTypesAdded(false), |
990 m_isOESTextureHalfFloatFormatsTypesAdded(false), | 996 m_isOESTextureHalfFloatFormatsTypesAdded(false), |
991 m_isWebGLDepthTextureFormatsTypesAdded(false), | 997 m_isWebGLDepthTextureFormatsTypesAdded(false), |
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1748 "attempt to bind a deleted texture"); | 1754 "attempt to bind a deleted texture"); |
1749 return; | 1755 return; |
1750 } | 1756 } |
1751 if (texture && texture->getTarget() && texture->getTarget() != target) { | 1757 if (texture && texture->getTarget() && texture->getTarget() != target) { |
1752 synthesizeGLError(GL_INVALID_OPERATION, "bindTexture", | 1758 synthesizeGLError(GL_INVALID_OPERATION, "bindTexture", |
1753 "textures can not be used with multiple targets"); | 1759 "textures can not be used with multiple targets"); |
1754 return; | 1760 return; |
1755 } | 1761 } |
1756 | 1762 |
1757 if (target == GL_TEXTURE_2D) { | 1763 if (target == GL_TEXTURE_2D) { |
1758 m_textureUnits[m_activeTextureUnit].m_texture2DBinding = texture; | 1764 m_textureUnits[m_activeTextureUnit].m_texture2DBinding = |
| 1765 TraceWrapperMember<WebGLTexture>(this, texture); |
1759 | 1766 |
1760 if (!m_activeTextureUnit) | 1767 if (!m_activeTextureUnit) |
1761 drawingBuffer()->setTexture2DBinding(objectOrZero(texture)); | 1768 drawingBuffer()->setTexture2DBinding(objectOrZero(texture)); |
1762 } else if (target == GL_TEXTURE_CUBE_MAP) { | 1769 } else if (target == GL_TEXTURE_CUBE_MAP) { |
1763 m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding = texture; | 1770 m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding = |
| 1771 TraceWrapperMember<WebGLTexture>(this, texture); |
1764 } else if (isWebGL2OrHigher() && target == GL_TEXTURE_2D_ARRAY) { | 1772 } else if (isWebGL2OrHigher() && target == GL_TEXTURE_2D_ARRAY) { |
1765 m_textureUnits[m_activeTextureUnit].m_texture2DArrayBinding = texture; | 1773 m_textureUnits[m_activeTextureUnit].m_texture2DArrayBinding = |
| 1774 TraceWrapperMember<WebGLTexture>(this, texture); |
1766 } else if (isWebGL2OrHigher() && target == GL_TEXTURE_3D) { | 1775 } else if (isWebGL2OrHigher() && target == GL_TEXTURE_3D) { |
1767 m_textureUnits[m_activeTextureUnit].m_texture3DBinding = texture; | 1776 m_textureUnits[m_activeTextureUnit].m_texture3DBinding = |
| 1777 TraceWrapperMember<WebGLTexture>(this, texture); |
1768 } else { | 1778 } else { |
1769 synthesizeGLError(GL_INVALID_ENUM, "bindTexture", "invalid target"); | 1779 synthesizeGLError(GL_INVALID_ENUM, "bindTexture", "invalid target"); |
1770 return; | 1780 return; |
1771 } | 1781 } |
1772 | 1782 |
1773 contextGL()->BindTexture(target, objectOrZero(texture)); | 1783 contextGL()->BindTexture(target, objectOrZero(texture)); |
1774 if (texture) { | 1784 if (texture) { |
1775 texture->setTarget(target); | 1785 texture->setTarget(target); |
1776 m_onePlusMaxNonDefaultTextureUnit = | 1786 m_onePlusMaxNonDefaultTextureUnit = |
1777 max(m_activeTextureUnit + 1, m_onePlusMaxNonDefaultTextureUnit); | 1787 max(m_activeTextureUnit + 1, m_onePlusMaxNonDefaultTextureUnit); |
(...skipping 5666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7444 m_onePlusMaxNonDefaultTextureUnit = 0; | 7454 m_onePlusMaxNonDefaultTextureUnit = 0; |
7445 } | 7455 } |
7446 | 7456 |
7447 DEFINE_TRACE(WebGLRenderingContextBase::TextureUnitState) { | 7457 DEFINE_TRACE(WebGLRenderingContextBase::TextureUnitState) { |
7448 visitor->trace(m_texture2DBinding); | 7458 visitor->trace(m_texture2DBinding); |
7449 visitor->trace(m_textureCubeMapBinding); | 7459 visitor->trace(m_textureCubeMapBinding); |
7450 visitor->trace(m_texture3DBinding); | 7460 visitor->trace(m_texture3DBinding); |
7451 visitor->trace(m_texture2DArrayBinding); | 7461 visitor->trace(m_texture2DArrayBinding); |
7452 } | 7462 } |
7453 | 7463 |
| 7464 DEFINE_TRACE_WRAPPERS(WebGLRenderingContextBase::TextureUnitState) { |
| 7465 visitor->traceWrappers(m_texture2DBinding); |
| 7466 visitor->traceWrappers(m_textureCubeMapBinding); |
| 7467 visitor->traceWrappers(m_texture3DBinding); |
| 7468 visitor->traceWrappers(m_texture2DArrayBinding); |
| 7469 } |
| 7470 |
7454 DEFINE_TRACE(WebGLRenderingContextBase) { | 7471 DEFINE_TRACE(WebGLRenderingContextBase) { |
7455 visitor->trace(m_contextObjects); | 7472 visitor->trace(m_contextObjects); |
7456 visitor->trace(m_boundArrayBuffer); | 7473 visitor->trace(m_boundArrayBuffer); |
7457 visitor->trace(m_defaultVertexArrayObject); | 7474 visitor->trace(m_defaultVertexArrayObject); |
7458 visitor->trace(m_boundVertexArrayObject); | 7475 visitor->trace(m_boundVertexArrayObject); |
7459 visitor->trace(m_currentProgram); | 7476 visitor->trace(m_currentProgram); |
7460 visitor->trace(m_framebufferBinding); | 7477 visitor->trace(m_framebufferBinding); |
7461 visitor->trace(m_renderbufferBinding); | 7478 visitor->trace(m_renderbufferBinding); |
7462 visitor->trace(m_textureUnits); | 7479 visitor->trace(m_textureUnits); |
7463 visitor->trace(m_extensions); | 7480 visitor->trace(m_extensions); |
7464 CanvasRenderingContext::trace(visitor); | 7481 CanvasRenderingContext::trace(visitor); |
7465 } | 7482 } |
7466 | 7483 |
7467 DEFINE_TRACE_WRAPPERS(WebGLRenderingContextBase) { | 7484 DEFINE_TRACE_WRAPPERS(WebGLRenderingContextBase) { |
7468 if (isContextLost()) { | 7485 if (isContextLost()) { |
7469 return; | 7486 return; |
7470 } | 7487 } |
7471 visitor->traceWrappers(m_boundArrayBuffer); | 7488 visitor->traceWrappers(m_boundArrayBuffer); |
7472 visitor->traceWrappers(m_renderbufferBinding); | 7489 visitor->traceWrappers(m_renderbufferBinding); |
7473 visitor->traceWrappers(m_framebufferBinding); | 7490 visitor->traceWrappers(m_framebufferBinding); |
7474 visitor->traceWrappers(m_currentProgram); | 7491 visitor->traceWrappers(m_currentProgram); |
7475 visitor->traceWrappers(m_boundVertexArrayObject); | 7492 visitor->traceWrappers(m_boundVertexArrayObject); |
7476 for (auto& unit : m_textureUnits) { | 7493 for (auto& unit : m_textureUnits) { |
7477 visitor->traceWrappers(unit.m_texture2DBinding); | 7494 visitor->traceWrappers(&unit); |
7478 visitor->traceWrappers(unit.m_textureCubeMapBinding); | |
7479 visitor->traceWrappers(unit.m_texture3DBinding); | |
7480 visitor->traceWrappers(unit.m_texture2DArrayBinding); | |
7481 } | 7495 } |
7482 for (ExtensionTracker* tracker : m_extensions) { | 7496 for (ExtensionTracker* tracker : m_extensions) { |
7483 WebGLExtension* extension = tracker->getExtensionObjectIfAlreadyEnabled(); | 7497 WebGLExtension* extension = tracker->getExtensionObjectIfAlreadyEnabled(); |
7484 visitor->traceWrappers(extension); | 7498 visitor->traceWrappers(extension); |
7485 } | 7499 } |
7486 CanvasRenderingContext::traceWrappers(visitor); | 7500 CanvasRenderingContext::traceWrappers(visitor); |
7487 } | 7501 } |
7488 | 7502 |
7489 int WebGLRenderingContextBase::externallyAllocatedBytesPerPixel() { | 7503 int WebGLRenderingContextBase::externallyAllocatedBytesPerPixel() { |
7490 if (isContextLost()) | 7504 if (isContextLost()) |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7531 | 7545 |
7532 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( | 7546 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( |
7533 HTMLCanvasElementOrOffscreenCanvas& result) const { | 7547 HTMLCanvasElementOrOffscreenCanvas& result) const { |
7534 if (canvas()) | 7548 if (canvas()) |
7535 result.setHTMLCanvasElement(canvas()); | 7549 result.setHTMLCanvasElement(canvas()); |
7536 else | 7550 else |
7537 result.setOffscreenCanvas(getOffscreenCanvas()); | 7551 result.setOffscreenCanvas(getOffscreenCanvas()); |
7538 } | 7552 } |
7539 | 7553 |
7540 } // namespace blink | 7554 } // namespace blink |
OLD | NEW |