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 outerThreshold)); | 69 outerThreshold)); |
70 } | 70 } |
71 | 71 |
72 virtual ~AlphaThresholdEffect() {}; | 72 virtual ~AlphaThresholdEffect() {}; |
73 | 73 |
74 const char* name() const override { return "Alpha Threshold"; } | 74 const char* name() const override { return "Alpha Threshold"; } |
75 | 75 |
76 float innerThreshold() const { return fInnerThreshold; } | 76 float innerThreshold() const { return fInnerThreshold; } |
77 float outerThreshold() const { return fOuterThreshold; } | 77 float outerThreshold() const { return fOuterThreshold; } |
78 | 78 |
79 void getGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const overri
de; | 79 void getGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const over
ride; |
80 | 80 |
81 GrGLFragmentProcessor* createGLInstance() const override; | 81 GrGLFragmentProcessor* createGLInstance() const override; |
82 | 82 |
83 private: | 83 private: |
84 AlphaThresholdEffect(GrTexture* texture, | 84 AlphaThresholdEffect(GrTexture* texture, |
85 GrTexture* maskTexture, | 85 GrTexture* maskTexture, |
86 float innerThreshold, | 86 float innerThreshold, |
87 float outerThreshold) | 87 float outerThreshold) |
88 : fInnerThreshold(innerThreshold) | 88 : fInnerThreshold(innerThreshold) |
89 , fOuterThreshold(outerThreshold) | 89 , fOuterThreshold(outerThreshold) |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 GrTexture** textures) { | 207 GrTexture** textures) { |
208 GrTexture* bmpTex = textures[GrProcessorUnitTest::kSkiaPMTextureIdx]; | 208 GrTexture* bmpTex = textures[GrProcessorUnitTest::kSkiaPMTextureIdx]; |
209 GrTexture* maskTex = textures[GrProcessorUnitTest::kAlphaTextureIdx]; | 209 GrTexture* maskTex = textures[GrProcessorUnitTest::kAlphaTextureIdx]; |
210 float inner_thresh = random->nextUScalar1(); | 210 float inner_thresh = random->nextUScalar1(); |
211 float outer_thresh = random->nextUScalar1(); | 211 float outer_thresh = random->nextUScalar1(); |
212 return AlphaThresholdEffect::Create(bmpTex, maskTex, inner_thresh, outer_thr
esh); | 212 return AlphaThresholdEffect::Create(bmpTex, maskTex, inner_thresh, outer_thr
esh); |
213 } | 213 } |
214 | 214 |
215 /////////////////////////////////////////////////////////////////////////////// | 215 /////////////////////////////////////////////////////////////////////////////// |
216 | 216 |
217 void AlphaThresholdEffect::getGLProcessorKey(const GrGLCaps& caps, | 217 void AlphaThresholdEffect::getGLProcessorKey(const GrGLSLCaps& caps, |
218 GrProcessorKeyBuilder* b) const { | 218 GrProcessorKeyBuilder* b) const { |
219 GrGLAlphaThresholdEffect::GenKey(*this, caps, b); | 219 GrGLAlphaThresholdEffect::GenKey(*this, caps, b); |
220 } | 220 } |
221 | 221 |
222 GrGLFragmentProcessor* AlphaThresholdEffect::createGLInstance() const { | 222 GrGLFragmentProcessor* AlphaThresholdEffect::createGLInstance() const { |
223 return SkNEW_ARGS(GrGLAlphaThresholdEffect, (*this)); | 223 return SkNEW_ARGS(GrGLAlphaThresholdEffect, (*this)); |
224 } | 224 } |
225 | 225 |
226 bool AlphaThresholdEffect::onIsEqual(const GrFragmentProcessor& sBase) const { | 226 bool AlphaThresholdEffect::onIsEqual(const GrFragmentProcessor& sBase) const { |
227 const AlphaThresholdEffect& s = sBase.cast<AlphaThresholdEffect>(); | 227 const AlphaThresholdEffect& s = sBase.cast<AlphaThresholdEffect>(); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 } | 377 } |
378 | 378 |
379 #ifndef SK_IGNORE_TO_STRING | 379 #ifndef SK_IGNORE_TO_STRING |
380 void SkAlphaThresholdFilterImpl::toString(SkString* str) const { | 380 void SkAlphaThresholdFilterImpl::toString(SkString* str) const { |
381 str->appendf("SkAlphaThresholdImageFilter: ("); | 381 str->appendf("SkAlphaThresholdImageFilter: ("); |
382 str->appendf("inner: %f outer: %f", fInnerThreshold, fOuterThreshold); | 382 str->appendf("inner: %f outer: %f", fInnerThreshold, fOuterThreshold); |
383 str->append(")"); | 383 str->append(")"); |
384 } | 384 } |
385 #endif | 385 #endif |
386 | 386 |
OLD | NEW |