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 /** | 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, int32_t unique ID = 0) { |
| 20 return SkNEW_ARGS(SkPictureImageFilter, (picture, uniqueID)); | 20 return SkNEW_ARGS(SkPictureImageFilter, (picture, uniqueID)); |
| 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, uint32_t uniqueID = 0) { | 27 static SkPictureImageFilter* Create(const SkPicture* picture, const SkRect& cropRect, |
| 28 return SkNEW_ARGS(SkPictureImageFilter, (picture, cropRect, uniqueID)); | 28 uint32_t uniqueID = 0) { |
| 29 return SkNEW_ARGS(SkPictureImageFilter, (picture, cropRect, uniqueID, | |
| 30 kDeviceSpace_PictureResolution) ); | |
| 31 } | |
| 32 | |
| 33 /** | |
| 34 * Refs the passed-in picture. The picture is rasterized at a resolution th at matches the | |
| 35 * local coordinate space. If the picture needs to be resampled for drawing it into the | |
| 36 * destination canvas, bilinear filtering will be used. cropRect can be use d to crop or | |
| 37 * expand the destination rect when the picture is drawn. (No scaling is im plied by the | |
| 38 * dest rect; only the CTM is applied.) | |
| 39 */ | |
| 40 static SkPictureImageFilter* CreateForLocalSpace(const SkPicture* picture, | |
| 41 const SkRect& cropRect, | |
| 42 uint32_t uniqueID = 0) { | |
| 43 return SkNEW_ARGS(SkPictureImageFilter, (picture, cropRect, uniqueID, | |
| 44 kLocalSpace_PictureResolution)) ; | |
| 29 } | 45 } |
| 30 | 46 |
| 31 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureImageFilter) | 47 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureImageFilter) |
| 32 | 48 |
| 33 protected: | 49 protected: |
| 50 enum PictureResolution { | |
| 51 kDeviceSpace_PictureResolution, | |
| 52 kLocalSpace_PictureResolution | |
|
Stephen White
2014/12/01 16:02:12
Is "local space" the usual Skia nomenclature for n
Justin Novosad
2014/12/02 16:33:36
It is standard nomenclature in computer graphics.
| |
| 53 }; | |
| 54 | |
| 34 explicit SkPictureImageFilter(const SkPicture* picture, uint32_t uniqueID); | 55 explicit SkPictureImageFilter(const SkPicture* picture, uint32_t uniqueID); |
| 35 SkPictureImageFilter(const SkPicture* picture, const SkRect& cropRect, uint3 2_t uniqueID); | 56 SkPictureImageFilter(const SkPicture* picture, const SkRect& cropRect, uint3 2_t uniqueID, |
| 57 PictureResolution); | |
| 36 virtual ~SkPictureImageFilter(); | 58 virtual ~SkPictureImageFilter(); |
| 37 /* Constructs an SkPictureImageFilter object from an SkReadBuffer. | 59 /* Constructs an SkPictureImageFilter object from an SkReadBuffer. |
| 38 * Note: If the SkPictureImageFilter object construction requires bitmap | 60 * Note: If the SkPictureImageFilter object construction requires bitmap |
| 39 * decoding, the decoder must be set on the SkReadBuffer parameter by calli ng | 61 * decoding, the decoder must be set on the SkReadBuffer parameter by calli ng |
| 40 * SkReadBuffer::setBitmapDecoder() before calling this constructor. | 62 * SkReadBuffer::setBitmapDecoder() before calling this constructor. |
| 41 * @param SkReadBuffer Serialized picture data. | 63 * @param SkReadBuffer Serialized picture data. |
| 42 */ | 64 */ |
| 43 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING | 65 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
| 44 explicit SkPictureImageFilter(SkReadBuffer&); | 66 explicit SkPictureImageFilter(SkReadBuffer&); |
| 45 #endif | 67 #endif |
| 46 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 68 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
| 47 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, | 69 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, |
| 48 SkBitmap* result, SkIPoint* offset) const SK_OVER RIDE; | 70 SkBitmap* result, SkIPoint* offset) const SK_OVER RIDE; |
| 49 | 71 |
| 50 private: | 72 private: |
| 51 const SkPicture* fPicture; | 73 |
| 52 SkRect fCropRect; | 74 |
| 75 void drawPictureAtNativeResolution(Proxy*, SkBaseDevice*, const SkIRect& dev iceBounds, | |
|
Stephen White
2014/12/01 16:02:12
We have native, device, local and original. Is the
Justin Novosad
2014/12/02 16:33:36
Acknowledged.
| |
| 76 const Context&) const; | |
| 77 void drawPictureAtOriginalResolution(Proxy*, SkBaseDevice*, const SkIRect& d eviceBounds, | |
| 78 const Context&) const; | |
| 79 | |
| 80 const SkPicture* fPicture; | |
| 81 SkRect fCropRect; | |
| 82 PictureResolution fPictureResolution; | |
| 53 typedef SkImageFilter INHERITED; | 83 typedef SkImageFilter INHERITED; |
| 54 }; | 84 }; |
| 55 | 85 |
| 56 #endif | 86 #endif |
| OLD | NEW |