blob: dc02f3dd78ddf8677ee5c37afd80a81eb630d240 [file] [log] [blame]
fmalitacd56f812015-09-14 13:31:18 -07001/*
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 Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/core/SkFlattenable.h"
12#include "include/core/SkImage.h"
13#include "include/core/SkImageFilter.h"
fmalitacd56f812015-09-14 13:31:18 -070014
fmalitacd56f812015-09-14 13:31:18 -070015class SK_API SkImageSource : public SkImageFilter {
16public:
robertphillips225db442016-04-17 14:27:05 -070017 static sk_sp<SkImageFilter> Make(sk_sp<SkImage> image);
robertphillips549c8992016-04-01 09:28:51 -070018 static sk_sp<SkImageFilter> Make(sk_sp<SkImage> image,
19 const SkRect& srcRect,
20 const SkRect& dstRect,
robertphillips225db442016-04-17 14:27:05 -070021 SkFilterQuality filterQuality);
fmalitacd56f812015-09-14 13:31:18 -070022
senorblancoe5e79842016-03-21 14:51:59 -070023 SkRect computeFastBounds(const SkRect& src) const override;
fmalitacd56f812015-09-14 13:31:18 -070024
fmalitacd56f812015-09-14 13:31:18 -070025protected:
26 void flatten(SkWriteBuffer&) const override;
27
robertphillips2302de92016-03-24 07:26:32 -070028 sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
29 SkIPoint* offset) const override;
fmalitacd56f812015-09-14 13:31:18 -070030
Robert Phillips12078432018-05-17 11:17:39 -040031 SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix& ctm,
32 MapDirection, const SkIRect* inputRect) const override;
Xianzhu Wangb4496662017-09-25 10:26:40 -070033
fmalitacd56f812015-09-14 13:31:18 -070034private:
Mike Klein4fee3232018-10-18 17:27:16 -040035 SK_FLATTENABLE_HOOKS(SkImageSource)
36
robertphillips549c8992016-04-01 09:28:51 -070037 explicit SkImageSource(sk_sp<SkImage>);
38 SkImageSource(sk_sp<SkImage>,
fmalitacd56f812015-09-14 13:31:18 -070039 const SkRect& srcRect,
40 const SkRect& dstRect,
41 SkFilterQuality);
42
robertphillips37bd7c32016-03-17 14:31:39 -070043 sk_sp<SkImage> fImage;
44 SkRect fSrcRect, fDstRect;
45 SkFilterQuality fFilterQuality;
fmalitacd56f812015-09-14 13:31:18 -070046
47 typedef SkImageFilter INHERITED;
48};
49
50#endif