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

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 windows and mac bot 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, GLenum read_format,
893 GLenum read_type, std::string& err_msg);
892 // Validate if |format| is valid for CopyTex{Sub}Image functions. 894 // Validate if |format| is valid for CopyTex{Sub}Image functions.
893 // If not, generate a GL error and return false. 895 // If not, generate a GL error and return false.
894 bool ValidateCopyTexFormat(const char* func_name, GLenum internal_format, 896 bool ValidateCopyTexFormat(const char* func_name, GLenum internal_format,
895 GLenum read_format, GLenum read_type); 897 GLenum read_format, GLenum read_type);
896 898
897 // Wrapper for CopyTexImage2D. 899 // Wrapper for CopyTexImage2D.
898 void DoCopyTexImage2D( 900 void DoCopyTexImage2D(
899 GLenum target, 901 GLenum target,
900 GLint level, 902 GLint level,
901 GLenum internal_format, 903 GLenum internal_format,
(...skipping 12788 matching lines...) Expand 10 before | Expand all | Expand 10 after
13690 height, depth, format, image_size, data); 13692 height, depth, format, image_size, data);
13691 } 13693 }
13692 } 13694 }
13693 13695
13694 // This may be a slow command. Exit command processing to allow for 13696 // This may be a slow command. Exit command processing to allow for
13695 // context preemption and GPU watchdog checks. 13697 // context preemption and GPU watchdog checks.
13696 ExitCommandProcessingEarly(); 13698 ExitCommandProcessingEarly();
13697 return error::kNoError; 13699 return error::kNoError;
13698 } 13700 }
13699 13701
13700 bool GLES2DecoderImpl::ValidateCopyTexFormat( 13702 bool GLES2DecoderImpl::ValidateCopyTexFormatHelper(GLenum internal_format,
13701 const char* func_name, GLenum internal_format, 13703 GLenum read_format, GLenum read_type, std::string& err_msg) {
Zhenyao Mo 2016/11/03 22:55:35 This is against coding style: https://google.githu
13702 GLenum read_format, GLenum read_type) {
13703 if (read_format == 0) { 13704 if (read_format == 0) {
13704 LOCAL_SET_GL_ERROR( 13705 err_msg = std::string("no valid color image");
13705 GL_INVALID_OPERATION, func_name, "no valid color image");
13706 return false; 13706 return false;
13707 } 13707 }
13708 // Check we have compatible formats. 13708 // Check we have compatible formats.
13709 uint32_t channels_exist = GLES2Util::GetChannelsForFormat(read_format); 13709 uint32_t channels_exist = GLES2Util::GetChannelsForFormat(read_format);
13710 uint32_t channels_needed = GLES2Util::GetChannelsForFormat(internal_format); 13710 uint32_t channels_needed = GLES2Util::GetChannelsForFormat(internal_format);
13711 if (!channels_needed || 13711 if (!channels_needed ||
13712 (channels_needed & channels_exist) != channels_needed) { 13712 (channels_needed & channels_exist) != channels_needed) {
13713 LOCAL_SET_GL_ERROR( 13713 err_msg = std::string("incompatible format");
13714 GL_INVALID_OPERATION, func_name, "incompatible format");
13715 return false; 13714 return false;
13716 } 13715 }
13717 if (feature_info_->IsWebGL2OrES3Context()) { 13716 if (feature_info_->IsWebGL2OrES3Context()) {
13718 GLint color_encoding = GetColorEncodingFromInternalFormat(read_format); 13717 GLint color_encoding = GetColorEncodingFromInternalFormat(read_format);
13719 if (color_encoding != GetColorEncodingFromInternalFormat(internal_format) || 13718 if (color_encoding != GetColorEncodingFromInternalFormat(internal_format) ||
13720 GLES2Util::IsFloatFormat(internal_format) || 13719 GLES2Util::IsFloatFormat(internal_format) ||
13721 (GLES2Util::IsSignedIntegerFormat(internal_format) != 13720 (GLES2Util::IsSignedIntegerFormat(internal_format) !=
13722 GLES2Util::IsSignedIntegerFormat(read_format)) || 13721 GLES2Util::IsSignedIntegerFormat(read_format)) ||
13723 (GLES2Util::IsUnsignedIntegerFormat(internal_format) != 13722 (GLES2Util::IsUnsignedIntegerFormat(internal_format) !=
13724 GLES2Util::IsUnsignedIntegerFormat(read_format))) { 13723 GLES2Util::IsUnsignedIntegerFormat(read_format))) {
13725 LOCAL_SET_GL_ERROR( 13724 err_msg = std::string("incompatible format");
13726 GL_INVALID_OPERATION, func_name, "incompatible format");
13727 return false; 13725 return false;
13728 } 13726 }
13729 } 13727 }
13730 if ((channels_needed & (GLES2Util::kDepth | GLES2Util::kStencil)) != 0) { 13728 if ((channels_needed & (GLES2Util::kDepth | GLES2Util::kStencil)) != 0) {
13731 LOCAL_SET_GL_ERROR( 13729 err_msg = std::string("can not be used with depth or stencil textures");
13732 GL_INVALID_OPERATION,
13733 func_name, "can not be used with depth or stencil textures");
13734 return false; 13730 return false;
13735 } 13731 }
13736 if (feature_info_->IsWebGL2OrES3Context()) { 13732 if (feature_info_->IsWebGL2OrES3Context()) {
13737 if (GLES2Util::IsSizedColorFormat(internal_format)) { 13733 if (GLES2Util::IsSizedColorFormat(internal_format)) {
13738 int sr, sg, sb, sa; 13734 int sr, sg, sb, sa;
13739 GLES2Util::GetColorFormatComponentSizes( 13735 GLES2Util::GetColorFormatComponentSizes(
13740 read_format, read_type, &sr, &sg, &sb, &sa); 13736 read_format, read_type, &sr, &sg, &sb, &sa);
13741 DCHECK(sr > 0 || sg > 0 || sb > 0 || sa > 0); 13737 DCHECK(sr > 0 || sg > 0 || sb > 0 || sa > 0);
13742 int dr, dg, db, da; 13738 int dr, dg, db, da;
13743 GLES2Util::GetColorFormatComponentSizes( 13739 GLES2Util::GetColorFormatComponentSizes(
13744 internal_format, 0, &dr, &dg, &db, &da); 13740 internal_format, 0, &dr, &dg, &db, &da);
13745 DCHECK(dr > 0 || dg > 0 || db > 0 || da > 0); 13741 DCHECK(dr > 0 || dg > 0 || db > 0 || da > 0);
13746 if ((dr > 0 && sr != dr) || 13742 if ((dr > 0 && sr != dr) ||
13747 (dg > 0 && sg != dg) || 13743 (dg > 0 && sg != dg) ||
13748 (db > 0 && sb != db) || 13744 (db > 0 && sb != db) ||
13749 (da > 0 && sa != da)) { 13745 (da > 0 && sa != da)) {
13750 LOCAL_SET_GL_ERROR( 13746 err_msg = std::string("incompatible color component sizes");
13751 GL_INVALID_OPERATION,
13752 func_name, "incompatible color component sizes");
13753 return false; 13747 return false;
13754 } 13748 }
13755 } 13749 }
13756 } 13750 }
13757 return true; 13751 return true;
13758 } 13752 }
13759 13753
13754 bool GLES2DecoderImpl::ValidateCopyTexFormat(
13755 const char* func_name, GLenum internal_format,
13756 GLenum read_format, GLenum read_type) {
13757 std::string err_msg;
13758 if (!ValidateCopyTexFormatHelper(internal_format, read_format,
13759 read_type, err_msg)) {
13760 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, err_msg.c_str());
13761 return false;
13762 }
13763 return true;
13764 }
13765
13760 void GLES2DecoderImpl::DoCopyTexImage2D( 13766 void GLES2DecoderImpl::DoCopyTexImage2D(
13761 GLenum target, 13767 GLenum target,
13762 GLint level, 13768 GLint level,
13763 GLenum internal_format, 13769 GLenum internal_format,
13764 GLint x, 13770 GLint x,
13765 GLint y, 13771 GLint y,
13766 GLsizei width, 13772 GLsizei width,
13767 GLsizei height, 13773 GLsizei height,
13768 GLint border) { 13774 GLint border) {
13769 const char* func_name = "glCopyTexImage2D"; 13775 const char* func_name = "glCopyTexImage2D";
(...skipping 2184 matching lines...) Expand 10 before | Expand all | Expand 10 after
15954 source_internal_format == GL_RED || source_internal_format == GL_ALPHA || 15960 source_internal_format == GL_RED || source_internal_format == GL_ALPHA ||
15955 source_internal_format == GL_RGB || source_internal_format == GL_RGBA || 15961 source_internal_format == GL_RGB || source_internal_format == GL_RGBA ||
15956 source_internal_format == GL_RGB8 || source_internal_format == GL_RGBA8 || 15962 source_internal_format == GL_RGB8 || source_internal_format == GL_RGBA8 ||
15957 source_internal_format == GL_LUMINANCE || 15963 source_internal_format == GL_LUMINANCE ||
15958 source_internal_format == GL_LUMINANCE_ALPHA || 15964 source_internal_format == GL_LUMINANCE_ALPHA ||
15959 source_internal_format == GL_BGRA_EXT || 15965 source_internal_format == GL_BGRA_EXT ||
15960 source_internal_format == GL_BGRA8_EXT || 15966 source_internal_format == GL_BGRA8_EXT ||
15961 source_internal_format == GL_RGB_YCBCR_420V_CHROMIUM || 15967 source_internal_format == GL_RGB_YCBCR_420V_CHROMIUM ||
15962 source_internal_format == GL_RGB_YCBCR_422_CHROMIUM; 15968 source_internal_format == GL_RGB_YCBCR_422_CHROMIUM;
15963 if (!valid_source_format) { 15969 if (!valid_source_format) {
15964 std::string msg = "invalid source internal format " +
15965 GLES2Util::GetStringEnum(source_internal_format);
15966 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
15967 msg.c_str());
15968 return false; 15970 return false;
15969 } 15971 }
15970 if (!valid_dest_format) { 15972 if (!valid_dest_format) {
15971 std::string msg = "invalid dest internal format " +
15972 GLES2Util::GetStringEnum(dest_internal_format);
15973 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name,
15974 msg.c_str());
15975 return false; 15973 return false;
15976 } 15974 }
15977 return true; 15975 return true;
15978 } 15976 }
15979 15977
15980 bool GLES2DecoderImpl::ValidateCompressedCopyTextureCHROMIUM( 15978 bool GLES2DecoderImpl::ValidateCompressedCopyTextureCHROMIUM(
15981 const char* function_name, 15979 const char* function_name,
15982 TextureRef* source_texture_ref, 15980 TextureRef* source_texture_ref,
15983 TextureRef* dest_texture_ref) { 15981 TextureRef* dest_texture_ref) {
15984 if (!source_texture_ref || !dest_texture_ref) { 15982 if (!source_texture_ref || !dest_texture_ref) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
16031 GLenum dest_type, 16029 GLenum dest_type,
16032 GLboolean unpack_flip_y, 16030 GLboolean unpack_flip_y,
16033 GLboolean unpack_premultiply_alpha, 16031 GLboolean unpack_premultiply_alpha,
16034 GLboolean unpack_unmultiply_alpha) { 16032 GLboolean unpack_unmultiply_alpha) {
16035 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopyTextureCHROMIUM"); 16033 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoCopyTextureCHROMIUM");
16036 static const char kFunctionName[] = "glCopyTextureCHROMIUM"; 16034 static const char kFunctionName[] = "glCopyTextureCHROMIUM";
16037 16035
16038 TextureRef* source_texture_ref = GetTexture(source_id); 16036 TextureRef* source_texture_ref = GetTexture(source_id);
16039 TextureRef* dest_texture_ref = GetTexture(dest_id); 16037 TextureRef* dest_texture_ref = GetTexture(dest_id);
16040 16038
16041 if (!texture_manager()->ValidateTextureParameters(
16042 GetErrorState(), kFunctionName, true, internal_format, dest_type,
16043 internal_format, 0))
16044 return;
16045
16046 if (!ValidateCopyTextureCHROMIUMTextures(kFunctionName, source_texture_ref, 16039 if (!ValidateCopyTextureCHROMIUMTextures(kFunctionName, source_texture_ref,
16047 dest_texture_ref)) { 16040 dest_texture_ref)) {
16048 return; 16041 return;
16049 } 16042 }
16050 16043
16051 if (!ValidateCopyTextureCHROMIUMInternalFormats(
16052 kFunctionName, source_texture_ref, internal_format)) {
16053 return;
16054 }
16055
16056 Texture* source_texture = source_texture_ref->texture(); 16044 Texture* source_texture = source_texture_ref->texture();
16057 Texture* dest_texture = dest_texture_ref->texture(); 16045 Texture* dest_texture = dest_texture_ref->texture();
16058 GLenum source_target = source_texture->target(); 16046 GLenum source_target = source_texture->target();
16059 GLenum dest_target = dest_texture->target(); 16047 GLenum dest_target = dest_texture->target();
16048
16049 GLenum source_type = 0;
16050 GLenum source_internal_format = 0;
16051 source_texture->GetLevelType(source_target, 0, &source_type,
16052 &source_internal_format);
16053 GLenum format = TextureManager::ExtractFormatFromStorageFormat(
16054 internal_format);
16055 if (!texture_manager()->ValidateTextureParameters(
16056 GetErrorState(), kFunctionName, true, format, dest_type,
16057 internal_format, 0))
16058 return;
16059
16060 bool legacy_format_valid = ValidateCopyTextureCHROMIUMInternalFormats(
Zhenyao Mo 2016/11/03 22:55:35 I think you should expand this function to handle
16061 kFunctionName, source_texture_ref, internal_format);
16062 bool source_format_color_renderable = Texture::ColorRenderable(
16063 GetFeatureInfo(), source_internal_format, source_texture->IsImmutable());
16064 std::string err_msg;
16065 bool copy_tex_image_format_valid = source_format_color_renderable &&
16066 source_target == GL_TEXTURE_2D && dest_target == GL_TEXTURE_2D &&
16067 ValidateCopyTexFormatHelper(internal_format,
16068 source_internal_format, source_type, err_msg);
16069 if (!legacy_format_valid && !copy_tex_image_format_valid) {
16070 std::string msg = "source internal format(" +
16071 GLES2Util::GetStringEnum(source_internal_format) +
16072 ") and destination internal format(" +
16073 GLES2Util::GetStringEnum(internal_format) +
16074 ") combination is invalid.";
16075 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName,
16076 msg.c_str());
16077 return;
16078 }
16079
16060 int source_width = 0; 16080 int source_width = 0;
16061 int source_height = 0; 16081 int source_height = 0;
16062 gl::GLImage* image = 16082 gl::GLImage* image =
16063 source_texture->GetLevelImage(source_target, 0); 16083 source_texture->GetLevelImage(source_target, 0);
16064 if (image) { 16084 if (image) {
16065 gfx::Size size = image->GetSize(); 16085 gfx::Size size = image->GetSize();
16066 source_width = size.width(); 16086 source_width = size.width();
16067 source_height = size.height(); 16087 source_height = size.height();
16068 if (source_width <= 0 || source_height <= 0) { 16088 if (source_width <= 0 || source_height <= 0) {
16069 LOCAL_SET_GL_ERROR( 16089 LOCAL_SET_GL_ERROR(
(...skipping 11 matching lines...) Expand all
16081 } 16101 }
16082 16102
16083 // Check that this type of texture is allowed. 16103 // Check that this type of texture is allowed.
16084 if (!texture_manager()->ValidForTarget(source_target, 0, 16104 if (!texture_manager()->ValidForTarget(source_target, 0,
16085 source_width, source_height, 1)) { 16105 source_width, source_height, 1)) {
16086 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "Bad dimensions"); 16106 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, "Bad dimensions");
16087 return; 16107 return;
16088 } 16108 }
16089 } 16109 }
16090 16110
16091 GLenum source_type = 0;
16092 GLenum source_internal_format = 0;
16093 source_texture->GetLevelType(source_target, 0, &source_type,
16094 &source_internal_format);
16095
16096 if (dest_texture->IsImmutable()) { 16111 if (dest_texture->IsImmutable()) {
16097 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName, 16112 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName,
16098 "texture is immutable"); 16113 "texture is immutable");
16099 return; 16114 return;
16100 } 16115 }
16101 16116
16102 // Clear the source texture if necessary. 16117 // Clear the source texture if necessary.
16103 if (!texture_manager()->ClearTextureLevel(this, source_texture_ref, 16118 if (!texture_manager()->ClearTextureLevel(this, source_texture_ref,
16104 source_target, 0)) { 16119 source_target, 0)) {
16105 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, kFunctionName, "dimensions too big"); 16120 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, kFunctionName, "dimensions too big");
(...skipping 20 matching lines...) Expand all
16126 dest_height != source_height || 16141 dest_height != source_height ||
16127 dest_internal_format != internal_format || 16142 dest_internal_format != internal_format ||
16128 dest_type_previous != dest_type) { 16143 dest_type_previous != dest_type) {
16129 // Ensure that the glTexImage2D succeeds. 16144 // Ensure that the glTexImage2D succeeds.
16130 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(kFunctionName); 16145 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(kFunctionName);
16131 glBindTexture(dest_target, dest_texture->service_id()); 16146 glBindTexture(dest_target, dest_texture->service_id());
16132 glTexImage2D( 16147 glTexImage2D(
16133 dest_target, 0, TextureManager::AdjustTexInternalFormat( 16148 dest_target, 0, TextureManager::AdjustTexInternalFormat(
16134 feature_info_.get(), internal_format), 16149 feature_info_.get(), internal_format),
16135 source_width, source_height, 0, 16150 source_width, source_height, 0,
16136 TextureManager::AdjustTexFormat(feature_info_.get(), internal_format), 16151 TextureManager::AdjustTexFormat(feature_info_.get(), format),
16137 dest_type, NULL); 16152 dest_type, NULL);
16138 GLenum error = LOCAL_PEEK_GL_ERROR(kFunctionName); 16153 GLenum error = LOCAL_PEEK_GL_ERROR(kFunctionName);
16139 if (error != GL_NO_ERROR) { 16154 if (error != GL_NO_ERROR) {
16140 RestoreCurrentTextureBindings(&state_, dest_target); 16155 RestoreCurrentTextureBindings(&state_, dest_target);
16141 return; 16156 return;
16142 } 16157 }
16143 16158
16144 texture_manager()->SetLevelInfo( 16159 texture_manager()->SetLevelInfo(
16145 dest_texture_ref, dest_target, 0, internal_format, source_width, 16160 dest_texture_ref, dest_target, 0, internal_format, source_width,
16146 source_height, 1, 0, internal_format, dest_type, 16161 source_height, 1, 0, format, dest_type,
16147 gfx::Rect(source_width, source_height)); 16162 gfx::Rect(source_width, source_height));
16148 dest_texture->ApplyFormatWorkarounds(feature_info_.get()); 16163 dest_texture->ApplyFormatWorkarounds(feature_info_.get());
16149 } else { 16164 } else {
16150 texture_manager()->SetLevelCleared(dest_texture_ref, dest_target, 0, 16165 texture_manager()->SetLevelCleared(dest_texture_ref, dest_target, 0, true);
16151 true);
16152 } 16166 }
16153 16167
16154 // Try using GLImage::CopyTexImage when possible. 16168 // Try using GLImage::CopyTexImage when possible.
16155 bool unpack_premultiply_alpha_change = 16169 bool unpack_premultiply_alpha_change =
16156 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0; 16170 (unpack_premultiply_alpha ^ unpack_unmultiply_alpha) != 0;
16157 if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) { 16171 if (image && !unpack_flip_y && !unpack_premultiply_alpha_change) {
16158 glBindTexture(dest_target, dest_texture->service_id()); 16172 glBindTexture(dest_target, dest_texture->service_id());
16159 if (image->CopyTexImage(dest_target)) 16173 if (image->CopyTexImage(dest_target))
16160 return; 16174 return;
16161 } 16175 }
16162 16176
16163 DoCopyTexImageIfNeeded(source_texture, source_target); 16177 DoCopyTexImageIfNeeded(source_texture, source_target);
16164 16178
16165 // GL_TEXTURE_EXTERNAL_OES texture requires that we apply a transform matrix 16179 // GL_TEXTURE_EXTERNAL_OES texture requires that we apply a transform matrix
16166 // before presenting. 16180 // before presenting.
16167 if (source_target == GL_TEXTURE_EXTERNAL_OES) { 16181 if (source_target == GL_TEXTURE_EXTERNAL_OES) {
16168 if (GLStreamTextureImage* image = 16182 if (GLStreamTextureImage* image =
16169 source_texture->GetLevelStreamTextureImage(GL_TEXTURE_EXTERNAL_OES, 16183 source_texture->GetLevelStreamTextureImage(GL_TEXTURE_EXTERNAL_OES,
16170 0)) { 16184 0)) {
16171 GLfloat transform_matrix[16]; 16185 GLfloat transform_matrix[16];
16172 image->GetTextureMatrix(transform_matrix); 16186 image->GetTextureMatrix(transform_matrix);
16173 copy_texture_CHROMIUM_->DoCopyTextureWithTransform( 16187 copy_texture_CHROMIUM_->DoCopyTextureWithTransform(
16174 this, source_target, source_texture->service_id(), dest_target, 16188 this, source_target, source_texture->service_id(), dest_target,
16175 dest_texture->service_id(), source_width, source_height, 16189 dest_texture->service_id(), source_width, source_height,
16176 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE, 16190 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE,
16177 unpack_unmultiply_alpha == GL_TRUE, transform_matrix); 16191 unpack_unmultiply_alpha == GL_TRUE, transform_matrix);
16178 return; 16192 return;
16179 } 16193 }
16180 } 16194 }
16181 copy_texture_CHROMIUM_->DoCopyTexture( 16195 if (legacy_format_valid) {
16182 this, source_target, source_texture->service_id(), source_internal_format, 16196 copy_texture_CHROMIUM_->DoCopyTexture(
16183 dest_target, dest_texture->service_id(), internal_format, source_width, 16197 this, source_target, source_texture->service_id(),
16184 source_height, unpack_flip_y == GL_TRUE, 16198 source_internal_format, dest_target, dest_texture->service_id(),
16185 unpack_premultiply_alpha == GL_TRUE, unpack_unmultiply_alpha == GL_TRUE); 16199 internal_format, source_width, source_height, unpack_flip_y == GL_TRUE,
16200 unpack_premultiply_alpha == GL_TRUE,
16201 unpack_unmultiply_alpha == GL_TRUE);
16202 } else if (copy_tex_image_format_valid) {
16203 copy_texture_CHROMIUM_->DoCopyTexImage2D(
16204 this, source_target, source_texture->service_id(),
16205 dest_target, dest_texture->service_id(),
16206 internal_format, source_width, source_height);
16207 } else {
16208 NOTIMPLEMENTED();
16209 }
16186 } 16210 }
16187 16211
16188 void GLES2DecoderImpl::DoCopySubTextureCHROMIUM( 16212 void GLES2DecoderImpl::DoCopySubTextureCHROMIUM(
16189 GLuint source_id, 16213 GLuint source_id,
16190 GLuint dest_id, 16214 GLuint dest_id,
16191 GLint xoffset, 16215 GLint xoffset,
16192 GLint yoffset, 16216 GLint yoffset,
16193 GLint x, 16217 GLint x,
16194 GLint y, 16218 GLint y,
16195 GLsizei width, 16219 GLsizei width,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
16277 "destination texture is not defined"); 16301 "destination texture is not defined");
16278 return; 16302 return;
16279 } 16303 }
16280 if (!dest_texture->ValidForTexture(dest_target, 0, xoffset, 16304 if (!dest_texture->ValidForTexture(dest_target, 0, xoffset,
16281 yoffset, 0, width, height, 1)) { 16305 yoffset, 0, width, height, 1)) {
16282 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName, 16306 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, kFunctionName,
16283 "destination texture bad dimensions."); 16307 "destination texture bad dimensions.");
16284 return; 16308 return;
16285 } 16309 }
16286 16310
16287 if (!ValidateCopyTextureCHROMIUMInternalFormats( 16311 bool legacy_format_valid = ValidateCopyTextureCHROMIUMInternalFormats(
16288 kFunctionName, source_texture_ref, dest_internal_format)) { 16312 kFunctionName, source_texture_ref, dest_internal_format);
16313 bool source_format_color_renderable = Texture::ColorRenderable(
16314 GetFeatureInfo(), source_internal_format, source_texture->IsImmutable());
16315 std::string err_msg;
16316 bool copy_tex_image_format_valid = source_format_color_renderable &&
16317 source_target == GL_TEXTURE_2D && dest_target == GL_TEXTURE_2D &&
16318 ValidateCopyTexFormatHelper(dest_internal_format,
16319 source_internal_format, source_type, err_msg);
16320 if (!legacy_format_valid && !copy_tex_image_format_valid) {
16321 std::string msg = "source internal format(" +
16322 GLES2Util::GetStringEnum(source_internal_format) +
16323 ") and destination internal format(" +
16324 GLES2Util::GetStringEnum(dest_internal_format) +
16325 ") combination is invalid.";
16326 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, kFunctionName,
16327 msg.c_str());
16289 return; 16328 return;
16290 } 16329 }
16291 16330
16292 // Clear the source texture if necessary. 16331 // Clear the source texture if necessary.
16293 if (!texture_manager()->ClearTextureLevel(this, source_texture_ref, 16332 if (!texture_manager()->ClearTextureLevel(this, source_texture_ref,
16294 source_target, 0)) { 16333 source_target, 0)) {
16295 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, kFunctionName, 16334 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, kFunctionName,
16296 "source texture dimensions too big"); 16335 "source texture dimensions too big");
16297 return; 16336 return;
16298 } 16337 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
16355 copy_texture_CHROMIUM_->DoCopySubTextureWithTransform( 16394 copy_texture_CHROMIUM_->DoCopySubTextureWithTransform(
16356 this, source_target, source_texture->service_id(), 16395 this, source_target, source_texture->service_id(),
16357 source_internal_format, dest_target, dest_texture->service_id(), 16396 source_internal_format, dest_target, dest_texture->service_id(),
16358 dest_internal_format, xoffset, yoffset, x, y, width, height, 16397 dest_internal_format, xoffset, yoffset, x, y, width, height,
16359 dest_width, dest_height, source_width, source_height, 16398 dest_width, dest_height, source_width, source_height,
16360 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE, 16399 unpack_flip_y == GL_TRUE, unpack_premultiply_alpha == GL_TRUE,
16361 unpack_unmultiply_alpha == GL_TRUE, transform_matrix); 16400 unpack_unmultiply_alpha == GL_TRUE, transform_matrix);
16362 return; 16401 return;
16363 } 16402 }
16364 } 16403 }
16365 copy_texture_CHROMIUM_->DoCopySubTexture( 16404 if (legacy_format_valid) {
16366 this, source_target, source_texture->service_id(), source_internal_format, 16405 copy_texture_CHROMIUM_->DoCopySubTexture(
16367 dest_target, dest_texture->service_id(), dest_internal_format, xoffset, 16406 this, source_target, source_texture->service_id(),
16368 yoffset, x, y, width, height, dest_width, dest_height, source_width, 16407 source_internal_format, dest_target, dest_texture->service_id(),
16369 source_height, unpack_flip_y == GL_TRUE, 16408 dest_internal_format, xoffset, yoffset, x, y, width, height,
16370 unpack_premultiply_alpha == GL_TRUE, unpack_unmultiply_alpha == GL_TRUE); 16409 dest_width, dest_height, source_width,
16410 source_height, unpack_flip_y == GL_TRUE,
16411 unpack_premultiply_alpha == GL_TRUE,
16412 unpack_unmultiply_alpha == GL_TRUE);
16413 } else if (copy_tex_image_format_valid) {
16414 copy_texture_CHROMIUM_->DoCopyTexSubImage2D(
16415 this, source_target, source_texture->service_id(),
16416 dest_target, dest_texture->service_id(),
16417 xoffset, yoffset, x, y, width, height);
16418 } else {
16419 NOTIMPLEMENTED();
16420 }
16371 } 16421 }
16372 16422
16373 bool GLES2DecoderImpl::InitializeCopyTexImageBlitter( 16423 bool GLES2DecoderImpl::InitializeCopyTexImageBlitter(
16374 const char* function_name) { 16424 const char* function_name) {
16375 if (!copy_tex_image_blit_.get()) { 16425 if (!copy_tex_image_blit_.get()) {
16376 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(function_name); 16426 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(function_name);
16377 copy_tex_image_blit_.reset( 16427 copy_tex_image_blit_.reset(
16378 new CopyTexImageResourceManager(feature_info_.get())); 16428 new CopyTexImageResourceManager(feature_info_.get()));
16379 copy_tex_image_blit_->Initialize(this); 16429 copy_tex_image_blit_->Initialize(this);
16380 if (LOCAL_PEEK_GL_ERROR(function_name) != GL_NO_ERROR) 16430 if (LOCAL_PEEK_GL_ERROR(function_name) != GL_NO_ERROR)
(...skipping 2405 matching lines...) Expand 10 before | Expand all | Expand 10 after
18786 } 18836 }
18787 18837
18788 // Include the auto-generated part of this file. We split this because it means 18838 // Include the auto-generated part of this file. We split this because it means
18789 // we can easily edit the non-auto generated parts right here in this file 18839 // we can easily edit the non-auto generated parts right here in this file
18790 // instead of having to edit some template or the code generator. 18840 // instead of having to edit some template or the code generator.
18791 #include "base/macros.h" 18841 #include "base/macros.h"
18792 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 18842 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
18793 18843
18794 } // namespace gles2 18844 } // namespace gles2
18795 } // namespace gpu 18845 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.cc ('k') | gpu/command_buffer/service/texture_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698