| 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 "GrProcessor.h" |
| 11 #include "GrGLEffect.h" | 11 #include "GrGLProcessor.h" |
| 12 #include "GrGLPathRendering.h" | 12 #include "GrGLPathRendering.h" |
| 13 #include "GrOptDrawState.h" | 13 #include "GrOptDrawState.h" |
| 14 #include "SkRTConf.h" | 14 #include "SkRTConf.h" |
| 15 #include "SkTSearch.h" | 15 #include "SkTSearch.h" |
| 16 | 16 |
| 17 #ifdef PROGRAM_CACHE_STATS | 17 #ifdef PROGRAM_CACHE_STATS |
| 18 SK_CONF_DECLARE(bool, c_DisplayCache, "gpu.displayCache", false, | 18 SK_CONF_DECLARE(bool, c_DisplayCache, "gpu.displayCache", false, |
| 19 "Display program cache usage."); | 19 "Display program cache usage."); |
| 20 #endif | 20 #endif |
| 21 | 21 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 } | 84 } |
| 85 fCount = 0; | 85 fCount = 0; |
| 86 } | 86 } |
| 87 | 87 |
| 88 int GrGpuGL::ProgramCache::search(const GrGLProgramDesc& desc) const { | 88 int GrGpuGL::ProgramCache::search(const GrGLProgramDesc& 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* GrGpuGL::ProgramCache::getProgram(const GrGLProgramDesc& desc, | 93 GrGLProgram* GrGpuGL::ProgramCache::getProgram(const GrGLProgramDesc& desc, |
| 94 const GrEffectStage* geometryProc
essor, | 94 const GrGeometryStage* geometryPr
ocessor, |
| 95 const GrEffectStage* colorStages[
], | 95 const GrFragmentStage* colorStage
s[], |
| 96 const GrEffectStage* coverageStag
es[]) { | 96 const GrFragmentStage* coverageSt
ages[]) { |
| 97 #ifdef PROGRAM_CACHE_STATS | 97 #ifdef PROGRAM_CACHE_STATS |
| 98 ++fTotalRequests; | 98 ++fTotalRequests; |
| 99 #endif | 99 #endif |
| 100 | 100 |
| 101 Entry* entry = NULL; | 101 Entry* entry = NULL; |
| 102 | 102 |
| 103 uint32_t hashIdx = desc.getChecksum(); | 103 uint32_t hashIdx = desc.getChecksum(); |
| 104 hashIdx ^= hashIdx >> 16; | 104 hashIdx ^= hashIdx >> 16; |
| 105 if (kHashBits <= 8) { | 105 if (kHashBits <= 8) { |
| 106 hashIdx ^= hashIdx >> 8; | 106 hashIdx ^= hashIdx >> 8; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 | 220 |
| 221 GrBlendCoeff srcCoeff = optState->getSrcBlendCoeff(); | 221 GrBlendCoeff srcCoeff = optState->getSrcBlendCoeff(); |
| 222 GrBlendCoeff dstCoeff = optState->getDstBlendCoeff(); | 222 GrBlendCoeff dstCoeff = optState->getDstBlendCoeff(); |
| 223 | 223 |
| 224 // In these blend coeff's we end up drawing nothing so we can skip draw
all together | 224 // In these blend coeff's we end up drawing nothing so we can skip draw
all together |
| 225 if (kZero_GrBlendCoeff == srcCoeff && kOne_GrBlendCoeff == dstCoeff && | 225 if (kZero_GrBlendCoeff == srcCoeff && kOne_GrBlendCoeff == dstCoeff && |
| 226 !optState->getStencil().doesWrite()) { | 226 !optState->getStencil().doesWrite()) { |
| 227 return false; | 227 return false; |
| 228 } | 228 } |
| 229 | 229 |
| 230 const GrEffectStage* geometryProcessor = NULL; | 230 const GrGeometryStage* geometryProcessor = NULL; |
| 231 SkSTArray<8, const GrEffectStage*, true> colorStages; | 231 SkSTArray<8, const GrFragmentStage*, true> colorStages; |
| 232 SkSTArray<8, const GrEffectStage*, true> coverageStages; | 232 SkSTArray<8, const GrFragmentStage*, true> coverageStages; |
| 233 GrGLProgramDesc desc; | 233 GrGLProgramDesc desc; |
| 234 if (!GrGLProgramDesc::Build(*optState.get(), | 234 if (!GrGLProgramDesc::Build(*optState.get(), |
| 235 type, | 235 type, |
| 236 srcCoeff, | 236 srcCoeff, |
| 237 dstCoeff, | 237 dstCoeff, |
| 238 this, | 238 this, |
| 239 dstCopy, | 239 dstCopy, |
| 240 &geometryProcessor, | 240 &geometryProcessor, |
| 241 &colorStages, | 241 &colorStages, |
| 242 &coverageStages, | 242 &coverageStages, |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 GrGLAttribTypeToLayout(attribType).fCount, | 362 GrGLAttribTypeToLayout(attribType).fCount, |
| 363 GrGLAttribTypeToLayout(attribType).fType, | 363 GrGLAttribTypeToLayout(attribType).fType, |
| 364 GrGLAttribTypeToLayout(attribType).fNormalized, | 364 GrGLAttribTypeToLayout(attribType).fNormalized, |
| 365 stride, | 365 stride, |
| 366 reinterpret_cast<GrGLvoid*>( | 366 reinterpret_cast<GrGLvoid*>( |
| 367 vertexOffsetInBytes + vertexAttrib->fOffset)); | 367 vertexOffsetInBytes + vertexAttrib->fOffset)); |
| 368 } | 368 } |
| 369 attribState->disableUnusedArrays(this, usedAttribArraysMask); | 369 attribState->disableUnusedArrays(this, usedAttribArraysMask); |
| 370 } | 370 } |
| 371 } | 371 } |
| OLD | NEW |