| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 maskTexture, | 69 maskTexture, |
| 70 innerThreshold, | 70 innerThreshold, |
| 71 outerThreshold)); | 71 outerThreshold)); |
| 72 } | 72 } |
| 73 | 73 |
| 74 virtual ~AlphaThresholdEffect() {}; | 74 virtual ~AlphaThresholdEffect() {}; |
| 75 | 75 |
| 76 static const char* Name() { return "Alpha Threshold"; } | 76 static const char* Name() { return "Alpha Threshold"; } |
| 77 | 77 |
| 78 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR
IDE; | 78 virtual const GrBackendFragmentProcessorFactory& getFactory() const SK_OVERR
IDE; |
| 79 virtual void getConstantColorComponents(GrColor* color, uint32_t* validFlags
) const SK_OVERRIDE; | |
| 80 | |
| 81 float innerThreshold() const { return fInnerThreshold; } | 79 float innerThreshold() const { return fInnerThreshold; } |
| 82 float outerThreshold() const { return fOuterThreshold; } | 80 float outerThreshold() const { return fOuterThreshold; } |
| 83 | 81 |
| 84 typedef GrGLAlphaThresholdEffect GLProcessor; | 82 typedef GrGLAlphaThresholdEffect GLProcessor; |
| 85 | 83 |
| 86 private: | 84 private: |
| 87 AlphaThresholdEffect(GrTexture* texture, | 85 AlphaThresholdEffect(GrTexture* texture, |
| 88 GrTexture* maskTexture, | 86 GrTexture* maskTexture, |
| 89 float innerThreshold, | 87 float innerThreshold, |
| 90 float outerThreshold) | 88 float outerThreshold) |
| 91 : fInnerThreshold(innerThreshold) | 89 : fInnerThreshold(innerThreshold) |
| 92 , fOuterThreshold(outerThreshold) | 90 , fOuterThreshold(outerThreshold) |
| 93 , fImageCoordTransform(kLocal_GrCoordSet, | 91 , fImageCoordTransform(kLocal_GrCoordSet, |
| 94 GrCoordTransform::MakeDivByTextureWHMatrix(textur
e), texture) | 92 GrCoordTransform::MakeDivByTextureWHMatrix(textur
e), texture) |
| 95 , fImageTextureAccess(texture) | 93 , fImageTextureAccess(texture) |
| 96 , fMaskCoordTransform(kLocal_GrCoordSet, | 94 , fMaskCoordTransform(kLocal_GrCoordSet, |
| 97 GrCoordTransform::MakeDivByTextureWHMatrix(maskTex
ture), maskTexture) | 95 GrCoordTransform::MakeDivByTextureWHMatrix(maskTex
ture), maskTexture) |
| 98 , fMaskTextureAccess(maskTexture) { | 96 , fMaskTextureAccess(maskTexture) { |
| 99 this->addCoordTransform(&fImageCoordTransform); | 97 this->addCoordTransform(&fImageCoordTransform); |
| 100 this->addTextureAccess(&fImageTextureAccess); | 98 this->addTextureAccess(&fImageTextureAccess); |
| 101 this->addCoordTransform(&fMaskCoordTransform); | 99 this->addCoordTransform(&fMaskCoordTransform); |
| 102 this->addTextureAccess(&fMaskTextureAccess); | 100 this->addTextureAccess(&fMaskTextureAccess); |
| 103 } | 101 } |
| 104 | 102 |
| 105 virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE; | 103 virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE; |
| 106 | 104 |
| 105 virtual void onGetConstantColorComponents(GrColor* color, uint32_t* validFla
gs, |
| 106 bool* isSingleComponent) const SK_
OVERRIDE; |
| 107 |
| 107 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 108 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
| 108 | 109 |
| 109 float fInnerThreshold; | 110 float fInnerThreshold; |
| 110 float fOuterThreshold; | 111 float fOuterThreshold; |
| 111 GrCoordTransform fImageCoordTransform; | 112 GrCoordTransform fImageCoordTransform; |
| 112 GrTextureAccess fImageTextureAccess; | 113 GrTextureAccess fImageTextureAccess; |
| 113 GrCoordTransform fMaskCoordTransform; | 114 GrCoordTransform fMaskCoordTransform; |
| 114 GrTextureAccess fMaskTextureAccess; | 115 GrTextureAccess fMaskTextureAccess; |
| 115 | 116 |
| 116 typedef GrFragmentProcessor INHERITED; | 117 typedef GrFragmentProcessor INHERITED; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 return GrTBackendFragmentProcessorFactory<AlphaThresholdEffect>::getInstance
(); | 222 return GrTBackendFragmentProcessorFactory<AlphaThresholdEffect>::getInstance
(); |
| 222 } | 223 } |
| 223 | 224 |
| 224 bool AlphaThresholdEffect::onIsEqual(const GrProcessor& sBase) const { | 225 bool AlphaThresholdEffect::onIsEqual(const GrProcessor& sBase) const { |
| 225 const AlphaThresholdEffect& s = sBase.cast<AlphaThresholdEffect>(); | 226 const AlphaThresholdEffect& s = sBase.cast<AlphaThresholdEffect>(); |
| 226 return (this->texture(0) == s.texture(0) && | 227 return (this->texture(0) == s.texture(0) && |
| 227 this->fInnerThreshold == s.fInnerThreshold && | 228 this->fInnerThreshold == s.fInnerThreshold && |
| 228 this->fOuterThreshold == s.fOuterThreshold); | 229 this->fOuterThreshold == s.fOuterThreshold); |
| 229 } | 230 } |
| 230 | 231 |
| 231 void AlphaThresholdEffect::getConstantColorComponents(GrColor* color, uint32_t*
validFlags) const { | 232 void AlphaThresholdEffect::onGetConstantColorComponents(GrColor* color, uint32_t
* validFlags, |
| 233 bool* isSingleComponent)
const { |
| 232 if ((*validFlags & kA_GrColorComponentFlag) && 0xFF == GrColorUnpackA(*color
) && | 234 if ((*validFlags & kA_GrColorComponentFlag) && 0xFF == GrColorUnpackA(*color
) && |
| 233 GrPixelConfigIsOpaque(this->texture(0)->config())) { | 235 GrPixelConfigIsOpaque(this->texture(0)->config())) { |
| 234 *validFlags = kA_GrColorComponentFlag; | 236 *validFlags = kA_GrColorComponentFlag; |
| 235 } else { | 237 } else { |
| 236 *validFlags = 0; | 238 *validFlags = 0; |
| 237 } | 239 } |
| 238 } | 240 } |
| 239 | 241 |
| 240 #endif | 242 #endif |
| 241 | 243 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 (U8CPU)(SkColorGetG(source) *
scale), | 381 (U8CPU)(SkColorGetG(source) *
scale), |
| 380 (U8CPU)(SkColorGetB(source) *
scale)); | 382 (U8CPU)(SkColorGetB(source) *
scale)); |
| 381 } | 383 } |
| 382 } | 384 } |
| 383 dptr[y * dst->width() + x] = output_color; | 385 dptr[y * dst->width() + x] = output_color; |
| 384 } | 386 } |
| 385 } | 387 } |
| 386 | 388 |
| 387 return true; | 389 return true; |
| 388 } | 390 } |
| OLD | NEW |