Handle account removal correctly on all platforms.
[chromium-blink-merge.git] / gpu / command_buffer / service / image_manager.cc
blob46438c7058a6efc48a8ab119c18530ed02f06359
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
3 // found in the LICENSE file.
5 #include "gpu/command_buffer/service/image_manager.h"
7 #include "base/logging.h"
8 #include "ui/gl/gl_image.h"
10 namespace gpu {
11 namespace gles2 {
13 ImageManager::ImageManager() {
16 ImageManager::~ImageManager() {
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();
26 void ImageManager::AddImage(gfx::GLImage* image, int32 service_id) {
27 DCHECK(images_.find(service_id) == images_.end());
28 images_[service_id] = image;
31 void ImageManager::RemoveImage(int32 service_id) {
32 GLImageMap::iterator iter = images_.find(service_id);
33 DCHECK(iter != images_.end());
34 iter->second.get()->Destroy(true);
35 images_.erase(iter);
38 gfx::GLImage* ImageManager::LookupImage(int32 service_id) {
39 GLImageMap::const_iterator iter = images_.find(service_id);
40 if (iter != images_.end())
41 return iter->second.get();
43 return NULL;
46 } // namespace gles2
47 } // namespace gpu