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 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
878 case GL_SRGB8: | 878 case GL_SRGB8: |
879 case GL_SRGB8_ALPHA8: | 879 case GL_SRGB8_ALPHA8: |
880 return true; | 880 return true; |
881 default: | 881 default: |
882 return false; | 882 return false; |
883 } | 883 } |
884 } | 884 } |
885 | 885 |
886 } // namespace | 886 } // namespace |
887 | 887 |
888 WebGLRenderingContextBase::WebGLRenderingContextBase(OffscreenCanvas* passedOffs creenCanvas, std::unique_ptr<WebGraphicsContext3DProvider> contextProvider, cons t WebGLContextAttributes& requestedAttributes) | 888 WebGLRenderingContextBase::WebGLRenderingContextBase(OffscreenCanvas* passedOffs creenCanvas, |
889 : WebGLRenderingContextBase(nullptr, passedOffscreenCanvas, std::move(contex tProvider), requestedAttributes) | 889 std::unique_ptr<WebGraphicsContext3DProvider> contextProvider, |
890 const WebGLContextAttributes& requestedAttributes, unsigned version) | |
891 : WebGLRenderingContextBase(nullptr, passedOffscreenCanvas, std::move(contex tProvider), requestedAttributes, version) | |
890 { } | 892 { } |
891 | 893 |
892 WebGLRenderingContextBase::WebGLRenderingContextBase(HTMLCanvasElement* passedCa nvas, std::unique_ptr<WebGraphicsContext3DProvider> contextProvider, const WebGL ContextAttributes& requestedAttributes) | 894 WebGLRenderingContextBase::WebGLRenderingContextBase(HTMLCanvasElement* passedCa nvas, |
893 : WebGLRenderingContextBase(passedCanvas, nullptr, std::move(contextProvider ), requestedAttributes) | 895 std::unique_ptr<WebGraphicsContext3DProvider> contextProvider, |
896 const WebGLContextAttributes& requestedAttributes, unsigned version) | |
897 : WebGLRenderingContextBase(passedCanvas, nullptr, std::move(contextProvider ), requestedAttributes, version) | |
894 { } | 898 { } |
895 | 899 |
896 WebGLRenderingContextBase::WebGLRenderingContextBase(HTMLCanvasElement* passedCa nvas, OffscreenCanvas* passedOffscreenCanvas, std::unique_ptr<WebGraphicsContext 3DProvider> contextProvider, const WebGLContextAttributes& requestedAttributes) | 900 WebGLRenderingContextBase::WebGLRenderingContextBase(HTMLCanvasElement* passedCa nvas, |
901 OffscreenCanvas* passedOffscreenCanvas, std::unique_ptr<WebGraphicsContext3D Provider> contextProvider, | |
902 const WebGLContextAttributes& requestedAttributes, unsigned version) | |
897 : CanvasRenderingContext(passedCanvas, passedOffscreenCanvas) | 903 : CanvasRenderingContext(passedCanvas, passedOffscreenCanvas) |
898 , m_isHidden(false) | 904 , m_isHidden(false) |
899 , m_contextLostMode(NotLostContext) | 905 , m_contextLostMode(NotLostContext) |
900 , m_autoRecoveryMethod(Manual) | 906 , m_autoRecoveryMethod(Manual) |
901 , m_dispatchContextLostEventTimer(this, &WebGLRenderingContextBase::dispatch ContextLostEvent) | 907 , m_dispatchContextLostEventTimer(this, &WebGLRenderingContextBase::dispatch ContextLostEvent) |
902 , m_restoreAllowed(false) | 908 , m_restoreAllowed(false) |
903 , m_restoreTimer(this, &WebGLRenderingContextBase::maybeRestoreContext) | 909 , m_restoreTimer(this, &WebGLRenderingContextBase::maybeRestoreContext) |
904 , m_preservedDefaultVAOObjectWrapper(false) | 910 , m_preservedDefaultVAOObjectWrapper(false) |
905 , m_generatedImageCache(4) | 911 , m_generatedImageCache(4) |
906 , m_requestedAttributes(requestedAttributes) | 912 , m_requestedAttributes(requestedAttributes) |
907 , m_synthesizedErrorsToConsole(true) | 913 , m_synthesizedErrorsToConsole(true) |
908 , m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole) | 914 , m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole) |
909 , m_onePlusMaxNonDefaultTextureUnit(0) | 915 , m_onePlusMaxNonDefaultTextureUnit(0) |
910 , m_isWebGL2FormatsTypesAdded(false) | 916 , m_isWebGL2FormatsTypesAdded(false) |
911 , m_isWebGL2InternalFormatsCopyTexImageAdded(false) | 917 , m_isWebGL2InternalFormatsCopyTexImageAdded(false) |
912 , m_isOESTextureFloatFormatsTypesAdded(false) | 918 , m_isOESTextureFloatFormatsTypesAdded(false) |
913 , m_isOESTextureHalfFloatFormatsTypesAdded(false) | 919 , m_isOESTextureHalfFloatFormatsTypesAdded(false) |
914 , m_isWebGLDepthTextureFormatsTypesAdded(false) | 920 , m_isWebGLDepthTextureFormatsTypesAdded(false) |
915 , m_isEXTsRGBFormatsTypesAdded(false) | 921 , m_isEXTsRGBFormatsTypesAdded(false) |
922 , m_version(version) | |
916 { | 923 { |
917 ASSERT(contextProvider); | 924 ASSERT(contextProvider); |
918 | 925 |
919 m_contextGroup = WebGLContextGroup::create(); | 926 m_contextGroup = WebGLContextGroup::create(); |
920 m_contextGroup->addContext(this); | 927 m_contextGroup->addContext(this); |
921 | 928 |
922 m_maxViewportDims[0] = m_maxViewportDims[1] = 0; | 929 m_maxViewportDims[0] = m_maxViewportDims[1] = 0; |
923 contextProvider->contextGL()->GetIntegerv(GL_MAX_VIEWPORT_DIMS, m_maxViewpor tDims); | 930 contextProvider->contextGL()->GetIntegerv(GL_MAX_VIEWPORT_DIMS, m_maxViewpor tDims); |
924 | 931 |
925 RefPtr<DrawingBuffer> buffer = createDrawingBuffer(std::move(contextProvider )); | 932 RefPtr<DrawingBuffer> buffer = createDrawingBuffer(std::move(contextProvider )); |
(...skipping 19 matching lines...) Expand all Loading... | |
945 } | 952 } |
946 | 953 |
947 PassRefPtr<DrawingBuffer> WebGLRenderingContextBase::createDrawingBuffer(std::un ique_ptr<WebGraphicsContext3DProvider> contextProvider) | 954 PassRefPtr<DrawingBuffer> WebGLRenderingContextBase::createDrawingBuffer(std::un ique_ptr<WebGraphicsContext3DProvider> contextProvider) |
948 { | 955 { |
949 bool premultipliedAlpha = m_requestedAttributes.premultipliedAlpha(); | 956 bool premultipliedAlpha = m_requestedAttributes.premultipliedAlpha(); |
950 bool wantAlphaChannel = m_requestedAttributes.alpha(); | 957 bool wantAlphaChannel = m_requestedAttributes.alpha(); |
951 bool wantDepthBuffer = m_requestedAttributes.depth(); | 958 bool wantDepthBuffer = m_requestedAttributes.depth(); |
952 bool wantStencilBuffer = m_requestedAttributes.stencil(); | 959 bool wantStencilBuffer = m_requestedAttributes.stencil(); |
953 bool wantAntialiasing = m_requestedAttributes.antialias(); | 960 bool wantAntialiasing = m_requestedAttributes.antialias(); |
954 DrawingBuffer::PreserveDrawingBuffer preserve = m_requestedAttributes.preser veDrawingBuffer() ? DrawingBuffer::Preserve : DrawingBuffer::Discard; | 961 DrawingBuffer::PreserveDrawingBuffer preserve = m_requestedAttributes.preser veDrawingBuffer() ? DrawingBuffer::Preserve : DrawingBuffer::Discard; |
962 DrawingBuffer::WebGLVersion webGLVersion = DrawingBuffer::WebGL1; | |
963 if (version() == 1) { | |
dshwang
2016/07/07 12:33:26
version() has to be non-virtual to be used here, b
| |
964 webGLVersion = DrawingBuffer::WebGL1; | |
965 } else if (version() == 2) { | |
966 webGLVersion = DrawingBuffer::WebGL2; | |
967 } else { | |
968 NOTREACHED(); | |
969 } | |
955 return DrawingBuffer::create( | 970 return DrawingBuffer::create( |
956 std::move(contextProvider), | 971 std::move(contextProvider), |
957 clampedCanvasSize(), | 972 clampedCanvasSize(), |
958 premultipliedAlpha, | 973 premultipliedAlpha, |
959 wantAlphaChannel, | 974 wantAlphaChannel, |
960 wantDepthBuffer, | 975 wantDepthBuffer, |
961 wantStencilBuffer, | 976 wantStencilBuffer, |
962 wantAntialiasing, | 977 wantAntialiasing, |
963 preserve); | 978 preserve, |
979 webGLVersion); | |
964 } | 980 } |
965 | 981 |
966 void WebGLRenderingContextBase::initializeNewContext() | 982 void WebGLRenderingContextBase::initializeNewContext() |
967 { | 983 { |
968 ASSERT(!isContextLost()); | 984 ASSERT(!isContextLost()); |
969 ASSERT(drawingBuffer()); | 985 ASSERT(drawingBuffer()); |
970 | 986 |
971 m_markedCanvasDirty = false; | 987 m_markedCanvasDirty = false; |
972 m_activeTextureUnit = 0; | 988 m_activeTextureUnit = 0; |
973 m_packAlignment = 4; | 989 m_packAlignment = 4; |
(...skipping 5497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6471 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); | 6487 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); |
6472 } | 6488 } |
6473 | 6489 |
6474 void WebGLRenderingContextBase::restoreUnpackParameters() | 6490 void WebGLRenderingContextBase::restoreUnpackParameters() |
6475 { | 6491 { |
6476 if (m_unpackAlignment != 1) | 6492 if (m_unpackAlignment != 1) |
6477 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 6493 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); |
6478 } | 6494 } |
6479 | 6495 |
6480 } // namespace blink | 6496 } // namespace blink |
OLD | NEW |