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

Side by Side Diff: src/effects/SkLerpXfermode.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/SkArithmeticMode.cpp ('k') | src/effects/SkPixelXorXfermode.cpp » ('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 * 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
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 }
OLDNEW
« no previous file with comments | « src/effects/SkArithmeticMode.cpp ('k') | src/effects/SkPixelXorXfermode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698