22std::shared_ptr<DlColorSource> MakeRuntimeEffect(
24 std::string_view
name,
25 const std::shared_ptr<std::vector<uint8_t>>& uniform_data = {},
26 const std::vector<std::shared_ptr<DlColorSource>>& samplers = {}) {
27 auto runtime_stages = test->OpenAssetAsRuntimeStage(
name.data());
45 } frag_uniforms = {.iResolution =
Vector2(400, 400), .iTime = 100.0};
46 auto uniform_data = std::make_shared<std::vector<uint8_t>>();
47 uniform_data->resize(
sizeof(FragUniforms));
48 memcpy(uniform_data->data(), &frag_uniforms,
sizeof(FragUniforms));
52 MakeRuntimeEffect(
this,
"runtime_stage_example.frag.iplr", uniform_data));
58 DlClipOp::kIntersect);
62 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
69 auto uniform_data = std::make_shared<std::vector<uint8_t>>();
70 uniform_data->resize(
sizeof(FragUniforms));
71 memcpy(uniform_data->data(), &frag_uniforms,
sizeof(FragUniforms));
75 MakeRuntimeEffect(
this,
"gradient.frag.iplr", uniform_data));
79 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
83 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
88 OpenAssetAsRuntimeStage(
"runtime_stage_filter_example.frag.iplr");
90 std::shared_ptr<RuntimeStage> runtime_stage =
92 ASSERT_TRUE(runtime_stage);
93 ASSERT_TRUE(runtime_stage->IsDirty());
95 std::vector<std::shared_ptr<DlColorSource>> sampler_inputs = {
98 auto uniform_data = std::make_shared<std::vector<uint8_t>>();
99 uniform_data->resize(
sizeof(
Vector2));
110 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
119 const float stops[2] = {0.0, 1.0};
121 2, colors.data(), stops,
123 std::vector<std::shared_ptr<DlColorSource>> sampler_inputs = {
127 auto uniform_data = std::make_shared<std::vector<uint8_t>>();
128 uniform_data->resize(
sizeof(
Vector2));
132 MakeRuntimeEffect(
this,
"runtime_stage_filter_example.frag.iplr",
133 uniform_data, sampler_inputs));
138 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
155 std::shared_ptr<DlImageFilter> color_filter =
158 auto runtime_stages =
159 OpenAssetAsRuntimeStage(
"runtime_stage_filter_warp.frag.iplr");
161 std::shared_ptr<RuntimeStage> runtime_stage =
163 ASSERT_TRUE(runtime_stage);
164 ASSERT_TRUE(runtime_stage->IsDirty());
166 std::vector<std::shared_ptr<DlColorSource>> sampler_inputs = {
169 auto uniform_data = std::make_shared<std::vector<uint8_t>>();
170 uniform_data->resize(
sizeof(
Vector2));
177 builder.
Scale(0.7, 0.7);
183 DlImageSampling::kNearestNeighbor, &paint);
187 builder.
DrawLine({100, 100}, {200, 100}, green);
188 builder.
DrawLine({100, 100}, {100, 200}, green);
190 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
194 auto runtime_stages =
195 OpenAssetAsRuntimeStage(
"runtime_stage_filter_warp.frag.iplr");
197 std::shared_ptr<RuntimeStage> runtime_stage =
199 ASSERT_TRUE(runtime_stage);
200 ASSERT_TRUE(runtime_stage->IsDirty());
205 bool compare =
false;
207 auto callback = [&]() -> sk_sp<DisplayList> {
209 ImGuiWindowFlags_AlwaysAutoResize)) {
210 ImGui::SliderFloat(
"xoffset", &xoffset, -50, 50);
211 ImGui::SliderFloat(
"yoffset", &yoffset, -50, 50);
212 ImGui::SliderFloat(
"xscale", &xscale, 0, 1);
213 ImGui::SliderFloat(
"yscale", &yscale, 0, 1);
214 ImGui::Checkbox(
"compare", &compare);
230 std::shared_ptr<DlImageFilter> color_filter =
233 std::vector<std::shared_ptr<DlColorSource>> sampler_inputs = {
236 auto uniform_data = std::make_shared<std::vector<uint8_t>>();
237 uniform_data->resize(
sizeof(
Vector2));
244 builder.
Scale(xscale, yscale);
250 DlImageSampling::kNearestNeighbor, &paint);
256 DlImageSampling::kNearestNeighbor, &paint);
260 DlImageSampling::kNearestNeighbor, &paint);
265 builder.
DrawLine({100, 100}, {200, 100}, green);
266 builder.
DrawLine({100, 100}, {100, 200}, green);
268 builder.
DrawLine({800, 100}, {900, 100}, green);
269 builder.
DrawLine({800, 100}, {800, 200}, green);
270 builder.
DrawLine({100, 800}, {200, 800}, green);
271 builder.
DrawLine({100, 800}, {100, 900}, green);
274 return builder.
Build();
277 ASSERT_TRUE(OpenPlaygroundHere(
callback));
281 auto runtime_stages =
282 OpenAssetAsRuntimeStage(
"runtime_stage_filter_circle.frag.iplr");
284 std::shared_ptr<RuntimeStage> runtime_stage =
286 ASSERT_TRUE(runtime_stage);
287 ASSERT_TRUE(runtime_stage->IsDirty());
290 auto callback = [&]() -> sk_sp<DisplayList> {
292 ImGuiWindowFlags_AlwaysAutoResize)) {
293 ImGui::SliderFloat(
"sigma", &sigma, 0, 20);
304 std::vector<std::shared_ptr<DlColorSource>> sampler_inputs = {
307 auto uniform_data = std::make_shared<std::vector<uint8_t>>();
308 uniform_data->resize(
sizeof(
Vector2));
320 DlImageSampling::kNearestNeighbor, &paint);
324 builder.
SaveLayer(std::nullopt, &save_paint, backdrop_filter.get());
329 builder.
DrawLine({100, 100}, {200, 100}, green);
330 builder.
DrawLine({100, 100}, {100, 200}, green);
332 return builder.
Build();
335 ASSERT_TRUE(OpenPlaygroundHere(
callback));
void DrawImage(const sk_sp< DlImage > &image, const DlPoint &point, DlImageSampling sampling, const DlPaint *paint=nullptr) override
void SaveLayer(const std::optional< DlRect > &bounds, const DlPaint *paint=nullptr, const DlImageFilter *backdrop=nullptr, std::optional< int64_t > backdrop_id=std::nullopt) override
void DrawLine(const DlPoint &p0, const DlPoint &p1, const DlPaint &paint) override
void ClipRoundRect(const DlRoundRect &rrect, DlClipOp clip_op=DlClipOp::kIntersect, bool is_aa=false) override
void Scale(DlScalar sx, DlScalar sy) override
void Translate(DlScalar tx, DlScalar ty) override
void DrawPaint(const DlPaint &paint) override
sk_sp< DisplayList > Build()
void DrawRect(const DlRect &rect, const DlPaint &paint) override
static std::shared_ptr< const DlColorFilter > MakeMatrix(const float matrix[20])
static std::shared_ptr< DlColorSource > MakeLinear(const DlPoint start_point, const DlPoint end_point, uint32_t stop_count, const DlColor *colors, const float *stops, DlTileMode tile_mode, const DlMatrix *matrix=nullptr)
static std::shared_ptr< DlColorSource > MakeRuntimeEffect(sk_sp< DlRuntimeEffect > runtime_effect, std::vector< std::shared_ptr< DlColorSource > > samplers, std::shared_ptr< std::vector< uint8_t > > uniform_data)
static std::shared_ptr< DlImageFilter > MakeBlur(DlScalar sigma_x, DlScalar sigma_y, DlTileMode tile_mode)
static std::shared_ptr< DlImageFilter > MakeRuntimeEffect(sk_sp< DlRuntimeEffect > runtime_effect, std::vector< std::shared_ptr< DlColorSource > > samplers, std::shared_ptr< std::vector< uint8_t > > uniform_data)
static std::shared_ptr< DlImageFilter > MakeColorFilter(const std::shared_ptr< const DlColorFilter > &filter)
static std::shared_ptr< DlImageFilter > MakeCompose(const std::shared_ptr< DlImageFilter > &outer, const std::shared_ptr< DlImageFilter > &inner)
DlPaint & setColor(DlColor color)
DlPaint & setBlendMode(DlBlendMode mode)
DlPaint & setImageFilter(std::nullptr_t filter)
DlPaint & setColorSource(std::nullptr_t source)
static sk_sp< DlRuntimeEffect > Make(std::shared_ptr< impeller::RuntimeStage > runtime_stage)
static bool ImGuiBegin(const char *name, bool *p_open, ImGuiWindowFlags flags)
static sk_sp< DlImageImpeller > Make(std::shared_ptr< Texture > texture, OwningContext owning_context=OwningContext::kIO)
FlutterVulkanImage * image
FlutterDesktopBinaryReply callback
#define FML_CHECK(condition)
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
DEF_SWITCHES_START aot vmservice shared library name
TEST_P(AiksTest, DrawAtlasNoColor)
constexpr RuntimeStageBackend PlaygroundBackendToRuntimeStageBackend(PlaygroundBackend backend)
static constexpr DlColor kBlue()
static constexpr DlColor kAqua()
static constexpr DlColor kRed()
static constexpr DlColor kGreen()
static RoundRect MakeRectXY(const Rect &rect, Scalar x_radius, Scalar y_radius)
static constexpr TRect MakeXYWH(Type x, Type y, Type width, Type height)
static constexpr TSize MakeWH(Type width, Type height)