Home | History | Annotate | Download | only in renderer
      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 <map>
     15 
     16 namespace rx
     17 {
     18 
     19 class IndexRangeCache
     20 {
     21   public:
     22     void addRange(GLenum type, unsigned int offset, GLsizei count, unsigned int minIdx, unsigned int maxIdx,
     23                   unsigned int streamOffset);
     24     bool findRange(GLenum type, unsigned int offset, GLsizei count, unsigned int *outMinIndex,
     25                    unsigned int *outMaxIndex, unsigned int *outStreamOffset) const;
     26 
     27     void invalidateRange(unsigned int offset, unsigned int size);
     28     void clear();
     29 
     30   private:
     31     struct IndexRange
     32     {
     33         GLenum type;
     34         unsigned int offset;
     35         GLsizei count;
     36 
     37         IndexRange();
     38         IndexRange(GLenum type, intptr_t offset, GLsizei count);
     39 
     40         bool operator<(const IndexRange& rhs) const;
     41     };
     42 
     43     struct IndexBounds
     44     {
     45         unsigned int minIndex;
     46         unsigned int maxIndex;
     47         unsigned int streamOffset;
     48 
     49         IndexBounds();
     50         IndexBounds(unsigned int minIdx, unsigned int maxIdx, unsigned int offset);
     51     };
     52 
     53     typedef std::map<IndexRange, IndexBounds> IndexRangeMap;
     54     IndexRangeMap mIndexRangeCache;
     55 };
     56 
     57 }
     58 
     59 #endif LIBGLESV2_RENDERER_INDEXRANGECACHE_H
     60