diff --git a/engine/src/flutter/impeller/aiks/canvas.cc b/engine/src/flutter/impeller/aiks/canvas.cc index 0cac288dd1..04852db407 100644 --- a/engine/src/flutter/impeller/aiks/canvas.cc +++ b/engine/src/flutter/impeller/aiks/canvas.cc @@ -326,8 +326,11 @@ void Canvas::ClipRRect(const Rect& rect, .SetBounds(rect) .TakePath(); - std::optional inner_rect = (corner_radius * 2 < rect.size.width && - corner_radius * 2 < rect.size.height) + auto size = rect.GetSize(); + // Does the rounded rect have a flat part on the top/bottom or left/right? + bool flat_on_TB = corner_radius * 2 < size.width; + bool flat_on_LR = corner_radius * 2 < size.height; + std::optional inner_rect = (flat_on_LR && flat_on_TB) ? rect.Expand(-corner_radius) : std::make_optional(); auto geometry = Geometry::MakeFillPath(path, inner_rect); @@ -353,12 +356,12 @@ void Canvas::ClipRRect(const Rect& rect, // without involving the curved corners // Since this is a subtract operation, we can subtract each // rectangle piece individually without fear of interference. - if (corner_radius * 2 < rect.size.width) { + if (flat_on_TB) { SubtractCulling(Rect::MakeLTRB( rect.GetLeft() + corner_radius, rect.GetTop(), rect.GetRight() - corner_radius, rect.GetBottom())); } - if (corner_radius * 2 < rect.size.height) { + if (flat_on_LR) { SubtractCulling(Rect::MakeLTRB( rect.GetLeft(), rect.GetTop() + corner_radius, // rect.GetRight(), rect.GetBottom() - corner_radius)); @@ -479,8 +482,7 @@ void Canvas::DrawImage(const std::shared_ptr& image, } const auto source = Rect::MakeSize(image->GetSize()); - const auto dest = - Rect::MakeXYWH(offset.x, offset.y, source.size.width, source.size.height); + const auto dest = source.Shift(offset); DrawImageRect(image, source, dest, paint, std::move(sampler)); } @@ -490,7 +492,7 @@ void Canvas::DrawImageRect(const std::shared_ptr& image, Rect dest, const Paint& paint, SamplerDescriptor sampler) { - if (!image || source.size.IsEmpty() || dest.size.IsEmpty()) { + if (!image || source.IsEmpty() || dest.IsEmpty()) { return; } diff --git a/engine/src/flutter/impeller/aiks/color_source.cc b/engine/src/flutter/impeller/aiks/color_source.cc index f88dcc57ad..b07ac1e018 100644 --- a/engine/src/flutter/impeller/aiks/color_source.cc +++ b/engine/src/flutter/impeller/aiks/color_source.cc @@ -64,7 +64,7 @@ ColorSource ColorSource::MakeLinearGradient(Point start_point, std::vector bounds{start_point, end_point}; auto intrinsic_size = Rect::MakePointBounds(bounds.begin(), bounds.end()); if (intrinsic_size.has_value()) { - contents->SetColorSourceSize(intrinsic_size->size); + contents->SetColorSourceSize(intrinsic_size->GetSize()); } return contents; }; @@ -98,7 +98,7 @@ ColorSource ColorSource::MakeConicalGradient(Point center, std::vector bounds{center + radius_pt, center - radius_pt}; auto intrinsic_size = Rect::MakePointBounds(bounds.begin(), bounds.end()); if (intrinsic_size.has_value()) { - contents->SetColorSourceSize(intrinsic_size->size); + contents->SetColorSourceSize(intrinsic_size->GetSize()); } return contents; }; @@ -128,7 +128,7 @@ ColorSource ColorSource::MakeRadialGradient(Point center, std::vector bounds{center + radius_pt, center - radius_pt}; auto intrinsic_size = Rect::MakePointBounds(bounds.begin(), bounds.end()); if (intrinsic_size.has_value()) { - contents->SetColorSourceSize(intrinsic_size->size); + contents->SetColorSourceSize(intrinsic_size->GetSize()); } return contents; }; diff --git a/engine/src/flutter/impeller/aiks/picture.cc b/engine/src/flutter/impeller/aiks/picture.cc index faa5c34e37..d924caa892 100644 --- a/engine/src/flutter/impeller/aiks/picture.cc +++ b/engine/src/flutter/impeller/aiks/picture.cc @@ -20,12 +20,12 @@ std::optional Picture::Snapshot(AiksContext& context) { return std::nullopt; } - const auto translate = Matrix::MakeTranslation(-coverage.value().origin); + const auto translate = Matrix::MakeTranslation(-coverage->GetOrigin()); auto texture = - RenderToTexture(context, ISize(coverage.value().size), translate); + RenderToTexture(context, ISize(coverage->GetSize()), translate); return impeller::Snapshot{ .texture = std::move(texture), - .transform = Matrix::MakeTranslation(coverage.value().origin)}; + .transform = Matrix::MakeTranslation(coverage->GetOrigin())}; } std::shared_ptr Picture::ToImage(AiksContext& context,