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

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

Issue 395603002: Simplify flattening to just write enough to call the factory (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 4 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/SkLayerRasterizer.cpp ('k') | src/effects/SkLightingImageFilter.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 13
14 SkXfermode* SkLerpXfermode::Create(SkScalar scale) { 14 SkXfermode* SkLerpXfermode::Create(SkScalar scale) {
15 int scale256 = SkScalarRoundToInt(scale * 256); 15 int scale256 = SkScalarRoundToInt(scale * 256);
16 if (scale256 >= 256) { 16 if (scale256 >= 256) {
17 return SkXfermode::Create(SkXfermode::kSrc_Mode); 17 return SkXfermode::Create(SkXfermode::kSrc_Mode);
18 } else if (scale256 <= 0) { 18 } else if (scale256 <= 0) {
19 return SkXfermode::Create(SkXfermode::kDst_Mode); 19 return SkXfermode::Create(SkXfermode::kDst_Mode);
20 } 20 }
21 return SkNEW_ARGS(SkLerpXfermode, (scale256)); 21 return SkNEW_ARGS(SkLerpXfermode, (scale256));
22 } 22 }
23 23
24 SkLerpXfermode::SkLerpXfermode(unsigned scale256) : fScale256(scale256) {} 24 SkLerpXfermode::SkLerpXfermode(unsigned scale256) : fScale256(scale256) {}
25 25
26 SkLerpXfermode::SkLerpXfermode(SkReadBuffer& buffer) 26 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
27 : INHERITED(buffer) { 27 SkLerpXfermode::SkLerpXfermode(SkReadBuffer& buffer) : INHERITED(buffer) {
28 fScale256 = buffer.readUInt(); 28 fScale256 = buffer.readUInt();
29 } 29 }
30 #endif
30 31
31 void SkLerpXfermode::flatten(SkWriteBuffer& buffer) const { 32 void SkLerpXfermode::flatten(SkWriteBuffer& buffer) const {
32 this->INHERITED::flatten(buffer);
33 buffer.writeUInt(fScale256); 33 buffer.writeUInt(fScale256);
34 } 34 }
35 35
36 SkFlattenable* SkLerpXfermode::CreateProc(SkReadBuffer& buffer) {
37 return SkNEW_ARGS(SkLerpXfermode, (buffer.readUInt()));
38 }
39
36 void SkLerpXfermode::xfer32(SkPMColor dst[], const SkPMColor src[], int count, 40 void SkLerpXfermode::xfer32(SkPMColor dst[], const SkPMColor src[], int count,
37 const SkAlpha aa[]) const { 41 const SkAlpha aa[]) const {
38 const int scale = fScale256; 42 const int scale = fScale256;
39 43
40 if (aa) { 44 if (aa) {
41 for (int i = 0; i < count; ++i) { 45 for (int i = 0; i < count; ++i) {
42 unsigned a = aa[i]; 46 unsigned a = aa[i];
43 if (a) { 47 if (a) {
44 SkPMColor dstC = dst[i]; 48 SkPMColor dstC = dst[i];
45 SkPMColor resC = SkFastFourByteInterp256(src[i], dstC, scale); 49 SkPMColor resC = SkFastFourByteInterp256(src[i], dstC, scale);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 dst[i] = SkAlphaBlend(SkGetPackedA32(src[i]), dst[i], scale); 106 dst[i] = SkAlphaBlend(SkGetPackedA32(src[i]), dst[i], scale);
103 } 107 }
104 } 108 }
105 } 109 }
106 110
107 #ifndef SK_IGNORE_TO_STRING 111 #ifndef SK_IGNORE_TO_STRING
108 void SkLerpXfermode::toString(SkString* str) const { 112 void SkLerpXfermode::toString(SkString* str) const {
109 str->printf("SkLerpXfermode: scale: %g", fScale256 / 256.0); 113 str->printf("SkLerpXfermode: scale: %g", fScale256 / 256.0);
110 } 114 }
111 #endif 115 #endif
OLDNEW
« no previous file with comments | « src/effects/SkLayerRasterizer.cpp ('k') | src/effects/SkLightingImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698