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 static SkImageFilter* Create(SkXfermode* mode, SkImageFilter* background, 25 SkImageFilter* foreground = NULL, 26 const CropRect* cropRect = NULL) { 27 SkImageFilter* inputs[2] = { background, foreground }; 28 return new SkXfermodeImageFilter(mode, inputs, cropRect); 29 } 30 31 SK_TO_STRING_OVERRIDE() 32 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkXfermodeImageFilter) 33 34 bool onFilterImageDeprecated(Proxy* proxy, 35 const SkBitmap& src, 36 const Context& ctx, 37 SkBitmap* dst, 38 SkIPoint* offset) const override; 39 #if SK_SUPPORT_GPU 40 bool canFilterImageGPU() const override; 41 bool filterImageGPUDeprecated(Proxy* proxy, const SkBitmap& src, const Context& ctx, 42 SkBitmap* result, SkIPoint* offset) const override; 43 #endif 44 45 protected: 46 SkXfermodeImageFilter(SkXfermode* mode, SkImageFilter* inputs[2], 47 const CropRect* cropRect); 48 void flatten(SkWriteBuffer&) const override; 49 50 private: 51 SkAutoTUnref<SkXfermode> fMode; 52 typedef SkImageFilter INHERITED; 53 }; 54 55 #endif 56