OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 The Android Open Source Project | 2 * Copyright 2014 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkResizeImageFilter_DEFINED | 8 #ifndef SkMatrixImageFilter_DEFINED |
9 #define SkResizeImageFilter_DEFINED | 9 #define SkMatrixImageFilter_DEFINED |
10 | 10 |
11 #include "SkImageFilter.h" | 11 #include "SkImageFilter.h" |
12 #include "SkScalar.h" | 12 #include "SkScalar.h" |
13 #include "SkRect.h" | 13 #include "SkSize.h" |
14 #include "SkPoint.h" | 14 #include "SkPoint.h" |
15 #include "SkPaint.h" | 15 #include "SkPaint.h" |
16 | 16 |
17 /*! \class SkResizeImageFilter | 17 /*! \class SkMatrixImageFilter |
18 Resampling image filter. This filter draws its source image resampled using
the given scale | 18 Matrix transformation image filter. This filter draws its source |
19 values. | 19 input transformed by the given matrix. |
20 */ | 20 */ |
21 | 21 |
22 class SK_API SkResizeImageFilter : public SkImageFilter { | 22 class SK_API SkMatrixImageFilter : public SkImageFilter { |
23 public: | 23 public: |
24 virtual ~SkResizeImageFilter(); | 24 /** Construct a 2D transformation image filter. |
25 | 25 * @param transform The matrix to apply when drawing the src bitmap |
26 /** Construct a (scaling-only) resampling image filter. | |
27 * @param sx The x scale parameter to apply when resizing. | |
28 * @param sy The y scale parameter to apply when resizing. | |
29 * @param filterLevel The quality of filtering to apply when scaling. | 26 * @param filterLevel The quality of filtering to apply when scaling. |
30 * @param input The input image filter. If NULL, the src bitmap | 27 * @param input The input image filter. If NULL, the src bitmap |
31 * passed to filterImage() is used instead. | 28 * passed to filterImage() is used instead. |
32 */ | 29 */ |
33 static SkResizeImageFilter* Create(SkScalar sx, SkScalar sy, SkPaint::Filter
Level filterLevel, | 30 |
34 SkImageFilter* input = NULL) { | 31 static SkMatrixImageFilter* Create(const SkMatrix& transform, |
35 return SkNEW_ARGS(SkResizeImageFilter, (sx, sy, filterLevel, input)); | 32 SkPaint::FilterLevel, |
36 } | 33 SkImageFilter* input = NULL); |
| 34 virtual ~SkMatrixImageFilter(); |
37 | 35 |
38 virtual void computeFastBounds(const SkRect&, SkRect*) const SK_OVERRIDE; | 36 virtual void computeFastBounds(const SkRect&, SkRect*) const SK_OVERRIDE; |
39 | 37 |
40 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkResizeImageFilter) | 38 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkMatrixImageFilter) |
41 | 39 |
42 protected: | 40 protected: |
43 SkResizeImageFilter(SkReadBuffer& buffer); | 41 SkMatrixImageFilter(const SkMatrix& transform, |
| 42 SkPaint::FilterLevel, |
| 43 SkImageFilter* input = NULL); |
| 44 SkMatrixImageFilter(SkReadBuffer& buffer); |
44 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 45 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
45 | 46 |
46 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, | 47 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, |
47 SkBitmap* result, SkIPoint* loc) const SK_OVERRID
E; | 48 SkBitmap* result, SkIPoint* loc) const SK_OVERRID
E; |
48 virtual bool onFilterBounds(const SkIRect& src, const SkMatrix&, | 49 virtual bool onFilterBounds(const SkIRect& src, const SkMatrix&, |
49 SkIRect* dst) const SK_OVERRIDE; | 50 SkIRect* dst) const SK_OVERRIDE; |
50 | 51 |
51 #ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS | |
52 public: | |
53 #endif | |
54 SkResizeImageFilter(SkScalar sx, SkScalar sy, SkPaint::FilterLevel filterLev
el, | |
55 SkImageFilter* input = NULL); | |
56 | |
57 private: | 52 private: |
58 SkScalar fSx, fSy; | 53 SkMatrix fTransform; |
59 SkPaint::FilterLevel fFilterLevel; | 54 SkPaint::FilterLevel fFilterLevel; |
60 typedef SkImageFilter INHERITED; | 55 typedef SkImageFilter INHERITED; |
61 }; | 56 }; |
62 | 57 |
63 #endif | 58 #endif |
OLD | NEW |