-
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] drawAtlas #35009
[impeller] drawAtlas #35009
Conversation
Still needs tests, and for some reason looks a little funky |
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. |
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.
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); |
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.
Here and everywhere else: Maybe "SetTransforms"? We've been using the term "transform" for any transformation matrices.
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.
Done
impeller/aiks/canvas.cc
Outdated
std::vector<Matrix> xform, | ||
std::vector<Rect> tex, | ||
std::vector<Color> colors, | ||
int count, |
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.
Looks like this count param is unused here.
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.
(Although that might just be because it's WIP)
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.
Removed, unneeded since I'm using std::vector here
|
||
#include <iostream> | ||
#include <optional> | ||
#include "impeller/geometry/path_builder.h" |
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.
Nit: Add space between std and impeller headers.
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.
Done
#include "impeller/renderer/formats.h" | ||
#include "impeller/renderer/sampler_library.h" | ||
#include "impeller/renderer/vertex_buffer_builder.h" | ||
#include "linear_gradient_contents.h" |
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.
Unintended import?
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.
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}; |
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.
Nit: indices
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.
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); |
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.
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.
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.
Ahh this was it, thanks @bdero !
|
||
std::shared_ptr<Texture> GetTexture() const; | ||
|
||
void SetXForm(std::vector<Matrix> xform); |
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.
Nit: Here and everywhere else: Maybe call this SetTransforms
? We've been using "Transform" for transformation matrices instead of Skia's "XForm" around Impeller.
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.
Done
…ncludes, rename xform
I've udpated this with some simple playgrounds. The colors example doesn't do anything yet since blend modes aren't implemented |
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.
LGTM, thanks!
} | ||
|
||
std::optional<Rect> AtlasContents::GetCoverage(const Entity& entity) const { | ||
Rect bounding_box = Rect::MakeLTRB(0, 0, 0, 0); |
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.
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, |
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.
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.
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.
I added a todo is aiks canvas.
Not implemented: