| 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 25 matching lines...) Expand all Loading... |
| 36 SkRegion fRegion; | 36 SkRegion fRegion; |
| 37 SkScalar fInnerThreshold; | 37 SkScalar fInnerThreshold; |
| 38 SkScalar fOuterThreshold; | 38 SkScalar fOuterThreshold; |
| 39 typedef SkImageFilter INHERITED; | 39 typedef SkImageFilter INHERITED; |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 SkImageFilter* SkAlphaThresholdFilter::Create(const SkRegion& region, | 42 SkImageFilter* SkAlphaThresholdFilter::Create(const SkRegion& region, |
| 43 SkScalar innerThreshold, | 43 SkScalar innerThreshold, |
| 44 SkScalar outerThreshold, | 44 SkScalar outerThreshold, |
| 45 SkImageFilter* input) { | 45 SkImageFilter* input) { |
| 46 return SkNEW_ARGS(SkAlphaThresholdFilterImpl, (region, innerThreshold, outer
Threshold, input)); | 46 return new SkAlphaThresholdFilterImpl(region, innerThreshold, outerThreshold
, input); |
| 47 } | 47 } |
| 48 | 48 |
| 49 #if SK_SUPPORT_GPU | 49 #if SK_SUPPORT_GPU |
| 50 #include "GrContext.h" | 50 #include "GrContext.h" |
| 51 #include "GrCoordTransform.h" | 51 #include "GrCoordTransform.h" |
| 52 #include "GrFragmentProcessor.h" | 52 #include "GrFragmentProcessor.h" |
| 53 #include "GrInvariantOutput.h" | 53 #include "GrInvariantOutput.h" |
| 54 #include "GrTextureAccess.h" | 54 #include "GrTextureAccess.h" |
| 55 #include "effects/GrPorterDuffXferProcessor.h" | 55 #include "effects/GrPorterDuffXferProcessor.h" |
| 56 | 56 |
| 57 #include "SkGr.h" | 57 #include "SkGr.h" |
| 58 | 58 |
| 59 #include "gl/GrGLFragmentProcessor.h" | 59 #include "gl/GrGLFragmentProcessor.h" |
| 60 #include "gl/builders/GrGLProgramBuilder.h" | 60 #include "gl/builders/GrGLProgramBuilder.h" |
| 61 | 61 |
| 62 class AlphaThresholdEffect : public GrFragmentProcessor { | 62 class AlphaThresholdEffect : public GrFragmentProcessor { |
| 63 | 63 |
| 64 public: | 64 public: |
| 65 static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager, | 65 static GrFragmentProcessor* Create(GrProcessorDataManager* procDataManager, |
| 66 GrTexture* texture, | 66 GrTexture* texture, |
| 67 GrTexture* maskTexture, | 67 GrTexture* maskTexture, |
| 68 float innerThreshold, | 68 float innerThreshold, |
| 69 float outerThreshold) { | 69 float outerThreshold) { |
| 70 return SkNEW_ARGS(AlphaThresholdEffect, (procDataManager, | 70 return new AlphaThresholdEffect(procDataManager, texture, maskTexture, i
nnerThreshold, |
| 71 texture, | 71 outerThreshold); |
| 72 maskTexture, | |
| 73 innerThreshold, | |
| 74 outerThreshold)); | |
| 75 } | 72 } |
| 76 | 73 |
| 77 virtual ~AlphaThresholdEffect() {}; | 74 virtual ~AlphaThresholdEffect() {}; |
| 78 | 75 |
| 79 const char* name() const override { return "Alpha Threshold"; } | 76 const char* name() const override { return "Alpha Threshold"; } |
| 80 | 77 |
| 81 float innerThreshold() const { return fInnerThreshold; } | 78 float innerThreshold() const { return fInnerThreshold; } |
| 82 float outerThreshold() const { return fOuterThreshold; } | 79 float outerThreshold() const { return fOuterThreshold; } |
| 83 | 80 |
| 84 private: | 81 private: |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 } | 205 } |
| 209 | 206 |
| 210 /////////////////////////////////////////////////////////////////////////////// | 207 /////////////////////////////////////////////////////////////////////////////// |
| 211 | 208 |
| 212 void AlphaThresholdEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, | 209 void AlphaThresholdEffect::onGetGLProcessorKey(const GrGLSLCaps& caps, |
| 213 GrProcessorKeyBuilder* b) const { | 210 GrProcessorKeyBuilder* b) const { |
| 214 GrGLAlphaThresholdEffect::GenKey(*this, caps, b); | 211 GrGLAlphaThresholdEffect::GenKey(*this, caps, b); |
| 215 } | 212 } |
| 216 | 213 |
| 217 GrGLFragmentProcessor* AlphaThresholdEffect::onCreateGLInstance() const { | 214 GrGLFragmentProcessor* AlphaThresholdEffect::onCreateGLInstance() const { |
| 218 return SkNEW_ARGS(GrGLAlphaThresholdEffect, (*this)); | 215 return new GrGLAlphaThresholdEffect(*this); |
| 219 } | 216 } |
| 220 | 217 |
| 221 bool AlphaThresholdEffect::onIsEqual(const GrFragmentProcessor& sBase) const { | 218 bool AlphaThresholdEffect::onIsEqual(const GrFragmentProcessor& sBase) const { |
| 222 const AlphaThresholdEffect& s = sBase.cast<AlphaThresholdEffect>(); | 219 const AlphaThresholdEffect& s = sBase.cast<AlphaThresholdEffect>(); |
| 223 return (this->fInnerThreshold == s.fInnerThreshold && | 220 return (this->fInnerThreshold == s.fInnerThreshold && |
| 224 this->fOuterThreshold == s.fOuterThreshold); | 221 this->fOuterThreshold == s.fOuterThreshold); |
| 225 } | 222 } |
| 226 | 223 |
| 227 void AlphaThresholdEffect::onComputeInvariantOutput(GrInvariantOutput* inout) co
nst { | 224 void AlphaThresholdEffect::onComputeInvariantOutput(GrInvariantOutput* inout) co
nst { |
| 228 if (GrPixelConfigIsAlphaOnly(this->texture(0)->config())) { | 225 if (GrPixelConfigIsAlphaOnly(this->texture(0)->config())) { |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 } | 372 } |
| 376 | 373 |
| 377 #ifndef SK_IGNORE_TO_STRING | 374 #ifndef SK_IGNORE_TO_STRING |
| 378 void SkAlphaThresholdFilterImpl::toString(SkString* str) const { | 375 void SkAlphaThresholdFilterImpl::toString(SkString* str) const { |
| 379 str->appendf("SkAlphaThresholdImageFilter: ("); | 376 str->appendf("SkAlphaThresholdImageFilter: ("); |
| 380 str->appendf("inner: %f outer: %f", fInnerThreshold, fOuterThreshold); | 377 str->appendf("inner: %f outer: %f", fInnerThreshold, fOuterThreshold); |
| 381 str->append(")"); | 378 str->append(")"); |
| 382 } | 379 } |
| 383 #endif | 380 #endif |
| 384 | 381 |
| OLD | NEW |