Chromium Code Reviews| Index: sky/compositor/resource_manager.cc |
| diff --git a/sky/compositor/resource_manager.cc b/sky/compositor/resource_manager.cc |
| index fe6dc0ec8c1597697cc4baeed4f2b160622e5326..1bbdd081f221a9003947d8b7df304271b47a8acf 100644 |
| --- a/sky/compositor/resource_manager.cc |
| +++ b/sky/compositor/resource_manager.cc |
| @@ -31,6 +31,16 @@ ResourceManager::~ResourceManager() { |
| scoped_ptr<mojo::GLTexture> ResourceManager::CreateTexture( |
| const gfx::Size& size) { |
| + if (!available_textures_.empty()) { |
| + scoped_ptr<mojo::GLTexture> texture(available_textures_.back()); |
| + available_textures_.back() = nullptr; |
| + available_textures_.pop_back(); |
| + if (texture->size() == size) |
| + return texture.Pass(); |
| + // Currently we only support caching textures of a constant size. |
| + available_textures_.clear(); |
| + } |
| + |
| gl_context_->MakeCurrent(); |
| return make_scoped_ptr(new mojo::GLTexture( |
| gl_context_, mojo::TypeConverter<mojo::Size, gfx::Size>::Convert(size))); |
| @@ -84,7 +94,7 @@ void ResourceManager::ReturnResources( |
| resource_to_texture_map_.erase(iter); |
| // TODO(abarth): Consider recycling the texture. |
|
jamesr
2015/01/15 18:51:50
this can go away now
|
| glWaitSyncPointCHROMIUM(resource->sync_point); |
| - delete texture; |
| + available_textures_.push_back(texture); |
| } |
| } |