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

Side by Side Diff: src/effects/SkAlphaThresholdFilter.cpp

Issue 1438003003: Move all ShaderBuilder files to GLSL (Closed) Base URL: https://skia.googlesource.com/skia.git@glslProgBuild
Patch Set: nits Created 5 years, 1 month 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
« no previous file with comments | « src/effects/GrCircleBlurFragmentProcessor.cpp ('k') | src/effects/SkArithmeticMode_gpu.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 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 "SkAlphaThresholdFilter.h" 8 #include "SkAlphaThresholdFilter.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkDevice.h" 10 #include "SkDevice.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #include "GrContext.h" 51 #include "GrContext.h"
52 #include "GrCoordTransform.h" 52 #include "GrCoordTransform.h"
53 #include "GrFragmentProcessor.h" 53 #include "GrFragmentProcessor.h"
54 #include "GrInvariantOutput.h" 54 #include "GrInvariantOutput.h"
55 #include "GrTextureAccess.h" 55 #include "GrTextureAccess.h"
56 #include "effects/GrPorterDuffXferProcessor.h" 56 #include "effects/GrPorterDuffXferProcessor.h"
57 57
58 #include "SkGr.h" 58 #include "SkGr.h"
59 59
60 #include "gl/GrGLFragmentProcessor.h" 60 #include "gl/GrGLFragmentProcessor.h"
61 #include "gl/builders/GrGLProgramBuilder.h" 61 #include "glsl/GrGLSLFragmentShaderBuilder.h"
62 #include "glsl/GrGLSLProgramBuilder.h"
62 #include "glsl/GrGLSLProgramDataManager.h" 63 #include "glsl/GrGLSLProgramDataManager.h"
63 64
64 class AlphaThresholdEffect : public GrFragmentProcessor { 65 class AlphaThresholdEffect : public GrFragmentProcessor {
65 66
66 public: 67 public:
67 static GrFragmentProcessor* Create(GrTexture* texture, 68 static GrFragmentProcessor* Create(GrTexture* texture,
68 GrTexture* maskTexture, 69 GrTexture* maskTexture,
69 float innerThreshold, 70 float innerThreshold,
70 float outerThreshold) { 71 float outerThreshold) {
71 return new AlphaThresholdEffect(texture, maskTexture, innerThreshold, ou terThreshold); 72 return new AlphaThresholdEffect(texture, maskTexture, innerThreshold, ou terThreshold);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 132
132 private: 133 private:
133 134
134 GrGLSLProgramDataManager::UniformHandle fInnerThresholdVar; 135 GrGLSLProgramDataManager::UniformHandle fInnerThresholdVar;
135 GrGLSLProgramDataManager::UniformHandle fOuterThresholdVar; 136 GrGLSLProgramDataManager::UniformHandle fOuterThresholdVar;
136 137
137 typedef GrGLFragmentProcessor INHERITED; 138 typedef GrGLFragmentProcessor INHERITED;
138 }; 139 };
139 140
140 void GrGLAlphaThresholdEffect::emitCode(EmitArgs& args) { 141 void GrGLAlphaThresholdEffect::emitCode(EmitArgs& args) {
141 fInnerThresholdVar = args.fBuilder->addUniform( 142 fInnerThresholdVar = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragme nt_Visibility,
142 GrGLProgramBuilder::kFragment_Visibility, 143 kFloat_GrSLType, kDefault_GrS LPrecision,
143 kFloat_GrSLType, kDefault_GrSLPrecision, 144 "inner_threshold");
144 "inner_threshold"); 145 fOuterThresholdVar = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragme nt_Visibility,
145 fOuterThresholdVar = args.fBuilder->addUniform( 146 kFloat_GrSLType, kDefault_GrS LPrecision,
146 GrGLProgramBuilder::kFragment_Visibility, 147 "outer_threshold");
147 kFloat_GrSLType, kDefault_GrSLPrecision,
148 "outer_threshold");
149 148
150 GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder(); 149 GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder() ;
151 SkString coords2D = fsBuilder->ensureFSCoords2D(args.fCoords, 0); 150 SkString coords2D = fsBuilder->ensureFSCoords2D(args.fCoords, 0);
152 SkString maskCoords2D = fsBuilder->ensureFSCoords2D(args.fCoords, 1); 151 SkString maskCoords2D = fsBuilder->ensureFSCoords2D(args.fCoords, 1);
153 152
154 fsBuilder->codeAppendf("\t\tvec2 coord = %s;\n", coords2D.c_str()); 153 fsBuilder->codeAppendf("\t\tvec2 coord = %s;\n", coords2D.c_str());
155 fsBuilder->codeAppendf("\t\tvec2 mask_coord = %s;\n", maskCoords2D.c_str()); 154 fsBuilder->codeAppendf("\t\tvec2 mask_coord = %s;\n", maskCoords2D.c_str());
156 fsBuilder->codeAppend("\t\tvec4 input_color = "); 155 fsBuilder->codeAppend("\t\tvec4 input_color = ");
157 fsBuilder->appendTextureLookup(args.fSamplers[0], "coord"); 156 fsBuilder->appendTextureLookup(args.fSamplers[0], "coord");
158 fsBuilder->codeAppend(";\n"); 157 fsBuilder->codeAppend(";\n");
159 fsBuilder->codeAppend("\t\tvec4 mask_color = "); 158 fsBuilder->codeAppend("\t\tvec4 mask_color = ");
160 fsBuilder->appendTextureLookup(args.fSamplers[1], "mask_coord"); 159 fsBuilder->appendTextureLookup(args.fSamplers[1], "mask_coord");
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 GrTexture* bmpTex = d->fTextures[GrProcessorUnitTest::kSkiaPMTextureIdx]; 197 GrTexture* bmpTex = d->fTextures[GrProcessorUnitTest::kSkiaPMTextureIdx];
199 GrTexture* maskTex = d->fTextures[GrProcessorUnitTest::kAlphaTextureIdx]; 198 GrTexture* maskTex = d->fTextures[GrProcessorUnitTest::kAlphaTextureIdx];
200 float innerThresh = d->fRandom->nextUScalar1(); 199 float innerThresh = d->fRandom->nextUScalar1();
201 float outerThresh = d->fRandom->nextUScalar1(); 200 float outerThresh = d->fRandom->nextUScalar1();
202 return AlphaThresholdEffect::Create(bmpTex, maskTex, innerThresh, outerThres h); 201 return AlphaThresholdEffect::Create(bmpTex, maskTex, innerThresh, outerThres h);
203 } 202 }
204 203
205 /////////////////////////////////////////////////////////////////////////////// 204 ///////////////////////////////////////////////////////////////////////////////
206 205
207 void AlphaThresholdEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, 206 void AlphaThresholdEffect::onGetGLProcessorKey(const GrGLSLCaps& caps,
208 GrProcessorKeyBuilder* b) const { 207 GrProcessorKeyBuilder* b) const {
209 GrGLAlphaThresholdEffect::GenKey(*this, caps, b); 208 GrGLAlphaThresholdEffect::GenKey(*this, caps, b);
210 } 209 }
211 210
212 GrGLFragmentProcessor* AlphaThresholdEffect::onCreateGLInstance() const { 211 GrGLFragmentProcessor* AlphaThresholdEffect::onCreateGLInstance() const {
213 return new GrGLAlphaThresholdEffect(*this); 212 return new GrGLAlphaThresholdEffect(*this);
214 } 213 }
215 214
216 bool AlphaThresholdEffect::onIsEqual(const GrFragmentProcessor& sBase) const { 215 bool AlphaThresholdEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
217 const AlphaThresholdEffect& s = sBase.cast<AlphaThresholdEffect>(); 216 const AlphaThresholdEffect& s = sBase.cast<AlphaThresholdEffect>();
218 return (this->fInnerThreshold == s.fInnerThreshold && 217 return (this->fInnerThreshold == s.fInnerThreshold &&
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 } 370 }
372 371
373 #ifndef SK_IGNORE_TO_STRING 372 #ifndef SK_IGNORE_TO_STRING
374 void SkAlphaThresholdFilterImpl::toString(SkString* str) const { 373 void SkAlphaThresholdFilterImpl::toString(SkString* str) const {
375 str->appendf("SkAlphaThresholdImageFilter: ("); 374 str->appendf("SkAlphaThresholdImageFilter: (");
376 str->appendf("inner: %f outer: %f", fInnerThreshold, fOuterThreshold); 375 str->appendf("inner: %f outer: %f", fInnerThreshold, fOuterThreshold);
377 str->append(")"); 376 str->append(")");
378 } 377 }
379 #endif 378 #endif
380 379
OLDNEW
« no previous file with comments | « src/effects/GrCircleBlurFragmentProcessor.cpp ('k') | src/effects/SkArithmeticMode_gpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698