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

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: build issues 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..52637dd271b1e19fb477f37a3d286ce2b165b7f2 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,31 @@ 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) {
+ // Ensure the service_id is not already in use.
reveman 2014/07/25 19:00:23 no need for this comment.
sohanjg 2014/07/26 10:42:23 Done.
+ DCHECK(images_.find(service_id) == images_.end());
images_[service_id] = image;
}
void ImageManager::RemoveImage(int32 service_id) {
- images_.erase(service_id);
+ if (service_id <= 0) {
reveman 2014/07/25 19:00:23 this check should not be here.
sohanjg 2014/07/26 10:42:23 Done.
+ LOG(ERROR) << "Cannot remove image with non-positive ID.";
+ return;
+ }
+ GLImageMap::iterator iter = images_.find(service_id);
+ if (iter == images_.end()) {
reveman 2014/07/25 19:00:23 replace this with DCHECK(iter != images_.end());
sohanjg 2014/07/26 10:42:23 Done.
+ 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