OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 The Android Open Source Project | 2 * Copyright 2013 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 SkPictureImageFilter_DEFINED | 8 #ifndef SkPictureImageFilter_DEFINED |
9 #define SkPictureImageFilter_DEFINED | 9 #define SkPictureImageFilter_DEFINED |
10 | 10 |
11 #include "SkImageFilter.h" | 11 #include "SkImageFilter.h" |
12 #include "SkPicture.h" | 12 #include "SkPicture.h" |
13 | 13 |
14 class SK_API SkPictureImageFilter : public SkImageFilter { | 14 class SK_API SkPictureImageFilter : public SkImageFilter { |
15 public: | 15 public: |
16 /** | 16 /** |
17 * Refs the passed-in picture. | 17 * Refs the passed-in picture. |
18 */ | 18 */ |
19 static SkPictureImageFilter* Create(const SkPicture* picture, int32_t unique
ID = 0) { | 19 static SkPictureImageFilter* Create(const SkPicture* picture) { |
20 return SkNEW_ARGS(SkPictureImageFilter, (picture, uniqueID)); | 20 return SkNEW_ARGS(SkPictureImageFilter, (picture)); |
21 } | 21 } |
22 | 22 |
23 /** | 23 /** |
24 * Refs the passed-in picture. cropRect can be used to crop or expand the d
estination rect when | 24 * Refs the passed-in picture. cropRect can be used to crop or expand the d
estination rect when |
25 * the picture is drawn. (No scaling is implied by the dest rect; only the
CTM is applied.) | 25 * the picture is drawn. (No scaling is implied by the dest rect; only the
CTM is applied.) |
26 */ | 26 */ |
27 static SkPictureImageFilter* Create(const SkPicture* picture, const SkRect&
cropRect, | 27 static SkPictureImageFilter* Create(const SkPicture* picture, const SkRect&
cropRect) { |
28 uint32_t uniqueID = 0) { | 28 return SkNEW_ARGS(SkPictureImageFilter, (picture, cropRect, |
29 return SkNEW_ARGS(SkPictureImageFilter, (picture, cropRect, uniqueID, | |
30 kDeviceSpace_PictureResolution, | 29 kDeviceSpace_PictureResolution, |
31 kLow_SkFilterQuality)); | 30 kLow_SkFilterQuality)); |
32 } | 31 } |
33 | 32 |
34 /** | 33 /** |
35 * Refs the passed-in picture. The picture is rasterized at a resolution th
at matches the | 34 * Refs the passed-in picture. The picture is rasterized at a resolution th
at matches the |
36 * local coordinate space. If the picture needs to be resampled for drawing
it into the | 35 * local coordinate space. If the picture needs to be resampled for drawing
it into the |
37 * destination canvas, bilinear filtering will be used. cropRect can be use
d to crop or | 36 * destination canvas, bilinear filtering will be used. cropRect can be use
d to crop or |
38 * expand the destination rect when the picture is drawn. (No scaling is im
plied by the | 37 * expand the destination rect when the picture is drawn. (No scaling is im
plied by the |
39 * dest rect; only the CTM is applied.) | 38 * dest rect; only the CTM is applied.) |
40 */ | 39 */ |
41 static SkPictureImageFilter* CreateForLocalSpace(const SkPicture* picture, | 40 static SkPictureImageFilter* CreateForLocalSpace(const SkPicture* picture, |
42 const SkRect& cropRect, | 41 const SkRect& cropRect, |
43 SkFilterQuality filterQuali
ty, | 42 SkFilterQuality filterQuali
ty) { |
44 uint32_t uniqueID = 0) { | 43 return SkNEW_ARGS(SkPictureImageFilter, (picture, cropRect, |
45 return SkNEW_ARGS(SkPictureImageFilter, (picture, cropRect, uniqueID, | |
46 kLocalSpace_PictureResolution,
filterQuality)); | 44 kLocalSpace_PictureResolution,
filterQuality)); |
47 } | 45 } |
48 #ifdef SK_SUPPORT_LEGACY_FILTERLEVEL_ENUM | 46 #ifdef SK_SUPPORT_LEGACY_FILTERLEVEL_ENUM |
49 static SkPictureImageFilter* CreateForLocalSpace(const SkPicture* picture, | 47 static SkPictureImageFilter* CreateForLocalSpace(const SkPicture* picture, |
50 const SkRect& cropRect, | 48 const SkRect& cropRect, |
51 SkPaint::FilterLevel filter
Level, | 49 SkPaint::FilterLevel filter
Level) { |
52 uint32_t uniqueID = 0) { | 50 return CreateForLocalSpace(picture, cropRect, (SkFilterQuality)filterLev
el); |
53 return CreateForLocalSpace(picture, cropRect, (SkFilterQuality)filterLev
el, uniqueID); | |
54 } | 51 } |
55 #endif | 52 #endif |
56 SK_TO_STRING_OVERRIDE() | 53 SK_TO_STRING_OVERRIDE() |
57 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureImageFilter) | 54 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureImageFilter) |
58 | 55 |
59 protected: | 56 protected: |
60 enum PictureResolution { | 57 enum PictureResolution { |
61 kDeviceSpace_PictureResolution, | 58 kDeviceSpace_PictureResolution, |
62 kLocalSpace_PictureResolution | 59 kLocalSpace_PictureResolution |
63 }; | 60 }; |
64 | 61 |
65 explicit SkPictureImageFilter(const SkPicture* picture, uint32_t uniqueID); | 62 explicit SkPictureImageFilter(const SkPicture* picture); |
66 SkPictureImageFilter(const SkPicture* picture, const SkRect& cropRect, uint3
2_t uniqueID, | 63 SkPictureImageFilter(const SkPicture* picture, const SkRect& cropRect, |
67 PictureResolution, SkFilterQuality); | 64 PictureResolution, SkFilterQuality); |
68 virtual ~SkPictureImageFilter(); | 65 virtual ~SkPictureImageFilter(); |
69 /* Constructs an SkPictureImageFilter object from an SkReadBuffer. | 66 /* Constructs an SkPictureImageFilter object from an SkReadBuffer. |
70 * Note: If the SkPictureImageFilter object construction requires bitmap | 67 * Note: If the SkPictureImageFilter object construction requires bitmap |
71 * decoding, the decoder must be set on the SkReadBuffer parameter by calli
ng | 68 * decoding, the decoder must be set on the SkReadBuffer parameter by calli
ng |
72 * SkReadBuffer::setBitmapDecoder() before calling this constructor. | 69 * SkReadBuffer::setBitmapDecoder() before calling this constructor. |
73 * @param SkReadBuffer Serialized picture data. | 70 * @param SkReadBuffer Serialized picture data. |
74 */ | 71 */ |
75 void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 72 void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
76 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, | 73 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, |
77 SkBitmap* result, SkIPoint* offset) const SK_OVER
RIDE; | 74 SkBitmap* result, SkIPoint* offset) const SK_OVER
RIDE; |
78 | 75 |
79 private: | 76 private: |
80 | 77 |
81 | 78 |
82 void drawPictureAtDeviceResolution(Proxy*, SkBaseDevice*, const SkIRect& dev
iceBounds, | 79 void drawPictureAtDeviceResolution(Proxy*, SkBaseDevice*, const SkIRect& dev
iceBounds, |
83 const Context&) const; | 80 const Context&) const; |
84 void drawPictureAtLocalResolution(Proxy*, SkBaseDevice*, const SkIRect& devi
ceBounds, | 81 void drawPictureAtLocalResolution(Proxy*, SkBaseDevice*, const SkIRect& devi
ceBounds, |
85 const Context&) const; | 82 const Context&) const; |
86 | 83 |
87 const SkPicture* fPicture; | 84 const SkPicture* fPicture; |
88 SkRect fCropRect; | 85 SkRect fCropRect; |
89 PictureResolution fPictureResolution; | 86 PictureResolution fPictureResolution; |
90 SkFilterQuality fFilterQuality; | 87 SkFilterQuality fFilterQuality; |
91 typedef SkImageFilter INHERITED; | 88 typedef SkImageFilter INHERITED; |
92 }; | 89 }; |
93 | 90 |
94 #endif | 91 #endif |
OLD | NEW |