Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: src/gpu/gl/GrGpuGL_program.cpp

Issue 16180006: separate arrays for color and coverage effects. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: add helper function Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/gpu/gl/GrGpuGL.h ('k') | tests/GLProgramsTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 } 77 }
78 fCount = 0; 78 fCount = 0;
79 } 79 }
80 80
81 int GrGpuGL::ProgramCache::search(const GrGLProgramDesc& desc) const { 81 int GrGpuGL::ProgramCache::search(const GrGLProgramDesc& desc) const {
82 ProgDescLess less; 82 ProgDescLess less;
83 return SkTSearch(fEntries, fCount, desc, sizeof(Entry*), less); 83 return SkTSearch(fEntries, fCount, desc, sizeof(Entry*), less);
84 } 84 }
85 85
86 GrGLProgram* GrGpuGL::ProgramCache::getProgram(const GrGLProgramDesc& desc, 86 GrGLProgram* GrGpuGL::ProgramCache::getProgram(const GrGLProgramDesc& desc,
87 const GrEffectStage* stages[]) { 87 const GrEffectStage* colorStages[ ],
88 const GrEffectStage* coverageStag es[]) {
88 #ifdef PROGRAM_CACHE_STATS 89 #ifdef PROGRAM_CACHE_STATS
89 ++fTotalRequests; 90 ++fTotalRequests;
90 #endif 91 #endif
91 92
92 Entry* entry = NULL; 93 Entry* entry = NULL;
93 94
94 uint32_t hashIdx = desc.getChecksum(); 95 uint32_t hashIdx = desc.getChecksum();
95 hashIdx ^= hashIdx >> 16; 96 hashIdx ^= hashIdx >> 16;
96 if (kHashBits <= 8) { 97 if (kHashBits <= 8) {
97 hashIdx ^= hashIdx >> 8; 98 hashIdx ^= hashIdx >> 8;
(...skipping 14 matching lines...) Expand all
112 ++fHashMisses; 113 ++fHashMisses;
113 #endif 114 #endif
114 } 115 }
115 } 116 }
116 117
117 if (NULL == entry) { 118 if (NULL == entry) {
118 // We have a cache miss 119 // We have a cache miss
119 #ifdef PROGRAM_CACHE_STATS 120 #ifdef PROGRAM_CACHE_STATS
120 ++fCacheMisses; 121 ++fCacheMisses;
121 #endif 122 #endif
122 GrGLProgram* program = GrGLProgram::Create(fGL, desc, stages); 123 GrGLProgram* program = GrGLProgram::Create(fGL, desc, colorStages, cover ageStages);
123 if (NULL == program) { 124 if (NULL == program) {
124 return NULL; 125 return NULL;
125 } 126 }
126 int purgeIdx = 0; 127 int purgeIdx = 0;
127 if (fCount < kMaxEntries) { 128 if (fCount < kMaxEntries) {
128 entry = SkNEW(Entry); 129 entry = SkNEW(Entry);
129 purgeIdx = fCount++; 130 purgeIdx = fCount++;
130 fEntries[purgeIdx] = entry; 131 fEntries[purgeIdx] = entry;
131 } else { 132 } else {
132 GrAssert(fCount == kMaxEntries); 133 GrAssert(fCount == kMaxEntries);
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 } else { 267 } else {
267 this->flushMiscFixedFunctionState(); 268 this->flushMiscFixedFunctionState();
268 269
269 GrBlendCoeff srcCoeff; 270 GrBlendCoeff srcCoeff;
270 GrBlendCoeff dstCoeff; 271 GrBlendCoeff dstCoeff;
271 GrDrawState::BlendOptFlags blendOpts = drawState.getBlendOpts(false, &sr cCoeff, &dstCoeff); 272 GrDrawState::BlendOptFlags blendOpts = drawState.getBlendOpts(false, &sr cCoeff, &dstCoeff);
272 if (GrDrawState::kSkipDraw_BlendOptFlag & blendOpts) { 273 if (GrDrawState::kSkipDraw_BlendOptFlag & blendOpts) {
273 return false; 274 return false;
274 } 275 }
275 276
276 const GrEffectStage* stages[GrDrawState::kNumStages]; 277 SkSTArray<8, const GrEffectStage*, true> colorStages;
278 SkSTArray<8, const GrEffectStage*, true> coverageStages;
277 GrGLProgramDesc desc; 279 GrGLProgramDesc desc;
278 GrGLProgramDesc::Build(this->getDrawState(), 280 GrGLProgramDesc::Build(this->getDrawState(),
279 kDrawPoints_DrawType == type, 281 kDrawPoints_DrawType == type,
280 blendOpts, 282 blendOpts,
281 srcCoeff, 283 srcCoeff,
282 dstCoeff, 284 dstCoeff,
283 this, 285 this,
284 dstCopy, 286 dstCopy,
285 stages, 287 &colorStages,
288 &coverageStages,
286 &desc); 289 &desc);
287 290
288 fCurrentProgram.reset(fProgramCache->getProgram(desc, stages)); 291 fCurrentProgram.reset(fProgramCache->getProgram(desc,
292 colorStages.begin(),
293 coverageStages.begin())) ;
289 if (NULL == fCurrentProgram.get()) { 294 if (NULL == fCurrentProgram.get()) {
290 GrAssert(!"Failed to create program!"); 295 GrAssert(!"Failed to create program!");
291 return false; 296 return false;
292 } 297 }
293 fCurrentProgram.get()->ref(); 298 fCurrentProgram.get()->ref();
294 299
295 GrGLuint programID = fCurrentProgram->programID(); 300 GrGLuint programID = fCurrentProgram->programID();
296 if (fHWProgramID != programID) { 301 if (fHWProgramID != programID) {
297 GL_CALL(UseProgram(programID)); 302 GL_CALL(UseProgram(programID));
298 fHWProgramID = programID; 303 fHWProgramID = programID;
299 } 304 }
300 305
301 fCurrentProgram->overrideBlend(&srcCoeff, &dstCoeff); 306 fCurrentProgram->overrideBlend(&srcCoeff, &dstCoeff);
302 this->flushBlend(kDrawLines_DrawType == type, srcCoeff, dstCoeff); 307 this->flushBlend(kDrawLines_DrawType == type, srcCoeff, dstCoeff);
303 308
304 fCurrentProgram->setData(this, blendOpts, stages, dstCopy, &fSharedGLPro gramState); 309 fCurrentProgram->setData(this,
310 blendOpts,
311 colorStages.begin(),
312 coverageStages.begin(),
313 dstCopy,
314 &fSharedGLProgramState);
305 } 315 }
306 this->flushStencil(type); 316 this->flushStencil(type);
307 this->flushScissor(); 317 this->flushScissor();
308 this->flushAAState(type); 318 this->flushAAState(type);
309 319
310 GrIRect* devRect = NULL; 320 GrIRect* devRect = NULL;
311 GrIRect devClipBounds; 321 GrIRect devClipBounds;
312 if (drawState.isClipState()) { 322 if (drawState.isClipState()) {
313 this->getClip()->getConservativeBounds(drawState.getRenderTarget(), &dev ClipBounds); 323 this->getClip()->getConservativeBounds(drawState.getRenderTarget(), &dev ClipBounds);
314 devRect = &devClipBounds; 324 devRect = &devClipBounds;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 GrGLAttribTypeToLayout(attribType).fCount, 399 GrGLAttribTypeToLayout(attribType).fCount,
390 GrGLAttribTypeToLayout(attribType).fType, 400 GrGLAttribTypeToLayout(attribType).fType,
391 GrGLAttribTypeToLayout(attribType).fNormalized, 401 GrGLAttribTypeToLayout(attribType).fNormalized,
392 stride, 402 stride,
393 reinterpret_cast<GrGLvoid*>( 403 reinterpret_cast<GrGLvoid*>(
394 vertexOffsetInBytes + vertexAttrib->fOffset)); 404 vertexOffsetInBytes + vertexAttrib->fOffset));
395 } 405 }
396 406
397 attribState->disableUnusedAttribArrays(this, usedAttribArraysMask); 407 attribState->disableUnusedAttribArrays(this, usedAttribArraysMask);
398 } 408 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGpuGL.h ('k') | tests/GLProgramsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698