reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 1 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 2 | * Copyright 2007 The Android Open Source Project |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 3 | * |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 6 | */ |
| 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.org | 6806fe8 | 2012-10-12 14:41:39 +0000 | [diff] [blame] | 18 | class SK_API SkPixelXorXfermode : public SkXfermode { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 19 | public: |
commit-bot@chromium.org | 0a2bf90 | 2014-02-20 20:40:19 +0000 | [diff] [blame] | 20 | static SkPixelXorXfermode* Create(SkColor opColor) { |
| 21 | return SkNEW_ARGS(SkPixelXorXfermode, (opColor)); |
| 22 | } |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 23 | |
commit-bot@chromium.org | 0f10f7b | 2014-03-13 18:02:17 +0000 | [diff] [blame] | 24 | SK_TO_STRING_OVERRIDE() |
djsollen@google.com | ba28d03 | 2012-03-26 17:57:35 +0000 | [diff] [blame] | 25 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPixelXorXfermode) |
tomhudson@google.com | 1447c6f | 2011-04-27 14:09:52 +0000 | [diff] [blame] | 26 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 27 | protected: |
commit-bot@chromium.org | bd0be25 | 2014-05-15 15:40:41 +0000 | [diff] [blame] | 28 | explicit SkPixelXorXfermode(SkColor opColor) : fOpColor(opColor) {} |
| 29 | explicit SkPixelXorXfermode(SkReadBuffer& rb); |
commit-bot@chromium.org | 8b0e8ac | 2014-01-30 18:58:24 +0000 | [diff] [blame] | 30 | virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
djsollen@google.com | 5492424 | 2012-03-29 15:18:04 +0000 | [diff] [blame] | 31 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 32 | // override from SkXfermode |
mike@reedtribe.org | 61490fa | 2012-12-24 14:38:46 +0000 | [diff] [blame] | 33 | virtual SkPMColor xferColor(SkPMColor src, SkPMColor dst) const; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 34 | |
| 35 | private: |
| 36 | SkColor fOpColor; |
| 37 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 38 | typedef SkXfermode INHERITED; |
| 39 | }; |
| 40 | |
| 41 | #endif |