Index: gpu/command_buffer/service/image_manager.cc |
diff --git a/gpu/command_buffer/service/image_manager.cc b/gpu/command_buffer/service/image_manager.cc |
index 953e3bcb5731b3b98bfaeef8d6b7bae11c96d376..46438c7058a6efc48a8ab119c18530ed02f06359 100644 |
--- a/gpu/command_buffer/service/image_manager.cc |
+++ b/gpu/command_buffer/service/image_manager.cc |
@@ -4,6 +4,7 @@ |
#include "gpu/command_buffer/service/image_manager.h" |
+#include "base/logging.h" |
#include "ui/gl/gl_image.h" |
namespace gpu { |
@@ -15,12 +16,23 @@ ImageManager::ImageManager() { |
ImageManager::~ImageManager() { |
} |
+void ImageManager::Destroy(bool have_context) { |
+ for (GLImageMap::const_iterator iter = images_.begin(); iter != images_.end(); |
+ ++iter) |
+ iter->second.get()->Destroy(have_context); |
+ images_.clear(); |
+} |
+ |
void ImageManager::AddImage(gfx::GLImage* image, int32 service_id) { |
+ DCHECK(images_.find(service_id) == images_.end()); |
images_[service_id] = image; |
} |
void ImageManager::RemoveImage(int32 service_id) { |
- images_.erase(service_id); |
+ GLImageMap::iterator iter = images_.find(service_id); |
+ DCHECK(iter != images_.end()); |
+ iter->second.get()->Destroy(true); |
+ images_.erase(iter); |
} |
gfx::GLImage* ImageManager::LookupImage(int32 service_id) { |