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 #include "common/mathutil.h" 15 16 #include "angle_gl.h" 17 18 #include <map> 19 20 namespace rx 21 { 22 23 class IndexRangeCache 24 { 25 public: 26 void addRange(GLenum type, unsigned int offset, GLsizei count, const RangeUI &range, 27 unsigned int streamOffset); 28 bool findRange(GLenum type, unsigned int offset, GLsizei count, RangeUI *rangeOut, 29 unsigned int *outStreamOffset) const; 30 31 void invalidateRange(unsigned int offset, unsigned int size); 32 void clear(); 33 34 static RangeUI ComputeRange(GLenum type, const GLvoid *indices, GLsizei count); 35 36 private: 37 struct IndexRange 38 { 39 GLenum type; 40 unsigned int offset; 41 GLsizei count; 42 43 IndexRange(); 44 IndexRange(GLenum type, intptr_t offset, GLsizei count); 45 46 bool operator<(const IndexRange& rhs) const; 47 }; 48 49 struct IndexBounds 50 { 51 RangeUI range; 52 unsigned int streamOffset; 53 54 IndexBounds(); 55 IndexBounds(const RangeUI &range, unsigned int offset); 56 }; 57 58 typedef std::map<IndexRange, IndexBounds> IndexRangeMap; 59 IndexRangeMap mIndexRangeCache; 60 }; 61 62 } 63 64 #endif // LIBGLESV2_RENDERER_INDEXRANGECACHE_H 65