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

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

Issue 25023003: Implement color filter as GrGLEffect (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: address review comments 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
« no previous file with comments | « src/gpu/gl/GrGLShaderBuilder.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 2012 Google Inc. 2 * Copyright 2012 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 "gl/GrGLShaderBuilder.h" 8 #include "gl/GrGLShaderBuilder.h"
9 #include "gl/GrGLProgram.h" 9 #include "gl/GrGLProgram.h"
10 #include "gl/GrGLUniformHandle.h" 10 #include "gl/GrGLUniformHandle.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 "_dstTexCoord", 142 "_dstTexCoord",
143 configMask, 143 configMask,
144 "rgba"); 144 "rgba");
145 this->fsCodeAppend(";\n\n"); 145 this->fsCodeAppend(";\n\n");
146 } 146 }
147 147
148 if (GrGLProgramDesc::kUniform_ColorInput == header.fColorInput) { 148 if (GrGLProgramDesc::kUniform_ColorInput == header.fColorInput) {
149 const char* name; 149 const char* name;
150 fColorUniform = this->addUniform(GrGLShaderBuilder::kFragment_Visibility , 150 fColorUniform = this->addUniform(GrGLShaderBuilder::kFragment_Visibility ,
151 kVec4f_GrSLType, "Color", &name); 151 kVec4f_GrSLType, "Color", &name);
152 fInputColor = name; 152 fInputColor = GrGLSLExpr4(name);
153 } else if (GrGLProgramDesc::kSolidWhite_ColorInput == header.fColorInput) { 153 } else if (GrGLProgramDesc::kSolidWhite_ColorInput == header.fColorInput) {
154 fInputColor = GrGLSLExpr<4>(1); 154 fInputColor = GrGLSLExpr4(1);
155 } else if (GrGLProgramDesc::kTransBlack_ColorInput == header.fColorInput) { 155 } else if (GrGLProgramDesc::kTransBlack_ColorInput == header.fColorInput) {
156 fInputColor = GrGLSLExpr<4>(0); 156 fInputColor = GrGLSLExpr4(0);
157 } 157 }
158 158
159 if (GrGLProgramDesc::kUniform_ColorInput == header.fCoverageInput) { 159 if (GrGLProgramDesc::kUniform_ColorInput == header.fCoverageInput) {
160 const char* name; 160 const char* name;
161 fCoverageUniform = this->addUniform(GrGLShaderBuilder::kFragment_Visibil ity, 161 fCoverageUniform = this->addUniform(GrGLShaderBuilder::kFragment_Visibil ity,
162 kVec4f_GrSLType, "Coverage", &name); 162 kVec4f_GrSLType, "Coverage", &name);
163 fInputCoverage = name; 163 fInputCoverage = GrGLSLExpr4(name);
164 } else if (GrGLProgramDesc::kSolidWhite_ColorInput == header.fCoverageInput) { 164 } else if (GrGLProgramDesc::kSolidWhite_ColorInput == header.fCoverageInput) {
165 fInputCoverage = GrGLSLExpr<4>(1); 165 fInputCoverage = GrGLSLExpr4(1);
166 } else if (GrGLProgramDesc::kTransBlack_ColorInput == header.fCoverageInput) { 166 } else if (GrGLProgramDesc::kTransBlack_ColorInput == header.fCoverageInput) {
167 fInputCoverage = GrGLSLExpr<4>(0); 167 fInputCoverage = GrGLSLExpr4(0);
168 } 168 }
169 169
170 if (k110_GrGLSLGeneration != fGpu->glslGeneration()) { 170 if (k110_GrGLSLGeneration != fGpu->glslGeneration()) {
171 fFSOutputs.push_back().set(kVec4f_GrSLType, 171 fFSOutputs.push_back().set(kVec4f_GrSLType,
172 GrGLShaderVar::kOut_TypeModifier, 172 GrGLShaderVar::kOut_TypeModifier,
173 declared_color_output_name()); 173 declared_color_output_name());
174 fHasCustomColorOutput = true; 174 fHasCustomColorOutput = true;
175 } 175 }
176 } 176 }
177 177
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 this->appendTextureLookup(&fFSCode, sampler, coordName, varyingType); 288 this->appendTextureLookup(&fFSCode, sampler, coordName, varyingType);
289 } 289 }
290 290
291 void GrGLShaderBuilder::fsAppendTextureLookupAndModulate( 291 void GrGLShaderBuilder::fsAppendTextureLookupAndModulate(
292 const char* modulation, 292 const char* modulation,
293 const GrGLShaderBuilder::TextureSamp ler& sampler, 293 const GrGLShaderBuilder::TextureSamp ler& sampler,
294 const char* coordName, 294 const char* coordName,
295 GrSLType varyingType) { 295 GrSLType varyingType) {
296 SkString lookup; 296 SkString lookup;
297 this->appendTextureLookup(&lookup, sampler, coordName, varyingType); 297 this->appendTextureLookup(&lookup, sampler, coordName, varyingType);
298 fFSCode.append((GrGLSLExpr<4>(modulation) * GrGLSLExpr<4>(lookup)).c_str()); 298 fFSCode.append((GrGLSLExpr4(modulation) * GrGLSLExpr4(lookup)).c_str());
299 } 299 }
300 300
301 GrGLShaderBuilder::DstReadKey GrGLShaderBuilder::KeyForDstRead(const GrTexture* dstCopy, 301 GrGLShaderBuilder::DstReadKey GrGLShaderBuilder::KeyForDstRead(const GrTexture* dstCopy,
302 const GrGLCaps& c aps) { 302 const GrGLCaps& c aps) {
303 uint32_t key = kYesDstRead_DstReadKeyBit; 303 uint32_t key = kYesDstRead_DstReadKeyBit;
304 if (GrGLCaps::kNone_FBFetchType != caps.fbFetchType()) { 304 if (GrGLCaps::kNone_FBFetchType != caps.fbFetchType()) {
305 return key; 305 return key;
306 } 306 }
307 SkASSERT(NULL != dstCopy); 307 SkASSERT(NULL != dstCopy);
308 if (!caps.textureSwizzleSupport() && GrPixelConfigIsAlphaOnly(dstCopy->confi g())) { 308 if (!caps.textureSwizzleSupport() && GrPixelConfigIsAlphaOnly(dstCopy->confi g())) {
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 fUniforms[i].fVariable.appendDecl(this->ctxInfo(), out); 508 fUniforms[i].fVariable.appendDecl(this->ctxInfo(), out);
509 out->append(";\n"); 509 out->append(";\n");
510 } 510 }
511 } 511 }
512 } 512 }
513 513
514 void GrGLShaderBuilder::createAndEmitEffects(GrGLProgramEffectsBuilder* programE ffectsBuilder, 514 void GrGLShaderBuilder::createAndEmitEffects(GrGLProgramEffectsBuilder* programE ffectsBuilder,
515 const GrEffectStage* effectStages[] , 515 const GrEffectStage* effectStages[] ,
516 const EffectKey effectKeys[], 516 const EffectKey effectKeys[],
517 int effectCnt, 517 int effectCnt,
518 GrGLSLExpr<4>* fsInOutColor) { 518 GrGLSLExpr4* fsInOutColor) {
519 bool effectEmitted = false; 519 bool effectEmitted = false;
520 520
521 GrGLSLExpr<4> inColor = *fsInOutColor; 521 GrGLSLExpr4 inColor = *fsInOutColor;
522 GrGLSLExpr<4> outColor; 522 GrGLSLExpr4 outColor;
523 523
524 for (int e = 0; e < effectCnt; ++e) { 524 for (int e = 0; e < effectCnt; ++e) {
525 SkASSERT(NULL != effectStages[e] && NULL != effectStages[e]->getEffect() ); 525 SkASSERT(NULL != effectStages[e] && NULL != effectStages[e]->getEffect() );
526 const GrEffectStage& stage = *effectStages[e]; 526 const GrEffectStage& stage = *effectStages[e];
527 527
528 CodeStage::AutoStageRestore csar(&fCodeStage, &stage); 528 CodeStage::AutoStageRestore csar(&fCodeStage, &stage);
529 529
530 if (inColor.isZeros()) { 530 if (inColor.isZeros()) {
531 SkString inColorName; 531 SkString inColorName;
532 532
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 } 832 }
833 } 833 }
834 834
835 return NULL; 835 return NULL;
836 } 836 }
837 837
838 GrGLProgramEffects* GrGLFullShaderBuilder::createAndEmitEffects( 838 GrGLProgramEffects* GrGLFullShaderBuilder::createAndEmitEffects(
839 const GrEffectStage* effectStages[], 839 const GrEffectStage* effectStages[],
840 const EffectKey effectKeys[], 840 const EffectKey effectKeys[],
841 int effectCnt, 841 int effectCnt,
842 GrGLSLExpr<4>* inOutFSColor) { 842 GrGLSLExpr4* inOutFSColor) {
843 843
844 GrGLVertexProgramEffectsBuilder programEffectsBuilder(this, effectCnt); 844 GrGLVertexProgramEffectsBuilder programEffectsBuilder(this, effectCnt);
845 this->INHERITED::createAndEmitEffects(&programEffectsBuilder, 845 this->INHERITED::createAndEmitEffects(&programEffectsBuilder,
846 effectStages, 846 effectStages,
847 effectKeys, 847 effectKeys,
848 effectCnt, 848 effectCnt,
849 inOutFSColor); 849 inOutFSColor);
850 return programEffectsBuilder.finish(); 850 return programEffectsBuilder.finish();
851 } 851 }
852 852
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 int firstFreeCoordSet = fNumTexCoordSets; 947 int firstFreeCoordSet = fNumTexCoordSets;
948 fNumTexCoordSets += count; 948 fNumTexCoordSets += count;
949 SkASSERT(gpu()->glCaps().maxFixedFunctionTextureCoords() >= fNumTexCoordSets ); 949 SkASSERT(gpu()->glCaps().maxFixedFunctionTextureCoords() >= fNumTexCoordSets );
950 return firstFreeCoordSet; 950 return firstFreeCoordSet;
951 } 951 }
952 952
953 GrGLProgramEffects* GrGLFragmentOnlyShaderBuilder::createAndEmitEffects( 953 GrGLProgramEffects* GrGLFragmentOnlyShaderBuilder::createAndEmitEffects(
954 const GrEffectStage* effectStages[], 954 const GrEffectStage* effectStages[],
955 const EffectKey effectKeys[], 955 const EffectKey effectKeys[],
956 int effectCnt, 956 int effectCnt,
957 GrGLSLExpr<4>* inOutFSColor) { 957 GrGLSLExpr4* inOutFSColor) {
958 958
959 GrGLTexGenProgramEffectsBuilder texGenEffectsBuilder(this, effectCnt); 959 GrGLTexGenProgramEffectsBuilder texGenEffectsBuilder(this, effectCnt);
960 this->INHERITED::createAndEmitEffects(&texGenEffectsBuilder, 960 this->INHERITED::createAndEmitEffects(&texGenEffectsBuilder,
961 effectStages, 961 effectStages,
962 effectKeys, 962 effectKeys,
963 effectCnt, 963 effectCnt,
964 inOutFSColor); 964 inOutFSColor);
965 return texGenEffectsBuilder.finish(); 965 return texGenEffectsBuilder.finish();
966 } 966 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLShaderBuilder.h ('k') | tests/GLProgramsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698