ajuma | 77b6ba3 | 2016-01-08 14:58:35 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 Google Inc. |
| 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 SkPaintImageFilter_DEFINED |
| 9 | #define SkPaintImageFilter_DEFINED |
| 10 | |
Cary Clark | 4dc5a45 | 2018-05-21 11:56:57 -0400 | [diff] [blame] | 11 | #include "SkFlattenable.h" |
ajuma | 77b6ba3 | 2016-01-08 14:58:35 -0800 | [diff] [blame] | 12 | #include "SkImageFilter.h" |
| 13 | #include "SkPaint.h" |
| 14 | |
| 15 | class SK_API SkPaintImageFilter : public SkImageFilter { |
| 16 | public: |
| 17 | /** Create a new image filter which fills the given rectangle using the |
| 18 | * given paint. If no rectangle is specified, an output is produced with |
| 19 | * the same bounds as the input primitive (even though the input |
| 20 | * primitive's pixels are not used for processing). |
| 21 | * @param paint Paint to use when filling the rect. |
| 22 | * @param rect Rectangle of output pixels. If NULL or a given crop edge is |
| 23 | * not specified, the source primitive's bounds are used |
| 24 | * instead. |
| 25 | */ |
robertphillips | 225db44 | 2016-04-17 14:27:05 -0700 | [diff] [blame] | 26 | static sk_sp<SkImageFilter> Make(const SkPaint& paint, const CropRect* cropRect = nullptr); |
ajuma | 77b6ba3 | 2016-01-08 14:58:35 -0800 | [diff] [blame] | 27 | |
senorblanco | 6db0a7b | 2016-04-01 16:41:10 -0700 | [diff] [blame] | 28 | bool affectsTransparentBlack() const override; |
ajuma | 77b6ba3 | 2016-01-08 14:58:35 -0800 | [diff] [blame] | 29 | |
Cary Clark | 4dc5a45 | 2018-05-21 11:56:57 -0400 | [diff] [blame] | 30 | Factory getFactory() const override { return CreateProc; } |
ajuma | 77b6ba3 | 2016-01-08 14:58:35 -0800 | [diff] [blame] | 31 | |
| 32 | protected: |
| 33 | void flatten(SkWriteBuffer&) const override; |
robertphillips | 2302de9 | 2016-03-24 07:26:32 -0700 | [diff] [blame] | 34 | sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&, |
| 35 | SkIPoint* offset) const override; |
Matt Sarett | 31abf1f | 2017-04-07 16:54:04 -0400 | [diff] [blame] | 36 | sk_sp<SkImageFilter> onMakeColorSpace(SkColorSpaceXformer* xformer) const override; |
ajuma | 77b6ba3 | 2016-01-08 14:58:35 -0800 | [diff] [blame] | 37 | |
| 38 | private: |
| 39 | SkPaintImageFilter(const SkPaint& paint, const CropRect* rect); |
Cary Clark | 4dc5a45 | 2018-05-21 11:56:57 -0400 | [diff] [blame] | 40 | static sk_sp<SkFlattenable> CreateProc(SkReadBuffer&); |
| 41 | friend class SkFlattenable::PrivateInitializer; |
ajuma | 77b6ba3 | 2016-01-08 14:58:35 -0800 | [diff] [blame] | 42 | |
| 43 | SkPaint fPaint; |
| 44 | |
| 45 | typedef SkImageFilter INHERITED; |
| 46 | }; |
| 47 | |
| 48 | #endif |