[Impeller] Do not cull in TextFrameDispatcher::drawDisplayList if the transform has perspective (flutter/engine#55602)
Fixes https://github.com/flutter/flutter/issues/155947
This commit is contained in:
@@ -452,6 +452,30 @@ TEST_P(AiksTest, CanRenderTextWithLargePerspectiveTransform) {
|
||||
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
|
||||
}
|
||||
|
||||
TEST_P(AiksTest, CanRenderTextWithPerspectiveTransformInSublist) {
|
||||
DisplayListBuilder text_builder;
|
||||
ASSERT_TRUE(RenderTextInCanvasSkia(GetContext(), text_builder, "Hello world",
|
||||
"Roboto-Regular.ttf"));
|
||||
auto text_display_list = text_builder.Build();
|
||||
|
||||
DisplayListBuilder builder;
|
||||
|
||||
Matrix matrix = Matrix::MakeRow(2.0, 0.0, 0.0, 0.0, //
|
||||
0.0, 2.0, 0.0, 0.0, //
|
||||
0.0, 0.0, 1.0, 0.0, //
|
||||
0.0, 0.002, 0.0, 1.0);
|
||||
|
||||
DlPaint save_paint;
|
||||
SkRect window_bounds =
|
||||
SkRect::MakeXYWH(0, 0, GetWindowSize().width, GetWindowSize().height);
|
||||
builder.SaveLayer(&window_bounds, &save_paint);
|
||||
builder.Transform(SkM44::ColMajor(matrix.m));
|
||||
builder.DrawDisplayList(text_display_list, 1.0f);
|
||||
builder.Restore();
|
||||
|
||||
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
|
||||
}
|
||||
|
||||
// This currently renders solid blue, as the support for text color sources was
|
||||
// moved into DLDispatching. Path data requires the SkTextBlobs which are not
|
||||
// used in impeller::TextFrames.
|
||||
|
||||
@@ -1484,16 +1484,20 @@ void TextFrameDispatcher::drawDisplayList(
|
||||
bool old_has_image_filter = has_image_filter_;
|
||||
has_image_filter_ = false;
|
||||
|
||||
Rect local_cull_bounds = GetCurrentLocalCullingBounds();
|
||||
if (local_cull_bounds.IsMaximum()) {
|
||||
if (matrix_.HasPerspective()) {
|
||||
display_list->Dispatch(*this);
|
||||
} else if (!local_cull_bounds.IsEmpty()) {
|
||||
IRect cull_rect = IRect::RoundOut(local_cull_bounds);
|
||||
display_list->Dispatch(*this, SkIRect::MakeLTRB(cull_rect.GetLeft(), //
|
||||
cull_rect.GetTop(), //
|
||||
cull_rect.GetRight(), //
|
||||
cull_rect.GetBottom() //
|
||||
));
|
||||
} else {
|
||||
Rect local_cull_bounds = GetCurrentLocalCullingBounds();
|
||||
if (local_cull_bounds.IsMaximum()) {
|
||||
display_list->Dispatch(*this);
|
||||
} else if (!local_cull_bounds.IsEmpty()) {
|
||||
IRect cull_rect = IRect::RoundOut(local_cull_bounds);
|
||||
display_list->Dispatch(*this, SkIRect::MakeLTRB(cull_rect.GetLeft(), //
|
||||
cull_rect.GetTop(), //
|
||||
cull_rect.GetRight(), //
|
||||
cull_rect.GetBottom() //
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
restore();
|
||||
|
||||
@@ -469,6 +469,9 @@ impeller_Play_AiksTest_CanRenderTextOutsideBoundaries_Vulkan.png
|
||||
impeller_Play_AiksTest_CanRenderTextWithLargePerspectiveTransform_Metal.png
|
||||
impeller_Play_AiksTest_CanRenderTextWithLargePerspectiveTransform_OpenGLES.png
|
||||
impeller_Play_AiksTest_CanRenderTextWithLargePerspectiveTransform_Vulkan.png
|
||||
impeller_Play_AiksTest_CanRenderTextWithPerspectiveTransformInSublist_Metal.png
|
||||
impeller_Play_AiksTest_CanRenderTextWithPerspectiveTransformInSublist_OpenGLES.png
|
||||
impeller_Play_AiksTest_CanRenderTextWithPerspectiveTransformInSublist_Vulkan.png
|
||||
impeller_Play_AiksTest_CanRenderThickCurvedStrokes_Metal.png
|
||||
impeller_Play_AiksTest_CanRenderThickCurvedStrokes_OpenGLES.png
|
||||
impeller_Play_AiksTest_CanRenderThickCurvedStrokes_Vulkan.png
|
||||
|
||||
Reference in New Issue
Block a user