OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
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 "SkLerpXfermode.h" | 8 #include "SkLerpXfermode.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 #include "SkValue.h" |
| 14 #include "SkValueKeys.h" |
13 | 15 |
14 SkXfermode* SkLerpXfermode::Create(SkScalar scale) { | 16 SkXfermode* SkLerpXfermode::Create(SkScalar scale) { |
15 int scale256 = SkScalarRoundToInt(scale * 256); | 17 int scale256 = SkScalarRoundToInt(scale * 256); |
16 if (scale256 >= 256) { | 18 if (scale256 >= 256) { |
17 return SkXfermode::Create(SkXfermode::kSrc_Mode); | 19 return SkXfermode::Create(SkXfermode::kSrc_Mode); |
18 } else if (scale256 <= 0) { | 20 } else if (scale256 <= 0) { |
19 return SkXfermode::Create(SkXfermode::kDst_Mode); | 21 return SkXfermode::Create(SkXfermode::kDst_Mode); |
20 } | 22 } |
21 return new SkLerpXfermode(scale256); | 23 return new SkLerpXfermode(scale256); |
22 } | 24 } |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 dst[i] = SkAlphaBlend(SkGetPackedA32(src[i]), dst[i], scale); | 102 dst[i] = SkAlphaBlend(SkGetPackedA32(src[i]), dst[i], scale); |
101 } | 103 } |
102 } | 104 } |
103 } | 105 } |
104 | 106 |
105 #ifndef SK_IGNORE_TO_STRING | 107 #ifndef SK_IGNORE_TO_STRING |
106 void SkLerpXfermode::toString(SkString* str) const { | 108 void SkLerpXfermode::toString(SkString* str) const { |
107 str->printf("SkLerpXfermode: scale: %g", fScale256 / 256.0); | 109 str->printf("SkLerpXfermode: scale: %g", fScale256 / 256.0); |
108 } | 110 } |
109 #endif | 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 } |
OLD | NEW |