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

[Impeller] Refactor SolidFill to use Path/Cover Geometry classes#36661

Merged
auto-submit[bot] merged 15 commits intoflutter:mainfrom
jonahwilliams:geometry_start
Oct 8, 2022
Merged

[Impeller] Refactor SolidFill to use Path/Cover Geometry classes#36661
auto-submit[bot] merged 15 commits intoflutter:mainfrom
jonahwilliams:geometry_start

Conversation

@jonahwilliams
Copy link
Contributor

Work towards go/impeller-geometry.

Notes:

  • Added ISize to the GeometryPosition instead of UVs to match how existing solid fill shaders work.
  • Always returning a huge rect from coverage for CoverGeometry, not sure if that is the correct approach.
  • Deleted solid_fill_utils since all usages of this code are just inlined into geometry.

}

std::optional<Rect> CoverGeometry::GetCoverage(Matrix transform) {
return Rect::MakeLTRB(-INFINITY, -INFINITY, INFINITY, INFINITY);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

crowdsourcing some alternative ideas here 😄

Copy link
Contributor

@bdero bdero Oct 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

@bdero bdero Oct 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

return std::nullopt;
}
return path_.GetTransformedBoundingBox(entity.GetTransformation());
if (geometry_ == nullptr) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

using IRect = TRect<int64_t>;

constexpr Rect kLargestCover =
Rect::MakeLTRB(-INFINITY, -INFINITY, INFINITY, INFINITY);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about adding a Rect::MakeMaximum constructor?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, std::numeric_limits<Scalar>::infinity?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, I think :)

HostBuffer& host_buffer,
std::shared_ptr<Tessellator> tessellator,
ISize render_target_size) {
auto rect = Rect(Size(render_target_size));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated this to skip tessellation

Copy link
Contributor

@bdero bdero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

auto rect = Rect(Size(render_target_size));
constexpr uint16_t kRectIndicies[6] = {0, 1, 2, 1, 2, 3};
return GeometryResult{
.type = PrimitiveType::kTriangle,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: This could also be a triangle strip with 4 indices! ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

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};
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This data layout is identical to GetPoints. Can we use that instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -62,12 +59,13 @@ bool SolidColorContents::Render(const ContentContext& renderer,
renderer.GetSolidFillPipeline(OptionsFromPassAndEntity(pass, entity));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self: We should clean up these these pipelines later on by using the new vertex shaders/deleting the old ones.

jonahwilliams added 2 commits October 7, 2022 18:25
@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 8, 2022
@auto-submit auto-submit bot merged commit feb8405 into flutter:main Oct 8, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App e: impeller

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants