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

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

Issue 25048002: Express (GLSL expression, possibly known value) pairs as a class (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 7 years, 2 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 | Annotate | Revision Log
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 "SkArithmeticMode.h" 8 #include "SkArithmeticMode.h"
9 #include "SkColorPriv.h" 9 #include "SkColorPriv.h"
10 #include "SkFlattenableBuffers.h" 10 #include "SkFlattenableBuffers.h"
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 dstColor = builder->dstColor(); 361 dstColor = builder->dstColor();
362 } 362 }
363 363
364 SkASSERT(NULL != dstColor); 364 SkASSERT(NULL != dstColor);
365 fKUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility, 365 fKUni = builder->addUniform(GrGLShaderBuilder::kFragment_Visibility,
366 kVec4f_GrSLType, "k"); 366 kVec4f_GrSLType, "k");
367 const char* kUni = builder->getUniformCStr(fKUni); 367 const char* kUni = builder->getUniformCStr(fKUni);
368 368
369 // We don't try to optimize for this case at all 369 // We don't try to optimize for this case at all
370 if (NULL == inputColor) { 370 if (NULL == inputColor) {
371 builder->fsCodeAppendf("\t\tconst vec4 src = %s;\n", GrGLSLOnesVecf(4)); 371 builder->fsCodeAppendf("\t\tconst vec4 src = %s;\n", GrGLSLExpr<4>(1).c_ str());
bsalomon 2013/10/02 15:18:04 Hmm.. This feels a little bit less readable. I'd
Kimmo Kinnunen 2013/10/08 12:18:29 I fixed this and the other similar instance by jus
bsalomon 2013/10/08 14:45:27 Yes, that seems like the most readable to me.
372 } else { 372 } else {
373 builder->fsCodeAppendf("\t\tvec4 src = %s;\n", inputColor); 373 builder->fsCodeAppendf("\t\tvec4 src = %s;\n", inputColor);
374 if (gUseUnpremul) { 374 if (gUseUnpremul) {
375 builder->fsCodeAppendf("\t\tsrc.rgb = clamp(src.rgb / src.a, 0.0, 1. 0);\n"); 375 builder->fsCodeAppendf("\t\tsrc.rgb = clamp(src.rgb / src.a, 0.0, 1. 0);\n");
376 } 376 }
377 } 377 }
378 378
379 builder->fsCodeAppendf("\t\tvec4 dst = %s;\n", dstColor); 379 builder->fsCodeAppendf("\t\tvec4 dst = %s;\n", dstColor);
380 if (gUseUnpremul) { 380 if (gUseUnpremul) {
381 builder->fsCodeAppendf("\t\tdst.rgb = clamp(dst.rgb / dst.a, 0.0, 1.0);\ n"); 381 builder->fsCodeAppendf("\t\tdst.rgb = clamp(dst.rgb / dst.a, 0.0, 1.0);\ n");
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 background); 443 background);
444 } 444 }
445 return true; 445 return true;
446 } 446 }
447 447
448 #endif 448 #endif
449 449
450 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkArithmeticMode) 450 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkArithmeticMode)
451 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArithmeticMode_scalar) 451 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkArithmeticMode_scalar)
452 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 452 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698