blob: 64648457f8f61d66e13af1094fe3c4edca794306 [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
commit-bot@chromium.org0f10f7b2014-03-13 18:02:17 +000024 SK_TO_STRING_OVERRIDE()
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.orgbd0be252014-05-15 15:40:41 +000028 explicit SkPixelXorXfermode(SkColor opColor) : fOpColor(opColor) {}
29 explicit SkPixelXorXfermode(SkReadBuffer& rb);
commit-bot@chromium.org8b0e8ac2014-01-30 18:58:24 +000030 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
djsollen@google.com54924242012-03-29 15:18:04 +000031
reed@android.com8a1c16f2008-12-17 15:59:43 +000032 // override from SkXfermode
mike@reedtribe.org61490fa2012-12-24 14:38:46 +000033 virtual SkPMColor xferColor(SkPMColor src, SkPMColor dst) const;
reed@android.com8a1c16f2008-12-17 15:59:43 +000034
35private:
36 SkColor fOpColor;
37
reed@android.com8a1c16f2008-12-17 15:59:43 +000038 typedef SkXfermode INHERITED;
39};
40
41#endif