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

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

Issue 21835004: Blur refactoring (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Removed unneeded #includes Created 7 years, 3 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/core/SkPicture.cpp ('k') | src/effects/SkBlurMask.h » ('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 2011 Google Inc. 3 * Copyright 2011 Google Inc.
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 #include "SkBlurDrawLooper.h" 8 #include "SkBlurDrawLooper.h"
9 #include "SkBlurMask.h" // just for SkBlurMask::ConvertRadiusToSigma
9 #include "SkBlurMaskFilter.h" 10 #include "SkBlurMaskFilter.h"
10 #include "SkCanvas.h" 11 #include "SkCanvas.h"
11 #include "SkColorFilter.h" 12 #include "SkColorFilter.h"
12 #include "SkFlattenableBuffers.h" 13 #include "SkFlattenableBuffers.h"
13 #include "SkMaskFilter.h" 14 #include "SkMaskFilter.h"
14 #include "SkPaint.h" 15 #include "SkPaint.h"
15 #include "SkString.h" 16 #include "SkString.h"
16 #include "SkStringUtils.h" 17 #include "SkStringUtils.h"
17 18
18 SkBlurDrawLooper::SkBlurDrawLooper(SkScalar radius, SkScalar dx, SkScalar dy, 19 SkBlurDrawLooper::SkBlurDrawLooper(SkScalar radius, SkScalar dx, SkScalar dy,
19 SkColor color, uint32_t flags) 20 SkColor color, uint32_t flags) {
20 : fDx(dx), fDy(dy), fBlurColor(color), fBlurFlags(flags), fState(kDone) { 21 this->init(SkBlurMask::ConvertRadiusToSigma(radius), dx, dy, color, flags);
22 }
23
24 SkBlurDrawLooper::SkBlurDrawLooper(SkColor color, SkScalar sigma,
25 SkScalar dx, SkScalar dy, uint32_t flags) {
26 this->init(sigma, dx, dy, color, flags);
27 }
28
29 void SkBlurDrawLooper::init(SkScalar sigma, SkScalar dx, SkScalar dy,
30 SkColor color, uint32_t flags) {
31 fDx = dx;
32 fDy = dy;
33 fBlurColor = color;
34 fBlurFlags = flags;
35 fState = kDone;
21 36
22 SkASSERT(flags <= kAll_BlurFlag); 37 SkASSERT(flags <= kAll_BlurFlag);
23 if (radius > 0) { 38 if (sigma > 0) {
24 uint32_t blurFlags = flags & kIgnoreTransform_BlurFlag ? 39 uint32_t blurFlags = flags & kIgnoreTransform_BlurFlag ?
25 SkBlurMaskFilter::kIgnoreTransform_BlurFlag : 40 SkBlurMaskFilter::kIgnoreTransform_BlurFlag :
26 SkBlurMaskFilter::kNone_BlurFlag; 41 SkBlurMaskFilter::kNone_BlurFlag;
27 42
28 blurFlags |= flags & kHighQuality_BlurFlag ? 43 blurFlags |= flags & kHighQuality_BlurFlag ?
29 SkBlurMaskFilter::kHighQuality_BlurFlag : 44 SkBlurMaskFilter::kHighQuality_BlurFlag :
30 SkBlurMaskFilter::kNone_BlurFlag; 45 SkBlurMaskFilter::kNone_BlurFlag;
31 46
32 fBlur = SkBlurMaskFilter::Create(radius, 47 fBlur = SkBlurMaskFilter::Create(SkBlurMaskFilter::kNormal_BlurStyle,
33 SkBlurMaskFilter::kNormal_BlurStyle, 48 sigma,
34 blurFlags); 49 blurFlags);
35 } else { 50 } else {
36 fBlur = NULL; 51 fBlur = NULL;
37 } 52 }
38 53
39 if (flags & kOverrideColor_BlurFlag) { 54 if (flags & kOverrideColor_BlurFlag) {
40 // Set alpha to 1 for the override since transparency will already 55 // Set alpha to 1 for the override since transparency will already
41 // be baked into the blurred mask. 56 // be baked into the blurred mask.
42 SkColor opaqueColor = SkColorSetA(color, 255); 57 SkColor opaqueColor = SkColorSetA(color, 255);
43 //The SrcIn xfer mode will multiply 'color' by the incoming alpha 58 //The SrcIn xfer mode will multiply 'color' by the incoming alpha
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 &needsSeparator); 157 &needsSeparator);
143 SkAddFlagToString(str, SkToBool(kHighQuality_BlurFlag & fBlurFlags), "Hi ghQuality", 158 SkAddFlagToString(str, SkToBool(kHighQuality_BlurFlag & fBlurFlags), "Hi ghQuality",
144 &needsSeparator); 159 &needsSeparator);
145 } 160 }
146 str->append(")"); 161 str->append(")");
147 162
148 // TODO: add optional "fBlurFilter->toString(str);" when SkMaskFilter::toStr ing is added 163 // TODO: add optional "fBlurFilter->toString(str);" when SkMaskFilter::toStr ing is added
149 // alternatively we could cache the radius in SkBlurDrawLooper and just add it here 164 // alternatively we could cache the radius in SkBlurDrawLooper and just add it here
150 } 165 }
151 #endif 166 #endif
OLDNEW
« no previous file with comments | « src/core/SkPicture.cpp ('k') | src/effects/SkBlurMask.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698