OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "GrGLGpu.h" | 8 #include "GrGLGpu.h" |
9 | 9 |
10 #include "builders/GrGLProgramBuilder.h" | 10 #include "builders/GrGLProgramBuilder.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 SkDELETE(fEntries[i]); | 83 SkDELETE(fEntries[i]); |
84 } | 84 } |
85 fCount = 0; | 85 fCount = 0; |
86 } | 86 } |
87 | 87 |
88 int GrGLGpu::ProgramCache::search(const GrProgramDesc& desc) const { | 88 int GrGLGpu::ProgramCache::search(const GrProgramDesc& desc) const { |
89 ProgDescLess less; | 89 ProgDescLess less; |
90 return SkTSearch(fEntries, fCount, desc, sizeof(Entry*), less); | 90 return SkTSearch(fEntries, fCount, desc, sizeof(Entry*), less); |
91 } | 91 } |
92 | 92 |
93 GrGLProgram* GrGLGpu::ProgramCache::getProgram(const DrawArgs& args) { | 93 GrGLProgram* GrGLGpu::ProgramCache::refProgram(const DrawArgs& args) { |
94 #ifdef PROGRAM_CACHE_STATS | 94 #ifdef PROGRAM_CACHE_STATS |
95 ++fTotalRequests; | 95 ++fTotalRequests; |
96 #endif | 96 #endif |
97 | 97 |
98 Entry* entry = NULL; | 98 Entry* entry = NULL; |
99 | 99 |
100 uint32_t hashIdx = args.fDesc->getChecksum(); | 100 uint32_t hashIdx = args.fDesc->getChecksum(); |
101 hashIdx ^= hashIdx >> 16; | 101 hashIdx ^= hashIdx >> 16; |
102 if (kHashBits <= 8) { | 102 if (kHashBits <= 8) { |
103 hashIdx ^= hashIdx >> 8; | 103 hashIdx ^= hashIdx >> 8; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 fHashTable[hashIdx] = entry; | 186 fHashTable[hashIdx] = entry; |
187 entry->fLRUStamp = fCurrLRUStamp; | 187 entry->fLRUStamp = fCurrLRUStamp; |
188 | 188 |
189 if (SK_MaxU32 == fCurrLRUStamp) { | 189 if (SK_MaxU32 == fCurrLRUStamp) { |
190 // wrap around! just trash our LRU, one time hit. | 190 // wrap around! just trash our LRU, one time hit. |
191 for (int i = 0; i < fCount; ++i) { | 191 for (int i = 0; i < fCount; ++i) { |
192 fEntries[i]->fLRUStamp = 0; | 192 fEntries[i]->fLRUStamp = 0; |
193 } | 193 } |
194 } | 194 } |
195 ++fCurrLRUStamp; | 195 ++fCurrLRUStamp; |
196 return entry->fProgram; | 196 return SkRef(entry->fProgram.get()); |
197 } | 197 } |
OLD | NEW |