| OLD | NEW | 
|    1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |    1 // Copyright (c) 2010 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 "gpu/command_buffer/common/gles2_cmd_utils.h" |    7 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 
|    8 #include "gpu/command_buffer/service/context_group.h" |    8 #include "gpu/command_buffer/service/context_group.h" | 
|    9 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |    9 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 
|   10  |   10  | 
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  271   default_texture_cube_map_ = TextureInfo::Ref(new TextureInfo(0)); |  271   default_texture_cube_map_ = TextureInfo::Ref(new TextureInfo(0)); | 
|  272   SetInfoTarget(default_texture_cube_map_, GL_TEXTURE_CUBE_MAP); |  272   SetInfoTarget(default_texture_cube_map_, GL_TEXTURE_CUBE_MAP); | 
|  273   for (int ii = 0; ii < GLES2Util::kNumFaces; ++ii) { |  273   for (int ii = 0; ii < GLES2Util::kNumFaces; ++ii) { | 
|  274     default_texture_cube_map_->SetLevelInfo( |  274     default_texture_cube_map_->SetLevelInfo( | 
|  275       GLES2Util::IndexToGLFaceTarget(ii), |  275       GLES2Util::IndexToGLFaceTarget(ii), | 
|  276       0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE); |  276       0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE); | 
|  277   } |  277   } | 
|  278 } |  278 } | 
|  279  |  279  | 
|  280 TextureManager::TextureInfo* TextureManager::CreateTextureInfo( |  280 TextureManager::TextureInfo* TextureManager::CreateTextureInfo( | 
|  281     GLuint texture_id) { |  281     GLuint client_id, GLuint service_id) { | 
|  282   TextureInfo::Ref info(new TextureInfo(texture_id)); |  282   TextureInfo::Ref info(new TextureInfo(service_id)); | 
|  283   std::pair<TextureInfoMap::iterator, bool> result = |  283   std::pair<TextureInfoMap::iterator, bool> result = | 
|  284       texture_infos_.insert(std::make_pair(texture_id, info)); |  284       texture_infos_.insert(std::make_pair(client_id, info)); | 
|  285   DCHECK(result.second); |  285   DCHECK(result.second); | 
|  286   return info.get(); |  286   return info.get(); | 
|  287 } |  287 } | 
|  288  |  288  | 
|  289 TextureManager::TextureInfo* TextureManager::GetTextureInfo( |  289 TextureManager::TextureInfo* TextureManager::GetTextureInfo( | 
|  290     GLuint texture_id) { |  290     GLuint client_id) { | 
|  291   TextureInfoMap::iterator it = texture_infos_.find(texture_id); |  291   TextureInfoMap::iterator it = texture_infos_.find(client_id); | 
|  292   return it != texture_infos_.end() ? it->second : NULL; |  292   return it != texture_infos_.end() ? it->second : NULL; | 
|  293 } |  293 } | 
|  294  |  294  | 
|  295 void TextureManager::RemoveTextureInfo(GLuint texture_id) { |  295 void TextureManager::RemoveTextureInfo(GLuint client_id) { | 
|  296   TextureInfoMap::iterator it = texture_infos_.find(texture_id); |  296   TextureInfoMap::iterator it = texture_infos_.find(client_id); | 
|  297   if (it != texture_infos_.end()) { |  297   if (it != texture_infos_.end()) { | 
|  298     it->second->MarkAsDeleted(); |  298     it->second->MarkAsDeleted(); | 
|  299     texture_infos_.erase(texture_id); |  299     texture_infos_.erase(it); | 
|  300   } |  300   } | 
|  301 } |  301 } | 
|  302  |  302  | 
 |  303 bool TextureManager::GetClientId(GLuint service_id, GLuint* client_id) const { | 
 |  304   // This doesn't need to be fast. It's only used during slow queries. | 
 |  305   for (TextureInfoMap::const_iterator it = texture_infos_.begin(); | 
 |  306        it != texture_infos_.end(); ++it) { | 
 |  307     if (it->second->service_id() == service_id) { | 
 |  308       *client_id = it->first; | 
 |  309       return true; | 
 |  310     } | 
 |  311   } | 
 |  312   return false; | 
 |  313 } | 
 |  314  | 
|  303 }  // namespace gles2 |  315 }  // namespace gles2 | 
|  304 }  // namespace gpu |  316 }  // namespace gpu | 
|  305  |  317  | 
|  306  |  318  | 
| OLD | NEW |