-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Impeller] Make paths externally immutable, update all tests to use PathBuilder to create Path. #45393
Merged
Merged
[Impeller] Make paths externally immutable, update all tests to use PathBuilder to create Path. #45393
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
db62ff2
[Impeller] make Paths externally immutable, always use PathBuilder.
jonahwilliams 34a5161
[Impeller] make Paths externally immutable, always use PathBuilder.
jonahwilliams 092414e
++
jonahwilliams 47a55fd
++
jonahwilliams 49af6b9
add some docs and fix test.
jonahwilliams 923f7b7
++
jonahwilliams File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,8 +48,8 @@ enum class Convexity { | |
/// All shapes supported by Impeller are paths either directly or | ||
/// via approximation (in the case of circles). | ||
/// | ||
/// Creating paths that describe complex shapes is usually done by a | ||
/// path builder. | ||
/// Paths are externally immutable once created, Creating paths must | ||
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. 👍🏽 |
||
/// be done using a path builder. | ||
/// | ||
class Path { | ||
public: | ||
|
@@ -95,25 +95,10 @@ class Path { | |
|
||
size_t GetComponentCount(std::optional<ComponentType> type = {}) const; | ||
|
||
void SetFillType(FillType fill); | ||
|
||
FillType GetFillType() const; | ||
|
||
bool IsConvex() const; | ||
|
||
Path& AddLinearComponent(Point p1, Point p2); | ||
|
||
Path& AddQuadraticComponent(Point p1, Point cp, Point p2); | ||
|
||
Path& AddCubicComponent(Point p1, Point cp1, Point cp2, Point p2); | ||
|
||
Path& AddContourComponent(Point destination, bool is_closed = false); | ||
|
||
void SetContourClosed(bool is_closed); | ||
|
||
/// @brief Transform the path by the given offset in-place. | ||
void Shift(Point shift); | ||
|
||
template <class T> | ||
using Applier = std::function<void(size_t index, const T& component)>; | ||
void EnumerateComponents( | ||
|
@@ -133,17 +118,6 @@ class Path { | |
bool GetContourComponentAtIndex(size_t index, | ||
ContourComponent& contour) const; | ||
|
||
bool UpdateLinearComponentAtIndex(size_t index, | ||
const LinearPathComponent& linear); | ||
|
||
bool UpdateQuadraticComponentAtIndex(size_t index, | ||
const QuadraticPathComponent& quadratic); | ||
|
||
bool UpdateCubicComponentAtIndex(size_t index, CubicPathComponent& cubic); | ||
|
||
bool UpdateContourComponentAtIndex(size_t index, | ||
const ContourComponent& contour); | ||
|
||
/// Callers must provide the scale factor for how this path will be | ||
/// transformed. | ||
/// | ||
|
@@ -162,6 +136,31 @@ class Path { | |
|
||
void SetConvexity(Convexity value); | ||
|
||
void SetFillType(FillType fill); | ||
|
||
Path& AddLinearComponent(Point p1, Point p2); | ||
|
||
Path& AddQuadraticComponent(Point p1, Point cp, Point p2); | ||
|
||
Path& AddCubicComponent(Point p1, Point cp1, Point cp2, Point p2); | ||
|
||
Path& AddContourComponent(Point destination, bool is_closed = false); | ||
|
||
void SetContourClosed(bool is_closed); | ||
|
||
void Shift(Point shift); | ||
|
||
bool UpdateLinearComponentAtIndex(size_t index, | ||
const LinearPathComponent& linear); | ||
|
||
bool UpdateQuadraticComponentAtIndex(size_t index, | ||
const QuadraticPathComponent& quadratic); | ||
|
||
bool UpdateCubicComponentAtIndex(size_t index, CubicPathComponent& cubic); | ||
|
||
bool UpdateContourComponentAtIndex(size_t index, | ||
const ContourComponent& contour); | ||
|
||
struct ComponentIndexPair { | ||
ComponentType type = ComponentType::kLinear; | ||
size_t index = 0; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add*
inserts a new contour -- this actually needs to beLineTo
to be equivalent.And no, you're not crazy. Yes, the linear component has redundant data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aghh, good catch. Thank you