| 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 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 // to the back-buffer of m_context. | 677 // to the back-buffer of m_context. |
| 678 RefPtr<DrawingBuffer> m_drawingBuffer; | 678 RefPtr<DrawingBuffer> m_drawingBuffer; |
| 679 DrawingBuffer* drawingBuffer() const; | 679 DrawingBuffer* drawingBuffer() const; |
| 680 | 680 |
| 681 RefPtr<WebGLContextGroup> m_contextGroup; | 681 RefPtr<WebGLContextGroup> m_contextGroup; |
| 682 | 682 |
| 683 bool m_isHidden; | 683 bool m_isHidden; |
| 684 LostContextMode m_contextLostMode; | 684 LostContextMode m_contextLostMode; |
| 685 AutoRecoveryMethod m_autoRecoveryMethod; | 685 AutoRecoveryMethod m_autoRecoveryMethod; |
| 686 // Dispatches a context lost event once it is determined that one is needed. | 686 // Dispatches a context lost event once it is determined that one is needed. |
| 687 // This is used for synthetic, WEBGL_lose_context and real context losses. For
real ones, it's | 687 // This is used for synthetic, WEBGL_lose_context and real context losses. For |
| 688 // likely that there's no JavaScript on the stack, but that might be dependent | 688 // real ones, it's likely that there's no JavaScript on the stack, but that |
| 689 // on how exactly the platform discovers that the context was lost. For better | 689 // might be dependent on how exactly the platform discovers that the context |
| 690 // portability we always defer the dispatch of the event. | 690 // was lost. For better portability we always defer the dispatch of the event. |
| 691 Timer<WebGLRenderingContextBase> m_dispatchContextLostEventTimer; | 691 Timer<WebGLRenderingContextBase> m_dispatchContextLostEventTimer; |
| 692 bool m_restoreAllowed; | 692 bool m_restoreAllowed; |
| 693 Timer<WebGLRenderingContextBase> m_restoreTimer; | 693 Timer<WebGLRenderingContextBase> m_restoreTimer; |
| 694 | 694 |
| 695 bool m_markedCanvasDirty; | 695 bool m_markedCanvasDirty; |
| 696 HeapHashSet<WeakMember<WebGLContextObject>> m_contextObjects; | 696 HeapHashSet<WeakMember<WebGLContextObject>> m_contextObjects; |
| 697 | 697 |
| 698 // List of bound VBO's. Used to maintain info about sizes for ARRAY_BUFFER and
stored values for ELEMENT_ARRAY_BUFFER | 698 // List of bound VBO's. Used to maintain info about sizes for ARRAY_BUFFER and |
| 699 // stored values for ELEMENT_ARRAY_BUFFER |
| 699 Member<WebGLBuffer> m_boundArrayBuffer; | 700 Member<WebGLBuffer> m_boundArrayBuffer; |
| 700 | 701 |
| 701 Member<WebGLVertexArrayObjectBase> m_defaultVertexArrayObject; | 702 Member<WebGLVertexArrayObjectBase> m_defaultVertexArrayObject; |
| 702 Member<WebGLVertexArrayObjectBase> m_boundVertexArrayObject; | 703 Member<WebGLVertexArrayObjectBase> m_boundVertexArrayObject; |
| 703 void setBoundVertexArrayObject(WebGLVertexArrayObjectBase*); | 704 void setBoundVertexArrayObject(WebGLVertexArrayObjectBase*); |
| 704 | 705 |
| 705 enum VertexAttribValueType { | 706 enum VertexAttribValueType { |
| 706 Float32ArrayType, | 707 Float32ArrayType, |
| 707 Int32ArrayType, | 708 Int32ArrayType, |
| 708 Uint32ArrayType, | 709 Uint32ArrayType, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 GLfloat m_clearColor[4]; | 763 GLfloat m_clearColor[4]; |
| 763 bool m_scissorEnabled; | 764 bool m_scissorEnabled; |
| 764 GLfloat m_clearDepth; | 765 GLfloat m_clearDepth; |
| 765 GLint m_clearStencil; | 766 GLint m_clearStencil; |
| 766 GLboolean m_colorMask[4]; | 767 GLboolean m_colorMask[4]; |
| 767 GLboolean m_depthMask; | 768 GLboolean m_depthMask; |
| 768 | 769 |
| 769 bool m_stencilEnabled; | 770 bool m_stencilEnabled; |
| 770 GLuint m_stencilMask, m_stencilMaskBack; | 771 GLuint m_stencilMask, m_stencilMaskBack; |
| 771 GLint m_stencilFuncRef, | 772 GLint m_stencilFuncRef, |
| 772 m_stencilFuncRefBack; // Note that these are the user specified values, n
ot the internal clamped value. | 773 m_stencilFuncRefBack; // Note that these are the user specified values, |
| 774 // not the internal clamped value. |
| 773 GLuint m_stencilFuncMask, m_stencilFuncMaskBack; | 775 GLuint m_stencilFuncMask, m_stencilFuncMaskBack; |
| 774 | 776 |
| 775 bool m_isDepthStencilSupported; | 777 bool m_isDepthStencilSupported; |
| 776 | 778 |
| 777 bool m_synthesizedErrorsToConsole; | 779 bool m_synthesizedErrorsToConsole; |
| 778 int m_numGLErrorsToConsoleAllowed; | 780 int m_numGLErrorsToConsoleAllowed; |
| 779 | 781 |
| 780 unsigned long m_onePlusMaxNonDefaultTextureUnit; | 782 unsigned long m_onePlusMaxNonDefaultTextureUnit; |
| 781 | 783 |
| 782 std::unique_ptr<Extensions3DUtil> m_extensionsUtil; | 784 std::unique_ptr<Extensions3DUtil> m_extensionsUtil; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 876 m_extensions.append( | 878 m_extensions.append( |
| 877 TypedExtensionTracker<T>::create(extensionPtr, flags, prefixes)); | 879 TypedExtensionTracker<T>::create(extensionPtr, flags, prefixes)); |
| 878 } | 880 } |
| 879 | 881 |
| 880 bool extensionSupportedAndAllowed(const ExtensionTracker*); | 882 bool extensionSupportedAndAllowed(const ExtensionTracker*); |
| 881 | 883 |
| 882 inline bool extensionEnabled(WebGLExtensionName name) { | 884 inline bool extensionEnabled(WebGLExtensionName name) { |
| 883 return m_extensionEnabled[name]; | 885 return m_extensionEnabled[name]; |
| 884 } | 886 } |
| 885 | 887 |
| 886 // ScopedDrawingBufferBinder is used for ReadPixels/CopyTexImage2D/CopySubImag
e2D to read from | 888 // ScopedDrawingBufferBinder is used for |
| 887 // a multisampled DrawingBuffer. In this situation, we need to blit to a singl
e sampled buffer | 889 // ReadPixels/CopyTexImage2D/CopySubImage2D to read from a multisampled |
| 888 // for reading, during which the bindings could be changed and need to be reco
vered. | 890 // DrawingBuffer. In this situation, we need to blit to a single sampled |
| 891 // buffer for reading, during which the bindings could be changed and need to |
| 892 // be recovered. |
| 889 class ScopedDrawingBufferBinder { | 893 class ScopedDrawingBufferBinder { |
| 890 STACK_ALLOCATED(); | 894 STACK_ALLOCATED(); |
| 891 | 895 |
| 892 public: | 896 public: |
| 893 ScopedDrawingBufferBinder(DrawingBuffer* drawingBuffer, | 897 ScopedDrawingBufferBinder(DrawingBuffer* drawingBuffer, |
| 894 WebGLFramebuffer* framebufferBinding) | 898 WebGLFramebuffer* framebufferBinding) |
| 895 : m_drawingBuffer(drawingBuffer), | 899 : m_drawingBuffer(drawingBuffer), |
| 896 m_readFramebufferBinding(framebufferBinding) { | 900 m_readFramebufferBinding(framebufferBinding) { |
| 897 // Commit DrawingBuffer if needed (e.g., for multisampling) | 901 // Commit DrawingBuffer if needed (e.g., for multisampling) |
| 898 if (!m_readFramebufferBinding && m_drawingBuffer) | 902 if (!m_readFramebufferBinding && m_drawingBuffer) |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 935 ScriptValue getBooleanParameter(ScriptState*, GLenum); | 939 ScriptValue getBooleanParameter(ScriptState*, GLenum); |
| 936 ScriptValue getBooleanArrayParameter(ScriptState*, GLenum); | 940 ScriptValue getBooleanArrayParameter(ScriptState*, GLenum); |
| 937 ScriptValue getFloatParameter(ScriptState*, GLenum); | 941 ScriptValue getFloatParameter(ScriptState*, GLenum); |
| 938 ScriptValue getIntParameter(ScriptState*, GLenum); | 942 ScriptValue getIntParameter(ScriptState*, GLenum); |
| 939 ScriptValue getInt64Parameter(ScriptState*, GLenum); | 943 ScriptValue getInt64Parameter(ScriptState*, GLenum); |
| 940 ScriptValue getUnsignedIntParameter(ScriptState*, GLenum); | 944 ScriptValue getUnsignedIntParameter(ScriptState*, GLenum); |
| 941 ScriptValue getWebGLFloatArrayParameter(ScriptState*, GLenum); | 945 ScriptValue getWebGLFloatArrayParameter(ScriptState*, GLenum); |
| 942 ScriptValue getWebGLIntArrayParameter(ScriptState*, GLenum); | 946 ScriptValue getWebGLIntArrayParameter(ScriptState*, GLenum); |
| 943 | 947 |
| 944 // Clear the backbuffer if it was composited since the last operation. | 948 // Clear the backbuffer if it was composited since the last operation. |
| 945 // clearMask is set to the bitfield of any clear that would happen anyway at t
his time | 949 // clearMask is set to the bitfield of any clear that would happen anyway at |
| 946 // and the function returns |CombinedClear| if that clear is now unnecessary. | 950 // this time and the function returns |CombinedClear| if that clear is now |
| 951 // unnecessary. |
| 947 enum HowToClear { | 952 enum HowToClear { |
| 948 // Skip clearing the backbuffer. | 953 // Skip clearing the backbuffer. |
| 949 Skipped, | 954 Skipped, |
| 950 // Clear the backbuffer. | 955 // Clear the backbuffer. |
| 951 JustClear, | 956 JustClear, |
| 952 // Combine webgl.clear() API with the backbuffer clear, so webgl.clear() | 957 // Combine webgl.clear() API with the backbuffer clear, so webgl.clear() |
| 953 // doesn't have to call glClear() again. | 958 // doesn't have to call glClear() again. |
| 954 CombinedClear | 959 CombinedClear |
| 955 }; | 960 }; |
| 956 HowToClear clearIfComposited(GLbitfield clearMask = 0); | 961 HowToClear clearIfComposited(GLbitfield clearMask = 0); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 995 GLint xoffset, | 1000 GLint xoffset, |
| 996 GLint yoffset, | 1001 GLint yoffset, |
| 997 GLint zoffset, | 1002 GLint zoffset, |
| 998 GLenum format, | 1003 GLenum format, |
| 999 GLenum type, | 1004 GLenum type, |
| 1000 Image*, | 1005 Image*, |
| 1001 WebGLImageConversion::ImageHtmlDomSource, | 1006 WebGLImageConversion::ImageHtmlDomSource, |
| 1002 bool flipY, | 1007 bool flipY, |
| 1003 bool premultiplyAlpha); | 1008 bool premultiplyAlpha); |
| 1004 | 1009 |
| 1005 // Copy from the source directly to the texture via the gpu, without a read-ba
ck to system memory. | 1010 // Copy from the source directly to the texture via the gpu, without a |
| 1006 // Souce could be canvas or imageBitmap. | 1011 // read-back to system memory. Souce could be canvas or imageBitmap. |
| 1007 void texImageByGPU(TexImageByGPUType, | 1012 void texImageByGPU(TexImageByGPUType, |
| 1008 WebGLTexture*, | 1013 WebGLTexture*, |
| 1009 GLenum target, | 1014 GLenum target, |
| 1010 GLint level, | 1015 GLint level, |
| 1011 GLint internalformat, | 1016 GLint internalformat, |
| 1012 GLenum type, | 1017 GLenum type, |
| 1013 GLint xoffset, | 1018 GLint xoffset, |
| 1014 GLint yoffset, | 1019 GLint yoffset, |
| 1015 GLint zoffset, | 1020 GLint zoffset, |
| 1016 CanvasImageSource*); | 1021 CanvasImageSource*); |
| 1017 virtual bool canUseTexImageByGPU(TexImageFunctionID, | 1022 virtual bool canUseTexImageByGPU(TexImageFunctionID, |
| 1018 GLint internalformat, | 1023 GLint internalformat, |
| 1019 GLenum type); | 1024 GLenum type); |
| 1020 | 1025 |
| 1021 virtual WebGLImageConversion::PixelStoreParams getPackPixelStoreParams(); | 1026 virtual WebGLImageConversion::PixelStoreParams getPackPixelStoreParams(); |
| 1022 virtual WebGLImageConversion::PixelStoreParams getUnpackPixelStoreParams( | 1027 virtual WebGLImageConversion::PixelStoreParams getUnpackPixelStoreParams( |
| 1023 TexImageDimension); | 1028 TexImageDimension); |
| 1024 | 1029 |
| 1025 // Helper function for copyTex{Sub}Image, check whether the internalformat | 1030 // Helper function for copyTex{Sub}Image, check whether the internalformat |
| 1026 // and the color buffer format of the current bound framebuffer combination | 1031 // and the color buffer format of the current bound framebuffer combination |
| 1027 // is valid. | 1032 // is valid. |
| 1028 bool isTexInternalFormatColorBufferCombinationValid(GLenum texInternalFormat, | 1033 bool isTexInternalFormatColorBufferCombinationValid(GLenum texInternalFormat, |
| 1029 GLenum colorBufferFormat); | 1034 GLenum colorBufferFormat); |
| 1030 | 1035 |
| 1031 // Helper function to verify limits on the length of uniform and attribute loc
ations. | 1036 // Helper function to verify limits on the length of uniform and attribute |
| 1037 // locations. |
| 1032 virtual unsigned getMaxWebGLLocationLength() const { return 256; } | 1038 virtual unsigned getMaxWebGLLocationLength() const { return 256; } |
| 1033 bool validateLocationLength(const char* functionName, const String&); | 1039 bool validateLocationLength(const char* functionName, const String&); |
| 1034 | 1040 |
| 1035 // Helper function to check if size is non-negative. | 1041 // Helper function to check if size is non-negative. |
| 1036 // Generate GL error and return false for negative inputs; otherwise, return t
rue. | 1042 // Generate GL error and return false for negative inputs; otherwise, return |
| 1043 // true. |
| 1037 bool validateSize(const char* functionName, GLint x, GLint y, GLint z = 0); | 1044 bool validateSize(const char* functionName, GLint x, GLint y, GLint z = 0); |
| 1038 | 1045 |
| 1039 // Helper function to check if all characters in the string belong to the | 1046 // Helper function to check if all characters in the string belong to the |
| 1040 // ASCII subset as defined in GLSL ES 1.0 spec section 3.1. | 1047 // ASCII subset as defined in GLSL ES 1.0 spec section 3.1. |
| 1041 bool validateString(const char* functionName, const String&); | 1048 bool validateString(const char* functionName, const String&); |
| 1042 | 1049 |
| 1043 // Helper function to check if all characters in the shader source belong to t
he ASCII | 1050 // Helper function to check if all characters in the shader source belong to |
| 1044 // subset as defined in GLSL ES 1.0 spec section 3.1 Character Set for WebGL 1
.0 and | 1051 // the ASCII subset as defined in GLSL ES 1.0 spec section 3.1 Character Set |
| 1045 // in GLSL ES 3.00 spec section 3.1 Character Set for WebGL 2.0. | 1052 // for WebGL 1.0 and in GLSL ES 3.00 spec section 3.1 Character Set for WebGL |
| 1053 // 2.0. |
| 1046 bool validateShaderSource(const String&); | 1054 bool validateShaderSource(const String&); |
| 1047 | 1055 |
| 1048 // Helper function to check texture binding target and texture bound to the ta
rget. | 1056 // Helper function to check texture binding target and texture bound to the |
| 1049 // Generate GL errors and return 0 if target is invalid or texture bound is | 1057 // target. Generate GL errors and return 0 if target is invalid or texture |
| 1050 // null. Otherwise, return the texture bound to the target. | 1058 // bound is null. Otherwise, return the texture bound to the target. |
| 1051 WebGLTexture* validateTextureBinding(const char* functionName, GLenum target); | 1059 WebGLTexture* validateTextureBinding(const char* functionName, GLenum target); |
| 1052 | 1060 |
| 1053 // Wrapper function for validateTexture2D(3D)Binding, used in texImageHelper f
unctions. | 1061 // Wrapper function for validateTexture2D(3D)Binding, used in texImageHelper |
| 1062 // functions. |
| 1054 virtual WebGLTexture* validateTexImageBinding(const char*, | 1063 virtual WebGLTexture* validateTexImageBinding(const char*, |
| 1055 TexImageFunctionID, | 1064 TexImageFunctionID, |
| 1056 GLenum); | 1065 GLenum); |
| 1057 | 1066 |
| 1058 // Helper function to check texture 2D target and texture bound to the target. | 1067 // Helper function to check texture 2D target and texture bound to the target. |
| 1059 // Generate GL errors and return 0 if target is invalid or texture bound is | 1068 // Generate GL errors and return 0 if target is invalid or texture bound is |
| 1060 // null. Otherwise, return the texture bound to the target. | 1069 // null. Otherwise, return the texture bound to the target. |
| 1061 WebGLTexture* validateTexture2DBinding(const char* functionName, | 1070 WebGLTexture* validateTexture2DBinding(const char* functionName, |
| 1062 GLenum target); | 1071 GLenum target); |
| 1063 | 1072 |
| 1064 void addExtensionSupportedFormatsTypes(); | 1073 void addExtensionSupportedFormatsTypes(); |
| 1065 | 1074 |
| 1066 // Helper function to check input internalformat/format/type for functions Tex
{Sub}Image taking TexImageSource source data. | 1075 // Helper function to check input internalformat/format/type for functions |
| 1067 // Generates GL error and returns false if parameters are invalid. | 1076 // Tex{Sub}Image taking TexImageSource source data. Generates GL error and |
| 1077 // returns false if parameters are invalid. |
| 1068 bool validateTexImageSourceFormatAndType(const char* functionName, | 1078 bool validateTexImageSourceFormatAndType(const char* functionName, |
| 1069 TexImageFunctionType, | 1079 TexImageFunctionType, |
| 1070 GLenum internalformat, | 1080 GLenum internalformat, |
| 1071 GLenum format, | 1081 GLenum format, |
| 1072 GLenum type); | 1082 GLenum type); |
| 1073 | 1083 |
| 1074 // Helper function to check input internalformat/format/type for functions Tex
{Sub}Image. | 1084 // Helper function to check input internalformat/format/type for functions |
| 1075 // Generates GL error and returns false if parameters are invalid. | 1085 // Tex{Sub}Image. Generates GL error and returns false if parameters are |
| 1086 // invalid. |
| 1076 bool validateTexFuncFormatAndType(const char* functionName, | 1087 bool validateTexFuncFormatAndType(const char* functionName, |
| 1077 TexImageFunctionType, | 1088 TexImageFunctionType, |
| 1078 GLenum internalformat, | 1089 GLenum internalformat, |
| 1079 GLenum format, | 1090 GLenum format, |
| 1080 GLenum type, | 1091 GLenum type, |
| 1081 GLint level); | 1092 GLint level); |
| 1082 | 1093 |
| 1083 // Helper function to check readbuffer validity for copyTex{Sub}Image. | 1094 // Helper function to check readbuffer validity for copyTex{Sub}Image. |
| 1084 // If yes, obtains the bound read framebuffer, returns true. | 1095 // If yes, obtains the bound read framebuffer, returns true. |
| 1085 // If not, generates a GL error, returns false. | 1096 // If not, generates a GL error, returns false. |
| 1086 bool validateReadBufferAndGetInfo(const char* functionName, | 1097 bool validateReadBufferAndGetInfo(const char* functionName, |
| 1087 WebGLFramebuffer*& readFramebufferBinding); | 1098 WebGLFramebuffer*& readFramebufferBinding); |
| 1088 | 1099 |
| 1089 // Helper function to check format/type and ArrayBuffer view type for readPixe
ls. | 1100 // Helper function to check format/type and ArrayBuffer view type for |
| 1101 // readPixels. |
| 1090 // Generates INVALID_ENUM and returns false if parameters are invalid. | 1102 // Generates INVALID_ENUM and returns false if parameters are invalid. |
| 1091 // Generates INVALID_OPERATION if ArrayBuffer view type is incompatible with t
ype. | 1103 // Generates INVALID_OPERATION if ArrayBuffer view type is incompatible with |
| 1104 // type. |
| 1092 virtual bool validateReadPixelsFormatAndType(GLenum format, | 1105 virtual bool validateReadPixelsFormatAndType(GLenum format, |
| 1093 GLenum type, | 1106 GLenum type, |
| 1094 DOMArrayBufferView*); | 1107 DOMArrayBufferView*); |
| 1095 | 1108 |
| 1096 // Helper function to check parameters of readPixels. Returns true if all para
meters | 1109 // Helper function to check parameters of readPixels. Returns true if all |
| 1097 // are valid. Otherwise, generates appropriate error and returns false. | 1110 // parameters are valid. Otherwise, generates appropriate error and returns |
| 1111 // false. |
| 1098 bool validateReadPixelsFuncParameters(GLsizei width, | 1112 bool validateReadPixelsFuncParameters(GLsizei width, |
| 1099 GLsizei height, | 1113 GLsizei height, |
| 1100 GLenum format, | 1114 GLenum format, |
| 1101 GLenum type, | 1115 GLenum type, |
| 1102 DOMArrayBufferView*, | 1116 DOMArrayBufferView*, |
| 1103 long long bufferSize); | 1117 long long bufferSize); |
| 1104 | 1118 |
| 1105 virtual GLint getMaxTextureLevelForTarget(GLenum target); | 1119 virtual GLint getMaxTextureLevelForTarget(GLenum target); |
| 1106 | 1120 |
| 1107 // Helper function to check input level for functions {copy}Tex{Sub}Image. | 1121 // Helper function to check input level for functions {copy}Tex{Sub}Image. |
| 1108 // Generates GL error and returns false if level is invalid. | 1122 // Generates GL error and returns false if level is invalid. |
| 1109 bool validateTexFuncLevel(const char* functionName, | 1123 bool validateTexFuncLevel(const char* functionName, |
| 1110 GLenum target, | 1124 GLenum target, |
| 1111 GLint level); | 1125 GLint level); |
| 1112 | 1126 |
| 1113 // Helper function to check if a 64-bit value is non-negative and can fit into
a 32-bit integer. | 1127 // Helper function to check if a 64-bit value is non-negative and can fit into |
| 1114 // Generates GL error and returns false if not. | 1128 // a 32-bit integer. Generates GL error and returns false if not. |
| 1115 bool validateValueFitNonNegInt32(const char* functionName, | 1129 bool validateValueFitNonNegInt32(const char* functionName, |
| 1116 const char* paramName, | 1130 const char* paramName, |
| 1117 long long value); | 1131 long long value); |
| 1118 | 1132 |
| 1119 enum TexFuncValidationSourceType { | 1133 enum TexFuncValidationSourceType { |
| 1120 SourceArrayBufferView, | 1134 SourceArrayBufferView, |
| 1121 SourceImageData, | 1135 SourceImageData, |
| 1122 SourceHTMLImageElement, | 1136 SourceHTMLImageElement, |
| 1123 SourceHTMLCanvasElement, | 1137 SourceHTMLCanvasElement, |
| 1124 SourceHTMLVideoElement, | 1138 SourceHTMLVideoElement, |
| 1125 SourceImageBitmap, | 1139 SourceImageBitmap, |
| 1126 SourceUnpackBuffer, | 1140 SourceUnpackBuffer, |
| 1127 }; | 1141 }; |
| 1128 | 1142 |
| 1129 // Helper function for tex{Sub}Image{2|3}D to check if the input format/type/l
evel/target/width/height/depth/border/xoffset/yoffset/zoffset are valid. | 1143 // Helper function for tex{Sub}Image{2|3}D to check if the input |
| 1130 // Otherwise, it would return quickly without doing other work. | 1144 // format/type/level/target/width/height/depth/border/xoffset/yoffset/zoffset |
| 1145 // are valid. Otherwise, it would return quickly without doing other work. |
| 1131 bool validateTexFunc(const char* functionName, | 1146 bool validateTexFunc(const char* functionName, |
| 1132 TexImageFunctionType, | 1147 TexImageFunctionType, |
| 1133 TexFuncValidationSourceType, | 1148 TexFuncValidationSourceType, |
| 1134 GLenum target, | 1149 GLenum target, |
| 1135 GLint level, | 1150 GLint level, |
| 1136 GLenum internalformat, | 1151 GLenum internalformat, |
| 1137 GLsizei width, | 1152 GLsizei width, |
| 1138 GLsizei height, | 1153 GLsizei height, |
| 1139 GLsizei depth, | 1154 GLsizei depth, |
| 1140 GLint border, | 1155 GLint border, |
| 1141 GLenum format, | 1156 GLenum format, |
| 1142 GLenum type, | 1157 GLenum type, |
| 1143 GLint xoffset, | 1158 GLint xoffset, |
| 1144 GLint yoffset, | 1159 GLint yoffset, |
| 1145 GLint zoffset); | 1160 GLint zoffset); |
| 1146 | 1161 |
| 1147 // Helper function to check input width and height for functions {copy, compre
ssed}Tex{Sub}Image. | 1162 // Helper function to check input width and height for functions {copy, |
| 1148 // Generates GL error and returns false if width or height is invalid. | 1163 // compressed}Tex{Sub}Image. Generates GL error and returns false if width or |
| 1164 // height is invalid. |
| 1149 bool validateTexFuncDimensions(const char* functionName, | 1165 bool validateTexFuncDimensions(const char* functionName, |
| 1150 TexImageFunctionType, | 1166 TexImageFunctionType, |
| 1151 GLenum target, | 1167 GLenum target, |
| 1152 GLint level, | 1168 GLint level, |
| 1153 GLsizei width, | 1169 GLsizei width, |
| 1154 GLsizei height, | 1170 GLsizei height, |
| 1155 GLsizei depth); | 1171 GLsizei depth); |
| 1156 | 1172 |
| 1157 // Helper function to check input parameters for functions {copy}Tex{Sub}Image
. | 1173 // Helper function to check input parameters for functions |
| 1158 // Generates GL error and returns false if parameters are invalid. | 1174 // {copy}Tex{Sub}Image. Generates GL error and returns false if parameters |
| 1175 // are invalid. |
| 1159 bool validateTexFuncParameters(const char* functionName, | 1176 bool validateTexFuncParameters(const char* functionName, |
| 1160 TexImageFunctionType, | 1177 TexImageFunctionType, |
| 1161 TexFuncValidationSourceType, | 1178 TexFuncValidationSourceType, |
| 1162 GLenum target, | 1179 GLenum target, |
| 1163 GLint level, | 1180 GLint level, |
| 1164 GLenum internalformat, | 1181 GLenum internalformat, |
| 1165 GLsizei width, | 1182 GLsizei width, |
| 1166 GLsizei height, | 1183 GLsizei height, |
| 1167 GLsizei depth, | 1184 GLsizei depth, |
| 1168 GLint border, | 1185 GLint border, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1191 // copyTexSubImage2D. | 1208 // copyTexSubImage2D. |
| 1192 // Generates GL error and returns false if the format is not settable. | 1209 // Generates GL error and returns false if the format is not settable. |
| 1193 bool validateSettableTexFormat(const char* functionName, GLenum format); | 1210 bool validateSettableTexFormat(const char* functionName, GLenum format); |
| 1194 | 1211 |
| 1195 // Helper function to validate format for CopyTexImage. | 1212 // Helper function to validate format for CopyTexImage. |
| 1196 bool validateCopyTexFormat(const char* functionName, GLenum format); | 1213 bool validateCopyTexFormat(const char* functionName, GLenum format); |
| 1197 | 1214 |
| 1198 // Helper function for validating compressed texture formats. | 1215 // Helper function for validating compressed texture formats. |
| 1199 bool validateCompressedTexFormat(const char* functionName, GLenum format); | 1216 bool validateCompressedTexFormat(const char* functionName, GLenum format); |
| 1200 | 1217 |
| 1201 // Helper function to validate if front/back stencilMask and stencilFunc setti
ngs are the same. | 1218 // Helper function to validate if front/back stencilMask and stencilFunc |
| 1219 // settings are the same. |
| 1202 bool validateStencilSettings(const char* functionName); | 1220 bool validateStencilSettings(const char* functionName); |
| 1203 | 1221 |
| 1204 // Helper function to validate stencil or depth func. | 1222 // Helper function to validate stencil or depth func. |
| 1205 bool validateStencilOrDepthFunc(const char* functionName, GLenum); | 1223 bool validateStencilOrDepthFunc(const char* functionName, GLenum); |
| 1206 | 1224 |
| 1207 // Helper function for texParameterf and texParameteri. | 1225 // Helper function for texParameterf and texParameteri. |
| 1208 void texParameter(GLenum target, | 1226 void texParameter(GLenum target, |
| 1209 GLenum pname, | 1227 GLenum pname, |
| 1210 GLfloat paramf, | 1228 GLfloat paramf, |
| 1211 GLint parami, | 1229 GLint parami, |
| 1212 bool isFloat); | 1230 bool isFloat); |
| 1213 | 1231 |
| 1214 // Helper function to print GL errors to console. | 1232 // Helper function to print GL errors to console. |
| 1215 void printGLErrorToConsole(const String&); | 1233 void printGLErrorToConsole(const String&); |
| 1216 | 1234 |
| 1217 // Helper function to print warnings to console. Currently | 1235 // Helper function to print warnings to console. Currently |
| 1218 // used only to warn about use of obsolete functions. | 1236 // used only to warn about use of obsolete functions. |
| 1219 void printWarningToConsole(const String&); | 1237 void printWarningToConsole(const String&); |
| 1220 | 1238 |
| 1221 // Helper function to validate the target for checkFramebufferStatus and valid
ateFramebufferFuncParameters. | 1239 // Helper function to validate the target for checkFramebufferStatus and |
| 1240 // validateFramebufferFuncParameters. |
| 1222 virtual bool validateFramebufferTarget(GLenum target); | 1241 virtual bool validateFramebufferTarget(GLenum target); |
| 1223 | 1242 |
| 1224 // Get the framebuffer bound to given target | 1243 // Get the framebuffer bound to given target |
| 1225 virtual WebGLFramebuffer* getFramebufferBinding(GLenum target); | 1244 virtual WebGLFramebuffer* getFramebufferBinding(GLenum target); |
| 1226 | 1245 |
| 1227 virtual WebGLFramebuffer* getReadFramebufferBinding(); | 1246 virtual WebGLFramebuffer* getReadFramebufferBinding(); |
| 1228 | 1247 |
| 1229 // Helper function to validate input parameters for framebuffer functions. | 1248 // Helper function to validate input parameters for framebuffer functions. |
| 1230 // Generate GL error if parameters are illegal. | 1249 // Generate GL error if parameters are illegal. |
| 1231 bool validateFramebufferFuncParameters(const char* functionName, | 1250 bool validateFramebufferFuncParameters(const char* functionName, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1277 GLsizei requiredMinSize) { | 1296 GLsizei requiredMinSize) { |
| 1278 if (!v.dataMaybeOnStack()) { | 1297 if (!v.dataMaybeOnStack()) { |
| 1279 synthesizeGLError(GL_INVALID_VALUE, functionName, "no array"); | 1298 synthesizeGLError(GL_INVALID_VALUE, functionName, "no array"); |
| 1280 return false; | 1299 return false; |
| 1281 } | 1300 } |
| 1282 return validateUniformMatrixParameters(functionName, location, false, | 1301 return validateUniformMatrixParameters(functionName, location, false, |
| 1283 v.dataMaybeOnStack(), v.length(), | 1302 v.dataMaybeOnStack(), v.length(), |
| 1284 requiredMinSize); | 1303 requiredMinSize); |
| 1285 } | 1304 } |
| 1286 | 1305 |
| 1287 // Helper function to validate the target for bufferData and getBufferParamete
r. | 1306 // Helper function to validate the target for bufferData and |
| 1307 // getBufferParameter. |
| 1288 virtual bool validateBufferTarget(const char* functionName, GLenum target); | 1308 virtual bool validateBufferTarget(const char* functionName, GLenum target); |
| 1289 | 1309 |
| 1290 // Helper function to validate the target for bufferData. | 1310 // Helper function to validate the target for bufferData. |
| 1291 // Return the current bound buffer to target, or 0 if the target is invalid. | 1311 // Return the current bound buffer to target, or 0 if the target is invalid. |
| 1292 virtual WebGLBuffer* validateBufferDataTarget(const char* functionName, | 1312 virtual WebGLBuffer* validateBufferDataTarget(const char* functionName, |
| 1293 GLenum target); | 1313 GLenum target); |
| 1294 // Helper function to validate the usage for bufferData. | 1314 // Helper function to validate the usage for bufferData. |
| 1295 virtual bool validateBufferDataUsage(const char* functionName, GLenum usage); | 1315 virtual bool validateBufferDataUsage(const char* functionName, GLenum usage); |
| 1296 | 1316 |
| 1297 virtual bool validateAndUpdateBufferBindTarget(const char* functionName, | 1317 virtual bool validateAndUpdateBufferBindTarget(const char* functionName, |
| 1298 GLenum target, | 1318 GLenum target, |
| 1299 WebGLBuffer*); | 1319 WebGLBuffer*); |
| 1300 | 1320 |
| 1301 virtual void removeBoundBuffer(WebGLBuffer*); | 1321 virtual void removeBoundBuffer(WebGLBuffer*); |
| 1302 | 1322 |
| 1303 // Helper function for tex{Sub}Image2D to make sure image is ready and wouldn'
t taint Origin. | 1323 // Helper function for tex{Sub}Image2D to make sure image is ready and |
| 1324 // wouldn't taint Origin. |
| 1304 bool validateHTMLImageElement(const char* functionName, | 1325 bool validateHTMLImageElement(const char* functionName, |
| 1305 HTMLImageElement*, | 1326 HTMLImageElement*, |
| 1306 ExceptionState&); | 1327 ExceptionState&); |
| 1307 | 1328 |
| 1308 // Helper function for tex{Sub}Image2D to make sure canvas is ready and wouldn
't taint Origin. | 1329 // Helper function for tex{Sub}Image2D to make sure canvas is ready and |
| 1330 // wouldn't taint Origin. |
| 1309 bool validateHTMLCanvasElement(const char* functionName, | 1331 bool validateHTMLCanvasElement(const char* functionName, |
| 1310 HTMLCanvasElement*, | 1332 HTMLCanvasElement*, |
| 1311 ExceptionState&); | 1333 ExceptionState&); |
| 1312 | 1334 |
| 1313 // Helper function for tex{Sub}Image2D to make sure video is ready wouldn't ta
int Origin. | 1335 // Helper function for tex{Sub}Image2D to make sure video is ready wouldn't |
| 1336 // taint Origin. |
| 1314 bool validateHTMLVideoElement(const char* functionName, | 1337 bool validateHTMLVideoElement(const char* functionName, |
| 1315 HTMLVideoElement*, | 1338 HTMLVideoElement*, |
| 1316 ExceptionState&); | 1339 ExceptionState&); |
| 1317 | 1340 |
| 1318 // Helper function for tex{Sub}Image2D to make sure imagebitmap is ready and w
ouldn't taint Origin. | 1341 // Helper function for tex{Sub}Image2D to make sure imagebitmap is ready and |
| 1342 // wouldn't taint Origin. |
| 1319 bool validateImageBitmap(const char* functionName, | 1343 bool validateImageBitmap(const char* functionName, |
| 1320 ImageBitmap*, | 1344 ImageBitmap*, |
| 1321 ExceptionState&); | 1345 ExceptionState&); |
| 1322 | 1346 |
| 1323 // Helper function to validate drawArrays(Instanced) calls | 1347 // Helper function to validate drawArrays(Instanced) calls |
| 1324 bool validateDrawArrays(const char* functionName); | 1348 bool validateDrawArrays(const char* functionName); |
| 1325 | 1349 |
| 1326 // Helper function to validate drawElements(Instanced) calls | 1350 // Helper function to validate drawElements(Instanced) calls |
| 1327 bool validateDrawElements(const char* functionName, | 1351 bool validateDrawElements(const char* functionName, |
| 1328 GLenum type, | 1352 GLenum type, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1368 // Enable or disable stencil test based on user setting and | 1392 // Enable or disable stencil test based on user setting and |
| 1369 // whether the current FBO has a stencil buffer. | 1393 // whether the current FBO has a stencil buffer. |
| 1370 void applyStencilTest(); | 1394 void applyStencilTest(); |
| 1371 | 1395 |
| 1372 // Helper for enabling or disabling a capability. | 1396 // Helper for enabling or disabling a capability. |
| 1373 void enableOrDisable(GLenum capability, bool enable); | 1397 void enableOrDisable(GLenum capability, bool enable); |
| 1374 | 1398 |
| 1375 // Clamp the width and height to GL_MAX_VIEWPORT_DIMS. | 1399 // Clamp the width and height to GL_MAX_VIEWPORT_DIMS. |
| 1376 IntSize clampedCanvasSize() const; | 1400 IntSize clampedCanvasSize() const; |
| 1377 | 1401 |
| 1378 // First time called, if EXT_draw_buffers is supported, query the value; other
wise return 0. | 1402 // First time called, if EXT_draw_buffers is supported, query the value; |
| 1379 // Later, return the cached value. | 1403 // otherwise return 0. Later, return the cached value. |
| 1380 GLint maxDrawBuffers(); | 1404 GLint maxDrawBuffers(); |
| 1381 GLint maxColorAttachments(); | 1405 GLint maxColorAttachments(); |
| 1382 | 1406 |
| 1383 void setBackDrawBuffer(GLenum); | 1407 void setBackDrawBuffer(GLenum); |
| 1384 void setFramebuffer(GLenum, WebGLFramebuffer*); | 1408 void setFramebuffer(GLenum, WebGLFramebuffer*); |
| 1385 | 1409 |
| 1386 virtual void restoreCurrentFramebuffer(); | 1410 virtual void restoreCurrentFramebuffer(); |
| 1387 void restoreCurrentTexture2D(); | 1411 void restoreCurrentTexture2D(); |
| 1388 | 1412 |
| 1389 void findNewMaxNonDefaultTextureUnit(); | 1413 void findNewMaxNonDefaultTextureUnit(); |
| 1390 | 1414 |
| 1391 virtual void renderbufferStorageImpl(GLenum target, | 1415 virtual void renderbufferStorageImpl(GLenum target, |
| 1392 GLsizei samples, | 1416 GLsizei samples, |
| 1393 GLenum internalformat, | 1417 GLenum internalformat, |
| 1394 GLsizei width, | 1418 GLsizei width, |
| 1395 GLsizei height, | 1419 GLsizei height, |
| 1396 const char* functionName); | 1420 const char* functionName); |
| 1397 | 1421 |
| 1398 friend class WebGLStateRestorer; | 1422 friend class WebGLStateRestorer; |
| 1399 friend class WebGLRenderingContextEvictionManager; | 1423 friend class WebGLRenderingContextEvictionManager; |
| 1400 | 1424 |
| 1401 static void activateContext(WebGLRenderingContextBase*); | 1425 static void activateContext(WebGLRenderingContextBase*); |
| 1402 static void deactivateContext(WebGLRenderingContextBase*); | 1426 static void deactivateContext(WebGLRenderingContextBase*); |
| 1403 static void addToEvictedList(WebGLRenderingContextBase*); | 1427 static void addToEvictedList(WebGLRenderingContextBase*); |
| 1404 static void removeFromEvictedList(WebGLRenderingContextBase*); | 1428 static void removeFromEvictedList(WebGLRenderingContextBase*); |
| 1405 static void willDestroyContext(WebGLRenderingContextBase*); | 1429 static void willDestroyContext(WebGLRenderingContextBase*); |
| 1406 static void forciblyLoseOldestContext(const String& reason); | 1430 static void forciblyLoseOldestContext(const String& reason); |
| 1407 // Return the least recently used context's position in the active context vec
tor. | 1431 // Return the least recently used context's position in the active context |
| 1408 // If the vector is empty, return the maximum allowed active context number. | 1432 // vector. If the vector is empty, return the maximum allowed active context |
| 1433 // number. |
| 1409 static WebGLRenderingContextBase* oldestContext(); | 1434 static WebGLRenderingContextBase* oldestContext(); |
| 1410 static WebGLRenderingContextBase* oldestEvictedContext(); | 1435 static WebGLRenderingContextBase* oldestEvictedContext(); |
| 1411 | 1436 |
| 1412 ImageBitmap* transferToImageBitmapBase(); | 1437 ImageBitmap* transferToImageBitmapBase(); |
| 1413 | 1438 |
| 1414 // Helper functions for tex(Sub)Image2D && texSubImage3D | 1439 // Helper functions for tex(Sub)Image2D && texSubImage3D |
| 1415 void texImageHelperDOMArrayBufferView(TexImageFunctionID, | 1440 void texImageHelperDOMArrayBufferView(TexImageFunctionID, |
| 1416 GLenum, | 1441 GLenum, |
| 1417 GLint, | 1442 GLint, |
| 1418 GLint, | 1443 GLint, |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1510 context, | 1535 context, |
| 1511 context->is3d(), | 1536 context->is3d(), |
| 1512 context.is3d()); | 1537 context.is3d()); |
| 1513 | 1538 |
| 1514 } // namespace blink | 1539 } // namespace blink |
| 1515 | 1540 |
| 1516 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS( | 1541 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS( |
| 1517 blink::WebGLRenderingContextBase::TextureUnitState); | 1542 blink::WebGLRenderingContextBase::TextureUnitState); |
| 1518 | 1543 |
| 1519 #endif // WebGLRenderingContextBase_h | 1544 #endif // WebGLRenderingContextBase_h |
| OLD | NEW |