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 "SkFlattenable.h" 12 #include "SkImage.h" 13 #include "SkImageFilter.h" 14 15 class SK_API SkImageSource : public SkImageFilter { 16 public: 17 static sk_sp<SkImageFilter> Make(sk_sp<SkImage> image); 18 static sk_sp<SkImageFilter> Make(sk_sp<SkImage> image, 19 const SkRect& srcRect, 20 const SkRect& dstRect, 21 SkFilterQuality filterQuality); 22 23 SkRect computeFastBounds(const SkRect& src) const override; 24 25 protected: 26 void flatten(SkWriteBuffer&) const override; 27 28 sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&, 29 SkIPoint* offset) const override; 30 sk_sp<SkImageFilter> onMakeColorSpace(SkColorSpaceXformer*) const override; 31 32 SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix& ctm, 33 MapDirection, const SkIRect* inputRect) const override; 34 35 private: 36 SK_FLATTENABLE_HOOKS(SkImageSource) 37 38 explicit SkImageSource(sk_sp<SkImage>); 39 SkImageSource(sk_sp<SkImage>, 40 const SkRect& srcRect, 41 const SkRect& dstRect, 42 SkFilterQuality); 43 44 sk_sp<SkImage> fImage; 45 SkRect fSrcRect, fDstRect; 46 SkFilterQuality fFilterQuality; 47 48 typedef SkImageFilter INHERITED; 49 }; 50 51 #endif 52