diff --git a/impeller/aiks/aiks_unittests.cc b/impeller/aiks/aiks_unittests.cc index 99b4deb4d726a..8025154a77ce6 100644 --- a/impeller/aiks/aiks_unittests.cc +++ b/impeller/aiks/aiks_unittests.cc @@ -2911,6 +2911,36 @@ TEST_P(AiksTest, CanRenderClippedRuntimeEffects) { ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); } +TEST_P(AiksTest, DrawPaintTransformsBounds) { + if (GetParam() != PlaygroundBackend::kMetal) { + GTEST_SKIP_("This backend doesn't support runtime effects."); + } + + auto runtime_stage = OpenAssetAsRuntimeStage("gradient.frag.iplr"); + ASSERT_TRUE(runtime_stage->IsDirty()); + + struct FragUniforms { + Size size; + } frag_uniforms = {.size = Size::MakeWH(400, 400)}; + auto uniform_data = std::make_shared>(); + uniform_data->resize(sizeof(FragUniforms)); + memcpy(uniform_data->data(), &frag_uniforms, sizeof(FragUniforms)); + + std::vector texture_inputs; + + Paint paint; + paint.color_source = ColorSource::MakeRuntimeEffect( + runtime_stage, uniform_data, texture_inputs); + + Canvas canvas; + canvas.Save(); + canvas.Scale(GetContentScale()); + canvas.DrawPaint(paint); + canvas.Restore(); + + ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); +} + TEST_P(AiksTest, CanDrawPoints) { std::vector points = { {0, 0}, // diff --git a/impeller/entity/geometry/cover_geometry.cc b/impeller/entity/geometry/cover_geometry.cc index f927c2d7299ba..42d3060ebf343 100644 --- a/impeller/entity/geometry/cover_geometry.cc +++ b/impeller/entity/geometry/cover_geometry.cc @@ -23,13 +23,16 @@ GeometryResult CoverGeometry::GetPositionBuffer(const ContentContext& renderer, .vertex_buffer = { .vertex_buffer = host_buffer.Emplace( - rect.GetPoints().data(), 8 * sizeof(float), alignof(float)), + rect.GetTransformedPoints(entity.GetTransformation().Invert()) + .data(), + 8 * sizeof(float), alignof(float)), .index_buffer = host_buffer.Emplace( kRectIndicies, 4 * sizeof(uint16_t), alignof(uint16_t)), .vertex_count = 4, .index_type = IndexType::k16bit, }, - .transform = Matrix::MakeOrthographic(pass.GetRenderTargetSize()), + .transform = Matrix::MakeOrthographic(pass.GetRenderTargetSize()) * + entity.GetTransformation(), .prevent_overdraw = false, }; } diff --git a/impeller/fixtures/BUILD.gn b/impeller/fixtures/BUILD.gn index f4381619a65a3..bcd37254b2327 100644 --- a/impeller/fixtures/BUILD.gn +++ b/impeller/fixtures/BUILD.gn @@ -57,6 +57,7 @@ impellerc("runtime_stages") { shaders = [ "ink_sparkle.frag", "runtime_stage_example.frag", + "gradient.frag", ] sl_file_extension = "iplr" shader_target_flag = "--runtime-stage-metal" diff --git a/impeller/fixtures/gradient.frag b/impeller/fixtures/gradient.frag new file mode 100644 index 0000000000000..249efd246969b --- /dev/null +++ b/impeller/fixtures/gradient.frag @@ -0,0 +1,10 @@ +#include + +uniform vec2 uSize; + +out vec4 fragColor; + +void main() { + float v = FlutterFragCoord().y / uSize.y; + fragColor = vec4(v, v, v, 1); +}