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

Unified Diff: gpu/command_buffer/service/image_manager.cc

Issue 301793003: During image destroy, delete textures only if we have a GL context. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments addressed. Created 6 years, 5 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
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..efc7a6b243701f20ca94ad42a1c9e31b78cd1abe 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,29 @@ 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) {
images_[service_id] = image;
reveman 2014/07/24 16:22:03 This could drop a GLImage reference without callin
sohanjg 2014/07/25 10:54:21 Done.
}
void ImageManager::RemoveImage(int32 service_id) {
reveman 2014/07/24 16:22:03 In light of the my comment below, this function sh
sohanjg 2014/07/25 10:54:21 Done.
- images_.erase(service_id);
+ if (service_id <= 0) {
+ LOG(ERROR) << "Cannot remove image with non-positive ID.";
+ return;
+ }
+ GLImageMap::iterator iter = images_.find(service_id);
+ if (iter == images_.end()) {
+ LOG(ERROR) << "Invalid ID.";
+ return;
+ }
+ iter->second.get()->Destroy(true);
+ images_.erase(iter);
}
gfx::GLImage* ImageManager::LookupImage(int32 service_id) {

Powered by Google App Engine
This is Rietveld 408576698