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 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 CombinedClear | 762 CombinedClear |
763 }; | 763 }; |
764 HowToClear clearIfComposited(GLbitfield clearMask = 0); | 764 HowToClear clearIfComposited(GLbitfield clearMask = 0); |
765 | 765 |
766 // Helper to restore state that clearing the framebuffer may destroy. | 766 // Helper to restore state that clearing the framebuffer may destroy. |
767 void restoreStateAfterClear(); | 767 void restoreStateAfterClear(); |
768 | 768 |
769 // Convert texture internal format. | 769 // Convert texture internal format. |
770 GLenum convertTexInternalFormat(GLenum internalformat, GLenum type); | 770 GLenum convertTexInternalFormat(GLenum internalformat, GLenum type); |
771 | 771 |
772 void texImage2DBase(GLenum target, GLint level, GLint internalformat, GLsize
i width, GLsizei height, GLint border, GLenum format, GLenum type, const void* p
ixels); | |
773 void texImage2DImpl(GLenum target, GLint level, GLint internalformat, GLenum
format, GLenum type, Image*, WebGLImageConversion::ImageHtmlDomSource, bool fli
pY, bool premultiplyAlpha); | |
774 void texSubImage2DBase(GLenum target, GLint level, GLint xoffset, GLint yoff
set, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixe
ls); | |
775 void texSubImage2DImpl(GLenum target, GLint level, GLint xoffset, GLint yoff
set, GLenum format, GLenum type, Image*, WebGLImageConversion::ImageHtmlDomSourc
e, bool flipY, bool premultiplyAlpha); | |
776 | |
777 enum TexImageFunctionType { | 772 enum TexImageFunctionType { |
778 TexImage, | 773 TexImage, |
779 TexSubImage, | 774 TexSubImage, |
780 CopyTexImage, | 775 CopyTexImage, |
781 CompressedTexImage | 776 CompressedTexImage |
782 }; | 777 }; |
| 778 enum TexImageFunctionID { |
| 779 TexImage2D, |
| 780 TexSubImage2D, |
| 781 TexImage3D, |
| 782 TexSubImage3D |
| 783 }; |
783 enum TexImageByGPUType { | 784 enum TexImageByGPUType { |
784 TexImage2DByGPU, | 785 TexImage2DByGPU, |
785 TexSubImage2DByGPU, | 786 TexSubImage2DByGPU, |
786 TexSubImage3DByGPU | 787 TexSubImage3DByGPU |
787 }; | 788 }; |
788 enum TexImageDimension { | 789 enum TexImageDimension { |
789 Tex2D, | 790 Tex2D, |
790 Tex3D | 791 Tex3D |
791 }; | 792 }; |
| 793 void texImage2DBase(GLenum target, GLint level, GLint internalformat, GLsize
i width, GLsizei height, GLint border, GLenum format, GLenum type, const void* p
ixels); |
| 794 void texImageImpl(TexImageFunctionID, GLenum target, GLint level, GLint inte
rnalformat, GLint xoffset, GLint yoffset, GLint zoffset, |
| 795 GLenum format, GLenum type, Image*, WebGLImageConversion::ImageHtmlDomSo
urce, bool flipY, bool premultiplyAlpha); |
| 796 |
792 // Copy from the canvas element directly to the texture via the GPU, without
a read-back to system memory. | 797 // Copy from the canvas element directly to the texture via the GPU, without
a read-back to system memory. |
793 void texImageCanvasByGPU(TexImageByGPUType, WebGLTexture*, GLenum target, GL
int level, | 798 void texImageCanvasByGPU(TexImageByGPUType, WebGLTexture*, GLenum target, GL
int level, |
794 GLint internalformat, GLenum type, GLint xoffset, GLint yoffset, GLint z
offset, HTMLCanvasElement*); | 799 GLint internalformat, GLenum type, GLint xoffset, GLint yoffset, GLint z
offset, HTMLCanvasElement*); |
795 virtual bool canUseTexImageCanvasByGPU(GLint internalformat, GLenum type); | 800 virtual bool canUseTexImageCanvasByGPU(GLint internalformat, GLenum type); |
796 | 801 |
797 virtual WebGLImageConversion::PixelStoreParams getPackPixelStoreParams(); | 802 virtual WebGLImageConversion::PixelStoreParams getPackPixelStoreParams(); |
798 virtual WebGLImageConversion::PixelStoreParams getUnpackPixelStoreParams(Tex
ImageDimension); | 803 virtual WebGLImageConversion::PixelStoreParams getUnpackPixelStoreParams(Tex
ImageDimension); |
799 | 804 |
800 // Helper function for copyTex{Sub}Image, check whether the internalformat | 805 // Helper function for copyTex{Sub}Image, check whether the internalformat |
801 // and the color buffer format of the current bound framebuffer combination | 806 // and the color buffer format of the current bound framebuffer combination |
(...skipping 10 matching lines...) Expand all Loading... |
812 | 817 |
813 // Helper function to check if all characters in the string belong to the | 818 // Helper function to check if all characters in the string belong to the |
814 // ASCII subset as defined in GLSL ES 1.0 spec section 3.1. | 819 // ASCII subset as defined in GLSL ES 1.0 spec section 3.1. |
815 bool validateString(const char* functionName, const String&); | 820 bool validateString(const char* functionName, const String&); |
816 | 821 |
817 // Helper function to check texture binding target and texture bound to the
target. | 822 // Helper function to check texture binding target and texture bound to the
target. |
818 // Generate GL errors and return 0 if target is invalid or texture bound is | 823 // Generate GL errors and return 0 if target is invalid or texture bound is |
819 // null. Otherwise, return the texture bound to the target. | 824 // null. Otherwise, return the texture bound to the target. |
820 WebGLTexture* validateTextureBinding(const char* functionName, GLenum target
); | 825 WebGLTexture* validateTextureBinding(const char* functionName, GLenum target
); |
821 | 826 |
| 827 // Wrapper function for validateTexture2D(3D)Binding, used in texImageHelper
functions. |
| 828 virtual WebGLTexture* validateTexImageBinding(const char*, TexImageFunctionI
D, GLenum); |
| 829 |
822 // Helper function to check texture 2D target and texture bound to the targe
t. | 830 // Helper function to check texture 2D target and texture bound to the targe
t. |
823 // Generate GL errors and return 0 if target is invalid or texture bound is | 831 // Generate GL errors and return 0 if target is invalid or texture bound is |
824 // null. Otherwise, return the texture bound to the target. | 832 // null. Otherwise, return the texture bound to the target. |
825 WebGLTexture* validateTexture2DBinding(const char* functionName, GLenum targ
et); | 833 WebGLTexture* validateTexture2DBinding(const char* functionName, GLenum targ
et); |
826 | 834 |
827 // Helper function to check input internalformat/format/type for functions {
copy}Tex{Sub}Image. | 835 // Helper function to check input internalformat/format/type for functions {
copy}Tex{Sub}Image. |
828 // Generates GL error and returns false if parameters are invalid. | 836 // Generates GL error and returns false if parameters are invalid. |
829 bool validateTexFuncFormatAndType(const char* functionName, TexImageFunction
Type, GLenum internalformat, GLenum format, GLenum type, GLint level); | 837 bool validateTexFuncFormatAndType(const char* functionName, TexImageFunction
Type, GLenum internalformat, GLenum format, GLenum type, GLint level); |
830 | 838 |
831 // Helper function to check readbuffer validity for copyTex{Sub}Image. | 839 // Helper function to check readbuffer validity for copyTex{Sub}Image. |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1081 static void willDestroyContext(WebGLRenderingContextBase*); | 1089 static void willDestroyContext(WebGLRenderingContextBase*); |
1082 static void forciblyLoseOldestContext(const String& reason); | 1090 static void forciblyLoseOldestContext(const String& reason); |
1083 // Return the least recently used context's position in the active context v
ector. | 1091 // Return the least recently used context's position in the active context v
ector. |
1084 // If the vector is empty, return the maximum allowed active context number. | 1092 // If the vector is empty, return the maximum allowed active context number. |
1085 static WebGLRenderingContextBase* oldestContext(); | 1093 static WebGLRenderingContextBase* oldestContext(); |
1086 static WebGLRenderingContextBase* oldestEvictedContext(); | 1094 static WebGLRenderingContextBase* oldestEvictedContext(); |
1087 | 1095 |
1088 CrossThreadWeakPersistentThisPointer<WebGLRenderingContextBase> createWeakTh
isPointer() { return CrossThreadWeakPersistentThisPointer<WebGLRenderingContextB
ase>(this); } | 1096 CrossThreadWeakPersistentThisPointer<WebGLRenderingContextBase> createWeakTh
isPointer() { return CrossThreadWeakPersistentThisPointer<WebGLRenderingContextB
ase>(this); } |
1089 | 1097 |
1090 ImageBitmap* transferToImageBitmapBase(); | 1098 ImageBitmap* transferToImageBitmapBase(); |
| 1099 |
| 1100 // Helper functions for tex(Sub)Image2D && texSubImage3D |
| 1101 void texImageHelperDOMArrayBufferView(TexImageFunctionID, GLenum, GLint, GLi
nt, GLsizei, GLsizei, GLint, GLenum, GLenum, GLsizei, GLint, GLint, GLint, DOMAr
rayBufferView*); |
| 1102 void texImageHelperImageData(TexImageFunctionID, GLenum, GLint, GLint, GLint
, GLenum, GLenum, GLsizei, GLint, GLint, GLint, ImageData*); |
| 1103 void texImageHelperHTMLImageElement(TexImageFunctionID, GLenum, GLint, GLint
, GLenum, GLenum, GLint, GLint, GLint, HTMLImageElement*, ExceptionState&); |
| 1104 void texImageHelperHTMLCanvasElement(TexImageFunctionID, GLenum, GLint, GLin
t, GLenum, GLenum, GLint, GLint, GLint, HTMLCanvasElement*, ExceptionState&); |
| 1105 void texImageHelperHTMLVideoElement(TexImageFunctionID, GLenum, GLint, GLint
, GLenum, GLenum, GLint, GLint, GLint, HTMLVideoElement*, ExceptionState&); |
| 1106 void texImageHelperImageBitmap(TexImageFunctionID, GLenum, GLint, GLint, GLe
num, GLenum, GLint, GLint, GLint, ImageBitmap*, ExceptionState&); |
| 1107 static const char* getTexImageFunctionName(TexImageFunctionID); |
| 1108 |
1091 private: | 1109 private: |
1092 WebGLRenderingContextBase(HTMLCanvasElement*, OffscreenCanvas*, PassOwnPtr<W
ebGraphicsContext3DProvider>, const WebGLContextAttributes&); | 1110 WebGLRenderingContextBase(HTMLCanvasElement*, OffscreenCanvas*, PassOwnPtr<W
ebGraphicsContext3DProvider>, const WebGLContextAttributes&); |
1093 static PassOwnPtr<WebGraphicsContext3DProvider> createContextProviderInterna
l(HTMLCanvasElement*, ScriptState*, WebGLContextAttributes, unsigned); | 1111 static PassOwnPtr<WebGraphicsContext3DProvider> createContextProviderInterna
l(HTMLCanvasElement*, ScriptState*, WebGLContextAttributes, unsigned); |
1094 }; | 1112 }; |
1095 | 1113 |
1096 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co
ntext->is3d(), context.is3d()); | 1114 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co
ntext->is3d(), context.is3d()); |
1097 | 1115 |
1098 } // namespace blink | 1116 } // namespace blink |
1099 | 1117 |
1100 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(blink::WebGLRenderingContextB
ase::TextureUnitState); | 1118 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(blink::WebGLRenderingContextB
ase::TextureUnitState); |
1101 | 1119 |
1102 #endif // WebGLRenderingContextBase_h | 1120 #endif // WebGLRenderingContextBase_h |
OLD | NEW |