Skip to content

Commit c2e333e

Browse files
committed
switched test to drawing images and fixed rerasterization logic
1 parent bf488c3 commit c2e333e

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

engine/src/flutter/impeller/display_list/aiks_dl_runtime_effect_unittests.cc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -474,9 +474,12 @@ TEST_P(AiksTest, ClippedBackdropFilterWithShader) {
474474
}
475475

476476
TEST_P(AiksTest, RuntimeEffectImageFilterRotated) {
477+
auto image = DlImageImpeller::Make(CreateTextureForFixture("kalimba.jpg"));
478+
auto size = image->GetBounds().GetSize();
479+
477480
struct FragUniforms {
478481
Size size;
479-
} frag_uniforms = {.size = Size::MakeWH(400, 400)};
482+
} frag_uniforms = {.size = Size(size.width, size.height)};
480483
auto uniform_data = std::make_shared<std::vector<uint8_t>>();
481484
uniform_data->resize(sizeof(FragUniforms));
482485
memcpy(uniform_data->data(), &frag_uniforms, sizeof(FragUniforms));
@@ -506,13 +509,14 @@ TEST_P(AiksTest, RuntimeEffectImageFilterRotated) {
506509
ImGui::End();
507510
}
508511
DisplayListBuilder builder;
509-
builder.Translate(200, 200);
512+
builder.Translate(size.width * 0.5, size.height * 0.5);
510513
builder.Rotate(rotation);
511-
builder.Translate(-200, -200);
514+
builder.Translate(-size.width * 0.5, -size.height * 0.5);
512515

513516
DlPaint paint;
514517
paint.setImageFilter(runtime_filter);
515-
builder.DrawRect(DlRect::MakeXYWH(0, 0, 400, 400), paint);
518+
builder.DrawImage(image, DlPoint(0.0, 0.0),
519+
DlImageSampling::kNearestNeighbor, &paint);
516520

517521
return builder.Build();
518522
};

engine/src/flutter/impeller/renderer/snapshot.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,15 @@ struct Snapshot {
4545
/// capture the padding.
4646
bool needs_rasterization_for_runtime_effects = false;
4747

48-
/// Any snapshot that is scaled should rerasterize because we should be
48+
/// Any snapshot that is scaled should re-rasterize because we should be
4949
/// performing the RuntimeEffect at the resolution of the screen, not the
5050
/// scaled up or scaled down version of the snapshot.
5151
bool ShouldRasterizeForRuntimeEffects() const {
52-
return !transform.IsTranslationOnly() ||
52+
// If the transform has a rotation we don't re-rasterize because we'll lose
53+
// the rotation.
54+
// TODO(tbd): We should re-rasterize scaled and rotated snapshots.
55+
return (!transform.IsTranslationOnly() &&
56+
transform.IsTranslationScaleOnly()) ||
5357
needs_rasterization_for_runtime_effects;
5458
}
5559

0 commit comments

Comments
 (0)