skia2/tests/sksl/shared/CommaSideEffects.glsl
John Stiles d68069019b Fix whitespace when commas are used in a binary-expression.
Previously, any code which emitted a binary expression would always emit
a leading and trailing space. This caused comma expressions to look
goofy: `foo() , bar();` instead of `foo(), bar();`.

Operator::operatorName() now returns the operator token with appropriate
whitespace around it, and tightOperatorName() is a new method which
omits the whitespace. Functions which assemble binary expressions
should now concatenate `x + operatorName() + y` instead of hard-coding
`x + " " + operatorName() + " " + y`. Prefix/postfix expressions should
use `tightOperatorName()` because otherwise negation looks bad (` - 123`
instead of `-123`).

Super low priority, but it was easy to fix.

Change-Id: I3c92832207293a310fb1070b3b5e72455757b0ce
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/497776
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2022-01-24 16:21:43 +00:00

23 lines
488 B
GLSL

out vec4 sk_FragColor;
uniform vec4 colorRed;
uniform vec4 colorGreen;
uniform vec4 colorWhite;
uniform vec4 colorBlack;
void setToColorBlack_vh4(out vec4 x) {
x = colorBlack;
}
vec4 main() {
vec4 a;
vec4 b;
vec4 c;
vec4 d;
(b = colorRed, c = colorGreen);
a = (setToColorBlack_vh4(d), colorWhite);
a *= a;
b *= b;
c *= c;
d *= d;
return ((a == colorWhite && b == colorRed) && c == colorGreen) && d == colorBlack ? colorGreen : colorRed;
}