OLD | NEW |
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 "SkReadBuffer.h" | 10 #include "SkReadBuffer.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 outerThreshold)); | 74 outerThreshold)); |
75 } | 75 } |
76 | 76 |
77 virtual ~AlphaThresholdEffect() {}; | 77 virtual ~AlphaThresholdEffect() {}; |
78 | 78 |
79 const char* name() const override { return "Alpha Threshold"; } | 79 const char* name() const override { return "Alpha Threshold"; } |
80 | 80 |
81 float innerThreshold() const { return fInnerThreshold; } | 81 float innerThreshold() const { return fInnerThreshold; } |
82 float outerThreshold() const { return fOuterThreshold; } | 82 float outerThreshold() const { return fOuterThreshold; } |
83 | 83 |
84 void getGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const over
ride; | |
85 | |
86 GrGLFragmentProcessor* createGLInstance() const override; | 84 GrGLFragmentProcessor* createGLInstance() const override; |
87 | 85 |
88 private: | 86 private: |
89 AlphaThresholdEffect(GrProcessorDataManager*, | 87 AlphaThresholdEffect(GrProcessorDataManager*, |
90 GrTexture* texture, | 88 GrTexture* texture, |
91 GrTexture* maskTexture, | 89 GrTexture* maskTexture, |
92 float innerThreshold, | 90 float innerThreshold, |
93 float outerThreshold) | 91 float outerThreshold) |
94 : fInnerThreshold(innerThreshold) | 92 : fInnerThreshold(innerThreshold) |
95 , fOuterThreshold(outerThreshold) | 93 , fOuterThreshold(outerThreshold) |
96 , fImageCoordTransform(kLocal_GrCoordSet, | 94 , fImageCoordTransform(kLocal_GrCoordSet, |
97 GrCoordTransform::MakeDivByTextureWHMatrix(textur
e), texture, | 95 GrCoordTransform::MakeDivByTextureWHMatrix(textur
e), texture, |
98 GrTextureParams::kNone_FilterMode) | 96 GrTextureParams::kNone_FilterMode) |
99 , fImageTextureAccess(texture) | 97 , fImageTextureAccess(texture) |
100 , fMaskCoordTransform(kLocal_GrCoordSet, | 98 , fMaskCoordTransform(kLocal_GrCoordSet, |
101 GrCoordTransform::MakeDivByTextureWHMatrix(maskTex
ture), maskTexture, | 99 GrCoordTransform::MakeDivByTextureWHMatrix(maskTex
ture), maskTexture, |
102 GrTextureParams::kNone_FilterMode) | 100 GrTextureParams::kNone_FilterMode) |
103 , fMaskTextureAccess(maskTexture) { | 101 , fMaskTextureAccess(maskTexture) { |
104 this->initClassID<AlphaThresholdEffect>(); | 102 this->initClassID<AlphaThresholdEffect>(); |
105 this->addCoordTransform(&fImageCoordTransform); | 103 this->addCoordTransform(&fImageCoordTransform); |
106 this->addTextureAccess(&fImageTextureAccess); | 104 this->addTextureAccess(&fImageTextureAccess); |
107 this->addCoordTransform(&fMaskCoordTransform); | 105 this->addCoordTransform(&fMaskCoordTransform); |
108 this->addTextureAccess(&fMaskTextureAccess); | 106 this->addTextureAccess(&fMaskTextureAccess); |
109 } | 107 } |
110 | 108 |
| 109 void onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const ov
erride; |
| 110 |
111 bool onIsEqual(const GrFragmentProcessor&) const override; | 111 bool onIsEqual(const GrFragmentProcessor&) const override; |
112 | 112 |
113 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; | 113 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; |
114 | 114 |
115 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 115 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
116 | 116 |
117 float fInnerThreshold; | 117 float fInnerThreshold; |
118 float fOuterThreshold; | 118 float fOuterThreshold; |
119 GrCoordTransform fImageCoordTransform; | 119 GrCoordTransform fImageCoordTransform; |
120 GrTextureAccess fImageTextureAccess; | 120 GrTextureAccess fImageTextureAccess; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 GrTexture* bmpTex = d->fTextures[GrProcessorUnitTest::kSkiaPMTextureIdx]; | 201 GrTexture* bmpTex = d->fTextures[GrProcessorUnitTest::kSkiaPMTextureIdx]; |
202 GrTexture* maskTex = d->fTextures[GrProcessorUnitTest::kAlphaTextureIdx]; | 202 GrTexture* maskTex = d->fTextures[GrProcessorUnitTest::kAlphaTextureIdx]; |
203 float innerThresh = d->fRandom->nextUScalar1(); | 203 float innerThresh = d->fRandom->nextUScalar1(); |
204 float outerThresh = d->fRandom->nextUScalar1(); | 204 float outerThresh = d->fRandom->nextUScalar1(); |
205 return AlphaThresholdEffect::Create(d->fProcDataManager, bmpTex, maskTex, in
nerThresh, | 205 return AlphaThresholdEffect::Create(d->fProcDataManager, bmpTex, maskTex, in
nerThresh, |
206 outerThresh); | 206 outerThresh); |
207 } | 207 } |
208 | 208 |
209 /////////////////////////////////////////////////////////////////////////////// | 209 /////////////////////////////////////////////////////////////////////////////// |
210 | 210 |
211 void AlphaThresholdEffect::getGLProcessorKey(const GrGLSLCaps& caps, | 211 void AlphaThresholdEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, |
212 GrProcessorKeyBuilder* b) const { | 212 GrProcessorKeyBuilder* b) const { |
213 GrGLAlphaThresholdEffect::GenKey(*this, caps, b); | 213 GrGLAlphaThresholdEffect::GenKey(*this, caps, b); |
214 } | 214 } |
215 | 215 |
216 GrGLFragmentProcessor* AlphaThresholdEffect::createGLInstance() const { | 216 GrGLFragmentProcessor* AlphaThresholdEffect::createGLInstance() const { |
217 return SkNEW_ARGS(GrGLAlphaThresholdEffect, (*this)); | 217 return SkNEW_ARGS(GrGLAlphaThresholdEffect, (*this)); |
218 } | 218 } |
219 | 219 |
220 bool AlphaThresholdEffect::onIsEqual(const GrFragmentProcessor& sBase) const { | 220 bool AlphaThresholdEffect::onIsEqual(const GrFragmentProcessor& sBase) const { |
221 const AlphaThresholdEffect& s = sBase.cast<AlphaThresholdEffect>(); | 221 const AlphaThresholdEffect& s = sBase.cast<AlphaThresholdEffect>(); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 } | 374 } |
375 | 375 |
376 #ifndef SK_IGNORE_TO_STRING | 376 #ifndef SK_IGNORE_TO_STRING |
377 void SkAlphaThresholdFilterImpl::toString(SkString* str) const { | 377 void SkAlphaThresholdFilterImpl::toString(SkString* str) const { |
378 str->appendf("SkAlphaThresholdImageFilter: ("); | 378 str->appendf("SkAlphaThresholdImageFilter: ("); |
379 str->appendf("inner: %f outer: %f", fInnerThreshold, fOuterThreshold); | 379 str->appendf("inner: %f outer: %f", fInnerThreshold, fOuterThreshold); |
380 str->append(")"); | 380 str->append(")"); |
381 } | 381 } |
382 #endif | 382 #endif |
383 | 383 |
OLD | NEW |