Flutter Engine
The Flutter Engine
SkSL_MinifiedSkSL.cpp
Go to the documentation of this file.
1// Copyright 2024 Google LLC.
2// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
4REG_FIDDLE(SkSL_MinifiedSkSL, 200, 200, false, 0) {
5static constexpr char SKSL_MINIFIED_GradientShader[] =
6"half4 main(float2 a){float b=1.-a.y*.006666667;if(a.x<100.)return half4(float4"
7"(0.,.5,.75,1.)*b);else return half4(half3(0.,.5,.75),half(b));}";
8
9void draw(SkCanvas* canvas) {
10 auto [effect, err] = SkRuntimeEffect::MakeForShader(SkString(SKSL_MINIFIED_GradientShader));
11 sk_sp<SkShader> myShader = effect->makeShader(/*uniforms=*/ nullptr,
12 /*children=*/ {});
13
14 // Fill canvas with gray, first:
15 canvas->drawColor(SK_ColorGRAY);
16
17 // Blend our test shader on top of that:
18 SkPaint p;
19 p.setShader(myShader);
20 canvas->drawPaint(p);
21}} // END FIDDLE
constexpr SkColor SK_ColorGRAY
Definition: SkColor.h:113
REG_FIDDLE(SkSL_MinifiedSkSL, 200, 200, false, 0)
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
void drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
Definition: SkCanvas.h:1182
void drawPaint(const SkPaint &paint)
Definition: SkCanvas.cpp:1668
static Result MakeForShader(SkString sksl, const Options &)