| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 , fImageTextureAccess(texture) | 93 , fImageTextureAccess(texture) |
| 94 , fMaskCoordTransform(kLocal_GrCoordSet, | 94 , fMaskCoordTransform(kLocal_GrCoordSet, |
| 95 GrCoordTransform::MakeDivByTextureWHMatrix(maskTex
ture), maskTexture) | 95 GrCoordTransform::MakeDivByTextureWHMatrix(maskTex
ture), maskTexture) |
| 96 , fMaskTextureAccess(maskTexture) { | 96 , fMaskTextureAccess(maskTexture) { |
| 97 this->addCoordTransform(&fImageCoordTransform); | 97 this->addCoordTransform(&fImageCoordTransform); |
| 98 this->addTextureAccess(&fImageTextureAccess); | 98 this->addTextureAccess(&fImageTextureAccess); |
| 99 this->addCoordTransform(&fMaskCoordTransform); | 99 this->addCoordTransform(&fMaskCoordTransform); |
| 100 this->addTextureAccess(&fMaskTextureAccess); | 100 this->addTextureAccess(&fMaskTextureAccess); |
| 101 } | 101 } |
| 102 | 102 |
| 103 virtual bool onIsEqual(const GrProcessor&) const SK_OVERRIDE; | 103 virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE; |
| 104 | 104 |
| 105 virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERR
IDE; | 105 virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERR
IDE; |
| 106 | 106 |
| 107 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 107 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
| 108 | 108 |
| 109 float fInnerThreshold; | 109 float fInnerThreshold; |
| 110 float fOuterThreshold; | 110 float fOuterThreshold; |
| 111 GrCoordTransform fImageCoordTransform; | 111 GrCoordTransform fImageCoordTransform; |
| 112 GrTextureAccess fImageTextureAccess; | 112 GrTextureAccess fImageTextureAccess; |
| 113 GrCoordTransform fMaskCoordTransform; | 113 GrCoordTransform fMaskCoordTransform; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 float outer_thresh = random->nextUScalar1(); | 214 float outer_thresh = random->nextUScalar1(); |
| 215 return AlphaThresholdEffect::Create(bmpTex, maskTex, inner_thresh, outer_thr
esh); | 215 return AlphaThresholdEffect::Create(bmpTex, maskTex, inner_thresh, outer_thr
esh); |
| 216 } | 216 } |
| 217 | 217 |
| 218 /////////////////////////////////////////////////////////////////////////////// | 218 /////////////////////////////////////////////////////////////////////////////// |
| 219 | 219 |
| 220 const GrBackendFragmentProcessorFactory& AlphaThresholdEffect::getFactory() cons
t { | 220 const GrBackendFragmentProcessorFactory& AlphaThresholdEffect::getFactory() cons
t { |
| 221 return GrTBackendFragmentProcessorFactory<AlphaThresholdEffect>::getInstance
(); | 221 return GrTBackendFragmentProcessorFactory<AlphaThresholdEffect>::getInstance
(); |
| 222 } | 222 } |
| 223 | 223 |
| 224 bool AlphaThresholdEffect::onIsEqual(const GrProcessor& sBase) const { | 224 bool AlphaThresholdEffect::onIsEqual(const GrFragmentProcessor& sBase) const { |
| 225 const AlphaThresholdEffect& s = sBase.cast<AlphaThresholdEffect>(); | 225 const AlphaThresholdEffect& s = sBase.cast<AlphaThresholdEffect>(); |
| 226 return (this->texture(0) == s.texture(0) && | 226 return (this->texture(0) == s.texture(0) && |
| 227 this->fInnerThreshold == s.fInnerThreshold && | 227 this->fInnerThreshold == s.fInnerThreshold && |
| 228 this->fOuterThreshold == s.fOuterThreshold); | 228 this->fOuterThreshold == s.fOuterThreshold); |
| 229 } | 229 } |
| 230 | 230 |
| 231 void AlphaThresholdEffect::onComputeInvariantOutput(InvariantOutput* inout) cons
t { | 231 void AlphaThresholdEffect::onComputeInvariantOutput(InvariantOutput* inout) cons
t { |
| 232 if (GrPixelConfigIsOpaque(this->texture(0)->config()) && fOuterThreshold >=
1.f) { | 232 if (GrPixelConfigIsOpaque(this->texture(0)->config()) && fOuterThreshold >=
1.f) { |
| 233 inout->mulByUnknownOpaqueColor(); | 233 inout->mulByUnknownOpaqueColor(); |
| 234 } else { | 234 } else { |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 (U8CPU)(SkColorGetG(source) *
scale), | 378 (U8CPU)(SkColorGetG(source) *
scale), |
| 379 (U8CPU)(SkColorGetB(source) *
scale)); | 379 (U8CPU)(SkColorGetB(source) *
scale)); |
| 380 } | 380 } |
| 381 } | 381 } |
| 382 dptr[y * dst->width() + x] = output_color; | 382 dptr[y * dst->width() + x] = output_color; |
| 383 } | 383 } |
| 384 } | 384 } |
| 385 | 385 |
| 386 return true; | 386 return true; |
| 387 } | 387 } |
| OLD | NEW |