OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
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 SkPaintImageFilter_DEFINED | 8 #ifndef SkPaintImageFilter_DEFINED |
9 #define SkPaintImageFilter_DEFINED | 9 #define SkPaintImageFilter_DEFINED |
10 | 10 |
11 #include "SkImageFilter.h" | 11 #include "SkImageFilter.h" |
12 #include "SkPaint.h" | 12 #include "SkPaint.h" |
13 | 13 |
14 class SK_API SkPaintImageFilter : public SkImageFilter { | 14 class SK_API SkPaintImageFilter : public SkImageFilter { |
15 public: | 15 public: |
16 /** Create a new image filter which fills the given rectangle using the | 16 /** Create a new image filter which fills the given rectangle using the |
17 * given paint. If no rectangle is specified, an output is produced with | 17 * given paint. If no rectangle is specified, an output is produced with |
18 * the same bounds as the input primitive (even though the input | 18 * the same bounds as the input primitive (even though the input |
19 * primitive's pixels are not used for processing). | 19 * primitive's pixels are not used for processing). |
20 * @param paint Paint to use when filling the rect. | 20 * @param paint Paint to use when filling the rect. |
21 * @param rect Rectangle of output pixels. If NULL or a given crop edge i
s | 21 * @param rect Rectangle of output pixels. If NULL or a given crop edge i
s |
22 * not specified, the source primitive's bounds are used | 22 * not specified, the source primitive's bounds are used |
23 * instead. | 23 * instead. |
24 */ | 24 */ |
25 static SkImageFilter* Create(const SkPaint& paint, const CropRect* rect = NU
LL); | 25 static sk_sp<SkImageFilter> Make(const SkPaint& paint, const CropRect* cropR
ect = nullptr) { |
| 26 return sk_sp<SkImageFilter>(new SkPaintImageFilter(paint, cropRect)); |
| 27 } |
26 | 28 |
27 bool canComputeFastBounds() const override; | 29 bool canComputeFastBounds() const override; |
28 | 30 |
29 SK_TO_STRING_OVERRIDE() | 31 SK_TO_STRING_OVERRIDE() |
30 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPaintImageFilter) | 32 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPaintImageFilter) |
31 | 33 |
| 34 #ifdef SK_SUPPORT_LEGACY_IMAGEFILTER_PTR |
| 35 static SkImageFilter* Create(const SkPaint& paint, const CropRect* rect = nu
llptr) { |
| 36 return Make(paint, rect).release(); |
| 37 } |
| 38 #endif |
| 39 |
32 protected: | 40 protected: |
33 void flatten(SkWriteBuffer&) const override; | 41 void flatten(SkWriteBuffer&) const override; |
34 sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&, | 42 sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&, |
35 SkIPoint* offset) const override; | 43 SkIPoint* offset) const override; |
36 | 44 |
37 private: | 45 private: |
38 SkPaintImageFilter(const SkPaint& paint, const CropRect* rect); | 46 SkPaintImageFilter(const SkPaint& paint, const CropRect* rect); |
39 | 47 |
40 SkPaint fPaint; | 48 SkPaint fPaint; |
41 | 49 |
42 typedef SkImageFilter INHERITED; | 50 typedef SkImageFilter INHERITED; |
43 }; | 51 }; |
44 | 52 |
45 #endif | 53 #endif |
OLD | NEW |