skia2/tests/sksl/inliner/StructsCanBeInlinedSafely.sksl
John Stiles 4f2bcff08e Implement Type cloning for enums and structs.
As far as I know, there shouldn't be a way to introduce a struct or enum
other than at global scope; the keywords are not accepted inside a
function body. In fact, I wasn't able to find a way to exercise these
code paths in practice. But we now have concrete assurance that any
possible type can be cloned into a symbol table safely; all Types are
either built-in (available everywhere by design) or are clonable.

Change-Id: I4b006b6cab995b3e598b683736ab9689828629c9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/354664
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
2021-01-15 21:45:56 +00:00

22 lines
304 B
Plaintext

half4 helper();
void main() {
sk_FragColor = helper();
}
struct Color {
half red;
half green;
half blue;
half alpha;
};
half4 helper() {
Color c;
c.red = 0.25;
c.green = 0.5;
c.blue = 0.75;
c.alpha = 1.0;
return half4(c.red, c.green, c.blue, c.alpha);
}