-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] improve performance of polyline and stroke generation by reducing allocation and lambda usage. #50379
Changes from all commits
205a630
e5a1087
9f4ef45
7c82649
17e9b9b
c6fbfbd
2d02e25
621bb1d
0703c30
aebe629
7744e36
e179a39
915d7db
3fc399f
aa13f2d
d39efb4
7efef62
e2e7ef9
e49996f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,11 @@ | |
|
|
||
| namespace impeller { | ||
|
|
||
| class VertexWriter { | ||
| public: | ||
| virtual void AppendVertex(const Point& point) = 0; | ||
| }; | ||
|
|
||
| /// @brief A geometry that is created from a stroked path object. | ||
| class StrokePathGeometry final : public Geometry { | ||
| public: | ||
|
|
@@ -28,23 +33,21 @@ class StrokePathGeometry final : public Geometry { | |
|
|
||
| Join GetStrokeJoin() const; | ||
|
|
||
| using CapProc = std::function<void(VertexWriter& vtx_builder, | ||
| const Point& position, | ||
| const Point& offset, | ||
| Scalar scale, | ||
| bool reverse)>; | ||
| using JoinProc = std::function<void(VertexWriter& vtx_builder, | ||
| const Point& position, | ||
| const Point& start_offset, | ||
| const Point& end_offset, | ||
| Scalar miter_limit, | ||
| Scalar scale)>; | ||
|
|
||
| private: | ||
| using VS = SolidFillVertexShader; | ||
|
|
||
| using CapProc = | ||
| std::function<void(VertexBufferBuilder<VS::PerVertexData>& vtx_builder, | ||
| const Point& position, | ||
| const Point& offset, | ||
| Scalar scale, | ||
| bool reverse)>; | ||
| using JoinProc = | ||
| std::function<void(VertexBufferBuilder<VS::PerVertexData>& vtx_builder, | ||
| const Point& position, | ||
| const Point& start_offset, | ||
| const Point& end_offset, | ||
| Scalar miter_limit, | ||
| Scalar scale)>; | ||
|
|
||
| // |Geometry| | ||
| GeometryResult GetPositionBuffer(const ContentContext& renderer, | ||
| const Entity& entity, | ||
|
|
@@ -65,23 +68,61 @@ class StrokePathGeometry final : public Geometry { | |
|
|
||
| bool SkipRendering() const; | ||
|
|
||
| static Scalar CreateBevelAndGetDirection( | ||
| VertexBufferBuilder<SolidFillVertexShader::PerVertexData>& vtx_builder, | ||
| const Point& position, | ||
| const Point& start_offset, | ||
| const Point& end_offset); | ||
| static Scalar CreateBevelAndGetDirection(VertexWriter& vtx_builder, | ||
| const Point& position, | ||
| const Point& start_offset, | ||
| const Point& end_offset); | ||
|
|
||
| static VertexBufferBuilder<SolidFillVertexShader::PerVertexData> | ||
| CreateSolidStrokeVertices(const Path& path, | ||
| Scalar stroke_width, | ||
| Scalar scaled_miter_limit, | ||
| const JoinProc& join_proc, | ||
| const CapProc& cap_proc, | ||
| Scalar scale); | ||
| static void CreateSolidStrokeVertices(VertexWriter& vtx_builder, | ||
| const Path::Polyline& path, | ||
| Scalar stroke_width, | ||
| Scalar scaled_miter_limit, | ||
| const JoinProc& join_proc, | ||
| const CapProc& cap_proc, | ||
| Scalar scale); | ||
|
|
||
| static StrokePathGeometry::JoinProc GetJoinProc(Join stroke_join); | ||
|
|
||
| static StrokePathGeometry::CapProc GetCapProc(Cap stroke_cap); | ||
| static StrokePathGeometry::CapProc GetCapProc(Cap cap); | ||
|
|
||
| static void CreateButtCap(VertexWriter& vtx_builder, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a bit confused - these don't seem to be used in this PR, is there a reason they were added to the headers? (these = all the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They are used, see https://github.com/flutter/engine/pull/50379/files#diff-c75818e02ee25c31e8f8a6d5cac9a4f80b33edf3066d39104cd805268310625dR267 Previous this used to pass around closures, but I updated these to be static functions, since that is what they are anyway. |
||
| const Point& position, | ||
| const Point& offset, | ||
| Scalar scale, | ||
| bool reverse); | ||
|
|
||
| static void CreateRoundCap(VertexWriter& vtx_builder, | ||
| const Point& position, | ||
| const Point& offset, | ||
| Scalar scale, | ||
| bool reverse); | ||
|
|
||
| static void CreateSquareCap(VertexWriter& vtx_builder, | ||
| const Point& position, | ||
| const Point& offset, | ||
| Scalar scale, | ||
| bool reverse); | ||
|
|
||
| static void CreateMiterJoin(VertexWriter& vtx_builder, | ||
| const Point& position, | ||
| const Point& start_offset, | ||
| const Point& end_offset, | ||
| Scalar miter_limit, | ||
| Scalar scale); | ||
|
|
||
| static void CreateRoundJoin(VertexWriter& vtx_builder, | ||
| const Point& position, | ||
| const Point& start_offset, | ||
| const Point& end_offset, | ||
| Scalar miter_limit, | ||
| Scalar scale); | ||
|
|
||
| static void CreateBevelJoin(VertexWriter& vtx_builder, | ||
| const Point& position, | ||
| const Point& start_offset, | ||
| const Point& end_offset, | ||
| Scalar miter_limit, | ||
| Scalar scale); | ||
|
|
||
| Path path_; | ||
| Scalar stroke_width_; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,6 @@ | |
|
|
||
| #include <functional> | ||
| #include <optional> | ||
| #include <set> | ||
| #include <tuple> | ||
| #include <vector> | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.