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"
13 ImageManager::ImageManager() {
16 ImageManager::~ImageManager() {
19 void ImageManager::Destroy(bool have_context
) {
20 for (GLImageMap::const_iterator iter
= images_
.begin(); iter
!= images_
.end();
22 iter
->second
.get()->Destroy(have_context
);
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);
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();