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

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: prevent crash when accessing destroyed glimage while doing bind/releaseTexImage. 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 "ui/gl/gl_image.h" 7 #include "ui/gl/gl_image.h"
8 8
9 namespace gpu { 9 namespace gpu {
10 namespace gles2 { 10 namespace gles2 {
11 11
12 ImageManager::ImageManager() { 12 ImageManager::ImageManager() {
13 } 13 }
14 14
15 ImageManager::~ImageManager() { 15 ImageManager::~ImageManager() {
16 } 16 }
17 17
18 void ImageManager::Destroy(bool have_context) {
19 for (GLImageMap::const_iterator iter = images_.begin(); iter != images_.end();
20 ++iter)
21 iter->second.get()->Destroy(have_context);
22 images_.clear();
23 }
24
18 void ImageManager::AddImage(gfx::GLImage* image, int32 service_id) { 25 void ImageManager::AddImage(gfx::GLImage* image, int32 service_id) {
19 images_[service_id] = image; 26 images_[service_id] = image;
20 } 27 }
21 28
22 void ImageManager::RemoveImage(int32 service_id) { 29 void ImageManager::RemoveImage(int32 service_id) {
30 LookupImage(service_id)->Destroy(true);
sohanjg 2014/07/24 13:24:10 Will it be safe to assume we have context while de
reveman 2014/07/24 13:51:55 It's safe to assume that you have a context here.
sohanjg 2014/07/24 15:26:59 Done.
23 images_.erase(service_id); 31 images_.erase(service_id);
24 } 32 }
25 33
26 gfx::GLImage* ImageManager::LookupImage(int32 service_id) { 34 gfx::GLImage* ImageManager::LookupImage(int32 service_id) {
27 GLImageMap::const_iterator iter = images_.find(service_id); 35 GLImageMap::const_iterator iter = images_.find(service_id);
28 if (iter != images_.end()) 36 if (iter != images_.end())
29 return iter->second.get(); 37 return iter->second.get();
30 38
31 return NULL; 39 return NULL;
32 } 40 }
33 41
34 } // namespace gles2 42 } // namespace gles2
35 } // namespace gpu 43 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/image_manager.h ('k') | gpu/command_buffer/service/stream_texture_manager_in_process_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698