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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gpu/command_buffer/service/image_manager.h" 5 #include "gpu/command_buffer/service/image_manager.h"
6 6
7 #include "base/logging.h"
7 #include "ui/gl/gl_image.h" 8 #include "ui/gl/gl_image.h"
8 9
9 namespace gpu { 10 namespace gpu {
10 namespace gles2 { 11 namespace gles2 {
11 12
12 ImageManager::ImageManager() { 13 ImageManager::ImageManager() {
13 } 14 }
14 15
15 ImageManager::~ImageManager() { 16 ImageManager::~ImageManager() {
16 } 17 }
17 18
19 void ImageManager::Destroy(bool have_context) {
20 for (GLImageMap::const_iterator iter = images_.begin(); iter != images_.end();
21 ++iter)
22 iter->second.get()->Destroy(have_context);
23 images_.clear();
24 }
25
18 void ImageManager::AddImage(gfx::GLImage* image, int32 service_id) { 26 void ImageManager::AddImage(gfx::GLImage* image, int32 service_id) {
19 images_[service_id] = image; 27 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.
20 } 28 }
21 29
22 void ImageManager::RemoveImage(int32 service_id) { 30 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.
23 images_.erase(service_id); 31 if (service_id <= 0) {
32 LOG(ERROR) << "Cannot remove image with non-positive ID.";
33 return;
34 }
35 GLImageMap::iterator iter = images_.find(service_id);
36 if (iter == images_.end()) {
37 LOG(ERROR) << "Invalid ID.";
38 return;
39 }
40 iter->second.get()->Destroy(true);
41 images_.erase(iter);
24 } 42 }
25 43
26 gfx::GLImage* ImageManager::LookupImage(int32 service_id) { 44 gfx::GLImage* ImageManager::LookupImage(int32 service_id) {
27 GLImageMap::const_iterator iter = images_.find(service_id); 45 GLImageMap::const_iterator iter = images_.find(service_id);
28 if (iter != images_.end()) 46 if (iter != images_.end())
29 return iter->second.get(); 47 return iter->second.get();
30 48
31 return NULL; 49 return NULL;
32 } 50 }
33 51
34 } // namespace gles2 52 } // namespace gles2
35 } // namespace gpu 53 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698