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); | |
897 // Validate if |format| is valid for CopyTex{Sub}Image functions. | 893 // Validate if |format| is valid for CopyTex{Sub}Image functions. |
898 // If not, generate a GL error and return false. | 894 // If not, generate a GL error and return false. |
899 bool ValidateCopyTexFormat(const char* func_name, GLenum internal_format, | 895 bool ValidateCopyTexFormat(const char* func_name, GLenum internal_format, |
900 GLenum read_format, GLenum read_type); | 896 GLenum read_format, GLenum read_type); |
901 | 897 |
902 // Wrapper for CopyTexImage2D. | 898 // Wrapper for CopyTexImage2D. |
903 void DoCopyTexImage2D( | 899 void DoCopyTexImage2D( |
904 GLenum target, | 900 GLenum target, |
905 GLint level, | 901 GLint level, |
906 GLenum internal_format, | 902 GLenum internal_format, |
(...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2000 GLsizei size, | 1996 GLsizei size, |
2001 const GLvoid* data); | 1997 const GLvoid* data); |
2002 bool ValidateCompressedTexSubDimensions( | 1998 bool ValidateCompressedTexSubDimensions( |
2003 const char* function_name, | 1999 const char* function_name, |
2004 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, | 2000 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, |
2005 GLsizei width, GLsizei height, GLsizei depth, GLenum format, | 2001 GLsizei width, GLsizei height, GLsizei depth, GLenum format, |
2006 Texture* texture); | 2002 Texture* texture); |
2007 bool ValidateCopyTextureCHROMIUMTextures(const char* function_name, | 2003 bool ValidateCopyTextureCHROMIUMTextures(const char* function_name, |
2008 TextureRef* source_texture_ref, | 2004 TextureRef* source_texture_ref, |
2009 TextureRef* dest_texture_ref); | 2005 TextureRef* dest_texture_ref); |
2010 CopyTextureMethod ValidateCopyTextureCHROMIUMInternalFormats( | 2006 bool ValidateCopyTextureCHROMIUMInternalFormats( |
2011 const char* function_name, | 2007 const char* function_name, |
2012 TextureRef* source_texture_ref, | 2008 TextureRef* source_texture_ref, |
2013 GLenum dest_internal_format); | 2009 GLenum dest_internal_format); |
2014 bool ValidateCompressedCopyTextureCHROMIUM(const char* function_name, | 2010 bool ValidateCompressedCopyTextureCHROMIUM(const char* function_name, |
2015 TextureRef* source_texture_ref, | 2011 TextureRef* source_texture_ref, |
2016 TextureRef* dest_texture_ref); | 2012 TextureRef* dest_texture_ref); |
2017 | 2013 |
2018 void RenderWarning(const char* filename, int line, const std::string& msg); | 2014 void RenderWarning(const char* filename, int line, const std::string& msg); |
2019 void PerformanceWarning( | 2015 void PerformanceWarning( |
2020 const char* filename, int line, const std::string& msg); | 2016 const char* filename, int line, const std::string& msg); |
(...skipping 11780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13801 height, depth, format, image_size, data); | 13797 height, depth, format, image_size, data); |
13802 } | 13798 } |
13803 } | 13799 } |
13804 | 13800 |
13805 // This may be a slow command. Exit command processing to allow for | 13801 // This may be a slow command. Exit command processing to allow for |
13806 // context preemption and GPU watchdog checks. | 13802 // context preemption and GPU watchdog checks. |
13807 ExitCommandProcessingEarly(); | 13803 ExitCommandProcessingEarly(); |
13808 return error::kNoError; | 13804 return error::kNoError; |
13809 } | 13805 } |
13810 | 13806 |
13811 bool GLES2DecoderImpl::ValidateCopyTexFormatHelper( | 13807 bool GLES2DecoderImpl::ValidateCopyTexFormat( |
13812 GLenum internal_format, | 13808 const char* func_name, GLenum internal_format, |
13813 GLenum read_format, | 13809 GLenum read_format, GLenum read_type) { |
13814 GLenum read_type, | |
13815 std::string* output_error_msg) { | |
13816 DCHECK(output_error_msg); | |
13817 if (read_format == 0) { | 13810 if (read_format == 0) { |
13818 *output_error_msg = std::string("no valid color image"); | 13811 LOCAL_SET_GL_ERROR( |
| 13812 GL_INVALID_OPERATION, func_name, "no valid color image"); |
13819 return false; | 13813 return false; |
13820 } | 13814 } |
13821 // Check we have compatible formats. | 13815 // Check we have compatible formats. |
13822 uint32_t channels_exist = GLES2Util::GetChannelsForFormat(read_format); | 13816 uint32_t channels_exist = GLES2Util::GetChannelsForFormat(read_format); |
13823 uint32_t channels_needed = GLES2Util::GetChannelsForFormat(internal_format); | 13817 uint32_t channels_needed = GLES2Util::GetChannelsForFormat(internal_format); |
13824 if (!channels_needed || | 13818 if (!channels_needed || |
13825 (channels_needed & channels_exist) != channels_needed) { | 13819 (channels_needed & channels_exist) != channels_needed) { |
13826 *output_error_msg = std::string("incompatible format"); | 13820 LOCAL_SET_GL_ERROR( |
| 13821 GL_INVALID_OPERATION, func_name, "incompatible format"); |
13827 return false; | 13822 return false; |
13828 } | 13823 } |
13829 if (feature_info_->IsWebGL2OrES3Context()) { | 13824 if (feature_info_->IsWebGL2OrES3Context()) { |
13830 GLint color_encoding = GetColorEncodingFromInternalFormat(read_format); | 13825 GLint color_encoding = GetColorEncodingFromInternalFormat(read_format); |
13831 bool float_mismatch = feature_info_->ext_color_buffer_float_available() ? | 13826 bool float_mismatch = feature_info_->ext_color_buffer_float_available() ? |
13832 (GLES2Util::IsIntegerFormat(internal_format) != | 13827 (GLES2Util::IsIntegerFormat(internal_format) != |
13833 GLES2Util::IsIntegerFormat(read_format)) : | 13828 GLES2Util::IsIntegerFormat(read_format)) : |
13834 GLES2Util::IsFloatFormat(internal_format); | 13829 GLES2Util::IsFloatFormat(internal_format); |
13835 if (color_encoding != GetColorEncodingFromInternalFormat(internal_format) || | 13830 if (color_encoding != GetColorEncodingFromInternalFormat(internal_format) || |
13836 float_mismatch || | 13831 float_mismatch || |
13837 (GLES2Util::IsSignedIntegerFormat(internal_format) != | 13832 (GLES2Util::IsSignedIntegerFormat(internal_format) != |
13838 GLES2Util::IsSignedIntegerFormat(read_format)) || | 13833 GLES2Util::IsSignedIntegerFormat(read_format)) || |
13839 (GLES2Util::IsUnsignedIntegerFormat(internal_format) != | 13834 (GLES2Util::IsUnsignedIntegerFormat(internal_format) != |
13840 GLES2Util::IsUnsignedIntegerFormat(read_format))) { | 13835 GLES2Util::IsUnsignedIntegerFormat(read_format))) { |
13841 *output_error_msg = std::string("incompatible format"); | 13836 LOCAL_SET_GL_ERROR( |
| 13837 GL_INVALID_OPERATION, func_name, "incompatible format"); |
13842 return false; | 13838 return false; |
13843 } | 13839 } |
13844 } | 13840 } |
13845 if ((channels_needed & (GLES2Util::kDepth | GLES2Util::kStencil)) != 0) { | 13841 if ((channels_needed & (GLES2Util::kDepth | GLES2Util::kStencil)) != 0) { |
13846 *output_error_msg = | 13842 LOCAL_SET_GL_ERROR( |
13847 std::string("can not be used with depth or stencil textures"); | 13843 GL_INVALID_OPERATION, |
| 13844 func_name, "can not be used with depth or stencil textures"); |
13848 return false; | 13845 return false; |
13849 } | 13846 } |
13850 if (feature_info_->IsWebGL2OrES3Context()) { | 13847 if (feature_info_->IsWebGL2OrES3Context()) { |
13851 if (GLES2Util::IsSizedColorFormat(internal_format)) { | 13848 if (GLES2Util::IsSizedColorFormat(internal_format)) { |
13852 int sr, sg, sb, sa; | 13849 int sr, sg, sb, sa; |
13853 GLES2Util::GetColorFormatComponentSizes( | 13850 GLES2Util::GetColorFormatComponentSizes( |
13854 read_format, read_type, &sr, &sg, &sb, &sa); | 13851 read_format, read_type, &sr, &sg, &sb, &sa); |
13855 DCHECK(sr > 0 || sg > 0 || sb > 0 || sa > 0); | 13852 DCHECK(sr > 0 || sg > 0 || sb > 0 || sa > 0); |
13856 int dr, dg, db, da; | 13853 int dr, dg, db, da; |
13857 GLES2Util::GetColorFormatComponentSizes( | 13854 GLES2Util::GetColorFormatComponentSizes( |
13858 internal_format, 0, &dr, &dg, &db, &da); | 13855 internal_format, 0, &dr, &dg, &db, &da); |
13859 DCHECK(dr > 0 || dg > 0 || db > 0 || da > 0); | 13856 DCHECK(dr > 0 || dg > 0 || db > 0 || da > 0); |
13860 if ((dr > 0 && sr != dr) || | 13857 if ((dr > 0 && sr != dr) || |
13861 (dg > 0 && sg != dg) || | 13858 (dg > 0 && sg != dg) || |
13862 (db > 0 && sb != db) || | 13859 (db > 0 && sb != db) || |
13863 (da > 0 && sa != da)) { | 13860 (da > 0 && sa != da)) { |
13864 *output_error_msg = std::string("incompatible color component sizes"); | 13861 LOCAL_SET_GL_ERROR( |
| 13862 GL_INVALID_OPERATION, |
| 13863 func_name, "incompatible color component sizes"); |
13865 return false; | 13864 return false; |
13866 } | 13865 } |
13867 } | 13866 } |
13868 } | 13867 } |
13869 return true; | 13868 return true; |
13870 } | 13869 } |
13871 | |
13872 bool GLES2DecoderImpl::ValidateCopyTexFormat(const char* func_name, | |
13873 GLenum internal_format, | |
13874 GLenum read_format, | |
13875 GLenum read_type) { | |
13876 std::string output_error_msg; | |
13877 if (!ValidateCopyTexFormatHelper(internal_format, read_format, read_type, | |
13878 &output_error_msg)) { | |
13879 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, | |
13880 output_error_msg.c_str()); | |
13881 return false; | |
13882 } | |
13883 return true; | |
13884 } | |
13885 | 13870 |
13886 void GLES2DecoderImpl::DoCopyTexImage2D( | 13871 void GLES2DecoderImpl::DoCopyTexImage2D( |
13887 GLenum target, | 13872 GLenum target, |
13888 GLint level, | 13873 GLint level, |
13889 GLenum internal_format, | 13874 GLenum internal_format, |
13890 GLint x, | 13875 GLint x, |
13891 GLint y, | 13876 GLint y, |
13892 GLsizei width, | 13877 GLsizei width, |
13893 GLsizei height, | 13878 GLsizei height, |
13894 GLint border) { | 13879 GLint border) { |
(...skipping 2185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16080 case GL_TEXTURE_EXTERNAL_OES: | 16065 case GL_TEXTURE_EXTERNAL_OES: |
16081 break; | 16066 break; |
16082 default: | 16067 default: |
16083 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, | 16068 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, |
16084 "invalid source texture target binding"); | 16069 "invalid source texture target binding"); |
16085 return false; | 16070 return false; |
16086 } | 16071 } |
16087 return true; | 16072 return true; |
16088 } | 16073 } |
16089 | 16074 |
16090 CopyTextureMethod GLES2DecoderImpl::ValidateCopyTextureCHROMIUMInternalFormats( | 16075 bool GLES2DecoderImpl::ValidateCopyTextureCHROMIUMInternalFormats( |
16091 const char* function_name, | 16076 const char* function_name, |
16092 TextureRef* source_texture_ref, | 16077 TextureRef* source_texture_ref, |
16093 GLenum dest_internal_format) { | 16078 GLenum dest_internal_format) { |
16094 GLenum source_type = 0; | 16079 GLenum source_type = 0; |
16095 GLenum source_internal_format = 0; | 16080 GLenum source_internal_format = 0; |
16096 Texture* source_texture = source_texture_ref->texture(); | 16081 Texture* source_texture = source_texture_ref->texture(); |
16097 source_texture->GetLevelType(source_texture->target(), 0, &source_type, | 16082 source_texture->GetLevelType(source_texture->target(), 0, &source_type, |
16098 &source_internal_format); | 16083 &source_internal_format); |
16099 | 16084 |
16100 bool valid_dest_format = false; | 16085 // The destination format should be GL_RGB, or GL_RGBA. GL_ALPHA, |
16101 // TODO(qiankun.miao@intel.com): ALPHA, LUMINANCE and LUMINANCE_ALPHA formats | 16086 // GL_LUMINANCE, and GL_LUMINANCE_ALPHA are not supported because they are not |
16102 // are not supported on GL core profile. See crbug.com/577144. Enable the | 16087 // renderable on some platforms. |
16103 // workaround for glCopyTexImage and glCopyTexSubImage in | 16088 bool valid_dest_format = |
16104 // gles2_cmd_copy_tex_image.cc for glCopyTextureCHROMIUM implementation. | 16089 dest_internal_format == GL_RGB || dest_internal_format == GL_RGBA || |
16105 switch (dest_internal_format) { | 16090 dest_internal_format == GL_RGB8 || dest_internal_format == GL_RGBA8 || |
16106 case GL_RGB: | 16091 dest_internal_format == GL_BGRA_EXT || |
16107 case GL_RGBA: | 16092 dest_internal_format == GL_BGRA8_EXT; |
16108 case GL_RGB8: | |
16109 case GL_RGBA8: | |
16110 valid_dest_format = true; | |
16111 break; | |
16112 case GL_BGRA_EXT: | |
16113 case GL_BGRA8_EXT: | |
16114 valid_dest_format = | |
16115 feature_info_->feature_flags().ext_texture_format_bgra8888; | |
16116 break; | |
16117 case GL_SRGB_EXT: | |
16118 case GL_SRGB_ALPHA_EXT: | |
16119 valid_dest_format = feature_info_->feature_flags().ext_srgb; | |
16120 break; | |
16121 case GL_R8: | |
16122 case GL_R8UI: | |
16123 case GL_RG8: | |
16124 case GL_RG8UI: | |
16125 case GL_SRGB8: | |
16126 case GL_RGB565: | |
16127 case GL_RGB8UI: | |
16128 case GL_SRGB8_ALPHA8: | |
16129 case GL_RGB5_A1: | |
16130 case GL_RGBA4: | |
16131 case GL_RGBA8UI: | |
16132 valid_dest_format = feature_info_->IsWebGL2OrES3Context(); | |
16133 break; | |
16134 case GL_RGB9_E5: | |
16135 valid_dest_format = !gl_version_info().is_es; | |
16136 break; | |
16137 case GL_R16F: | |
16138 case GL_R32F: | |
16139 case GL_RG16F: | |
16140 case GL_RG32F: | |
16141 case GL_RGB16F: | |
16142 case GL_RGB32F: | |
16143 case GL_RGBA16F: | |
16144 case GL_RGBA32F: | |
16145 case GL_R11F_G11F_B10F: | |
16146 valid_dest_format = feature_info_->ext_color_buffer_float_available(); | |
16147 break; | |
16148 default: | |
16149 valid_dest_format = false; | |
16150 break; | |
16151 } | |
16152 | |
16153 bool valid_source_format = | 16093 bool valid_source_format = |
16154 source_internal_format == GL_RED || source_internal_format == GL_ALPHA || | 16094 source_internal_format == GL_RED || source_internal_format == GL_ALPHA || |
16155 source_internal_format == GL_RGB || source_internal_format == GL_RGBA || | 16095 source_internal_format == GL_RGB || source_internal_format == GL_RGBA || |
16156 source_internal_format == GL_RGB8 || source_internal_format == GL_RGBA8 || | 16096 source_internal_format == GL_RGB8 || source_internal_format == GL_RGBA8 || |
16157 source_internal_format == GL_LUMINANCE || | 16097 source_internal_format == GL_LUMINANCE || |
16158 source_internal_format == GL_LUMINANCE_ALPHA || | 16098 source_internal_format == GL_LUMINANCE_ALPHA || |
16159 source_internal_format == GL_BGRA_EXT || | 16099 source_internal_format == GL_BGRA_EXT || |
16160 source_internal_format == GL_BGRA8_EXT || | 16100 source_internal_format == GL_BGRA8_EXT || |
16161 source_internal_format == GL_RGB_YCBCR_420V_CHROMIUM || | 16101 source_internal_format == GL_RGB_YCBCR_420V_CHROMIUM || |
16162 source_internal_format == GL_RGB_YCBCR_422_CHROMIUM; | 16102 source_internal_format == GL_RGB_YCBCR_422_CHROMIUM; |
16163 if (!valid_source_format) { | 16103 if (!valid_source_format) { |
16164 std::string msg = "invalid source internal format " + | 16104 std::string msg = "invalid source internal format " + |
16165 GLES2Util::GetStringEnum(source_internal_format); | 16105 GLES2Util::GetStringEnum(source_internal_format); |
16166 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, | 16106 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, |
16167 msg.c_str()); | 16107 msg.c_str()); |
16168 return NOT_COPYABLE; | 16108 return false; |
16169 } | 16109 } |
16170 if (!valid_dest_format) { | 16110 if (!valid_dest_format) { |
16171 std::string msg = "invalid dest internal format " + | 16111 std::string msg = "invalid dest internal format " + |
16172 GLES2Util::GetStringEnum(dest_internal_format); | 16112 GLES2Util::GetStringEnum(dest_internal_format); |
16173 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, | 16113 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, |
16174 msg.c_str()); | 16114 msg.c_str()); |
16175 return NOT_COPYABLE; | 16115 return false; |
16176 } | 16116 } |
16177 | 16117 return true; |
16178 bool source_format_color_renderable = | |
16179 Texture::ColorRenderable(GetFeatureInfo(), source_internal_format, false); | |
16180 bool dest_format_color_renderable = | |
16181 Texture::ColorRenderable(GetFeatureInfo(), dest_internal_format, false); | |
16182 std::string output_error_msg; | |
16183 | |
16184 // CopyTexImage* should not allow internalformat of GL_BGRA_EXT and | |
16185 // GL_BGRA8_EXT. crbug.com/663086. | |
16186 bool copy_tex_image_format_valid = | |
16187 source_internal_format != GL_BGRA_EXT && | |
16188 dest_internal_format != GL_BGRA_EXT && | |
16189 source_internal_format != GL_BGRA8_EXT && | |
16190 dest_internal_format != GL_BGRA8_EXT && | |
16191 ValidateCopyTexFormatHelper(dest_internal_format, source_internal_format, | |
16192 source_type, &output_error_msg); | |
16193 if (source_format_color_renderable && copy_tex_image_format_valid) | |
16194 return DIRECT_COPY; | |
16195 | |
16196 if (dest_format_color_renderable) | |
16197 return DIRECT_DRAW; | |
16198 | |
16199 return DRAW_AND_COPY; | |
16200 } | 16118 } |
16201 | 16119 |
16202 bool GLES2DecoderImpl::ValidateCompressedCopyTextureCHROMIUM( | 16120 bool GLES2DecoderImpl::ValidateCompressedCopyTextureCHROMIUM( |
16203 const char* function_name, | 16121 const char* function_name, |
16204 TextureRef* source_texture_ref, | 16122 TextureRef* source_texture_ref, |
16205 TextureRef* dest_texture_ref) { | 16123 TextureRef* dest_texture_ref) { |
16206 if (!source_texture_ref || !dest_texture_ref) { | 16124 if (!source_texture_ref || !dest_texture_ref) { |
16207 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "unknown texture id"); | 16125 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "unknown texture id"); |
16208 return false; | 16126 return false; |
16209 } | 16127 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16253 GLenum dest_type, | 16171 GLenum dest_type, |
16254 GLboolean unpack_flip_y, | 16172 GLboolean unpack_flip_y, |
16255 GLboolean unpack_premultiply_alpha, | 16173 GLboolean unpack_premultiply_alpha, |
16256 GLboolean unpack_unmultiply_alpha) { | 16174 GLboolean unpack_unmultiply_alpha) { |
16257 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopyTextureCHROMIUM"); | 16175 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopyTextureCHROMIUM"); |
16258 static const char kFunctionName[] = "glCopyTextureCHROMIUM"; | 16176 static const char kFunctionName[] = "glCopyTextureCHROMIUM"; |
16259 | 16177 |
16260 TextureRef* source_texture_ref = GetTexture(source_id); | 16178 TextureRef* source_texture_ref = GetTexture(source_id); |
16261 TextureRef* dest_texture_ref = GetTexture(dest_id); | 16179 TextureRef* dest_texture_ref = GetTexture(dest_id); |
16262 | 16180 |
| 16181 if (!texture_manager()->ValidateTextureParameters( |
| 16182 GetErrorState(), kFunctionName, true, internal_format, dest_type, |
| 16183 internal_format, 0)) |
| 16184 return; |
| 16185 |
16263 if (!ValidateCopyTextureCHROMIUMTextures(kFunctionName, source_texture_ref, | 16186 if (!ValidateCopyTextureCHROMIUMTextures(kFunctionName, source_texture_ref, |
16264 dest_texture_ref)) { | 16187 dest_texture_ref)) { |
16265 return; | 16188 return; |
16266 } | 16189 } |
16267 | 16190 |
| 16191 if (!ValidateCopyTextureCHROMIUMInternalFormats( |
| 16192 kFunctionName, source_texture_ref, internal_format)) { |
| 16193 return; |
| 16194 } |
| 16195 |
16268 Texture* source_texture = source_texture_ref->texture(); | 16196 Texture* source_texture = source_texture_ref->texture(); |
16269 Texture* dest_texture = dest_texture_ref->texture(); | 16197 Texture* dest_texture = dest_texture_ref->texture(); |
16270 GLenum source_target = source_texture->target(); | 16198 GLenum source_target = source_texture->target(); |
16271 GLenum dest_target = dest_texture->target(); | 16199 GLenum dest_target = dest_texture->target(); |
16272 | |
16273 GLenum source_type = 0; | |
16274 GLenum source_internal_format = 0; | |
16275 source_texture->GetLevelType(source_target, 0, &source_type, | |
16276 &source_internal_format); | |
16277 GLenum format = | |
16278 TextureManager::ExtractFormatFromStorageFormat(internal_format); | |
16279 if (!texture_manager()->ValidateTextureParameters( | |
16280 GetErrorState(), kFunctionName, true, format, dest_type, | |
16281 internal_format, 0)) { | |
16282 return; | |
16283 } | |
16284 | |
16285 CopyTextureMethod method = ValidateCopyTextureCHROMIUMInternalFormats( | |
16286 kFunctionName, source_texture_ref, internal_format); | |
16287 // INVALID_OPERATION is already generated by | |
16288 // ValidateCopyTextureCHROMIUMInternalFormats. | |
16289 if (NOT_COPYABLE == method) { | |
16290 return; | |
16291 } | |
16292 | |
16293 if (feature_info_->feature_flags().desktop_srgb_support) { | |
16294 bool enable_framebuffer_srgb = | |
16295 GetColorEncodingFromInternalFormat(source_internal_format) == GL_SRGB || | |
16296 GetColorEncodingFromInternalFormat(internal_format) == GL_SRGB; | |
16297 state_.EnableDisableFramebufferSRGB(enable_framebuffer_srgb); | |
16298 } | |
16299 | |
16300 int source_width = 0; | 16200 int source_width = 0; |
16301 int source_height = 0; | 16201 int source_height = 0; |
16302 gl::GLImage* image = | 16202 gl::GLImage* image = |
16303 source_texture->GetLevelImage(source_target, 0); | 16203 source_texture->GetLevelImage(source_target, 0); |
16304 if (image) { | 16204 if (image) { |
16305 gfx::Size size = image->GetSize(); | 16205 gfx::Size size = image->GetSize(); |
16306 source_width = size.width(); | 16206 source_width = size.width(); |
16307 source_height = size.height(); | 16207 source_height = size.height(); |
16308 if (source_width <= 0 || source_height <= 0) { | 16208 if (source_width <= 0 || source_height <= 0) { |
16309 LOCAL_SET_GL_ERROR( | 16209 LOCAL_SET_GL_ERROR( |
(...skipping 11 matching lines...) Expand all Loading... |
16321 } | 16221 } |
16322 | 16222 |
16323 // Check that this type of texture is allowed. | 16223 // Check that this type of texture is allowed. |
16324 if (!texture_manager()->ValidForTarget(source_target, 0, | 16224 if (!texture_manager()->ValidForTarget(source_target, 0, |
16325 source_width, source_height, 1)) { | 16225 source_width, source_height, 1)) { |
16326 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "Bad dimensions"); | 16226 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "Bad dimensions"); |
16327 return; | 16227 return; |
16328 } | 16228 } |
16329 } | 16229 } |
16330 | 16230 |
| 16231 GLenum source_type = 0; |
| 16232 GLenum source_internal_format = 0; |
| 16233 source_texture->GetLevelType(source_target, 0, &source_type, |
| 16234 &source_internal_format); |
| 16235 |
16331 if (dest_texture->IsImmutable()) { | 16236 if (dest_texture->IsImmutable()) { |
16332 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, | 16237 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, |
16333 "texture is immutable"); | 16238 "texture is immutable"); |
16334 return; | 16239 return; |
16335 } | 16240 } |
16336 | 16241 |
16337 // Clear the source texture if necessary. | 16242 // Clear the source texture if necessary. |
16338 if (!texture_manager()->ClearTextureLevel(this, source_texture_ref, | 16243 if (!texture_manager()->ClearTextureLevel(this, source_texture_ref, |
16339 source_target, 0)) { | 16244 source_target, 0)) { |
16340 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, kFunctionName, "dimensions too big"); | 16245 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, kFunctionName, "dimensions too big"); |
(...skipping 16 matching lines...) Expand all Loading... |
16357 } | 16262 } |
16358 | 16263 |
16359 // Resize the destination texture to the dimensions of the source texture. | 16264 // Resize the destination texture to the dimensions of the source texture. |
16360 if (!dest_level_defined || dest_width != source_width || | 16265 if (!dest_level_defined || dest_width != source_width || |
16361 dest_height != source_height || | 16266 dest_height != source_height || |
16362 dest_internal_format != internal_format || | 16267 dest_internal_format != internal_format || |
16363 dest_type_previous != dest_type) { | 16268 dest_type_previous != dest_type) { |
16364 // Ensure that the glTexImage2D succeeds. | 16269 // Ensure that the glTexImage2D succeeds. |
16365 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(kFunctionName); | 16270 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(kFunctionName); |
16366 glBindTexture(dest_target, dest_texture->service_id()); | 16271 glBindTexture(dest_target, dest_texture->service_id()); |
16367 glTexImage2D(dest_target, 0, TextureManager::AdjustTexInternalFormat( | 16272 glTexImage2D( |
16368 feature_info_.get(), internal_format), | 16273 dest_target, 0, TextureManager::AdjustTexInternalFormat( |
16369 source_width, source_height, 0, | 16274 feature_info_.get(), internal_format), |
16370 TextureManager::AdjustTexFormat(feature_info_.get(), format), | 16275 source_width, source_height, 0, |
16371 dest_type, NULL); | 16276 TextureManager::AdjustTexFormat(feature_info_.get(), internal_format), |
| 16277 dest_type, NULL); |
16372 GLenum error = LOCAL_PEEK_GL_ERROR(kFunctionName); | 16278 GLenum error = LOCAL_PEEK_GL_ERROR(kFunctionName); |
16373 if (error != GL_NO_ERROR) { | 16279 if (error != GL_NO_ERROR) { |
16374 RestoreCurrentTextureBindings(&state_, dest_target); | 16280 RestoreCurrentTextureBindings(&state_, dest_target); |
16375 return; | 16281 return; |
16376 } | 16282 } |
16377 | 16283 |
16378 texture_manager()->SetLevelInfo(dest_texture_ref, dest_target, 0, | 16284 texture_manager()->SetLevelInfo( |
16379 internal_format, source_width, | 16285 dest_texture_ref, dest_target, 0, internal_format, source_width, |
16380 source_height, 1, 0, format, dest_type, | 16286 source_height, 1, 0, internal_format, dest_type, |
16381 gfx::Rect(source_width, source_height)); | 16287 gfx::Rect(source_width, source_height)); |
16382 dest_texture->ApplyFormatWorkarounds(feature_info_.get()); | 16288 dest_texture->ApplyFormatWorkarounds(feature_info_.get()); |
16383 } else { | 16289 } else { |
16384 texture_manager()->SetLevelCleared(dest_texture_ref, dest_target, 0, true); | 16290 texture_manager()->SetLevelCleared(dest_texture_ref, dest_target, 0, |
| 16291 true); |
16385 } | 16292 } |
16386 | 16293 |
16387 // Try using GLImage::CopyTexImage when possible. | 16294 // Try using GLImage::CopyTexImage when possible. |
16388 bool unpack_premultiply_alpha_change = | 16295 bool unpack_premultiply_alpha_change = |
16389 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0; | 16296 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0; |
16390 if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) { | 16297 if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) { |
16391 glBindTexture(dest_target, dest_texture->service_id()); | 16298 glBindTexture(dest_target, dest_texture->service_id()); |
16392 if (image->CopyTexImage(dest_target)) | 16299 if (image->CopyTexImage(dest_target)) |
16393 return; | 16300 return; |
16394 } | 16301 } |
16395 | 16302 |
16396 DoCopyTexImageIfNeeded(source_texture, source_target); | 16303 DoCopyTexImageIfNeeded(source_texture, source_target); |
16397 | 16304 |
16398 // GL_TEXTURE_EXTERNAL_OES texture requires that we apply a transform matrix | 16305 // GL_TEXTURE_EXTERNAL_OES texture requires that we apply a transform matrix |
16399 // before presenting. | 16306 // before presenting. |
16400 if (source_target == GL_TEXTURE_EXTERNAL_OES) { | 16307 if (source_target == GL_TEXTURE_EXTERNAL_OES) { |
16401 if (GLStreamTextureImage* image = | 16308 if (GLStreamTextureImage* image = |
16402 source_texture->GetLevelStreamTextureImage(GL_TEXTURE_EXTERNAL_OES, | 16309 source_texture->GetLevelStreamTextureImage(GL_TEXTURE_EXTERNAL_OES, |
16403 0)) { | 16310 0)) { |
16404 GLfloat transform_matrix[16]; | 16311 GLfloat transform_matrix[16]; |
16405 image->GetTextureMatrix(transform_matrix); | 16312 image->GetTextureMatrix(transform_matrix); |
16406 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( | 16313 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( |
16407 this, source_target, source_texture->service_id(), | 16314 this, source_target, source_texture->service_id(), dest_target, |
16408 source_internal_format, dest_target, dest_texture->service_id(), | 16315 dest_texture->service_id(), source_width, source_height, |
16409 internal_format, source_width, source_height, | |
16410 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE, | 16316 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE, |
16411 unpack_unmultiply_alpha == GL_TRUE, transform_matrix); | 16317 unpack_unmultiply_alpha == GL_TRUE, transform_matrix); |
16412 return; | 16318 return; |
16413 } | 16319 } |
16414 } | 16320 } |
16415 | |
16416 copy_texture_CHROMIUM_->DoCopyTexture( | 16321 copy_texture_CHROMIUM_->DoCopyTexture( |
16417 this, source_target, source_texture->service_id(), source_internal_format, | 16322 this, source_target, source_texture->service_id(), source_internal_format, |
16418 dest_target, dest_texture->service_id(), internal_format, source_width, | 16323 dest_target, dest_texture->service_id(), internal_format, source_width, |
16419 source_height, unpack_flip_y == GL_TRUE, | 16324 source_height, unpack_flip_y == GL_TRUE, |
16420 unpack_premultiply_alpha == GL_TRUE, unpack_unmultiply_alpha == GL_TRUE, | 16325 unpack_premultiply_alpha == GL_TRUE, unpack_unmultiply_alpha == GL_TRUE); |
16421 method); | |
16422 } | 16326 } |
16423 | 16327 |
16424 void GLES2DecoderImpl::DoCopySubTextureCHROMIUM( | 16328 void GLES2DecoderImpl::DoCopySubTextureCHROMIUM( |
16425 GLuint source_id, | 16329 GLuint source_id, |
16426 GLuint dest_id, | 16330 GLuint dest_id, |
16427 GLint xoffset, | 16331 GLint xoffset, |
16428 GLint yoffset, | 16332 GLint yoffset, |
16429 GLint x, | 16333 GLint x, |
16430 GLint y, | 16334 GLint y, |
16431 GLsizei width, | 16335 GLsizei width, |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16513 "destination texture is not defined"); | 16417 "destination texture is not defined"); |
16514 return; | 16418 return; |
16515 } | 16419 } |
16516 if (!dest_texture->ValidForTexture(dest_target, 0, xoffset, | 16420 if (!dest_texture->ValidForTexture(dest_target, 0, xoffset, |
16517 yoffset, 0, width, height, 1)) { | 16421 yoffset, 0, width, height, 1)) { |
16518 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, | 16422 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, |
16519 "destination texture bad dimensions."); | 16423 "destination texture bad dimensions."); |
16520 return; | 16424 return; |
16521 } | 16425 } |
16522 | 16426 |
16523 CopyTextureMethod method = ValidateCopyTextureCHROMIUMInternalFormats( | 16427 if (!ValidateCopyTextureCHROMIUMInternalFormats( |
16524 kFunctionName, source_texture_ref, dest_internal_format); | 16428 kFunctionName, source_texture_ref, dest_internal_format)) { |
16525 // INVALID_OPERATION is already generated by | |
16526 // ValidateCopyTextureCHROMIUMInternalFormats. | |
16527 if (NOT_COPYABLE == method) { | |
16528 return; | 16429 return; |
16529 } | 16430 } |
16530 | 16431 |
16531 if (feature_info_->feature_flags().desktop_srgb_support) { | |
16532 bool enable_framebuffer_srgb = | |
16533 GetColorEncodingFromInternalFormat(source_internal_format) == GL_SRGB || | |
16534 GetColorEncodingFromInternalFormat(dest_internal_format) == GL_SRGB; | |
16535 state_.EnableDisableFramebufferSRGB(enable_framebuffer_srgb); | |
16536 } | |
16537 | |
16538 // Clear the source texture if necessary. | 16432 // Clear the source texture if necessary. |
16539 if (!texture_manager()->ClearTextureLevel(this, source_texture_ref, | 16433 if (!texture_manager()->ClearTextureLevel(this, source_texture_ref, |
16540 source_target, 0)) { | 16434 source_target, 0)) { |
16541 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, kFunctionName, | 16435 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, kFunctionName, |
16542 "source texture dimensions too big"); | 16436 "source texture dimensions too big"); |
16543 return; | 16437 return; |
16544 } | 16438 } |
16545 | 16439 |
16546 if (!InitializeCopyTextureCHROMIUM(kFunctionName)) | 16440 if (!InitializeCopyTextureCHROMIUM(kFunctionName)) |
16547 return; | 16441 return; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16606 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE, | 16500 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE, |
16607 unpack_unmultiply_alpha == GL_TRUE, transform_matrix); | 16501 unpack_unmultiply_alpha == GL_TRUE, transform_matrix); |
16608 return; | 16502 return; |
16609 } | 16503 } |
16610 } | 16504 } |
16611 copy_texture_CHROMIUM_->DoCopySubTexture( | 16505 copy_texture_CHROMIUM_->DoCopySubTexture( |
16612 this, source_target, source_texture->service_id(), source_internal_format, | 16506 this, source_target, source_texture->service_id(), source_internal_format, |
16613 dest_target, dest_texture->service_id(), dest_internal_format, xoffset, | 16507 dest_target, dest_texture->service_id(), dest_internal_format, xoffset, |
16614 yoffset, x, y, width, height, dest_width, dest_height, source_width, | 16508 yoffset, x, y, width, height, dest_width, dest_height, source_width, |
16615 source_height, unpack_flip_y == GL_TRUE, | 16509 source_height, unpack_flip_y == GL_TRUE, |
16616 unpack_premultiply_alpha == GL_TRUE, unpack_unmultiply_alpha == GL_TRUE, | 16510 unpack_premultiply_alpha == GL_TRUE, unpack_unmultiply_alpha == GL_TRUE); |
16617 method); | |
16618 } | 16511 } |
16619 | 16512 |
16620 bool GLES2DecoderImpl::InitializeCopyTexImageBlitter( | 16513 bool GLES2DecoderImpl::InitializeCopyTexImageBlitter( |
16621 const char* function_name) { | 16514 const char* function_name) { |
16622 if (!copy_tex_image_blit_.get()) { | 16515 if (!copy_tex_image_blit_.get()) { |
16623 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(function_name); | 16516 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(function_name); |
16624 copy_tex_image_blit_.reset( | 16517 copy_tex_image_blit_.reset( |
16625 new CopyTexImageResourceManager(feature_info_.get())); | 16518 new CopyTexImageResourceManager(feature_info_.get())); |
16626 copy_tex_image_blit_->Initialize(this); | 16519 copy_tex_image_blit_->Initialize(this); |
16627 if (LOCAL_PEEK_GL_ERROR(function_name) != GL_NO_ERROR) | 16520 if (LOCAL_PEEK_GL_ERROR(function_name) != GL_NO_ERROR) |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16782 | 16675 |
16783 texture_manager()->SetLevelInfo( | 16676 texture_manager()->SetLevelInfo( |
16784 dest_texture_ref, dest_texture->target(), 0, GL_RGBA, source_width, | 16677 dest_texture_ref, dest_texture->target(), 0, GL_RGBA, source_width, |
16785 source_height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 16678 source_height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
16786 gfx::Rect(source_width, source_height)); | 16679 gfx::Rect(source_width, source_height)); |
16787 | 16680 |
16788 copy_texture_CHROMIUM_->DoCopyTexture( | 16681 copy_texture_CHROMIUM_->DoCopyTexture( |
16789 this, source_texture->target(), source_texture->service_id(), | 16682 this, source_texture->target(), source_texture->service_id(), |
16790 source_internal_format, dest_texture->target(), | 16683 source_internal_format, dest_texture->target(), |
16791 dest_texture->service_id(), GL_RGBA, source_width, source_height, false, | 16684 dest_texture->service_id(), GL_RGBA, source_width, source_height, false, |
16792 false, false, DIRECT_DRAW); | 16685 false, false); |
16793 } | 16686 } |
16794 | 16687 |
16795 void GLES2DecoderImpl::TexStorageImpl(GLenum target, | 16688 void GLES2DecoderImpl::TexStorageImpl(GLenum target, |
16796 GLsizei levels, | 16689 GLsizei levels, |
16797 GLenum internal_format, | 16690 GLenum internal_format, |
16798 GLsizei width, | 16691 GLsizei width, |
16799 GLsizei height, | 16692 GLsizei height, |
16800 GLsizei depth, | 16693 GLsizei depth, |
16801 ContextState::Dimension dimension, | 16694 ContextState::Dimension dimension, |
16802 const char* function_name) { | 16695 const char* function_name) { |
(...skipping 2235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19038 } | 18931 } |
19039 | 18932 |
19040 // Include the auto-generated part of this file. We split this because it means | 18933 // Include the auto-generated part of this file. We split this because it means |
19041 // we can easily edit the non-auto generated parts right here in this file | 18934 // we can easily edit the non-auto generated parts right here in this file |
19042 // instead of having to edit some template or the code generator. | 18935 // instead of having to edit some template or the code generator. |
19043 #include "base/macros.h" | 18936 #include "base/macros.h" |
19044 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 18937 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
19045 | 18938 |
19046 } // namespace gles2 | 18939 } // namespace gles2 |
19047 } // namespace gpu | 18940 } // namespace gpu |
OLD | NEW |