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

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

Issue 25023003: Implement color filter as GrGLEffect (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix a small thinko Created 7 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 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 "GrGLProgramDesc.h" 8 #include "GrGLProgramDesc.h"
9 #include "GrBackendEffectFactory.h" 9 #include "GrBackendEffectFactory.h"
10 #include "GrDrawEffect.h" 10 #include "GrDrawEffect.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 // to a canonical value to avoid duplicate programs with different keys. 63 // to a canonical value to avoid duplicate programs with different keys.
64 64
65 bool requiresColorAttrib = !skipColor && drawState.hasColorVertexAttribute() ; 65 bool requiresColorAttrib = !skipColor && drawState.hasColorVertexAttribute() ;
66 bool requiresCoverageAttrib = !skipCoverage && drawState.hasCoverageVertexAt tribute(); 66 bool requiresCoverageAttrib = !skipCoverage && drawState.hasCoverageVertexAt tribute();
67 // we only need the local coords if we're actually going to generate effect code 67 // we only need the local coords if we're actually going to generate effect code
68 bool requiresLocalCoordAttrib = !(skipCoverage && skipColor) && 68 bool requiresLocalCoordAttrib = !(skipCoverage && skipColor) &&
69 drawState.hasLocalCoordAttribute(); 69 drawState.hasLocalCoordAttribute();
70 70
71 bool colorIsTransBlack = SkToBool(blendOpts & GrDrawState::kEmitTransBlack_B lendOptFlag); 71 bool colorIsTransBlack = SkToBool(blendOpts & GrDrawState::kEmitTransBlack_B lendOptFlag);
72 bool colorIsSolidWhite = (blendOpts & GrDrawState::kEmitCoverage_BlendOptFla g) || 72 bool colorIsSolidWhite = (blendOpts & GrDrawState::kEmitCoverage_BlendOptFla g) ||
73 (!requiresColorAttrib && 0xffffffff == drawState.ge tColor()); 73 (!requiresColorAttrib && 0xffffffff == drawState.ge tColor()) ||
74 (drawState.numColorStages() > 0 && !(*drawState.get ColorStage(0).getEffect())->willUseInputColor());
74 75
75 int numEffects = (skipColor ? 0 : drawState.numColorStages()) + 76 int numEffects = (skipColor ? 0 : drawState.numColorStages()) +
76 (skipCoverage ? 0 : drawState.numCoverageStages()); 77 (skipCoverage ? 0 : drawState.numCoverageStages());
77 78
78 size_t newKeyLength = KeyLength(numEffects); 79 size_t newKeyLength = KeyLength(numEffects);
79 bool allocChanged; 80 bool allocChanged;
80 desc->fKey.reset(newKeyLength, SkAutoMalloc::kAlloc_OnShrink, &allocChanged) ; 81 desc->fKey.reset(newKeyLength, SkAutoMalloc::kAlloc_OnShrink, &allocChanged) ;
81 if (allocChanged || !desc->fInitialized) { 82 if (allocChanged || !desc->fInitialized) {
82 // make sure any padding in the header is zero if we we haven't used thi s allocation before. 83 // make sure any padding in the header is zero if we we haven't used thi s allocation before.
83 memset(desc->header(), 0, kHeaderSize); 84 memset(desc->header(), 0, kHeaderSize);
(...skipping 20 matching lines...) Expand all
104 for (int s = 0; s < drawState.numCoverageStages(); ++s) { 105 for (int s = 0; s < drawState.numCoverageStages(); ++s) {
105 effectKeys[currEffectKey++] = 106 effectKeys[currEffectKey++] =
106 get_key_and_update_stats(drawState.getCoverageStage(s), gpu->glC aps(), 107 get_key_and_update_stats(drawState.getCoverageStage(s), gpu->glC aps(),
107 requiresLocalCoordAttrib, &readsDst, &r eadFragPosition, 108 requiresLocalCoordAttrib, &readsDst, &r eadFragPosition,
108 &hasVertexCode); 109 &hasVertexCode);
109 } 110 }
110 } 111 }
111 112
112 header->fHasVertexCode = hasVertexCode || requiresLocalCoordAttrib; 113 header->fHasVertexCode = hasVertexCode || requiresLocalCoordAttrib;
113 header->fEmitsPointSize = isPoints; 114 header->fEmitsPointSize = isPoints;
114 header->fColorFilterXfermode = skipColor ? SkXfermode::kDst_Mode : drawState .getColorFilterMode();
115 115
116 // Currently the experimental GS will only work with triangle prims (and it doesn't do anything 116 // Currently the experimental GS will only work with triangle prims (and it doesn't do anything
117 // other than pass through values from the VS to the FS anyway). 117 // other than pass through values from the VS to the FS anyway).
118 #if GR_GL_EXPERIMENTAL_GS 118 #if GR_GL_EXPERIMENTAL_GS
119 #if 0 119 #if 0
120 header->fExperimentalGS = gpu->caps().geometryShaderSupport(); 120 header->fExperimentalGS = gpu->caps().geometryShaderSupport();
121 #else 121 #else
122 header->fExperimentalGS = false; 122 header->fExperimentalGS = false;
123 #endif 123 #endif
124 #endif 124 #endif
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 // Here we deal with whether/how we handle color and coverage separately. 193 // Here we deal with whether/how we handle color and coverage separately.
194 194
195 // Set these defaults and then possibly change our mind if there is coverage . 195 // Set these defaults and then possibly change our mind if there is coverage .
196 header->fDiscardIfZeroCoverage = false; 196 header->fDiscardIfZeroCoverage = false;
197 header->fCoverageOutput = kModulate_CoverageOutput; 197 header->fCoverageOutput = kModulate_CoverageOutput;
198 198
199 // If we do have coverage determine whether it matters. 199 // If we do have coverage determine whether it matters.
200 bool separateCoverageFromColor = false; 200 bool separateCoverageFromColor = false;
201 if (!drawState.isCoverageDrawing() && !skipCoverage && 201 if (!drawState.isCoverageDrawing() && !skipCoverage &&
202 (drawState.numCoverageStages() > 0 || requiresCoverageAttrib)) { 202 (drawState.numCoverageStages() > 0 || requiresCoverageAttrib)) {
203 // color filter is applied between color/coverage computation
204 if (SkXfermode::kDst_Mode != header->fColorFilterXfermode) {
205 separateCoverageFromColor = true;
206 }
207
208 // If we're stenciling then we want to discard samples that have zero co verage 203 // If we're stenciling then we want to discard samples that have zero co verage
209 if (drawState.getStencil().doesWrite()) { 204 if (drawState.getStencil().doesWrite()) {
210 header->fDiscardIfZeroCoverage = true; 205 header->fDiscardIfZeroCoverage = true;
211 separateCoverageFromColor = true; 206 separateCoverageFromColor = true;
212 } 207 }
213 208
214 if (gpu->caps()->dualSourceBlendingSupport() && 209 if (gpu->caps()->dualSourceBlendingSupport() &&
215 !(blendOpts & (GrDrawState::kEmitCoverage_BlendOptFlag | 210 !(blendOpts & (GrDrawState::kEmitCoverage_BlendOptFlag |
216 GrDrawState::kCoverageAsAlpha_BlendOptFlag))) { 211 GrDrawState::kCoverageAsAlpha_BlendOptFlag))) {
217 if (kZero_GrBlendCoeff == dstCoeff) { 212 if (kZero_GrBlendCoeff == dstCoeff) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 257
263 GrGLProgramDesc& GrGLProgramDesc::operator= (const GrGLProgramDesc& other) { 258 GrGLProgramDesc& GrGLProgramDesc::operator= (const GrGLProgramDesc& other) {
264 fInitialized = other.fInitialized; 259 fInitialized = other.fInitialized;
265 if (fInitialized) { 260 if (fInitialized) {
266 size_t keyLength = other.keyLength(); 261 size_t keyLength = other.keyLength();
267 fKey.reset(keyLength); 262 fKey.reset(keyLength);
268 memcpy(fKey.get(), other.fKey.get(), keyLength); 263 memcpy(fKey.get(), other.fKey.get(), keyLength);
269 } 264 }
270 return *this; 265 return *this;
271 } 266 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698