summaryrefslogtreecommitdiffstats
path: root/cc/test/ordered_texture_map.h
blob: 2aa311184a3a7c96c7f6b2ff4c455d392238b24d (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
// Copyright 2013 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.

#ifndef CC_TEST_ORDERED_TEXTURE_MAP_H_
#define CC_TEST_ORDERED_TEXTURE_MAP_H_

#include <vector>

#include "base/containers/hash_tables.h"
#include "base/memory/ref_counted.h"
#include "third_party/khronos/GLES2/gl2.h"

namespace cc {

struct TestTexture;

class OrderedTextureMap {
 public:
  OrderedTextureMap();
  ~OrderedTextureMap();

  void Append(GLuint id, scoped_refptr<TestTexture> texture);
  void Replace(GLuint id, scoped_refptr<TestTexture> texture);
  void Remove(GLuint id);

  size_t Size();

  bool ContainsId(GLuint id);

  scoped_refptr<TestTexture> TextureForId(GLuint id);
  GLuint IdAt(size_t index);

 private:
  typedef base::hash_map<GLuint, scoped_refptr<TestTexture>> TextureMap;
  typedef std::vector<GLuint> TextureList;

  TextureMap textures_;
  TextureList ordered_textures_;
};

}  // namespace cc

#endif  // CC_TEST_ORDERED_TEXTURE_MAP_H_