2015-09-14 20:31:18 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2015 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkImageSource_DEFINED
|
|
|
|
#define SkImageSource_DEFINED
|
|
|
|
|
2016-03-24 17:41:47 +00:00
|
|
|
#include "SkImage.h"
|
2015-09-14 20:31:18 +00:00
|
|
|
#include "SkImageFilter.h"
|
|
|
|
|
|
|
|
class SK_API SkImageSource : public SkImageFilter {
|
|
|
|
public:
|
2016-04-17 21:27:05 +00:00
|
|
|
static sk_sp<SkImageFilter> Make(sk_sp<SkImage> image);
|
2016-04-01 16:28:51 +00:00
|
|
|
static sk_sp<SkImageFilter> Make(sk_sp<SkImage> image,
|
|
|
|
const SkRect& srcRect,
|
|
|
|
const SkRect& dstRect,
|
2016-04-17 21:27:05 +00:00
|
|
|
SkFilterQuality filterQuality);
|
2015-09-14 20:31:18 +00:00
|
|
|
|
2016-03-21 21:51:59 +00:00
|
|
|
SkRect computeFastBounds(const SkRect& src) const override;
|
2015-09-14 20:31:18 +00:00
|
|
|
|
|
|
|
SK_TO_STRING_OVERRIDE()
|
|
|
|
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkImageSource)
|
|
|
|
|
2016-04-01 16:28:51 +00:00
|
|
|
#ifdef SK_SUPPORT_LEGACY_IMAGEFILTER_PTR
|
|
|
|
static SkImageFilter* Create(SkImage* image) {
|
|
|
|
return Make(sk_ref_sp<SkImage>(image)).release();
|
|
|
|
}
|
|
|
|
static SkImageFilter* Create(SkImage* image,
|
|
|
|
const SkRect& srcRect,
|
|
|
|
const SkRect& dstRect,
|
|
|
|
SkFilterQuality filterQuality) {
|
|
|
|
return Make(sk_ref_sp<SkImage>(image), srcRect, dstRect, filterQuality).release();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-09-14 20:31:18 +00:00
|
|
|
protected:
|
|
|
|
void flatten(SkWriteBuffer&) const override;
|
|
|
|
|
2016-03-24 14:26:32 +00:00
|
|
|
sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
|
|
|
|
SkIPoint* offset) const override;
|
2015-09-14 20:31:18 +00:00
|
|
|
|
|
|
|
private:
|
2016-04-01 16:28:51 +00:00
|
|
|
explicit SkImageSource(sk_sp<SkImage>);
|
|
|
|
SkImageSource(sk_sp<SkImage>,
|
2015-09-14 20:31:18 +00:00
|
|
|
const SkRect& srcRect,
|
|
|
|
const SkRect& dstRect,
|
|
|
|
SkFilterQuality);
|
|
|
|
|
2016-03-17 21:31:39 +00:00
|
|
|
sk_sp<SkImage> fImage;
|
|
|
|
SkRect fSrcRect, fDstRect;
|
|
|
|
SkFilterQuality fFilterQuality;
|
2015-09-14 20:31:18 +00:00
|
|
|
|
|
|
|
typedef SkImageFilter INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|