summaryrefslogtreecommitdiffstats
path: root/gpu/command_buffer/service/image_manager.cc
blob: 7c7c6e6f6a9796ca925f4f4bafca52122cd62fe8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "gpu/command_buffer/service/image_manager.h"

#include <stdint.h>

#include "base/logging.h"
#include "ui/gl/gl_image.h"

namespace gpu {
namespace gles2 {

ImageManager::ImageManager() {
}

ImageManager::~ImageManager() {
}

void ImageManager::Destroy(bool have_context) {
  for (GLImageMap::const_iterator iter = images_.begin(); iter != images_.end();
       ++iter)
    iter->second.get()->Destroy(have_context);
  images_.clear();
}

void ImageManager::AddImage(gl::GLImage* image, int32_t service_id) {
  DCHECK(images_.find(service_id) == images_.end());
  images_[service_id] = image;
}

void ImageManager::RemoveImage(int32_t service_id) {
  GLImageMap::iterator iter = images_.find(service_id);
  DCHECK(iter != images_.end());
  iter->second.get()->Destroy(true);
  images_.erase(iter);
}

gl::GLImage* ImageManager::LookupImage(int32_t service_id) {
  GLImageMap::const_iterator iter = images_.find(service_id);
  if (iter != images_.end())
    return iter->second.get();

  return NULL;
}

}  // namespace gles2
}  // namespace gpu