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

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

Issue 12942014: Move GrGLProgram::Desc out of GrGLProgram. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Move #include below dbl include check Created 7 years, 9 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
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 30 matching lines...) Expand all
41 41
42 void GrGpuGL::ProgramCache::abandon() { 42 void GrGpuGL::ProgramCache::abandon() {
43 for (int i = 0; i < fCount; ++i) { 43 for (int i = 0; i < fCount; ++i) {
44 GrAssert(NULL != fEntries[i].fProgram.get()); 44 GrAssert(NULL != fEntries[i].fProgram.get());
45 fEntries[i].fProgram->abandon(); 45 fEntries[i].fProgram->abandon();
46 fEntries[i].fProgram.reset(NULL); 46 fEntries[i].fProgram.reset(NULL);
47 } 47 }
48 fCount = 0; 48 fCount = 0;
49 } 49 }
50 50
51 GrGLProgram* GrGpuGL::ProgramCache::getProgram(const GrGLProgram::Desc& desc, 51 GrGLProgram* GrGpuGL::ProgramCache::getProgram(const GrGLProgramDesc& desc,
52 const GrEffectStage* stages[]) { 52 const GrEffectStage* stages[]) {
53 Entry newEntry; 53 Entry newEntry;
54 newEntry.fKey.setKeyData(desc.asKey()); 54 newEntry.fKey.setKeyData(desc.asKey());
55 #ifdef PROGRAM_CACHE_STATS 55 #ifdef PROGRAM_CACHE_STATS
56 ++fTotalRequests; 56 ++fTotalRequests;
57 #endif 57 #endif
58 58
59 Entry* entry = fHashCache.find(newEntry.fKey); 59 Entry* entry = fHashCache.find(newEntry.fKey);
60 if (NULL == entry) { 60 if (NULL == entry) {
61 #ifdef PROGRAM_CACHE_STATS 61 #ifdef PROGRAM_CACHE_STATS
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 GrBlendCoeff dstCoeff; 173 GrBlendCoeff dstCoeff;
174 GrDrawState::BlendOptFlags blendOpts = drawState.getBlendOpts(false, &sr cCoeff, &dstCoeff); 174 GrDrawState::BlendOptFlags blendOpts = drawState.getBlendOpts(false, &sr cCoeff, &dstCoeff);
175 if (GrDrawState::kSkipDraw_BlendOptFlag & blendOpts) { 175 if (GrDrawState::kSkipDraw_BlendOptFlag & blendOpts) {
176 return false; 176 return false;
177 } 177 }
178 178
179 const GrEffectStage* stages[GrDrawState::kNumStages]; 179 const GrEffectStage* stages[GrDrawState::kNumStages];
180 for (int i = 0; i < GrDrawState::kNumStages; ++i) { 180 for (int i = 0; i < GrDrawState::kNumStages; ++i) {
181 stages[i] = drawState.isStageEnabled(i) ? &drawState.getStage(i) : N ULL; 181 stages[i] = drawState.isStageEnabled(i) ? &drawState.getStage(i) : N ULL;
182 } 182 }
183 GrGLProgram::Desc desc; 183 GrGLProgramDesc desc;
184 GrGLProgram::BuildDesc(this->getDrawState(), 184 GrGLProgramDesc::Build(this->getDrawState(),
185 kDrawPoints_DrawType == type, 185 kDrawPoints_DrawType == type,
186 blendOpts, 186 blendOpts,
187 srcCoeff, 187 srcCoeff,
188 dstCoeff, 188 dstCoeff,
189 this, 189 this,
190 &desc); 190 &desc);
191 191
192 fCurrentProgram.reset(fProgramCache->getProgram(desc, stages)); 192 fCurrentProgram.reset(fProgramCache->getProgram(desc, stages));
193 if (NULL == fCurrentProgram.get()) { 193 if (NULL == fCurrentProgram.get()) {
194 GrAssert(!"Failed to create program!"); 194 GrAssert(!"Failed to create program!");
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 const GrVertexAttrib* vertexAttrib = this->getDrawState().getVertexAttribs() ; 295 const GrVertexAttrib* vertexAttrib = this->getDrawState().getVertexAttribs() ;
296 int vertexAttribCount = this->getDrawState().getVertexAttribCount(); 296 int vertexAttribCount = this->getDrawState().getVertexAttribCount();
297 for (int vertexAttribIndex = 0; vertexAttribIndex < vertexAttribCount; 297 for (int vertexAttribIndex = 0; vertexAttribIndex < vertexAttribCount;
298 ++vertexAttribIndex, ++vertexAttrib) { 298 ++vertexAttribIndex, ++vertexAttrib) {
299 299
300 usedAttribArraysMask |= (1 << vertexAttribIndex); 300 usedAttribArraysMask |= (1 << vertexAttribIndex);
301 GrVertexAttribType attribType = vertexAttrib->fType; 301 GrVertexAttribType attribType = vertexAttrib->fType;
302 attribState->set(this, 302 attribState->set(this,
303 vertexAttribIndex, 303 vertexAttribIndex,
304 vbuf, 304 vbuf,
305 GrGLProgram::kAttribLayouts[attribType].fCount, 305 GrGLAttribTypeToLayout(attribType).fCount,
306 GrGLProgram::kAttribLayouts[attribType].fType, 306 GrGLAttribTypeToLayout(attribType).fType,
307 GrGLProgram::kAttribLayouts[attribType].fNormalized, 307 GrGLAttribTypeToLayout(attribType).fNormalized,
308 stride, 308 stride,
309 reinterpret_cast<GrGLvoid*>( 309 reinterpret_cast<GrGLvoid*>(
310 vertexOffsetInBytes + vertexAttrib->fOffset)); 310 vertexOffsetInBytes + vertexAttrib->fOffset));
311 } 311 }
312 312
313 attribState->disableUnusedAttribArrays(this, usedAttribArraysMask); 313 attribState->disableUnusedAttribArrays(this, usedAttribArraysMask);
314 } 314 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698