blob: 8b7f3388ff705c82364c30b928ecb18f1e9d8b72 [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:
halcanary385fe4d2015-08-26 13:07:48 -070020 static SkPixelXorXfermode* Create(SkColor opColor) { return new SkPixelXorXfermode(opColor); }
reed@android.com8a1c16f2008-12-17 15:59:43 +000021
commit-bot@chromium.org0f10f7b2014-03-13 18:02:17 +000022 SK_TO_STRING_OVERRIDE()
djsollen@google.comba28d032012-03-26 17:57:35 +000023 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPixelXorXfermode)
tomhudson@google.com1447c6f2011-04-27 14:09:52 +000024
reed@android.com8a1c16f2008-12-17 15:59:43 +000025protected:
commit-bot@chromium.orgbd0be252014-05-15 15:40:41 +000026 explicit SkPixelXorXfermode(SkColor opColor) : fOpColor(opColor) {}
mtklein36352bf2015-03-25 18:17:31 -070027 void flatten(SkWriteBuffer&) const override;
djsollen@google.com54924242012-03-29 15:18:04 +000028
reed@android.com8a1c16f2008-12-17 15:59:43 +000029 // override from SkXfermode
mtklein36352bf2015-03-25 18:17:31 -070030 SkPMColor xferColor(SkPMColor src, SkPMColor dst) const override;
reed@android.com8a1c16f2008-12-17 15:59:43 +000031
32private:
33 SkColor fOpColor;
34
reed@android.com8a1c16f2008-12-17 15:59:43 +000035 typedef SkXfermode INHERITED;
36};
37
38#endif