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

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: build issues addressed. Created 6 years, 4 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) {
27 // 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.
28 DCHECK(images_.find(service_id) == images_.end());
19 images_[service_id] = image; 29 images_[service_id] = image;
20 } 30 }
21 31
22 void ImageManager::RemoveImage(int32 service_id) { 32 void ImageManager::RemoveImage(int32 service_id) {
23 images_.erase(service_id); 33 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.
34 LOG(ERROR) << "Cannot remove image with non-positive ID.";
35 return;
36 }
37 GLImageMap::iterator iter = images_.find(service_id);
38 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.
39 LOG(ERROR) << "Invalid ID.";
40 return;
41 }
42 iter->second.get()->Destroy(true);
43 images_.erase(iter);
24 } 44 }
25 45
26 gfx::GLImage* ImageManager::LookupImage(int32 service_id) { 46 gfx::GLImage* ImageManager::LookupImage(int32 service_id) {
27 GLImageMap::const_iterator iter = images_.find(service_id); 47 GLImageMap::const_iterator iter = images_.find(service_id);
28 if (iter != images_.end()) 48 if (iter != images_.end())
29 return iter->second.get(); 49 return iter->second.get();
30 50
31 return NULL; 51 return NULL;
32 } 52 }
33 53
34 } // namespace gles2 54 } // namespace gles2
35 } // namespace gpu 55 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698