diff options
author | 2013-01-18 20:48:20 +0000 | |
---|---|---|
committer | 2013-01-18 20:48:20 +0000 | |
commit | 3f2d45aff69260fcf39d4eea8586387ed44402bb (patch) | |
tree | 41bb7d9415bca4ffc6279cc91caedb36b0356790 /include/effects/SkBicubicImageFilter.h | |
parent | 80d447893e9141e986702842ed6a5603670eb837 (diff) |
(Relanding r7275 with assert fix, plus fixes from r7276, r7280, r7283.)
Implement a bicubic resampling image filter, with raster and GPU backends.
In order to get this to work on the GPU side, I had to modify the width and height of the drawn texture in drawSprite() and drawDevice() to use the filtered texture's dimensions, instead of the source texture. (This wasn't a problem before since all other image filters produce results the same dimensions as their input texture.)
For now, this implementation only does axis-aligned scaling (same as the Lanczos-3 implementation in Chrome). It's also done for correctness and clarity, not speed, so there are lots of opportunities for speedups.
Committed: https://code.google.com/p/skia/source/detail?r=7275
Review URL: https://codereview.appspot.com/7033049
git-svn-id: http://skia.googlecode.com/svn/trunk@7287 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/effects/SkBicubicImageFilter.h')
-rw-r--r-- | include/effects/SkBicubicImageFilter.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/include/effects/SkBicubicImageFilter.h b/include/effects/SkBicubicImageFilter.h new file mode 100644 index 0000000000..682b4600cc --- /dev/null +++ b/include/effects/SkBicubicImageFilter.h @@ -0,0 +1,55 @@ +/* + * Copyright 2013 The Android Open Source Project + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef SkBicubicImageFilter_DEFINED +#define SkBicubicImageFilter_DEFINED + +#include "SkSingleInputImageFilter.h" +#include "SkScalar.h" +#include "SkSize.h" +#include "SkPoint.h" + +/*! \class SkBicubicImageFilter + Bicubic resampling image filter. This filter does a 16-tap bicubic + filter using the given matrix. + */ + +class SK_API SkBicubicImageFilter : public SkSingleInputImageFilter { +public: + /** Construct a (scaling-only) bicubic resampling image filter. + @param scale How much to scale the image. + @param coefficients The 16 coefficients of the bicubic matrix. + @param input The input image filter. If NULL, the src bitmap + passed to filterImage() is used instead. + */ + + SkBicubicImageFilter(const SkSize& scale, const SkScalar coefficients[16], SkImageFilter* input = NULL); + static SkBicubicImageFilter* CreateMitchell(const SkSize& scale, SkImageFilter* input = NULL); + virtual ~SkBicubicImageFilter(); + + SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBicubicImageFilter) + +protected: + SkBicubicImageFilter(SkFlattenableReadBuffer& buffer); + virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; + + virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix&, + SkBitmap* result, SkIPoint* loc) SK_OVERRIDE; + +#if SK_SUPPORT_GPU + virtual bool canFilterImageGPU() const SK_OVERRIDE { return true; } + virtual GrTexture* filterImageGPU(Proxy* proxy, GrTexture* src, + const SkRect& rect) SK_OVERRIDE; +#endif + +private: + SkSize fScale; + SkScalar fCoefficients[16]; + typedef SkSingleInputImageFilter INHERITED; +}; + +#endif |