Jonah Williams
2023-08-30 19:54:06 -07:00
committed by GitHub
parent ffa16ec08f
commit 42f0f83acb
4 changed files with 46 additions and 2 deletions

View File

@@ -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<std::vector<uint8_t>>();
uniform_data->resize(sizeof(FragUniforms));
memcpy(uniform_data->data(), &frag_uniforms, sizeof(FragUniforms));
std::vector<RuntimeEffectContents::TextureInput> 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<Point> points = {
{0, 0}, //

View File

@@ -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,
};
}

View File

@@ -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"

View File

@@ -0,0 +1,10 @@
#include <flutter/runtime_effect.glsl>
uniform vec2 uSize;
out vec4 fragColor;
void main() {
float v = FlutterFragCoord().y / uSize.y;
fragColor = vec4(v, v, v, 1);
}