Chromium Code Reviews| 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 enum PictureResolution { | |
| 17 /** | |
| 18 * In this mode, which is the default, the picture is reasterized in at | |
| 19 * a resolution that matches the device that filter is rendering to. | |
| 20 */ | |
| 21 kDeviceSpace_PictureResolution, | |
| 22 | |
| 23 /** | |
| 24 * In this mode, the picture is rasterized at a resolution such that pix els have | |
| 25 * unit size in the local (pre-transform) coordinate space. This is equi valent | |
| 26 * to rendering in record-time device space and the resampling the resul t to | |
| 27 * pring in into the playback device space. | |
| 28 */ | |
| 29 kLocalSpace_PictureResolution | |
| 30 }; | |
| 31 | |
| 16 /** | 32 /** |
| 17 * Refs the passed-in picture. | 33 * Refs the passed-in picture. |
| 18 */ | 34 */ |
| 19 static SkPictureImageFilter* Create(const SkPicture* picture, int32_t unique ID = 0) { | 35 static SkPictureImageFilter* Create(const SkPicture* picture, int32_t unique ID = 0, |
|
reed2
2014/11/28 15:33:52
api nit: can we not have so many default arguments
| |
| 20 return SkNEW_ARGS(SkPictureImageFilter, (picture, uniqueID)); | 36 PictureResolution res = kDeviceSpace_Pic tureResolution, |
| 37 SkPaint::FilterLevel level = SkPaint::kL ow_FilterLevel) { | |
| 38 return SkNEW_ARGS(SkPictureImageFilter, (picture, uniqueID, res, level)) ; | |
| 21 } | 39 } |
| 22 | 40 |
| 23 /** | 41 /** |
| 24 * Refs the passed-in picture. cropRect can be used to crop or expand the d estination rect when | 42 * 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.) | 43 * the picture is drawn. (No scaling is implied by the dest rect; only the CTM is applied.) |
| 26 */ | 44 */ |
| 27 static SkPictureImageFilter* Create(const SkPicture* picture, const SkRect& cropRect, uint32_t uniqueID = 0) { | 45 static SkPictureImageFilter* Create(const SkPicture* picture, const SkRect& cropRect, |
| 28 return SkNEW_ARGS(SkPictureImageFilter, (picture, cropRect, uniqueID)); | 46 uint32_t uniqueID = 0, |
| 47 PictureResolution res = kDeviceSpace_Pic tureResolution, | |
| 48 SkPaint::FilterLevel level = SkPaint::kL ow_FilterLevel) { | |
| 49 return SkNEW_ARGS(SkPictureImageFilter, (picture, cropRect, uniqueID, re s, level)); | |
| 29 } | 50 } |
| 30 | 51 |
| 31 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureImageFilter) | 52 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureImageFilter) |
| 32 | 53 |
| 33 protected: | 54 protected: |
| 34 explicit SkPictureImageFilter(const SkPicture* picture, uint32_t uniqueID); | 55 explicit SkPictureImageFilter(const SkPicture* picture, uint32_t uniqueID, P ictureResolution, |
| 35 SkPictureImageFilter(const SkPicture* picture, const SkRect& cropRect, uint3 2_t uniqueID); | 56 SkPaint::FilterLevel); |
| 57 SkPictureImageFilter(const SkPicture* picture, const SkRect& cropRect, uint3 2_t uniqueID, | |
| 58 PictureResolution, SkPaint::FilterLevel); | |
| 36 virtual ~SkPictureImageFilter(); | 59 virtual ~SkPictureImageFilter(); |
| 37 /* Constructs an SkPictureImageFilter object from an SkReadBuffer. | 60 /* Constructs an SkPictureImageFilter object from an SkReadBuffer. |
| 38 * Note: If the SkPictureImageFilter object construction requires bitmap | 61 * Note: If the SkPictureImageFilter object construction requires bitmap |
| 39 * decoding, the decoder must be set on the SkReadBuffer parameter by calli ng | 62 * decoding, the decoder must be set on the SkReadBuffer parameter by calli ng |
| 40 * SkReadBuffer::setBitmapDecoder() before calling this constructor. | 63 * SkReadBuffer::setBitmapDecoder() before calling this constructor. |
| 41 * @param SkReadBuffer Serialized picture data. | 64 * @param SkReadBuffer Serialized picture data. |
| 42 */ | 65 */ |
| 43 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING | 66 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
| 44 explicit SkPictureImageFilter(SkReadBuffer&); | 67 explicit SkPictureImageFilter(SkReadBuffer&); |
| 45 #endif | 68 #endif |
| 46 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 69 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
| 47 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, | 70 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, |
| 48 SkBitmap* result, SkIPoint* offset) const SK_OVER RIDE; | 71 SkBitmap* result, SkIPoint* offset) const SK_OVER RIDE; |
| 49 | 72 |
| 50 private: | 73 private: |
| 51 const SkPicture* fPicture; | 74 void drawPictureAtNativeResolution(Proxy*, SkBaseDevice*, const SkIRect& dev iceBounds, |
| 52 SkRect fCropRect; | 75 const Context&) const; |
| 76 void drawPictureAtOriginalResolution(Proxy*, SkBaseDevice*, const SkIRect& d eviceBounds, | |
| 77 const Context&) const; | |
| 78 | |
| 79 const SkPicture* fPicture; | |
| 80 SkRect fCropRect; | |
| 81 SkPaint::FilterLevel fFilterLevel; | |
| 82 PictureResolution fPictureResolution; | |
| 53 typedef SkImageFilter INHERITED; | 83 typedef SkImageFilter INHERITED; |
| 54 }; | 84 }; |
| 55 | 85 |
| 56 #endif | 86 #endif |
| OLD | NEW |