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

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

Issue 253833002: move common blur types into central header (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: fix false -> null warning Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « src/effects/SkBlurMask.cpp ('k') | src/effects/SkEmbossMaskFilter.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 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "SkBlurMaskFilter.h" 9 #include "SkBlurMaskFilter.h"
10 #include "SkBlurMask.h" 10 #include "SkBlurMask.h"
(...skipping 11 matching lines...) Expand all
22 #include "GrTexture.h" 22 #include "GrTexture.h"
23 #include "GrEffect.h" 23 #include "GrEffect.h"
24 #include "gl/GrGLEffect.h" 24 #include "gl/GrGLEffect.h"
25 #include "effects/GrSimpleTextureEffect.h" 25 #include "effects/GrSimpleTextureEffect.h"
26 #include "GrTBackendEffectFactory.h" 26 #include "GrTBackendEffectFactory.h"
27 #include "SkGrPixelRef.h" 27 #include "SkGrPixelRef.h"
28 #endif 28 #endif
29 29
30 class SkBlurMaskFilterImpl : public SkMaskFilter { 30 class SkBlurMaskFilterImpl : public SkMaskFilter {
31 public: 31 public:
32 SkBlurMaskFilterImpl(SkScalar sigma, SkBlurMaskFilter::BlurStyle, uint32_t f lags); 32 SkBlurMaskFilterImpl(SkScalar sigma, SkBlurStyle, uint32_t flags);
33 33
34 // overrides from SkMaskFilter 34 // overrides from SkMaskFilter
35 virtual SkMask::Format getFormat() const SK_OVERRIDE; 35 virtual SkMask::Format getFormat() const SK_OVERRIDE;
36 virtual bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&, 36 virtual bool filterMask(SkMask* dst, const SkMask& src, const SkMatrix&,
37 SkIPoint* margin) const SK_OVERRIDE; 37 SkIPoint* margin) const SK_OVERRIDE;
38 38
39 #if SK_SUPPORT_GPU 39 #if SK_SUPPORT_GPU
40 virtual bool canFilterMaskGPU(const SkRect& devBounds, 40 virtual bool canFilterMaskGPU(const SkRect& devBounds,
41 const SkIRect& clipBounds, 41 const SkIRect& clipBounds,
42 const SkMatrix& ctm, 42 const SkMatrix& ctm,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 SkIPoint* margin, SkMask::CreateMode createMode) const; 75 SkIPoint* margin, SkMask::CreateMode createMode) const;
76 bool filterRRectMask(SkMask* dstM, const SkRRect& r, const SkMatrix& matrix, 76 bool filterRRectMask(SkMask* dstM, const SkRRect& r, const SkMatrix& matrix,
77 SkIPoint* margin, SkMask::CreateMode createMode) const; 77 SkIPoint* margin, SkMask::CreateMode createMode) const;
78 78
79 private: 79 private:
80 // To avoid unseemly allocation requests (esp. for finite platforms like 80 // To avoid unseemly allocation requests (esp. for finite platforms like
81 // handset) we limit the radius so something manageable. (as opposed to 81 // handset) we limit the radius so something manageable. (as opposed to
82 // a request like 10,000) 82 // a request like 10,000)
83 static const SkScalar kMAX_BLUR_SIGMA; 83 static const SkScalar kMAX_BLUR_SIGMA;
84 84
85 SkScalar fSigma; 85 SkScalar fSigma;
86 SkBlurMaskFilter::BlurStyle fBlurStyle; 86 SkBlurStyle fBlurStyle;
87 uint32_t fBlurFlags; 87 uint32_t fBlurFlags;
88 88
89 SkBlurMaskFilterImpl(SkReadBuffer&); 89 SkBlurMaskFilterImpl(SkReadBuffer&);
90 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; 90 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
91 91
92 SkScalar computeXformedSigma(const SkMatrix& ctm) const { 92 SkScalar computeXformedSigma(const SkMatrix& ctm) const {
93 bool ignoreTransform = SkToBool(fBlurFlags & SkBlurMaskFilter::kIgnoreTr ansform_BlurFlag); 93 bool ignoreTransform = SkToBool(fBlurFlags & SkBlurMaskFilter::kIgnoreTr ansform_BlurFlag);
94 94
95 SkScalar xformedSigma = ignoreTransform ? fSigma : ctm.mapRadius(fSigma) ; 95 SkScalar xformedSigma = ignoreTransform ? fSigma : ctm.mapRadius(fSigma) ;
96 return SkMinScalar(xformedSigma, kMAX_BLUR_SIGMA); 96 return SkMinScalar(xformedSigma, kMAX_BLUR_SIGMA);
97 } 97 }
98 98
99 typedef SkMaskFilter INHERITED; 99 typedef SkMaskFilter INHERITED;
100 }; 100 };
101 101
102 const SkScalar SkBlurMaskFilterImpl::kMAX_BLUR_SIGMA = SkIntToScalar(128); 102 const SkScalar SkBlurMaskFilterImpl::kMAX_BLUR_SIGMA = SkIntToScalar(128);
103 103
104 SkMaskFilter* SkBlurMaskFilter::Create(SkBlurStyle style, SkScalar sigma, uint32 _t flags) {
105 if (!(sigma > 0)) {
scroggo 2014/04/28 15:47:45 Can you add the comment (removed down below) about
106 return NULL;
107 }
108 if ((unsigned)style > (unsigned)kLastEnum_SkBlurStyle) {
109 return NULL;
110 }
111 if (flags > SkBlurMaskFilter::kAll_BlurFlag) {
112 return NULL;
113 }
114 return SkNEW_ARGS(SkBlurMaskFilterImpl, (sigma, style, flags));
115 }
116
117 #ifdef SK_SUPPORT_LEGACY_BLURMASKFILTER_STYLE
104 SkMaskFilter* SkBlurMaskFilter::Create(SkScalar radius, 118 SkMaskFilter* SkBlurMaskFilter::Create(SkScalar radius,
105 SkBlurMaskFilter::BlurStyle style, 119 SkBlurMaskFilter::BlurStyle style,
106 uint32_t flags) { 120 uint32_t flags) {
107 // use !(radius > 0) instead of radius <= 0 to reject NaN values
108 if (!(radius > 0) || (unsigned)style >= SkBlurMaskFilter::kBlurStyleCount
109 || flags > SkBlurMaskFilter::kAll_BlurFlag) {
110 return NULL;
111 }
112
113 SkScalar sigma = SkBlurMask::ConvertRadiusToSigma(radius); 121 SkScalar sigma = SkBlurMask::ConvertRadiusToSigma(radius);
114 122 return Create((SkBlurStyle)style, sigma, flags);
115 return SkNEW_ARGS(SkBlurMaskFilterImpl, (sigma, style, flags));
116 } 123 }
117 124
118 SkMaskFilter* SkBlurMaskFilter::Create(SkBlurMaskFilter::BlurStyle style, 125 SkMaskFilter* SkBlurMaskFilter::Create(SkBlurMaskFilter::BlurStyle style,
119 SkScalar sigma, 126 SkScalar sigma,
120 uint32_t flags) { 127 uint32_t flags) {
121 // use !(sigma > 0) instead of sigma <= 0 to reject NaN values 128 return Create((SkBlurStyle)style, sigma, flags);
122 if (!(sigma > 0) || (unsigned)style >= SkBlurMaskFilter::kBlurStyleCount
123 || flags > SkBlurMaskFilter::kAll_BlurFlag) {
124 return NULL;
125 }
126
127 return SkNEW_ARGS(SkBlurMaskFilterImpl, (sigma, style, flags));
128 } 129 }
130 #endif
129 131
130 /////////////////////////////////////////////////////////////////////////////// 132 ///////////////////////////////////////////////////////////////////////////////
131 133
132 SkBlurMaskFilterImpl::SkBlurMaskFilterImpl(SkScalar sigma, 134 SkBlurMaskFilterImpl::SkBlurMaskFilterImpl(SkScalar sigma, SkBlurStyle style, ui nt32_t flags)
133 SkBlurMaskFilter::BlurStyle style, 135 : fSigma(sigma)
134 uint32_t flags) 136 , fBlurStyle(style)
135 : fSigma(sigma), fBlurStyle(style), fBlurFlags(flags) { 137 , fBlurFlags(flags) {
136 #if 0 138 SkASSERT(fSigma > 0);
137 fGamma = NULL; 139 SkASSERT((unsigned)style <= kLastEnum_SkBlurStyle);
138 if (gammaScale) {
139 fGamma = new U8[256];
140 if (gammaScale > 0)
141 SkBlurMask::BuildSqrGamma(fGamma, gammaScale);
142 else
143 SkBlurMask::BuildSqrtGamma(fGamma, -gammaScale);
144 }
145 #endif
146 SkASSERT(fSigma >= 0);
147 SkASSERT((unsigned)style < SkBlurMaskFilter::kBlurStyleCount);
148 SkASSERT(flags <= SkBlurMaskFilter::kAll_BlurFlag); 140 SkASSERT(flags <= SkBlurMaskFilter::kAll_BlurFlag);
149 } 141 }
150 142
151 SkMask::Format SkBlurMaskFilterImpl::getFormat() const { 143 SkMask::Format SkBlurMaskFilterImpl::getFormat() const {
152 return SkMask::kA8_Format; 144 return SkMask::kA8_Format;
153 } 145 }
154 146
155 bool SkBlurMaskFilterImpl::filterMask(SkMask* dst, const SkMask& src, 147 bool SkBlurMaskFilterImpl::filterMask(SkMask* dst, const SkMask& src,
156 const SkMatrix& matrix, 148 const SkMatrix& matrix,
157 SkIPoint* margin) const{ 149 SkIPoint* margin) const{
158 SkScalar sigma = this->computeXformedSigma(matrix); 150 SkScalar sigma = this->computeXformedSigma(matrix);
159 151
160 SkBlurMask::Quality blurQuality = 152 SkBlurQuality blurQuality =
161 (fBlurFlags & SkBlurMaskFilter::kHighQuality_BlurFlag) ? 153 (fBlurFlags & SkBlurMaskFilter::kHighQuality_BlurFlag) ?
162 SkBlurMask::kHigh_Quality : SkBlurMask::kLow_Quality; 154 kHigh_SkBlurQuality : kLow_SkBlurQuality;
163 155
164 return SkBlurMask::BoxBlur(dst, src, sigma, (SkBlurMask::Style)fBlurStyle, 156 return SkBlurMask::BoxBlur(dst, src, sigma, fBlurStyle, blurQuality, margin) ;
165 blurQuality, margin);
166 } 157 }
167 158
168 bool SkBlurMaskFilterImpl::filterRectMask(SkMask* dst, const SkRect& r, 159 bool SkBlurMaskFilterImpl::filterRectMask(SkMask* dst, const SkRect& r,
169 const SkMatrix& matrix, 160 const SkMatrix& matrix,
170 SkIPoint* margin, SkMask::CreateMode c reateMode) const{ 161 SkIPoint* margin, SkMask::CreateMode c reateMode) const{
171 SkScalar sigma = computeXformedSigma(matrix); 162 SkScalar sigma = computeXformedSigma(matrix);
172 163
173 return SkBlurMask::BlurRect(sigma, dst, r, (SkBlurMask::Style)fBlurStyle, 164 return SkBlurMask::BlurRect(sigma, dst, r, fBlurStyle,
174 margin, createMode); 165 margin, createMode);
175 } 166 }
176 167
177 bool SkBlurMaskFilterImpl::filterRRectMask(SkMask* dst, const SkRRect& r, 168 bool SkBlurMaskFilterImpl::filterRRectMask(SkMask* dst, const SkRRect& r,
178 const SkMatrix& matrix, 169 const SkMatrix& matrix,
179 SkIPoint* margin, SkMask::CreateMode c reateMode) const{ 170 SkIPoint* margin, SkMask::CreateMode c reateMode) const{
180 SkScalar sigma = computeXformedSigma(matrix); 171 SkScalar sigma = computeXformedSigma(matrix);
181 172
182 return SkBlurMask::BlurRRect(sigma, dst, r, (SkBlurMask::Style)fBlurStyle, 173 return SkBlurMask::BlurRRect(sigma, dst, r, fBlurStyle,
183 margin, createMode); 174 margin, createMode);
184 } 175 }
185 176
186 #include "SkCanvas.h" 177 #include "SkCanvas.h"
187 178
188 static bool prepare_to_draw_into_mask(const SkRect& bounds, SkMask* mask) { 179 static bool prepare_to_draw_into_mask(const SkRect& bounds, SkMask* mask) {
189 SkASSERT(mask != NULL); 180 SkASSERT(mask != NULL);
190 181
191 bounds.roundOut(&mask->fBounds); 182 bounds.roundOut(&mask->fBounds);
192 mask->fRowBytes = SkAlign4(mask->fBounds.width()); 183 mask->fRowBytes = SkAlign4(mask->fBounds.width());
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 281
291 // These three can take advantage of this fast path. 282 // These three can take advantage of this fast path.
292 case SkRRect::kSimple_Type: 283 case SkRRect::kSimple_Type:
293 case SkRRect::kNinePatch_Type: 284 case SkRRect::kNinePatch_Type:
294 case SkRRect::kComplex_Type: 285 case SkRRect::kComplex_Type:
295 break; 286 break;
296 } 287 }
297 288
298 // TODO: report correct metrics for innerstyle, where we do not grow the 289 // TODO: report correct metrics for innerstyle, where we do not grow the
299 // total bounds, but we do need an inset the size of our blur-radius 290 // total bounds, but we do need an inset the size of our blur-radius
300 if (SkBlurMaskFilter::kInner_BlurStyle == fBlurStyle) { 291 if (kInner_SkBlurStyle == fBlurStyle) {
301 return kUnimplemented_FilterReturn; 292 return kUnimplemented_FilterReturn;
302 } 293 }
303 294
304 // TODO: take clipBounds into account to limit our coordinates up front 295 // TODO: take clipBounds into account to limit our coordinates up front
305 // for now, just skip too-large src rects (to take the old code path). 296 // for now, just skip too-large src rects (to take the old code path).
306 if (rect_exceeds(rrect.rect(), SkIntToScalar(32767))) { 297 if (rect_exceeds(rrect.rect(), SkIntToScalar(32767))) {
307 return kUnimplemented_FilterReturn; 298 return kUnimplemented_FilterReturn;
308 } 299 }
309 300
310 SkIPoint margin; 301 SkIPoint margin;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 SkBlurMaskFilterImpl::filterRectsToNine(const SkRect rects[], int count, 393 SkBlurMaskFilterImpl::filterRectsToNine(const SkRect rects[], int count,
403 const SkMatrix& matrix, 394 const SkMatrix& matrix,
404 const SkIRect& clipBounds, 395 const SkIRect& clipBounds,
405 NinePatch* patch) const { 396 NinePatch* patch) const {
406 if (count < 1 || count > 2) { 397 if (count < 1 || count > 2) {
407 return kUnimplemented_FilterReturn; 398 return kUnimplemented_FilterReturn;
408 } 399 }
409 400
410 // TODO: report correct metrics for innerstyle, where we do not grow the 401 // TODO: report correct metrics for innerstyle, where we do not grow the
411 // total bounds, but we do need an inset the size of our blur-radius 402 // total bounds, but we do need an inset the size of our blur-radius
412 if (SkBlurMaskFilter::kInner_BlurStyle == fBlurStyle || 403 if (kInner_SkBlurStyle == fBlurStyle || kOuter_SkBlurStyle == fBlurStyle) {
413 SkBlurMaskFilter::kOuter_BlurStyle == fBlurStyle) {
414 return kUnimplemented_FilterReturn; 404 return kUnimplemented_FilterReturn;
415 } 405 }
416 406
417 // TODO: take clipBounds into account to limit our coordinates up front 407 // TODO: take clipBounds into account to limit our coordinates up front
418 // for now, just skip too-large src rects (to take the old code path). 408 // for now, just skip too-large src rects (to take the old code path).
419 if (rect_exceeds(rects[0], SkIntToScalar(32767))) { 409 if (rect_exceeds(rects[0], SkIntToScalar(32767))) {
420 return kUnimplemented_FilterReturn; 410 return kUnimplemented_FilterReturn;
421 } 411 }
422 412
423 SkIPoint margin; 413 SkIPoint margin;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 SkRect* dst) const { 513 SkRect* dst) const {
524 SkScalar pad = 3.0f * fSigma; 514 SkScalar pad = 3.0f * fSigma;
525 515
526 dst->set(src.fLeft - pad, src.fTop - pad, 516 dst->set(src.fLeft - pad, src.fTop - pad,
527 src.fRight + pad, src.fBottom + pad); 517 src.fRight + pad, src.fBottom + pad);
528 } 518 }
529 519
530 SkBlurMaskFilterImpl::SkBlurMaskFilterImpl(SkReadBuffer& buffer) 520 SkBlurMaskFilterImpl::SkBlurMaskFilterImpl(SkReadBuffer& buffer)
531 : SkMaskFilter(buffer) { 521 : SkMaskFilter(buffer) {
532 fSigma = buffer.readScalar(); 522 fSigma = buffer.readScalar();
533 fBlurStyle = (SkBlurMaskFilter::BlurStyle)buffer.readInt(); 523 fBlurStyle = (SkBlurStyle)buffer.readInt();
534 fBlurFlags = buffer.readUInt() & SkBlurMaskFilter::kAll_BlurFlag; 524 fBlurFlags = buffer.readUInt() & SkBlurMaskFilter::kAll_BlurFlag;
535 SkASSERT(fSigma >= 0); 525 SkASSERT(fSigma > 0);
536 SkASSERT((unsigned)fBlurStyle < SkBlurMaskFilter::kBlurStyleCount); 526 SkASSERT((unsigned)fBlurStyle <= kLastEnum_SkBlurStyle);
537 } 527 }
538 528
539 void SkBlurMaskFilterImpl::flatten(SkWriteBuffer& buffer) const { 529 void SkBlurMaskFilterImpl::flatten(SkWriteBuffer& buffer) const {
540 this->INHERITED::flatten(buffer); 530 this->INHERITED::flatten(buffer);
541 buffer.writeScalar(fSigma); 531 buffer.writeScalar(fSigma);
542 buffer.writeInt(fBlurStyle); 532 buffer.writeInt(fBlurStyle);
543 buffer.writeUInt(fBlurFlags); 533 buffer.writeUInt(fBlurFlags);
544 } 534 }
545 535
546 #if SK_SUPPORT_GPU 536 #if SK_SUPPORT_GPU
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 float width = random->nextRangeF(200,300); 767 float width = random->nextRangeF(200,300);
778 float height = random->nextRangeF(200,300); 768 float height = random->nextRangeF(200,300);
779 return GrRectBlurEffect::Create(context, SkRect::MakeWH(width, height), sigm a); 769 return GrRectBlurEffect::Create(context, SkRect::MakeWH(width, height), sigm a);
780 } 770 }
781 771
782 772
783 bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrContext* context, 773 bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrContext* context,
784 GrPaint* grp, 774 GrPaint* grp,
785 const SkStrokeRec& strokeRec, 775 const SkStrokeRec& strokeRec,
786 const SkPath& path) const { 776 const SkPath& path) const {
787 if (fBlurStyle != SkBlurMaskFilter::kNormal_BlurStyle) { 777 if (fBlurStyle != kNormal_SkBlurStyle) {
788 return false; 778 return false;
789 } 779 }
790 780
791 SkRect rect; 781 SkRect rect;
792 if (!path.isRect(&rect)) { 782 if (!path.isRect(&rect)) {
793 return false; 783 return false;
794 } 784 }
795 785
796 if (!strokeRec.isFillStyle()) { 786 if (!strokeRec.isFillStyle()) {
797 return false; 787 return false;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 862
873 GrContext* context = src->getContext(); 863 GrContext* context = src->getContext();
874 864
875 GrContext::AutoWideOpenIdentityDraw awo(context, NULL); 865 GrContext::AutoWideOpenIdentityDraw awo(context, NULL);
876 866
877 SkScalar xformedSigma = this->computeXformedSigma(ctm); 867 SkScalar xformedSigma = this->computeXformedSigma(ctm);
878 SkASSERT(xformedSigma > 0); 868 SkASSERT(xformedSigma > 0);
879 869
880 // If we're doing a normal blur, we can clobber the pathTexture in the 870 // If we're doing a normal blur, we can clobber the pathTexture in the
881 // gaussianBlur. Otherwise, we need to save it for later compositing. 871 // gaussianBlur. Otherwise, we need to save it for later compositing.
882 bool isNormalBlur = (SkBlurMaskFilter::kNormal_BlurStyle == fBlurStyle); 872 bool isNormalBlur = (kNormal_SkBlurStyle == fBlurStyle);
883 *result = SkGpuBlurUtils::GaussianBlur(context, src, isNormalBlur && canOver writeSrc, 873 *result = SkGpuBlurUtils::GaussianBlur(context, src, isNormalBlur && canOver writeSrc,
884 clipRect, false, xformedSigma, xforme dSigma); 874 clipRect, false, xformedSigma, xforme dSigma);
885 if (NULL == *result) { 875 if (NULL == *result) {
886 return false; 876 return false;
887 } 877 }
888 878
889 if (!isNormalBlur) { 879 if (!isNormalBlur) {
890 context->setIdentityMatrix(); 880 context->setIdentityMatrix();
891 GrPaint paint; 881 GrPaint paint;
892 SkMatrix matrix; 882 SkMatrix matrix;
893 matrix.setIDiv(src->width(), src->height()); 883 matrix.setIDiv(src->width(), src->height());
894 // Blend pathTexture over blurTexture. 884 // Blend pathTexture over blurTexture.
895 GrContext::AutoRenderTarget art(context, (*result)->asRenderTarget()); 885 GrContext::AutoRenderTarget art(context, (*result)->asRenderTarget());
896 paint.addColorEffect(GrSimpleTextureEffect::Create(src, matrix))->unref( ); 886 paint.addColorEffect(GrSimpleTextureEffect::Create(src, matrix))->unref( );
897 if (SkBlurMaskFilter::kInner_BlurStyle == fBlurStyle) { 887 if (kInner_SkBlurStyle == fBlurStyle) {
898 // inner: dst = dst * src 888 // inner: dst = dst * src
899 paint.setBlendFunc(kDC_GrBlendCoeff, kZero_GrBlendCoeff); 889 paint.setBlendFunc(kDC_GrBlendCoeff, kZero_GrBlendCoeff);
900 } else if (SkBlurMaskFilter::kSolid_BlurStyle == fBlurStyle) { 890 } else if (kSolid_SkBlurStyle == fBlurStyle) {
901 // solid: dst = src + dst - src * dst 891 // solid: dst = src + dst - src * dst
902 // = (1 - dst) * src + 1 * dst 892 // = (1 - dst) * src + 1 * dst
903 paint.setBlendFunc(kIDC_GrBlendCoeff, kOne_GrBlendCoeff); 893 paint.setBlendFunc(kIDC_GrBlendCoeff, kOne_GrBlendCoeff);
904 } else if (SkBlurMaskFilter::kOuter_BlurStyle == fBlurStyle) { 894 } else if (kOuter_SkBlurStyle == fBlurStyle) {
905 // outer: dst = dst * (1 - src) 895 // outer: dst = dst * (1 - src)
906 // = 0 * src + (1 - src) * dst 896 // = 0 * src + (1 - src) * dst
907 paint.setBlendFunc(kZero_GrBlendCoeff, kISC_GrBlendCoeff); 897 paint.setBlendFunc(kZero_GrBlendCoeff, kISC_GrBlendCoeff);
908 } 898 }
909 context->drawRect(paint, clipRect); 899 context->drawRect(paint, clipRect);
910 } 900 }
911 901
912 return true; 902 return true;
913 } 903 }
914 904
915 #endif // SK_SUPPORT_GPU 905 #endif // SK_SUPPORT_GPU
916 906
917 907
918 #ifndef SK_IGNORE_TO_STRING 908 #ifndef SK_IGNORE_TO_STRING
919 void SkBlurMaskFilterImpl::toString(SkString* str) const { 909 void SkBlurMaskFilterImpl::toString(SkString* str) const {
920 str->append("SkBlurMaskFilterImpl: ("); 910 str->append("SkBlurMaskFilterImpl: (");
921 911
922 str->append("sigma: "); 912 str->append("sigma: ");
923 str->appendScalar(fSigma); 913 str->appendScalar(fSigma);
924 str->append(" "); 914 str->append(" ");
925 915
926 static const char* gStyleName[SkBlurMaskFilter::kBlurStyleCount] = { 916 static const char* gStyleName[kLastEnum_SkBlurStyle + 1] = {
927 "normal", "solid", "outer", "inner" 917 "normal", "solid", "outer", "inner"
928 }; 918 };
929 919
930 str->appendf("style: %s ", gStyleName[fBlurStyle]); 920 str->appendf("style: %s ", gStyleName[fBlurStyle]);
931 str->append("flags: ("); 921 str->append("flags: (");
932 if (fBlurFlags) { 922 if (fBlurFlags) {
933 bool needSeparator = false; 923 bool needSeparator = false;
934 SkAddFlagToString(str, 924 SkAddFlagToString(str,
935 SkToBool(fBlurFlags & SkBlurMaskFilter::kIgnoreTransfo rm_BlurFlag), 925 SkToBool(fBlurFlags & SkBlurMaskFilter::kIgnoreTransfo rm_BlurFlag),
936 "IgnoreXform", &needSeparator); 926 "IgnoreXform", &needSeparator);
937 SkAddFlagToString(str, 927 SkAddFlagToString(str,
938 SkToBool(fBlurFlags & SkBlurMaskFilter::kHighQuality_B lurFlag), 928 SkToBool(fBlurFlags & SkBlurMaskFilter::kHighQuality_B lurFlag),
939 "HighQuality", &needSeparator); 929 "HighQuality", &needSeparator);
940 } else { 930 } else {
941 str->append("None"); 931 str->append("None");
942 } 932 }
943 str->append("))"); 933 str->append("))");
944 } 934 }
945 #endif 935 #endif
946 936
947 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) 937 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter)
948 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) 938 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl)
949 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 939 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « src/effects/SkBlurMask.cpp ('k') | src/effects/SkEmbossMaskFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698