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

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

Issue 1852113003: switch maskfilters to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 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/SkBlurDrawLooper.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 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 "SkBlurMaskFilter.h" 8 #include "SkBlurMaskFilter.h"
9 #include "SkBlurMask.h" 9 #include "SkBlurMask.h"
10 #include "SkGpuBlurUtils.h" 10 #include "SkGpuBlurUtils.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 return SkMinScalar(xformedSigma, kMAX_BLUR_SIGMA); 116 return SkMinScalar(xformedSigma, kMAX_BLUR_SIGMA);
117 } 117 }
118 118
119 friend class SkBlurMaskFilter; 119 friend class SkBlurMaskFilter;
120 120
121 typedef SkMaskFilter INHERITED; 121 typedef SkMaskFilter INHERITED;
122 }; 122 };
123 123
124 const SkScalar SkBlurMaskFilterImpl::kMAX_BLUR_SIGMA = SkIntToScalar(128); 124 const SkScalar SkBlurMaskFilterImpl::kMAX_BLUR_SIGMA = SkIntToScalar(128);
125 125
126 SkMaskFilter* SkBlurMaskFilter::Create(SkBlurStyle style, SkScalar sigma, uint32 _t flags) { 126 sk_sp<SkMaskFilter> SkBlurMaskFilter::Make(SkBlurStyle style, SkScalar sigma, ui nt32_t flags) {
127 if (!SkScalarIsFinite(sigma) || sigma <= 0) { 127 if (!SkScalarIsFinite(sigma) || sigma <= 0) {
128 return nullptr; 128 return nullptr;
129 } 129 }
130 if ((unsigned)style > (unsigned)kLastEnum_SkBlurStyle) { 130 if ((unsigned)style > (unsigned)kLastEnum_SkBlurStyle) {
131 return nullptr; 131 return nullptr;
132 } 132 }
133 if (flags > SkBlurMaskFilter::kAll_BlurFlag) { 133 if (flags > SkBlurMaskFilter::kAll_BlurFlag) {
134 return nullptr; 134 return nullptr;
135 } 135 }
136 return new SkBlurMaskFilterImpl(sigma, style, flags); 136 return sk_sp<SkMaskFilter>(new SkBlurMaskFilterImpl(sigma, style, flags));
137 } 137 }
138 138
139 /////////////////////////////////////////////////////////////////////////////// 139 ///////////////////////////////////////////////////////////////////////////////
140 140
141 SkBlurMaskFilterImpl::SkBlurMaskFilterImpl(SkScalar sigma, SkBlurStyle style, ui nt32_t flags) 141 SkBlurMaskFilterImpl::SkBlurMaskFilterImpl(SkScalar sigma, SkBlurStyle style, ui nt32_t flags)
142 : fSigma(sigma) 142 : fSigma(sigma)
143 , fBlurStyle(style) 143 , fBlurStyle(style)
144 , fBlurFlags(flags) { 144 , fBlurFlags(flags) {
145 SkASSERT(fSigma > 0); 145 SkASSERT(fSigma > 0);
146 SkASSERT((unsigned)style <= kLastEnum_SkBlurStyle); 146 SkASSERT((unsigned)style <= kLastEnum_SkBlurStyle);
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 579
580 dst->set(src.fLeft - pad, src.fTop - pad, 580 dst->set(src.fLeft - pad, src.fTop - pad,
581 src.fRight + pad, src.fBottom + pad); 581 src.fRight + pad, src.fBottom + pad);
582 } 582 }
583 583
584 sk_sp<SkFlattenable> SkBlurMaskFilterImpl::CreateProc(SkReadBuffer& buffer) { 584 sk_sp<SkFlattenable> SkBlurMaskFilterImpl::CreateProc(SkReadBuffer& buffer) {
585 const SkScalar sigma = buffer.readScalar(); 585 const SkScalar sigma = buffer.readScalar();
586 const unsigned style = buffer.readUInt(); 586 const unsigned style = buffer.readUInt();
587 const unsigned flags = buffer.readUInt(); 587 const unsigned flags = buffer.readUInt();
588 if (style <= kLastEnum_SkBlurStyle) { 588 if (style <= kLastEnum_SkBlurStyle) {
589 return sk_sp<SkFlattenable>(SkBlurMaskFilter::Create((SkBlurStyle)style, sigma, flags)); 589 return SkBlurMaskFilter::Make((SkBlurStyle)style, sigma, flags);
590 } 590 }
591 return nullptr; 591 return nullptr;
592 } 592 }
593 593
594 void SkBlurMaskFilterImpl::flatten(SkWriteBuffer& buffer) const { 594 void SkBlurMaskFilterImpl::flatten(SkWriteBuffer& buffer) const {
595 buffer.writeScalar(fSigma); 595 buffer.writeScalar(fSigma);
596 buffer.writeUInt(fBlurStyle); 596 buffer.writeUInt(fBlurStyle);
597 buffer.writeUInt(fBlurFlags); 597 buffer.writeUInt(fBlurFlags);
598 } 598 }
599 599
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after
1308 } else { 1308 } else {
1309 str->append("None"); 1309 str->append("None");
1310 } 1310 }
1311 str->append("))"); 1311 str->append("))");
1312 } 1312 }
1313 #endif 1313 #endif
1314 1314
1315 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter) 1315 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkBlurMaskFilter)
1316 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl) 1316 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkBlurMaskFilterImpl)
1317 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 1317 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « src/effects/SkBlurDrawLooper.cpp ('k') | src/effects/SkEmbossMaskFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698