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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 } | 83 } |
84 fCount = 0; | 84 fCount = 0; |
85 } | 85 } |
86 | 86 |
87 int GrGpuGL::ProgramCache::search(const GrGLProgramDesc& desc) const { | 87 int GrGpuGL::ProgramCache::search(const GrGLProgramDesc& desc) const { |
88 ProgDescLess less; | 88 ProgDescLess less; |
89 return SkTSearch(fEntries, fCount, desc, sizeof(Entry*), less); | 89 return SkTSearch(fEntries, fCount, desc, sizeof(Entry*), less); |
90 } | 90 } |
91 | 91 |
92 GrGLProgram* GrGpuGL::ProgramCache::getProgram(const GrGLProgramDesc& desc, | 92 GrGLProgram* GrGpuGL::ProgramCache::getProgram(const GrGLProgramDesc& desc, |
| 93 const GrEffectStage* geometryProc
essor, |
93 const GrEffectStage* colorStages[
], | 94 const GrEffectStage* colorStages[
], |
94 const GrEffectStage* coverageStag
es[]) { | 95 const GrEffectStage* coverageStag
es[]) { |
95 #ifdef PROGRAM_CACHE_STATS | 96 #ifdef PROGRAM_CACHE_STATS |
96 ++fTotalRequests; | 97 ++fTotalRequests; |
97 #endif | 98 #endif |
98 | 99 |
99 Entry* entry = NULL; | 100 Entry* entry = NULL; |
100 | 101 |
101 uint32_t hashIdx = desc.getChecksum(); | 102 uint32_t hashIdx = desc.getChecksum(); |
102 hashIdx ^= hashIdx >> 16; | 103 hashIdx ^= hashIdx >> 16; |
(...skipping 16 matching lines...) Expand all Loading... |
119 ++fHashMisses; | 120 ++fHashMisses; |
120 #endif | 121 #endif |
121 } | 122 } |
122 } | 123 } |
123 | 124 |
124 if (NULL == entry) { | 125 if (NULL == entry) { |
125 // We have a cache miss | 126 // We have a cache miss |
126 #ifdef PROGRAM_CACHE_STATS | 127 #ifdef PROGRAM_CACHE_STATS |
127 ++fCacheMisses; | 128 ++fCacheMisses; |
128 #endif | 129 #endif |
129 GrGLProgram* program = GrGLProgram::Create(fGpu, desc, colorStages, cove
rageStages); | 130 GrGLProgram* program = GrGLProgram::Create(fGpu, desc, geometryProcessor
, colorStages, coverageStages); |
130 if (NULL == program) { | 131 if (NULL == program) { |
131 return NULL; | 132 return NULL; |
132 } | 133 } |
133 int purgeIdx = 0; | 134 int purgeIdx = 0; |
134 if (fCount < kMaxEntries) { | 135 if (fCount < kMaxEntries) { |
135 entry = SkNEW(Entry); | 136 entry = SkNEW(Entry); |
136 purgeIdx = fCount++; | 137 purgeIdx = fCount++; |
137 fEntries[purgeIdx] = entry; | 138 fEntries[purgeIdx] = entry; |
138 } else { | 139 } else { |
139 SkASSERT(fCount == kMaxEntries); | 140 SkASSERT(fCount == kMaxEntries); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 } else { | 216 } else { |
216 this->flushMiscFixedFunctionState(); | 217 this->flushMiscFixedFunctionState(); |
217 | 218 |
218 GrBlendCoeff srcCoeff; | 219 GrBlendCoeff srcCoeff; |
219 GrBlendCoeff dstCoeff; | 220 GrBlendCoeff dstCoeff; |
220 GrDrawState::BlendOptFlags blendOpts = drawState.getBlendOpts(false, &sr
cCoeff, &dstCoeff); | 221 GrDrawState::BlendOptFlags blendOpts = drawState.getBlendOpts(false, &sr
cCoeff, &dstCoeff); |
221 if (GrDrawState::kSkipDraw_BlendOptFlag & blendOpts) { | 222 if (GrDrawState::kSkipDraw_BlendOptFlag & blendOpts) { |
222 return false; | 223 return false; |
223 } | 224 } |
224 | 225 |
| 226 const GrEffectStage* geometryProcessor = NULL; |
225 SkSTArray<8, const GrEffectStage*, true> colorStages; | 227 SkSTArray<8, const GrEffectStage*, true> colorStages; |
226 SkSTArray<8, const GrEffectStage*, true> coverageStages; | 228 SkSTArray<8, const GrEffectStage*, true> coverageStages; |
227 GrGLProgramDesc desc; | 229 GrGLProgramDesc desc; |
228 if (!GrGLProgramDesc::Build(this->getDrawState(), | 230 if (!GrGLProgramDesc::Build(this->getDrawState(), |
229 type, | 231 type, |
230 blendOpts, | 232 blendOpts, |
231 srcCoeff, | 233 srcCoeff, |
232 dstCoeff, | 234 dstCoeff, |
233 this, | 235 this, |
234 dstCopy, | 236 dstCopy, |
| 237 &geometryProcessor, |
235 &colorStages, | 238 &colorStages, |
236 &coverageStages, | 239 &coverageStages, |
237 &desc)) { | 240 &desc)) { |
238 SkDEBUGFAIL("Failed to generate GL program descriptor"); | 241 SkDEBUGFAIL("Failed to generate GL program descriptor"); |
239 return false; | 242 return false; |
240 } | 243 } |
241 | 244 |
242 fCurrentProgram.reset(fProgramCache->getProgram(desc, | 245 fCurrentProgram.reset(fProgramCache->getProgram(desc, |
| 246 geometryProcessor, |
243 colorStages.begin(), | 247 colorStages.begin(), |
244 coverageStages.begin()))
; | 248 coverageStages.begin()))
; |
245 if (NULL == fCurrentProgram.get()) { | 249 if (NULL == fCurrentProgram.get()) { |
246 SkDEBUGFAIL("Failed to create program!"); | 250 SkDEBUGFAIL("Failed to create program!"); |
247 return false; | 251 return false; |
248 } | 252 } |
249 | 253 |
250 fCurrentProgram.get()->ref(); | 254 fCurrentProgram.get()->ref(); |
251 | 255 |
252 GrGLuint programID = fCurrentProgram->programID(); | 256 GrGLuint programID = fCurrentProgram->programID(); |
253 if (fHWProgramID != programID) { | 257 if (fHWProgramID != programID) { |
254 GL_CALL(UseProgram(programID)); | 258 GL_CALL(UseProgram(programID)); |
255 fHWProgramID = programID; | 259 fHWProgramID = programID; |
256 } | 260 } |
257 | 261 |
258 fCurrentProgram->overrideBlend(&srcCoeff, &dstCoeff); | 262 fCurrentProgram->overrideBlend(&srcCoeff, &dstCoeff); |
259 this->flushBlend(kDrawLines_DrawType == type, srcCoeff, dstCoeff); | 263 this->flushBlend(kDrawLines_DrawType == type, srcCoeff, dstCoeff); |
260 | 264 |
261 fCurrentProgram->setData(type, | 265 fCurrentProgram->setData(type, |
262 blendOpts, | 266 blendOpts, |
| 267 geometryProcessor, |
263 colorStages.begin(), | 268 colorStages.begin(), |
264 coverageStages.begin(), | 269 coverageStages.begin(), |
265 dstCopy, | 270 dstCopy, |
266 &fSharedGLProgramState); | 271 &fSharedGLProgramState); |
267 } | 272 } |
268 this->flushStencil(type); | 273 this->flushStencil(type); |
269 this->flushScissor(); | 274 this->flushScissor(); |
270 this->flushAAState(type); | 275 this->flushAAState(type); |
271 | 276 |
272 SkIRect* devRect = NULL; | 277 SkIRect* devRect = NULL; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 GrGLAttribTypeToLayout(attribType).fType, | 362 GrGLAttribTypeToLayout(attribType).fType, |
358 GrGLAttribTypeToLayout(attribType).fNormalized, | 363 GrGLAttribTypeToLayout(attribType).fNormalized, |
359 stride, | 364 stride, |
360 reinterpret_cast<GrGLvoid*>( | 365 reinterpret_cast<GrGLvoid*>( |
361 vertexOffsetInBytes + vertexAttrib->fOffset)); | 366 vertexOffsetInBytes + vertexAttrib->fOffset)); |
362 } | 367 } |
363 } | 368 } |
364 attribState->disableUnusedArrays(this, usedAttribArraysMask); | 369 attribState->disableUnusedArrays(this, usedAttribArraysMask); |
365 } | 370 } |
366 } | 371 } |
OLD | NEW |