senorblanco@chromium.org | 5333300 | 2013-12-12 23:28:52 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 The Android Open Source Project |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef SkPictureImageFilter_DEFINED |
| 9 | #define SkPictureImageFilter_DEFINED |
| 10 | |
| 11 | #include "SkImageFilter.h" |
| 12 | #include "SkPicture.h" |
| 13 | |
| 14 | class SK_API SkPictureImageFilter : public SkImageFilter { |
| 15 | public: |
| 16 | /** |
| 17 | * Refs the passed-in picture. |
| 18 | */ |
senorblanco | 5e5f948 | 2014-08-26 12:27:12 -0700 | [diff] [blame] | 19 | static SkPictureImageFilter* Create(const SkPicture* picture, int32_t uniqueID = 0) { |
| 20 | return SkNEW_ARGS(SkPictureImageFilter, (picture, uniqueID)); |
commit-bot@chromium.org | cac5fd5 | 2014-03-10 10:51:58 +0000 | [diff] [blame] | 21 | } |
senorblanco@chromium.org | 5333300 | 2013-12-12 23:28:52 +0000 | [diff] [blame] | 22 | |
| 23 | /** |
commit-bot@chromium.org | cac5fd5 | 2014-03-10 10:51:58 +0000 | [diff] [blame] | 24 | * Refs the passed-in picture. cropRect can be used to crop or expand the destination rect when |
senorblanco@chromium.org | 5333300 | 2013-12-12 23:28:52 +0000 | [diff] [blame] | 25 | * the picture is drawn. (No scaling is implied by the dest rect; only the CTM is applied.) |
| 26 | */ |
senorblanco | 5e5f948 | 2014-08-26 12:27:12 -0700 | [diff] [blame] | 27 | static SkPictureImageFilter* Create(const SkPicture* picture, const SkRect& cropRect, uint32_t uniqueID = 0) { |
| 28 | return SkNEW_ARGS(SkPictureImageFilter, (picture, cropRect, uniqueID)); |
commit-bot@chromium.org | cac5fd5 | 2014-03-10 10:51:58 +0000 | [diff] [blame] | 29 | } |
senorblanco@chromium.org | 5333300 | 2013-12-12 23:28:52 +0000 | [diff] [blame] | 30 | |
| 31 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureImageFilter) |
| 32 | |
| 33 | protected: |
senorblanco | 5e5f948 | 2014-08-26 12:27:12 -0700 | [diff] [blame] | 34 | explicit SkPictureImageFilter(const SkPicture* picture, uint32_t uniqueID); |
| 35 | SkPictureImageFilter(const SkPicture* picture, const SkRect& cropRect, uint32_t uniqueID); |
senorblanco@chromium.org | 5333300 | 2013-12-12 23:28:52 +0000 | [diff] [blame] | 36 | virtual ~SkPictureImageFilter(); |
commit-bot@chromium.org | 5e0995e | 2014-02-07 12:20:04 +0000 | [diff] [blame] | 37 | /* Constructs an SkPictureImageFilter object from an SkReadBuffer. |
| 38 | * Note: If the SkPictureImageFilter object construction requires bitmap |
| 39 | * decoding, the decoder must be set on the SkReadBuffer parameter by calling |
| 40 | * SkReadBuffer::setBitmapDecoder() before calling this constructor. |
| 41 | * @param SkReadBuffer Serialized picture data. |
| 42 | */ |
commit-bot@chromium.org | 8b0e8ac | 2014-01-30 18:58:24 +0000 | [diff] [blame] | 43 | virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
senorblanco@chromium.org | 4cb543d | 2014-03-14 15:44:01 +0000 | [diff] [blame] | 44 | virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, |
commit-bot@chromium.org | ae761f7 | 2014-02-05 22:32:02 +0000 | [diff] [blame] | 45 | SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE; |
senorblanco@chromium.org | 5333300 | 2013-12-12 23:28:52 +0000 | [diff] [blame] | 46 | |
| 47 | private: |
robertphillips | e846499 | 2014-07-14 07:53:26 -0700 | [diff] [blame] | 48 | const SkPicture* fPicture; |
| 49 | SkRect fCropRect; |
senorblanco@chromium.org | 5333300 | 2013-12-12 23:28:52 +0000 | [diff] [blame] | 50 | typedef SkImageFilter INHERITED; |
| 51 | }; |
| 52 | |
| 53 | #endif |