Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit cf294fa

Browse files
author
Jonah Williams
authored
[Impeller] expose reference to tessellator instead of shared_ptr. (#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.
1 parent c40b0b6 commit cf294fa

File tree

9 files changed

+12
-14
lines changed

9 files changed

+12
-14
lines changed

impeller/entity/contents/content_context.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,8 +543,8 @@ fml::StatusOr<RenderTarget> ContentContext::MakeSubpass(
543543
return subpass_target;
544544
}
545545

546-
std::shared_ptr<Tessellator> ContentContext::GetTessellator() const {
547-
return tessellator_;
546+
Tessellator& ContentContext::GetTessellator() const {
547+
return *tessellator_;
548548
}
549549

550550
std::shared_ptr<Context> ContentContext::GetContext() const {

impeller/entity/contents/content_context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ class ContentContext {
374374

375375
bool IsValid() const;
376376

377-
std::shared_ptr<Tessellator> GetTessellator() const;
377+
Tessellator& GetTessellator() const;
378378

379379
std::shared_ptr<Pipeline<PipelineDescriptor>> GetFastGradientPipeline(
380380
ContentContextOptions opts) const {

impeller/entity/geometry/circle_geometry.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,10 @@ GeometryResult CircleGeometry::GetPositionBuffer(const ContentContext& renderer,
4646
: LineGeometry::ComputePixelHalfWidth(
4747
transform, stroke_width_);
4848

49-
const std::shared_ptr<Tessellator>& tessellator = renderer.GetTessellator();
50-
5149
// We call the StrokedCircle method which will simplify to a
5250
// FilledCircleGenerator if the inner_radius is <= 0.
53-
auto generator =
54-
tessellator->StrokedCircle(transform, center_, radius_, half_width);
51+
auto generator = renderer.GetTessellator().StrokedCircle(transform, center_,
52+
radius_, half_width);
5553

5654
return ComputePositionGeometry(renderer, generator, entity, pass);
5755
}

impeller/entity/geometry/ellipse_geometry.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ GeometryResult EllipseGeometry::GetPositionBuffer(
1818
RenderPass& pass) const {
1919
return ComputePositionGeometry(
2020
renderer,
21-
renderer.GetTessellator()->FilledEllipse(entity.GetTransform(), bounds_),
21+
renderer.GetTessellator().FilledEllipse(entity.GetTransform(), bounds_),
2222
entity, pass);
2323
}
2424

impeller/entity/geometry/fill_path_geometry.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ GeometryResult FillPathGeometry::GetPositionBuffer(
3838
};
3939
}
4040

41-
VertexBuffer vertex_buffer = renderer.GetTessellator()->TessellateConvex(
41+
VertexBuffer vertex_buffer = renderer.GetTessellator().TessellateConvex(
4242
path_, host_buffer, entity.GetTransform().GetMaxBasisLengthXY());
4343

4444
return GeometryResult{

impeller/entity/geometry/line_geometry.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ GeometryResult LineGeometry::GetPositionBuffer(const ContentContext& renderer,
8080
auto radius = ComputePixelHalfWidth(transform, width_);
8181

8282
if (cap_ == Cap::kRound) {
83-
std::shared_ptr<Tessellator> tessellator = renderer.GetTessellator();
84-
auto generator = tessellator->RoundCapLine(transform, p0_, p1_, radius);
83+
auto generator =
84+
renderer.GetTessellator().RoundCapLine(transform, p0_, p1_, radius);
8585
return ComputePositionGeometry(renderer, generator, entity, pass);
8686
}
8787

impeller/entity/geometry/point_field_geometry.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ GeometryResult PointFieldGeometry::GetPositionBuffer(
4242
// Get triangulation relative to {0, 0} so we can translate it to each
4343
// point in turn.
4444
Tessellator::EllipticalVertexGenerator generator =
45-
renderer.GetTessellator()->FilledCircle(transform, {}, radius);
45+
renderer.GetTessellator().FilledCircle(transform, {}, radius);
4646
FML_DCHECK(generator.GetTriangleType() == PrimitiveType::kTriangleStrip);
4747

4848
std::vector<Point> circle_vertices;

impeller/entity/geometry/round_rect_geometry.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ GeometryResult RoundRectGeometry::GetPositionBuffer(
1616
const Entity& entity,
1717
RenderPass& pass) const {
1818
return ComputePositionGeometry(renderer,
19-
renderer.GetTessellator()->FilledRoundRect(
19+
renderer.GetTessellator().FilledRoundRect(
2020
entity.GetTransform(), bounds_, radii_),
2121
entity, pass);
2222
}

impeller/entity/geometry/stroke_path_geometry.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ GeometryResult StrokePathGeometry::GetPositionBuffer(
581581
auto scale = entity.GetTransform().GetMaxBasisLengthXY();
582582

583583
PositionWriter position_writer;
584-
auto polyline = renderer.GetTessellator()->CreateTempPolyline(path_, scale);
584+
auto polyline = renderer.GetTessellator().CreateTempPolyline(path_, scale);
585585
CreateSolidStrokeVertices(position_writer, polyline, stroke_width,
586586
miter_limit_ * stroke_width_ * 0.5f,
587587
GetJoinProc<PositionWriter>(stroke_join_),

0 commit comments

Comments
 (0)