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

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

Issue 628293002: Plumb OptDrawState down to VertexShaderBuilder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Clean up Created 6 years, 2 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
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 "GrProcessor.h" 10 #include "GrProcessor.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 SkDELETE(fEntries[i]); 83 SkDELETE(fEntries[i]);
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 GrOptDrawState& optState,
94 const GrGLProgramDesc& desc,
94 const GrGeometryStage* geometryPr ocessor, 95 const GrGeometryStage* geometryPr ocessor,
95 const GrFragmentStage* colorStage s[], 96 const GrFragmentStage* colorStage s[],
96 const GrFragmentStage* coverageSt ages[]) { 97 const GrFragmentStage* coverageSt ages[]) {
97 #ifdef PROGRAM_CACHE_STATS 98 #ifdef PROGRAM_CACHE_STATS
98 ++fTotalRequests; 99 ++fTotalRequests;
99 #endif 100 #endif
100 101
101 Entry* entry = NULL; 102 Entry* entry = NULL;
102 103
103 uint32_t hashIdx = desc.getChecksum(); 104 uint32_t hashIdx = desc.getChecksum();
(...skipping 17 matching lines...) Expand all
121 ++fHashMisses; 122 ++fHashMisses;
122 #endif 123 #endif
123 } 124 }
124 } 125 }
125 126
126 if (NULL == entry) { 127 if (NULL == entry) {
127 // We have a cache miss 128 // We have a cache miss
128 #ifdef PROGRAM_CACHE_STATS 129 #ifdef PROGRAM_CACHE_STATS
129 ++fCacheMisses; 130 ++fCacheMisses;
130 #endif 131 #endif
131 GrGLProgram* program = GrGLProgram::Create(fGpu, desc, geometryProcessor , 132 GrGLProgram* program = GrGLProgram::Create(fGpu, optState, desc, geometr yProcessor,
132 colorStages, coverageStages); 133 colorStages, coverageStages);
133 if (NULL == program) { 134 if (NULL == program) {
134 return NULL; 135 return NULL;
135 } 136 }
136 int purgeIdx = 0; 137 int purgeIdx = 0;
137 if (fCount < kMaxEntries) { 138 if (fCount < kMaxEntries) {
138 entry = SkNEW(Entry); 139 entry = SkNEW(Entry);
139 purgeIdx = fCount++; 140 purgeIdx = fCount++;
140 fEntries[purgeIdx] = entry; 141 fEntries[purgeIdx] = entry;
141 } else { 142 } else {
142 SkASSERT(fCount == kMaxEntries); 143 SkASSERT(fCount == kMaxEntries);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 const GrRenderTarget* rt = optState->getRenderTarget(); 215 const GrRenderTarget* rt = optState->getRenderTarget();
215 SkISize size; 216 SkISize size;
216 size.set(rt->width(), rt->height()); 217 size.set(rt->width(), rt->height());
217 this->glPathRendering()->setProjectionMatrix(optState->getViewMatrix(), size, rt->origin()); 218 this->glPathRendering()->setProjectionMatrix(optState->getViewMatrix(), size, rt->origin());
218 } else { 219 } else {
219 this->flushMiscFixedFunctionState(*optState.get()); 220 this->flushMiscFixedFunctionState(*optState.get());
220 221
221 GrBlendCoeff srcCoeff = optState->getSrcBlendCoeff(); 222 GrBlendCoeff srcCoeff = optState->getSrcBlendCoeff();
222 GrBlendCoeff dstCoeff = optState->getDstBlendCoeff(); 223 GrBlendCoeff dstCoeff = optState->getDstBlendCoeff();
223 224
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 &&
226 !optState->getStencil().doesWrite()) {
227 return false;
228 }
229
230 const GrGeometryStage* geometryProcessor = NULL; 225 const GrGeometryStage* geometryProcessor = NULL;
231 SkSTArray<8, const GrFragmentStage*, true> colorStages; 226 SkSTArray<8, const GrFragmentStage*, true> colorStages;
232 SkSTArray<8, const GrFragmentStage*, true> coverageStages; 227 SkSTArray<8, const GrFragmentStage*, true> coverageStages;
233 GrGLProgramDesc desc; 228 GrGLProgramDesc desc;
234 if (!GrGLProgramDesc::Build(*optState.get(), 229 if (!GrGLProgramDesc::Build(*optState.get(),
235 type, 230 type,
236 srcCoeff, 231 srcCoeff,
237 dstCoeff, 232 dstCoeff,
238 this, 233 this,
239 dstCopy, 234 dstCopy,
240 &geometryProcessor, 235 &geometryProcessor,
241 &colorStages, 236 &colorStages,
242 &coverageStages, 237 &coverageStages,
243 &desc)) { 238 &desc)) {
244 SkDEBUGFAIL("Failed to generate GL program descriptor"); 239 SkDEBUGFAIL("Failed to generate GL program descriptor");
245 return false; 240 return false;
246 } 241 }
247 242
248 fCurrentProgram.reset(fProgramCache->getProgram(desc, 243 fCurrentProgram.reset(fProgramCache->getProgram(*optState.get(),
244 desc,
249 geometryProcessor, 245 geometryProcessor,
250 colorStages.begin(), 246 colorStages.begin(),
251 coverageStages.begin())) ; 247 coverageStages.begin())) ;
252 if (NULL == fCurrentProgram.get()) { 248 if (NULL == fCurrentProgram.get()) {
253 SkDEBUGFAIL("Failed to create program!"); 249 SkDEBUGFAIL("Failed to create program!");
254 return false; 250 return false;
255 } 251 }
256 252
257 fCurrentProgram.get()->ref(); 253 fCurrentProgram.get()->ref();
258 254
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 GrGLAttribTypeToLayout(attribType).fCount, 358 GrGLAttribTypeToLayout(attribType).fCount,
363 GrGLAttribTypeToLayout(attribType).fType, 359 GrGLAttribTypeToLayout(attribType).fType,
364 GrGLAttribTypeToLayout(attribType).fNormalized, 360 GrGLAttribTypeToLayout(attribType).fNormalized,
365 stride, 361 stride,
366 reinterpret_cast<GrGLvoid*>( 362 reinterpret_cast<GrGLvoid*>(
367 vertexOffsetInBytes + vertexAttrib->fOffset)); 363 vertexOffsetInBytes + vertexAttrib->fOffset));
368 } 364 }
369 attribState->disableUnusedArrays(this, usedAttribArraysMask); 365 attribState->disableUnusedArrays(this, usedAttribArraysMask);
370 } 366 }
371 } 367 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698