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

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

Issue 1434313002: Make all GrFragmentProcessors GL independent. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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.h » ('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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 #if SK_SUPPORT_GPU 50 #if SK_SUPPORT_GPU
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 "glsl/GrGLSLFragmentProcessor.h"
61 #include "glsl/GrGLSLFragmentShaderBuilder.h" 61 #include "glsl/GrGLSLFragmentShaderBuilder.h"
62 #include "glsl/GrGLSLProgramBuilder.h" 62 #include "glsl/GrGLSLProgramBuilder.h"
63 #include "glsl/GrGLSLProgramDataManager.h" 63 #include "glsl/GrGLSLProgramDataManager.h"
64 64
65 class AlphaThresholdEffect : public GrFragmentProcessor { 65 class AlphaThresholdEffect : public GrFragmentProcessor {
66 66
67 public: 67 public:
68 static GrFragmentProcessor* Create(GrTexture* texture, 68 static GrFragmentProcessor* Create(GrTexture* texture,
69 GrTexture* maskTexture, 69 GrTexture* maskTexture,
70 float innerThreshold, 70 float innerThreshold,
(...skipping 23 matching lines...) Expand all
94 GrCoordTransform::MakeDivByTextureWHMatrix(maskTex ture), maskTexture, 94 GrCoordTransform::MakeDivByTextureWHMatrix(maskTex ture), maskTexture,
95 GrTextureParams::kNone_FilterMode) 95 GrTextureParams::kNone_FilterMode)
96 , fMaskTextureAccess(maskTexture) { 96 , fMaskTextureAccess(maskTexture) {
97 this->initClassID<AlphaThresholdEffect>(); 97 this->initClassID<AlphaThresholdEffect>();
98 this->addCoordTransform(&fImageCoordTransform); 98 this->addCoordTransform(&fImageCoordTransform);
99 this->addTextureAccess(&fImageTextureAccess); 99 this->addTextureAccess(&fImageTextureAccess);
100 this->addCoordTransform(&fMaskCoordTransform); 100 this->addCoordTransform(&fMaskCoordTransform);
101 this->addTextureAccess(&fMaskTextureAccess); 101 this->addTextureAccess(&fMaskTextureAccess);
102 } 102 }
103 103
104 GrGLFragmentProcessor* onCreateGLInstance() const override; 104 GrGLSLFragmentProcessor* onCreateGLInstance() const override;
105 105
106 void onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const ov erride; 106 void onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const ov erride;
107 107
108 bool onIsEqual(const GrFragmentProcessor&) const override; 108 bool onIsEqual(const GrFragmentProcessor&) const override;
109 109
110 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; 110 void onComputeInvariantOutput(GrInvariantOutput* inout) const override;
111 111
112 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; 112 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
113 113
114 float fInnerThreshold; 114 float fInnerThreshold;
115 float fOuterThreshold; 115 float fOuterThreshold;
116 GrCoordTransform fImageCoordTransform; 116 GrCoordTransform fImageCoordTransform;
117 GrTextureAccess fImageTextureAccess; 117 GrTextureAccess fImageTextureAccess;
118 GrCoordTransform fMaskCoordTransform; 118 GrCoordTransform fMaskCoordTransform;
119 GrTextureAccess fMaskTextureAccess; 119 GrTextureAccess fMaskTextureAccess;
120 120
121 typedef GrFragmentProcessor INHERITED; 121 typedef GrFragmentProcessor INHERITED;
122 }; 122 };
123 123
124 class GrGLAlphaThresholdEffect : public GrGLFragmentProcessor { 124 class GrGLAlphaThresholdEffect : public GrGLSLFragmentProcessor {
125 public: 125 public:
126 GrGLAlphaThresholdEffect(const GrFragmentProcessor&) {} 126 GrGLAlphaThresholdEffect(const GrFragmentProcessor&) {}
127 127
128 virtual void emitCode(EmitArgs&) override; 128 virtual void emitCode(EmitArgs&) override;
129 129
130 protected: 130 protected:
131 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override ; 131 void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override ;
132 132
133 private: 133 private:
134 134
135 GrGLSLProgramDataManager::UniformHandle fInnerThresholdVar; 135 GrGLSLProgramDataManager::UniformHandle fInnerThresholdVar;
136 GrGLSLProgramDataManager::UniformHandle fOuterThresholdVar; 136 GrGLSLProgramDataManager::UniformHandle fOuterThresholdVar;
137 137
138 typedef GrGLFragmentProcessor INHERITED; 138 typedef GrGLSLFragmentProcessor INHERITED;
139 }; 139 };
140 140
141 void GrGLAlphaThresholdEffect::emitCode(EmitArgs& args) { 141 void GrGLAlphaThresholdEffect::emitCode(EmitArgs& args) {
142 fInnerThresholdVar = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragme nt_Visibility, 142 fInnerThresholdVar = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragme nt_Visibility,
143 kFloat_GrSLType, kDefault_GrS LPrecision, 143 kFloat_GrSLType, kDefault_GrS LPrecision,
144 "inner_threshold"); 144 "inner_threshold");
145 fOuterThresholdVar = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragme nt_Visibility, 145 fOuterThresholdVar = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragme nt_Visibility,
146 kFloat_GrSLType, kDefault_GrS LPrecision, 146 kFloat_GrSLType, kDefault_GrS LPrecision,
147 "outer_threshold"); 147 "outer_threshold");
148 148
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 return AlphaThresholdEffect::Create(bmpTex, maskTex, innerThresh, outerThres h); 201 return AlphaThresholdEffect::Create(bmpTex, maskTex, innerThresh, outerThres h);
202 } 202 }
203 203
204 /////////////////////////////////////////////////////////////////////////////// 204 ///////////////////////////////////////////////////////////////////////////////
205 205
206 void AlphaThresholdEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, 206 void AlphaThresholdEffect::onGetGLProcessorKey(const GrGLSLCaps& caps,
207 GrProcessorKeyBuilder* b) const { 207 GrProcessorKeyBuilder* b) const {
208 GrGLAlphaThresholdEffect::GenKey(*this, caps, b); 208 GrGLAlphaThresholdEffect::GenKey(*this, caps, b);
209 } 209 }
210 210
211 GrGLFragmentProcessor* AlphaThresholdEffect::onCreateGLInstance() const { 211 GrGLSLFragmentProcessor* AlphaThresholdEffect::onCreateGLInstance() const {
212 return new GrGLAlphaThresholdEffect(*this); 212 return new GrGLAlphaThresholdEffect(*this);
213 } 213 }
214 214
215 bool AlphaThresholdEffect::onIsEqual(const GrFragmentProcessor& sBase) const { 215 bool AlphaThresholdEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
216 const AlphaThresholdEffect& s = sBase.cast<AlphaThresholdEffect>(); 216 const AlphaThresholdEffect& s = sBase.cast<AlphaThresholdEffect>();
217 return (this->fInnerThreshold == s.fInnerThreshold && 217 return (this->fInnerThreshold == s.fInnerThreshold &&
218 this->fOuterThreshold == s.fOuterThreshold); 218 this->fOuterThreshold == s.fOuterThreshold);
219 } 219 }
220 220
221 void AlphaThresholdEffect::onComputeInvariantOutput(GrInvariantOutput* inout) co nst { 221 void AlphaThresholdEffect::onComputeInvariantOutput(GrInvariantOutput* inout) co nst {
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 } 370 }
371 371
372 #ifndef SK_IGNORE_TO_STRING 372 #ifndef SK_IGNORE_TO_STRING
373 void SkAlphaThresholdFilterImpl::toString(SkString* str) const { 373 void SkAlphaThresholdFilterImpl::toString(SkString* str) const {
374 str->appendf("SkAlphaThresholdImageFilter: ("); 374 str->appendf("SkAlphaThresholdImageFilter: (");
375 str->appendf("inner: %f outer: %f", fInnerThreshold, fOuterThreshold); 375 str->appendf("inner: %f outer: %f", fInnerThreshold, fOuterThreshold);
376 str->append(")"); 376 str->append(")");
377 } 377 }
378 #endif 378 #endif
379 379
OLDNEW
« no previous file with comments | « src/effects/GrCircleBlurFragmentProcessor.cpp ('k') | src/effects/SkArithmeticMode_gpu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698