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

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

Issue 1643753002: kill SkValue (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 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.h » ('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 2011 Google Inc. 2 * Copyright 2011 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 "SkPixelXorXfermode.h" 8 #include "SkPixelXorXfermode.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"
15 13
16 // we always return an opaque color, 'cause I don't know what to do with 14 // we always return an opaque color, 'cause I don't know what to do with
17 // the alpha-component and still return a valid premultiplied color. 15 // the alpha-component and still return a valid premultiplied color.
18 SkPMColor SkPixelXorXfermode::xferColor(SkPMColor src, SkPMColor dst) const { 16 SkPMColor SkPixelXorXfermode::xferColor(SkPMColor src, SkPMColor dst) const {
19 SkPMColor res = src ^ dst ^ fOpColor; 17 SkPMColor res = src ^ dst ^ fOpColor;
20 18
21 res |= (SK_A32_MASK << SK_A32_SHIFT); // force it to be opaque 19 res |= (SK_A32_MASK << SK_A32_SHIFT); // force it to be opaque
22 return res; 20 return res;
23 } 21 }
24 22
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 const char* opColor) { 57 const char* opColor) {
60 static const GrGLSLShaderVar gXorArgs[] = { 58 static const GrGLSLShaderVar gXorArgs[] = {
61 GrGLSLShaderVar("f1", kFloat_GrSLType), 59 GrGLSLShaderVar("f1", kFloat_GrSLType),
62 GrGLSLShaderVar("f2", kFloat_GrSLType), 60 GrGLSLShaderVar("f2", kFloat_GrSLType),
63 GrGLSLShaderVar("f3", kFloat_GrSLType), 61 GrGLSLShaderVar("f3", kFloat_GrSLType),
64 GrGLSLShaderVar("fPowerOf2Divisor", kFloat_GrSLType), 62 GrGLSLShaderVar("fPowerOf2Divisor", kFloat_GrSLType),
65 }; 63 };
66 SkString xorFuncName; 64 SkString xorFuncName;
67 65
68 // The xor function checks if the three passed in floats (f1, f2, f3) would 66 // The xor function checks if the three passed in floats (f1, f2, f3) would
69 // have a bit in the log2(fPowerOf2Divisor)-th position if they were 67 // have a bit in the log2(fPowerOf2Divisor)-th position if they were
70 // represented by an int. It then performs an xor of the 3 bits (using 68 // represented by an int. It then performs an xor of the 3 bits (using
71 // the property that serial xors can be treated as a sum of 0s & 1s mod 2). 69 // the property that serial xors can be treated as a sum of 0s & 1s mod 2).
72 fragBuilder->emitFunction(kFloat_GrSLType, 70 fragBuilder->emitFunction(kFloat_GrSLType,
73 "xor", 71 "xor",
74 SK_ARRAY_COUNT(gXorArgs), 72 SK_ARRAY_COUNT(gXorArgs),
75 gXorArgs, 73 gXorArgs,
76 "float bit1 = floor(f1 / fPowerOf2Divisor);" 74 "float bit1 = floor(f1 / fPowerOf2Divisor);"
77 "float bit2 = floor(f2 / fPowerOf2Divisor);" 75 "float bit2 = floor(f2 / fPowerOf2Divisor);"
78 "float bit3 = floor(f3 / fPowerOf2Divisor);" 76 "float bit3 = floor(f3 / fPowerOf2Divisor);"
79 "return mod(bit1 + bit2 + bit3, 2.0);", 77 "return mod(bit1 + bit2 + bit3, 2.0);",
80 &xorFuncName); 78 &xorFuncName);
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 add_pixelxor_code(fragBuilder, srcColor, dstColor, outColor, kOpColorUni ); 289 add_pixelxor_code(fragBuilder, srcColor, dstColor, outColor, kOpColorUni );
292 290
293 // Apply coverage. 291 // Apply coverage.
294 INHERITED::DefaultCoverageModulation(fragBuilder, srcCoverage, dstColor, outColor, 292 INHERITED::DefaultCoverageModulation(fragBuilder, srcCoverage, dstColor, outColor,
295 outColorSecondary, proc); 293 outColorSecondary, proc);
296 } 294 }
297 295
298 void onSetData(const GrGLSLProgramDataManager& pdman, 296 void onSetData(const GrGLSLProgramDataManager& pdman,
299 const GrXferProcessor& processor) override { 297 const GrXferProcessor& processor) override {
300 const PixelXorXP& pixelXor = processor.cast<PixelXorXP>(); 298 const PixelXorXP& pixelXor = processor.cast<PixelXorXP>();
301 pdman.set3f(fOpColorUni, 299 pdman.set3f(fOpColorUni,
302 SkColorGetR(pixelXor.opColor())/255.0f, 300 SkColorGetR(pixelXor.opColor())/255.0f,
303 SkColorGetG(pixelXor.opColor())/255.0f, 301 SkColorGetG(pixelXor.opColor())/255.0f,
304 SkColorGetB(pixelXor.opColor())/255.0f); 302 SkColorGetB(pixelXor.opColor())/255.0f);
305 }; 303 };
306 304
307 GrGLSLProgramDataManager::UniformHandle fOpColorUni; 305 GrGLSLProgramDataManager::UniformHandle fOpColorUni;
308 306
309 typedef GrGLSLXferProcessor INHERITED; 307 typedef GrGLSLXferProcessor INHERITED;
310 }; 308 };
311 309
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 } 379 }
382 380
383 bool SkPixelXorXfermode::asXPFactory(GrXPFactory** xpf) const { 381 bool SkPixelXorXfermode::asXPFactory(GrXPFactory** xpf) const {
384 if (xpf) { 382 if (xpf) {
385 *xpf = GrPixelXorXPFactory::Create(fOpColor); 383 *xpf = GrPixelXorXPFactory::Create(fOpColor);
386 } 384 }
387 return true; 385 return true;
388 } 386 }
389 387
390 #endif 388 #endif
391
392 SkValue SkPixelXorXfermode::asValue() const {
393 auto value = SkValue::Object(SkValue::PixelXorXfermode);
394 value.set(SkValueKeys::PixelXorXfermode::kOpColor,
395 SkValue::FromU32(SkToU32(fOpColor)));
396 return value;
397 }
OLDNEW
« no previous file with comments | « src/effects/SkArithmeticMode.cpp ('k') | src/effects/SkToFromValue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698