-
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
Linux texture support #20714
Linux texture support #20714
Conversation
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. Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
37ba1bd
to
3db32a6
Compare
Fixed! |
d7ff522
to
63e980a
Compare
Filed flutter/flutter#64576 for the lint issue; we'll figure out the plan to resolve the unrelated issues there. I'll review the rest for functionality now. |
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.
At a high level, the structure matches the other desktop platforms, so that part looks good. I'll defer to @robert-ancell on most of the detailed review since I'm still not fluent enough in reading GObject code to feel like I would catch bugs there.
I left some some nits and comments though.
As for tests, at the very least the new classes should all have tests; while the current situation is uneven, the goal is to improve the level of coverage, not regress it. There are examples of tests already; are there specific questions you have about how to test the new classes?
63e980a
to
333457a
Compare
@stuartmorgan Resolved nits and added partial tests. I've rolled back the changes that don't touch my code (linting fixes), as you've filed an issue for that. Re-review? |
333457a
to
9b271a6
Compare
Also addresses nits from code review. Testing will be complete once I figure out how to stub `eglGetProcAddress` in the tests.
9b271a6
to
013cd2a
Compare
Based on flutter/flutter#64576, the solution for now should be to add |
In the future, please don't force-push to in-review PRs. It removes the ability to use very helpful review features like seeing everything that changed since the last review. |
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.
Thanks for working on this!
shell/platform/linux/public/flutter_linux/fl_texture_registrar.h
Outdated
Show resolved
Hide resolved
shell/platform/linux/public/flutter_linux/fl_texture_registrar.h
Outdated
Show resolved
Hide resolved
shell/platform/linux/public/flutter_linux/fl_texture_registrar.h
Outdated
Show resolved
Hide resolved
I've addressed nits. Finished tests as well by changing the mock implementation in I ended up taking the approach that @robert-ancell suggested and removed the |
The conversation starting here is relevant to this PR as well; we should address them the same way, ideally. |
I've read that conversation, and my personal thinking is that this initial functionality is worth merging, then we can handle more efficient texture handoff later. Like Windows, Linux doesn't have any graphics API-independent way to hand off textures so I think this is the best way for now, since it abstracts that functionality from the user. |
As I explained there, it's important that enough thought is given to things like API names in this version that the more efficient version(s) can be added later without it being a breaking change (or being stuck with confusing APIs where there are 2+ variants, but one of them has a confusingly generic name). |
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.
@stuartmorgan I've left some notes on what I think could be a way to make this API more agnostic of the underlying texture backend. Please comment any thoughts or nits you may have on this design.
gboolean fl_external_texture_gl_copy_pixel_buffer( | ||
FlExternalTextureGl* external_texture, | ||
size_t* width, | ||
size_t* height); |
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 renaming this to fl_external_texture_gl_prepare
would be more fitting if we wanted to make it agnostic. This should also be a part of the FlExternalTexture
interface.
/** | ||
* FlExternalTextureGl: | ||
* | ||
* #FlExternalTextureGl is an abstraction over OpenGL textures. | ||
*/ |
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.
On making this agnostic-- It could be better if this inherited from a base type FlExternalTexture
, and the texture registrar would handle those instead of FlExternalTextureGl
.
int64_t fl_external_texture_gl_texture_id( | ||
FlExternalTextureGl* external_texture); |
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 should just be a part of the interface as well. Since each subclass of FlExternalTexture
should represent one graphics API's textures, ids shouldn't be overlapping.
gboolean fl_external_texture_gl_populate_texture( | ||
FlExternalTextureGl* external_texture, | ||
size_t width, | ||
size_t height, | ||
FlutterOpenGLTexture* opengl_texture); |
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 can also be part of the interface, but maybe swapping FlutterOpenGLTexture*
for a void*
since each subclass will want a different texture type. Keeping this out of the interface doesn't make sense since every subclass will have to do this at some point. This could also be renamed to fl_external_texture_gl_prepare_for_embedder
, but that's a bit more verbose.
FlExternalTextureGl* fl_external_texture_gl_new( | ||
FlTextureCallback texture_callback, | ||
void* user_data); |
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 should definitely be part of the interface but not sure how to make it generic based on FlTextureCallback
returning different values. One way would be to change the output buffer of FlTextureCallback
to a void*
, then the subclass defines what is supposed to be output.
bool fl_texture_registrar_populate_texture( | ||
FlTextureRegistrar* registrar, | ||
int64_t texture_id, | ||
size_t width, | ||
size_t height, | ||
FlutterOpenGLTexture* opengl_texture); |
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.
Again, the FlutterOpenGLTexture
should be changed to a void*
.
*/ | ||
typedef gboolean (*FlTextureCallback)(size_t* width, | ||
size_t* height, | ||
const uint8_t** buffer, |
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 might be better redefined as void* out
, so it is agnostic of the underlying output and can therefore be safely passed to all FlExternalTexture
subclasses.
/** | ||
* FlTextureRegistrar: | ||
* | ||
* #FlTextureRegistrar is used when registering textures. | ||
*/ |
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.
Internally, the FlTextureRegistrar
hashmap should be managing FlExternalTexture
s not their subclasses.
int64_t fl_texture_registrar_register_texture( | ||
FlTextureRegistrar* registrar, | ||
FlTextureCallback texture_callback, | ||
void* user_data); |
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.
On making this agnostic-- it might make sense to make an enum here to differentiate which type of texture is being registered (i.e. OpenGL
, Vulkan
or Pixel Buffer
which should be agnostic). Then the texture registrar would instantiate the respective underlying FlExternalTexture
subclass. Managing Pixel Buffer
callbacks could be done by the texture registrar itself, maybe by simply wrapping it with another callback.
@@ -39,3 +48,14 @@ gchar* bytes_to_hex_string(GBytes* bytes) { | |||
g_string_append_printf(hex_string, "%02x", data[i]); | |||
return g_string_free(hex_string, FALSE); | |||
} | |||
|
|||
FlEngine* make_mock_engine() { |
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.
Can you split this change out into a separate PR?
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.
There's a number of cases where this could be common.
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, #21585.
Some of #19405 (review) (the C API layer part) is relevant here. You've suggested Or maybe there's something that's a higher-level |
From PR triage, is there any progress being made on this PR? If not, can we close this as it looks stale (last update 21 days ago). |
I outlined a path forward in 19405 for the API. |
Looks like this PR will need quite a bit of refactoring to pass review again. I don't think I'll have time for the next month or so, so I've left this as a draft for now. I am definitely still interested in adding support, and will undraft the PR when I feel it's ready :) |
Looks like progress on this has stalled. Closing it for now. Please re-open when needed. |
This needs to re-Open lots of things depend on this one, |
Please read the recent comments; it's not ready for final review yet, so can't be merged as-is. |
I have redesigned API and resubmit this PR #24916. |
Description
Add support for external textures to the Linux platform shell.
Related Issues
Fixes flutter/flutter#64188.
Tests
I added the following tests:
FlTextureRegistrar
FlExternalTextureGl
Checklist
Breaking Change
Did any tests fail when you ran them? Please read handling breaking changes.