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

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

Issue 1827433002: Reland of [2] of "switch colorfilters to sk_sp (patchset #11 id:200001 of https://codereview.chromium.o… (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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/SkShader.cpp ('k') | src/effects/SkColorCubeFilter.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 2011 Google Inc. 2 * Copyright 2011 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 "SkBlurDrawLooper.h" 8 #include "SkBlurDrawLooper.h"
9 #include "SkBlurMask.h" // just for SkBlurMask::ConvertRadiusToSigma 9 #include "SkBlurMask.h" // just for SkBlurMask::ConvertRadiusToSigma
10 #include "SkBlurMaskFilter.h" 10 #include "SkBlurMaskFilter.h"
(...skipping 26 matching lines...) Expand all
37 fBlur = SkBlurMaskFilter::Create(kNormal_SkBlurStyle, fSigma, flags); 37 fBlur = SkBlurMaskFilter::Create(kNormal_SkBlurStyle, fSigma, flags);
38 } else { 38 } else {
39 fBlur = nullptr; 39 fBlur = nullptr;
40 } 40 }
41 41
42 if (fBlurFlags & kOverrideColor_BlurFlag) { 42 if (fBlurFlags & kOverrideColor_BlurFlag) {
43 // Set alpha to 1 for the override since transparency will already 43 // Set alpha to 1 for the override since transparency will already
44 // be baked into the blurred mask. 44 // be baked into the blurred mask.
45 SkColor opaqueColor = SkColorSetA(fBlurColor, 255); 45 SkColor opaqueColor = SkColorSetA(fBlurColor, 255);
46 //The SrcIn xfer mode will multiply 'color' by the incoming alpha 46 //The SrcIn xfer mode will multiply 'color' by the incoming alpha
47 fColorFilter = SkColorFilter::CreateModeFilter(opaqueColor, 47 fColorFilter = SkColorFilter::MakeModeFilter(opaqueColor, SkXfermode::kS rcIn_Mode);
48 SkXfermode::kSrcIn_Mode);
49 } else { 48 } else {
50 fColorFilter = nullptr; 49 fColorFilter = nullptr;
51 } 50 }
52 } 51 }
53 52
54 void SkBlurDrawLooper::init(SkScalar sigma, SkScalar dx, SkScalar dy, 53 void SkBlurDrawLooper::init(SkScalar sigma, SkScalar dx, SkScalar dy,
55 SkColor color, uint32_t flags) { 54 SkColor color, uint32_t flags) {
56 fSigma = sigma; 55 fSigma = sigma;
57 fDx = dx; 56 fDx = dx;
58 fDy = dy; 57 fDy = dy;
(...skipping 15 matching lines...) Expand all
74 void SkBlurDrawLooper::flatten(SkWriteBuffer& buffer) const { 73 void SkBlurDrawLooper::flatten(SkWriteBuffer& buffer) const {
75 buffer.writeColor(fBlurColor); 74 buffer.writeColor(fBlurColor);
76 buffer.writeScalar(fSigma); 75 buffer.writeScalar(fSigma);
77 buffer.writeScalar(fDx); 76 buffer.writeScalar(fDx);
78 buffer.writeScalar(fDy); 77 buffer.writeScalar(fDy);
79 buffer.write32(fBlurFlags); 78 buffer.write32(fBlurFlags);
80 } 79 }
81 80
82 SkBlurDrawLooper::~SkBlurDrawLooper() { 81 SkBlurDrawLooper::~SkBlurDrawLooper() {
83 SkSafeUnref(fBlur); 82 SkSafeUnref(fBlur);
84 SkSafeUnref(fColorFilter);
85 } 83 }
86 84
87 bool SkBlurDrawLooper::asABlurShadow(BlurShadowRec* rec) const { 85 bool SkBlurDrawLooper::asABlurShadow(BlurShadowRec* rec) const {
88 if (fSigma <= 0 || (fBlurFlags & fBlurFlags & kIgnoreTransform_BlurFlag)) { 86 if (fSigma <= 0 || (fBlurFlags & fBlurFlags & kIgnoreTransform_BlurFlag)) {
89 return false; 87 return false;
90 } 88 }
91 89
92 if (rec) { 90 if (rec) {
93 rec->fSigma = fSigma; 91 rec->fSigma = fSigma;
94 rec->fColor = fBlurColor; 92 rec->fColor = fBlurColor;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 &needsSeparator); 173 &needsSeparator);
176 SkAddFlagToString(str, SkToBool(kHighQuality_BlurFlag & fBlurFlags), "Hi ghQuality", 174 SkAddFlagToString(str, SkToBool(kHighQuality_BlurFlag & fBlurFlags), "Hi ghQuality",
177 &needsSeparator); 175 &needsSeparator);
178 } 176 }
179 str->append(")"); 177 str->append(")");
180 178
181 // TODO: add optional "fBlurFilter->toString(str);" when SkMaskFilter::toStr ing is added 179 // TODO: add optional "fBlurFilter->toString(str);" when SkMaskFilter::toStr ing is added
182 // alternatively we could cache the radius in SkBlurDrawLooper and just add it here 180 // alternatively we could cache the radius in SkBlurDrawLooper and just add it here
183 } 181 }
184 #endif 182 #endif
OLDNEW
« no previous file with comments | « src/core/SkShader.cpp ('k') | src/effects/SkColorCubeFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698