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

Conversation

@jonahwilliams
Copy link
Contributor

@jonahwilliams jonahwilliams commented Apr 10, 2024

Canvas implementation that renders directly, requires ENABLE_EXPERIMENTAL_CANVAS to be set to true and only wired up for android/vulkan.

Currently missing:

  • Clips
  • backdrop filters
  • opacity peephole
  • More?

This will eventually allow us to delete the aiks layer and cut out most conversion costs. Part of flutter/flutter#142054

SkScalar opacity) override {
save();
display_list->Dispatch(*this);
restore();
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add a DCHECK that we returned to the same level we started at?? DL should never leave us hanging here, but it couldn't hurt to check?

This saves having to construct a new Dispatcher object for the sub-DL, which would technically be a "safer" implementation.

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

@jonahwilliams jonahwilliams changed the title [Impeller] experimental canvas. [Impeller] Off by defaul experimental canvas. Apr 17, 2024
@jonahwilliams jonahwilliams marked this pull request as ready for review April 17, 2024 19:24
@jonahwilliams jonahwilliams requested review from bdero and flar April 17, 2024 19:24
@jonahwilliams jonahwilliams changed the title [Impeller] Off by defaul experimental canvas. [Impeller] Off by default experimental canvas. Apr 17, 2024
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact "@test-exemption-reviewer" in the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

const Paint& paint);
virtual void DrawTextFrame(const std::shared_ptr<TextFrame>& text_frame,
Point position,
const Paint& paint);
Copy link
Member

Choose a reason for hiding this comment

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

I think the shared data and logic between the old and new canvas is going to get confusing real fast as we continue ramping up the new dispatcher.

Why not just make the new "Canvas" not share an interface with the original Canvas at all? That way, we can start diverging immediately where it makes sense, and we can incorporate @flar's changes in the new Canvas without having to mess with the original interface unnecessarily.

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 was your suggestion to make the migration more gradual without fully rewriting the renderer :)

Copy link
Member

@bdero bdero Apr 17, 2024

Choose a reason for hiding this comment

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

My suggestion was more to reuse Entities render methods, not the Aiks or Dispatcher logic. I think not extending Canvas would be a minor change here, since it doesn't look like you're actually using much Canvas stuff (unless I'm missing something)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh I was never going to rewrite entities, that s waaay too much work for one patch. I could do a one time copy/paste of the dispatcher and canvas logic but its quite non-trivial and I wouldn't want to maintain that for too long. If you are able to help me get this work finished quickly I think that would be OK, but I wouldn't want to maintain two dispatchers for very long.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I totally misread this patch -- I just noticed that you're overriding ExperimentalCanvas::AddEntityToCurrentPass to call the render method, and it actually is using most of the original Canvas logic. Disregard. 😅

Copy link
Contributor

Choose a reason for hiding this comment

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

current_pass_ and base_pass_ aren't really needed for the experimental canvas. It would be nice if we renamed "Canvas" to "CanvasBase" and then Canvas and ExperimentalCanvas would subclass from that with their differences and associated data hidden in their own sub-class...?

Copy link
Member

@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

const std::shared_ptr<ImageFilter>& backdrop_filter,
ContentBoundsPromise bounds_promise) {
// Can we always guarantee that we get a bounds? Does a lack of bounds
// indicate something?
Copy link
Member

Choose a reason for hiding this comment

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

The bounds parameter is kinda badly named. In Skia it's a "hint" for optimization that allows the user to promise they won't draw outside of the area. We could do away with this when we start querying computed SaveLayer bounds from the DL.

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 bounds value is already computed in the DL. So these are actual bounds, modulo some places where we seem to not get bounds.

Copy link
Contributor

Choose a reason for hiding this comment

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

Will ExperimentalCanvas be used independently of a DL dispatch? The current aiks Canvas gets content from tests that don't always supply a bounds, but the DL dispatch will now always have a bounds. It has an additional hint that the bounds might (as in probably, most likely) clip the contents, but other than that distinction, the bounds should always be trustable if they came from a DL.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will not be used independently of a DlDispatcher. In fact, long term we'll probably just merge this class into the DL dispatcher.

Comment on lines +145 to +148
if (!bounds.has_value()) {
bounds = Rect::MakeSize(render_target_.GetRenderTargetSize());
}
Rect subpass_coverage = bounds->TransformBounds(GetCurrentTransform());
Copy link
Member

Choose a reason for hiding this comment

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

If only it were this simple...

Copy link
Contributor

Choose a reason for hiding this comment

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

ExperimentalCanvas could probably FML_[D]CHECK(bounds.has_value())

@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 17, 2024
@auto-submit auto-submit bot merged commit 07f7532 into flutter:main Apr 17, 2024
@jonahwilliams jonahwilliams deleted the canvas_stuff_2 branch April 17, 2024 22:43
auto transform = entity.GetTransform();
entity.SetTransform(
Matrix::MakeTranslation(Vector3(-GetGlobalPassPosition())) * transform);
entity.Render(renderer_, *render_passes_.back());
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the ExperimentalCanvas using the old clipping stencil buffer implementation? (the reason I ask is it isn't setting the "NewClipDepth") I didn't think that was still in there...

engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 18, 2024
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.

3 participants