Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(311)

Side by Side Diff: src/effects/SkAlphaThresholdFilter.cpp

Issue 608253002: Add isSingleComponent bool to getConstantColorComponent (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix isSolidWhite Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkXfermode.cpp ('k') | src/effects/SkArithmeticMode.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERR IDE;
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;
114 GrTextureAccess fMaskTextureAccess; 114 GrTextureAccess fMaskTextureAccess;
115 115
116 typedef GrFragmentProcessor INHERITED; 116 typedef GrFragmentProcessor INHERITED;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 GrProcessor& 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::getConstantColorComponents(GrColor* color, uint32_t* validFlags) const { 231 void AlphaThresholdEffect::onComputeInvariantOutput(InvariantOutput* inout) cons t {
232 if ((*validFlags & kA_GrColorComponentFlag) && 0xFF == GrColorUnpackA(*color ) && 232 if (inout->isOpaque() && GrPixelConfigIsOpaque(this->texture(0)->config())) {
233 GrPixelConfigIsOpaque(this->texture(0)->config())) { 233 inout->fValidFlags = kA_GrColorComponentFlag;
234 *validFlags = kA_GrColorComponentFlag;
235 } else { 234 } else {
236 *validFlags = 0; 235 inout->fValidFlags = 0;
237 } 236 }
237 inout->fIsSingleComponent = false;
238 } 238 }
239 239
240 #endif 240 #endif
241 241
242 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING 242 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
243 SkAlphaThresholdFilterImpl::SkAlphaThresholdFilterImpl(SkReadBuffer& buffer) 243 SkAlphaThresholdFilterImpl::SkAlphaThresholdFilterImpl(SkReadBuffer& buffer)
244 : INHERITED(1, buffer) { 244 : INHERITED(1, buffer) {
245 fInnerThreshold = buffer.readScalar(); 245 fInnerThreshold = buffer.readScalar();
246 fOuterThreshold = buffer.readScalar(); 246 fOuterThreshold = buffer.readScalar();
247 buffer.readRegion(&fRegion); 247 buffer.readRegion(&fRegion);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 (U8CPU)(SkColorGetG(source) * scale), 379 (U8CPU)(SkColorGetG(source) * scale),
380 (U8CPU)(SkColorGetB(source) * scale)); 380 (U8CPU)(SkColorGetB(source) * scale));
381 } 381 }
382 } 382 }
383 dptr[y * dst->width() + x] = output_color; 383 dptr[y * dst->width() + x] = output_color;
384 } 384 }
385 } 385 }
386 386
387 return true; 387 return true;
388 } 388 }
OLDNEW
« no previous file with comments | « src/core/SkXfermode.cpp ('k') | src/effects/SkArithmeticMode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698