fmalita | cd56f81 | 2015-09-14 13:31:18 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 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 SkImageSource_DEFINED |
| 9 | #define SkImageSource_DEFINED |
| 10 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "include/core/SkFlattenable.h" |
| 12 | #include "include/core/SkImage.h" |
| 13 | #include "include/core/SkImageFilter.h" |
fmalita | cd56f81 | 2015-09-14 13:31:18 -0700 | [diff] [blame] | 14 | |
fmalita | cd56f81 | 2015-09-14 13:31:18 -0700 | [diff] [blame] | 15 | class SK_API SkImageSource : public SkImageFilter { |
| 16 | public: |
robertphillips | 225db44 | 2016-04-17 14:27:05 -0700 | [diff] [blame] | 17 | static sk_sp<SkImageFilter> Make(sk_sp<SkImage> image); |
robertphillips | 549c899 | 2016-04-01 09:28:51 -0700 | [diff] [blame] | 18 | static sk_sp<SkImageFilter> Make(sk_sp<SkImage> image, |
| 19 | const SkRect& srcRect, |
| 20 | const SkRect& dstRect, |
robertphillips | 225db44 | 2016-04-17 14:27:05 -0700 | [diff] [blame] | 21 | SkFilterQuality filterQuality); |
fmalita | cd56f81 | 2015-09-14 13:31:18 -0700 | [diff] [blame] | 22 | |
senorblanco | e5e7984 | 2016-03-21 14:51:59 -0700 | [diff] [blame] | 23 | SkRect computeFastBounds(const SkRect& src) const override; |
fmalita | cd56f81 | 2015-09-14 13:31:18 -0700 | [diff] [blame] | 24 | |
fmalita | cd56f81 | 2015-09-14 13:31:18 -0700 | [diff] [blame] | 25 | protected: |
| 26 | void flatten(SkWriteBuffer&) const override; |
| 27 | |
robertphillips | 2302de9 | 2016-03-24 07:26:32 -0700 | [diff] [blame] | 28 | sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&, |
| 29 | SkIPoint* offset) const override; |
fmalita | cd56f81 | 2015-09-14 13:31:18 -0700 | [diff] [blame] | 30 | |
Robert Phillips | 1207843 | 2018-05-17 11:17:39 -0400 | [diff] [blame] | 31 | SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix& ctm, |
| 32 | MapDirection, const SkIRect* inputRect) const override; |
Xianzhu Wang | b449666 | 2017-09-25 10:26:40 -0700 | [diff] [blame] | 33 | |
fmalita | cd56f81 | 2015-09-14 13:31:18 -0700 | [diff] [blame] | 34 | private: |
Mike Klein | 4fee323 | 2018-10-18 17:27:16 -0400 | [diff] [blame] | 35 | SK_FLATTENABLE_HOOKS(SkImageSource) |
| 36 | |
robertphillips | 549c899 | 2016-04-01 09:28:51 -0700 | [diff] [blame] | 37 | explicit SkImageSource(sk_sp<SkImage>); |
| 38 | SkImageSource(sk_sp<SkImage>, |
fmalita | cd56f81 | 2015-09-14 13:31:18 -0700 | [diff] [blame] | 39 | const SkRect& srcRect, |
| 40 | const SkRect& dstRect, |
| 41 | SkFilterQuality); |
| 42 | |
robertphillips | 37bd7c3 | 2016-03-17 14:31:39 -0700 | [diff] [blame] | 43 | sk_sp<SkImage> fImage; |
| 44 | SkRect fSrcRect, fDstRect; |
| 45 | SkFilterQuality fFilterQuality; |
fmalita | cd56f81 | 2015-09-14 13:31:18 -0700 | [diff] [blame] | 46 | |
| 47 | typedef SkImageFilter INHERITED; |
| 48 | }; |
| 49 | |
| 50 | #endif |