Skia
2DGraphicsLibrary
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SkImageSource.h
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 
11 #include "SkImage.h"
12 #include "SkImageFilter.h"
13 
14 class SK_API SkImageSource : public SkImageFilter {
15 public:
16  static sk_sp<SkImageFilter> Make(sk_sp<SkImage> image);
17  static sk_sp<SkImageFilter> Make(sk_sp<SkImage> image,
18  const SkRect& srcRect,
19  const SkRect& dstRect,
20  SkFilterQuality filterQuality);
21 
22  SkRect computeFastBounds(const SkRect& src) const override;
23 
24  SK_TO_STRING_OVERRIDE()
25  SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkImageSource)
26 
27 #ifdef SK_SUPPORT_LEGACY_IMAGEFILTER_PTR
28  static SkImageFilter* Create(SkImage* image) {
29  return Make(sk_ref_sp<SkImage>(image)).release();
30  }
31  static SkImageFilter* Create(SkImage* image,
32  const SkRect& srcRect,
33  const SkRect& dstRect,
34  SkFilterQuality filterQuality) {
35  return Make(sk_ref_sp<SkImage>(image), srcRect, dstRect, filterQuality).release();
36  }
37 #endif
38 
39 protected:
40  void flatten(SkWriteBuffer&) const override;
41 
42  sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
43  SkIPoint* offset) const override;
44 
45 private:
46  explicit SkImageSource(sk_sp<SkImage>);
48  const SkRect& srcRect,
49  const SkRect& dstRect,
50  SkFilterQuality);
51 
52  sk_sp<SkImage> fImage;
53  SkRect fSrcRect, fDstRect;
54  SkFilterQuality fFilterQuality;
55 
56  typedef SkImageFilter INHERITED;
57 };
58 
59 #endif
T *SK_WARN_UNUSED_RESULT release()
Return the bare pointer, and set the internal object pointer to nullptr.
Definition: SkRefCnt.h:363
void flatten(SkWriteBuffer &) const override
Override this if your subclass needs to record data that it will need to recreate itself from its Cre...
virtual sk_sp< SkSpecialImage > onFilterImage(SkSpecialImage *src, const Context &, SkIPoint *offset) const =0
This is the virtual which should be overridden by the derived class to perform image filtering...
Definition: SkRefCnt.h:135
Base class for image filters.
Definition: SkImageFilter.h:35
Definition: SkImageSource.h:14
Definition: SkWriteBuffer.h:26
Definition: SkRect.h:390
Definition: SkImageFilter.h:37
SkImage is an abstraction for drawing a rectagle of pixels, though the particular type of image could...
Definition: SkImage.h:45
SkIPoint holds two 32 bit integer coordinates.
Definition: SkPoint.h:40