4REG_FIDDLE(SkSL_PremultipliedAlpha, 200, 200,
false, 0) {
10 "const half3 iColor = half3(0, 0.5, 0.75);"
11 "half4 main(float2 coord) {"
12 " float alpha = 1 - (coord.y / 150);"
13 " if (coord.x < 100) {"
14 " /* Correctly premultiplied version of color */"
15 " return iColor.rgb1 * alpha;"
17 " /* Returning an unpremultiplied color (just setting alpha) leads to over-bright colors. */"
18 " return half4(iColor, alpha);"
31 p.setShader(myShader);
constexpr SkColor SK_ColorGRAY
REG_FIDDLE(SkSL_PremultipliedAlpha, 200, 200, false, 0)
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
void drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
void drawPaint(const SkPaint &paint)
static Result MakeForShader(SkString sksl, const Options &)