michael@0: /* michael@0: * Copyright 2012 The Android Open Source Project michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: #ifndef SkBitmapSource_DEFINED michael@0: #define SkBitmapSource_DEFINED michael@0: michael@0: #include "SkImageFilter.h" michael@0: #include "SkBitmap.h" michael@0: michael@0: class SK_API SkBitmapSource : public SkImageFilter { michael@0: public: michael@0: static SkBitmapSource* Create(const SkBitmap& bitmap) { michael@0: return SkNEW_ARGS(SkBitmapSource, (bitmap)); michael@0: } michael@0: static SkBitmapSource* Create(const SkBitmap& bitmap, const SkRect& srcRect, michael@0: const SkRect& dstRect) { michael@0: return SkNEW_ARGS(SkBitmapSource, (bitmap, srcRect, dstRect)); michael@0: } michael@0: virtual void computeFastBounds(const SkRect& src, SkRect* dst) const SK_OVERRIDE; michael@0: michael@0: SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapSource) michael@0: michael@0: protected: michael@0: explicit SkBitmapSource(SkReadBuffer& buffer); michael@0: virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; michael@0: virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, michael@0: SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE; michael@0: virtual bool onFilterBounds(const SkIRect& src, const SkMatrix& ctm, SkIRect* dst) const SK_OVERRIDE; michael@0: michael@0: #ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS michael@0: public: michael@0: #endif michael@0: explicit SkBitmapSource(const SkBitmap& bitmap); michael@0: SkBitmapSource(const SkBitmap& bitmap, const SkRect& srcRect, const SkRect& dstRect); michael@0: michael@0: private: michael@0: SkBitmap fBitmap; michael@0: SkRect fSrcRect, fDstRect; michael@0: typedef SkImageFilter INHERITED; michael@0: }; michael@0: michael@0: #endif