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

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: full path 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 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after
1982 GLsizei size, 1986 GLsizei size,
1983 const GLvoid* data); 1987 const GLvoid* data);
1984 bool ValidateCompressedTexSubDimensions( 1988 bool ValidateCompressedTexSubDimensions(
1985 const char* function_name, 1989 const char* function_name,
1986 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, 1990 GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset,
1987 GLsizei width, GLsizei height, GLsizei depth, GLenum format, 1991 GLsizei width, GLsizei height, GLsizei depth, GLenum format,
1988 Texture* texture); 1992 Texture* texture);
1989 bool ValidateCopyTextureCHROMIUMTextures(const char* function_name, 1993 bool ValidateCopyTextureCHROMIUMTextures(const char* function_name,
1990 TextureRef* source_texture_ref, 1994 TextureRef* source_texture_ref,
1991 TextureRef* dest_texture_ref); 1995 TextureRef* dest_texture_ref);
1992 bool ValidateCopyTextureCHROMIUMInternalFormats( 1996 SupportedCopyMethodByFormat ValidateCopyTextureCHROMIUMInternalFormats(
1993 const char* function_name, 1997 const char* function_name,
1994 TextureRef* source_texture_ref, 1998 TextureRef* source_texture_ref,
1995 GLenum dest_internal_format); 1999 GLenum dest_internal_format);
1996 bool ValidateCompressedCopyTextureCHROMIUM(const char* function_name, 2000 bool ValidateCompressedCopyTextureCHROMIUM(const char* function_name,
1997 TextureRef* source_texture_ref, 2001 TextureRef* source_texture_ref,
1998 TextureRef* dest_texture_ref); 2002 TextureRef* dest_texture_ref);
1999 2003
2000 void RenderWarning(const char* filename, int line, const std::string& msg); 2004 void RenderWarning(const char* filename, int line, const std::string& msg);
2001 void PerformanceWarning( 2005 void PerformanceWarning(
2002 const char* filename, int line, const std::string& msg); 2006 const char* filename, int line, const std::string& msg);
(...skipping 11723 matching lines...) Expand 10 before | Expand all | Expand 10 after
13726 height, depth, format, image_size, data); 13730 height, depth, format, image_size, data);
13727 } 13731 }
13728 } 13732 }
13729 13733
13730 // This may be a slow command. Exit command processing to allow for 13734 // This may be a slow command. Exit command processing to allow for
13731 // context preemption and GPU watchdog checks. 13735 // context preemption and GPU watchdog checks.
13732 ExitCommandProcessingEarly(); 13736 ExitCommandProcessingEarly();
13733 return error::kNoError; 13737 return error::kNoError;
13734 } 13738 }
13735 13739
13736 bool GLES2DecoderImpl::ValidateCopyTexFormat( 13740 bool GLES2DecoderImpl::ValidateCopyTexFormatHelper(
13737 const char* func_name, GLenum internal_format, 13741 GLenum internal_format,
13738 GLenum read_format, GLenum read_type) { 13742 GLenum read_format,
13743 GLenum read_type,
13744 std::string* output_error_msg) {
13739 if (read_format == 0) { 13745 if (read_format == 0) {
13740 LOCAL_SET_GL_ERROR( 13746 *output_error_msg = std::string("no valid color image");
13741 GL_INVALID_OPERATION, func_name, "no valid color image");
13742 return false; 13747 return false;
13743 } 13748 }
13744 // Check we have compatible formats. 13749 // Check we have compatible formats.
13745 uint32_t channels_exist = GLES2Util::GetChannelsForFormat(read_format); 13750 uint32_t channels_exist = GLES2Util::GetChannelsForFormat(read_format);
13746 uint32_t channels_needed = GLES2Util::GetChannelsForFormat(internal_format); 13751 uint32_t channels_needed = GLES2Util::GetChannelsForFormat(internal_format);
13747 if (!channels_needed || 13752 if (!channels_needed ||
13748 (channels_needed & channels_exist) != channels_needed) { 13753 (channels_needed & channels_exist) != channels_needed) {
13749 LOCAL_SET_GL_ERROR( 13754 *output_error_msg = std::string("incompatible format");
13750 GL_INVALID_OPERATION, func_name, "incompatible format");
13751 return false; 13755 return false;
13752 } 13756 }
13753 if (feature_info_->IsWebGL2OrES3Context()) { 13757 if (feature_info_->IsWebGL2OrES3Context()) {
13754 GLint color_encoding = GetColorEncodingFromInternalFormat(read_format); 13758 GLint color_encoding = GetColorEncodingFromInternalFormat(read_format);
13755 bool float_mismatch= feature_info_->ext_color_buffer_float_available() ? 13759 bool float_mismatch= feature_info_->ext_color_buffer_float_available() ?
13756 (GLES2Util::IsIntegerFormat(internal_format) != 13760 (GLES2Util::IsIntegerFormat(internal_format) !=
13757 GLES2Util::IsIntegerFormat(read_format)) : 13761 GLES2Util::IsIntegerFormat(read_format)) :
13758 GLES2Util::IsFloatFormat(internal_format); 13762 GLES2Util::IsFloatFormat(internal_format);
13759 if (color_encoding != GetColorEncodingFromInternalFormat(internal_format) || 13763 if (color_encoding != GetColorEncodingFromInternalFormat(internal_format) ||
13760 float_mismatch || 13764 float_mismatch ||
13761 (GLES2Util::IsSignedIntegerFormat(internal_format) != 13765 (GLES2Util::IsSignedIntegerFormat(internal_format) !=
13762 GLES2Util::IsSignedIntegerFormat(read_format)) || 13766 GLES2Util::IsSignedIntegerFormat(read_format)) ||
13763 (GLES2Util::IsUnsignedIntegerFormat(internal_format) != 13767 (GLES2Util::IsUnsignedIntegerFormat(internal_format) !=
13764 GLES2Util::IsUnsignedIntegerFormat(read_format))) { 13768 GLES2Util::IsUnsignedIntegerFormat(read_format))) {
13765 LOCAL_SET_GL_ERROR( 13769 *output_error_msg = std::string("incompatible format");
13766 GL_INVALID_OPERATION, func_name, "incompatible format");
13767 return false; 13770 return false;
13768 } 13771 }
13769 } 13772 }
13770 if ((channels_needed & (GLES2Util::kDepth | GLES2Util::kStencil)) != 0) { 13773 if ((channels_needed & (GLES2Util::kDepth | GLES2Util::kStencil)) != 0) {
13771 LOCAL_SET_GL_ERROR( 13774 *output_error_msg =
13772 GL_INVALID_OPERATION, 13775 std::string("can not be used with depth or stencil textures");
13773 func_name, "can not be used with depth or stencil textures");
13774 return false; 13776 return false;
13775 } 13777 }
13776 if (feature_info_->IsWebGL2OrES3Context()) { 13778 if (feature_info_->IsWebGL2OrES3Context()) {
13777 if (GLES2Util::IsSizedColorFormat(internal_format)) { 13779 if (GLES2Util::IsSizedColorFormat(internal_format)) {
13778 int sr, sg, sb, sa; 13780 int sr, sg, sb, sa;
13779 GLES2Util::GetColorFormatComponentSizes( 13781 GLES2Util::GetColorFormatComponentSizes(
13780 read_format, read_type, &sr, &sg, &sb, &sa); 13782 read_format, read_type, &sr, &sg, &sb, &sa);
13781 DCHECK(sr > 0 || sg > 0 || sb > 0 || sa > 0); 13783 DCHECK(sr > 0 || sg > 0 || sb > 0 || sa > 0);
13782 int dr, dg, db, da; 13784 int dr, dg, db, da;
13783 GLES2Util::GetColorFormatComponentSizes( 13785 GLES2Util::GetColorFormatComponentSizes(
13784 internal_format, 0, &dr, &dg, &db, &da); 13786 internal_format, 0, &dr, &dg, &db, &da);
13785 DCHECK(dr > 0 || dg > 0 || db > 0 || da > 0); 13787 DCHECK(dr > 0 || dg > 0 || db > 0 || da > 0);
13786 if ((dr > 0 && sr != dr) || 13788 if ((dr > 0 && sr != dr) ||
13787 (dg > 0 && sg != dg) || 13789 (dg > 0 && sg != dg) ||
13788 (db > 0 && sb != db) || 13790 (db > 0 && sb != db) ||
13789 (da > 0 && sa != da)) { 13791 (da > 0 && sa != da)) {
13790 LOCAL_SET_GL_ERROR( 13792 *output_error_msg = std::string("incompatible color component sizes");
13791 GL_INVALID_OPERATION,
13792 func_name, "incompatible color component sizes");
13793 return false; 13793 return false;
13794 } 13794 }
13795 } 13795 }
13796 } 13796 }
13797 return true; 13797 return true;
13798 } 13798 }
13799 13799
13800 bool GLES2DecoderImpl::ValidateCopyTexFormat(const char* func_name,
13801 GLenum internal_format,
13802 GLenum read_format,
13803 GLenum read_type) {
13804 std::string output_error_msg;
13805 if (!ValidateCopyTexFormatHelper(internal_format, read_format, read_type,
13806 &output_error_msg)) {
13807 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name,
13808 output_error_msg.c_str());
13809 return false;
13810 }
13811 return true;
13812 }
13813
13800 void GLES2DecoderImpl::DoCopyTexImage2D( 13814 void GLES2DecoderImpl::DoCopyTexImage2D(
13801 GLenum target, 13815 GLenum target,
13802 GLint level, 13816 GLint level,
13803 GLenum internal_format, 13817 GLenum internal_format,
13804 GLint x, 13818 GLint x,
13805 GLint y, 13819 GLint y,
13806 GLsizei width, 13820 GLsizei width,
13807 GLsizei height, 13821 GLsizei height,
13808 GLint border) { 13822 GLint border) {
13809 const char* func_name = "glCopyTexImage2D"; 13823 const char* func_name = "glCopyTexImage2D";
(...skipping 2184 matching lines...) Expand 10 before | Expand all | Expand 10 after
15994 case GL_TEXTURE_EXTERNAL_OES: 16008 case GL_TEXTURE_EXTERNAL_OES:
15995 break; 16009 break;
15996 default: 16010 default:
15997 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, 16011 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name,
15998 "invalid source texture target binding"); 16012 "invalid source texture target binding");
15999 return false; 16013 return false;
16000 } 16014 }
16001 return true; 16015 return true;
16002 } 16016 }
16003 16017
16004 bool GLES2DecoderImpl::ValidateCopyTextureCHROMIUMInternalFormats( 16018 SupportedCopyMethodByFormat
16019 GLES2DecoderImpl::ValidateCopyTextureCHROMIUMInternalFormats(
16005 const char* function_name, 16020 const char* function_name,
16006 TextureRef* source_texture_ref, 16021 TextureRef* source_texture_ref,
16007 GLenum dest_internal_format) { 16022 GLenum dest_internal_format) {
16008 GLenum source_type = 0; 16023 GLenum source_type = 0;
16009 GLenum source_internal_format = 0; 16024 GLenum source_internal_format = 0;
16010 Texture* source_texture = source_texture_ref->texture(); 16025 Texture* source_texture = source_texture_ref->texture();
16011 source_texture->GetLevelType(source_texture->target(), 0, &source_type, 16026 source_texture->GetLevelType(source_texture->target(), 0, &source_type,
16012 &source_internal_format); 16027 &source_internal_format);
16013 16028
16014 // The destination format should be GL_RGB, or GL_RGBA. GL_ALPHA, 16029 bool valid_dest_format = false;
16015 // GL_LUMINANCE, and GL_LUMINANCE_ALPHA are not supported because they are not 16030 switch (dest_internal_format) {
16016 // renderable on some platforms. 16031 case GL_LUMINANCE_ALPHA:
16017 bool valid_dest_format = 16032 case GL_LUMINANCE:
16018 dest_internal_format == GL_RGB || dest_internal_format == GL_RGBA || 16033 case GL_ALPHA:
16019 dest_internal_format == GL_RGB8 || dest_internal_format == GL_RGBA8 || 16034 case GL_RGB:
16020 dest_internal_format == GL_BGRA_EXT || 16035 case GL_RGBA:
16021 dest_internal_format == GL_BGRA8_EXT; 16036 case GL_BGRA_EXT:
16037 case GL_BGRA8_EXT:
16038 case GL_RGB8:
16039 case GL_RGBA8:
16040 valid_dest_format = true;
16041 break;
16042 case GL_R8:
16043 case GL_R16F:
16044 case GL_R32F:
16045 case GL_R8UI:
16046 case GL_RG8:
16047 case GL_RG16F:
16048 case GL_RG32F:
16049 case GL_RG8UI:
16050 case GL_SRGB8:
16051 case GL_RGB565:
16052 case GL_R11F_G11F_B10F:
16053 case GL_RGB9_E5:
16054 case GL_RGB16F:
16055 case GL_RGB32F:
16056 case GL_RGB8UI:
16057 case GL_SRGB8_ALPHA8:
16058 case GL_RGB5_A1:
16059 case GL_RGBA4:
16060 case GL_RGBA16F:
16061 case GL_RGBA32F:
16062 case GL_RGBA8UI:
16063 valid_dest_format = feature_info_->IsWebGL2OrES3Context();
16064 break;
16065 default:
16066 valid_dest_format = false;
16067 break;
16068 }
16069
16022 bool valid_source_format = 16070 bool valid_source_format =
16023 source_internal_format == GL_RED || source_internal_format == GL_ALPHA || 16071 source_internal_format == GL_RED || source_internal_format == GL_ALPHA ||
16024 source_internal_format == GL_RGB || source_internal_format == GL_RGBA || 16072 source_internal_format == GL_RGB || source_internal_format == GL_RGBA ||
16025 source_internal_format == GL_RGB8 || source_internal_format == GL_RGBA8 || 16073 source_internal_format == GL_RGB8 || source_internal_format == GL_RGBA8 ||
16026 source_internal_format == GL_LUMINANCE || 16074 source_internal_format == GL_LUMINANCE ||
16027 source_internal_format == GL_LUMINANCE_ALPHA || 16075 source_internal_format == GL_LUMINANCE_ALPHA ||
16028 source_internal_format == GL_BGRA_EXT || 16076 source_internal_format == GL_BGRA_EXT ||
16029 source_internal_format == GL_BGRA8_EXT || 16077 source_internal_format == GL_BGRA8_EXT ||
16030 source_internal_format == GL_RGB_YCBCR_420V_CHROMIUM || 16078 source_internal_format == GL_RGB_YCBCR_420V_CHROMIUM ||
16031 source_internal_format == GL_RGB_YCBCR_422_CHROMIUM; 16079 source_internal_format == GL_RGB_YCBCR_422_CHROMIUM;
16032 if (!valid_source_format) { 16080 if (!valid_source_format) {
16033 std::string msg = "invalid source internal format " + 16081 std::string msg = "invalid source internal format " +
16034 GLES2Util::GetStringEnum(source_internal_format); 16082 GLES2Util::GetStringEnum(source_internal_format);
16035 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, 16083 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
16036 msg.c_str()); 16084 msg.c_str());
16037 return false; 16085 return NONE_COPY;
16038 } 16086 }
16039 if (!valid_dest_format) { 16087 if (!valid_dest_format) {
16040 std::string msg = "invalid dest internal format " + 16088 std::string msg = "invalid dest internal format " +
16041 GLES2Util::GetStringEnum(dest_internal_format); 16089 GLES2Util::GetStringEnum(dest_internal_format);
16042 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, 16090 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
16043 msg.c_str()); 16091 msg.c_str());
16044 return false; 16092 return NONE_COPY;
16045 } 16093 }
16046 return true; 16094
16095 bool source_format_color_renderable =
16096 Texture::ColorRenderable(GetFeatureInfo(), source_internal_format, false);
16097 bool dest_format_color_renderable =
16098 Texture::ColorRenderable(GetFeatureInfo(), dest_internal_format, false);
16099 std::string output_error_msg;
16100
16101 // CopyTexImage* should not allow internalformat of GL_BGRA_EXT and
16102 // GL_BGRA8_EXT. crbug.com/663086.
16103 bool copy_tex_image_format_valid =
16104 source_internal_format != GL_BGRA_EXT &&
16105 dest_internal_format != GL_BGRA_EXT &&
16106 source_internal_format != GL_BGRA8_EXT &&
16107 dest_internal_format != GL_BGRA8_EXT &&
16108 ValidateCopyTexFormatHelper(dest_internal_format, source_internal_format,
16109 source_type, &output_error_msg);
16110 if (source_format_color_renderable && copy_tex_image_format_valid)
16111 return DIRECT_COPY;
16112
16113 if (dest_format_color_renderable)
16114 return DIRECT_DRAW;
16115
16116 return DRAW_AND_COPY;
16047 } 16117 }
16048 16118
16049 bool GLES2DecoderImpl::ValidateCompressedCopyTextureCHROMIUM( 16119 bool GLES2DecoderImpl::ValidateCompressedCopyTextureCHROMIUM(
16050 const char* function_name, 16120 const char* function_name,
16051 TextureRef* source_texture_ref, 16121 TextureRef* source_texture_ref,
16052 TextureRef* dest_texture_ref) { 16122 TextureRef* dest_texture_ref) {
16053 if (!source_texture_ref || !dest_texture_ref) { 16123 if (!source_texture_ref || !dest_texture_ref) {
16054 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "unknown texture id"); 16124 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "unknown texture id");
16055 return false; 16125 return false;
16056 } 16126 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
16100 GLenum dest_type, 16170 GLenum dest_type,
16101 GLboolean unpack_flip_y, 16171 GLboolean unpack_flip_y,
16102 GLboolean unpack_premultiply_alpha, 16172 GLboolean unpack_premultiply_alpha,
16103 GLboolean unpack_unmultiply_alpha) { 16173 GLboolean unpack_unmultiply_alpha) {
16104 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopyTextureCHROMIUM"); 16174 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopyTextureCHROMIUM");
16105 static const char kFunctionName[] = "glCopyTextureCHROMIUM"; 16175 static const char kFunctionName[] = "glCopyTextureCHROMIUM";
16106 16176
16107 TextureRef* source_texture_ref = GetTexture(source_id); 16177 TextureRef* source_texture_ref = GetTexture(source_id);
16108 TextureRef* dest_texture_ref = GetTexture(dest_id); 16178 TextureRef* dest_texture_ref = GetTexture(dest_id);
16109 16179
16110 if (!texture_manager()->ValidateTextureParameters(
16111 GetErrorState(), kFunctionName, true, internal_format, dest_type,
16112 internal_format, 0))
16113 return;
16114
16115 if (!ValidateCopyTextureCHROMIUMTextures(kFunctionName, source_texture_ref, 16180 if (!ValidateCopyTextureCHROMIUMTextures(kFunctionName, source_texture_ref,
16116 dest_texture_ref)) { 16181 dest_texture_ref)) {
16117 return; 16182 return;
16118 } 16183 }
16119 16184
16120 if (!ValidateCopyTextureCHROMIUMInternalFormats(
16121 kFunctionName, source_texture_ref, internal_format)) {
16122 return;
16123 }
16124
16125 Texture* source_texture = source_texture_ref->texture(); 16185 Texture* source_texture = source_texture_ref->texture();
16126 Texture* dest_texture = dest_texture_ref->texture(); 16186 Texture* dest_texture = dest_texture_ref->texture();
16127 GLenum source_target = source_texture->target(); 16187 GLenum source_target = source_texture->target();
16128 GLenum dest_target = dest_texture->target(); 16188 GLenum dest_target = dest_texture->target();
16189
16190 GLenum source_type = 0;
16191 GLenum source_internal_format = 0;
16192 source_texture->GetLevelType(source_target, 0, &source_type,
16193 &source_internal_format);
16194 GLenum format =
16195 TextureManager::ExtractFormatFromStorageFormat(internal_format);
16196 if (!texture_manager()->ValidateTextureParameters(
16197 GetErrorState(), kFunctionName, true, format, dest_type,
16198 internal_format, 0))
16199 return;
16200
16201 SupportedCopyMethodByFormat method =
16202 ValidateCopyTextureCHROMIUMInternalFormats(
16203 kFunctionName, source_texture_ref, internal_format);
16204 if (NONE_COPY == method) {
16205 return;
16206 }
16207
16208 if (feature_info_->feature_flags().desktop_srgb_support) {
16209 bool enable_framebuffer_srgb =
16210 GetColorEncodingFromInternalFormat(source_internal_format) ||
16211 GetColorEncodingFromInternalFormat(internal_format);
16212 state_.EnableDisableFramebufferSRGB(enable_framebuffer_srgb);
16213 }
16214
16129 int source_width = 0; 16215 int source_width = 0;
16130 int source_height = 0; 16216 int source_height = 0;
16131 gl::GLImage* image = 16217 gl::GLImage* image =
16132 source_texture->GetLevelImage(source_target, 0); 16218 source_texture->GetLevelImage(source_target, 0);
16133 if (image) { 16219 if (image) {
16134 gfx::Size size = image->GetSize(); 16220 gfx::Size size = image->GetSize();
16135 source_width = size.width(); 16221 source_width = size.width();
16136 source_height = size.height(); 16222 source_height = size.height();
16137 if (source_width <= 0 || source_height <= 0) { 16223 if (source_width <= 0 || source_height <= 0) {
16138 LOCAL_SET_GL_ERROR( 16224 LOCAL_SET_GL_ERROR(
(...skipping 11 matching lines...) Expand all
16150 } 16236 }
16151 16237
16152 // Check that this type of texture is allowed. 16238 // Check that this type of texture is allowed.
16153 if (!texture_manager()->ValidForTarget(source_target, 0, 16239 if (!texture_manager()->ValidForTarget(source_target, 0,
16154 source_width, source_height, 1)) { 16240 source_width, source_height, 1)) {
16155 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "Bad dimensions"); 16241 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "Bad dimensions");
16156 return; 16242 return;
16157 } 16243 }
16158 } 16244 }
16159 16245
16160 GLenum source_type = 0;
16161 GLenum source_internal_format = 0;
16162 source_texture->GetLevelType(source_target, 0, &source_type,
16163 &source_internal_format);
16164
16165 if (dest_texture->IsImmutable()) { 16246 if (dest_texture->IsImmutable()) {
16166 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, 16247 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName,
16167 "texture is immutable"); 16248 "texture is immutable");
16168 return; 16249 return;
16169 } 16250 }
16170 16251
16171 // Clear the source texture if necessary. 16252 // Clear the source texture if necessary.
16172 if (!texture_manager()->ClearTextureLevel(this, source_texture_ref, 16253 if (!texture_manager()->ClearTextureLevel(this, source_texture_ref,
16173 source_target, 0)) { 16254 source_target, 0)) {
16174 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, kFunctionName, "dimensions too big"); 16255 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, kFunctionName, "dimensions too big");
(...skipping 16 matching lines...) Expand all
16191 } 16272 }
16192 16273
16193 // Resize the destination texture to the dimensions of the source texture. 16274 // Resize the destination texture to the dimensions of the source texture.
16194 if (!dest_level_defined || dest_width != source_width || 16275 if (!dest_level_defined || dest_width != source_width ||
16195 dest_height != source_height || 16276 dest_height != source_height ||
16196 dest_internal_format != internal_format || 16277 dest_internal_format != internal_format ||
16197 dest_type_previous != dest_type) { 16278 dest_type_previous != dest_type) {
16198 // Ensure that the glTexImage2D succeeds. 16279 // Ensure that the glTexImage2D succeeds.
16199 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(kFunctionName); 16280 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(kFunctionName);
16200 glBindTexture(dest_target, dest_texture->service_id()); 16281 glBindTexture(dest_target, dest_texture->service_id());
16201 glTexImage2D( 16282 glTexImage2D(dest_target, 0, TextureManager::AdjustTexInternalFormat(
16202 dest_target, 0, TextureManager::AdjustTexInternalFormat( 16283 feature_info_.get(), internal_format),
16203 feature_info_.get(), internal_format), 16284 source_width, source_height, 0,
16204 source_width, source_height, 0, 16285 TextureManager::AdjustTexFormat(feature_info_.get(), format),
16205 TextureManager::AdjustTexFormat(feature_info_.get(), internal_format), 16286 dest_type, NULL);
16206 dest_type, NULL);
16207 GLenum error = LOCAL_PEEK_GL_ERROR(kFunctionName); 16287 GLenum error = LOCAL_PEEK_GL_ERROR(kFunctionName);
16208 if (error != GL_NO_ERROR) { 16288 if (error != GL_NO_ERROR) {
16209 RestoreCurrentTextureBindings(&state_, dest_target); 16289 RestoreCurrentTextureBindings(&state_, dest_target);
16210 return; 16290 return;
16211 } 16291 }
16212 16292
16213 texture_manager()->SetLevelInfo( 16293 texture_manager()->SetLevelInfo(dest_texture_ref, dest_target, 0,
16214 dest_texture_ref, dest_target, 0, internal_format, source_width, 16294 internal_format, source_width,
16215 source_height, 1, 0, internal_format, dest_type, 16295 source_height, 1, 0, format, dest_type,
16216 gfx::Rect(source_width, source_height)); 16296 gfx::Rect(source_width, source_height));
16217 dest_texture->ApplyFormatWorkarounds(feature_info_.get()); 16297 dest_texture->ApplyFormatWorkarounds(feature_info_.get());
16218 } else { 16298 } else {
16219 texture_manager()->SetLevelCleared(dest_texture_ref, dest_target, 0, 16299 texture_manager()->SetLevelCleared(dest_texture_ref, dest_target, 0, true);
16220 true);
16221 } 16300 }
16222 16301
16223 // Try using GLImage::CopyTexImage when possible. 16302 // Try using GLImage::CopyTexImage when possible.
16224 bool unpack_premultiply_alpha_change = 16303 bool unpack_premultiply_alpha_change =
16225 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0; 16304 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0;
16226 if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) { 16305 if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) {
16227 glBindTexture(dest_target, dest_texture->service_id()); 16306 glBindTexture(dest_target, dest_texture->service_id());
16228 if (image->CopyTexImage(dest_target)) 16307 if (image->CopyTexImage(dest_target))
16229 return; 16308 return;
16230 } 16309 }
16231 16310
16232 DoCopyTexImageIfNeeded(source_texture, source_target); 16311 DoCopyTexImageIfNeeded(source_texture, source_target);
16233 16312
16234 // GL_TEXTURE_EXTERNAL_OES texture requires that we apply a transform matrix 16313 // GL_TEXTURE_EXTERNAL_OES texture requires that we apply a transform matrix
16235 // before presenting. 16314 // before presenting.
16236 if (source_target == GL_TEXTURE_EXTERNAL_OES) { 16315 if (source_target == GL_TEXTURE_EXTERNAL_OES) {
16237 if (GLStreamTextureImage* image = 16316 if (GLStreamTextureImage* image =
16238 source_texture->GetLevelStreamTextureImage(GL_TEXTURE_EXTERNAL_OES, 16317 source_texture->GetLevelStreamTextureImage(GL_TEXTURE_EXTERNAL_OES,
16239 0)) { 16318 0)) {
16240 GLfloat transform_matrix[16]; 16319 GLfloat transform_matrix[16];
16241 image->GetTextureMatrix(transform_matrix); 16320 image->GetTextureMatrix(transform_matrix);
16242 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( 16321 copy_texture_CHROMIUM_->DoCopyTextureWithTransform(
16243 this, source_target, source_texture->service_id(), dest_target, 16322 this, source_target, source_texture->service_id(),
16244 dest_texture->service_id(), source_width, source_height, 16323 source_internal_format, dest_target, dest_texture->service_id(),
16324 internal_format, source_width, source_height,
16245 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE, 16325 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE,
16246 unpack_unmultiply_alpha == GL_TRUE, transform_matrix); 16326 unpack_unmultiply_alpha == GL_TRUE, transform_matrix);
16247 return; 16327 return;
16248 } 16328 }
16249 } 16329 }
16330
16250 copy_texture_CHROMIUM_->DoCopyTexture( 16331 copy_texture_CHROMIUM_->DoCopyTexture(
16251 this, source_target, source_texture->service_id(), source_internal_format, 16332 this, source_target, source_texture->service_id(), source_internal_format,
16252 dest_target, dest_texture->service_id(), internal_format, source_width, 16333 dest_target, dest_texture->service_id(), internal_format, source_width,
16253 source_height, unpack_flip_y == GL_TRUE, 16334 source_height, unpack_flip_y == GL_TRUE,
16254 unpack_premultiply_alpha == GL_TRUE, unpack_unmultiply_alpha == GL_TRUE); 16335 unpack_premultiply_alpha == GL_TRUE, unpack_unmultiply_alpha == GL_TRUE,
16336 method);
16255 } 16337 }
16256 16338
16257 void GLES2DecoderImpl::DoCopySubTextureCHROMIUM( 16339 void GLES2DecoderImpl::DoCopySubTextureCHROMIUM(
16258 GLuint source_id, 16340 GLuint source_id,
16259 GLuint dest_id, 16341 GLuint dest_id,
16260 GLint xoffset, 16342 GLint xoffset,
16261 GLint yoffset, 16343 GLint yoffset,
16262 GLint x, 16344 GLint x,
16263 GLint y, 16345 GLint y,
16264 GLsizei width, 16346 GLsizei width,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
16346 "destination texture is not defined"); 16428 "destination texture is not defined");
16347 return; 16429 return;
16348 } 16430 }
16349 if (!dest_texture->ValidForTexture(dest_target, 0, xoffset, 16431 if (!dest_texture->ValidForTexture(dest_target, 0, xoffset,
16350 yoffset, 0, width, height, 1)) { 16432 yoffset, 0, width, height, 1)) {
16351 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, 16433 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName,
16352 "destination texture bad dimensions."); 16434 "destination texture bad dimensions.");
16353 return; 16435 return;
16354 } 16436 }
16355 16437
16356 if (!ValidateCopyTextureCHROMIUMInternalFormats( 16438 SupportedCopyMethodByFormat method =
16357 kFunctionName, source_texture_ref, dest_internal_format)) { 16439 ValidateCopyTextureCHROMIUMInternalFormats(
16440 kFunctionName, source_texture_ref, dest_internal_format);
16441 if (NONE_COPY == method) {
16358 return; 16442 return;
16359 } 16443 }
16360 16444
16361 // Clear the source texture if necessary. 16445 // Clear the source texture if necessary.
16362 if (!texture_manager()->ClearTextureLevel(this, source_texture_ref, 16446 if (!texture_manager()->ClearTextureLevel(this, source_texture_ref,
16363 source_target, 0)) { 16447 source_target, 0)) {
16364 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, kFunctionName, 16448 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, kFunctionName,
16365 "source texture dimensions too big"); 16449 "source texture dimensions too big");
16366 return; 16450 return;
16367 } 16451 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
16429 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE, 16513 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE,
16430 unpack_unmultiply_alpha == GL_TRUE, transform_matrix); 16514 unpack_unmultiply_alpha == GL_TRUE, transform_matrix);
16431 return; 16515 return;
16432 } 16516 }
16433 } 16517 }
16434 copy_texture_CHROMIUM_->DoCopySubTexture( 16518 copy_texture_CHROMIUM_->DoCopySubTexture(
16435 this, source_target, source_texture->service_id(), source_internal_format, 16519 this, source_target, source_texture->service_id(), source_internal_format,
16436 dest_target, dest_texture->service_id(), dest_internal_format, xoffset, 16520 dest_target, dest_texture->service_id(), dest_internal_format, xoffset,
16437 yoffset, x, y, width, height, dest_width, dest_height, source_width, 16521 yoffset, x, y, width, height, dest_width, dest_height, source_width,
16438 source_height, unpack_flip_y == GL_TRUE, 16522 source_height, unpack_flip_y == GL_TRUE,
16439 unpack_premultiply_alpha == GL_TRUE, unpack_unmultiply_alpha == GL_TRUE); 16523 unpack_premultiply_alpha == GL_TRUE, unpack_unmultiply_alpha == GL_TRUE,
16524 method);
16440 } 16525 }
16441 16526
16442 bool GLES2DecoderImpl::InitializeCopyTexImageBlitter( 16527 bool GLES2DecoderImpl::InitializeCopyTexImageBlitter(
16443 const char* function_name) { 16528 const char* function_name) {
16444 if (!copy_tex_image_blit_.get()) { 16529 if (!copy_tex_image_blit_.get()) {
16445 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(function_name); 16530 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(function_name);
16446 copy_tex_image_blit_.reset( 16531 copy_tex_image_blit_.reset(
16447 new CopyTexImageResourceManager(feature_info_.get())); 16532 new CopyTexImageResourceManager(feature_info_.get()));
16448 copy_tex_image_blit_->Initialize(this); 16533 copy_tex_image_blit_->Initialize(this);
16449 if (LOCAL_PEEK_GL_ERROR(function_name) != GL_NO_ERROR) 16534 if (LOCAL_PEEK_GL_ERROR(function_name) != GL_NO_ERROR)
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
16604 16689
16605 texture_manager()->SetLevelInfo( 16690 texture_manager()->SetLevelInfo(
16606 dest_texture_ref, dest_texture->target(), 0, GL_RGBA, source_width, 16691 dest_texture_ref, dest_texture->target(), 0, GL_RGBA, source_width,
16607 source_height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 16692 source_height, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
16608 gfx::Rect(source_width, source_height)); 16693 gfx::Rect(source_width, source_height));
16609 16694
16610 copy_texture_CHROMIUM_->DoCopyTexture( 16695 copy_texture_CHROMIUM_->DoCopyTexture(
16611 this, source_texture->target(), source_texture->service_id(), 16696 this, source_texture->target(), source_texture->service_id(),
16612 source_internal_format, dest_texture->target(), 16697 source_internal_format, dest_texture->target(),
16613 dest_texture->service_id(), GL_RGBA, source_width, source_height, false, 16698 dest_texture->service_id(), GL_RGBA, source_width, source_height, false,
16614 false, false); 16699 false, false, DIRECT_DRAW);
16615 } 16700 }
16616 16701
16617 void GLES2DecoderImpl::TexStorageImpl(GLenum target, 16702 void GLES2DecoderImpl::TexStorageImpl(GLenum target,
16618 GLsizei levels, 16703 GLsizei levels,
16619 GLenum internal_format, 16704 GLenum internal_format,
16620 GLsizei width, 16705 GLsizei width,
16621 GLsizei height, 16706 GLsizei height,
16622 GLsizei depth, 16707 GLsizei depth,
16623 ContextState::Dimension dimension, 16708 ContextState::Dimension dimension,
16624 const char* function_name) { 16709 const char* function_name) {
(...skipping 2233 matching lines...) Expand 10 before | Expand all | Expand 10 after
18858 } 18943 }
18859 18944
18860 // Include the auto-generated part of this file. We split this because it means 18945 // Include the auto-generated part of this file. We split this because it means
18861 // we can easily edit the non-auto generated parts right here in this file 18946 // we can easily edit the non-auto generated parts right here in this file
18862 // instead of having to edit some template or the code generator. 18947 // instead of having to edit some template or the code generator.
18863 #include "base/macros.h" 18948 #include "base/macros.h"
18864 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 18949 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
18865 18950
18866 } // namespace gles2 18951 } // namespace gles2
18867 } // namespace gpu 18952 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698