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

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

Issue 395603002: Simplify flattening to just write enough to call the factory (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 4 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/effects/SkBlurImageFilter.cpp ('k') | src/effects/SkColorFilterImageFilter.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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 SkBlurMaskFilterImpl(SkReadBuffer&); 101 SkBlurMaskFilterImpl(SkReadBuffer&);
102 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; 102 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
103 103
104 SkScalar computeXformedSigma(const SkMatrix& ctm) const { 104 SkScalar computeXformedSigma(const SkMatrix& ctm) const {
105 bool ignoreTransform = SkToBool(fBlurFlags & SkBlurMaskFilter::kIgnoreTr ansform_BlurFlag); 105 bool ignoreTransform = SkToBool(fBlurFlags & SkBlurMaskFilter::kIgnoreTr ansform_BlurFlag);
106 106
107 SkScalar xformedSigma = ignoreTransform ? fSigma : ctm.mapRadius(fSigma) ; 107 SkScalar xformedSigma = ignoreTransform ? fSigma : ctm.mapRadius(fSigma) ;
108 return SkMinScalar(xformedSigma, kMAX_BLUR_SIGMA); 108 return SkMinScalar(xformedSigma, kMAX_BLUR_SIGMA);
109 } 109 }
110 110
111 friend class SkBlurMaskFilter;
112
111 typedef SkMaskFilter INHERITED; 113 typedef SkMaskFilter INHERITED;
112 }; 114 };
113 115
114 const SkScalar SkBlurMaskFilterImpl::kMAX_BLUR_SIGMA = SkIntToScalar(128); 116 const SkScalar SkBlurMaskFilterImpl::kMAX_BLUR_SIGMA = SkIntToScalar(128);
115 117
116 SkMaskFilter* SkBlurMaskFilter::Create(SkBlurStyle style, SkScalar sigma, uint32 _t flags) { 118 SkMaskFilter* SkBlurMaskFilter::Create(SkBlurStyle style, SkScalar sigma, uint32 _t flags) {
117 if (!SkScalarIsFinite(sigma) || sigma <= 0) { 119 if (!SkScalarIsFinite(sigma) || sigma <= 0) {
118 return NULL; 120 return NULL;
119 } 121 }
120 if ((unsigned)style > (unsigned)kLastEnum_SkBlurStyle) { 122 if ((unsigned)style > (unsigned)kLastEnum_SkBlurStyle) {
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 } 517 }
516 518
517 void SkBlurMaskFilterImpl::computeFastBounds(const SkRect& src, 519 void SkBlurMaskFilterImpl::computeFastBounds(const SkRect& src,
518 SkRect* dst) const { 520 SkRect* dst) const {
519 SkScalar pad = 3.0f * fSigma; 521 SkScalar pad = 3.0f * fSigma;
520 522
521 dst->set(src.fLeft - pad, src.fTop - pad, 523 dst->set(src.fLeft - pad, src.fTop - pad,
522 src.fRight + pad, src.fBottom + pad); 524 src.fRight + pad, src.fBottom + pad);
523 } 525 }
524 526
525 SkBlurMaskFilterImpl::SkBlurMaskFilterImpl(SkReadBuffer& buffer) 527 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
526 : SkMaskFilter(buffer) { 528 SkBlurMaskFilterImpl::SkBlurMaskFilterImpl(SkReadBuffer& buffer) : SkMaskFilter( buffer) {
527 fSigma = buffer.readScalar(); 529 fSigma = buffer.readScalar();
528 fBlurStyle = (SkBlurStyle)buffer.readInt(); 530 fBlurStyle = (SkBlurStyle)buffer.readInt();
529 fBlurFlags = buffer.readUInt() & SkBlurMaskFilter::kAll_BlurFlag; 531 fBlurFlags = buffer.readUInt() & SkBlurMaskFilter::kAll_BlurFlag;
530 SkASSERT(fSigma > 0); 532 SkASSERT(fSigma > 0);
531 SkASSERT((unsigned)fBlurStyle <= kLastEnum_SkBlurStyle); 533 SkASSERT((unsigned)fBlurStyle <= kLastEnum_SkBlurStyle);
532 } 534 }
535 #endif
536
537 SkFlattenable* SkBlurMaskFilterImpl::CreateProc(SkReadBuffer& buffer) {
538 const SkScalar sigma = buffer.readScalar();
539 const unsigned style = buffer.readUInt();
540 const unsigned flags = buffer.readUInt();
541 if (style <= kLastEnum_SkBlurStyle) {
542 return SkBlurMaskFilter::Create((SkBlurStyle)style, sigma, flags);
543 }
544 return NULL;
545 }
533 546
534 void SkBlurMaskFilterImpl::flatten(SkWriteBuffer& buffer) const { 547 void SkBlurMaskFilterImpl::flatten(SkWriteBuffer& buffer) const {
535 this->INHERITED::flatten(buffer);
536 buffer.writeScalar(fSigma); 548 buffer.writeScalar(fSigma);
537 buffer.writeInt(fBlurStyle); 549 buffer.writeUInt(fBlurStyle);
538 buffer.writeUInt(fBlurFlags); 550 buffer.writeUInt(fBlurFlags);
539 } 551 }
540 552
541 #if SK_SUPPORT_GPU 553 #if SK_SUPPORT_GPU
542 554
543 class GrGLRectBlurEffect; 555 class GrGLRectBlurEffect;
544 556
545 class GrRectBlurEffect : public GrEffect { 557 class GrRectBlurEffect : public GrEffect {
546 public: 558 public:
547 virtual ~GrRectBlurEffect(); 559 virtual ~GrRectBlurEffect();
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 } else { 1216 } else {
1205 str->append("None"); 1217 str->append("None");
1206 } 1218 }
1207 str->append("))"); 1219 str->append("))");
1208 } 1220 }
1209 #endif 1221 #endif
1210 1222
1211 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) 1223 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter)
1212 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) 1224 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl)
1213 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 1225 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « src/effects/SkBlurImageFilter.cpp ('k') | src/effects/SkColorFilterImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698