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 SkXfermodeImageFilter_DEFINED 9 #define SkXfermodeImageFilter_DEFINED 10 11 #include "SkImageFilter.h" 12 13 class SkBitmap; 14 class SkXfermode; 15 16 class SK_API SkXfermodeImageFilter : public SkImageFilter { 17 /** 18 * This filter takes an xfermode, and uses it to composite the foreground 19 * over the background. If foreground or background is NULL, the input 20 * bitmap (src) is used instead. 21 */ 22 23 public: 24 SkXfermodeImageFilter(SkXfermode* mode, SkImageFilter* background, 25 SkImageFilter* foreground = NULL, const CropRect* cropRect = NULL); 26 27 virtual ~SkXfermodeImageFilter(); 28 29 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkXfermodeImageFilter) 30 31 virtual bool onFilterImage(Proxy* proxy, 32 const SkBitmap& src, 33 const SkMatrix& ctm, 34 SkBitmap* dst, 35 SkIPoint* offset) SK_OVERRIDE; 36 #if SK_SUPPORT_GPU 37 virtual bool canFilterImageGPU() const SK_OVERRIDE { return !cropRectIsSet(); } 38 virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm, 39 SkBitmap* result, SkIPoint* offset) SK_OVERRIDE; 40 #endif 41 42 protected: 43 explicit SkXfermodeImageFilter(SkFlattenableReadBuffer& buffer); 44 virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE; 45 46 private: 47 SkXfermode* fMode; 48 typedef SkImageFilter INHERITED; 49 }; 50 51 #endif 52