OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkPixelXorXfermode.h" | 10 #include "SkPixelXorXfermode.h" |
11 #include "SkColorPriv.h" | 11 #include "SkColorPriv.h" |
12 #include "SkReadBuffer.h" | 12 #include "SkReadBuffer.h" |
13 #include "SkWriteBuffer.h" | 13 #include "SkWriteBuffer.h" |
14 #include "SkString.h" | 14 #include "SkString.h" |
15 #include "SkValue.h" | |
15 | 16 |
16 // we always return an opaque color, 'cause I don't know what to do with | 17 // we always return an opaque color, 'cause I don't know what to do with |
17 // the alpha-component and still return a valid premultiplied color. | 18 // the alpha-component and still return a valid premultiplied color. |
18 SkPMColor SkPixelXorXfermode::xferColor(SkPMColor src, SkPMColor dst) const { | 19 SkPMColor SkPixelXorXfermode::xferColor(SkPMColor src, SkPMColor dst) const { |
19 SkPMColor res = src ^ dst ^ fOpColor; | 20 SkPMColor res = src ^ dst ^ fOpColor; |
20 res |= (SK_A32_MASK << SK_A32_SHIFT); // force it to be opaque | 21 res |= (SK_A32_MASK << SK_A32_SHIFT); // force it to be opaque |
21 return res; | 22 return res; |
22 } | 23 } |
23 | 24 |
24 void SkPixelXorXfermode::flatten(SkWriteBuffer& wb) const { | 25 void SkPixelXorXfermode::flatten(SkWriteBuffer& wb) const { |
25 wb.writeColor(fOpColor); | 26 wb.writeColor(fOpColor); |
26 } | 27 } |
27 | 28 |
28 SkFlattenable* SkPixelXorXfermode::CreateProc(SkReadBuffer& buffer) { | 29 SkFlattenable* SkPixelXorXfermode::CreateProc(SkReadBuffer& buffer) { |
29 return Create(buffer.readColor()); | 30 return Create(buffer.readColor()); |
30 } | 31 } |
31 | 32 |
32 #ifndef SK_IGNORE_TO_STRING | 33 #ifndef SK_IGNORE_TO_STRING |
33 void SkPixelXorXfermode::toString(SkString* str) const { | 34 void SkPixelXorXfermode::toString(SkString* str) const { |
34 str->append("SkPixelXorXfermode: "); | 35 str->append("SkPixelXorXfermode: "); |
35 str->appendHex(fOpColor); | 36 str->appendHex(fOpColor); |
36 } | 37 } |
37 #endif | 38 #endif |
39 | |
40 enum { kOpColor }; | |
mtklein
2016/01/21 17:46:19
?
hal.canary
2016/01/21 18:35:21
forgot that one. good catch
| |
41 | |
42 SkValue SkPixelXorXfermode::asValue() const { | |
43 auto value = SkValue::Object(SkValue::PixelXorXfermode); | |
44 value.set(kOpColor, SkValue::FromU32(SkToU32(fOpColor))); | |
45 return value; | |
46 } | |
OLD | NEW |