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

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

Issue 14308014: Clean up of GLES2 Command Decoder by moving some of the error state into a separate class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed the remaining tests. Added mock ErrorState. Created 7 years, 8 months 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/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 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 level_info.type, 1037 level_info.type,
1037 level_info.cleared); 1038 level_info.cleared);
1038 } 1039 }
1039 } 1040 }
1040 1041
1041 GLuint old_service_id = texture->service_id(); 1042 GLuint old_service_id = texture->service_id();
1042 glDeleteTextures(1, &old_service_id); 1043 glDeleteTextures(1, &old_service_id);
1043 texture->SetServiceId(definition->ReleaseServiceId()); 1044 texture->SetServiceId(definition->ReleaseServiceId());
1044 glBindTexture(texture->target(), texture->service_id()); 1045 glBindTexture(texture->target(), texture->service_id());
1045 texture->SetImmutable(definition->immutable()); 1046 texture->SetImmutable(definition->immutable());
1046 SetParameter(function_name, decoder, texture, GL_TEXTURE_MIN_FILTER, 1047 ErrorState* error_state = decoder->GetErrorState();
1048 SetParameter(function_name, error_state, texture, GL_TEXTURE_MIN_FILTER,
1047 definition->min_filter()); 1049 definition->min_filter());
1048 SetParameter(function_name, decoder, texture, GL_TEXTURE_MAG_FILTER, 1050 SetParameter(function_name, error_state, texture, GL_TEXTURE_MAG_FILTER,
1049 definition->mag_filter()); 1051 definition->mag_filter());
1050 SetParameter(function_name, decoder, texture, GL_TEXTURE_WRAP_S, 1052 SetParameter(function_name, error_state, texture, GL_TEXTURE_WRAP_S,
1051 definition->wrap_s()); 1053 definition->wrap_s());
1052 SetParameter(function_name, decoder, texture, GL_TEXTURE_WRAP_T, 1054 SetParameter(function_name, error_state, texture, GL_TEXTURE_WRAP_T,
1053 definition->wrap_t()); 1055 definition->wrap_t());
1054 if (feature_info_->validators()->texture_parameter.IsValid( 1056 if (feature_info_->validators()->texture_parameter.IsValid(
1055 GL_TEXTURE_USAGE_ANGLE)) { 1057 GL_TEXTURE_USAGE_ANGLE)) {
1056 SetParameter(function_name, decoder, texture, GL_TEXTURE_USAGE_ANGLE, 1058 SetParameter(function_name, error_state, texture, GL_TEXTURE_USAGE_ANGLE,
1057 definition->usage()); 1059 definition->usage());
1058 } 1060 }
1059 1061
1060 return true; 1062 return true;
1061 } 1063 }
1062 1064
1063 void TextureManager::SetParameter( 1065 void TextureManager::SetParameter(
1064 const char* function_name, GLES2Decoder* decoder, 1066 const char* function_name, ErrorState* error_state,
1065 Texture* texture, GLenum pname, GLint param) { 1067 Texture* texture, GLenum pname, GLint param) {
1066 DCHECK(decoder); 1068 DCHECK(error_state);
1067 DCHECK(texture); 1069 DCHECK(texture);
1068 if (!texture->CanRender(feature_info_)) { 1070 if (!texture->CanRender(feature_info_)) {
1069 DCHECK_NE(0, num_unrenderable_textures_); 1071 DCHECK_NE(0, num_unrenderable_textures_);
1070 --num_unrenderable_textures_; 1072 --num_unrenderable_textures_;
1071 } 1073 }
1072 if (!texture->SafeToRenderFrom()) { 1074 if (!texture->SafeToRenderFrom()) {
1073 DCHECK_NE(0, num_unsafe_textures_); 1075 DCHECK_NE(0, num_unsafe_textures_);
1074 --num_unsafe_textures_; 1076 --num_unsafe_textures_;
1075 } 1077 }
1076 GLenum result = texture->SetParameter(feature_info_, pname, param); 1078 GLenum result = texture->SetParameter(feature_info_, pname, param);
1077 if (result != GL_NO_ERROR) { 1079 if (result != GL_NO_ERROR) {
1078 if (result == GL_INVALID_ENUM) { 1080 if (result == GL_INVALID_ENUM) {
1079 GLESDECODER_SET_GL_ERROR_INVALID_ENUM( 1081 ERRORSTATE_SET_GL_ERROR_INVALID_ENUM(
1080 decoder, function_name, param, "param"); 1082 error_state, function_name, param, "param");
1081 } else { 1083 } else {
1082 GLESDECODER_SET_GL_ERROR_INVALID_PARAM( 1084 ERRORSTATE_SET_GL_ERROR_INVALID_PARAM(
1083 decoder, result, function_name, pname, static_cast<GLint>(param)); 1085 error_state, result, function_name, pname, static_cast<GLint>(param));
1084 } 1086 }
1085 } else { 1087 } else {
1086 // Texture tracking pools exist only for the command decoder, so 1088 // Texture tracking pools exist only for the command decoder, so
1087 // do not pass them on to the native GL implementation. 1089 // do not pass them on to the native GL implementation.
1088 if (pname != GL_TEXTURE_POOL_CHROMIUM) { 1090 if (pname != GL_TEXTURE_POOL_CHROMIUM) {
1089 glTexParameteri(texture->target(), pname, param); 1091 glTexParameteri(texture->target(), pname, param);
1090 } 1092 }
1091 } 1093 }
1092 1094
1093 if (!texture->CanRender(feature_info_)) { 1095 if (!texture->CanRender(feature_info_)) {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 void TextureManager::AddToSignature( 1235 void TextureManager::AddToSignature(
1234 Texture* texture, 1236 Texture* texture,
1235 GLenum target, 1237 GLenum target,
1236 GLint level, 1238 GLint level,
1237 std::string* signature) const { 1239 std::string* signature) const {
1238 texture->AddToSignature(feature_info_.get(), target, level, signature); 1240 texture->AddToSignature(feature_info_.get(), target, level, signature);
1239 } 1241 }
1240 1242
1241 } // namespace gles2 1243 } // namespace gles2
1242 } // namespace gpu 1244 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698