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

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

Issue 1611633002: Remove SkLerpXfermode (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove recent usages 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/SkArithmeticMode.cpp ('k') | src/effects/SkToFromValue.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "SkLerpXfermode.h"
9 #include "SkColorPriv.h"
10 #include "SkReadBuffer.h"
11 #include "SkWriteBuffer.h"
12 #include "SkString.h"
13 #include "SkValue.h"
14 #include "SkValueKeys.h"
15
16 SkXfermode* SkLerpXfermode::Create(SkScalar scale) {
17 int scale256 = SkScalarRoundToInt(scale * 256);
18 if (scale256 >= 256) {
19 return SkXfermode::Create(SkXfermode::kSrc_Mode);
20 } else if (scale256 <= 0) {
21 return SkXfermode::Create(SkXfermode::kDst_Mode);
22 }
23 return new SkLerpXfermode(scale256);
24 }
25
26 SkLerpXfermode::SkLerpXfermode(unsigned scale256) : fScale256(scale256) {}
27
28 void SkLerpXfermode::flatten(SkWriteBuffer& buffer) const {
29 buffer.writeUInt(fScale256);
30 }
31
32 SkFlattenable* SkLerpXfermode::CreateProc(SkReadBuffer& buffer) {
33 return new SkLerpXfermode(buffer.readUInt());
34 }
35
36 void SkLerpXfermode::xfer32(SkPMColor dst[], const SkPMColor src[], int count,
37 const SkAlpha aa[]) const {
38 const int scale = fScale256;
39
40 if (aa) {
41 for (int i = 0; i < count; ++i) {
42 unsigned a = aa[i];
43 if (a) {
44 SkPMColor dstC = dst[i];
45 SkPMColor resC = SkFastFourByteInterp256(src[i], dstC, scale);
46 if (a < 255) {
47 resC = SkFastFourByteInterp256(resC, dstC, a + (a >> 7));
48 }
49 dst[i] = resC;
50 }
51 }
52 } else {
53 for (int i = 0; i < count; ++i) {
54 dst[i] = SkFastFourByteInterp256(src[i], dst[i], scale);
55 }
56 }
57 }
58
59 void SkLerpXfermode::xfer16(uint16_t dst[], const SkPMColor src[], int count,
60 const SkAlpha aa[]) const {
61 const int scale = fScale256;
62
63 if (aa) {
64 for (int i = 0; i < count; ++i) {
65 unsigned a = aa[i];
66 if (a) {
67 SkPMColor dstC = SkPixel16ToPixel32(dst[i]);
68 SkPMColor resC = SkFastFourByteInterp256(src[i], dstC, scale);
69 if (a < 255) {
70 resC = SkFastFourByteInterp256(resC, dstC, a + (a >> 7));
71 }
72 dst[i] = SkPixel32ToPixel16(resC);
73 }
74 }
75 } else {
76 for (int i = 0; i < count; ++i) {
77 SkPMColor dstC = SkPixel16ToPixel32(dst[i]);
78 SkPMColor resC = SkFastFourByteInterp256(src[i], dstC, scale);
79 dst[i] = SkPixel32ToPixel16(resC);
80 }
81 }
82 }
83
84 void SkLerpXfermode::xferA8(SkAlpha dst[], const SkPMColor src[], int count,
85 const SkAlpha aa[]) const {
86 const int scale = fScale256;
87
88 if (aa) {
89 for (int i = 0; i < count; ++i) {
90 unsigned a = aa[i];
91 if (a) {
92 unsigned dstA = dst[i];
93 unsigned resA = SkAlphaBlend(SkGetPackedA32(src[i]), dstA, scale );
94 if (a < 255) {
95 resA = SkAlphaBlend(resA, dstA, a + (a >> 7));
96 }
97 dst[i] = resA;
98 }
99 }
100 } else {
101 for (int i = 0; i < count; ++i) {
102 dst[i] = SkAlphaBlend(SkGetPackedA32(src[i]), dst[i], scale);
103 }
104 }
105 }
106
107 #ifndef SK_IGNORE_TO_STRING
108 void SkLerpXfermode::toString(SkString* str) const {
109 str->printf("SkLerpXfermode: scale: %g", fScale256 / 256.0);
110 }
111 #endif
112
113 SkValue SkLerpXfermode::asValue() const {
114 auto value = SkValue::Object(SkValue::LerpXfermode);
115 value.set(SkValueKeys::LerpXfermode::kScale,
116 SkValue::FromF32(fScale256 / 256.0f));
117 return value;
118 }
OLDNEW
« no previous file with comments | « src/effects/SkArithmeticMode.cpp ('k') | src/effects/SkToFromValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698