blob: cfd59ecce010d1395b60208f9d3ed0345454e0b8 [file] [log] [blame]
reed@android.com8a1c16f2008-12-17 15:59:43 +00001/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00002 * Copyright 2007 The Android Open Source Project
reed@android.com8a1c16f2008-12-17 15:59:43 +00003 *
epoger@google.comec3ed6a2011-07-28 14:26:00 +00004 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
reed@android.com8a1c16f2008-12-17 15:59:43 +00006 */
7
8#ifndef SkPixelXorXfermode_DEFINED
9#define SkPixelXorXfermode_DEFINED
10
11#include "SkXfermode.h"
12
13/** SkPixelXorXfermode implements a simple pixel xor (op ^ src ^ dst).
14 This transformation does not follow premultiplied conventions, therefore
15 this proc *always* returns an opaque color (alpha == 255). Thus it is
16 not really usefull for operating on blended colors.
17*/
tfarina@chromium.org6806fe82012-10-12 14:41:39 +000018class SK_API SkPixelXorXfermode : public SkXfermode {
reed@android.com8a1c16f2008-12-17 15:59:43 +000019public:
commit-bot@chromium.org0a2bf902014-02-20 20:40:19 +000020 static SkPixelXorXfermode* Create(SkColor opColor) {
21 return SkNEW_ARGS(SkPixelXorXfermode, (opColor));
22 }
reed@android.com8a1c16f2008-12-17 15:59:43 +000023
robertphillips@google.comb83b6b42013-01-22 14:32:09 +000024 SK_DEVELOPER_TO_STRING()
djsollen@google.comba28d032012-03-26 17:57:35 +000025 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPixelXorXfermode)
tomhudson@google.com1447c6f2011-04-27 14:09:52 +000026
reed@android.com8a1c16f2008-12-17 15:59:43 +000027protected:
commit-bot@chromium.org8b0e8ac2014-01-30 18:58:24 +000028 SkPixelXorXfermode(SkReadBuffer& rb);
29 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
djsollen@google.com54924242012-03-29 15:18:04 +000030
reed@android.com8a1c16f2008-12-17 15:59:43 +000031 // override from SkXfermode
mike@reedtribe.org61490fa2012-12-24 14:38:46 +000032 virtual SkPMColor xferColor(SkPMColor src, SkPMColor dst) const;
reed@android.com8a1c16f2008-12-17 15:59:43 +000033
commit-bot@chromium.org0a2bf902014-02-20 20:40:19 +000034#ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
35public:
36#endif
37 SkPixelXorXfermode(SkColor opColor) : fOpColor(opColor) {}
38
reed@android.com8a1c16f2008-12-17 15:59:43 +000039private:
40 SkColor fOpColor;
41
reed@android.com8a1c16f2008-12-17 15:59:43 +000042 typedef SkXfermode INHERITED;
43};
44
45#endif