OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
6 | 6 |
7 #include <limits.h> | 7 #include <limits.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <stdio.h> | 10 #include <stdio.h> |
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
883 GLint yoffset, | 883 GLint yoffset, |
884 GLint zoffset, | 884 GLint zoffset, |
885 GLsizei width, | 885 GLsizei width, |
886 GLsizei height, | 886 GLsizei height, |
887 GLsizei depth, | 887 GLsizei depth, |
888 GLenum format, | 888 GLenum format, |
889 GLsizei imageSize, | 889 GLsizei imageSize, |
890 const void* data, | 890 const void* data, |
891 ContextState::Dimension dimension); | 891 ContextState::Dimension dimension); |
892 | 892 |
| 893 bool ValidateCopyTexFormatHelper(GLenum internal_format, |
| 894 GLenum read_format, |
| 895 GLenum read_type, |
| 896 std::string* output_error_msg); |
893 // Validate if |format| is valid for CopyTex{Sub}Image functions. | 897 // Validate if |format| is valid for CopyTex{Sub}Image functions. |
894 // If not, generate a GL error and return false. | 898 // If not, generate a GL error and return false. |
895 bool ValidateCopyTexFormat(const char* func_name, GLenum internal_format, | 899 bool ValidateCopyTexFormat(const char* func_name, GLenum internal_format, |
896 GLenum read_format, GLenum read_type); | 900 GLenum read_format, GLenum read_type); |
897 | 901 |
898 // Wrapper for CopyTexImage2D. | 902 // Wrapper for CopyTexImage2D. |
899 void DoCopyTexImage2D( | 903 void DoCopyTexImage2D( |
900 GLenum target, | 904 GLenum target, |
901 GLint level, | 905 GLint level, |
902 GLenum internal_format, | 906 GLenum internal_format, |
(...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1996 GLsizei size, | 2000 GLsizei size, |
1997 const GLvoid* data); | 2001 const GLvoid* data); |
1998 bool ValidateCompressedTexSubDimensions( | 2002 bool ValidateCompressedTexSubDimensions( |
1999 const char* function_name, | 2003 const char* function_name, |
2000 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, | 2004 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, |
2001 GLsizei width, GLsizei height, GLsizei depth, GLenum format, | 2005 GLsizei width, GLsizei height, GLsizei depth, GLenum format, |
2002 Texture* texture); | 2006 Texture* texture); |
2003 bool ValidateCopyTextureCHROMIUMTextures(const char* function_name, | 2007 bool ValidateCopyTextureCHROMIUMTextures(const char* function_name, |
2004 TextureRef* source_texture_ref, | 2008 TextureRef* source_texture_ref, |
2005 TextureRef* dest_texture_ref); | 2009 TextureRef* dest_texture_ref); |
2006 bool ValidateCopyTextureCHROMIUMInternalFormats( | 2010 SupportedCopyMethodByFormat ValidateCopyTextureCHROMIUMInternalFormats( |
2007 const char* function_name, | 2011 const char* function_name, |
2008 TextureRef* source_texture_ref, | 2012 TextureRef* source_texture_ref, |
2009 GLenum dest_internal_format); | 2013 GLenum dest_internal_format); |
2010 bool ValidateCompressedCopyTextureCHROMIUM(const char* function_name, | 2014 bool ValidateCompressedCopyTextureCHROMIUM(const char* function_name, |
2011 TextureRef* source_texture_ref, | 2015 TextureRef* source_texture_ref, |
2012 TextureRef* dest_texture_ref); | 2016 TextureRef* dest_texture_ref); |
2013 | 2017 |
2014 void RenderWarning(const char* filename, int line, const std::string& msg); | 2018 void RenderWarning(const char* filename, int line, const std::string& msg); |
2015 void PerformanceWarning( | 2019 void PerformanceWarning( |
2016 const char* filename, int line, const std::string& msg); | 2020 const char* filename, int line, const std::string& msg); |
(...skipping 11764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13781 height, depth, format, image_size, data); | 13785 height, depth, format, image_size, data); |
13782 } | 13786 } |
13783 } | 13787 } |
13784 | 13788 |
13785 // This may be a slow command. Exit command processing to allow for | 13789 // This may be a slow command. Exit command processing to allow for |
13786 // context preemption and GPU watchdog checks. | 13790 // context preemption and GPU watchdog checks. |
13787 ExitCommandProcessingEarly(); | 13791 ExitCommandProcessingEarly(); |
13788 return error::kNoError; | 13792 return error::kNoError; |
13789 } | 13793 } |
13790 | 13794 |
13791 bool GLES2DecoderImpl::ValidateCopyTexFormat( | 13795 bool GLES2DecoderImpl::ValidateCopyTexFormatHelper( |
13792 const char* func_name, GLenum internal_format, | 13796 GLenum internal_format, |
13793 GLenum read_format, GLenum read_type) { | 13797 GLenum read_format, |
| 13798 GLenum read_type, |
| 13799 std::string* output_error_msg) { |
| 13800 DCHECK(output_error_msg); |
13794 if (read_format == 0) { | 13801 if (read_format == 0) { |
13795 LOCAL_SET_GL_ERROR( | 13802 *output_error_msg = std::string("no valid color image"); |
13796 GL_INVALID_OPERATION, func_name, "no valid color image"); | |
13797 return false; | 13803 return false; |
13798 } | 13804 } |
13799 // Check we have compatible formats. | 13805 // Check we have compatible formats. |
13800 uint32_t channels_exist = GLES2Util::GetChannelsForFormat(read_format); | 13806 uint32_t channels_exist = GLES2Util::GetChannelsForFormat(read_format); |
13801 uint32_t channels_needed = GLES2Util::GetChannelsForFormat(internal_format); | 13807 uint32_t channels_needed = GLES2Util::GetChannelsForFormat(internal_format); |
13802 if (!channels_needed || | 13808 if (!channels_needed || |
13803 (channels_needed & channels_exist) != channels_needed) { | 13809 (channels_needed & channels_exist) != channels_needed) { |
13804 LOCAL_SET_GL_ERROR( | 13810 *output_error_msg = std::string("incompatible format"); |
13805 GL_INVALID_OPERATION, func_name, "incompatible format"); | |
13806 return false; | 13811 return false; |
13807 } | 13812 } |
13808 if (feature_info_->IsWebGL2OrES3Context()) { | 13813 if (feature_info_->IsWebGL2OrES3Context()) { |
13809 GLint color_encoding = GetColorEncodingFromInternalFormat(read_format); | 13814 GLint color_encoding = GetColorEncodingFromInternalFormat(read_format); |
13810 bool float_mismatch = feature_info_->ext_color_buffer_float_available() ? | 13815 bool float_mismatch = feature_info_->ext_color_buffer_float_available() ? |
13811 (GLES2Util::IsIntegerFormat(internal_format) != | 13816 (GLES2Util::IsIntegerFormat(internal_format) != |
13812 GLES2Util::IsIntegerFormat(read_format)) : | 13817 GLES2Util::IsIntegerFormat(read_format)) : |
13813 GLES2Util::IsFloatFormat(internal_format); | 13818 GLES2Util::IsFloatFormat(internal_format); |
13814 if (color_encoding != GetColorEncodingFromInternalFormat(internal_format) || | 13819 if (color_encoding != GetColorEncodingFromInternalFormat(internal_format) || |
13815 float_mismatch || | 13820 float_mismatch || |
13816 (GLES2Util::IsSignedIntegerFormat(internal_format) != | 13821 (GLES2Util::IsSignedIntegerFormat(internal_format) != |
13817 GLES2Util::IsSignedIntegerFormat(read_format)) || | 13822 GLES2Util::IsSignedIntegerFormat(read_format)) || |
13818 (GLES2Util::IsUnsignedIntegerFormat(internal_format) != | 13823 (GLES2Util::IsUnsignedIntegerFormat(internal_format) != |
13819 GLES2Util::IsUnsignedIntegerFormat(read_format))) { | 13824 GLES2Util::IsUnsignedIntegerFormat(read_format))) { |
13820 LOCAL_SET_GL_ERROR( | 13825 *output_error_msg = std::string("incompatible format"); |
13821 GL_INVALID_OPERATION, func_name, "incompatible format"); | |
13822 return false; | 13826 return false; |
13823 } | 13827 } |
13824 } | 13828 } |
13825 if ((channels_needed & (GLES2Util::kDepth | GLES2Util::kStencil)) != 0) { | 13829 if ((channels_needed & (GLES2Util::kDepth | GLES2Util::kStencil)) != 0) { |
13826 LOCAL_SET_GL_ERROR( | 13830 *output_error_msg = |
13827 GL_INVALID_OPERATION, | 13831 std::string("can not be used with depth or stencil textures"); |
13828 func_name, "can not be used with depth or stencil textures"); | |
13829 return false; | 13832 return false; |
13830 } | 13833 } |
13831 if (feature_info_->IsWebGL2OrES3Context()) { | 13834 if (feature_info_->IsWebGL2OrES3Context()) { |
13832 if (GLES2Util::IsSizedColorFormat(internal_format)) { | 13835 if (GLES2Util::IsSizedColorFormat(internal_format)) { |
13833 int sr, sg, sb, sa; | 13836 int sr, sg, sb, sa; |
13834 GLES2Util::GetColorFormatComponentSizes( | 13837 GLES2Util::GetColorFormatComponentSizes( |
13835 read_format, read_type, &sr, &sg, &sb, &sa); | 13838 read_format, read_type, &sr, &sg, &sb, &sa); |
13836 DCHECK(sr > 0 || sg > 0 || sb > 0 || sa > 0); | 13839 DCHECK(sr > 0 || sg > 0 || sb > 0 || sa > 0); |
13837 int dr, dg, db, da; | 13840 int dr, dg, db, da; |
13838 GLES2Util::GetColorFormatComponentSizes( | 13841 GLES2Util::GetColorFormatComponentSizes( |
13839 internal_format, 0, &dr, &dg, &db, &da); | 13842 internal_format, 0, &dr, &dg, &db, &da); |
13840 DCHECK(dr > 0 || dg > 0 || db > 0 || da > 0); | 13843 DCHECK(dr > 0 || dg > 0 || db > 0 || da > 0); |
13841 if ((dr > 0 && sr != dr) || | 13844 if ((dr > 0 && sr != dr) || |
13842 (dg > 0 && sg != dg) || | 13845 (dg > 0 && sg != dg) || |
13843 (db > 0 && sb != db) || | 13846 (db > 0 && sb != db) || |
13844 (da > 0 && sa != da)) { | 13847 (da > 0 && sa != da)) { |
13845 LOCAL_SET_GL_ERROR( | 13848 *output_error_msg = std::string("incompatible color component sizes"); |
13846 GL_INVALID_OPERATION, | |
13847 func_name, "incompatible color component sizes"); | |
13848 return false; | 13849 return false; |
13849 } | 13850 } |
13850 } | 13851 } |
13851 } | 13852 } |
13852 return true; | 13853 return true; |
13853 } | 13854 } |
13854 | 13855 |
| 13856 bool GLES2DecoderImpl::ValidateCopyTexFormat(const char* func_name, |
| 13857 GLenum internal_format, |
| 13858 GLenum read_format, |
| 13859 GLenum read_type) { |
| 13860 std::string output_error_msg; |
| 13861 if (!ValidateCopyTexFormatHelper(internal_format, read_format, read_type, |
| 13862 &output_error_msg)) { |
| 13863 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
| 13864 output_error_msg.c_str()); |
| 13865 return false; |
| 13866 } |
| 13867 return true; |
| 13868 } |
| 13869 |
13855 void GLES2DecoderImpl::DoCopyTexImage2D( | 13870 void GLES2DecoderImpl::DoCopyTexImage2D( |
13856 GLenum target, | 13871 GLenum target, |
13857 GLint level, | 13872 GLint level, |
13858 GLenum internal_format, | 13873 GLenum internal_format, |
13859 GLint x, | 13874 GLint x, |
13860 GLint y, | 13875 GLint y, |
13861 GLsizei width, | 13876 GLsizei width, |
13862 GLsizei height, | 13877 GLsizei height, |
13863 GLint border) { | 13878 GLint border) { |
13864 const char* func_name = "glCopyTexImage2D"; | 13879 const char* func_name = "glCopyTexImage2D"; |
(...skipping 2184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16049 case GL_TEXTURE_EXTERNAL_OES: | 16064 case GL_TEXTURE_EXTERNAL_OES: |
16050 break; | 16065 break; |
16051 default: | 16066 default: |
16052 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, | 16067 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, |
16053 "invalid source texture target binding"); | 16068 "invalid source texture target binding"); |
16054 return false; | 16069 return false; |
16055 } | 16070 } |
16056 return true; | 16071 return true; |
16057 } | 16072 } |
16058 | 16073 |
16059 bool GLES2DecoderImpl::ValidateCopyTextureCHROMIUMInternalFormats( | 16074 SupportedCopyMethodByFormat |
| 16075 GLES2DecoderImpl::ValidateCopyTextureCHROMIUMInternalFormats( |
16060 const char* function_name, | 16076 const char* function_name, |
16061 TextureRef* source_texture_ref, | 16077 TextureRef* source_texture_ref, |
16062 GLenum dest_internal_format) { | 16078 GLenum dest_internal_format) { |
16063 GLenum source_type = 0; | 16079 GLenum source_type = 0; |
16064 GLenum source_internal_format = 0; | 16080 GLenum source_internal_format = 0; |
16065 Texture* source_texture = source_texture_ref->texture(); | 16081 Texture* source_texture = source_texture_ref->texture(); |
16066 source_texture->GetLevelType(source_texture->target(), 0, &source_type, | 16082 source_texture->GetLevelType(source_texture->target(), 0, &source_type, |
16067 &source_internal_format); | 16083 &source_internal_format); |
16068 | 16084 |
16069 // The destination format should be GL_RGB, or GL_RGBA. GL_ALPHA, | 16085 bool valid_dest_format = false; |
16070 // GL_LUMINANCE, and GL_LUMINANCE_ALPHA are not supported because they are not | 16086 // TODO(qiankun.miao@intel.com): ALPHA, LUMINANCE and LUMINANCE_ALPHA formats |
16071 // renderable on some platforms. | 16087 // are not supported on GL core profile. See crbug.com/577144. Enable the |
16072 bool valid_dest_format = | 16088 // workaround for glCopyTexImage and glCopyTexSubImage in |
16073 dest_internal_format == GL_RGB || dest_internal_format == GL_RGBA || | 16089 // gles2_cmd_copy_tex_image.cc for glCopyTextureCHROMIUM implementation. |
16074 dest_internal_format == GL_RGB8 || dest_internal_format == GL_RGBA8 || | 16090 switch (dest_internal_format) { |
16075 dest_internal_format == GL_BGRA_EXT || | 16091 case GL_RGB: |
16076 dest_internal_format == GL_BGRA8_EXT; | 16092 case GL_RGBA: |
| 16093 case GL_RGB8: |
| 16094 case GL_RGBA8: |
| 16095 valid_dest_format = true; |
| 16096 break; |
| 16097 case GL_BGRA_EXT: |
| 16098 case GL_BGRA8_EXT: |
| 16099 valid_dest_format = |
| 16100 feature_info_->feature_flags().ext_texture_format_bgra8888; |
| 16101 break; |
| 16102 case GL_SRGB_EXT: |
| 16103 case GL_SRGB_ALPHA_EXT: |
| 16104 valid_dest_format = feature_info_->feature_flags().ext_srgb; |
| 16105 break; |
| 16106 case GL_R8: |
| 16107 case GL_R8UI: |
| 16108 case GL_RG8: |
| 16109 case GL_RG8UI: |
| 16110 case GL_SRGB8: |
| 16111 case GL_RGB565: |
| 16112 case GL_RGB9_E5: |
| 16113 case GL_RGB8UI: |
| 16114 case GL_SRGB8_ALPHA8: |
| 16115 case GL_RGB5_A1: |
| 16116 case GL_RGBA4: |
| 16117 case GL_RGBA8UI: |
| 16118 valid_dest_format = feature_info_->IsWebGL2OrES3Context(); |
| 16119 break; |
| 16120 case GL_R16F: |
| 16121 case GL_R32F: |
| 16122 case GL_RG16F: |
| 16123 case GL_RG32F: |
| 16124 case GL_RGB16F: |
| 16125 case GL_RGB32F: |
| 16126 case GL_RGBA16F: |
| 16127 case GL_RGBA32F: |
| 16128 case GL_R11F_G11F_B10F: |
| 16129 valid_dest_format = feature_info_->ext_color_buffer_float_available(); |
| 16130 break; |
| 16131 default: |
| 16132 valid_dest_format = false; |
| 16133 break; |
| 16134 } |
| 16135 |
16077 bool valid_source_format = | 16136 bool valid_source_format = |
16078 source_internal_format == GL_RED || source_internal_format == GL_ALPHA || | 16137 source_internal_format == GL_RED || source_internal_format == GL_ALPHA || |
16079 source_internal_format == GL_RGB || source_internal_format == GL_RGBA || | 16138 source_internal_format == GL_RGB || source_internal_format == GL_RGBA || |
16080 source_internal_format == GL_RGB8 || source_internal_format == GL_RGBA8 || | 16139 source_internal_format == GL_RGB8 || source_internal_format == GL_RGBA8 || |
16081 source_internal_format == GL_LUMINANCE || | 16140 source_internal_format == GL_LUMINANCE || |
16082 source_internal_format == GL_LUMINANCE_ALPHA || | 16141 source_internal_format == GL_LUMINANCE_ALPHA || |
16083 source_internal_format == GL_BGRA_EXT || | 16142 source_internal_format == GL_BGRA_EXT || |
16084 source_internal_format == GL_BGRA8_EXT || | 16143 source_internal_format == GL_BGRA8_EXT || |
16085 source_internal_format == GL_RGB_YCBCR_420V_CHROMIUM || | 16144 source_internal_format == GL_RGB_YCBCR_420V_CHROMIUM || |
16086 source_internal_format == GL_RGB_YCBCR_422_CHROMIUM; | 16145 source_internal_format == GL_RGB_YCBCR_422_CHROMIUM; |
16087 if (!valid_source_format) { | 16146 if (!valid_source_format) { |
16088 std::string msg = "invalid source internal format " + | 16147 std::string msg = "invalid source internal format " + |
16089 GLES2Util::GetStringEnum(source_internal_format); | 16148 GLES2Util::GetStringEnum(source_internal_format); |
16090 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, | 16149 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, |
16091 msg.c_str()); | 16150 msg.c_str()); |
16092 return false; | 16151 return NONE_COPY; |
16093 } | 16152 } |
16094 if (!valid_dest_format) { | 16153 if (!valid_dest_format) { |
16095 std::string msg = "invalid dest internal format " + | 16154 std::string msg = "invalid dest internal format " + |
16096 GLES2Util::GetStringEnum(dest_internal_format); | 16155 GLES2Util::GetStringEnum(dest_internal_format); |
16097 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, | 16156 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, |
16098 msg.c_str()); | 16157 msg.c_str()); |
16099 return false; | 16158 return NONE_COPY; |
16100 } | 16159 } |
16101 return true; | 16160 |
| 16161 bool source_format_color_renderable = |
| 16162 Texture::ColorRenderable(GetFeatureInfo(), source_internal_format, false); |
| 16163 bool dest_format_color_renderable = |
| 16164 Texture::ColorRenderable(GetFeatureInfo(), dest_internal_format, false); |
| 16165 std::string output_error_msg; |
| 16166 |
| 16167 // CopyTexImage* should not allow internalformat of GL_BGRA_EXT and |
| 16168 // GL_BGRA8_EXT. crbug.com/663086. |
| 16169 bool copy_tex_image_format_valid = |
| 16170 source_internal_format != GL_BGRA_EXT && |
| 16171 dest_internal_format != GL_BGRA_EXT && |
| 16172 source_internal_format != GL_BGRA8_EXT && |
| 16173 dest_internal_format != GL_BGRA8_EXT && |
| 16174 ValidateCopyTexFormatHelper(dest_internal_format, source_internal_format, |
| 16175 source_type, &output_error_msg); |
| 16176 if (source_format_color_renderable && copy_tex_image_format_valid) |
| 16177 return DIRECT_COPY; |
| 16178 |
| 16179 if (dest_format_color_renderable) |
| 16180 return DIRECT_DRAW; |
| 16181 |
| 16182 return DRAW_AND_COPY; |
16102 } | 16183 } |
16103 | 16184 |
16104 bool GLES2DecoderImpl::ValidateCompressedCopyTextureCHROMIUM( | 16185 bool GLES2DecoderImpl::ValidateCompressedCopyTextureCHROMIUM( |
16105 const char* function_name, | 16186 const char* function_name, |
16106 TextureRef* source_texture_ref, | 16187 TextureRef* source_texture_ref, |
16107 TextureRef* dest_texture_ref) { | 16188 TextureRef* dest_texture_ref) { |
16108 if (!source_texture_ref || !dest_texture_ref) { | 16189 if (!source_texture_ref || !dest_texture_ref) { |
16109 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "unknown texture id"); | 16190 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "unknown texture id"); |
16110 return false; | 16191 return false; |
16111 } | 16192 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16155 GLenum dest_type, | 16236 GLenum dest_type, |
16156 GLboolean unpack_flip_y, | 16237 GLboolean unpack_flip_y, |
16157 GLboolean unpack_premultiply_alpha, | 16238 GLboolean unpack_premultiply_alpha, |
16158 GLboolean unpack_unmultiply_alpha) { | 16239 GLboolean unpack_unmultiply_alpha) { |
16159 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopyTextureCHROMIUM"); | 16240 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopyTextureCHROMIUM"); |
16160 static const char kFunctionName[] = "glCopyTextureCHROMIUM"; | 16241 static const char kFunctionName[] = "glCopyTextureCHROMIUM"; |
16161 | 16242 |
16162 TextureRef* source_texture_ref = GetTexture(source_id); | 16243 TextureRef* source_texture_ref = GetTexture(source_id); |
16163 TextureRef* dest_texture_ref = GetTexture(dest_id); | 16244 TextureRef* dest_texture_ref = GetTexture(dest_id); |
16164 | 16245 |
16165 if (!texture_manager()->ValidateTextureParameters( | |
16166 GetErrorState(), kFunctionName, true, internal_format, dest_type, | |
16167 internal_format, 0)) | |
16168 return; | |
16169 | |
16170 if (!ValidateCopyTextureCHROMIUMTextures(kFunctionName, source_texture_ref, | 16246 if (!ValidateCopyTextureCHROMIUMTextures(kFunctionName, source_texture_ref, |
16171 dest_texture_ref)) { | 16247 dest_texture_ref)) { |
16172 return; | 16248 return; |
16173 } | 16249 } |
16174 | 16250 |
16175 if (!ValidateCopyTextureCHROMIUMInternalFormats( | |
16176 kFunctionName, source_texture_ref, internal_format)) { | |
16177 return; | |
16178 } | |
16179 | |
16180 Texture* source_texture = source_texture_ref->texture(); | 16251 Texture* source_texture = source_texture_ref->texture(); |
16181 Texture* dest_texture = dest_texture_ref->texture(); | 16252 Texture* dest_texture = dest_texture_ref->texture(); |
16182 GLenum source_target = source_texture->target(); | 16253 GLenum source_target = source_texture->target(); |
16183 GLenum dest_target = dest_texture->target(); | 16254 GLenum dest_target = dest_texture->target(); |
| 16255 |
| 16256 GLenum source_type = 0; |
| 16257 GLenum source_internal_format = 0; |
| 16258 source_texture->GetLevelType(source_target, 0, &source_type, |
| 16259 &source_internal_format); |
| 16260 GLenum format = |
| 16261 TextureManager::ExtractFormatFromStorageFormat(internal_format); |
| 16262 if (!texture_manager()->ValidateTextureParameters( |
| 16263 GetErrorState(), kFunctionName, true, format, dest_type, |
| 16264 internal_format, 0)) { |
| 16265 return; |
| 16266 } |
| 16267 |
| 16268 SupportedCopyMethodByFormat method = |
| 16269 ValidateCopyTextureCHROMIUMInternalFormats( |
| 16270 kFunctionName, source_texture_ref, internal_format); |
| 16271 // INVALID_OPERATION is already generated by |
| 16272 // ValidateCopyTextureCHROMIUMInternalFormats. |
| 16273 if (NONE_COPY == method) { |
| 16274 return; |
| 16275 } |
| 16276 |
| 16277 if (feature_info_->feature_flags().desktop_srgb_support) { |
| 16278 bool enable_framebuffer_srgb = |
| 16279 GetColorEncodingFromInternalFormat(source_internal_format) == GL_SRGB || |
| 16280 GetColorEncodingFromInternalFormat(internal_format) == GL_SRGB; |
| 16281 state_.EnableDisableFramebufferSRGB(enable_framebuffer_srgb); |
| 16282 } |
| 16283 |
16184 int source_width = 0; | 16284 int source_width = 0; |
16185 int source_height = 0; | 16285 int source_height = 0; |
16186 gl::GLImage* image = | 16286 gl::GLImage* image = |
16187 source_texture->GetLevelImage(source_target, 0); | 16287 source_texture->GetLevelImage(source_target, 0); |
16188 if (image) { | 16288 if (image) { |
16189 gfx::Size size = image->GetSize(); | 16289 gfx::Size size = image->GetSize(); |
16190 source_width = size.width(); | 16290 source_width = size.width(); |
16191 source_height = size.height(); | 16291 source_height = size.height(); |
16192 if (source_width <= 0 || source_height <= 0) { | 16292 if (source_width <= 0 || source_height <= 0) { |
16193 LOCAL_SET_GL_ERROR( | 16293 LOCAL_SET_GL_ERROR( |
(...skipping 11 matching lines...) Expand all Loading... |
16205 } | 16305 } |
16206 | 16306 |
16207 // Check that this type of texture is allowed. | 16307 // Check that this type of texture is allowed. |
16208 if (!texture_manager()->ValidForTarget(source_target, 0, | 16308 if (!texture_manager()->ValidForTarget(source_target, 0, |
16209 source_width, source_height, 1)) { | 16309 source_width, source_height, 1)) { |
16210 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "Bad dimensions"); | 16310 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "Bad dimensions"); |
16211 return; | 16311 return; |
16212 } | 16312 } |
16213 } | 16313 } |
16214 | 16314 |
16215 GLenum source_type = 0; | |
16216 GLenum source_internal_format = 0; | |
16217 source_texture->GetLevelType(source_target, 0, &source_type, | |
16218 &source_internal_format); | |
16219 | |
16220 if (dest_texture->IsImmutable()) { | 16315 if (dest_texture->IsImmutable()) { |
16221 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, | 16316 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, |
16222 "texture is immutable"); | 16317 "texture is immutable"); |
16223 return; | 16318 return; |
16224 } | 16319 } |
16225 | 16320 |
16226 // Clear the source texture if necessary. | 16321 // Clear the source texture if necessary. |
16227 if (!texture_manager()->ClearTextureLevel(this, source_texture_ref, | 16322 if (!texture_manager()->ClearTextureLevel(this, source_texture_ref, |
16228 source_target, 0)) { | 16323 source_target, 0)) { |
16229 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, kFunctionName, "dimensions too big"); | 16324 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, kFunctionName, "dimensions too big"); |
(...skipping 16 matching lines...) Expand all Loading... |
16246 } | 16341 } |
16247 | 16342 |
16248 // Resize the destination texture to the dimensions of the source texture. | 16343 // Resize the destination texture to the dimensions of the source texture. |
16249 if (!dest_level_defined || dest_width != source_width || | 16344 if (!dest_level_defined || dest_width != source_width || |
16250 dest_height != source_height || | 16345 dest_height != source_height || |
16251 dest_internal_format != internal_format || | 16346 dest_internal_format != internal_format || |
16252 dest_type_previous != dest_type) { | 16347 dest_type_previous != dest_type) { |
16253 // Ensure that the glTexImage2D succeeds. | 16348 // Ensure that the glTexImage2D succeeds. |
16254 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(kFunctionName); | 16349 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(kFunctionName); |
16255 glBindTexture(dest_target, dest_texture->service_id()); | 16350 glBindTexture(dest_target, dest_texture->service_id()); |
16256 glTexImage2D( | 16351 glTexImage2D(dest_target, 0, TextureManager::AdjustTexInternalFormat( |
16257 dest_target, 0, TextureManager::AdjustTexInternalFormat( | 16352 feature_info_.get(), internal_format), |
16258 feature_info_.get(), internal_format), | 16353 source_width, source_height, 0, |
16259 source_width, source_height, 0, | 16354 TextureManager::AdjustTexFormat(feature_info_.get(), format), |
16260 TextureManager::AdjustTexFormat(feature_info_.get(), internal_format), | 16355 dest_type, NULL); |
16261 dest_type, NULL); | |
16262 GLenum error = LOCAL_PEEK_GL_ERROR(kFunctionName); | 16356 GLenum error = LOCAL_PEEK_GL_ERROR(kFunctionName); |
16263 if (error != GL_NO_ERROR) { | 16357 if (error != GL_NO_ERROR) { |
16264 RestoreCurrentTextureBindings(&state_, dest_target); | 16358 RestoreCurrentTextureBindings(&state_, dest_target); |
16265 return; | 16359 return; |
16266 } | 16360 } |
16267 | 16361 |
16268 texture_manager()->SetLevelInfo( | 16362 texture_manager()->SetLevelInfo(dest_texture_ref, dest_target, 0, |
16269 dest_texture_ref, dest_target, 0, internal_format, source_width, | 16363 internal_format, source_width, |
16270 source_height, 1, 0, internal_format, dest_type, | 16364 source_height, 1, 0, format, dest_type, |
16271 gfx::Rect(source_width, source_height)); | 16365 gfx::Rect(source_width, source_height)); |
16272 dest_texture->ApplyFormatWorkarounds(feature_info_.get()); | 16366 dest_texture->ApplyFormatWorkarounds(feature_info_.get()); |
16273 } else { | 16367 } else { |
16274 texture_manager()->SetLevelCleared(dest_texture_ref, dest_target, 0, | 16368 texture_manager()->SetLevelCleared(dest_texture_ref, dest_target, 0, true); |
16275 true); | |
16276 } | 16369 } |
16277 | 16370 |
16278 // Try using GLImage::CopyTexImage when possible. | 16371 // Try using GLImage::CopyTexImage when possible. |
16279 bool unpack_premultiply_alpha_change = | 16372 bool unpack_premultiply_alpha_change = |
16280 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0; | 16373 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0; |
16281 if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) { | 16374 if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) { |
16282 glBindTexture(dest_target, dest_texture->service_id()); | 16375 glBindTexture(dest_target, dest_texture->service_id()); |
16283 if (image->CopyTexImage(dest_target)) | 16376 if (image->CopyTexImage(dest_target)) |
16284 return; | 16377 return; |
16285 } | 16378 } |
16286 | 16379 |
16287 DoCopyTexImageIfNeeded(source_texture, source_target); | 16380 DoCopyTexImageIfNeeded(source_texture, source_target); |
16288 | 16381 |
16289 // GL_TEXTURE_EXTERNAL_OES texture requires that we apply a transform matrix | 16382 // GL_TEXTURE_EXTERNAL_OES texture requires that we apply a transform matrix |
16290 // before presenting. | 16383 // before presenting. |
16291 if (source_target == GL_TEXTURE_EXTERNAL_OES) { | 16384 if (source_target == GL_TEXTURE_EXTERNAL_OES) { |
16292 if (GLStreamTextureImage* image = | 16385 if (GLStreamTextureImage* image = |
16293 source_texture->GetLevelStreamTextureImage(GL_TEXTURE_EXTERNAL_OES, | 16386 source_texture->GetLevelStreamTextureImage(GL_TEXTURE_EXTERNAL_OES, |
16294 0)) { | 16387 0)) { |
16295 GLfloat transform_matrix[16]; | 16388 GLfloat transform_matrix[16]; |
16296 image->GetTextureMatrix(transform_matrix); | 16389 image->GetTextureMatrix(transform_matrix); |
16297 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( | 16390 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( |
16298 this, source_target, source_texture->service_id(), dest_target, | 16391 this, source_target, source_texture->service_id(), |
16299 dest_texture->service_id(), source_width, source_height, | 16392 source_internal_format, dest_target, dest_texture->service_id(), |
| 16393 internal_format, source_width, source_height, |
16300 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE, | 16394 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE, |
16301 unpack_unmultiply_alpha == GL_TRUE, transform_matrix); | 16395 unpack_unmultiply_alpha == GL_TRUE, transform_matrix); |
16302 return; | 16396 return; |
16303 } | 16397 } |
16304 } | 16398 } |
| 16399 |
16305 copy_texture_CHROMIUM_->DoCopyTexture( | 16400 copy_texture_CHROMIUM_->DoCopyTexture( |
16306 this, source_target, source_texture->service_id(), source_internal_format, | 16401 this, source_target, source_texture->service_id(), source_internal_format, |
16307 dest_target, dest_texture->service_id(), internal_format, source_width, | 16402 dest_target, dest_texture->service_id(), internal_format, source_width, |
16308 source_height, unpack_flip_y == GL_TRUE, | 16403 source_height, unpack_flip_y == GL_TRUE, |
16309 unpack_premultiply_alpha == GL_TRUE, unpack_unmultiply_alpha == GL_TRUE); | 16404 unpack_premultiply_alpha == GL_TRUE, unpack_unmultiply_alpha == GL_TRUE, |
| 16405 method); |
16310 } | 16406 } |
16311 | 16407 |
16312 void GLES2DecoderImpl::DoCopySubTextureCHROMIUM( | 16408 void GLES2DecoderImpl::DoCopySubTextureCHROMIUM( |
16313 GLuint source_id, | 16409 GLuint source_id, |
16314 GLuint dest_id, | 16410 GLuint dest_id, |
16315 GLint xoffset, | 16411 GLint xoffset, |
16316 GLint yoffset, | 16412 GLint yoffset, |
16317 GLint x, | 16413 GLint x, |
16318 GLint y, | 16414 GLint y, |
16319 GLsizei width, | 16415 GLsizei width, |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16401 "destination texture is not defined"); | 16497 "destination texture is not defined"); |
16402 return; | 16498 return; |
16403 } | 16499 } |
16404 if (!dest_texture->ValidForTexture(dest_target, 0, xoffset, | 16500 if (!dest_texture->ValidForTexture(dest_target, 0, xoffset, |
16405 yoffset, 0, width, height, 1)) { | 16501 yoffset, 0, width, height, 1)) { |
16406 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, | 16502 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, |
16407 "destination texture bad dimensions."); | 16503 "destination texture bad dimensions."); |
16408 return; | 16504 return; |
16409 } | 16505 } |
16410 | 16506 |
16411 if (!ValidateCopyTextureCHROMIUMInternalFormats( | 16507 SupportedCopyMethodByFormat method = |
16412 kFunctionName, source_texture_ref, dest_internal_format)) { | 16508 ValidateCopyTextureCHROMIUMInternalFormats( |
| 16509 kFunctionName, source_texture_ref, dest_internal_format); |
| 16510 // INVALID_OPERATION is already generated by |
| 16511 // ValidateCopyTextureCHROMIUMInternalFormats. |
| 16512 if (NONE_COPY == method) { |
16413 return; | 16513 return; |
16414 } | 16514 } |
16415 | 16515 |
| 16516 if (feature_info_->feature_flags().desktop_srgb_support) { |
| 16517 bool enable_framebuffer_srgb = |
| 16518 GetColorEncodingFromInternalFormat(source_internal_format) == GL_SRGB || |
| 16519 GetColorEncodingFromInternalFormat(dest_internal_format) == GL_SRGB; |
| 16520 state_.EnableDisableFramebufferSRGB(enable_framebuffer_srgb); |
| 16521 } |
| 16522 |
16416 // Clear the source texture if necessary. | 16523 // Clear the source texture if necessary. |
16417 if (!texture_manager()->ClearTextureLevel(this, source_texture_ref, | 16524 if (!texture_manager()->ClearTextureLevel(this, source_texture_ref, |
16418 source_target, 0)) { | 16525 source_target, 0)) { |
16419 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, kFunctionName, | 16526 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, kFunctionName, |
16420 "source texture dimensions too big"); | 16527 "source texture dimensions too big"); |
16421 return; | 16528 return; |
16422 } | 16529 } |
16423 | 16530 |
16424 if (!InitializeCopyTextureCHROMIUM(kFunctionName)) | 16531 if (!InitializeCopyTextureCHROMIUM(kFunctionName)) |
16425 return; | 16532 return; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16484 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE, | 16591 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE, |
16485 unpack_unmultiply_alpha == GL_TRUE, transform_matrix); | 16592 unpack_unmultiply_alpha == GL_TRUE, transform_matrix); |
16486 return; | 16593 return; |
16487 } | 16594 } |
16488 } | 16595 } |
16489 copy_texture_CHROMIUM_->DoCopySubTexture( | 16596 copy_texture_CHROMIUM_->DoCopySubTexture( |
16490 this, source_target, source_texture->service_id(), source_internal_format, | 16597 this, source_target, source_texture->service_id(), source_internal_format, |
16491 dest_target, dest_texture->service_id(), dest_internal_format, xoffset, | 16598 dest_target, dest_texture->service_id(), dest_internal_format, xoffset, |
16492 yoffset, x, y, width, height, dest_width, dest_height, source_width, | 16599 yoffset, x, y, width, height, dest_width, dest_height, source_width, |
16493 source_height, unpack_flip_y == GL_TRUE, | 16600 source_height, unpack_flip_y == GL_TRUE, |
16494 unpack_premultiply_alpha == GL_TRUE, unpack_unmultiply_alpha == GL_TRUE); | 16601 unpack_premultiply_alpha == GL_TRUE, unpack_unmultiply_alpha == GL_TRUE, |
| 16602 method); |
16495 } | 16603 } |
16496 | 16604 |
16497 bool GLES2DecoderImpl::InitializeCopyTexImageBlitter( | 16605 bool GLES2DecoderImpl::InitializeCopyTexImageBlitter( |
16498 const char* function_name) { | 16606 const char* function_name) { |
16499 if (!copy_tex_image_blit_.get()) { | 16607 if (!copy_tex_image_blit_.get()) { |
16500 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(function_name); | 16608 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(function_name); |
16501 copy_tex_image_blit_.reset( | 16609 copy_tex_image_blit_.reset( |
16502 new CopyTexImageResourceManager(feature_info_.get())); | 16610 new CopyTexImageResourceManager(feature_info_.get())); |
16503 copy_tex_image_blit_->Initialize(this); | 16611 copy_tex_image_blit_->Initialize(this); |
16504 if (LOCAL_PEEK_GL_ERROR(function_name) != GL_NO_ERROR) | 16612 if (LOCAL_PEEK_GL_ERROR(function_name) != GL_NO_ERROR) |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16659 | 16767 |
16660 texture_manager()->SetLevelInfo( | 16768 texture_manager()->SetLevelInfo( |
16661 dest_texture_ref, dest_texture->target(), 0, GL_RGBA, source_width, | 16769 dest_texture_ref, dest_texture->target(), 0, GL_RGBA, source_width, |
16662 source_height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 16770 source_height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
16663 gfx::Rect(source_width, source_height)); | 16771 gfx::Rect(source_width, source_height)); |
16664 | 16772 |
16665 copy_texture_CHROMIUM_->DoCopyTexture( | 16773 copy_texture_CHROMIUM_->DoCopyTexture( |
16666 this, source_texture->target(), source_texture->service_id(), | 16774 this, source_texture->target(), source_texture->service_id(), |
16667 source_internal_format, dest_texture->target(), | 16775 source_internal_format, dest_texture->target(), |
16668 dest_texture->service_id(), GL_RGBA, source_width, source_height, false, | 16776 dest_texture->service_id(), GL_RGBA, source_width, source_height, false, |
16669 false, false); | 16777 false, false, DIRECT_DRAW); |
16670 } | 16778 } |
16671 | 16779 |
16672 void GLES2DecoderImpl::TexStorageImpl(GLenum target, | 16780 void GLES2DecoderImpl::TexStorageImpl(GLenum target, |
16673 GLsizei levels, | 16781 GLsizei levels, |
16674 GLenum internal_format, | 16782 GLenum internal_format, |
16675 GLsizei width, | 16783 GLsizei width, |
16676 GLsizei height, | 16784 GLsizei height, |
16677 GLsizei depth, | 16785 GLsizei depth, |
16678 ContextState::Dimension dimension, | 16786 ContextState::Dimension dimension, |
16679 const char* function_name) { | 16787 const char* function_name) { |
(...skipping 2235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18915 } | 19023 } |
18916 | 19024 |
18917 // Include the auto-generated part of this file. We split this because it means | 19025 // Include the auto-generated part of this file. We split this because it means |
18918 // we can easily edit the non-auto generated parts right here in this file | 19026 // we can easily edit the non-auto generated parts right here in this file |
18919 // instead of having to edit some template or the code generator. | 19027 // instead of having to edit some template or the code generator. |
18920 #include "base/macros.h" | 19028 #include "base/macros.h" |
18921 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 19029 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
18922 | 19030 |
18923 } // namespace gles2 | 19031 } // namespace gles2 |
18924 } // namespace gpu | 19032 } // namespace gpu |
OLD | NEW |