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 4807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4818 break; | 4818 break; |
4819 case GC3D_COMPRESSED_ATC_RGBA_EXPLICIT_ALPHA_AMD: | 4819 case GC3D_COMPRESSED_ATC_RGBA_EXPLICIT_ALPHA_AMD: |
4820 case GC3D_COMPRESSED_ATC_RGBA_INTERPOLATED_ALPHA_AMD: | 4820 case GC3D_COMPRESSED_ATC_RGBA_INTERPOLATED_ALPHA_AMD: |
4821 { | 4821 { |
4822 bytesRequired = floor(static_cast<double>((width + 3) / 4)) * floor( static_cast<double>((height + 3) / 4)) * 16; | 4822 bytesRequired = floor(static_cast<double>((width + 3) / 4)) * floor( static_cast<double>((height + 3) / 4)) * 16; |
4823 } | 4823 } |
4824 break; | 4824 break; |
4825 case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG: | 4825 case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG: |
4826 case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: | 4826 case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: |
4827 { | 4827 { |
4828 bytesRequired = max(width, 8) * max(height, 8) / 2; | 4828 bytesRequired = (max(width, 8) * max(height, 8) * 4 + 7) / 8; |
Ken Russell (switch to Gerrit)
2014/04/18 01:56:35
Please submit a pull request updating the extensio
| |
4829 } | 4829 } |
4830 break; | 4830 break; |
4831 case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG: | 4831 case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG: |
4832 case GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: | 4832 case GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: |
4833 { | 4833 { |
4834 bytesRequired = max(width, 8) * max(height, 8) / 4; | 4834 bytesRequired = (max(width, 16) * max(height, 8) * 2 + 7) / 8; |
Ken Russell (switch to Gerrit)
2014/04/18 01:56:35
Same for this change.
| |
4835 } | 4835 } |
4836 break; | 4836 break; |
4837 default: | 4837 default: |
4838 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid format"); | 4838 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid format"); |
4839 return false; | 4839 return false; |
4840 } | 4840 } |
4841 | 4841 |
4842 if (pixels->byteLength() != bytesRequired) { | 4842 if (pixels->byteLength() != bytesRequired) { |
4843 synthesizeGLError(GL_INVALID_VALUE, functionName, "length of ArrayBuffer View is not correct for dimensions"); | 4843 synthesizeGLError(GL_INVALID_VALUE, functionName, "length of ArrayBuffer View is not correct for dimensions"); |
4844 return false; | 4844 return false; |
4845 } | 4845 } |
4846 | 4846 |
4847 return true; | 4847 return true; |
4848 } | 4848 } |
4849 | 4849 |
4850 bool WebGLRenderingContextBase::validateCompressedTexDimensions(const char* func tionName, TexFuncValidationFunctionType functionType, GLenum target, GLint level , GLsizei width, GLsizei height, GLenum format) | 4850 bool WebGLRenderingContextBase::validateCompressedTexDimensions(const char* func tionName, TexFuncValidationFunctionType functionType, GLenum target, GLint level , GLsizei width, GLsizei height, GLenum format) |
4851 { | 4851 { |
4852 if (!validateTexFuncDimensions(functionName, functionType, target, level, wi dth, height)) | 4852 if (!validateTexFuncDimensions(functionName, functionType, target, level, wi dth, height)) |
4853 return false; | 4853 return false; |
4854 | 4854 |
4855 bool widthValid = false; | |
4856 bool heightValid = false; | |
4857 | |
4855 switch (format) { | 4858 switch (format) { |
4859 case GC3D_COMPRESSED_ATC_RGB_AMD: | |
4860 case GC3D_COMPRESSED_ATC_RGBA_EXPLICIT_ALPHA_AMD: | |
4861 case GC3D_COMPRESSED_ATC_RGBA_INTERPOLATED_ALPHA_AMD: | |
4856 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: | 4862 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
4857 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: | 4863 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
4858 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: | 4864 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: |
4859 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: { | 4865 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: { |
4860 const int kBlockWidth = 4; | 4866 const int kBlockWidth = 4; |
4861 const int kBlockHeight = 4; | 4867 const int kBlockHeight = 4; |
4862 bool widthValid = (level && width == 1) || (level && width == 2) || !(wi dth % kBlockWidth); | 4868 widthValid = (level && width == 1) || (level && width == 2) || !(width % kBlockWidth); |
4863 bool heightValid = (level && height == 1) || (level && height == 2) || ! (height % kBlockHeight); | 4869 heightValid = (level && height == 1) || (level && height == 2) || !(heig ht % kBlockHeight); |
4864 if (!widthValid || !heightValid) { | 4870 break; |
4865 synthesizeGLError(GL_INVALID_OPERATION, functionName, "width or heig ht invalid for level"); | 4871 } |
4866 return false; | 4872 case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG: |
4867 } | 4873 case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: |
4868 return true; | 4874 case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG: |
4875 case GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: { | |
4876 // Must be a power of two | |
4877 widthValid = (width & (width - 1)) == 0; | |
4878 heightValid = (height & (height - 1)) == 0; | |
4879 break; | |
4880 } | |
4881 case GL_ETC1_RGB8_OES: { | |
4882 widthValid = true; | |
4883 heightValid = true; | |
4884 break; | |
4869 } | 4885 } |
4870 default: | 4886 default: |
4871 return false; | 4887 return false; |
4872 } | 4888 } |
4889 | |
4890 if (!widthValid || !heightValid) { | |
4891 synthesizeGLError(GL_INVALID_OPERATION, functionName, "width or height i nvalid for level"); | |
4892 return false; | |
4893 } | |
4894 | |
4895 return true; | |
4873 } | 4896 } |
4874 | 4897 |
4875 bool WebGLRenderingContextBase::validateCompressedTexSubDimensions(const char* f unctionName, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei w idth, GLsizei height, GLenum format, WebGLTexture* tex) | 4898 bool WebGLRenderingContextBase::validateCompressedTexSubDimensions(const char* f unctionName, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei w idth, GLsizei height, GLenum format, WebGLTexture* tex) |
4876 { | 4899 { |
4877 if (xoffset < 0 || yoffset < 0) { | 4900 if (xoffset < 0 || yoffset < 0) { |
4878 synthesizeGLError(GL_INVALID_VALUE, functionName, "xoffset or yoffset < 0"); | 4901 synthesizeGLError(GL_INVALID_VALUE, functionName, "xoffset or yoffset < 0"); |
4879 return false; | 4902 return false; |
4880 } | 4903 } |
4881 | 4904 |
4882 switch (format) { | 4905 switch (format) { |
4883 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: | 4906 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
4884 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: | 4907 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
4885 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: | 4908 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: |
4886 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: { | 4909 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: { |
4887 const int kBlockWidth = 4; | 4910 const int kBlockWidth = 4; |
4888 const int kBlockHeight = 4; | 4911 const int kBlockHeight = 4; |
4889 if ((xoffset % kBlockWidth) || (yoffset % kBlockHeight)) { | 4912 if ((xoffset % kBlockWidth) || (yoffset % kBlockHeight)) { |
4890 synthesizeGLError(GL_INVALID_OPERATION, functionName, "xoffset or yo ffset not multiple of 4"); | 4913 synthesizeGLError(GL_INVALID_OPERATION, functionName, "xoffset or yo ffset not multiple of 4"); |
4891 return false; | 4914 return false; |
4892 } | 4915 } |
4893 if (width - xoffset > tex->getWidth(target, level) | 4916 if (width - xoffset > tex->getWidth(target, level) |
4894 || height - yoffset > tex->getHeight(target, level)) { | 4917 || height - yoffset > tex->getHeight(target, level)) { |
4895 synthesizeGLError(GL_INVALID_OPERATION, functionName, "dimensions ou t of range"); | 4918 synthesizeGLError(GL_INVALID_OPERATION, functionName, "dimensions ou t of range"); |
4896 return false; | 4919 return false; |
4897 } | 4920 } |
4898 return validateCompressedTexDimensions(functionName, TexSubImage2D, targ et, level, width, height, format); | 4921 return validateCompressedTexDimensions(functionName, TexSubImage2D, targ et, level, width, height, format); |
4899 } | 4922 } |
4923 case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG: | |
4924 case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: | |
4925 case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG: | |
4926 case GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: { | |
4927 if ((xoffset != 0) || (yoffset != 0)) { | |
4928 synthesizeGLError(GL_INVALID_OPERATION, functionName, "xoffset or yo ffset must be zero"); | |
Ken Russell (switch to Gerrit)
2014/04/18 01:56:35
"xoffset and yoffset" would be clearer.
| |
4929 return false; | |
4930 } | |
4931 if (width != tex->getWidth(target, level) | |
4932 || height != tex->getHeight(target, level)) { | |
4933 synthesizeGLError(GL_INVALID_OPERATION, functionName, "dimensions mu st match existing level"); | |
4934 return false; | |
4935 } | |
4936 return validateCompressedTexDimensions(functionName, TexSubImage2D, targ et, level, width, height, format); | |
4937 } | |
4938 case GC3D_COMPRESSED_ATC_RGB_AMD: | |
4939 case GC3D_COMPRESSED_ATC_RGBA_EXPLICIT_ALPHA_AMD: | |
4940 case GC3D_COMPRESSED_ATC_RGBA_INTERPOLATED_ALPHA_AMD: | |
4941 case GL_ETC1_RGB8_OES: { | |
4942 synthesizeGLError(GL_INVALID_OPERATION, functionName, "not valid for thi s format"); | |
Zhenyao Mo
2014/04/17 22:40:27
I think if these formats are not supported, they s
Ken Russell (switch to Gerrit)
2014/04/18 01:56:35
I think this is here because texSubImage2D isn't s
| |
4943 return false; | |
4944 } | |
4900 default: | 4945 default: |
4901 return false; | 4946 return false; |
4902 } | 4947 } |
4903 } | 4948 } |
4904 | 4949 |
4905 bool WebGLRenderingContextBase::validateDrawMode(const char* functionName, GLenu m mode) | 4950 bool WebGLRenderingContextBase::validateDrawMode(const char* functionName, GLenu m mode) |
4906 { | 4951 { |
4907 switch (mode) { | 4952 switch (mode) { |
4908 case GL_POINTS: | 4953 case GL_POINTS: |
4909 case GL_LINE_STRIP: | 4954 case GL_LINE_STRIP: |
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5593 if (m_textureUnits[i].m_texture2DBinding | 5638 if (m_textureUnits[i].m_texture2DBinding |
5594 || m_textureUnits[i].m_textureCubeMapBinding) { | 5639 || m_textureUnits[i].m_textureCubeMapBinding) { |
5595 m_onePlusMaxNonDefaultTextureUnit = i + 1; | 5640 m_onePlusMaxNonDefaultTextureUnit = i + 1; |
5596 return; | 5641 return; |
5597 } | 5642 } |
5598 } | 5643 } |
5599 m_onePlusMaxNonDefaultTextureUnit = 0; | 5644 m_onePlusMaxNonDefaultTextureUnit = 0; |
5600 } | 5645 } |
5601 | 5646 |
5602 } // namespace WebCore | 5647 } // namespace WebCore |
OLD | NEW |