| 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) { | 19 static SkImageFilter* Create(const SkPicture* picture) { |
| 20 return new SkPictureImageFilter(picture); | 20 return new 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 SkImageFilter* Create(const SkPicture* picture, const SkRect& cropRec
t) { |
| 28 return new SkPictureImageFilter(picture, cropRect, kDeviceSpace_PictureR
esolution, | 28 return new SkPictureImageFilter(picture, cropRect, kDeviceSpace_PictureR
esolution, |
| 29 kLow_SkFilterQuality); | 29 kLow_SkFilterQuality); |
| 30 } | 30 } |
| 31 | 31 |
| 32 /** | 32 /** |
| 33 * Refs the passed-in picture. The picture is rasterized at a resolution th
at matches the | 33 * Refs the passed-in picture. The picture is rasterized at a resolution th
at matches the |
| 34 * local coordinate space. If the picture needs to be resampled for drawing
it into the | 34 * local coordinate space. If the picture needs to be resampled for drawing
it into the |
| 35 * destination canvas, bilinear filtering will be used. cropRect can be use
d to crop or | 35 * destination canvas, bilinear filtering will be used. cropRect can be use
d to crop or |
| 36 * expand the destination rect when the picture is drawn. (No scaling is im
plied by the | 36 * expand the destination rect when the picture is drawn. (No scaling is im
plied by the |
| 37 * dest rect; only the CTM is applied.) | 37 * dest rect; only the CTM is applied.) |
| 38 */ | 38 */ |
| 39 static SkPictureImageFilter* CreateForLocalSpace(const SkPicture* picture, | 39 static SkImageFilter* CreateForLocalSpace(const SkPicture* picture, |
| 40 const SkRect& cropRect, | 40 const SkRect& cropRect, |
| 41 SkFilterQuality filterQuali
ty) { | 41 SkFilterQuality filterQuali
ty) { |
| 42 return new SkPictureImageFilter(picture, cropRect, kLocalSpace_PictureRe
solution, | 42 return new SkPictureImageFilter(picture, cropRect, kLocalSpace_PictureRe
solution, |
| 43 filterQuality); | 43 filterQuality); |
| 44 } | 44 } |
| 45 |
| 45 SK_TO_STRING_OVERRIDE() | 46 SK_TO_STRING_OVERRIDE() |
| 46 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureImageFilter) | 47 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureImageFilter) |
| 47 | 48 |
| 48 protected: | 49 protected: |
| 49 enum PictureResolution { | 50 enum PictureResolution { |
| 50 kDeviceSpace_PictureResolution, | 51 kDeviceSpace_PictureResolution, |
| 51 kLocalSpace_PictureResolution | 52 kLocalSpace_PictureResolution |
| 52 }; | 53 }; |
| 53 | 54 |
| 54 explicit SkPictureImageFilter(const SkPicture* picture); | |
| 55 SkPictureImageFilter(const SkPicture* picture, const SkRect& cropRect, | |
| 56 PictureResolution, SkFilterQuality); | |
| 57 virtual ~SkPictureImageFilter(); | 55 virtual ~SkPictureImageFilter(); |
| 56 |
| 58 /* Constructs an SkPictureImageFilter object from an SkReadBuffer. | 57 /* Constructs an SkPictureImageFilter object from an SkReadBuffer. |
| 59 * Note: If the SkPictureImageFilter object construction requires bitmap | 58 * Note: If the SkPictureImageFilter object construction requires bitmap |
| 60 * decoding, the decoder must be set on the SkReadBuffer parameter by calli
ng | 59 * decoding, the decoder must be set on the SkReadBuffer parameter by calli
ng |
| 61 * SkReadBuffer::setBitmapDecoder() before calling this constructor. | 60 * SkReadBuffer::setBitmapDecoder() before calling this constructor. |
| 62 * @param SkReadBuffer Serialized picture data. | 61 * @param SkReadBuffer Serialized picture data. |
| 63 */ | 62 */ |
| 64 void flatten(SkWriteBuffer&) const override; | 63 void flatten(SkWriteBuffer&) const override; |
| 65 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, | 64 bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, SkBitmap* re
sult, |
| 66 SkBitmap* result, SkIPoint* offset) const overrid
e; | 65 SkIPoint* offset) const override; |
| 67 | 66 |
| 68 private: | 67 private: |
| 69 | 68 explicit SkPictureImageFilter(const SkPicture* picture); |
| 69 SkPictureImageFilter(const SkPicture* picture, const SkRect& cropRect, |
| 70 PictureResolution, SkFilterQuality); |
| 70 | 71 |
| 71 void drawPictureAtDeviceResolution(SkBaseDevice*, const SkIRect& deviceBound
s, | 72 void drawPictureAtDeviceResolution(SkBaseDevice*, const SkIRect& deviceBound
s, |
| 72 const Context&) const; | 73 const Context&) const; |
| 73 void drawPictureAtLocalResolution(Proxy*, SkBaseDevice*, const SkIRect& devi
ceBounds, | 74 void drawPictureAtLocalResolution(Proxy*, SkBaseDevice*, const SkIRect& devi
ceBounds, |
| 74 const Context&) const; | 75 const Context&) const; |
| 75 | 76 |
| 76 const SkPicture* fPicture; | 77 const SkPicture* fPicture; |
| 77 SkRect fCropRect; | 78 SkRect fCropRect; |
| 78 PictureResolution fPictureResolution; | 79 PictureResolution fPictureResolution; |
| 79 SkFilterQuality fFilterQuality; | 80 SkFilterQuality fFilterQuality; |
| 81 |
| 80 typedef SkImageFilter INHERITED; | 82 typedef SkImageFilter INHERITED; |
| 81 }; | 83 }; |
| 82 | 84 |
| 83 #endif | 85 #endif |
| OLD | NEW |