2012-08-20 14:53:21 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2012 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkBitmapSource_DEFINED
|
|
|
|
#define SkBitmapSource_DEFINED
|
|
|
|
|
|
|
|
#include "SkImageFilter.h"
|
|
|
|
#include "SkBitmap.h"
|
|
|
|
|
|
|
|
class SK_API SkBitmapSource : public SkImageFilter {
|
|
|
|
public:
|
2014-03-10 10:51:58 +00:00
|
|
|
static SkBitmapSource* Create(const SkBitmap& bitmap) {
|
|
|
|
return SkNEW_ARGS(SkBitmapSource, (bitmap));
|
|
|
|
}
|
2015-04-09 13:47:12 +00:00
|
|
|
static SkBitmapSource* Create(const SkBitmap& bitmap,
|
|
|
|
const SkRect& srcRect, const SkRect& dstRect,
|
|
|
|
SkFilterQuality filterQuality = kHigh_SkFilterQuality) {
|
|
|
|
return SkNEW_ARGS(SkBitmapSource, (bitmap, srcRect, dstRect, filterQuality));
|
2014-03-10 10:51:58 +00:00
|
|
|
}
|
2015-03-26 01:17:31 +00:00
|
|
|
void computeFastBounds(const SkRect& src, SkRect* dst) const override;
|
2012-08-20 14:53:21 +00:00
|
|
|
|
2014-12-19 21:49:15 +00:00
|
|
|
SK_TO_STRING_OVERRIDE()
|
2012-08-20 14:53:21 +00:00
|
|
|
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapSource)
|
|
|
|
|
|
|
|
protected:
|
2014-05-15 15:40:41 +00:00
|
|
|
explicit SkBitmapSource(const SkBitmap& bitmap);
|
2015-04-09 13:47:12 +00:00
|
|
|
SkBitmapSource(const SkBitmap& bitmap,
|
|
|
|
const SkRect& srcRect, const SkRect& dstRect,
|
|
|
|
SkFilterQuality filterQuality);
|
2015-03-26 01:17:31 +00:00
|
|
|
void flatten(SkWriteBuffer&) const override;
|
2014-05-15 15:40:41 +00:00
|
|
|
|
2014-03-14 15:44:01 +00:00
|
|
|
virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
2015-03-26 01:17:31 +00:00
|
|
|
SkBitmap* result, SkIPoint* offset) const override;
|
2012-08-20 14:53:21 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
SkBitmap fBitmap;
|
2013-12-09 18:31:42 +00:00
|
|
|
SkRect fSrcRect, fDstRect;
|
2015-04-09 13:47:12 +00:00
|
|
|
SkFilterQuality fFilterQuality;
|
|
|
|
|
2012-08-20 14:53:21 +00:00
|
|
|
typedef SkImageFilter INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|