diff options
author | senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-03-25 17:35:10 +0000 |
---|---|---|
committer | senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-03-25 17:35:10 +0000 |
commit | fd0ec2c76a27ce26a62da23eb75017839959e7cb (patch) | |
tree | f8b43d35589c7d3ea0fd0ffd39156cff27f6f21b /include | |
parent | d9ea09e1f29b303e6fa36079e99729d2951925b9 (diff) |
Implement a generic matrix transform image filter.
This will be used in Blink to accommodate matrices that contain
rotation or shearing. This is a generalization of SkResizeImageFilter,
so I've replaced all uses of SkResizeImageFilter in Skia. (It might be
easier to review by diffing it with SkResizeImageFilter, too.)
R=reed@google.com
Review URL: https://codereview.chromium.org/211103006
git-svn-id: http://skia.googlecode.com/svn/trunk@13941 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include')
-rw-r--r-- | include/effects/SkMatrixImageFilter.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/include/effects/SkMatrixImageFilter.h b/include/effects/SkMatrixImageFilter.h new file mode 100644 index 0000000000..004c6ef9ed --- /dev/null +++ b/include/effects/SkMatrixImageFilter.h @@ -0,0 +1,58 @@ +/* + * Copyright 2014 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 SkMatrixImageFilter_DEFINED +#define SkMatrixImageFilter_DEFINED + +#include "SkImageFilter.h" +#include "SkScalar.h" +#include "SkSize.h" +#include "SkPoint.h" +#include "SkPaint.h" + +/*! \class SkMatrixImageFilter + Matrix transformation image filter. This filter draws its source + input transformed by the given matrix. + */ + +class SK_API SkMatrixImageFilter : public SkImageFilter { +public: + /** Construct a 2D transformation image filter. + * @param transform The matrix to apply when drawing the src bitmap + * @param filterLevel The quality of filtering to apply when scaling. + * @param input The input image filter. If NULL, the src bitmap + * passed to filterImage() is used instead. + */ + + static SkMatrixImageFilter* Create(const SkMatrix& transform, + SkPaint::FilterLevel, + SkImageFilter* input = NULL); + virtual ~SkMatrixImageFilter(); + + virtual void computeFastBounds(const SkRect&, SkRect*) const SK_OVERRIDE; + + SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMatrixImageFilter) + +protected: + SkMatrixImageFilter(const SkMatrix& transform, + SkPaint::FilterLevel, + SkImageFilter* input = NULL); + SkMatrixImageFilter(SkReadBuffer& buffer); + virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; + + virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, + SkBitmap* result, SkIPoint* loc) const SK_OVERRIDE; + virtual bool onFilterBounds(const SkIRect& src, const SkMatrix&, + SkIRect* dst) const SK_OVERRIDE; + +private: + SkMatrix fTransform; + SkPaint::FilterLevel fFilterLevel; + typedef SkImageFilter INHERITED; +}; + +#endif |