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

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

Issue 1832223002: switch xfermodes over to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 4 years, 8 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
OLDNEW
1 /* 1 /*
2 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkAvoidXfermode.h" 8 #include "SkAvoidXfermode.h"
9 #include "SkColorPriv.h" 9 #include "SkColorPriv.h"
10 #include "SkReadBuffer.h" 10 #include "SkReadBuffer.h"
11 #include "SkWriteBuffer.h" 11 #include "SkWriteBuffer.h"
12 #include "SkString.h" 12 #include "SkString.h"
13 13
14 SkAvoidXfermode::SkAvoidXfermode(SkColor opColor, U8CPU tolerance, Mode mode) { 14 SkAvoidXfermode::SkAvoidXfermode(SkColor opColor, U8CPU tolerance, Mode mode) {
15 if (tolerance > 255) { 15 if (tolerance > 255) {
16 tolerance = 255; 16 tolerance = 255;
17 } 17 }
18 fTolerance = SkToU8(tolerance); 18 fTolerance = SkToU8(tolerance);
19 fOpColor = opColor; 19 fOpColor = opColor;
20 fDistMul = (256 << 14) / (tolerance + 1); 20 fDistMul = (256 << 14) / (tolerance + 1);
21 fMode = mode; 21 fMode = mode;
22 } 22 }
23 23
24 SkFlattenable* SkAvoidXfermode::CreateProc(SkReadBuffer& buffer) { 24 SkFlattenable* SkAvoidXfermode::CreateProc(SkReadBuffer& buffer) {
25 const SkColor color = buffer.readColor(); 25 const SkColor color = buffer.readColor();
26 const unsigned tolerance = buffer.readUInt(); 26 const unsigned tolerance = buffer.readUInt();
27 const unsigned mode = buffer.readUInt(); 27 const unsigned mode = buffer.readUInt();
28 return Create(color, tolerance, (Mode)mode); 28 return Make(color, tolerance, (Mode)mode).release();
29 } 29 }
30 30
31 void SkAvoidXfermode::flatten(SkWriteBuffer& buffer) const { 31 void SkAvoidXfermode::flatten(SkWriteBuffer& buffer) const {
32 buffer.writeColor(fOpColor); 32 buffer.writeColor(fOpColor);
33 buffer.writeUInt(fTolerance); 33 buffer.writeUInt(fTolerance);
34 buffer.writeUInt(fMode); 34 buffer.writeUInt(fMode);
35 } 35 }
36 36
37 // returns 0..31 37 // returns 0..31
38 static unsigned color_dist16(uint16_t c, unsigned r, unsigned g, unsigned b) { 38 static unsigned color_dist16(uint16_t c, unsigned r, unsigned g, unsigned b) {
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 void SkAvoidXfermode::toString(SkString* str) const { 535 void SkAvoidXfermode::toString(SkString* str) const {
536 str->append("AvoidXfermode: opColor: "); 536 str->append("AvoidXfermode: opColor: ");
537 str->appendHex(fOpColor); 537 str->appendHex(fOpColor);
538 str->appendf("tolerance: %d ", fTolerance); 538 str->appendf("tolerance: %d ", fTolerance);
539 539
540 static const char* gModeStrings[] = { "Avoid", "Target" }; 540 static const char* gModeStrings[] = { "Avoid", "Target" };
541 541
542 str->appendf("mode: %s", gModeStrings[fMode]); 542 str->appendf("mode: %s", gModeStrings[fMode]);
543 } 543 }
544 #endif 544 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698