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

Unified Diff: sky/compositor/resource_manager.cc

Issue 761503004: Fix several leaks in the Sky compositor (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Fix typo Created 6 years, 1 month 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/layer_host.cc ('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 5fee461b75e37324385baee94f0fe2a8ae6fb7cc..38c7cca342f3174e0bf813b4ae632ca2196f859e 100644
--- a/sky/compositor/resource_manager.cc
+++ b/sky/compositor/resource_manager.cc
@@ -9,6 +9,7 @@
#endif
#include "base/logging.h"
+#include "base/stl_util.h"
#include "gpu/GLES2/gl2chromium.h"
#include "gpu/GLES2/gl2extchromium.h"
#include "mojo/converters/geometry/geometry_type_converters.h"
@@ -24,6 +25,8 @@ ResourceManager::ResourceManager(base::WeakPtr<mojo::GLContext> gl_context)
}
ResourceManager::~ResourceManager() {
+ STLDeleteContainerPairSecondPointers(resource_to_texture_map_.begin(),
+ resource_to_texture_map_.end());
ojan 2014/11/25 19:27:47 git cl format plz
}
scoped_ptr<mojo::GLTexture> ResourceManager::CreateTexture(
@@ -73,11 +76,14 @@ void ResourceManager::ReturnResources(
for (size_t i = 0u; i < resources.size(); ++i) {
mojo::ReturnedResourcePtr resource = resources[i].Pass();
DCHECK_EQ(1, resource->count);
- glWaitSyncPointCHROMIUM(resource->sync_point);
- mojo::GLTexture* texture = resource_to_texture_map_[resource->id];
+ auto iter = resource_to_texture_map_.find(resource->id);
+ if (iter == resource_to_texture_map_.end())
+ continue;
+ mojo::GLTexture* texture = iter->second;
DCHECK_NE(0u, texture->texture_id());
- resource_to_texture_map_.erase(resource->id);
+ resource_to_texture_map_.erase(iter);
// TODO(abarth): Consider recycling the texture.
+ glWaitSyncPointCHROMIUM(resource->sync_point);
delete texture;
}
}
« no previous file with comments | « sky/compositor/layer_host.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698