| 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 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 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 uint32_t uniqueID = 0) { |
| 29 return SkNEW_ARGS(SkPictureImageFilter, (picture, cropRect, uniqueID, | 29 return SkNEW_ARGS(SkPictureImageFilter, (picture, cropRect, uniqueID, |
| 30 kDeviceSpace_PictureResolution, | 30 kDeviceSpace_PictureResolution, |
| 31 SkPaint::kLow_FilterLevel)); | 31 kLow_SkFilterQuality)); |
| 32 } | 32 } |
| 33 | 33 |
| 34 /** | 34 /** |
| 35 * Refs the passed-in picture. The picture is rasterized at a resolution th
at matches the | 35 * 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 | 36 * 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 | 37 * 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 | 38 * expand the destination rect when the picture is drawn. (No scaling is im
plied by the |
| 39 * dest rect; only the CTM is applied.) | 39 * dest rect; only the CTM is applied.) |
| 40 */ | 40 */ |
| 41 static SkPictureImageFilter* CreateForLocalSpace(const SkPicture* picture, | 41 static SkPictureImageFilter* CreateForLocalSpace(const SkPicture* picture, |
| 42 const SkRect& cropRect, | 42 const SkRect& cropRect, |
| 43 SkFilterQuality filterQuali
ty, |
| 44 uint32_t uniqueID = 0) { |
| 45 return SkNEW_ARGS(SkPictureImageFilter, (picture, cropRect, uniqueID, |
| 46 kLocalSpace_PictureResolution,
filterQuality)); |
| 47 } |
| 48 #ifdef SK_SUPPORT_LEGACY_FILTERLEVEL_ENUM |
| 49 static SkPictureImageFilter* CreateForLocalSpace(const SkPicture* picture, |
| 50 const SkRect& cropRect, |
| 43 SkPaint::FilterLevel filter
Level, | 51 SkPaint::FilterLevel filter
Level, |
| 44 uint32_t uniqueID = 0) { | 52 uint32_t uniqueID = 0) { |
| 45 return SkNEW_ARGS(SkPictureImageFilter, (picture, cropRect, uniqueID, | 53 return CreateForLocalSpace(picture, cropRect, (SkFilterQuality)filterLev
el, uniqueID); |
| 46 kLocalSpace_PictureResolution,
filterLevel)); | |
| 47 } | 54 } |
| 48 | 55 #endif |
| 49 SK_TO_STRING_OVERRIDE() | 56 SK_TO_STRING_OVERRIDE() |
| 50 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureImageFilter) | 57 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureImageFilter) |
| 51 | 58 |
| 52 protected: | 59 protected: |
| 53 enum PictureResolution { | 60 enum PictureResolution { |
| 54 kDeviceSpace_PictureResolution, | 61 kDeviceSpace_PictureResolution, |
| 55 kLocalSpace_PictureResolution | 62 kLocalSpace_PictureResolution |
| 56 }; | 63 }; |
| 57 | 64 |
| 58 explicit SkPictureImageFilter(const SkPicture* picture, uint32_t uniqueID); | 65 explicit SkPictureImageFilter(const SkPicture* picture, uint32_t uniqueID); |
| 59 SkPictureImageFilter(const SkPicture* picture, const SkRect& cropRect, uint3
2_t uniqueID, | 66 SkPictureImageFilter(const SkPicture* picture, const SkRect& cropRect, uint3
2_t uniqueID, |
| 60 PictureResolution, SkPaint::FilterLevel); | 67 PictureResolution, SkFilterQuality); |
| 61 virtual ~SkPictureImageFilter(); | 68 virtual ~SkPictureImageFilter(); |
| 62 /* Constructs an SkPictureImageFilter object from an SkReadBuffer. | 69 /* Constructs an SkPictureImageFilter object from an SkReadBuffer. |
| 63 * Note: If the SkPictureImageFilter object construction requires bitmap | 70 * Note: If the SkPictureImageFilter object construction requires bitmap |
| 64 * decoding, the decoder must be set on the SkReadBuffer parameter by calli
ng | 71 * decoding, the decoder must be set on the SkReadBuffer parameter by calli
ng |
| 65 * SkReadBuffer::setBitmapDecoder() before calling this constructor. | 72 * SkReadBuffer::setBitmapDecoder() before calling this constructor. |
| 66 * @param SkReadBuffer Serialized picture data. | 73 * @param SkReadBuffer Serialized picture data. |
| 67 */ | 74 */ |
| 68 void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 75 void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
| 69 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, | 76 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, |
| 70 SkBitmap* result, SkIPoint* offset) const SK_OVER
RIDE; | 77 SkBitmap* result, SkIPoint* offset) const SK_OVER
RIDE; |
| 71 | 78 |
| 72 private: | 79 private: |
| 73 | 80 |
| 74 | 81 |
| 75 void drawPictureAtDeviceResolution(Proxy*, SkBaseDevice*, const SkIRect& dev
iceBounds, | 82 void drawPictureAtDeviceResolution(Proxy*, SkBaseDevice*, const SkIRect& dev
iceBounds, |
| 76 const Context&) const; | 83 const Context&) const; |
| 77 void drawPictureAtLocalResolution(Proxy*, SkBaseDevice*, const SkIRect& devi
ceBounds, | 84 void drawPictureAtLocalResolution(Proxy*, SkBaseDevice*, const SkIRect& devi
ceBounds, |
| 78 const Context&) const; | 85 const Context&) const; |
| 79 | 86 |
| 80 const SkPicture* fPicture; | 87 const SkPicture* fPicture; |
| 81 SkRect fCropRect; | 88 SkRect fCropRect; |
| 82 PictureResolution fPictureResolution; | 89 PictureResolution fPictureResolution; |
| 83 SkPaint::FilterLevel fFilterLevel; | 90 SkFilterQuality fFilterQuality; |
| 84 typedef SkImageFilter INHERITED; | 91 typedef SkImageFilter INHERITED; |
| 85 }; | 92 }; |
| 86 | 93 |
| 87 #endif | 94 #endif |
| OLD | NEW |