[Impeller] expose reference to tessellator instead of shared_ptr. (flutter/engine#56244)

All geometries were incrementing the shared_ptr usage count which shows up in profiles. Instead expose a Tessellator reference like we do with HostBuffer.
This commit is contained in:
Jonah Williams
2024-10-30 17:40:18 -07:00
committed by GitHub
parent a4bb83e6e8
commit 693f99ae00
9 changed files with 12 additions and 14 deletions

View File

@@ -543,8 +543,8 @@ fml::StatusOr<RenderTarget> ContentContext::MakeSubpass(
return subpass_target;
}
std::shared_ptr<Tessellator> ContentContext::GetTessellator() const {
return tessellator_;
Tessellator& ContentContext::GetTessellator() const {
return *tessellator_;
}
std::shared_ptr<Context> ContentContext::GetContext() const {

View File

@@ -374,7 +374,7 @@ class ContentContext {
bool IsValid() const;
std::shared_ptr<Tessellator> GetTessellator() const;
Tessellator& GetTessellator() const;
std::shared_ptr<Pipeline<PipelineDescriptor>> GetFastGradientPipeline(
ContentContextOptions opts) const {

View File

@@ -46,12 +46,10 @@ GeometryResult CircleGeometry::GetPositionBuffer(const ContentContext& renderer,
: LineGeometry::ComputePixelHalfWidth(
transform, stroke_width_);
const std::shared_ptr<Tessellator>& tessellator = renderer.GetTessellator();
// We call the StrokedCircle method which will simplify to a
// FilledCircleGenerator if the inner_radius is <= 0.
auto generator =
tessellator->StrokedCircle(transform, center_, radius_, half_width);
auto generator = renderer.GetTessellator().StrokedCircle(transform, center_,
radius_, half_width);
return ComputePositionGeometry(renderer, generator, entity, pass);
}

View File

@@ -18,7 +18,7 @@ GeometryResult EllipseGeometry::GetPositionBuffer(
RenderPass& pass) const {
return ComputePositionGeometry(
renderer,
renderer.GetTessellator()->FilledEllipse(entity.GetTransform(), bounds_),
renderer.GetTessellator().FilledEllipse(entity.GetTransform(), bounds_),
entity, pass);
}

View File

@@ -38,7 +38,7 @@ GeometryResult FillPathGeometry::GetPositionBuffer(
};
}
VertexBuffer vertex_buffer = renderer.GetTessellator()->TessellateConvex(
VertexBuffer vertex_buffer = renderer.GetTessellator().TessellateConvex(
path_, host_buffer, entity.GetTransform().GetMaxBasisLengthXY());
return GeometryResult{

View File

@@ -80,8 +80,8 @@ GeometryResult LineGeometry::GetPositionBuffer(const ContentContext& renderer,
auto radius = ComputePixelHalfWidth(transform, width_);
if (cap_ == Cap::kRound) {
std::shared_ptr<Tessellator> tessellator = renderer.GetTessellator();
auto generator = tessellator->RoundCapLine(transform, p0_, p1_, radius);
auto generator =
renderer.GetTessellator().RoundCapLine(transform, p0_, p1_, radius);
return ComputePositionGeometry(renderer, generator, entity, pass);
}

View File

@@ -42,7 +42,7 @@ GeometryResult PointFieldGeometry::GetPositionBuffer(
// Get triangulation relative to {0, 0} so we can translate it to each
// point in turn.
Tessellator::EllipticalVertexGenerator generator =
renderer.GetTessellator()->FilledCircle(transform, {}, radius);
renderer.GetTessellator().FilledCircle(transform, {}, radius);
FML_DCHECK(generator.GetTriangleType() == PrimitiveType::kTriangleStrip);
std::vector<Point> circle_vertices;

View File

@@ -16,7 +16,7 @@ GeometryResult RoundRectGeometry::GetPositionBuffer(
const Entity& entity,
RenderPass& pass) const {
return ComputePositionGeometry(renderer,
renderer.GetTessellator()->FilledRoundRect(
renderer.GetTessellator().FilledRoundRect(
entity.GetTransform(), bounds_, radii_),
entity, pass);
}

View File

@@ -581,7 +581,7 @@ GeometryResult StrokePathGeometry::GetPositionBuffer(
auto scale = entity.GetTransform().GetMaxBasisLengthXY();
PositionWriter position_writer;
auto polyline = renderer.GetTessellator()->CreateTempPolyline(path_, scale);
auto polyline = renderer.GetTessellator().CreateTempPolyline(path_, scale);
CreateSolidStrokeVertices(position_writer, polyline, stroke_width,
miter_limit_ * stroke_width_ * 0.5f,
GetJoinProc<PositionWriter>(stroke_join_),