| 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 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 // copyRenderingResultsFromDrawingBuffer is expected to always succeed becau
se we've | 725 // copyRenderingResultsFromDrawingBuffer is expected to always succeed becau
se we've |
| 726 // explicitly created an Accelerated surface and have already validated it. | 726 // explicitly created an Accelerated surface and have already validated it. |
| 727 NOTREACHED(); | 727 NOTREACHED(); |
| 728 return nullptr; | 728 return nullptr; |
| 729 } | 729 } |
| 730 return buffer->newImageSnapshot(hint, reason); | 730 return buffer->newImageSnapshot(hint, reason); |
| 731 } | 731 } |
| 732 | 732 |
| 733 namespace { | 733 namespace { |
| 734 | 734 |
| 735 // ES2 enums | |
| 736 static const GLenum kSupportedInternalFormatsES2[] = { | |
| 737 GL_RGB, GL_RGBA, GL_LUMINANCE_ALPHA, GL_LUMINANCE, GL_ALPHA, | |
| 738 }; | |
| 739 | |
| 740 // Exposed by GL_ANGLE_depth_texture | 735 // Exposed by GL_ANGLE_depth_texture |
| 741 static const GLenum kSupportedInternalFormatsOESDepthTex[] = { | 736 static const GLenum kSupportedInternalFormatsOESDepthTex[] = { |
| 742 GL_DEPTH_COMPONENT, GL_DEPTH_STENCIL, | 737 GL_DEPTH_COMPONENT, GL_DEPTH_STENCIL, |
| 743 }; | 738 }; |
| 744 | 739 |
| 745 // Exposed by GL_EXT_sRGB | 740 // Exposed by GL_EXT_sRGB |
| 746 static const GLenum kSupportedInternalFormatsEXTsRGB[] = { | 741 static const GLenum kSupportedInternalFormatsEXTsRGB[] = { |
| 747 GL_SRGB, GL_SRGB_ALPHA_EXT, | 742 GL_SRGB, GL_SRGB_ALPHA_EXT, |
| 748 }; | 743 }; |
| 749 | 744 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 779 GL_RGBA8_SNORM, | 774 GL_RGBA8_SNORM, |
| 780 GL_RGBA16F, | 775 GL_RGBA16F, |
| 781 GL_RGBA32F, | 776 GL_RGBA32F, |
| 782 GL_DEPTH_COMPONENT16, | 777 GL_DEPTH_COMPONENT16, |
| 783 GL_DEPTH_COMPONENT24, | 778 GL_DEPTH_COMPONENT24, |
| 784 GL_DEPTH_COMPONENT32F, | 779 GL_DEPTH_COMPONENT32F, |
| 785 GL_DEPTH24_STENCIL8, | 780 GL_DEPTH24_STENCIL8, |
| 786 GL_DEPTH32F_STENCIL8, | 781 GL_DEPTH32F_STENCIL8, |
| 787 }; | 782 }; |
| 788 | 783 |
| 784 // ES3 enums supported by TexImageSource |
| 785 static const GLenum kSupportedInternalFormatsTexImageSourceES3[] = { |
| 786 GL_R8, GL_R16F, GL_R32F, GL_R8UI, GL_RG8, |
| 787 GL_RG16F, GL_RG32F, GL_RG8UI, GL_RGB8, GL_SRGB8, |
| 788 GL_RGB565, GL_R11F_G11F_B10F, GL_RGB9_E5, GL_RGB16F, GL_RGB32F, |
| 789 GL_RGB8UI, GL_RGBA8, GL_SRGB8_ALPHA8, GL_RGB5_A1, GL_RGBA4, |
| 790 GL_RGBA16F, GL_RGBA32F, GL_RGBA8UI, |
| 791 }; |
| 792 |
| 789 // ES2 enums | 793 // ES2 enums |
| 794 // Internalformat must equal format in ES2. |
| 790 static const GLenum kSupportedFormatsES2[] = { | 795 static const GLenum kSupportedFormatsES2[] = { |
| 791 GL_RGB, GL_RGBA, GL_LUMINANCE_ALPHA, GL_LUMINANCE, GL_ALPHA, | 796 GL_RGB, GL_RGBA, GL_LUMINANCE_ALPHA, GL_LUMINANCE, GL_ALPHA, |
| 792 }; | 797 }; |
| 793 | 798 |
| 794 // Exposed by GL_ANGLE_depth_texture | 799 // Exposed by GL_ANGLE_depth_texture |
| 795 static const GLenum kSupportedFormatsOESDepthTex[] = { | 800 static const GLenum kSupportedFormatsOESDepthTex[] = { |
| 796 GL_DEPTH_COMPONENT, GL_DEPTH_STENCIL, | 801 GL_DEPTH_COMPONENT, GL_DEPTH_STENCIL, |
| 797 }; | 802 }; |
| 798 | 803 |
| 799 // Exposed by GL_EXT_sRGB | 804 // Exposed by GL_EXT_sRGB |
| 800 static const GLenum kSupportedFormatsEXTsRGB[] = { | 805 static const GLenum kSupportedFormatsEXTsRGB[] = { |
| 801 GL_SRGB, GL_SRGB_ALPHA_EXT, | 806 GL_SRGB, GL_SRGB_ALPHA_EXT, |
| 802 }; | 807 }; |
| 803 | 808 |
| 804 // ES3 enums | 809 // ES3 enums |
| 805 static const GLenum kSupportedFormatsES3[] = { | 810 static const GLenum kSupportedFormatsES3[] = { |
| 806 GL_RED, GL_RED_INTEGER, GL_RG, | 811 GL_RED, GL_RED_INTEGER, GL_RG, |
| 807 GL_RG_INTEGER, GL_RGB, GL_RGB_INTEGER, | 812 GL_RG_INTEGER, GL_RGB, GL_RGB_INTEGER, |
| 808 GL_RGBA, GL_RGBA_INTEGER, GL_DEPTH_COMPONENT, | 813 GL_RGBA, GL_RGBA_INTEGER, GL_DEPTH_COMPONENT, |
| 809 GL_DEPTH_STENCIL, | 814 GL_DEPTH_STENCIL, |
| 810 }; | 815 }; |
| 811 | 816 |
| 817 // ES3 enums supported by TexImageSource |
| 818 static const GLenum kSupportedFormatsTexImageSourceES3[] = { |
| 819 GL_RED, GL_RED_INTEGER, GL_RG, GL_RG_INTEGER, |
| 820 GL_RGB, GL_RGB_INTEGER, GL_RGBA, GL_RGBA_INTEGER, |
| 821 }; |
| 822 |
| 812 // ES2 enums | 823 // ES2 enums |
| 813 static const GLenum kSupportedTypesES2[] = { | 824 static const GLenum kSupportedTypesES2[] = { |
| 814 GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_4_4_4_4, | 825 GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_4_4_4_4, |
| 815 GL_UNSIGNED_SHORT_5_5_5_1, | 826 GL_UNSIGNED_SHORT_5_5_5_1, |
| 816 }; | 827 }; |
| 817 | 828 |
| 818 // Exposed by GL_OES_texture_float | 829 // Exposed by GL_OES_texture_float |
| 819 static const GLenum kSupportedTypesOESTexFloat[] = { | 830 static const GLenum kSupportedTypesOESTexFloat[] = { |
| 820 GL_FLOAT, | 831 GL_FLOAT, |
| 821 }; | 832 }; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 839 GL_INT, | 850 GL_INT, |
| 840 GL_HALF_FLOAT, | 851 GL_HALF_FLOAT, |
| 841 GL_FLOAT, | 852 GL_FLOAT, |
| 842 GL_UNSIGNED_INT_2_10_10_10_REV, | 853 GL_UNSIGNED_INT_2_10_10_10_REV, |
| 843 GL_UNSIGNED_INT_10F_11F_11F_REV, | 854 GL_UNSIGNED_INT_10F_11F_11F_REV, |
| 844 GL_UNSIGNED_INT_5_9_9_9_REV, | 855 GL_UNSIGNED_INT_5_9_9_9_REV, |
| 845 GL_UNSIGNED_INT_24_8, | 856 GL_UNSIGNED_INT_24_8, |
| 846 GL_FLOAT_32_UNSIGNED_INT_24_8_REV, | 857 GL_FLOAT_32_UNSIGNED_INT_24_8_REV, |
| 847 }; | 858 }; |
| 848 | 859 |
| 860 // ES3 enums supported by TexImageSource |
| 861 static const GLenum kSupportedTypesTexImageSourceES3[] = { |
| 862 GL_HALF_FLOAT, GL_FLOAT, GL_UNSIGNED_INT_10F_11F_11F_REV, |
| 863 }; |
| 864 |
| 849 bool isUnsignedIntegerFormat(GLenum internalformat) { | 865 bool isUnsignedIntegerFormat(GLenum internalformat) { |
| 850 switch (internalformat) { | 866 switch (internalformat) { |
| 851 case GL_R8UI: | 867 case GL_R8UI: |
| 852 case GL_R16UI: | 868 case GL_R16UI: |
| 853 case GL_R32UI: | 869 case GL_R32UI: |
| 854 case GL_RG8UI: | 870 case GL_RG8UI: |
| 855 case GL_RG16UI: | 871 case GL_RG16UI: |
| 856 case GL_RG32UI: | 872 case GL_RG32UI: |
| 857 case GL_RGB8UI: | 873 case GL_RGB8UI: |
| 858 case GL_RGB16UI: | 874 case GL_RGB16UI: |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 955 m_dispatchContextLostEventTimer( | 971 m_dispatchContextLostEventTimer( |
| 956 this, | 972 this, |
| 957 &WebGLRenderingContextBase::dispatchContextLostEvent), | 973 &WebGLRenderingContextBase::dispatchContextLostEvent), |
| 958 m_restoreAllowed(false), | 974 m_restoreAllowed(false), |
| 959 m_restoreTimer(this, &WebGLRenderingContextBase::maybeRestoreContext), | 975 m_restoreTimer(this, &WebGLRenderingContextBase::maybeRestoreContext), |
| 960 m_generatedImageCache(4), | 976 m_generatedImageCache(4), |
| 961 m_synthesizedErrorsToConsole(true), | 977 m_synthesizedErrorsToConsole(true), |
| 962 m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole), | 978 m_numGLErrorsToConsoleAllowed(maxGLErrorsAllowedToConsole), |
| 963 m_onePlusMaxNonDefaultTextureUnit(0), | 979 m_onePlusMaxNonDefaultTextureUnit(0), |
| 964 m_isWebGL2FormatsTypesAdded(false), | 980 m_isWebGL2FormatsTypesAdded(false), |
| 981 m_isWebGL2TexImageSourceFormatsTypesAdded(false), |
| 965 m_isWebGL2InternalFormatsCopyTexImageAdded(false), | 982 m_isWebGL2InternalFormatsCopyTexImageAdded(false), |
| 966 m_isOESTextureFloatFormatsTypesAdded(false), | 983 m_isOESTextureFloatFormatsTypesAdded(false), |
| 967 m_isOESTextureHalfFloatFormatsTypesAdded(false), | 984 m_isOESTextureHalfFloatFormatsTypesAdded(false), |
| 968 m_isWebGLDepthTextureFormatsTypesAdded(false), | 985 m_isWebGLDepthTextureFormatsTypesAdded(false), |
| 969 m_isEXTsRGBFormatsTypesAdded(false), | 986 m_isEXTsRGBFormatsTypesAdded(false), |
| 970 m_version(version) { | 987 m_version(version) { |
| 971 ASSERT(contextProvider); | 988 ASSERT(contextProvider); |
| 972 | 989 |
| 973 m_contextGroup = WebGLContextGroup::create(); | 990 m_contextGroup = WebGLContextGroup::create(); |
| 974 m_contextGroup->addContext(this); | 991 m_contextGroup->addContext(this); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 994 WTF::bind(&WebGLRenderingContextBase::notifyCanvasContextChanged, | 1011 WTF::bind(&WebGLRenderingContextBase::notifyCanvasContextChanged, |
| 995 wrapWeakPersistent(this))); | 1012 wrapWeakPersistent(this))); |
| 996 drawingBuffer()->bind(GL_FRAMEBUFFER); | 1013 drawingBuffer()->bind(GL_FRAMEBUFFER); |
| 997 setupFlags(); | 1014 setupFlags(); |
| 998 | 1015 |
| 999 #define ADD_VALUES_TO_SET(set, values) \ | 1016 #define ADD_VALUES_TO_SET(set, values) \ |
| 1000 for (size_t i = 0; i < WTF_ARRAY_LENGTH(values); ++i) { \ | 1017 for (size_t i = 0; i < WTF_ARRAY_LENGTH(values); ++i) { \ |
| 1001 set.insert(values[i]); \ | 1018 set.insert(values[i]); \ |
| 1002 } | 1019 } |
| 1003 | 1020 |
| 1004 ADD_VALUES_TO_SET(m_supportedInternalFormats, kSupportedInternalFormatsES2); | 1021 ADD_VALUES_TO_SET(m_supportedInternalFormats, kSupportedFormatsES2); |
| 1022 ADD_VALUES_TO_SET(m_supportedTexImageSourceInternalFormats, |
| 1023 kSupportedFormatsES2); |
| 1005 ADD_VALUES_TO_SET(m_supportedInternalFormatsCopyTexImage, | 1024 ADD_VALUES_TO_SET(m_supportedInternalFormatsCopyTexImage, |
| 1006 kSupportedInternalFormatsES2); | 1025 kSupportedFormatsES2); |
| 1007 ADD_VALUES_TO_SET(m_supportedFormats, kSupportedFormatsES2); | 1026 ADD_VALUES_TO_SET(m_supportedFormats, kSupportedFormatsES2); |
| 1027 ADD_VALUES_TO_SET(m_supportedTexImageSourceFormats, kSupportedFormatsES2); |
| 1008 ADD_VALUES_TO_SET(m_supportedTypes, kSupportedTypesES2); | 1028 ADD_VALUES_TO_SET(m_supportedTypes, kSupportedTypesES2); |
| 1029 ADD_VALUES_TO_SET(m_supportedTexImageSourceTypes, kSupportedTypesES2); |
| 1009 } | 1030 } |
| 1010 | 1031 |
| 1011 PassRefPtr<DrawingBuffer> WebGLRenderingContextBase::createDrawingBuffer( | 1032 PassRefPtr<DrawingBuffer> WebGLRenderingContextBase::createDrawingBuffer( |
| 1012 std::unique_ptr<WebGraphicsContext3DProvider> contextProvider, | 1033 std::unique_ptr<WebGraphicsContext3DProvider> contextProvider, |
| 1013 DrawingBuffer::ChromiumImageUsage chromiumImageUsage) { | 1034 DrawingBuffer::ChromiumImageUsage chromiumImageUsage) { |
| 1014 bool premultipliedAlpha = creationAttributes().premultipliedAlpha(); | 1035 bool premultipliedAlpha = creationAttributes().premultipliedAlpha(); |
| 1015 bool wantAlphaChannel = creationAttributes().alpha(); | 1036 bool wantAlphaChannel = creationAttributes().alpha(); |
| 1016 bool wantDepthBuffer = creationAttributes().depth(); | 1037 bool wantDepthBuffer = creationAttributes().depth(); |
| 1017 bool wantStencilBuffer = creationAttributes().stencil(); | 1038 bool wantStencilBuffer = creationAttributes().stencil(); |
| 1018 bool wantAntialiasing = creationAttributes().antialias(); | 1039 bool wantAntialiasing = creationAttributes().antialias(); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1133 if (isWebGL2OrHigher()) | 1154 if (isWebGL2OrHigher()) |
| 1134 contextGL()->Enable(GL_PRIMITIVE_RESTART_FIXED_INDEX); | 1155 contextGL()->Enable(GL_PRIMITIVE_RESTART_FIXED_INDEX); |
| 1135 | 1156 |
| 1136 // This ensures that the context has a valid "lastFlushID" and won't be mistak
enly identified as the "least recently used" context. | 1157 // This ensures that the context has a valid "lastFlushID" and won't be mistak
enly identified as the "least recently used" context. |
| 1137 contextGL()->Flush(); | 1158 contextGL()->Flush(); |
| 1138 | 1159 |
| 1139 for (int i = 0; i < WebGLExtensionNameCount; ++i) | 1160 for (int i = 0; i < WebGLExtensionNameCount; ++i) |
| 1140 m_extensionEnabled[i] = false; | 1161 m_extensionEnabled[i] = false; |
| 1141 | 1162 |
| 1142 m_isWebGL2FormatsTypesAdded = false; | 1163 m_isWebGL2FormatsTypesAdded = false; |
| 1164 m_isWebGL2TexImageSourceFormatsTypesAdded = false; |
| 1143 m_isWebGL2InternalFormatsCopyTexImageAdded = false; | 1165 m_isWebGL2InternalFormatsCopyTexImageAdded = false; |
| 1144 m_isOESTextureFloatFormatsTypesAdded = false; | 1166 m_isOESTextureFloatFormatsTypesAdded = false; |
| 1145 m_isOESTextureHalfFloatFormatsTypesAdded = false; | 1167 m_isOESTextureHalfFloatFormatsTypesAdded = false; |
| 1146 m_isWebGLDepthTextureFormatsTypesAdded = false; | 1168 m_isWebGLDepthTextureFormatsTypesAdded = false; |
| 1147 m_isEXTsRGBFormatsTypesAdded = false; | 1169 m_isEXTsRGBFormatsTypesAdded = false; |
| 1148 | 1170 |
| 1149 m_supportedInternalFormats.clear(); | 1171 m_supportedInternalFormats.clear(); |
| 1150 ADD_VALUES_TO_SET(m_supportedInternalFormats, kSupportedInternalFormatsES2); | 1172 ADD_VALUES_TO_SET(m_supportedInternalFormats, kSupportedFormatsES2); |
| 1173 m_supportedTexImageSourceInternalFormats.clear(); |
| 1174 ADD_VALUES_TO_SET(m_supportedTexImageSourceInternalFormats, |
| 1175 kSupportedFormatsES2); |
| 1151 m_supportedInternalFormatsCopyTexImage.clear(); | 1176 m_supportedInternalFormatsCopyTexImage.clear(); |
| 1152 ADD_VALUES_TO_SET(m_supportedInternalFormatsCopyTexImage, | 1177 ADD_VALUES_TO_SET(m_supportedInternalFormatsCopyTexImage, |
| 1153 kSupportedInternalFormatsES2); | 1178 kSupportedFormatsES2); |
| 1154 m_supportedFormats.clear(); | 1179 m_supportedFormats.clear(); |
| 1155 ADD_VALUES_TO_SET(m_supportedFormats, kSupportedFormatsES2); | 1180 ADD_VALUES_TO_SET(m_supportedFormats, kSupportedFormatsES2); |
| 1181 m_supportedTexImageSourceFormats.clear(); |
| 1182 ADD_VALUES_TO_SET(m_supportedTexImageSourceFormats, kSupportedFormatsES2); |
| 1156 m_supportedTypes.clear(); | 1183 m_supportedTypes.clear(); |
| 1157 ADD_VALUES_TO_SET(m_supportedTypes, kSupportedTypesES2); | 1184 ADD_VALUES_TO_SET(m_supportedTypes, kSupportedTypesES2); |
| 1185 m_supportedTexImageSourceTypes.clear(); |
| 1186 ADD_VALUES_TO_SET(m_supportedTexImageSourceTypes, kSupportedTypesES2); |
| 1158 | 1187 |
| 1159 activateContext(this); | 1188 activateContext(this); |
| 1160 } | 1189 } |
| 1161 | 1190 |
| 1162 void WebGLRenderingContextBase::setupFlags() { | 1191 void WebGLRenderingContextBase::setupFlags() { |
| 1163 ASSERT(drawingBuffer()); | 1192 ASSERT(drawingBuffer()); |
| 1164 if (canvas()) { | 1193 if (canvas()) { |
| 1165 if (Page* p = canvas()->document().page()) { | 1194 if (Page* p = canvas()->document().page()) { |
| 1166 m_synthesizedErrorsToConsole = | 1195 m_synthesizedErrorsToConsole = |
| 1167 p->settings().webGLErrorsToConsoleEnabled(); | 1196 p->settings().webGLErrorsToConsoleEnabled(); |
| (...skipping 3182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4350 GLsizei depth, | 4379 GLsizei depth, |
| 4351 GLint border, | 4380 GLint border, |
| 4352 GLenum format, | 4381 GLenum format, |
| 4353 GLenum type, | 4382 GLenum type, |
| 4354 GLint xoffset, | 4383 GLint xoffset, |
| 4355 GLint yoffset, | 4384 GLint yoffset, |
| 4356 GLint zoffset) { | 4385 GLint zoffset) { |
| 4357 if (!validateTexFuncLevel(functionName, target, level)) | 4386 if (!validateTexFuncLevel(functionName, target, level)) |
| 4358 return false; | 4387 return false; |
| 4359 | 4388 |
| 4360 if (!validateTexFuncParameters(functionName, functionType, target, level, | 4389 if (!validateTexFuncParameters(functionName, functionType, sourceType, target, |
| 4361 internalformat, width, height, depth, border, | 4390 level, internalformat, width, height, depth, |
| 4362 format, type)) | 4391 border, format, type)) |
| 4363 return false; | 4392 return false; |
| 4364 | 4393 |
| 4365 if (functionType == TexSubImage) { | 4394 if (functionType == TexSubImage) { |
| 4366 if (!validateSettableTexFormat(functionName, format)) | 4395 if (!validateSettableTexFormat(functionName, format)) |
| 4367 return false; | 4396 return false; |
| 4368 if (!validateSize(functionName, xoffset, yoffset, zoffset)) | 4397 if (!validateSize(functionName, xoffset, yoffset, zoffset)) |
| 4369 return false; | 4398 return false; |
| 4370 } else { | 4399 } else { |
| 4371 // For SourceArrayBufferView, function validateTexFuncData() would handle wh
ether to validate the SettableTexFormat | 4400 // For SourceArrayBufferView, function validateTexFuncData() would handle wh
ether to validate the SettableTexFormat |
| 4372 // by checking if the ArrayBufferView is null or not. | 4401 // by checking if the ArrayBufferView is null or not. |
| (...skipping 1863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6236 continue; | 6265 continue; |
| 6237 } | 6266 } |
| 6238 if (!validateCharacter(string[i])) { | 6267 if (!validateCharacter(string[i])) { |
| 6239 synthesizeGLError(GL_INVALID_VALUE, "shaderSource", "string not ASCII"); | 6268 synthesizeGLError(GL_INVALID_VALUE, "shaderSource", "string not ASCII"); |
| 6240 return false; | 6269 return false; |
| 6241 } | 6270 } |
| 6242 } | 6271 } |
| 6243 return true; | 6272 return true; |
| 6244 } | 6273 } |
| 6245 | 6274 |
| 6275 void WebGLRenderingContextBase::addExtensionSupportedFormatsTypes() { |
| 6276 if (!m_isOESTextureFloatFormatsTypesAdded && |
| 6277 extensionEnabled(OESTextureFloatName)) { |
| 6278 ADD_VALUES_TO_SET(m_supportedTypes, kSupportedTypesOESTexFloat); |
| 6279 ADD_VALUES_TO_SET(m_supportedTexImageSourceTypes, |
| 6280 kSupportedTypesOESTexFloat); |
| 6281 m_isOESTextureFloatFormatsTypesAdded = true; |
| 6282 } |
| 6283 |
| 6284 if (!m_isOESTextureHalfFloatFormatsTypesAdded && |
| 6285 extensionEnabled(OESTextureHalfFloatName)) { |
| 6286 ADD_VALUES_TO_SET(m_supportedTypes, kSupportedTypesOESTexHalfFloat); |
| 6287 ADD_VALUES_TO_SET(m_supportedTexImageSourceTypes, |
| 6288 kSupportedTypesOESTexHalfFloat); |
| 6289 m_isOESTextureHalfFloatFormatsTypesAdded = true; |
| 6290 } |
| 6291 |
| 6292 if (!m_isWebGLDepthTextureFormatsTypesAdded && |
| 6293 extensionEnabled(WebGLDepthTextureName)) { |
| 6294 ADD_VALUES_TO_SET(m_supportedInternalFormats, |
| 6295 kSupportedInternalFormatsOESDepthTex); |
| 6296 ADD_VALUES_TO_SET(m_supportedTexImageSourceInternalFormats, |
| 6297 kSupportedInternalFormatsOESDepthTex); |
| 6298 ADD_VALUES_TO_SET(m_supportedFormats, kSupportedFormatsOESDepthTex); |
| 6299 ADD_VALUES_TO_SET(m_supportedTexImageSourceFormats, |
| 6300 kSupportedFormatsOESDepthTex); |
| 6301 ADD_VALUES_TO_SET(m_supportedTypes, kSupportedTypesOESDepthTex); |
| 6302 ADD_VALUES_TO_SET(m_supportedTexImageSourceTypes, |
| 6303 kSupportedTypesOESDepthTex); |
| 6304 m_isWebGLDepthTextureFormatsTypesAdded = true; |
| 6305 } |
| 6306 |
| 6307 if (!m_isEXTsRGBFormatsTypesAdded && extensionEnabled(EXTsRGBName)) { |
| 6308 ADD_VALUES_TO_SET(m_supportedInternalFormats, |
| 6309 kSupportedInternalFormatsEXTsRGB); |
| 6310 ADD_VALUES_TO_SET(m_supportedTexImageSourceInternalFormats, |
| 6311 kSupportedInternalFormatsEXTsRGB); |
| 6312 ADD_VALUES_TO_SET(m_supportedFormats, kSupportedFormatsEXTsRGB); |
| 6313 ADD_VALUES_TO_SET(m_supportedTexImageSourceFormats, |
| 6314 kSupportedFormatsEXTsRGB); |
| 6315 m_isEXTsRGBFormatsTypesAdded = true; |
| 6316 } |
| 6317 } |
| 6318 |
| 6319 bool WebGLRenderingContextBase::validateTexImageSourceFormatAndType( |
| 6320 const char* functionName, |
| 6321 TexImageFunctionType functionType, |
| 6322 GLenum internalformat, |
| 6323 GLenum format, |
| 6324 GLenum type) { |
| 6325 if (!m_isWebGL2TexImageSourceFormatsTypesAdded && isWebGL2OrHigher()) { |
| 6326 ADD_VALUES_TO_SET(m_supportedTexImageSourceInternalFormats, |
| 6327 kSupportedInternalFormatsTexImageSourceES3); |
| 6328 ADD_VALUES_TO_SET(m_supportedTexImageSourceFormats, |
| 6329 kSupportedFormatsTexImageSourceES3); |
| 6330 ADD_VALUES_TO_SET(m_supportedTexImageSourceTypes, |
| 6331 kSupportedTypesTexImageSourceES3); |
| 6332 m_isWebGL2TexImageSourceFormatsTypesAdded = true; |
| 6333 } |
| 6334 |
| 6335 if (!isWebGL2OrHigher()) { |
| 6336 addExtensionSupportedFormatsTypes(); |
| 6337 } |
| 6338 |
| 6339 if (internalformat != 0 && |
| 6340 m_supportedTexImageSourceInternalFormats.find(internalformat) == |
| 6341 m_supportedTexImageSourceInternalFormats.end()) { |
| 6342 if (functionType == TexImage) { |
| 6343 synthesizeGLError(GL_INVALID_VALUE, functionName, |
| 6344 "invalid internalformat"); |
| 6345 } else { |
| 6346 synthesizeGLError(GL_INVALID_ENUM, functionName, |
| 6347 "invalid internalformat"); |
| 6348 } |
| 6349 return false; |
| 6350 } |
| 6351 if (m_supportedTexImageSourceFormats.find(format) == |
| 6352 m_supportedTexImageSourceFormats.end()) { |
| 6353 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid format"); |
| 6354 return false; |
| 6355 } |
| 6356 if (m_supportedTexImageSourceTypes.find(type) == |
| 6357 m_supportedTexImageSourceTypes.end()) { |
| 6358 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid type"); |
| 6359 return false; |
| 6360 } |
| 6361 |
| 6362 return true; |
| 6363 } |
| 6364 |
| 6246 bool WebGLRenderingContextBase::validateTexFuncFormatAndType( | 6365 bool WebGLRenderingContextBase::validateTexFuncFormatAndType( |
| 6247 const char* functionName, | 6366 const char* functionName, |
| 6248 TexImageFunctionType functionType, | 6367 TexImageFunctionType functionType, |
| 6249 GLenum internalformat, | 6368 GLenum internalformat, |
| 6250 GLenum format, | 6369 GLenum format, |
| 6251 GLenum type, | 6370 GLenum type, |
| 6252 GLint level) { | 6371 GLint level) { |
| 6253 if (!m_isWebGL2FormatsTypesAdded && isWebGL2OrHigher()) { | 6372 if (!m_isWebGL2FormatsTypesAdded && isWebGL2OrHigher()) { |
| 6254 ADD_VALUES_TO_SET(m_supportedInternalFormats, kSupportedInternalFormatsES3); | 6373 ADD_VALUES_TO_SET(m_supportedInternalFormats, kSupportedInternalFormatsES3); |
| 6255 ADD_VALUES_TO_SET(m_supportedInternalFormats, | 6374 ADD_VALUES_TO_SET(m_supportedInternalFormats, |
| 6256 kSupportedInternalFormatsTexImageES3); | 6375 kSupportedInternalFormatsTexImageES3); |
| 6257 ADD_VALUES_TO_SET(m_supportedFormats, kSupportedFormatsES3); | 6376 ADD_VALUES_TO_SET(m_supportedFormats, kSupportedFormatsES3); |
| 6258 ADD_VALUES_TO_SET(m_supportedTypes, kSupportedTypesES3); | 6377 ADD_VALUES_TO_SET(m_supportedTypes, kSupportedTypesES3); |
| 6259 m_isWebGL2FormatsTypesAdded = true; | 6378 m_isWebGL2FormatsTypesAdded = true; |
| 6260 } | 6379 } |
| 6261 | 6380 |
| 6262 if (!isWebGL2OrHigher()) { | 6381 if (!isWebGL2OrHigher()) { |
| 6263 if (!m_isOESTextureFloatFormatsTypesAdded && | 6382 addExtensionSupportedFormatsTypes(); |
| 6264 extensionEnabled(OESTextureFloatName)) { | |
| 6265 ADD_VALUES_TO_SET(m_supportedTypes, kSupportedTypesOESTexFloat); | |
| 6266 m_isOESTextureFloatFormatsTypesAdded = true; | |
| 6267 } | |
| 6268 | |
| 6269 if (!m_isOESTextureHalfFloatFormatsTypesAdded && | |
| 6270 extensionEnabled(OESTextureHalfFloatName)) { | |
| 6271 ADD_VALUES_TO_SET(m_supportedTypes, kSupportedTypesOESTexHalfFloat); | |
| 6272 m_isOESTextureHalfFloatFormatsTypesAdded = true; | |
| 6273 } | |
| 6274 | |
| 6275 if (!m_isWebGLDepthTextureFormatsTypesAdded && | |
| 6276 extensionEnabled(WebGLDepthTextureName)) { | |
| 6277 ADD_VALUES_TO_SET(m_supportedInternalFormats, | |
| 6278 kSupportedInternalFormatsOESDepthTex); | |
| 6279 ADD_VALUES_TO_SET(m_supportedFormats, kSupportedFormatsOESDepthTex); | |
| 6280 ADD_VALUES_TO_SET(m_supportedTypes, kSupportedTypesOESDepthTex); | |
| 6281 m_isWebGLDepthTextureFormatsTypesAdded = true; | |
| 6282 } | |
| 6283 | |
| 6284 if (!m_isEXTsRGBFormatsTypesAdded && extensionEnabled(EXTsRGBName)) { | |
| 6285 ADD_VALUES_TO_SET(m_supportedInternalFormats, | |
| 6286 kSupportedInternalFormatsEXTsRGB); | |
| 6287 ADD_VALUES_TO_SET(m_supportedFormats, kSupportedFormatsEXTsRGB); | |
| 6288 m_isEXTsRGBFormatsTypesAdded = true; | |
| 6289 } | |
| 6290 } | 6383 } |
| 6291 | 6384 |
| 6292 if (internalformat != 0 && | 6385 if (internalformat != 0 && |
| 6293 m_supportedInternalFormats.find(internalformat) == | 6386 m_supportedInternalFormats.find(internalformat) == |
| 6294 m_supportedInternalFormats.end()) { | 6387 m_supportedInternalFormats.end()) { |
| 6295 if (functionType == TexImage) { | 6388 if (functionType == TexImage) { |
| 6296 synthesizeGLError(GL_INVALID_VALUE, functionName, | 6389 synthesizeGLError(GL_INVALID_VALUE, functionName, |
| 6297 "invalid internalformat"); | 6390 "invalid internalformat"); |
| 6298 } else { | 6391 } else { |
| 6299 synthesizeGLError(GL_INVALID_ENUM, functionName, | 6392 synthesizeGLError(GL_INVALID_ENUM, functionName, |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6424 default: | 6517 default: |
| 6425 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid target"); | 6518 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid target"); |
| 6426 return false; | 6519 return false; |
| 6427 } | 6520 } |
| 6428 return true; | 6521 return true; |
| 6429 } | 6522 } |
| 6430 | 6523 |
| 6431 bool WebGLRenderingContextBase::validateTexFuncParameters( | 6524 bool WebGLRenderingContextBase::validateTexFuncParameters( |
| 6432 const char* functionName, | 6525 const char* functionName, |
| 6433 TexImageFunctionType functionType, | 6526 TexImageFunctionType functionType, |
| 6527 TexFuncValidationSourceType sourceType, |
| 6434 GLenum target, | 6528 GLenum target, |
| 6435 GLint level, | 6529 GLint level, |
| 6436 GLenum internalformat, | 6530 GLenum internalformat, |
| 6437 GLsizei width, | 6531 GLsizei width, |
| 6438 GLsizei height, | 6532 GLsizei height, |
| 6439 GLsizei depth, | 6533 GLsizei depth, |
| 6440 GLint border, | 6534 GLint border, |
| 6441 GLenum format, | 6535 GLenum format, |
| 6442 GLenum type) { | 6536 GLenum type) { |
| 6443 // We absolutely have to validate the format and type combination. | 6537 // We absolutely have to validate the format and type combination. |
| 6444 // The texImage2D entry points taking HTMLImage, etc. will produce | 6538 // The texImage2D entry points taking HTMLImage, etc. will produce |
| 6445 // temporary data based on this combination, so it must be legal. | 6539 // temporary data based on this combination, so it must be legal. |
| 6446 if (!validateTexFuncFormatAndType(functionName, functionType, internalformat, | 6540 if (sourceType == SourceHTMLImageElement || |
| 6447 format, type, level)) | 6541 sourceType == SourceHTMLCanvasElement || |
| 6448 return false; | 6542 sourceType == SourceHTMLVideoElement || sourceType == SourceImageData || |
| 6543 sourceType == SourceImageBitmap) { |
| 6544 if (!validateTexImageSourceFormatAndType(functionName, functionType, |
| 6545 internalformat, format, type)) { |
| 6546 return false; |
| 6547 } |
| 6548 } else { |
| 6549 if (!validateTexFuncFormatAndType(functionName, functionType, |
| 6550 internalformat, format, type, level)) { |
| 6551 return false; |
| 6552 } |
| 6553 } |
| 6449 | 6554 |
| 6450 if (!validateTexFuncDimensions(functionName, functionType, target, level, | 6555 if (!validateTexFuncDimensions(functionName, functionType, target, level, |
| 6451 width, height, depth)) | 6556 width, height, depth)) |
| 6452 return false; | 6557 return false; |
| 6453 | 6558 |
| 6454 if (border) { | 6559 if (border) { |
| 6455 synthesizeGLError(GL_INVALID_VALUE, functionName, "border != 0"); | 6560 synthesizeGLError(GL_INVALID_VALUE, functionName, "border != 0"); |
| 6456 return false; | 6561 return false; |
| 6457 } | 6562 } |
| 6458 | 6563 |
| (...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7323 | 7428 |
| 7324 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( | 7429 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( |
| 7325 HTMLCanvasElementOrOffscreenCanvas& result) const { | 7430 HTMLCanvasElementOrOffscreenCanvas& result) const { |
| 7326 if (canvas()) | 7431 if (canvas()) |
| 7327 result.setHTMLCanvasElement(canvas()); | 7432 result.setHTMLCanvasElement(canvas()); |
| 7328 else | 7433 else |
| 7329 result.setOffscreenCanvas(getOffscreenCanvas()); | 7434 result.setOffscreenCanvas(getOffscreenCanvas()); |
| 7330 } | 7435 } |
| 7331 | 7436 |
| 7332 } // namespace blink | 7437 } // namespace blink |
| OLD | NEW |