Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Side by Side Diff: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h

Issue 2025703002: Pack repeated code in tex(Sub)Image2D and texSubImage3D into helper func (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pass enum instead of const char*, use a wrapper for validate2D(3D)Binding Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 void texImage2DImpl(GLenum target, GLint level, GLint internalformat, GLenum format, GLenum type, Image*, WebGLImageConversion::ImageHtmlDomSource, bool fli pY, bool premultiplyAlpha); 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); 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); 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 776
777 enum TexImageFunctionType { 777 enum TexImageFunctionType {
778 TexImage, 778 TexImage,
779 TexSubImage, 779 TexSubImage,
780 CopyTexImage, 780 CopyTexImage,
781 CompressedTexImage 781 CompressedTexImage
782 }; 782 };
783 enum TexImageFunctionName {
784 TexImage2D,
785 TexSubImage2D,
786 TexImage3D,
787 TexSubImage3D
788 };
783 enum TexImageByGPUType { 789 enum TexImageByGPUType {
784 TexImage2DByGPU, 790 TexImage2DByGPU,
785 TexSubImage2DByGPU, 791 TexSubImage2DByGPU,
786 TexSubImage3DByGPU 792 TexSubImage3DByGPU
787 }; 793 };
788 enum TexImageDimension { 794 enum TexImageDimension {
789 Tex2D, 795 Tex2D,
790 Tex3D 796 Tex3D
791 }; 797 };
792 // Copy from the canvas element directly to the texture via the GPU, without a read-back to system memory. 798 // Copy from the canvas element directly to the texture via the GPU, without a read-back to system memory.
(...skipping 19 matching lines...) Expand all
812 818
813 // Helper function to check if all characters in the string belong to the 819 // 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. 820 // ASCII subset as defined in GLSL ES 1.0 spec section 3.1.
815 bool validateString(const char* functionName, const String&); 821 bool validateString(const char* functionName, const String&);
816 822
817 // Helper function to check texture binding target and texture bound to the target. 823 // 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 824 // Generate GL errors and return 0 if target is invalid or texture bound is
819 // null. Otherwise, return the texture bound to the target. 825 // null. Otherwise, return the texture bound to the target.
820 WebGLTexture* validateTextureBinding(const char* functionName, GLenum target ); 826 WebGLTexture* validateTextureBinding(const char* functionName, GLenum target );
821 827
828 // Wrapper function for validateTexture2D(3D)Binding, used in texImageHelper functions.
829 virtual WebGLTexture* validateTexImageBinding(const char*, TexImageFunctionN ame, GLenum);
830
822 // Helper function to check texture 2D target and texture bound to the targe t. 831 // 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 832 // Generate GL errors and return 0 if target is invalid or texture bound is
824 // null. Otherwise, return the texture bound to the target. 833 // null. Otherwise, return the texture bound to the target.
825 WebGLTexture* validateTexture2DBinding(const char* functionName, GLenum targ et); 834 WebGLTexture* validateTexture2DBinding(const char* functionName, GLenum targ et);
826 835
827 // Helper function to check input internalformat/format/type for functions { copy}Tex{Sub}Image. 836 // 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. 837 // 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); 838 bool validateTexFuncFormatAndType(const char* functionName, TexImageFunction Type, GLenum internalformat, GLenum format, GLenum type, GLint level);
830 839
831 // Helper function to check readbuffer validity for copyTex{Sub}Image. 840 // Helper function to check readbuffer validity for copyTex{Sub}Image.
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 static void willDestroyContext(WebGLRenderingContextBase*); 1090 static void willDestroyContext(WebGLRenderingContextBase*);
1082 static void forciblyLoseOldestContext(const String& reason); 1091 static void forciblyLoseOldestContext(const String& reason);
1083 // Return the least recently used context's position in the active context v ector. 1092 // 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. 1093 // If the vector is empty, return the maximum allowed active context number.
1085 static WebGLRenderingContextBase* oldestContext(); 1094 static WebGLRenderingContextBase* oldestContext();
1086 static WebGLRenderingContextBase* oldestEvictedContext(); 1095 static WebGLRenderingContextBase* oldestEvictedContext();
1087 1096
1088 CrossThreadWeakPersistentThisPointer<WebGLRenderingContextBase> createWeakTh isPointer() { return CrossThreadWeakPersistentThisPointer<WebGLRenderingContextB ase>(this); } 1097 CrossThreadWeakPersistentThisPointer<WebGLRenderingContextBase> createWeakTh isPointer() { return CrossThreadWeakPersistentThisPointer<WebGLRenderingContextB ase>(this); }
1089 1098
1090 ImageBitmap* transferToImageBitmapBase(); 1099 ImageBitmap* transferToImageBitmapBase();
1100
1101 // Helper functions for tex(Sub)Image2D && texSubImage3D
1102 void texImageHelperDOMArrayBufferView(TexImageFunctionName, GLenum, GLint, G Lint, GLsizei, GLsizei, GLint, GLenum, GLenum, GLsizei, GLint, GLint, GLint, DOM ArrayBufferView*);
1103 void texImageHelperImageData(TexImageFunctionName, GLenum, GLint, GLint, GLi nt, GLenum, GLenum, GLsizei, GLint, GLint, GLint, ImageData*);
1104 bool texImageHelperHTMLImageElement(TexImageFunctionName, GLenum, GLint, GLi nt, GLenum, GLenum, GLint, GLint, GLint, HTMLImageElement*, ExceptionState&);
1105 WebGLTexture* texImageHelperHTMLCanvasElement(TexImageFunctionName, GLenum, GLint, GLint, GLenum, GLenum, GLint, GLint, GLint, HTMLCanvasElement*, Exception State&);
1106 WebGLTexture* texImageHelperHTMLVideoElement(TexImageFunctionName, GLenum, G Lint, GLint, GLenum, GLenum, GLint, GLint, GLint, HTMLVideoElement*, ExceptionSt ate&);
1107 void texImageHelperImageBitmap(TexImageFunctionName, GLenum, GLint, GLint, G Lenum, GLenum, GLint, GLint, GLint, ImageBitmap*, ExceptionState&);
1108 static const char* getTexImageFunctionName(TexImageFunctionName);
1109
1091 private: 1110 private:
1092 WebGLRenderingContextBase(HTMLCanvasElement*, OffscreenCanvas*, PassOwnPtr<W ebGraphicsContext3DProvider>, const WebGLContextAttributes&); 1111 WebGLRenderingContextBase(HTMLCanvasElement*, OffscreenCanvas*, PassOwnPtr<W ebGraphicsContext3DProvider>, const WebGLContextAttributes&);
1093 static PassOwnPtr<WebGraphicsContext3DProvider> createContextProviderInterna l(HTMLCanvasElement*, ScriptState*, WebGLContextAttributes, unsigned); 1112 static PassOwnPtr<WebGraphicsContext3DProvider> createContextProviderInterna l(HTMLCanvasElement*, ScriptState*, WebGLContextAttributes, unsigned);
1094 }; 1113 };
1095 1114
1096 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co ntext->is3d(), context.is3d()); 1115 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co ntext->is3d(), context.is3d());
1097 1116
1098 } // namespace blink 1117 } // namespace blink
1099 1118
1100 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(blink::WebGLRenderingContextB ase::TextureUnitState); 1119 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(blink::WebGLRenderingContextB ase::TextureUnitState);
1101 1120
1102 #endif // WebGLRenderingContextBase_h 1121 #endif // WebGLRenderingContextBase_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698