epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
mike@reedtribe.org | 3334c3a | 2011-04-20 11:39:28 +0000 | [diff] [blame] | 2 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 3 | * Copyright 2011 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
mike@reedtribe.org | 3334c3a | 2011-04-20 11:39:28 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 9 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 10 | #include "SkPixelXorXfermode.h" |
| 11 | #include "SkColorPriv.h" |
| 12 | |
| 13 | // we always return an opaque color, 'cause I don't know what to do with |
| 14 | // the alpha-component and still return a valid premultiplied color. |
mike@reedtribe.org | 3334c3a | 2011-04-20 11:39:28 +0000 | [diff] [blame] | 15 | SkPMColor SkPixelXorXfermode::xferColor(SkPMColor src, SkPMColor dst) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 16 | SkPMColor res = src ^ dst ^ fOpColor; |
| 17 | res |= (SK_A32_MASK << SK_A32_SHIFT); // force it to be opaque |
| 18 | return res; |
| 19 | } |
| 20 | |
djsollen@google.com | 5492424 | 2012-03-29 15:18:04 +0000 | [diff] [blame^] | 21 | void SkPixelXorXfermode::flatten(SkFlattenableWriteBuffer& wb) const { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 22 | this->INHERITED::flatten(wb); |
| 23 | wb.write32(fOpColor); |
| 24 | } |
| 25 | |
| 26 | SkPixelXorXfermode::SkPixelXorXfermode(SkFlattenableReadBuffer& rb) |
djsollen@google.com | 5492424 | 2012-03-29 15:18:04 +0000 | [diff] [blame^] | 27 | : INHERITED(rb) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 28 | fOpColor = rb.readU32(); |
| 29 | } |
| 30 | |
caryclark@google.com | d26147a | 2011-12-15 14:16:43 +0000 | [diff] [blame] | 31 | SK_DEFINE_FLATTENABLE_REGISTRAR(SkPixelXorXfermode) |