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

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 2479513002: Reland of Extend CopyTextureCHROMIUM to more ES 3.0 texture formats. (Closed)
Patch Set: fix comments from zmo #17 Created 4 years, 1 month 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 // 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 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 GLint yoffset, 882 GLint yoffset,
883 GLint zoffset, 883 GLint zoffset,
884 GLsizei width, 884 GLsizei width,
885 GLsizei height, 885 GLsizei height,
886 GLsizei depth, 886 GLsizei depth,
887 GLenum format, 887 GLenum format,
888 GLsizei imageSize, 888 GLsizei imageSize,
889 const void* data, 889 const void* data,
890 ContextState::Dimension dimension); 890 ContextState::Dimension dimension);
891 891
892 bool ValidateCopyTexFormatHelper(GLenum internal_format,
893 GLenum read_format,
894 GLenum read_type,
895 std::string* output_error_msg);
892 // Validate if |format| is valid for CopyTex{Sub}Image functions. 896 // Validate if |format| is valid for CopyTex{Sub}Image functions.
893 // If not, generate a GL error and return false. 897 // If not, generate a GL error and return false.
894 bool ValidateCopyTexFormat(const char* func_name, GLenum internal_format, 898 bool ValidateCopyTexFormat(const char* func_name, GLenum internal_format,
895 GLenum read_format, GLenum read_type); 899 GLenum read_format, GLenum read_type);
896 900
897 // Wrapper for CopyTexImage2D. 901 // Wrapper for CopyTexImage2D.
898 void DoCopyTexImage2D( 902 void DoCopyTexImage2D(
899 GLenum target, 903 GLenum target,
900 GLint level, 904 GLint level,
901 GLenum internal_format, 905 GLenum internal_format,
(...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after
1995 GLsizei size, 1999 GLsizei size,
1996 const GLvoid* data); 2000 const GLvoid* data);
1997 bool ValidateCompressedTexSubDimensions( 2001 bool ValidateCompressedTexSubDimensions(
1998 const char* function_name, 2002 const char* function_name,
1999 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, 2003 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset,
2000 GLsizei width, GLsizei height, GLsizei depth, GLenum format, 2004 GLsizei width, GLsizei height, GLsizei depth, GLenum format,
2001 Texture* texture); 2005 Texture* texture);
2002 bool ValidateCopyTextureCHROMIUMTextures(const char* function_name, 2006 bool ValidateCopyTextureCHROMIUMTextures(const char* function_name,
2003 TextureRef* source_texture_ref, 2007 TextureRef* source_texture_ref,
2004 TextureRef* dest_texture_ref); 2008 TextureRef* dest_texture_ref);
2005 bool ValidateCopyTextureCHROMIUMInternalFormats( 2009 SupportedCopyMethodByFormat ValidateCopyTextureCHROMIUMInternalFormats(
2006 const char* function_name, 2010 const char* function_name,
2007 TextureRef* source_texture_ref, 2011 TextureRef* source_texture_ref,
2008 GLenum dest_internal_format); 2012 GLenum dest_internal_format);
2009 bool ValidateCompressedCopyTextureCHROMIUM(const char* function_name, 2013 bool ValidateCompressedCopyTextureCHROMIUM(const char* function_name,
2010 TextureRef* source_texture_ref, 2014 TextureRef* source_texture_ref,
2011 TextureRef* dest_texture_ref); 2015 TextureRef* dest_texture_ref);
2012 2016
2013 void RenderWarning(const char* filename, int line, const std::string& msg); 2017 void RenderWarning(const char* filename, int line, const std::string& msg);
2014 void PerformanceWarning( 2018 void PerformanceWarning(
2015 const char* filename, int line, const std::string& msg); 2019 const char* filename, int line, const std::string& msg);
(...skipping 11715 matching lines...) Expand 10 before | Expand all | Expand 10 after
13731 height, depth, format, image_size, data); 13735 height, depth, format, image_size, data);
13732 } 13736 }
13733 } 13737 }
13734 13738
13735 // This may be a slow command. Exit command processing to allow for 13739 // This may be a slow command. Exit command processing to allow for
13736 // context preemption and GPU watchdog checks. 13740 // context preemption and GPU watchdog checks.
13737 ExitCommandProcessingEarly(); 13741 ExitCommandProcessingEarly();
13738 return error::kNoError; 13742 return error::kNoError;
13739 } 13743 }
13740 13744
13741 bool GLES2DecoderImpl::ValidateCopyTexFormat( 13745 bool GLES2DecoderImpl::ValidateCopyTexFormatHelper(
13742 const char* func_name, GLenum internal_format, 13746 GLenum internal_format,
13743 GLenum read_format, GLenum read_type) { 13747 GLenum read_format,
13748 GLenum read_type,
13749 std::string* output_error_msg) {
13750 DCHECK(output_error_msg);
13744 if (read_format == 0) { 13751 if (read_format == 0) {
13745 LOCAL_SET_GL_ERROR( 13752 *output_error_msg = std::string("no valid color image");
13746 GL_INVALID_OPERATION, func_name, "no valid color image");
13747 return false; 13753 return false;
13748 } 13754 }
13749 // Check we have compatible formats. 13755 // Check we have compatible formats.
13750 uint32_t channels_exist = GLES2Util::GetChannelsForFormat(read_format); 13756 uint32_t channels_exist = GLES2Util::GetChannelsForFormat(read_format);
13751 uint32_t channels_needed = GLES2Util::GetChannelsForFormat(internal_format); 13757 uint32_t channels_needed = GLES2Util::GetChannelsForFormat(internal_format);
13752 if (!channels_needed || 13758 if (!channels_needed ||
13753 (channels_needed & channels_exist) != channels_needed) { 13759 (channels_needed & channels_exist) != channels_needed) {
13754 LOCAL_SET_GL_ERROR( 13760 *output_error_msg = std::string("incompatible format");
13755 GL_INVALID_OPERATION, func_name, "incompatible format");
13756 return false; 13761 return false;
13757 } 13762 }
13758 if (feature_info_->IsWebGL2OrES3Context()) { 13763 if (feature_info_->IsWebGL2OrES3Context()) {
13759 GLint color_encoding = GetColorEncodingFromInternalFormat(read_format); 13764 GLint color_encoding = GetColorEncodingFromInternalFormat(read_format);
13760 bool float_mismatch = feature_info_->ext_color_buffer_float_available() ? 13765 bool float_mismatch = feature_info_->ext_color_buffer_float_available() ?
13761 (GLES2Util::IsIntegerFormat(internal_format) != 13766 (GLES2Util::IsIntegerFormat(internal_format) !=
13762 GLES2Util::IsIntegerFormat(read_format)) : 13767 GLES2Util::IsIntegerFormat(read_format)) :
13763 GLES2Util::IsFloatFormat(internal_format); 13768 GLES2Util::IsFloatFormat(internal_format);
13764 if (color_encoding != GetColorEncodingFromInternalFormat(internal_format) || 13769 if (color_encoding != GetColorEncodingFromInternalFormat(internal_format) ||
13765 float_mismatch || 13770 float_mismatch ||
13766 (GLES2Util::IsSignedIntegerFormat(internal_format) != 13771 (GLES2Util::IsSignedIntegerFormat(internal_format) !=
13767 GLES2Util::IsSignedIntegerFormat(read_format)) || 13772 GLES2Util::IsSignedIntegerFormat(read_format)) ||
13768 (GLES2Util::IsUnsignedIntegerFormat(internal_format) != 13773 (GLES2Util::IsUnsignedIntegerFormat(internal_format) !=
13769 GLES2Util::IsUnsignedIntegerFormat(read_format))) { 13774 GLES2Util::IsUnsignedIntegerFormat(read_format))) {
13770 LOCAL_SET_GL_ERROR( 13775 *output_error_msg = std::string("incompatible format");
13771 GL_INVALID_OPERATION, func_name, "incompatible format");
13772 return false; 13776 return false;
13773 } 13777 }
13774 } 13778 }
13775 if ((channels_needed & (GLES2Util::kDepth | GLES2Util::kStencil)) != 0) { 13779 if ((channels_needed & (GLES2Util::kDepth | GLES2Util::kStencil)) != 0) {
13776 LOCAL_SET_GL_ERROR( 13780 *output_error_msg =
13777 GL_INVALID_OPERATION, 13781 std::string("can not be used with depth or stencil textures");
13778 func_name, "can not be used with depth or stencil textures");
13779 return false; 13782 return false;
13780 } 13783 }
13781 if (feature_info_->IsWebGL2OrES3Context()) { 13784 if (feature_info_->IsWebGL2OrES3Context()) {
13782 if (GLES2Util::IsSizedColorFormat(internal_format)) { 13785 if (GLES2Util::IsSizedColorFormat(internal_format)) {
13783 int sr, sg, sb, sa; 13786 int sr, sg, sb, sa;
13784 GLES2Util::GetColorFormatComponentSizes( 13787 GLES2Util::GetColorFormatComponentSizes(
13785 read_format, read_type, &sr, &sg, &sb, &sa); 13788 read_format, read_type, &sr, &sg, &sb, &sa);
13786 DCHECK(sr > 0 || sg > 0 || sb > 0 || sa > 0); 13789 DCHECK(sr > 0 || sg > 0 || sb > 0 || sa > 0);
13787 int dr, dg, db, da; 13790 int dr, dg, db, da;
13788 GLES2Util::GetColorFormatComponentSizes( 13791 GLES2Util::GetColorFormatComponentSizes(
13789 internal_format, 0, &dr, &dg, &db, &da); 13792 internal_format, 0, &dr, &dg, &db, &da);
13790 DCHECK(dr > 0 || dg > 0 || db > 0 || da > 0); 13793 DCHECK(dr > 0 || dg > 0 || db > 0 || da > 0);
13791 if ((dr > 0 && sr != dr) || 13794 if ((dr > 0 && sr != dr) ||
13792 (dg > 0 && sg != dg) || 13795 (dg > 0 && sg != dg) ||
13793 (db > 0 && sb != db) || 13796 (db > 0 && sb != db) ||
13794 (da > 0 && sa != da)) { 13797 (da > 0 && sa != da)) {
13795 LOCAL_SET_GL_ERROR( 13798 *output_error_msg = std::string("incompatible color component sizes");
13796 GL_INVALID_OPERATION,
13797 func_name, "incompatible color component sizes");
13798 return false; 13799 return false;
13799 } 13800 }
13800 } 13801 }
13801 } 13802 }
13802 return true; 13803 return true;
13803 } 13804 }
13804 13805
13806 bool GLES2DecoderImpl::ValidateCopyTexFormat(const char* func_name,
13807 GLenum internal_format,
13808 GLenum read_format,
13809 GLenum read_type) {
13810 std::string output_error_msg;
13811 if (!ValidateCopyTexFormatHelper(internal_format, read_format, read_type,
13812 &output_error_msg)) {
13813 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name,
13814 output_error_msg.c_str());
13815 return false;
13816 }
13817 return true;
13818 }
13819
13805 void GLES2DecoderImpl::DoCopyTexImage2D( 13820 void GLES2DecoderImpl::DoCopyTexImage2D(
13806 GLenum target, 13821 GLenum target,
13807 GLint level, 13822 GLint level,
13808 GLenum internal_format, 13823 GLenum internal_format,
13809 GLint x, 13824 GLint x,
13810 GLint y, 13825 GLint y,
13811 GLsizei width, 13826 GLsizei width,
13812 GLsizei height, 13827 GLsizei height,
13813 GLint border) { 13828 GLint border) {
13814 const char* func_name = "glCopyTexImage2D"; 13829 const char* func_name = "glCopyTexImage2D";
(...skipping 2184 matching lines...) Expand 10 before | Expand all | Expand 10 after
15999 case GL_TEXTURE_EXTERNAL_OES: 16014 case GL_TEXTURE_EXTERNAL_OES:
16000 break; 16015 break;
16001 default: 16016 default:
16002 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, 16017 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name,
16003 "invalid source texture target binding"); 16018 "invalid source texture target binding");
16004 return false; 16019 return false;
16005 } 16020 }
16006 return true; 16021 return true;
16007 } 16022 }
16008 16023
16009 bool GLES2DecoderImpl::ValidateCopyTextureCHROMIUMInternalFormats( 16024 SupportedCopyMethodByFormat
16025 GLES2DecoderImpl::ValidateCopyTextureCHROMIUMInternalFormats(
16010 const char* function_name, 16026 const char* function_name,
16011 TextureRef* source_texture_ref, 16027 TextureRef* source_texture_ref,
16012 GLenum dest_internal_format) { 16028 GLenum dest_internal_format) {
16013 GLenum source_type = 0; 16029 GLenum source_type = 0;
16014 GLenum source_internal_format = 0; 16030 GLenum source_internal_format = 0;
16015 Texture* source_texture = source_texture_ref->texture(); 16031 Texture* source_texture = source_texture_ref->texture();
16016 source_texture->GetLevelType(source_texture->target(), 0, &source_type, 16032 source_texture->GetLevelType(source_texture->target(), 0, &source_type,
16017 &source_internal_format); 16033 &source_internal_format);
16018 16034
16019 // The destination format should be GL_RGB, or GL_RGBA. GL_ALPHA, 16035 bool valid_dest_format = false;
16020 // GL_LUMINANCE, and GL_LUMINANCE_ALPHA are not supported because they are not 16036 // TODO(qiankun.miao@intel.com): ALPHA, LUMINANCE and LUMINANCE_ALPHA formats
16021 // renderable on some platforms. 16037 // have bug on GL core profile. See crbug.com/577144. Enable the workaround
Zhenyao Mo 2016/12/01 01:34:02 It's not really a bug. something like "formats ar
qiankun 2016/12/02 16:53:46 Done.
16022 bool valid_dest_format = 16038 // for glCopyTexImage and glCopyTexSubImage in gles2_cmd_copy_tex_image.cc for
16023 dest_internal_format == GL_RGB || dest_internal_format == GL_RGBA || 16039 // glCopyTextureCHROMIUM implementation.
16024 dest_internal_format == GL_RGB8 || dest_internal_format == GL_RGBA8 || 16040 switch (dest_internal_format) {
16025 dest_internal_format == GL_BGRA_EXT || 16041 case GL_RGB:
16026 dest_internal_format == GL_BGRA8_EXT; 16042 case GL_RGBA:
16043 case GL_RGB8:
16044 case GL_RGBA8:
16045 valid_dest_format = true;
16046 break;
16047 case GL_BGRA_EXT:
16048 case GL_BGRA8_EXT:
16049 valid_dest_format =
16050 feature_info_->feature_flags().ext_texture_format_bgra8888;
16051 break;
16052 case GL_SRGB_EXT:
16053 case GL_SRGB_ALPHA_EXT:
16054 valid_dest_format = feature_info_->feature_flags().ext_srgb;
16055 break;
16056 case GL_R8:
16057 case GL_R8UI:
16058 case GL_RG8:
16059 case GL_RG8UI:
16060 case GL_SRGB8:
16061 case GL_RGB565:
16062 case GL_RGB9_E5:
16063 case GL_RGB8UI:
16064 case GL_SRGB8_ALPHA8:
16065 case GL_RGB5_A1:
16066 case GL_RGBA4:
16067 case GL_RGBA8UI:
16068 valid_dest_format = feature_info_->IsWebGL2OrES3Context();
16069 break;
16070 case GL_R16F:
16071 case GL_R32F:
16072 case GL_RG16F:
16073 case GL_RG32F:
16074 case GL_RGB16F:
16075 case GL_RGB32F:
16076 case GL_RGBA16F:
16077 case GL_RGBA32F:
16078 case GL_R11F_G11F_B10F:
16079 valid_dest_format = feature_info_->ext_color_buffer_float_available();
Zhenyao Mo 2016/12/03 00:39:20 Actually, even without this extension, so these fo
qiankun 2016/12/10 00:12:40 Add a TODO for this.
16080 break;
16081 default:
16082 valid_dest_format = false;
16083 break;
16084 }
16085
16027 bool valid_source_format = 16086 bool valid_source_format =
16028 source_internal_format == GL_RED || source_internal_format == GL_ALPHA || 16087 source_internal_format == GL_RED || source_internal_format == GL_ALPHA ||
16029 source_internal_format == GL_RGB || source_internal_format == GL_RGBA || 16088 source_internal_format == GL_RGB || source_internal_format == GL_RGBA ||
16030 source_internal_format == GL_RGB8 || source_internal_format == GL_RGBA8 || 16089 source_internal_format == GL_RGB8 || source_internal_format == GL_RGBA8 ||
16031 source_internal_format == GL_LUMINANCE || 16090 source_internal_format == GL_LUMINANCE ||
16032 source_internal_format == GL_LUMINANCE_ALPHA || 16091 source_internal_format == GL_LUMINANCE_ALPHA ||
16033 source_internal_format == GL_BGRA_EXT || 16092 source_internal_format == GL_BGRA_EXT ||
16034 source_internal_format == GL_BGRA8_EXT || 16093 source_internal_format == GL_BGRA8_EXT ||
16035 source_internal_format == GL_RGB_YCBCR_420V_CHROMIUM || 16094 source_internal_format == GL_RGB_YCBCR_420V_CHROMIUM ||
16036 source_internal_format == GL_RGB_YCBCR_422_CHROMIUM; 16095 source_internal_format == GL_RGB_YCBCR_422_CHROMIUM;
16037 if (!valid_source_format) { 16096 if (!valid_source_format) {
16038 std::string msg = "invalid source internal format " + 16097 std::string msg = "invalid source internal format " +
16039 GLES2Util::GetStringEnum(source_internal_format); 16098 GLES2Util::GetStringEnum(source_internal_format);
16040 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, 16099 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
16041 msg.c_str()); 16100 msg.c_str());
16042 return false; 16101 return NONE_COPY;
16043 } 16102 }
16044 if (!valid_dest_format) { 16103 if (!valid_dest_format) {
16045 std::string msg = "invalid dest internal format " + 16104 std::string msg = "invalid dest internal format " +
16046 GLES2Util::GetStringEnum(dest_internal_format); 16105 GLES2Util::GetStringEnum(dest_internal_format);
16047 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, 16106 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
16048 msg.c_str()); 16107 msg.c_str());
16049 return false; 16108 return NONE_COPY;
16050 } 16109 }
16051 return true; 16110
16111 bool source_format_color_renderable =
16112 Texture::ColorRenderable(GetFeatureInfo(), source_internal_format, false);
16113 bool dest_format_color_renderable =
16114 Texture::ColorRenderable(GetFeatureInfo(), dest_internal_format, false);
16115 std::string output_error_msg;
16116
16117 // CopyTexImage* should not allow internalformat of GL_BGRA_EXT and
16118 // GL_BGRA8_EXT. crbug.com/663086.
16119 bool copy_tex_image_format_valid =
16120 source_internal_format != GL_BGRA_EXT &&
16121 dest_internal_format != GL_BGRA_EXT &&
16122 source_internal_format != GL_BGRA8_EXT &&
16123 dest_internal_format != GL_BGRA8_EXT &&
16124 ValidateCopyTexFormatHelper(dest_internal_format, source_internal_format,
16125 source_type, &output_error_msg);
16126 if (source_format_color_renderable && copy_tex_image_format_valid)
16127 return DIRECT_COPY;
16128
16129 if (dest_format_color_renderable)
16130 return DIRECT_DRAW;
16131
16132 return DRAW_AND_COPY;
16052 } 16133 }
16053 16134
16054 bool GLES2DecoderImpl::ValidateCompressedCopyTextureCHROMIUM( 16135 bool GLES2DecoderImpl::ValidateCompressedCopyTextureCHROMIUM(
16055 const char* function_name, 16136 const char* function_name,
16056 TextureRef* source_texture_ref, 16137 TextureRef* source_texture_ref,
16057 TextureRef* dest_texture_ref) { 16138 TextureRef* dest_texture_ref) {
16058 if (!source_texture_ref || !dest_texture_ref) { 16139 if (!source_texture_ref || !dest_texture_ref) {
16059 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "unknown texture id"); 16140 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "unknown texture id");
16060 return false; 16141 return false;
16061 } 16142 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
16105 GLenum dest_type, 16186 GLenum dest_type,
16106 GLboolean unpack_flip_y, 16187 GLboolean unpack_flip_y,
16107 GLboolean unpack_premultiply_alpha, 16188 GLboolean unpack_premultiply_alpha,
16108 GLboolean unpack_unmultiply_alpha) { 16189 GLboolean unpack_unmultiply_alpha) {
16109 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopyTextureCHROMIUM"); 16190 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopyTextureCHROMIUM");
16110 static const char kFunctionName[] = "glCopyTextureCHROMIUM"; 16191 static const char kFunctionName[] = "glCopyTextureCHROMIUM";
16111 16192
16112 TextureRef* source_texture_ref = GetTexture(source_id); 16193 TextureRef* source_texture_ref = GetTexture(source_id);
16113 TextureRef* dest_texture_ref = GetTexture(dest_id); 16194 TextureRef* dest_texture_ref = GetTexture(dest_id);
16114 16195
16115 if (!texture_manager()->ValidateTextureParameters(
16116 GetErrorState(), kFunctionName, true, internal_format, dest_type,
16117 internal_format, 0))
16118 return;
16119
16120 if (!ValidateCopyTextureCHROMIUMTextures(kFunctionName, source_texture_ref, 16196 if (!ValidateCopyTextureCHROMIUMTextures(kFunctionName, source_texture_ref,
16121 dest_texture_ref)) { 16197 dest_texture_ref)) {
16122 return; 16198 return;
16123 } 16199 }
16124 16200
16125 if (!ValidateCopyTextureCHROMIUMInternalFormats(
16126 kFunctionName, source_texture_ref, internal_format)) {
16127 return;
16128 }
16129
16130 Texture* source_texture = source_texture_ref->texture(); 16201 Texture* source_texture = source_texture_ref->texture();
16131 Texture* dest_texture = dest_texture_ref->texture(); 16202 Texture* dest_texture = dest_texture_ref->texture();
16132 GLenum source_target = source_texture->target(); 16203 GLenum source_target = source_texture->target();
16133 GLenum dest_target = dest_texture->target(); 16204 GLenum dest_target = dest_texture->target();
16205
16206 GLenum source_type = 0;
16207 GLenum source_internal_format = 0;
16208 source_texture->GetLevelType(source_target, 0, &source_type,
16209 &source_internal_format);
16210 GLenum format =
16211 TextureManager::ExtractFormatFromStorageFormat(internal_format);
16212 if (!texture_manager()->ValidateTextureParameters(
16213 GetErrorState(), kFunctionName, true, format, dest_type,
16214 internal_format, 0)) {
16215 return;
16216 }
16217
16218 SupportedCopyMethodByFormat method =
16219 ValidateCopyTextureCHROMIUMInternalFormats(
16220 kFunctionName, source_texture_ref, internal_format);
16221 // INVALID_OPERATION is already generated by
16222 // ValidateCopyTextureCHROMIUMInternalFormats.
16223 if (NONE_COPY == method) {
16224 return;
16225 }
16226
16227 if (feature_info_->feature_flags().desktop_srgb_support) {
16228 bool enable_framebuffer_srgb =
16229 GetColorEncodingFromInternalFormat(source_internal_format) == GL_SRGB ||
16230 GetColorEncodingFromInternalFormat(internal_format) == GL_SRGB;
16231 state_.EnableDisableFramebufferSRGB(enable_framebuffer_srgb);
16232 }
16233
16134 int source_width = 0; 16234 int source_width = 0;
16135 int source_height = 0; 16235 int source_height = 0;
16136 gl::GLImage* image = 16236 gl::GLImage* image =
16137 source_texture->GetLevelImage(source_target, 0); 16237 source_texture->GetLevelImage(source_target, 0);
16138 if (image) { 16238 if (image) {
16139 gfx::Size size = image->GetSize(); 16239 gfx::Size size = image->GetSize();
16140 source_width = size.width(); 16240 source_width = size.width();
16141 source_height = size.height(); 16241 source_height = size.height();
16142 if (source_width <= 0 || source_height <= 0) { 16242 if (source_width <= 0 || source_height <= 0) {
16143 LOCAL_SET_GL_ERROR( 16243 LOCAL_SET_GL_ERROR(
(...skipping 11 matching lines...) Expand all
16155 } 16255 }
16156 16256
16157 // Check that this type of texture is allowed. 16257 // Check that this type of texture is allowed.
16158 if (!texture_manager()->ValidForTarget(source_target, 0, 16258 if (!texture_manager()->ValidForTarget(source_target, 0,
16159 source_width, source_height, 1)) { 16259 source_width, source_height, 1)) {
16160 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "Bad dimensions"); 16260 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "Bad dimensions");
16161 return; 16261 return;
16162 } 16262 }
16163 } 16263 }
16164 16264
16165 GLenum source_type = 0;
16166 GLenum source_internal_format = 0;
16167 source_texture->GetLevelType(source_target, 0, &source_type,
16168 &source_internal_format);
16169
16170 if (dest_texture->IsImmutable()) { 16265 if (dest_texture->IsImmutable()) {
16171 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, 16266 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName,
16172 "texture is immutable"); 16267 "texture is immutable");
16173 return; 16268 return;
16174 } 16269 }
16175 16270
16176 // Clear the source texture if necessary. 16271 // Clear the source texture if necessary.
16177 if (!texture_manager()->ClearTextureLevel(this, source_texture_ref, 16272 if (!texture_manager()->ClearTextureLevel(this, source_texture_ref,
16178 source_target, 0)) { 16273 source_target, 0)) {
16179 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, kFunctionName, "dimensions too big"); 16274 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, kFunctionName, "dimensions too big");
(...skipping 16 matching lines...) Expand all
16196 } 16291 }
16197 16292
16198 // Resize the destination texture to the dimensions of the source texture. 16293 // Resize the destination texture to the dimensions of the source texture.
16199 if (!dest_level_defined || dest_width != source_width || 16294 if (!dest_level_defined || dest_width != source_width ||
16200 dest_height != source_height || 16295 dest_height != source_height ||
16201 dest_internal_format != internal_format || 16296 dest_internal_format != internal_format ||
16202 dest_type_previous != dest_type) { 16297 dest_type_previous != dest_type) {
16203 // Ensure that the glTexImage2D succeeds. 16298 // Ensure that the glTexImage2D succeeds.
16204 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(kFunctionName); 16299 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(kFunctionName);
16205 glBindTexture(dest_target, dest_texture->service_id()); 16300 glBindTexture(dest_target, dest_texture->service_id());
16206 glTexImage2D( 16301 glTexImage2D(dest_target, 0, TextureManager::AdjustTexInternalFormat(
16207 dest_target, 0, TextureManager::AdjustTexInternalFormat( 16302 feature_info_.get(), internal_format),
16208 feature_info_.get(), internal_format), 16303 source_width, source_height, 0,
16209 source_width, source_height, 0, 16304 TextureManager::AdjustTexFormat(feature_info_.get(), format),
16210 TextureManager::AdjustTexFormat(feature_info_.get(), internal_format), 16305 dest_type, NULL);
16211 dest_type, NULL);
16212 GLenum error = LOCAL_PEEK_GL_ERROR(kFunctionName); 16306 GLenum error = LOCAL_PEEK_GL_ERROR(kFunctionName);
16213 if (error != GL_NO_ERROR) { 16307 if (error != GL_NO_ERROR) {
16214 RestoreCurrentTextureBindings(&state_, dest_target); 16308 RestoreCurrentTextureBindings(&state_, dest_target);
16215 return; 16309 return;
16216 } 16310 }
16217 16311
16218 texture_manager()->SetLevelInfo( 16312 texture_manager()->SetLevelInfo(dest_texture_ref, dest_target, 0,
16219 dest_texture_ref, dest_target, 0, internal_format, source_width, 16313 internal_format, source_width,
16220 source_height, 1, 0, internal_format, dest_type, 16314 source_height, 1, 0, format, dest_type,
16221 gfx::Rect(source_width, source_height)); 16315 gfx::Rect(source_width, source_height));
16222 dest_texture->ApplyFormatWorkarounds(feature_info_.get()); 16316 dest_texture->ApplyFormatWorkarounds(feature_info_.get());
16223 } else { 16317 } else {
16224 texture_manager()->SetLevelCleared(dest_texture_ref, dest_target, 0, 16318 texture_manager()->SetLevelCleared(dest_texture_ref, dest_target, 0, true);
16225 true);
16226 } 16319 }
16227 16320
16228 // Try using GLImage::CopyTexImage when possible. 16321 // Try using GLImage::CopyTexImage when possible.
16229 bool unpack_premultiply_alpha_change = 16322 bool unpack_premultiply_alpha_change =
16230 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0; 16323 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0;
16231 if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) { 16324 if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) {
16232 glBindTexture(dest_target, dest_texture->service_id()); 16325 glBindTexture(dest_target, dest_texture->service_id());
16233 if (image->CopyTexImage(dest_target)) 16326 if (image->CopyTexImage(dest_target))
16234 return; 16327 return;
16235 } 16328 }
16236 16329
16237 DoCopyTexImageIfNeeded(source_texture, source_target); 16330 DoCopyTexImageIfNeeded(source_texture, source_target);
16238 16331
16239 // GL_TEXTURE_EXTERNAL_OES texture requires that we apply a transform matrix 16332 // GL_TEXTURE_EXTERNAL_OES texture requires that we apply a transform matrix
16240 // before presenting. 16333 // before presenting.
16241 if (source_target == GL_TEXTURE_EXTERNAL_OES) { 16334 if (source_target == GL_TEXTURE_EXTERNAL_OES) {
16242 if (GLStreamTextureImage* image = 16335 if (GLStreamTextureImage* image =
16243 source_texture->GetLevelStreamTextureImage(GL_TEXTURE_EXTERNAL_OES, 16336 source_texture->GetLevelStreamTextureImage(GL_TEXTURE_EXTERNAL_OES,
16244 0)) { 16337 0)) {
16245 GLfloat transform_matrix[16]; 16338 GLfloat transform_matrix[16];
16246 image->GetTextureMatrix(transform_matrix); 16339 image->GetTextureMatrix(transform_matrix);
16247 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( 16340 copy_texture_CHROMIUM_->DoCopyTextureWithTransform(
16248 this, source_target, source_texture->service_id(), dest_target, 16341 this, source_target, source_texture->service_id(),
16249 dest_texture->service_id(), source_width, source_height, 16342 source_internal_format, dest_target, dest_texture->service_id(),
16343 internal_format, source_width, source_height,
16250 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE, 16344 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE,
16251 unpack_unmultiply_alpha == GL_TRUE, transform_matrix); 16345 unpack_unmultiply_alpha == GL_TRUE, transform_matrix);
16252 return; 16346 return;
16253 } 16347 }
16254 } 16348 }
16349
16255 copy_texture_CHROMIUM_->DoCopyTexture( 16350 copy_texture_CHROMIUM_->DoCopyTexture(
16256 this, source_target, source_texture->service_id(), source_internal_format, 16351 this, source_target, source_texture->service_id(), source_internal_format,
16257 dest_target, dest_texture->service_id(), internal_format, source_width, 16352 dest_target, dest_texture->service_id(), internal_format, source_width,
16258 source_height, unpack_flip_y == GL_TRUE, 16353 source_height, unpack_flip_y == GL_TRUE,
16259 unpack_premultiply_alpha == GL_TRUE, unpack_unmultiply_alpha == GL_TRUE); 16354 unpack_premultiply_alpha == GL_TRUE, unpack_unmultiply_alpha == GL_TRUE,
16355 method);
16260 } 16356 }
16261 16357
16262 void GLES2DecoderImpl::DoCopySubTextureCHROMIUM( 16358 void GLES2DecoderImpl::DoCopySubTextureCHROMIUM(
16263 GLuint source_id, 16359 GLuint source_id,
16264 GLuint dest_id, 16360 GLuint dest_id,
16265 GLint xoffset, 16361 GLint xoffset,
16266 GLint yoffset, 16362 GLint yoffset,
16267 GLint x, 16363 GLint x,
16268 GLint y, 16364 GLint y,
16269 GLsizei width, 16365 GLsizei width,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
16351 "destination texture is not defined"); 16447 "destination texture is not defined");
16352 return; 16448 return;
16353 } 16449 }
16354 if (!dest_texture->ValidForTexture(dest_target, 0, xoffset, 16450 if (!dest_texture->ValidForTexture(dest_target, 0, xoffset,
16355 yoffset, 0, width, height, 1)) { 16451 yoffset, 0, width, height, 1)) {
16356 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, 16452 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName,
16357 "destination texture bad dimensions."); 16453 "destination texture bad dimensions.");
16358 return; 16454 return;
16359 } 16455 }
16360 16456
16361 if (!ValidateCopyTextureCHROMIUMInternalFormats( 16457 SupportedCopyMethodByFormat method =
16362 kFunctionName, source_texture_ref, dest_internal_format)) { 16458 ValidateCopyTextureCHROMIUMInternalFormats(
16459 kFunctionName, source_texture_ref, dest_internal_format);
16460 // INVALID_OPERATION is already generated by
16461 // ValidateCopyTextureCHROMIUMInternalFormats.
16462 if (NONE_COPY == method) {
16363 return; 16463 return;
16364 } 16464 }
16365 16465
16466 if (feature_info_->feature_flags().desktop_srgb_support) {
16467 bool enable_framebuffer_srgb =
16468 GetColorEncodingFromInternalFormat(source_internal_format) == GL_SRGB ||
16469 GetColorEncodingFromInternalFormat(dest_internal_format) == GL_SRGB;
16470 state_.EnableDisableFramebufferSRGB(enable_framebuffer_srgb);
16471 }
16472
16366 // Clear the source texture if necessary. 16473 // Clear the source texture if necessary.
16367 if (!texture_manager()->ClearTextureLevel(this, source_texture_ref, 16474 if (!texture_manager()->ClearTextureLevel(this, source_texture_ref,
16368 source_target, 0)) { 16475 source_target, 0)) {
16369 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, kFunctionName, 16476 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, kFunctionName,
16370 "source texture dimensions too big"); 16477 "source texture dimensions too big");
16371 return; 16478 return;
16372 } 16479 }
16373 16480
16374 if (!InitializeCopyTextureCHROMIUM(kFunctionName)) 16481 if (!InitializeCopyTextureCHROMIUM(kFunctionName))
16375 return; 16482 return;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
16434 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE, 16541 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE,
16435 unpack_unmultiply_alpha == GL_TRUE, transform_matrix); 16542 unpack_unmultiply_alpha == GL_TRUE, transform_matrix);
16436 return; 16543 return;
16437 } 16544 }
16438 } 16545 }
16439 copy_texture_CHROMIUM_->DoCopySubTexture( 16546 copy_texture_CHROMIUM_->DoCopySubTexture(
16440 this, source_target, source_texture->service_id(), source_internal_format, 16547 this, source_target, source_texture->service_id(), source_internal_format,
16441 dest_target, dest_texture->service_id(), dest_internal_format, xoffset, 16548 dest_target, dest_texture->service_id(), dest_internal_format, xoffset,
16442 yoffset, x, y, width, height, dest_width, dest_height, source_width, 16549 yoffset, x, y, width, height, dest_width, dest_height, source_width,
16443 source_height, unpack_flip_y == GL_TRUE, 16550 source_height, unpack_flip_y == GL_TRUE,
16444 unpack_premultiply_alpha == GL_TRUE, unpack_unmultiply_alpha == GL_TRUE); 16551 unpack_premultiply_alpha == GL_TRUE, unpack_unmultiply_alpha == GL_TRUE,
16552 method);
16445 } 16553 }
16446 16554
16447 bool GLES2DecoderImpl::InitializeCopyTexImageBlitter( 16555 bool GLES2DecoderImpl::InitializeCopyTexImageBlitter(
16448 const char* function_name) { 16556 const char* function_name) {
16449 if (!copy_tex_image_blit_.get()) { 16557 if (!copy_tex_image_blit_.get()) {
16450 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(function_name); 16558 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(function_name);
16451 copy_tex_image_blit_.reset( 16559 copy_tex_image_blit_.reset(
16452 new CopyTexImageResourceManager(feature_info_.get())); 16560 new CopyTexImageResourceManager(feature_info_.get()));
16453 copy_tex_image_blit_->Initialize(this); 16561 copy_tex_image_blit_->Initialize(this);
16454 if (LOCAL_PEEK_GL_ERROR(function_name) != GL_NO_ERROR) 16562 if (LOCAL_PEEK_GL_ERROR(function_name) != GL_NO_ERROR)
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
16609 16717
16610 texture_manager()->SetLevelInfo( 16718 texture_manager()->SetLevelInfo(
16611 dest_texture_ref, dest_texture->target(), 0, GL_RGBA, source_width, 16719 dest_texture_ref, dest_texture->target(), 0, GL_RGBA, source_width,
16612 source_height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 16720 source_height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
16613 gfx::Rect(source_width, source_height)); 16721 gfx::Rect(source_width, source_height));
16614 16722
16615 copy_texture_CHROMIUM_->DoCopyTexture( 16723 copy_texture_CHROMIUM_->DoCopyTexture(
16616 this, source_texture->target(), source_texture->service_id(), 16724 this, source_texture->target(), source_texture->service_id(),
16617 source_internal_format, dest_texture->target(), 16725 source_internal_format, dest_texture->target(),
16618 dest_texture->service_id(), GL_RGBA, source_width, source_height, false, 16726 dest_texture->service_id(), GL_RGBA, source_width, source_height, false,
16619 false, false); 16727 false, false, DIRECT_DRAW);
16620 } 16728 }
16621 16729
16622 void GLES2DecoderImpl::TexStorageImpl(GLenum target, 16730 void GLES2DecoderImpl::TexStorageImpl(GLenum target,
16623 GLsizei levels, 16731 GLsizei levels,
16624 GLenum internal_format, 16732 GLenum internal_format,
16625 GLsizei width, 16733 GLsizei width,
16626 GLsizei height, 16734 GLsizei height,
16627 GLsizei depth, 16735 GLsizei depth,
16628 ContextState::Dimension dimension, 16736 ContextState::Dimension dimension,
16629 const char* function_name) { 16737 const char* function_name) {
(...skipping 2235 matching lines...) Expand 10 before | Expand all | Expand 10 after
18865 } 18973 }
18866 18974
18867 // Include the auto-generated part of this file. We split this because it means 18975 // Include the auto-generated part of this file. We split this because it means
18868 // we can easily edit the non-auto generated parts right here in this file 18976 // we can easily edit the non-auto generated parts right here in this file
18869 // instead of having to edit some template or the code generator. 18977 // instead of having to edit some template or the code generator.
18870 #include "base/macros.h" 18978 #include "base/macros.h"
18871 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 18979 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
18872 18980
18873 } // namespace gles2 18981 } // namespace gles2
18874 } // namespace gpu 18982 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698