SkPictureImageFilter.h revision 4cb543d6057b692e1099e9f115155f0bf323a0c8
1/* 2 * Copyright 2013 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 SkPictureImageFilter_DEFINED 9#define SkPictureImageFilter_DEFINED 10 11#include "SkImageFilter.h" 12#include "SkPicture.h" 13 14class SK_API SkPictureImageFilter : public SkImageFilter { 15public: 16 /** 17 * Refs the passed-in picture. 18 */ 19 static SkPictureImageFilter* Create(SkPicture* picture) { 20 return SkNEW_ARGS(SkPictureImageFilter, (picture)); 21 } 22 23 /** 24 * Refs the passed-in picture. cropRect can be used to crop or expand the destination rect when 25 * the picture is drawn. (No scaling is implied by the dest rect; only the CTM is applied.) 26 */ 27 static SkPictureImageFilter* Create(SkPicture* picture, const SkRect& cropRect) { 28 return SkNEW_ARGS(SkPictureImageFilter, (picture, cropRect)); 29 } 30 31 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPictureImageFilter) 32 33protected: 34 virtual ~SkPictureImageFilter(); 35 /* Constructs an SkPictureImageFilter object from an SkReadBuffer. 36 * Note: If the SkPictureImageFilter object construction requires bitmap 37 * decoding, the decoder must be set on the SkReadBuffer parameter by calling 38 * SkReadBuffer::setBitmapDecoder() before calling this constructor. 39 * @param SkReadBuffer Serialized picture data. 40 */ 41 explicit SkPictureImageFilter(SkReadBuffer&); 42 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; 43 virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&, 44 SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE; 45 46#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS 47public: 48#endif 49 explicit SkPictureImageFilter(SkPicture* picture); 50 SkPictureImageFilter(SkPicture* picture, const SkRect& cropRect); 51 52private: 53 SkPicture* fPicture; 54 SkRect fCropRect; 55 typedef SkImageFilter INHERITED; 56}; 57 58#endif 59