Chromium Code Reviews| 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/error_state.h" |
| 10 #include "gpu/command_buffer/service/feature_info.h" | 10 #include "gpu/command_buffer/service/feature_info.h" |
| 11 #include "gpu/command_buffer/service/framebuffer_manager.h" | 11 #include "gpu/command_buffer/service/framebuffer_manager.h" |
| 12 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 12 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 13 #include "gpu/command_buffer/service/mailbox_manager.h" | 13 #include "gpu/command_buffer/service/mailbox_manager.h" |
| 14 #include "gpu/command_buffer/service/memory_tracking.h" | 14 #include "gpu/command_buffer/service/memory_tracking.h" |
| 15 #include "gpu/command_buffer/service/texture_definition.h" | |
| 16 | 15 |
| 17 namespace gpu { | 16 namespace gpu { |
| 18 namespace gles2 { | 17 namespace gles2 { |
| 19 | 18 |
| 20 static size_t GLTargetToFaceIndex(GLenum target) { | 19 static size_t GLTargetToFaceIndex(GLenum target) { |
| 21 switch (target) { | 20 switch (target) { |
| 22 case GL_TEXTURE_2D: | 21 case GL_TEXTURE_2D: |
| 23 case GL_TEXTURE_EXTERNAL_OES: | 22 case GL_TEXTURE_EXTERNAL_OES: |
| 24 case GL_TEXTURE_RECTANGLE_ARB: | 23 case GL_TEXTURE_RECTANGLE_ARB: |
| 25 return 0; | 24 return 0; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 | 81 |
| 83 if (have_context) { | 82 if (have_context) { |
| 84 glDeleteTextures(arraysize(black_texture_ids_), black_texture_ids_); | 83 glDeleteTextures(arraysize(black_texture_ids_), black_texture_ids_); |
| 85 } | 84 } |
| 86 | 85 |
| 87 DCHECK_EQ(0u, memory_tracker_managed_->GetMemRepresented()); | 86 DCHECK_EQ(0u, memory_tracker_managed_->GetMemRepresented()); |
| 88 DCHECK_EQ(0u, memory_tracker_unmanaged_->GetMemRepresented()); | 87 DCHECK_EQ(0u, memory_tracker_unmanaged_->GetMemRepresented()); |
| 89 } | 88 } |
| 90 | 89 |
| 91 Texture::Texture(GLuint service_id) | 90 Texture::Texture(GLuint service_id) |
| 92 : memory_tracking_ref_(NULL), | 91 : mailbox_manager_(NULL), |
| 92 memory_tracking_ref_(NULL), | |
| 93 service_id_(service_id), | 93 service_id_(service_id), |
| 94 cleared_(true), | 94 cleared_(true), |
| 95 num_uncleared_mips_(0), | 95 num_uncleared_mips_(0), |
| 96 target_(0), | 96 target_(0), |
| 97 min_filter_(GL_NEAREST_MIPMAP_LINEAR), | 97 min_filter_(GL_NEAREST_MIPMAP_LINEAR), |
| 98 mag_filter_(GL_LINEAR), | 98 mag_filter_(GL_LINEAR), |
| 99 wrap_s_(GL_REPEAT), | 99 wrap_s_(GL_REPEAT), |
| 100 wrap_t_(GL_REPEAT), | 100 wrap_t_(GL_REPEAT), |
| 101 usage_(GL_NONE), | 101 usage_(GL_NONE), |
| 102 pool_(GL_TEXTURE_POOL_UNMANAGED_CHROMIUM), | 102 pool_(GL_TEXTURE_POOL_UNMANAGED_CHROMIUM), |
| 103 max_level_set_(-1), | 103 max_level_set_(-1), |
| 104 texture_complete_(false), | 104 texture_complete_(false), |
| 105 cube_complete_(false), | 105 cube_complete_(false), |
| 106 npot_(false), | 106 npot_(false), |
| 107 has_been_bound_(false), | 107 has_been_bound_(false), |
| 108 framebuffer_attachment_count_(0), | 108 framebuffer_attachment_count_(0), |
| 109 owned_(true), | 109 owned_(true), |
| 110 stream_texture_(false), | 110 stream_texture_(false), |
| 111 immutable_(false), | 111 immutable_(false), |
| 112 estimated_size_(0), | 112 estimated_size_(0), |
| 113 can_render_condition_(CAN_RENDER_ALWAYS) { | 113 can_render_condition_(CAN_RENDER_ALWAYS) { |
| 114 } | 114 } |
| 115 | 115 |
| 116 Texture::~Texture() { | 116 Texture::~Texture() { |
| 117 if (mailbox_manager_) | |
| 118 mailbox_manager_->TextureDeleted(this); | |
| 117 } | 119 } |
| 118 | 120 |
| 119 void Texture::AddTextureRef(TextureRef* ref) { | 121 void Texture::AddTextureRef(TextureRef* ref) { |
| 120 DCHECK(refs_.find(ref) == refs_.end()); | 122 DCHECK(refs_.find(ref) == refs_.end()); |
| 121 refs_.insert(ref); | 123 refs_.insert(ref); |
| 122 if (!memory_tracking_ref_) { | 124 if (!memory_tracking_ref_) { |
| 123 memory_tracking_ref_ = ref; | 125 memory_tracking_ref_ = ref; |
| 124 GetMemTracker()->TrackMemAlloc(estimated_size()); | 126 GetMemTracker()->TrackMemAlloc(estimated_size()); |
| 125 } | 127 } |
| 126 } | 128 } |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 259 "|min_filter=%04x|mag_filter=%04x|wrap_s=%04x|wrap_t=%04x" | 261 "|min_filter=%04x|mag_filter=%04x|wrap_s=%04x|wrap_t=%04x" |
| 260 "|usage=%04x", | 262 "|usage=%04x", |
| 261 target, level, info.internal_format, | 263 target, level, info.internal_format, |
| 262 info.width, info.height, info.depth, info.border, | 264 info.width, info.height, info.depth, info.border, |
| 263 info.format, info.type, info.image.get() != NULL, | 265 info.format, info.type, info.image.get() != NULL, |
| 264 CanRender(feature_info), CanRenderTo(), npot_, | 266 CanRender(feature_info), CanRenderTo(), npot_, |
| 265 min_filter_, mag_filter_, wrap_s_, wrap_t_, | 267 min_filter_, mag_filter_, wrap_s_, wrap_t_, |
| 266 usage_); | 268 usage_); |
| 267 } | 269 } |
| 268 | 270 |
| 271 void Texture::SetMailboxManager(MailboxManager* mailbox_manager) { | |
| 272 DCHECK(!mailbox_manager_ || mailbox_manager_ == mailbox_manager); | |
| 273 mailbox_manager_ = mailbox_manager; | |
| 274 } | |
| 275 | |
| 269 bool Texture::MarkMipmapsGenerated( | 276 bool Texture::MarkMipmapsGenerated( |
| 270 const FeatureInfo* feature_info) { | 277 const FeatureInfo* feature_info) { |
| 271 if (!CanGenerateMipmaps(feature_info)) { | 278 if (!CanGenerateMipmaps(feature_info)) { |
| 272 return false; | 279 return false; |
| 273 } | 280 } |
| 274 for (size_t ii = 0; ii < level_infos_.size(); ++ii) { | 281 for (size_t ii = 0; ii < level_infos_.size(); ++ii) { |
| 275 const Texture::LevelInfo& info1 = level_infos_[ii][0]; | 282 const Texture::LevelInfo& info1 = level_infos_[ii][0]; |
| 276 GLsizei width = info1.width; | 283 GLsizei width = info1.width; |
| 277 GLsizei height = info1.height; | 284 GLsizei height = info1.height; |
| 278 GLsizei depth = info1.depth; | 285 GLsizei depth = info1.depth; |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 787 static_cast<size_t>(level) < level_infos_[face_index].size()) { | 794 static_cast<size_t>(level) < level_infos_[face_index].size()) { |
| 788 const LevelInfo& info = level_infos_[GLTargetToFaceIndex(target)][level]; | 795 const LevelInfo& info = level_infos_[GLTargetToFaceIndex(target)][level]; |
| 789 if (info.target != 0) { | 796 if (info.target != 0) { |
| 790 return info.image; | 797 return info.image; |
| 791 } | 798 } |
| 792 } | 799 } |
| 793 return 0; | 800 return 0; |
| 794 } | 801 } |
| 795 | 802 |
| 796 | 803 |
| 797 TextureRef::TextureRef(TextureManager* manager, Texture* texture) | 804 TextureRef::TextureRef(TextureManager* manager, |
| 805 GLuint client_id, | |
| 806 Texture* texture) | |
| 798 : manager_(manager), | 807 : manager_(manager), |
| 799 texture_(texture) { | 808 texture_(texture), |
| 809 client_id_(client_id) { | |
| 800 DCHECK(manager_); | 810 DCHECK(manager_); |
| 801 DCHECK(texture_); | 811 DCHECK(texture_); |
| 802 texture_->AddTextureRef(this); | 812 texture_->AddTextureRef(this); |
| 803 manager_->StartTracking(this); | 813 manager_->StartTracking(this); |
| 804 } | 814 } |
| 805 | 815 |
| 806 scoped_refptr<TextureRef> TextureRef::Create(TextureManager* manager, | 816 scoped_refptr<TextureRef> TextureRef::Create(TextureManager* manager, |
| 817 GLuint client_id, | |
| 807 GLuint service_id) { | 818 GLuint service_id) { |
| 808 return new TextureRef(manager, new Texture(service_id)); | 819 return new TextureRef(manager, client_id, new Texture(service_id)); |
| 809 } | 820 } |
| 810 | 821 |
| 811 TextureRef::~TextureRef() { | 822 TextureRef::~TextureRef() { |
| 812 manager_->StopTracking(this); | 823 manager_->StopTracking(this); |
| 813 texture_->RemoveTextureRef(this, manager_->have_context_); | 824 texture_->RemoveTextureRef(this, manager_->have_context_); |
| 814 manager_ = NULL; | 825 manager_ = NULL; |
| 815 } | 826 } |
| 816 | 827 |
| 817 | |
| 818 TextureManager::TextureManager( | 828 TextureManager::TextureManager( |
| 819 MemoryTracker* memory_tracker, | 829 MemoryTracker* memory_tracker, |
| 820 FeatureInfo* feature_info, | 830 FeatureInfo* feature_info, |
| 821 GLint max_texture_size, | 831 GLint max_texture_size, |
| 822 GLint max_cube_map_texture_size) | 832 GLint max_cube_map_texture_size) |
| 823 : memory_tracker_managed_( | 833 : memory_tracker_managed_( |
| 824 new MemoryTypeTracker(memory_tracker, MemoryTracker::kManaged)), | 834 new MemoryTypeTracker(memory_tracker, MemoryTracker::kManaged)), |
| 825 memory_tracker_unmanaged_( | 835 memory_tracker_unmanaged_( |
| 826 new MemoryTypeTracker(memory_tracker, MemoryTracker::kUnmanaged)), | 836 new MemoryTypeTracker(memory_tracker, MemoryTracker::kUnmanaged)), |
| 827 feature_info_(feature_info), | 837 feature_info_(feature_info), |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 890 GL_RGBA, GL_UNSIGNED_BYTE, black); | 900 GL_RGBA, GL_UNSIGNED_BYTE, black); |
| 891 } | 901 } |
| 892 } else { | 902 } else { |
| 893 glTexImage2D(target, 0, GL_RGBA, 1, 1, 0, GL_RGBA, | 903 glTexImage2D(target, 0, GL_RGBA, 1, 1, 0, GL_RGBA, |
| 894 GL_UNSIGNED_BYTE, black); | 904 GL_UNSIGNED_BYTE, black); |
| 895 } | 905 } |
| 896 } | 906 } |
| 897 } | 907 } |
| 898 glBindTexture(target, 0); | 908 glBindTexture(target, 0); |
| 899 | 909 |
| 900 scoped_refptr<TextureRef> default_texture(TextureRef::Create(this, ids[1])); | 910 scoped_refptr<TextureRef> default_texture( |
| 911 TextureRef::Create(this, 0, ids[1])); | |
| 901 SetTarget(default_texture, target); | 912 SetTarget(default_texture, target); |
| 902 if (needs_faces) { | 913 if (needs_faces) { |
| 903 for (int ii = 0; ii < GLES2Util::kNumFaces; ++ii) { | 914 for (int ii = 0; ii < GLES2Util::kNumFaces; ++ii) { |
| 904 SetLevelInfo( | 915 SetLevelInfo( |
| 905 default_texture, GLES2Util::IndexToGLFaceTarget(ii), | 916 default_texture, GLES2Util::IndexToGLFaceTarget(ii), |
| 906 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true); | 917 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, true); |
| 907 } | 918 } |
| 908 } else { | 919 } else { |
| 909 if (needs_initialization) { | 920 if (needs_initialization) { |
| 910 SetLevelInfo(default_texture, | 921 SetLevelInfo(default_texture, |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 992 DCHECK(ref); | 1003 DCHECK(ref); |
| 993 Texture* texture = ref->texture(); | 1004 Texture* texture = ref->texture(); |
| 994 | 1005 |
| 995 texture->GetMemTracker()->TrackMemFree(texture->estimated_size()); | 1006 texture->GetMemTracker()->TrackMemFree(texture->estimated_size()); |
| 996 texture->SetLevelInfo( | 1007 texture->SetLevelInfo( |
| 997 feature_info_, target, level, internal_format, width, height, depth, | 1008 feature_info_, target, level, internal_format, width, height, depth, |
| 998 border, format, type, cleared); | 1009 border, format, type, cleared); |
| 999 texture->GetMemTracker()->TrackMemAlloc(texture->estimated_size()); | 1010 texture->GetMemTracker()->TrackMemAlloc(texture->estimated_size()); |
| 1000 } | 1011 } |
| 1001 | 1012 |
| 1002 TextureDefinition* TextureManager::Save(TextureRef* ref) { | 1013 Texture* TextureManager::Produce(TextureRef* ref) { |
| 1003 DCHECK(ref); | 1014 DCHECK(ref); |
| 1004 Texture* texture = ref->texture(); | 1015 Texture* texture = ref->texture(); |
| 1005 DCHECK(texture->owned_); | 1016 if (!texture->owned_) |
| 1006 | |
| 1007 if (texture->IsAttachedToFramebuffer()) | |
| 1008 return NULL; | 1017 return NULL; |
| 1009 | 1018 return texture; |
| 1010 TextureDefinition::LevelInfos level_infos(texture->level_infos_.size()); | |
| 1011 for (size_t face = 0; face < level_infos.size(); ++face) { | |
| 1012 GLenum target = | |
| 1013 texture->target() == GL_TEXTURE_CUBE_MAP ? FaceIndexToGLTarget(face) | |
| 1014 : texture->target(); | |
| 1015 for (GLint level = 0; level <= texture->max_level_set_; ++level) { | |
| 1016 const Texture::LevelInfo& level_info = | |
| 1017 texture->level_infos_[face][level]; | |
| 1018 | |
| 1019 level_infos[face].push_back( | |
| 1020 TextureDefinition::LevelInfo(target, | |
| 1021 level_info.internal_format, | |
| 1022 level_info.width, | |
| 1023 level_info.height, | |
| 1024 level_info.depth, | |
| 1025 level_info.border, | |
| 1026 level_info.format, | |
| 1027 level_info.type, | |
| 1028 level_info.cleared)); | |
| 1029 | |
| 1030 SetLevelInfo(ref, | |
| 1031 target, | |
| 1032 level, | |
| 1033 GL_RGBA, | |
| 1034 0, | |
| 1035 0, | |
| 1036 0, | |
| 1037 0, | |
| 1038 GL_RGBA, | |
| 1039 GL_UNSIGNED_BYTE, | |
| 1040 true); | |
| 1041 } | |
| 1042 } | |
| 1043 | |
| 1044 GLuint old_service_id = texture->service_id(); | |
| 1045 bool immutable = texture->IsImmutable(); | |
| 1046 bool stream_texture = texture->IsStreamTexture(); | |
| 1047 | |
| 1048 GLuint new_service_id = 0; | |
| 1049 glGenTextures(1, &new_service_id); | |
| 1050 texture->SetServiceId(new_service_id); | |
| 1051 texture->SetImmutable(false); | |
| 1052 texture->SetStreamTexture(false); | |
| 1053 | |
| 1054 return new TextureDefinition(texture->target(), | |
| 1055 old_service_id, | |
| 1056 texture->min_filter(), | |
| 1057 texture->mag_filter(), | |
| 1058 texture->wrap_s(), | |
| 1059 texture->wrap_t(), | |
| 1060 texture->usage(), | |
| 1061 immutable, | |
| 1062 stream_texture, | |
| 1063 level_infos); | |
| 1064 } | 1019 } |
| 1065 | 1020 |
| 1066 bool TextureManager::Restore( | 1021 TextureRef* TextureManager::Consume( |
| 1067 const char* function_name, | 1022 GLuint client_id, |
| 1068 GLES2Decoder* decoder, | 1023 Texture* texture) { |
| 1069 TextureRef* ref, | 1024 DCHECK(client_id); |
| 1070 TextureDefinition* definition) { | 1025 scoped_refptr<TextureRef> ref(new TextureRef(this, client_id, texture)); |
| 1071 DCHECK(ref); | 1026 bool result = textures_.insert(std::make_pair(client_id, ref)).second; |
| 1072 Texture* texture = ref->texture(); | 1027 DCHECK(result); |
|
greggman
2013/05/23 17:36:19
Seems like there needs to be some bookkeeping call
piman
2013/05/23 18:02:38
This is done when we create the TextureRef - it ca
greggman
2013/05/23 18:38:26
I'm confused. TextureRefs are per context so chang
| |
| 1073 DCHECK(texture->owned_); | 1028 return ref.get(); |
| 1074 | |
| 1075 scoped_ptr<TextureDefinition> scoped_definition(definition); | |
| 1076 | |
| 1077 if (texture->IsAttachedToFramebuffer()) | |
| 1078 return false; | |
| 1079 | |
| 1080 if (texture->target() != definition->target()) | |
| 1081 return false; | |
| 1082 | |
| 1083 if (texture->level_infos_.size() < definition->level_infos().size()) | |
| 1084 return false; | |
| 1085 | |
| 1086 if (texture->level_infos_[0].size() < definition->level_infos()[0].size()) | |
| 1087 return false; | |
| 1088 | |
| 1089 for (size_t face = 0; face < definition->level_infos().size(); ++face) { | |
| 1090 GLenum target = | |
| 1091 texture->target() == GL_TEXTURE_CUBE_MAP ? FaceIndexToGLTarget(face) | |
| 1092 : texture->target(); | |
| 1093 GLint new_max_level = definition->level_infos()[face].size() - 1; | |
| 1094 for (GLint level = 0; | |
| 1095 level <= std::max(texture->max_level_set_, new_max_level); | |
| 1096 ++level) { | |
| 1097 const TextureDefinition::LevelInfo& level_info = | |
| 1098 level <= new_max_level ? definition->level_infos()[face][level] | |
| 1099 : TextureDefinition::LevelInfo(); | |
| 1100 SetLevelInfo(ref, | |
| 1101 target, | |
| 1102 level, | |
| 1103 level_info.internal_format, | |
| 1104 level_info.width, | |
| 1105 level_info.height, | |
| 1106 level_info.depth, | |
| 1107 level_info.border, | |
| 1108 level_info.format, | |
| 1109 level_info.type, | |
| 1110 level_info.cleared); | |
| 1111 } | |
| 1112 } | |
| 1113 | |
| 1114 GLuint old_service_id = texture->service_id(); | |
| 1115 glDeleteTextures(1, &old_service_id); | |
| 1116 texture->SetServiceId(definition->ReleaseServiceId()); | |
| 1117 glBindTexture(texture->target(), texture->service_id()); | |
| 1118 texture->SetImmutable(definition->immutable()); | |
| 1119 texture->SetStreamTexture(definition->stream_texture()); | |
| 1120 ErrorState* error_state = decoder->GetErrorState(); | |
| 1121 SetParameter(function_name, error_state, ref, GL_TEXTURE_MIN_FILTER, | |
| 1122 definition->min_filter()); | |
| 1123 SetParameter(function_name, error_state, ref, GL_TEXTURE_MAG_FILTER, | |
| 1124 definition->mag_filter()); | |
| 1125 SetParameter(function_name, error_state, ref, GL_TEXTURE_WRAP_S, | |
| 1126 definition->wrap_s()); | |
| 1127 SetParameter(function_name, error_state, ref, GL_TEXTURE_WRAP_T, | |
| 1128 definition->wrap_t()); | |
| 1129 if (feature_info_->validators()->texture_parameter.IsValid( | |
| 1130 GL_TEXTURE_USAGE_ANGLE)) { | |
| 1131 SetParameter(function_name, error_state, ref, GL_TEXTURE_USAGE_ANGLE, | |
| 1132 definition->usage()); | |
| 1133 } | |
| 1134 | |
| 1135 return true; | |
| 1136 } | 1029 } |
| 1137 | 1030 |
| 1138 void TextureManager::SetParameter( | 1031 void TextureManager::SetParameter( |
| 1139 const char* function_name, ErrorState* error_state, | 1032 const char* function_name, ErrorState* error_state, |
| 1140 TextureRef* ref, GLenum pname, GLint param) { | 1033 TextureRef* ref, GLenum pname, GLint param) { |
| 1141 DCHECK(error_state); | 1034 DCHECK(error_state); |
| 1142 DCHECK(ref); | 1035 DCHECK(ref); |
| 1143 Texture* texture = ref->texture(); | 1036 Texture* texture = ref->texture(); |
| 1144 GLenum result = texture->SetParameter(feature_info_, pname, param); | 1037 GLenum result = texture->SetParameter(feature_info_, pname, param); |
| 1145 if (result != GL_NO_ERROR) { | 1038 if (result != GL_NO_ERROR) { |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 1164 Texture* texture = ref->texture(); | 1057 Texture* texture = ref->texture(); |
| 1165 texture->GetMemTracker()->TrackMemFree(texture->estimated_size()); | 1058 texture->GetMemTracker()->TrackMemFree(texture->estimated_size()); |
| 1166 bool result = texture->MarkMipmapsGenerated(feature_info_); | 1059 bool result = texture->MarkMipmapsGenerated(feature_info_); |
| 1167 texture->GetMemTracker()->TrackMemAlloc(texture->estimated_size()); | 1060 texture->GetMemTracker()->TrackMemAlloc(texture->estimated_size()); |
| 1168 return result; | 1061 return result; |
| 1169 } | 1062 } |
| 1170 | 1063 |
| 1171 TextureRef* TextureManager::CreateTexture( | 1064 TextureRef* TextureManager::CreateTexture( |
| 1172 GLuint client_id, GLuint service_id) { | 1065 GLuint client_id, GLuint service_id) { |
| 1173 DCHECK_NE(0u, service_id); | 1066 DCHECK_NE(0u, service_id); |
| 1174 scoped_refptr<TextureRef> ref(TextureRef::Create(this, service_id)); | 1067 scoped_refptr<TextureRef> ref(TextureRef::Create( |
| 1068 this, client_id, service_id)); | |
| 1175 std::pair<TextureMap::iterator, bool> result = | 1069 std::pair<TextureMap::iterator, bool> result = |
| 1176 textures_.insert(std::make_pair(client_id, ref)); | 1070 textures_.insert(std::make_pair(client_id, ref)); |
| 1177 DCHECK(result.second); | 1071 DCHECK(result.second); |
| 1178 return ref.get(); | 1072 return ref.get(); |
| 1179 } | 1073 } |
| 1180 | 1074 |
| 1181 TextureRef* TextureManager::GetTexture( | 1075 TextureRef* TextureManager::GetTexture( |
| 1182 GLuint client_id) const { | 1076 GLuint client_id) const { |
| 1183 TextureMap::const_iterator it = textures_.find(client_id); | 1077 TextureMap::const_iterator it = textures_.find(client_id); |
| 1184 return it != textures_.end() ? it->second : NULL; | 1078 return it != textures_.end() ? it->second : NULL; |
| 1185 } | 1079 } |
| 1186 | 1080 |
| 1187 void TextureManager::RemoveTexture(GLuint client_id) { | 1081 void TextureManager::RemoveTexture(GLuint client_id) { |
| 1188 TextureMap::iterator it = textures_.find(client_id); | 1082 TextureMap::iterator it = textures_.find(client_id); |
| 1189 if (it != textures_.end()) { | 1083 if (it != textures_.end()) { |
| 1084 it->second->reset_client_id(); | |
| 1190 textures_.erase(it); | 1085 textures_.erase(it); |
| 1191 } | 1086 } |
| 1192 } | 1087 } |
| 1193 | 1088 |
| 1194 void TextureManager::StartTracking(TextureRef* ref) { | 1089 void TextureManager::StartTracking(TextureRef* ref) { |
| 1195 Texture* texture = ref->texture(); | 1090 Texture* texture = ref->texture(); |
| 1196 ++texture_count_; | 1091 ++texture_count_; |
| 1197 num_uncleared_mips_ += texture->num_uncleared_mips(); | 1092 num_uncleared_mips_ += texture->num_uncleared_mips(); |
| 1198 if (!texture->SafeToRenderFrom()) | 1093 if (!texture->SafeToRenderFrom()) |
| 1199 ++num_unsafe_textures_; | 1094 ++num_unsafe_textures_; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1291 } | 1186 } |
| 1292 | 1187 |
| 1293 void TextureManager::IncFramebufferStateChangeCount() { | 1188 void TextureManager::IncFramebufferStateChangeCount() { |
| 1294 if (framebuffer_manager_) | 1189 if (framebuffer_manager_) |
| 1295 framebuffer_manager_->IncFramebufferStateChangeCount(); | 1190 framebuffer_manager_->IncFramebufferStateChangeCount(); |
| 1296 | 1191 |
| 1297 } | 1192 } |
| 1298 | 1193 |
| 1299 } // namespace gles2 | 1194 } // namespace gles2 |
| 1300 } // namespace gpu | 1195 } // namespace gpu |
| OLD | NEW |