Upstream version 5.34.92.0
[platform/framework/web/crosswalk.git] / src / third_party / angle / src / libGLESv2 / renderer / IndexRangeCache.h
1 //
2 // Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6
7 // IndexRangeCache.h: Defines the rx::IndexRangeCache class which stores information about
8 // ranges of indices.
9
10 #ifndef LIBGLESV2_RENDERER_INDEXRANGECACHE_H_
11 #define LIBGLESV2_RENDERER_INDEXRANGECACHE_H_
12
13 #include "common/angleutils.h"
14
15 namespace rx
16 {
17
18 class IndexRangeCache
19 {
20   public:
21     void addRange(GLenum type, unsigned int offset, GLsizei count, unsigned int minIdx, unsigned int maxIdx,
22                   unsigned int streamOffset);
23     bool findRange(GLenum type, unsigned int offset, GLsizei count, unsigned int *outMinIndex,
24                    unsigned int *outMaxIndex, unsigned int *outStreamOffset) const;
25
26     void invalidateRange(unsigned int offset, unsigned int size);
27     void clear();
28
29   private:
30     struct IndexRange
31     {
32         GLenum type;
33         unsigned int offset;
34         GLsizei count;
35
36         IndexRange();
37         IndexRange(GLenum type, intptr_t offset, GLsizei count);
38
39         bool operator<(const IndexRange& rhs) const;
40     };
41
42     struct IndexBounds
43     {
44         unsigned int minIndex;
45         unsigned int maxIndex;
46         unsigned int streamOffset;
47
48         IndexBounds();
49         IndexBounds(unsigned int minIdx, unsigned int maxIdx, unsigned int offset);
50     };
51
52     typedef std::map<IndexRange, IndexBounds> IndexRangeMap;
53     IndexRangeMap mIndexRangeCache;
54 };
55
56 }
57
58 #endif LIBGLESV2_RENDERER_INDEXRANGECACHE_H