| 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 "SkDevice.h" | 10 #include "SkDevice.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 GrGLSLFragmentProcessor* onCreateGLInstance() const override; | 104 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; |
| 105 | 105 |
| 106 void onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const ov
erride; | 106 void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const
override; |
| 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; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 const GrFragmentProcessor* AlphaThresholdEffect::TestCreate(GrProcessorTestData*
d) { | 196 const GrFragmentProcessor* AlphaThresholdEffect::TestCreate(GrProcessorTestData*
d) { |
| 197 GrTexture* bmpTex = d->fTextures[GrProcessorUnitTest::kSkiaPMTextureIdx]; | 197 GrTexture* bmpTex = d->fTextures[GrProcessorUnitTest::kSkiaPMTextureIdx]; |
| 198 GrTexture* maskTex = d->fTextures[GrProcessorUnitTest::kAlphaTextureIdx]; | 198 GrTexture* maskTex = d->fTextures[GrProcessorUnitTest::kAlphaTextureIdx]; |
| 199 float innerThresh = d->fRandom->nextUScalar1(); | 199 float innerThresh = d->fRandom->nextUScalar1(); |
| 200 float outerThresh = d->fRandom->nextUScalar1(); | 200 float outerThresh = d->fRandom->nextUScalar1(); |
| 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::onGetGLSLProcessorKey(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 GrGLSLFragmentProcessor* AlphaThresholdEffect::onCreateGLInstance() const { | 211 GrGLSLFragmentProcessor* AlphaThresholdEffect::onCreateGLSLInstance() 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 Loading... |
| 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 |
| OLD | NEW |