Index: src/gpu/gl/GrGpuGL.h |
diff --git a/src/gpu/gl/GrGpuGL.h b/src/gpu/gl/GrGpuGL.h |
index 0f75280178a4b6b9a4eb77705e70775f25329908..8f80a72cbcba3dc2f2f16dd113ec7ff112232283 100644 |
--- a/src/gpu/gl/GrGpuGL.h |
+++ b/src/gpu/gl/GrGpuGL.h |
@@ -177,47 +177,36 @@ private: |
void abandon(); |
GrGLProgram* getProgram(const GrGLProgramDesc& desc, const GrEffectStage* stages[]); |
+ |
private: |
enum { |
- kKeySize = sizeof(GrGLProgramDesc), |
// We may actually have kMaxEntries+1 shaders in the GL context because we create a new |
// shader before evicting from the cache. |
- kMaxEntries = 32 |
+ kMaxEntries = 32, |
+ kHashBits = 6, |
}; |
- class Entry; |
- // The value of the hash key is based on the ProgramDesc. |
- typedef GrTBinHashKey<Entry, kKeySize> ProgramHashKey; |
- |
- class Entry : public ::GrNoncopyable { |
- public: |
- Entry() : fProgram(NULL), fLRUStamp(0) {} |
- Entry& operator = (const Entry& entry) { |
- GrSafeRef(entry.fProgram.get()); |
- fProgram.reset(entry.fProgram.get()); |
- fKey = entry.fKey; |
- fLRUStamp = entry.fLRUStamp; |
- return *this; |
- } |
- int compare(const ProgramHashKey& key) const { |
- return fKey.compare(key); |
- } |
+ struct Entry; |
- public: |
- SkAutoTUnref<GrGLProgram> fProgram; |
- ProgramHashKey fKey; |
- unsigned int fLRUStamp; // Move outside entry? |
- }; |
+ struct ProgDescLess; |
+ |
+ // binary search for entry matching desc. returns index into fEntries that matches desc or ~ |
+ // of the index of where it should be inserted. |
+ int search(const GrGLProgramDesc& desc) const; |
- GrTHashTable<Entry, ProgramHashKey, 8> fHashCache; |
+ // sorted array of all the entries |
+ Entry* fEntries[kMaxEntries]; |
+ // hash table based on lowest kHashBits bits of the program key. Used to avoid binary |
+ // searching fEntries. |
+ Entry* fHashTable[1 << kHashBits]; |
- Entry fEntries[kMaxEntries]; |
int fCount; |
unsigned int fCurrLRUStamp; |
const GrGLContext& fGL; |
#ifdef PROGRAM_CACHE_STATS |
int fTotalRequests; |
int fCacheMisses; |
+ int fHashMisses; // cache hit but hash table missed |
#endif |
}; |