[Impeller] Refactor SolidFill to use Path/Cover Geometry classes#36661
[Impeller] Refactor SolidFill to use Path/Cover Geometry classes#36661auto-submit[bot] merged 15 commits intoflutter:mainfrom
Conversation
impeller/entity/geometry.cc
Outdated
| } | ||
|
|
||
| std::optional<Rect> CoverGeometry::GetCoverage(Matrix transform) { | ||
| return Rect::MakeLTRB(-INFINITY, -INFINITY, INFINITY, INFINITY); |
There was a problem hiding this comment.
crowdsourcing some alternative ideas here 😄
There was a problem hiding this comment.
Handling infinity rects has been a long time coming. I believe infinity coverage shouldn't cause a problem for EntityPass in its current state given the frustum/stencil clip cropping. We've already got a few Aiks tests using DrawPaint -- including ColorWheel. If none of these tests crash when flipping through them then we're probably good to go.
There was a problem hiding this comment.
Ah, I just noticed this doesn't replace DrawPaint yet. I'd say this is good. If we find problems down the road when landing it they should be easy fixes. It also occurs to me that we still need move comprehensive filter cropping support.
Although eventually we should just ignore most image filters and execute color filters on the CPU for the DrawPaint case anyway.
| return std::nullopt; | ||
| } | ||
| return path_.GetTransformedBoundingBox(entity.GetTransformation()); | ||
| if (geometry_ == nullptr) { |
There was a problem hiding this comment.
This worked before because we'd end up with an empty path here if nothing was set, and we have a test that verifies this works for SolidColorContents, but nothing else.
Is there a valid use-case for drawing a contents without a path or cover, or should this assert instead?
impeller/geometry/rect.h
Outdated
| using IRect = TRect<int64_t>; | ||
|
|
||
| constexpr Rect kLargestCover = | ||
| Rect::MakeLTRB(-INFINITY, -INFINITY, INFINITY, INFINITY); |
There was a problem hiding this comment.
What about adding a Rect::MakeMaximum constructor?
There was a problem hiding this comment.
Also, std::numeric_limits<Scalar>::infinity?
There was a problem hiding this comment.
Done, I think :)
| HostBuffer& host_buffer, | ||
| std::shared_ptr<Tessellator> tessellator, | ||
| ISize render_target_size) { | ||
| auto rect = Rect(Size(render_target_size)); |
There was a problem hiding this comment.
Updated this to skip tessellation
bdero
left a comment
There was a problem hiding this comment.
LGTM! Just some minor comments.
It's nice to see those cover branches moved out of the Contents::Render impls. They've been making me feel uneasy for a while now.
| void ClipContents::SetPath(Path path) { | ||
| path_ = std::move(path); | ||
| void ClipContents::SetGeometry(std::unique_ptr<Geometry> geometry) { | ||
| geometry_ = std::move(geometry); |
There was a problem hiding this comment.
Ah yes, clip paths... Even though clips can only be specified using paths right now, using Geometry SGTM because we'll want clip paths to benefit from all the special optimizations we're gonna land over time. Heck, we might even produce polylines from DL paths directly at some point.
impeller/entity/geometry.cc
Outdated
| auto rect = Rect(Size(render_target_size)); | ||
| constexpr uint16_t kRectIndicies[6] = {0, 1, 2, 1, 2, 3}; | ||
| return GeometryResult{ | ||
| .type = PrimitiveType::kTriangle, |
There was a problem hiding this comment.
Nit: This could also be a triangle strip with 4 indices! ;)
impeller/geometry/rect.h
Outdated
| auto wx = origin.x + size.width; | ||
| auto wy = origin.y + size.height; | ||
| return {origin.x, origin.y, wx, origin.y, origin.x, wy, wx, wy}; | ||
| } |
There was a problem hiding this comment.
This data layout is identical to GetPoints. Can we use that instead?
| @@ -62,12 +59,13 @@ bool SolidColorContents::Render(const ContentContext& renderer, | |||
| renderer.GetSolidFillPipeline(OptionsFromPassAndEntity(pass, entity)); | |||
There was a problem hiding this comment.
Note to self: We should clean up these these pipelines later on by using the new vertex shaders/deleting the old ones.
Work towards go/impeller-geometry.
Notes: