diff options
author | senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-07-15 14:28:16 +0000 |
---|---|---|
committer | senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-07-15 14:28:16 +0000 |
commit | e36ddf01311802dd5c5fe85d47a9bd84b2b84565 (patch) | |
tree | 5afe3ee14eab469d374ed2cc169219546890d9d6 /src/gpu | |
parent | 9de4dc9b1ecb724757a9895c6a7d32d6267bf211 (diff) |
More GPU blur fixes.
- clamp the max. radius to 128, as the software path does
- use a more accurate radius-to-sigma conversion (0.6 instead of 0.6666)
- make SampleBlur derive from SampleView, not SkView, so benchmark mode ('f')
works
- implement a new BigBlur sample to test large radii
Review URL: http://codereview.appspot.com/4726043
git-svn-id: http://skia.googlecode.com/svn/trunk@1871 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 386b409bae..b39f90eb32 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -48,7 +48,18 @@ enum { #define USE_GPU_BLUR 0 -#define MAX_SIGMA 4.0f +#define MAX_BLUR_SIGMA 4.0f +// FIXME: This value comes from from SkBlurMaskFilter.cpp. +// Should probably be put in a common header someplace. +#define MAX_BLUR_RADIUS SkIntToScalar(128) +// This constant approximates the scaling done in the software path's +// "high quality" mode, in SkBlurMask::Blur() (1 / sqrt(3)). +// IMHO, it actually should be 1: we blur "less" than we should do +// according to the CSS and canvas specs, simply because Safari does the same. +// Firefox used to do the same too, until 4.0 where they fixed it. So at some +// point we should probably get rid of these scaling constants and rebaseline +// all the blur tests. +#define BLUR_SIGMA_SCALE 0.6f /////////////////////////////////////////////////////////////////////////////// SkGpuDevice::SkAutoCachedTexture:: @@ -836,14 +847,15 @@ static bool drawWithGPUMaskFilter(GrContext* context, const SkPath& path, if (SkMaskFilter::kNone_BlurType == blurType) { return false; } - float radius = info.fIgnoreTransform ? info.fRadius - : matrix.mapRadius(info.fRadius); - float sigma = radius * 0.6666f; + SkScalar radius = info.fIgnoreTransform ? info.fRadius + : matrix.mapRadius(info.fRadius); + radius = SkMinScalar(radius, MAX_BLUR_RADIUS); + float sigma = SkScalarToFloat(radius) * BLUR_SIGMA_SCALE; SkRect srcRect = path.getBounds(); int scaleFactor = 1; - while (sigma > MAX_SIGMA) { + while (sigma > MAX_BLUR_SIGMA) { scaleFactor *= 2; sigma *= 0.5f; } |