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

Unified Diff: sky/compositor/resource_manager.cc

Issue 845963006: The Sky compositor should recycle textures (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/compositor/resource_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
}
« no previous file with comments | « sky/compositor/resource_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698