mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[Impeller] make sure to render TiledTextureContents if the geometry doesn't fit in the texture's bounds. (flutter/engine#51393)
fixes https://github.com/flutter/flutter/issues/144836 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
parent
eb4a94243f
commit
076f29066c
@ -1146,5 +1146,40 @@ TEST_P(AiksTest, GaussianBlurMipMapSolidColor) {
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_P(AiksTest, MaskBlurDoesntStretchContents) {
|
||||
Scalar sigma = 70;
|
||||
auto callback = [&](AiksContext& renderer) -> std::optional<Picture> {
|
||||
if (AiksTest::ImGuiBegin("Controls", nullptr,
|
||||
ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||
ImGui::SliderFloat("Sigma", &sigma, 0, 500);
|
||||
ImGui::End();
|
||||
}
|
||||
Canvas canvas;
|
||||
canvas.Scale(GetContentScale());
|
||||
canvas.DrawPaint({.color = Color(0.1, 0.1, 0.1, 1.0)});
|
||||
|
||||
std::shared_ptr<Texture> boston = CreateTextureForFixture("boston.jpg");
|
||||
ColorSource image_source = ColorSource::MakeImage(
|
||||
boston, Entity::TileMode::kRepeat, Entity::TileMode::kRepeat, {}, {});
|
||||
|
||||
canvas.Transform(Matrix::MakeTranslation({100, 100, 0}) *
|
||||
Matrix::MakeScale({0.5, 0.5, 1.0}));
|
||||
Paint paint = {
|
||||
.color_source = image_source,
|
||||
.mask_blur_descriptor =
|
||||
Paint::MaskBlurDescriptor{
|
||||
.style = FilterContents::BlurStyle::kNormal,
|
||||
.sigma = Sigma(sigma),
|
||||
},
|
||||
};
|
||||
canvas.DrawRect(
|
||||
Rect::MakeXYWH(0, 0, boston->GetSize().width, boston->GetSize().height),
|
||||
paint);
|
||||
|
||||
return canvas.EndRecordingAsPicture();
|
||||
};
|
||||
ASSERT_TRUE(OpenPlaygroundHere(callback));
|
||||
}
|
||||
|
||||
} // namespace testing
|
||||
} // namespace impeller
|
||||
|
||||
@ -183,7 +183,6 @@ std::shared_ptr<FilterContents> Paint::MaskBlurDescriptor::CreateMaskBlur(
|
||||
}
|
||||
color_source_contents->SetGeometry(
|
||||
Geometry::MakeRect(*expanded_local_bounds));
|
||||
|
||||
std::shared_ptr<Contents> color_contents = color_source_contents;
|
||||
|
||||
/// 4. Apply the user set color filter on the GPU, if applicable.
|
||||
|
||||
@ -228,8 +228,12 @@ std::optional<Snapshot> TiledTextureContents::RenderToSnapshot(
|
||||
bool msaa_enabled,
|
||||
int32_t mip_count,
|
||||
const std::string& label) const {
|
||||
std::optional<Rect> geometry_coverage = GetGeometry()->GetCoverage({});
|
||||
if (GetInverseEffectTransform().IsIdentity() &&
|
||||
GetGeometry()->IsAxisAlignedRect()) {
|
||||
GetGeometry()->IsAxisAlignedRect() &&
|
||||
(!geometry_coverage.has_value() ||
|
||||
Rect::MakeSize(texture_->GetSize())
|
||||
.Contains(geometry_coverage.value()))) {
|
||||
auto coverage = GetCoverage(entity);
|
||||
if (!coverage.has_value()) {
|
||||
return std::nullopt;
|
||||
|
||||
@ -528,6 +528,9 @@ impeller_Play_AiksTest_ImageFilteredUnboundedSaveLayerWithUnboundedContents_Vulk
|
||||
impeller_Play_AiksTest_LinearToSrgbFilterSubpassCollapseOptimization_Metal.png
|
||||
impeller_Play_AiksTest_LinearToSrgbFilterSubpassCollapseOptimization_OpenGLES.png
|
||||
impeller_Play_AiksTest_LinearToSrgbFilterSubpassCollapseOptimization_Vulkan.png
|
||||
impeller_Play_AiksTest_MaskBlurDoesntStretchContents_Metal.png
|
||||
impeller_Play_AiksTest_MaskBlurDoesntStretchContents_OpenGLES.png
|
||||
impeller_Play_AiksTest_MaskBlurDoesntStretchContents_Vulkan.png
|
||||
impeller_Play_AiksTest_MaskBlurTexture_Metal.png
|
||||
impeller_Play_AiksTest_MaskBlurTexture_OpenGLES.png
|
||||
impeller_Play_AiksTest_MaskBlurTexture_Vulkan.png
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user