Skip to content
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] drawAtlas #35009

Merged
merged 8 commits into from
Aug 2, 2022
Merged

Conversation

jonahwilliams
Copy link
Member

@jonahwilliams jonahwilliams commented Jul 29, 2022

Not implemented:

  • cull rect
  • Per-vert color + blending. Sort of approximated it by drawing texture if no color is present and doing dstIn (for one particular reason if color is present).

@jonahwilliams jonahwilliams marked this pull request as ready for review August 2, 2022 16:44
@jonahwilliams
Copy link
Member Author

Still needs tests, and for some reason looks a little funky

@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 Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on 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.

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.

This is great! I spotted a possible issue with the transformed positions, but everything else is nits.


std::shared_ptr<Texture> GetTexture() const;

void SetXForm(std::vector<Matrix> xform);
Copy link
Member

Choose a reason for hiding this comment

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

Here and everywhere else: Maybe "SetTransforms"? We've been using the term "transform" for any transformation matrices.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

std::vector<Matrix> xform,
std::vector<Rect> tex,
std::vector<Color> colors,
int count,
Copy link
Member

Choose a reason for hiding this comment

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

Looks like this count param is unused here.

Copy link
Member

Choose a reason for hiding this comment

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

(Although that might just be because it's WIP)

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed, unneeded since I'm using std::vector here


#include <iostream>
#include <optional>
#include "impeller/geometry/path_builder.h"
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Add space between std and impeller headers.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

#include "impeller/renderer/formats.h"
#include "impeller/renderer/sampler_library.h"
#include "impeller/renderer/vertex_buffer_builder.h"
#include "linear_gradient_contents.h"
Copy link
Member

@bdero bdero Aug 2, 2022

Choose a reason for hiding this comment

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

Unintended import?

Copy link
Member Author

Choose a reason for hiding this comment

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

Cleaned up imports

VertexBufferBuilder<VS::PerVertexData> vertex_builder;
{
vertex_builder.Reserve(texture_coords_.size() * 6);
constexpr size_t indexes[6] = {0, 1, 2, 1, 2, 3};
Copy link
Member

Choose a reason for hiding this comment

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

Nit: indices

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

auto sample_rect = texture_coords_[i];
auto matrix = xform_[i];
auto color = (colors_.size() > 0 ? colors_[i] : Color::Black());
auto transformed_points = sample_rect.GetTransformedPoints(matrix);
Copy link
Member

Choose a reason for hiding this comment

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

Since transformed_points is used as the position of the draw rect, should this be something like Rect::MakeSize(sample_rect.size).GetTransformedPoints(matrix)? It seems like the transformed rect should have origin 0 rather than the position used for sampling the atlas.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ahh this was it, thanks @bdero !


std::shared_ptr<Texture> GetTexture() const;

void SetXForm(std::vector<Matrix> xform);
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Here and everywhere else: Maybe call this SetTransforms? We've been using "Transform" for transformation matrices instead of Skia's "XForm" around Impeller.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@jonahwilliams
Copy link
Member Author

I've udpated this with some simple playgrounds. The colors example doesn't do anything yet since blend modes aren't implemented

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, thanks!

}

std::optional<Rect> AtlasContents::GetCoverage(const Entity& entity) const {
Rect bounding_box = Rect::MakeLTRB(0, 0, 0, 0);
Copy link
Member

Choose a reason for hiding this comment

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

Nit: This can just be the default constructor.

@@ -838,8 +874,10 @@ void DisplayListDispatcher::drawAtlas(const sk_sp<flutter::DlImage> atlas,
flutter::DlImageSampling sampling,
const SkRect* cull_rect,
Copy link
Member

@bdero bdero Aug 2, 2022

Choose a reason for hiding this comment

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

I think we need to incorporate this cull rect at some point, but we can do this as follow-up work. It can probably be done by either surrounding DrawAtlas with DrawClip/Restore calls or doing clipping tricks while building the draw call + coverage itself.
May be worth inserting a TODO nearby.

Copy link
Member Author

Choose a reason for hiding this comment

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

I added a todo is aiks canvas.

@jonahwilliams jonahwilliams added autosubmit Merge PR when tree becomes green via auto submit App and removed needs tests labels Aug 2, 2022
@auto-submit auto-submit bot merged commit e7a37cc into flutter:main Aug 2, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 3, 2022
betrevisan pushed a commit to betrevisan/engine that referenced this pull request Aug 5, 2022
emilyabest pushed a commit to emilyabest/engine that referenced this pull request Aug 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App e: impeller
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants