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

Unified Diff: sky/compositor/resource_manager.cc

Issue 868263002: Sky shouldn't crash on device rotate (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') | sky/compositor/texture_cache.h » ('j') | 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 0169380c982a061ffc193ecc5cfb466d140ff76b..9a5eecd249f340e539058f0c3fb59b0b8f39665b 100644
--- a/sky/compositor/resource_manager.cc
+++ b/sky/compositor/resource_manager.cc
@@ -31,16 +31,9 @@ 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();
- }
-
+ scoped_ptr<mojo::GLTexture> texture = texture_cache_.GetTexture(size);
+ if (texture)
+ return texture.Pass();
gl_context_->MakeCurrent();
return make_scoped_ptr(new mojo::GLTexture(
gl_context_, mojo::TypeConverter<mojo::Size, gfx::Size>::Convert(size)));
@@ -89,11 +82,11 @@ void ResourceManager::ReturnResources(
auto iter = resource_to_texture_map_.find(resource->id);
if (iter == resource_to_texture_map_.end())
continue;
- mojo::GLTexture* texture = iter->second;
+ scoped_ptr<mojo::GLTexture> texture(iter->second);
DCHECK_NE(0u, texture->texture_id());
resource_to_texture_map_.erase(iter);
glWaitSyncPointCHROMIUM(resource->sync_point);
- available_textures_.push_back(texture);
+ texture_cache_.PutTexture(texture.Pass());
}
}
« no previous file with comments | « sky/compositor/resource_manager.h ('k') | sky/compositor/texture_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698