7#include "absl/status/statusor.h"
17#include "third_party/abseil-cpp/absl/status/status_matchers.h"
25absl::StatusOr<std::shared_ptr<DlColorSource>> MakeRuntimeEffect(
27 std::string_view
name,
28 const std::shared_ptr<std::vector<uint8_t>>& uniform_data = {},
29 const std::vector<std::shared_ptr<DlColorSource>>& samplers = {}) {
30 auto runtime_stages_result = test->OpenAssetAsRuntimeStage(
name.data());
31 if (!runtime_stages_result.ok()) {
32 return runtime_stages_result.status();
34 std::shared_ptr<RuntimeStage> runtime_stage =
38 return absl::InternalError(
"Runtime stage not found for backend.");
40 if (!runtime_stage->IsDirty()) {
41 return absl::InternalError(
"Runtime stage is not dirty.");
56 } frag_uniforms = {.iResolution =
Vector2(400, 400), .iTime = 100.0};
57 auto uniform_data = std::make_shared<std::vector<uint8_t>>();
58 uniform_data->resize(
sizeof(FragUniforms));
59 memcpy(uniform_data->data(), &frag_uniforms,
sizeof(FragUniforms));
63 MakeRuntimeEffect(
this,
"runtime_stage_example.frag.iplr", uniform_data);
64 ABSL_ASSERT_OK(effect);
71 DlClipOp::kIntersect);
75 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
82 auto uniform_data = std::make_shared<std::vector<uint8_t>>();
83 uniform_data->resize(
sizeof(FragUniforms));
84 memcpy(uniform_data->data(), &frag_uniforms,
sizeof(FragUniforms));
87 auto effect = MakeRuntimeEffect(
this,
"gradient.frag.iplr", uniform_data);
88 ABSL_ASSERT_OK(effect);
93 builder.
Scale(GetContentScale().
x, GetContentScale().
y);
97 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
101 auto runtime_stages_result =
102 OpenAssetAsRuntimeStage(
"runtime_stage_filter_example.frag.iplr");
103 ABSL_ASSERT_OK(runtime_stages_result);
104 std::shared_ptr<RuntimeStage> runtime_stage =
105 runtime_stages_result
107 ASSERT_TRUE(runtime_stage);
108 ASSERT_TRUE(runtime_stage->IsDirty());
110 std::vector<std::shared_ptr<DlColorSource>> sampler_inputs = {
113 auto uniform_data = std::make_shared<std::vector<uint8_t>>();
114 uniform_data->resize(
sizeof(
Vector2));
125 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
134 const float stops[2] = {0.0, 1.0};
136 2, colors.data(), stops,
138 std::vector<std::shared_ptr<DlColorSource>> sampler_inputs = {
142 auto uniform_data = std::make_shared<std::vector<uint8_t>>();
143 uniform_data->resize(
sizeof(
Vector2));
147 MakeRuntimeEffect(
this,
"runtime_stage_filter_example.frag.iplr",
148 uniform_data, sampler_inputs);
149 ABSL_ASSERT_OK(effect);
155 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
172 std::shared_ptr<DlImageFilter> color_filter =
175 auto runtime_stages_result =
176 OpenAssetAsRuntimeStage(
"runtime_stage_filter_warp.frag.iplr");
177 ABSL_ASSERT_OK(runtime_stages_result);
178 std::shared_ptr<RuntimeStage> runtime_stage =
179 runtime_stages_result
181 ASSERT_TRUE(runtime_stage);
182 ASSERT_TRUE(runtime_stage->IsDirty());
184 std::vector<std::shared_ptr<DlColorSource>> sampler_inputs = {
187 auto uniform_data = std::make_shared<std::vector<uint8_t>>();
188 uniform_data->resize(
sizeof(
Vector2));
195 builder.
Scale(0.7, 0.7);
201 DlImageSampling::kNearestNeighbor, &paint);
205 builder.
DrawLine({100, 100}, {200, 100}, green);
206 builder.
DrawLine({100, 100}, {100, 200}, green);
208 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
212 auto runtime_stages_result =
213 OpenAssetAsRuntimeStage(
"runtime_stage_filter_warp.frag.iplr");
214 ABSL_ASSERT_OK(runtime_stages_result);
215 std::shared_ptr<RuntimeStage> runtime_stage =
216 runtime_stages_result
218 ASSERT_TRUE(runtime_stage);
219 ASSERT_TRUE(runtime_stage->IsDirty());
224 bool compare =
false;
226 auto callback = [&]() -> sk_sp<DisplayList> {
228 ImGuiWindowFlags_AlwaysAutoResize)) {
229 ImGui::SliderFloat(
"xoffset", &xoffset, -50, 50);
230 ImGui::SliderFloat(
"yoffset", &yoffset, -50, 50);
231 ImGui::SliderFloat(
"xscale", &xscale, 0, 1);
232 ImGui::SliderFloat(
"yscale", &yscale, 0, 1);
233 ImGui::Checkbox(
"compare", &compare);
249 std::shared_ptr<DlImageFilter> color_filter =
252 std::vector<std::shared_ptr<DlColorSource>> sampler_inputs = {
255 auto uniform_data = std::make_shared<std::vector<uint8_t>>();
256 uniform_data->resize(
sizeof(
Vector2));
263 builder.
Scale(xscale, yscale);
269 DlImageSampling::kNearestNeighbor, &paint);
275 DlImageSampling::kNearestNeighbor, &paint);
279 DlImageSampling::kNearestNeighbor, &paint);
284 builder.
DrawLine({100, 100}, {200, 100}, green);
285 builder.
DrawLine({100, 100}, {100, 200}, green);
287 builder.
DrawLine({800, 100}, {900, 100}, green);
288 builder.
DrawLine({800, 100}, {800, 200}, green);
289 builder.
DrawLine({100, 800}, {200, 800}, green);
290 builder.
DrawLine({100, 800}, {100, 900}, green);
293 return builder.
Build();
296 ASSERT_TRUE(OpenPlaygroundHere(
callback));
300 auto runtime_stages_result =
301 OpenAssetAsRuntimeStage(
"runtime_stage_filter_circle.frag.iplr");
302 ABSL_ASSERT_OK(runtime_stages_result);
303 std::shared_ptr<RuntimeStage> runtime_stage =
304 runtime_stages_result
306 ASSERT_TRUE(runtime_stage);
307 ASSERT_TRUE(runtime_stage->IsDirty());
310 auto callback = [&]() -> sk_sp<DisplayList> {
312 ImGuiWindowFlags_AlwaysAutoResize)) {
313 ImGui::SliderFloat(
"sigma", &sigma, 0, 20);
324 std::vector<std::shared_ptr<DlColorSource>> sampler_inputs = {
327 auto uniform_data = std::make_shared<std::vector<uint8_t>>();
328 uniform_data->resize(
sizeof(
Vector2));
340 DlImageSampling::kNearestNeighbor, &paint);
344 builder.
SaveLayer(std::nullopt, &save_paint, backdrop_filter.get());
349 builder.
DrawLine({100, 100}, {200, 100}, green);
350 builder.
DrawLine({100, 100}, {100, 200}, green);
352 return builder.
Build();
355 ASSERT_TRUE(OpenPlaygroundHere(
callback));
359 auto runtime_stages_result =
360 OpenAssetAsRuntimeStage(
"runtime_stage_filter_circle.frag.iplr");
361 ABSL_ASSERT_OK(runtime_stages_result);
362 std::shared_ptr<RuntimeStage> runtime_stage =
363 runtime_stages_result
365 ASSERT_TRUE(runtime_stage);
366 ASSERT_TRUE(runtime_stage->IsDirty());
369 auto callback = [&]() -> sk_sp<DisplayList> {
371 ImGuiWindowFlags_AlwaysAutoResize)) {
372 ImGui::SliderFloat(
"sigma", &sigma, 0, 20);
383 std::vector<std::shared_ptr<DlColorSource>> sampler_inputs = {
386 auto uniform_data = std::make_shared<std::vector<uint8_t>>();
387 uniform_data->resize(
sizeof(
Vector2));
399 DlImageSampling::kNearestNeighbor, &paint);
403 builder.
SaveLayer(std::nullopt, &save_paint, backdrop_filter.get());
408 builder.
DrawLine({100, 100}, {200, 100}, green);
409 builder.
DrawLine({100, 100}, {100, 200}, green);
411 return builder.
Build();
414 ASSERT_TRUE(OpenPlaygroundHere(
callback));
418 struct FragUniforms {
420 } frag_uniforms = {.uSize =
Vector2(400, 400)};
421 auto uniform_data = std::make_shared<std::vector<uint8_t>>();
422 uniform_data->resize(
sizeof(FragUniforms));
423 memcpy(uniform_data->data(), &frag_uniforms,
sizeof(FragUniforms));
425 auto runtime_stages_result =
426 OpenAssetAsRuntimeStage(
"runtime_stage_border.frag.iplr");
427 ABSL_ASSERT_OK(runtime_stages_result);
428 std::shared_ptr<RuntimeStage> runtime_stage =
429 runtime_stages_result
431 ASSERT_TRUE(runtime_stage);
432 ASSERT_TRUE(runtime_stage->IsDirty());
434 std::vector<std::shared_ptr<DlColorSource>> sampler_inputs = {
465 builder.
SaveLayer(std::nullopt, &save_paint, runtime_filter.get());
473 ASSERT_TRUE(OpenPlaygroundHere(builder.
Build()));
478 auto size =
image->GetBounds().GetSize();
480 struct FragUniforms {
482 } frag_uniforms = {.size =
Size(
size.width,
size.height)};
483 auto uniform_data = std::make_shared<std::vector<uint8_t>>();
484 uniform_data->resize(
sizeof(FragUniforms));
485 memcpy(uniform_data->data(), &frag_uniforms,
sizeof(FragUniforms));
487 auto runtime_stages_result = OpenAssetAsRuntimeStage(
"gradient.frag.iplr");
488 ABSL_ASSERT_OK(runtime_stages_result);
489 std::shared_ptr<RuntimeStage> runtime_stage =
490 runtime_stages_result
492 ASSERT_TRUE(runtime_stage);
493 ASSERT_TRUE(runtime_stage->IsDirty());
495 std::vector<std::shared_ptr<DlColorSource>> sampler_inputs = {
505 auto callback = [&]() -> sk_sp<DisplayList> {
507 ImGuiWindowFlags_AlwaysAutoResize)) {
508 ImGui::SliderFloat(
"rotation", &rotation, 0, 360);
519 DlImageSampling::kNearestNeighbor, &paint);
521 return builder.
Build();
524 ASSERT_TRUE(OpenPlaygroundHere(
callback));
void ClipRect(const DlRect &rect, DlClipOp clip_op=DlClipOp::kIntersect, bool is_aa=false) override
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 Rotate(DlScalar degrees) 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
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 kWhite()
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)