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 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 void restoreStateAfterClear(); | 724 void restoreStateAfterClear(); |
725 | 725 |
726 // Convert texture internal format. | 726 // Convert texture internal format. |
727 GLenum convertTexInternalFormat(GLenum internalformat, GLenum type); | 727 GLenum convertTexInternalFormat(GLenum internalformat, GLenum type); |
728 | 728 |
729 void texImage2DBase(GLenum target, GLint level, GLenum internalformat, GLsiz
ei width, GLsizei height, GLint border, GLenum format, GLenum type, const void*
pixels, ExceptionState&); | 729 void texImage2DBase(GLenum target, GLint level, GLenum internalformat, GLsiz
ei width, GLsizei height, GLint border, GLenum format, GLenum type, const void*
pixels, ExceptionState&); |
730 void texImage2DImpl(GLenum target, GLint level, GLenum internalformat, GLenu
m format, GLenum type, Image*, WebGLImageConversion::ImageHtmlDomSource, bool fl
ipY, bool premultiplyAlpha, ExceptionState&); | 730 void texImage2DImpl(GLenum target, GLint level, GLenum internalformat, GLenu
m format, GLenum type, Image*, WebGLImageConversion::ImageHtmlDomSource, bool fl
ipY, bool premultiplyAlpha, ExceptionState&); |
731 void texSubImage2DBase(GLenum target, GLint level, GLint xoffset, GLint yoff
set, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixe
ls, ExceptionState&); | 731 void texSubImage2DBase(GLenum target, GLint level, GLint xoffset, GLint yoff
set, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixe
ls, ExceptionState&); |
732 void texSubImage2DImpl(GLenum target, GLint level, GLint xoffset, GLint yoff
set, GLenum format, GLenum type, Image*, WebGLImageConversion::ImageHtmlDomSourc
e, bool flipY, bool premultiplyAlpha, ExceptionState&); | 732 void texSubImage2DImpl(GLenum target, GLint level, GLint xoffset, GLint yoff
set, GLenum format, GLenum type, Image*, WebGLImageConversion::ImageHtmlDomSourc
e, bool flipY, bool premultiplyAlpha, ExceptionState&); |
733 | 733 |
| 734 enum TexImageFunctionType { |
| 735 NotTexSubImage2D, |
| 736 TexSubImage2D, |
| 737 }; |
| 738 // Copy from the canvas element directly to the texture via the GPU, without
a read-back to system memory. |
| 739 void texImage2DCanvasByGPU(TexImageFunctionType, WebGLTexture*, GLenum targe
t, GLint level, |
| 740 GLenum internalformat, GLenum type, GLint xoffset, GLint yoffset, HTMLCa
nvasElement*); |
| 741 |
734 void handleTextureCompleteness(const char*, bool); | 742 void handleTextureCompleteness(const char*, bool); |
735 void createFallbackBlackTextures1x1(); | 743 void createFallbackBlackTextures1x1(); |
736 | 744 |
737 // Helper function for copyTex{Sub}Image, check whether the internalformat | 745 // Helper function for copyTex{Sub}Image, check whether the internalformat |
738 // and the color buffer format of the current bound framebuffer combination | 746 // and the color buffer format of the current bound framebuffer combination |
739 // is valid. | 747 // is valid. |
740 bool isTexInternalFormatColorBufferCombinationValid(GLenum texInternalFormat
, GLenum colorBufferFormat); | 748 bool isTexInternalFormatColorBufferCombinationValid(GLenum texInternalFormat
, GLenum colorBufferFormat); |
741 | 749 |
742 // Helper function to get the bound framebuffer's color buffer format. | 750 // Helper function to get the bound framebuffer's color buffer format. |
743 GLenum boundFramebufferColorFormat(); | 751 GLenum boundFramebufferColorFormat(); |
(...skipping 19 matching lines...) Expand all Loading... |
763 bool validateTexFuncFormatAndType(const char* functionName, GLenum format, G
Lenum type, GLint level); | 771 bool validateTexFuncFormatAndType(const char* functionName, GLenum format, G
Lenum type, GLint level); |
764 | 772 |
765 // Helper function to check input level for functions {copy}Tex{Sub}Image. | 773 // Helper function to check input level for functions {copy}Tex{Sub}Image. |
766 // Generates GL error and returns false if level is invalid. | 774 // Generates GL error and returns false if level is invalid. |
767 bool validateTexFuncLevel(const char* functionName, GLenum target, GLint lev
el); | 775 bool validateTexFuncLevel(const char* functionName, GLenum target, GLint lev
el); |
768 | 776 |
769 // Helper function to check if a 64-bit value is non-negative and can fit in
to a 32-bit integer. | 777 // Helper function to check if a 64-bit value is non-negative and can fit in
to a 32-bit integer. |
770 // Generates GL error and returns false if not. | 778 // Generates GL error and returns false if not. |
771 bool validateValueFitNonNegInt32(const char* functionName, const char* param
Name, long long value); | 779 bool validateValueFitNonNegInt32(const char* functionName, const char* param
Name, long long value); |
772 | 780 |
773 enum TexFuncValidationFunctionType { | |
774 NotTexSubImage2D, | |
775 TexSubImage2D, | |
776 }; | |
777 | |
778 enum TexFuncValidationSourceType { | 781 enum TexFuncValidationSourceType { |
779 SourceArrayBufferView, | 782 SourceArrayBufferView, |
780 SourceImageData, | 783 SourceImageData, |
781 SourceHTMLImageElement, | 784 SourceHTMLImageElement, |
782 SourceHTMLCanvasElement, | 785 SourceHTMLCanvasElement, |
783 SourceHTMLVideoElement, | 786 SourceHTMLVideoElement, |
784 }; | 787 }; |
785 | 788 |
786 // Helper function for tex{Sub}Image2D to check if the input format/type/lev
el/target/width/height/border/xoffset/yoffset are valid. | 789 // Helper function for tex{Sub}Image2D to check if the input format/type/lev
el/target/width/height/border/xoffset/yoffset are valid. |
787 // Otherwise, it would return quickly without doing other work. | 790 // Otherwise, it would return quickly without doing other work. |
788 bool validateTexFunc(const char* functionName, TexFuncValidationFunctionType
, TexFuncValidationSourceType, GLenum target, GLint level, GLenum internalformat
, GLsizei width, | 791 bool validateTexFunc(const char* functionName, TexImageFunctionType, TexFunc
ValidationSourceType, GLenum target, GLint level, GLenum internalformat, GLsizei
width, |
789 GLsizei height, GLint border, GLenum format, GLenum type, GLint xoffset,
GLint yoffset); | 792 GLsizei height, GLint border, GLenum format, GLenum type, GLint xoffset,
GLint yoffset); |
790 | 793 |
791 // Helper function to check input width and height for functions {copy, comp
ressed}Tex{Sub}Image. | 794 // Helper function to check input width and height for functions {copy, comp
ressed}Tex{Sub}Image. |
792 // Generates GL error and returns false if width or height is invalid. | 795 // Generates GL error and returns false if width or height is invalid. |
793 bool validateTexFuncDimensions(const char* functionName, TexFuncValidationFu
nctionType, GLenum target, GLint level, GLsizei width, GLsizei height); | 796 bool validateTexFuncDimensions(const char* functionName, TexImageFunctionTyp
e, GLenum target, GLint level, GLsizei width, GLsizei height); |
794 | 797 |
795 // Helper function to check input parameters for functions {copy}Tex{Sub}Ima
ge. | 798 // Helper function to check input parameters for functions {copy}Tex{Sub}Ima
ge. |
796 // Generates GL error and returns false if parameters are invalid. | 799 // Generates GL error and returns false if parameters are invalid. |
797 bool validateTexFuncParameters(const char* functionName, TexFuncValidationFu
nctionType, GLenum target, GLint level, GLenum internalformat, GLsizei width, GL
sizei height, GLint border, GLenum format, GLenum type); | 800 bool validateTexFuncParameters(const char* functionName, TexImageFunctionTyp
e, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei hei
ght, GLint border, GLenum format, GLenum type); |
798 | 801 |
799 enum NullDisposition { | 802 enum NullDisposition { |
800 NullAllowed, | 803 NullAllowed, |
801 NullNotAllowed | 804 NullNotAllowed |
802 }; | 805 }; |
803 | 806 |
804 // Helper function to validate that the given ArrayBufferView | 807 // Helper function to validate that the given ArrayBufferView |
805 // is of the correct type and contains enough data for the texImage call. | 808 // is of the correct type and contains enough data for the texImage call. |
806 // Generates GL error and returns false if parameters are invalid. | 809 // Generates GL error and returns false if parameters are invalid. |
807 bool validateTexFuncData(const char* functionName, GLint level, GLsizei widt
h, GLsizei height, GLenum format, GLenum type, DOMArrayBufferView* pixels, NullD
isposition); | 810 bool validateTexFuncData(const char* functionName, GLint level, GLsizei widt
h, GLsizei height, GLenum format, GLenum type, DOMArrayBufferView* pixels, NullD
isposition); |
808 | 811 |
809 // Helper function to validate a given texture format is settable as in | 812 // Helper function to validate a given texture format is settable as in |
810 // you can supply data to texImage2D, or call texImage2D, copyTexImage2D and | 813 // you can supply data to texImage2D, or call texImage2D, copyTexImage2D and |
811 // copyTexSubImage2D. | 814 // copyTexSubImage2D. |
812 // Generates GL error and returns false if the format is not settable. | 815 // Generates GL error and returns false if the format is not settable. |
813 bool validateSettableTexFormat(const char* functionName, GLenum format); | 816 bool validateSettableTexFormat(const char* functionName, GLenum format); |
814 | 817 |
815 // Helper function to validate compressed texture data is correct size | 818 // Helper function to validate compressed texture data is correct size |
816 // for the given format and dimensions. | 819 // for the given format and dimensions. |
817 bool validateCompressedTexFuncData(const char* functionName, GLsizei width,
GLsizei height, GLenum format, DOMArrayBufferView* pixels); | 820 bool validateCompressedTexFuncData(const char* functionName, GLsizei width,
GLsizei height, GLenum format, DOMArrayBufferView* pixels); |
818 | 821 |
819 // Helper function for validating compressed texture formats. | 822 // Helper function for validating compressed texture formats. |
820 bool validateCompressedTexFormat(GLenum format); | 823 bool validateCompressedTexFormat(GLenum format); |
821 | 824 |
822 // Helper function to validate compressed texture dimensions are valid for | 825 // Helper function to validate compressed texture dimensions are valid for |
823 // the given format. | 826 // the given format. |
824 bool validateCompressedTexDimensions(const char* functionName, TexFuncValida
tionFunctionType, GLenum target, GLint level, GLsizei width, GLsizei height, GLe
num format); | 827 bool validateCompressedTexDimensions(const char* functionName, TexImageFunct
ionType, GLenum target, GLint level, GLsizei width, GLsizei height, GLenum forma
t); |
825 | 828 |
826 // Helper function to validate compressed texture dimensions are valid for | 829 // Helper function to validate compressed texture dimensions are valid for |
827 // the given format. | 830 // the given format. |
828 bool validateCompressedTexSubDimensions(const char* functionName, GLenum tar
get, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, G
Lenum format, WebGLTexture*); | 831 bool validateCompressedTexSubDimensions(const char* functionName, GLenum tar
get, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, G
Lenum format, WebGLTexture*); |
829 | 832 |
830 // Helper function to validate mode for draw{Arrays/Elements}. | 833 // Helper function to validate mode for draw{Arrays/Elements}. |
831 bool validateDrawMode(const char* functionName, GLenum); | 834 bool validateDrawMode(const char* functionName, GLenum); |
832 | 835 |
833 // Helper function to validate if front/back stencilMask and stencilFunc set
tings are the same. | 836 // Helper function to validate if front/back stencilMask and stencilFunc set
tings are the same. |
834 bool validateStencilSettings(const char* functionName); | 837 bool validateStencilSettings(const char* functionName); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 static IntSize oldestContextSize(); | 967 static IntSize oldestContextSize(); |
965 }; | 968 }; |
966 | 969 |
967 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co
ntext->is3d(), context.is3d()); | 970 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co
ntext->is3d(), context.is3d()); |
968 | 971 |
969 } // namespace blink | 972 } // namespace blink |
970 | 973 |
971 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(blink::WebGLRenderingContextB
ase::TextureUnitState); | 974 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(blink::WebGLRenderingContextB
ase::TextureUnitState); |
972 | 975 |
973 #endif // WebGLRenderingContextBase_h | 976 #endif // WebGLRenderingContextBase_h |
OLD | NEW |