Separable mask blurs: Add compile-time flag. Fix reversed offsets in asymmetrical blurs (this bug cancels itself out, but I thought it might be confusing for future readers). Use correct stride in asymmetrical blurs (this is a real bug).
Review URL: https://codereview.appspot.com/6782089 git-svn-id: http://skia.googlecode.com/svn/trunk@6508 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
2cda3871cb
commit
336b4da6b0
@ -31,8 +31,10 @@ public:
|
||||
kIgnoreTransform_BlurFlag = 0x01,
|
||||
kOverrideColor_BlurFlag = 0x02,
|
||||
kHighQuality_BlurFlag = 0x04,
|
||||
/** faster, but may discretize the radius */
|
||||
kCoarseRadius_BlurFlag = 0x08,
|
||||
/** mask for all blur flags */
|
||||
kAll_BlurFlag = 0x07
|
||||
kAll_BlurFlag = 0x0F
|
||||
};
|
||||
|
||||
SkBlurDrawLooper(SkScalar radius, SkScalar dx, SkScalar dy, SkColor color,
|
||||
|
@ -29,8 +29,10 @@ public:
|
||||
kIgnoreTransform_BlurFlag = 0x01,
|
||||
/** Use a smother, higher qulity blur algorithm */
|
||||
kHighQuality_BlurFlag = 0x02,
|
||||
/** Do faster blurs by rounding the radius to a set of sub-integer values */
|
||||
kCoarseRadius_BlurFlag = 0x04,
|
||||
/** mask for all blur flags */
|
||||
kAll_BlurFlag = 0x03
|
||||
kAll_BlurFlag = 0x07
|
||||
};
|
||||
|
||||
/** Create a blur maskfilter.
|
||||
|
@ -27,6 +27,10 @@ SkBlurDrawLooper::SkBlurDrawLooper(SkScalar radius, SkScalar dx, SkScalar dy,
|
||||
SkBlurMaskFilter::kHighQuality_BlurFlag :
|
||||
SkBlurMaskFilter::kNone_BlurFlag;
|
||||
|
||||
blurFlags |= flags & kCoarseRadius_BlurFlag ?
|
||||
SkBlurMaskFilter::kCoarseRadius_BlurFlag :
|
||||
SkBlurMaskFilter::kNone_BlurFlag;
|
||||
|
||||
fBlur = SkBlurMaskFilter::Create(radius,
|
||||
SkBlurMaskFilter::kNormal_BlurStyle,
|
||||
blurFlags);
|
||||
|
@ -34,8 +34,9 @@ static int boxBlur(const uint8_t* src, int src_y_stride, uint8_t* dst,
|
||||
uint8_t* dptr = dst + y * dst_y_stride;
|
||||
const uint8_t* right = src + y * src_y_stride;
|
||||
const uint8_t* left = right;
|
||||
for (int x = 0; x < leftRadius - rightRadius; x++) {
|
||||
*dptr++ = 0;
|
||||
for (int x = 0; x < rightRadius - leftRadius; x++) {
|
||||
*dptr = 0;
|
||||
dptr += dst_x_stride;
|
||||
}
|
||||
for (int x = 0; x < border; ++x) {
|
||||
sum += *right++;
|
||||
@ -57,8 +58,9 @@ static int boxBlur(const uint8_t* src, int src_y_stride, uint8_t* dst,
|
||||
sum -= *left++;
|
||||
dptr += dst_x_stride;
|
||||
}
|
||||
for (int x = 0; x < rightRadius - leftRadius; x++) {
|
||||
*dptr++ = 0;
|
||||
for (int x = 0; x < leftRadius - rightRadius; x++) {
|
||||
*dptr = 0;
|
||||
dptr += dst_x_stride;
|
||||
}
|
||||
SkASSERT(sum == 0);
|
||||
}
|
||||
|
@ -97,8 +97,13 @@ bool SkBlurMaskFilterImpl::filterMask(SkMask* dst, const SkMask& src,
|
||||
(fBlurFlags & SkBlurMaskFilter::kHighQuality_BlurFlag) ?
|
||||
SkBlurMask::kHigh_Quality : SkBlurMask::kLow_Quality;
|
||||
|
||||
return SkBlurMask::Blur(dst, src, radius, (SkBlurMask::Style)fBlurStyle,
|
||||
blurQuality, margin);
|
||||
if (fBlurFlags & SkBlurMaskFilter::kCoarseRadius_BlurFlag) {
|
||||
return SkBlurMask::BlurSeparable(dst, src, radius, (SkBlurMask::Style)fBlurStyle,
|
||||
blurQuality, margin);
|
||||
} else {
|
||||
return SkBlurMask::Blur(dst, src, radius, (SkBlurMask::Style)fBlurStyle,
|
||||
blurQuality, margin);
|
||||
}
|
||||
}
|
||||
|
||||
#include "SkCanvas.h"
|
||||
|
Loading…
Reference in New Issue
Block a user