OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gpu/command_buffer/service/texture_manager.h" | 5 #include "gpu/command_buffer/service/texture_manager.h" |
6 #include "base/bits.h" | 6 #include "base/bits.h" |
7 #include "base/stringprintf.h" | 7 #include "base/stringprintf.h" |
8 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 8 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| 9 #include "gpu/command_buffer/service/error_state.h" |
9 #include "gpu/command_buffer/service/feature_info.h" | 10 #include "gpu/command_buffer/service/feature_info.h" |
10 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 11 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
11 #include "gpu/command_buffer/service/mailbox_manager.h" | 12 #include "gpu/command_buffer/service/mailbox_manager.h" |
12 #include "gpu/command_buffer/service/memory_tracking.h" | 13 #include "gpu/command_buffer/service/memory_tracking.h" |
13 #include "gpu/command_buffer/service/texture_definition.h" | 14 #include "gpu/command_buffer/service/texture_definition.h" |
14 | 15 |
15 namespace gpu { | 16 namespace gpu { |
16 namespace gles2 { | 17 namespace gles2 { |
17 | 18 |
18 static size_t GLTargetToFaceIndex(GLenum target) { | 19 static size_t GLTargetToFaceIndex(GLenum target) { |
(...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1040 level_info.cleared); | 1041 level_info.cleared); |
1041 } | 1042 } |
1042 } | 1043 } |
1043 | 1044 |
1044 GLuint old_service_id = texture->service_id(); | 1045 GLuint old_service_id = texture->service_id(); |
1045 glDeleteTextures(1, &old_service_id); | 1046 glDeleteTextures(1, &old_service_id); |
1046 texture->SetServiceId(definition->ReleaseServiceId()); | 1047 texture->SetServiceId(definition->ReleaseServiceId()); |
1047 glBindTexture(texture->target(), texture->service_id()); | 1048 glBindTexture(texture->target(), texture->service_id()); |
1048 texture->SetImmutable(definition->immutable()); | 1049 texture->SetImmutable(definition->immutable()); |
1049 texture->SetStreamTexture(definition->stream_texture()); | 1050 texture->SetStreamTexture(definition->stream_texture()); |
1050 SetParameter(function_name, decoder, texture, GL_TEXTURE_MIN_FILTER, | 1051 |
| 1052 ErrorState* error_state = decoder->GetErrorState(); |
| 1053 SetParameter(function_name, error_state, texture, GL_TEXTURE_MIN_FILTER, |
1051 definition->min_filter()); | 1054 definition->min_filter()); |
1052 SetParameter(function_name, decoder, texture, GL_TEXTURE_MAG_FILTER, | 1055 SetParameter(function_name, error_state, texture, GL_TEXTURE_MAG_FILTER, |
1053 definition->mag_filter()); | 1056 definition->mag_filter()); |
1054 SetParameter(function_name, decoder, texture, GL_TEXTURE_WRAP_S, | 1057 SetParameter(function_name, error_state, texture, GL_TEXTURE_WRAP_S, |
1055 definition->wrap_s()); | 1058 definition->wrap_s()); |
1056 SetParameter(function_name, decoder, texture, GL_TEXTURE_WRAP_T, | 1059 SetParameter(function_name, error_state, texture, GL_TEXTURE_WRAP_T, |
1057 definition->wrap_t()); | 1060 definition->wrap_t()); |
1058 if (feature_info_->validators()->texture_parameter.IsValid( | 1061 if (feature_info_->validators()->texture_parameter.IsValid( |
1059 GL_TEXTURE_USAGE_ANGLE)) { | 1062 GL_TEXTURE_USAGE_ANGLE)) { |
1060 SetParameter(function_name, decoder, texture, GL_TEXTURE_USAGE_ANGLE, | 1063 SetParameter(function_name, error_state, texture, GL_TEXTURE_USAGE_ANGLE, |
1061 definition->usage()); | 1064 definition->usage()); |
1062 } | 1065 } |
1063 | 1066 |
1064 return true; | 1067 return true; |
1065 } | 1068 } |
1066 | 1069 |
1067 void TextureManager::SetParameter( | 1070 void TextureManager::SetParameter( |
1068 const char* function_name, GLES2Decoder* decoder, | 1071 const char* function_name, ErrorState* error_state, |
1069 Texture* texture, GLenum pname, GLint param) { | 1072 Texture* texture, GLenum pname, GLint param) { |
1070 DCHECK(decoder); | 1073 DCHECK(error_state); |
1071 DCHECK(texture); | 1074 DCHECK(texture); |
1072 if (!texture->CanRender(feature_info_)) { | 1075 if (!texture->CanRender(feature_info_)) { |
1073 DCHECK_NE(0, num_unrenderable_textures_); | 1076 DCHECK_NE(0, num_unrenderable_textures_); |
1074 --num_unrenderable_textures_; | 1077 --num_unrenderable_textures_; |
1075 } | 1078 } |
1076 if (!texture->SafeToRenderFrom()) { | 1079 if (!texture->SafeToRenderFrom()) { |
1077 DCHECK_NE(0, num_unsafe_textures_); | 1080 DCHECK_NE(0, num_unsafe_textures_); |
1078 --num_unsafe_textures_; | 1081 --num_unsafe_textures_; |
1079 } | 1082 } |
1080 GLenum result = texture->SetParameter(feature_info_, pname, param); | 1083 GLenum result = texture->SetParameter(feature_info_, pname, param); |
1081 if (result != GL_NO_ERROR) { | 1084 if (result != GL_NO_ERROR) { |
1082 if (result == GL_INVALID_ENUM) { | 1085 if (result == GL_INVALID_ENUM) { |
1083 GLESDECODER_SET_GL_ERROR_INVALID_ENUM( | 1086 ERRORSTATE_SET_GL_ERROR_INVALID_ENUM( |
1084 decoder, function_name, param, "param"); | 1087 error_state, function_name, param, "param"); |
1085 } else { | 1088 } else { |
1086 GLESDECODER_SET_GL_ERROR_INVALID_PARAM( | 1089 ERRORSTATE_SET_GL_ERROR_INVALID_PARAM( |
1087 decoder, result, function_name, pname, static_cast<GLint>(param)); | 1090 error_state, result, function_name, pname, static_cast<GLint>(param)); |
1088 } | 1091 } |
1089 } else { | 1092 } else { |
1090 // Texture tracking pools exist only for the command decoder, so | 1093 // Texture tracking pools exist only for the command decoder, so |
1091 // do not pass them on to the native GL implementation. | 1094 // do not pass them on to the native GL implementation. |
1092 if (pname != GL_TEXTURE_POOL_CHROMIUM) { | 1095 if (pname != GL_TEXTURE_POOL_CHROMIUM) { |
1093 glTexParameteri(texture->target(), pname, param); | 1096 glTexParameteri(texture->target(), pname, param); |
1094 } | 1097 } |
1095 } | 1098 } |
1096 | 1099 |
1097 if (!texture->CanRender(feature_info_)) { | 1100 if (!texture->CanRender(feature_info_)) { |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1237 void TextureManager::AddToSignature( | 1240 void TextureManager::AddToSignature( |
1238 Texture* texture, | 1241 Texture* texture, |
1239 GLenum target, | 1242 GLenum target, |
1240 GLint level, | 1243 GLint level, |
1241 std::string* signature) const { | 1244 std::string* signature) const { |
1242 texture->AddToSignature(feature_info_.get(), target, level, signature); | 1245 texture->AddToSignature(feature_info_.get(), target, level, signature); |
1243 } | 1246 } |
1244 | 1247 |
1245 } // namespace gles2 | 1248 } // namespace gles2 |
1246 } // namespace gpu | 1249 } // namespace gpu |
OLD | NEW |