Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/effects/SkPixelXorXfermode.cpp

Issue 1585813004: SkValue: SkXfermode (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: space Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/effects/SkLerpXfermode.cpp ('k') | src/effects/SkToFromValue.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
16 #include "SkValueKeys.h"
15 17
16 // we always return an opaque color, 'cause I don't know what to do with 18 // 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. 19 // the alpha-component and still return a valid premultiplied color.
18 SkPMColor SkPixelXorXfermode::xferColor(SkPMColor src, SkPMColor dst) const { 20 SkPMColor SkPixelXorXfermode::xferColor(SkPMColor src, SkPMColor dst) const {
19 SkPMColor res = src ^ dst ^ fOpColor; 21 SkPMColor res = src ^ dst ^ fOpColor;
20 res |= (SK_A32_MASK << SK_A32_SHIFT); // force it to be opaque 22 res |= (SK_A32_MASK << SK_A32_SHIFT); // force it to be opaque
21 return res; 23 return res;
22 } 24 }
23 25
24 void SkPixelXorXfermode::flatten(SkWriteBuffer& wb) const { 26 void SkPixelXorXfermode::flatten(SkWriteBuffer& wb) const {
25 wb.writeColor(fOpColor); 27 wb.writeColor(fOpColor);
26 } 28 }
27 29
28 SkFlattenable* SkPixelXorXfermode::CreateProc(SkReadBuffer& buffer) { 30 SkFlattenable* SkPixelXorXfermode::CreateProc(SkReadBuffer& buffer) {
29 return Create(buffer.readColor()); 31 return Create(buffer.readColor());
30 } 32 }
31 33
32 #ifndef SK_IGNORE_TO_STRING 34 #ifndef SK_IGNORE_TO_STRING
33 void SkPixelXorXfermode::toString(SkString* str) const { 35 void SkPixelXorXfermode::toString(SkString* str) const {
34 str->append("SkPixelXorXfermode: "); 36 str->append("SkPixelXorXfermode: ");
35 str->appendHex(fOpColor); 37 str->appendHex(fOpColor);
36 } 38 }
37 #endif 39 #endif
40
41 SkValue SkPixelXorXfermode::asValue() const {
42 auto value = SkValue::Object(SkValue::PixelXorXfermode);
43 value.set(SkValueKeys::PixelXorXfermode::kOpColor,
44 SkValue::FromU32(SkToU32(fOpColor)));
45 return value;
46 }
OLDNEW
« no previous file with comments | « src/effects/SkLerpXfermode.cpp ('k') | src/effects/SkToFromValue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698