1 /* 2 * Copyright 2012 The Android Open Source Project 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 SkBitmapSource_DEFINED 9 #define SkBitmapSource_DEFINED 10 11 #include "SkImageFilter.h" 12 #include "SkBitmap.h" 13 14 class SK_API SkBitmapSource : public SkImageFilter { 15 public: Create(const SkBitmap & bitmap)16 static SkBitmapSource* Create(const SkBitmap& bitmap) { 17 return SkNEW_ARGS(SkBitmapSource, (bitmap)); 18 } 19 static SkBitmapSource* Create(const SkBitmap& bitmap, 20 const SkRect& srcRect, const SkRect& dstRect, 21 SkFilterQuality filterQuality = kHigh_SkFilterQuality) { 22 return SkNEW_ARGS(SkBitmapSource, (bitmap, srcRect, dstRect, filterQuality)); 23 } 24 void computeFastBounds(const SkRect& src, SkRect* dst) const override; 25 26 SK_TO_STRING_OVERRIDE() 27 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkBitmapSource) 28 29 protected: 30 explicit SkBitmapSource(const SkBitmap& bitmap); 31 SkBitmapSource(const SkBitmap& bitmap, 32 const SkRect& srcRect, const SkRect& dstRect, 33 SkFilterQuality filterQuality); 34 void flatten(SkWriteBuffer&) const override; 35 36 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, 37 SkBitmap* result, SkIPoint* offset) const override; 38 39 private: 40 SkBitmap fBitmap; 41 SkRect fSrcRect, fDstRect; 42 SkFilterQuality fFilterQuality; 43 44 typedef SkImageFilter INHERITED; 45 }; 46 47 #endif 48