2 * Copyright 2013 The Android Open Source Project
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef SkXfermodeImageFilter_DEFINED
9 #define SkXfermodeImageFilter_DEFINED
11 #include "SkImageFilter.h"
16 class SK_API SkXfermodeImageFilter : public SkImageFilter {
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.
24 virtual ~SkXfermodeImageFilter();
26 static SkXfermodeImageFilter* Create(SkXfermode* mode, SkImageFilter* background,
27 SkImageFilter* foreground = NULL,
28 const CropRect* cropRect = NULL,
29 uint32_t uniqueID = 0) {
30 SkImageFilter* inputs[2] = { background, foreground };
31 return SkNEW_ARGS(SkXfermodeImageFilter, (mode, inputs, cropRect, uniqueID));
34 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkXfermodeImageFilter)
36 virtual bool onFilterImage(Proxy* proxy,
40 SkIPoint* offset) const SK_OVERRIDE;
42 virtual bool canFilterImageGPU() const SK_OVERRIDE;
43 virtual bool filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx,
44 SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
48 SkXfermodeImageFilter(SkXfermode* mode, SkImageFilter* inputs[2],
49 const CropRect* cropRect, uint32_t uniqueID);
50 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
51 explicit SkXfermodeImageFilter(SkReadBuffer& buffer);
53 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
57 typedef SkImageFilter INHERITED;