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 "GrGpuGL.h" | 8 #include "GrGpuGL.h" |
9 | 9 |
10 #include "GrEffect.h" | 10 #include "GrEffect.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 SkASSERT(NULL != entry->fProgram.get()); | 28 SkASSERT(NULL != entry->fProgram.get()); |
29 return GrGLProgramDesc::Less(desc, entry->fProgram->getDesc()); | 29 return GrGLProgramDesc::Less(desc, entry->fProgram->getDesc()); |
30 } | 30 } |
31 | 31 |
32 bool operator() (const Entry* entry, const GrGLProgramDesc& desc) { | 32 bool operator() (const Entry* entry, const GrGLProgramDesc& desc) { |
33 SkASSERT(NULL != entry->fProgram.get()); | 33 SkASSERT(NULL != entry->fProgram.get()); |
34 return GrGLProgramDesc::Less(entry->fProgram->getDesc(), desc); | 34 return GrGLProgramDesc::Less(entry->fProgram->getDesc(), desc); |
35 } | 35 } |
36 }; | 36 }; |
37 | 37 |
38 GrGpuGL::ProgramCache::ProgramCache(const GrGLContext& gl) | 38 GrGpuGL::ProgramCache::ProgramCache(GrGpuGL* gpu) |
39 : fCount(0) | 39 : fCount(0) |
40 , fCurrLRUStamp(0) | 40 , fCurrLRUStamp(0) |
41 , fGL(gl) | 41 , fGpu(gpu) |
42 #ifdef PROGRAM_CACHE_STATS | 42 #ifdef PROGRAM_CACHE_STATS |
43 , fTotalRequests(0) | 43 , fTotalRequests(0) |
44 , fCacheMisses(0) | 44 , fCacheMisses(0) |
45 , fHashMisses(0) | 45 , fHashMisses(0) |
46 #endif | 46 #endif |
47 { | 47 { |
48 for (int i = 0; i < 1 << kHashBits; ++i) { | 48 for (int i = 0; i < 1 << kHashBits; ++i) { |
49 fHashTable[i] = NULL; | 49 fHashTable[i] = NULL; |
50 } | 50 } |
51 } | 51 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 ++fHashMisses; | 112 ++fHashMisses; |
113 #endif | 113 #endif |
114 } | 114 } |
115 } | 115 } |
116 | 116 |
117 if (NULL == entry) { | 117 if (NULL == entry) { |
118 // We have a cache miss | 118 // We have a cache miss |
119 #ifdef PROGRAM_CACHE_STATS | 119 #ifdef PROGRAM_CACHE_STATS |
120 ++fCacheMisses; | 120 ++fCacheMisses; |
121 #endif | 121 #endif |
122 GrGLProgram* program = GrGLProgram::Create(fGL, desc, colorStages, cover
ageStages); | 122 GrGLProgram* program = GrGLProgram::Create(fGpu, desc, colorStages, cove
rageStages); |
123 if (NULL == program) { | 123 if (NULL == program) { |
124 return NULL; | 124 return NULL; |
125 } | 125 } |
126 int purgeIdx = 0; | 126 int purgeIdx = 0; |
127 if (fCount < kMaxEntries) { | 127 if (fCount < kMaxEntries) { |
128 entry = SkNEW(Entry); | 128 entry = SkNEW(Entry); |
129 purgeIdx = fCount++; | 129 purgeIdx = fCount++; |
130 fEntries[purgeIdx] = entry; | 130 fEntries[purgeIdx] = entry; |
131 } else { | 131 } else { |
132 SkASSERT(fCount == kMaxEntries); | 132 SkASSERT(fCount == kMaxEntries); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 | 298 |
299 GrGLuint programID = fCurrentProgram->programID(); | 299 GrGLuint programID = fCurrentProgram->programID(); |
300 if (fHWProgramID != programID) { | 300 if (fHWProgramID != programID) { |
301 GL_CALL(UseProgram(programID)); | 301 GL_CALL(UseProgram(programID)); |
302 fHWProgramID = programID; | 302 fHWProgramID = programID; |
303 } | 303 } |
304 | 304 |
305 fCurrentProgram->overrideBlend(&srcCoeff, &dstCoeff); | 305 fCurrentProgram->overrideBlend(&srcCoeff, &dstCoeff); |
306 this->flushBlend(kDrawLines_DrawType == type, srcCoeff, dstCoeff); | 306 this->flushBlend(kDrawLines_DrawType == type, srcCoeff, dstCoeff); |
307 | 307 |
308 fCurrentProgram->setData(this, | 308 fCurrentProgram->setData(blendOpts, |
309 blendOpts, | |
310 colorStages.begin(), | 309 colorStages.begin(), |
311 coverageStages.begin(), | 310 coverageStages.begin(), |
312 dstCopy, | 311 dstCopy, |
313 &fSharedGLProgramState); | 312 &fSharedGLProgramState); |
314 } | 313 } |
315 this->flushStencil(type); | 314 this->flushStencil(type); |
316 this->flushScissor(); | 315 this->flushScissor(); |
317 this->flushAAState(type); | 316 this->flushAAState(type); |
318 | 317 |
319 SkIRect* devRect = NULL; | 318 SkIRect* devRect = NULL; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 GrGLAttribTypeToLayout(attribType).fCount, | 397 GrGLAttribTypeToLayout(attribType).fCount, |
399 GrGLAttribTypeToLayout(attribType).fType, | 398 GrGLAttribTypeToLayout(attribType).fType, |
400 GrGLAttribTypeToLayout(attribType).fNormalized, | 399 GrGLAttribTypeToLayout(attribType).fNormalized, |
401 stride, | 400 stride, |
402 reinterpret_cast<GrGLvoid*>( | 401 reinterpret_cast<GrGLvoid*>( |
403 vertexOffsetInBytes + vertexAttrib->fOffset)); | 402 vertexOffsetInBytes + vertexAttrib->fOffset)); |
404 } | 403 } |
405 | 404 |
406 attribState->disableUnusedAttribArrays(this, usedAttribArraysMask); | 405 attribState->disableUnusedAttribArrays(this, usedAttribArraysMask); |
407 } | 406 } |
OLD | NEW |