| 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 954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 return false; | 965 return false; |
| 966 } | 966 } |
| 967 } | 967 } |
| 968 | 968 |
| 969 } // namespace | 969 } // namespace |
| 970 | 970 |
| 971 WebGLRenderingContextBase::WebGLRenderingContextBase( | 971 WebGLRenderingContextBase::WebGLRenderingContextBase( |
| 972 OffscreenCanvas* passedOffscreenCanvas, | 972 OffscreenCanvas* passedOffscreenCanvas, |
| 973 std::unique_ptr<WebGraphicsContext3DProvider> contextProvider, | 973 std::unique_ptr<WebGraphicsContext3DProvider> contextProvider, |
| 974 const CanvasContextCreationAttributes& requestedAttributes, | 974 const CanvasContextCreationAttributes& requestedAttributes, |
| 975 ExecutionContext* executionContext, |
| 975 unsigned version) | 976 unsigned version) |
| 976 : WebGLRenderingContextBase(nullptr, | 977 : WebGLRenderingContextBase(nullptr, |
| 977 passedOffscreenCanvas, | 978 passedOffscreenCanvas, |
| 978 std::move(contextProvider), | 979 std::move(contextProvider), |
| 979 requestedAttributes, | 980 requestedAttributes, |
| 981 executionContext, |
| 980 version) {} | 982 version) {} |
| 981 | 983 |
| 982 WebGLRenderingContextBase::WebGLRenderingContextBase( | 984 WebGLRenderingContextBase::WebGLRenderingContextBase( |
| 983 HTMLCanvasElement* passedCanvas, | 985 HTMLCanvasElement* passedCanvas, |
| 984 std::unique_ptr<WebGraphicsContext3DProvider> contextProvider, | 986 std::unique_ptr<WebGraphicsContext3DProvider> contextProvider, |
| 985 const CanvasContextCreationAttributes& requestedAttributes, | 987 const CanvasContextCreationAttributes& requestedAttributes, |
| 986 unsigned version) | 988 unsigned version) |
| 987 : WebGLRenderingContextBase(passedCanvas, | 989 : WebGLRenderingContextBase(passedCanvas, |
| 988 nullptr, | 990 nullptr, |
| 989 std::move(contextProvider), | 991 std::move(contextProvider), |
| 990 requestedAttributes, | 992 requestedAttributes, |
| 993 nullptr, |
| 991 version) {} | 994 version) {} |
| 992 | 995 |
| 993 WebGLRenderingContextBase::WebGLRenderingContextBase( | 996 WebGLRenderingContextBase::WebGLRenderingContextBase( |
| 994 HTMLCanvasElement* passedCanvas, | 997 HTMLCanvasElement* passedCanvas, |
| 995 OffscreenCanvas* passedOffscreenCanvas, | 998 OffscreenCanvas* passedOffscreenCanvas, |
| 996 std::unique_ptr<WebGraphicsContext3DProvider> contextProvider, | 999 std::unique_ptr<WebGraphicsContext3DProvider> contextProvider, |
| 997 const CanvasContextCreationAttributes& requestedAttributes, | 1000 const CanvasContextCreationAttributes& requestedAttributes, |
| 1001 ExecutionContext* executionContext, |
| 998 unsigned version) | 1002 unsigned version) |
| 999 : CanvasRenderingContext(passedCanvas, | 1003 : CanvasRenderingContext(passedCanvas, |
| 1000 passedOffscreenCanvas, | 1004 passedOffscreenCanvas, |
| 1001 requestedAttributes), | 1005 requestedAttributes), |
| 1002 m_isHidden(false), | 1006 m_isHidden(false), |
| 1003 m_contextLostMode(NotLostContext), | 1007 m_contextLostMode(NotLostContext), |
| 1004 m_autoRecoveryMethod(Manual), | 1008 m_autoRecoveryMethod(Manual), |
| 1005 m_dispatchContextLostEventTimer( | 1009 m_dispatchContextLostEventTimer( |
| 1006 this, | 1010 this, |
| 1007 &WebGLRenderingContextBase::dispatchContextLostEvent), | 1011 &WebGLRenderingContextBase::dispatchContextLostEvent), |
| 1008 m_restoreAllowed(false), | 1012 m_restoreAllowed(false), |
| 1009 m_restoreTimer(this, &WebGLRenderingContextBase::maybeRestoreContext), | 1013 m_restoreTimer(this, &WebGLRenderingContextBase::maybeRestoreContext), |
| 1010 m_boundArrayBuffer(this, nullptr), | 1014 m_boundArrayBuffer(this, nullptr), |
| 1011 m_boundVertexArrayObject(this, nullptr), | 1015 m_boundVertexArrayObject(this, nullptr), |
| 1012 m_currentProgram(this, nullptr), | 1016 m_currentProgram(this, nullptr), |
| 1013 m_framebufferBinding(this, nullptr), | 1017 m_framebufferBinding(this, nullptr), |
| 1014 m_renderbufferBinding(this, nullptr), | 1018 m_renderbufferBinding(this, nullptr), |
| 1015 m_generatedImageCache(4), | 1019 m_generatedImageCache(4), |
| 1016 m_synthesizedErrorsToConsole(true), | 1020 m_synthesizedErrorsToConsole(true), |
| 1017 m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole), | 1021 m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole), |
| 1018 m_onePlusMaxNonDefaultTextureUnit(0), | 1022 m_onePlusMaxNonDefaultTextureUnit(0), |
| 1019 m_isWebGL2FormatsTypesAdded(false), | 1023 m_isWebGL2FormatsTypesAdded(false), |
| 1020 m_isWebGL2TexImageSourceFormatsTypesAdded(false), | 1024 m_isWebGL2TexImageSourceFormatsTypesAdded(false), |
| 1021 m_isWebGL2InternalFormatsCopyTexImageAdded(false), | 1025 m_isWebGL2InternalFormatsCopyTexImageAdded(false), |
| 1022 m_isOESTextureFloatFormatsTypesAdded(false), | 1026 m_isOESTextureFloatFormatsTypesAdded(false), |
| 1023 m_isOESTextureHalfFloatFormatsTypesAdded(false), | 1027 m_isOESTextureHalfFloatFormatsTypesAdded(false), |
| 1024 m_isWebGLDepthTextureFormatsTypesAdded(false), | 1028 m_isWebGLDepthTextureFormatsTypesAdded(false), |
| 1025 m_isEXTsRGBFormatsTypesAdded(false), | 1029 m_isEXTsRGBFormatsTypesAdded(false), |
| 1026 m_version(version) { | 1030 m_version(version), |
| 1031 m_executionContext(executionContext) { |
| 1027 ASSERT(contextProvider); | 1032 ASSERT(contextProvider); |
| 1028 | 1033 |
| 1029 m_contextGroup = WebGLContextGroup::create(); | 1034 m_contextGroup = WebGLContextGroup::create(); |
| 1030 m_contextGroup->addContext(this); | 1035 m_contextGroup->addContext(this); |
| 1031 | 1036 |
| 1032 m_maxViewportDims[0] = m_maxViewportDims[1] = 0; | 1037 m_maxViewportDims[0] = m_maxViewportDims[1] = 0; |
| 1033 contextProvider->contextGL()->GetIntegerv(GL_MAX_VIEWPORT_DIMS, | 1038 contextProvider->contextGL()->GetIntegerv(GL_MAX_VIEWPORT_DIMS, |
| 1034 m_maxViewportDims); | 1039 m_maxViewportDims); |
| 1035 | 1040 |
| 1036 RefPtr<DrawingBuffer> buffer; | 1041 RefPtr<DrawingBuffer> buffer; |
| (...skipping 6253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7290 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, functionName, reason); | 7295 synthesizeGLError(GL_INVALID_FRAMEBUFFER_OPERATION, functionName, reason); |
| 7291 return false; | 7296 return false; |
| 7292 } | 7297 } |
| 7293 | 7298 |
| 7294 return true; | 7299 return true; |
| 7295 } | 7300 } |
| 7296 | 7301 |
| 7297 void WebGLRenderingContextBase::dispatchContextLostEvent(TimerBase*) { | 7302 void WebGLRenderingContextBase::dispatchContextLostEvent(TimerBase*) { |
| 7298 WebGLContextEvent* event = WebGLContextEvent::create( | 7303 WebGLContextEvent* event = WebGLContextEvent::create( |
| 7299 EventTypeNames::webglcontextlost, false, true, ""); | 7304 EventTypeNames::webglcontextlost, false, true, ""); |
| 7300 canvas()->dispatchEvent(event); | 7305 if (getOffscreenCanvas()) |
| 7306 getOffscreenCanvas()->dispatchEvent(event); |
| 7307 else |
| 7308 canvas()->dispatchEvent(event); |
| 7301 m_restoreAllowed = event->defaultPrevented(); | 7309 m_restoreAllowed = event->defaultPrevented(); |
| 7302 if (m_restoreAllowed && !m_isHidden) { | 7310 if (m_restoreAllowed && !m_isHidden) { |
| 7303 if (m_autoRecoveryMethod == Auto) | 7311 if (m_autoRecoveryMethod == Auto) |
| 7304 m_restoreTimer.startOneShot(0, BLINK_FROM_HERE); | 7312 m_restoreTimer.startOneShot(0, BLINK_FROM_HERE); |
| 7305 } | 7313 } |
| 7306 } | 7314 } |
| 7307 | 7315 |
| 7308 void WebGLRenderingContextBase::maybeRestoreContext(TimerBase*) { | 7316 void WebGLRenderingContextBase::maybeRestoreContext(TimerBase*) { |
| 7309 ASSERT(isContextLost()); | 7317 ASSERT(isContextLost()); |
| 7310 | 7318 |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7589 DEFINE_TRACE(WebGLRenderingContextBase) { | 7597 DEFINE_TRACE(WebGLRenderingContextBase) { |
| 7590 visitor->trace(m_contextObjects); | 7598 visitor->trace(m_contextObjects); |
| 7591 visitor->trace(m_boundArrayBuffer); | 7599 visitor->trace(m_boundArrayBuffer); |
| 7592 visitor->trace(m_defaultVertexArrayObject); | 7600 visitor->trace(m_defaultVertexArrayObject); |
| 7593 visitor->trace(m_boundVertexArrayObject); | 7601 visitor->trace(m_boundVertexArrayObject); |
| 7594 visitor->trace(m_currentProgram); | 7602 visitor->trace(m_currentProgram); |
| 7595 visitor->trace(m_framebufferBinding); | 7603 visitor->trace(m_framebufferBinding); |
| 7596 visitor->trace(m_renderbufferBinding); | 7604 visitor->trace(m_renderbufferBinding); |
| 7597 visitor->trace(m_textureUnits); | 7605 visitor->trace(m_textureUnits); |
| 7598 visitor->trace(m_extensions); | 7606 visitor->trace(m_extensions); |
| 7607 visitor->trace(m_executionContext); |
| 7599 CanvasRenderingContext::trace(visitor); | 7608 CanvasRenderingContext::trace(visitor); |
| 7600 } | 7609 } |
| 7601 | 7610 |
| 7602 DEFINE_TRACE_WRAPPERS(WebGLRenderingContextBase) { | 7611 DEFINE_TRACE_WRAPPERS(WebGLRenderingContextBase) { |
| 7603 if (isContextLost()) { | 7612 if (isContextLost()) { |
| 7604 return; | 7613 return; |
| 7605 } | 7614 } |
| 7606 visitor->traceWrappers(m_boundArrayBuffer); | 7615 visitor->traceWrappers(m_boundArrayBuffer); |
| 7607 visitor->traceWrappers(m_renderbufferBinding); | 7616 visitor->traceWrappers(m_renderbufferBinding); |
| 7608 visitor->traceWrappers(m_framebufferBinding); | 7617 visitor->traceWrappers(m_framebufferBinding); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7668 | 7677 |
| 7669 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( | 7678 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( |
| 7670 HTMLCanvasElementOrOffscreenCanvas& result) const { | 7679 HTMLCanvasElementOrOffscreenCanvas& result) const { |
| 7671 if (canvas()) | 7680 if (canvas()) |
| 7672 result.setHTMLCanvasElement(canvas()); | 7681 result.setHTMLCanvasElement(canvas()); |
| 7673 else | 7682 else |
| 7674 result.setOffscreenCanvas(getOffscreenCanvas()); | 7683 result.setOffscreenCanvas(getOffscreenCanvas()); |
| 7675 } | 7684 } |
| 7676 | 7685 |
| 7677 } // namespace blink | 7686 } // namespace blink |
| OLD | NEW |