-
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 #24916
Linux texture support #24916
Conversation
Has anything changed from the original PR? |
In one word, FlExternalTextureGL has been replaced with an abstract class Also code is ported to be compatible with master branch. Comments are refined. |
This is great hope this time it will get merged 👍 I Appreciate all the hard work everyone is doing :) |
@huanghongxun Amazing to see progress here. I currently work on https://github.com/FlutterGL/flutter_web_gl |
@escamoteur |
But that's inside the Flutter Engine |
@escamoteur GdkWindow* window = gtk_widget_get_parent_window(#FlView)
GdkGLContext* context = gdk_window_create_gl_context(window, error); above code should create a context shared with the one Flutter is using. |
@huanghongxun lets have a more detailed chat when this is merged and on master :-) |
d273114
to
669e0b4
Compare
Will this allow transparent windows (or at least a transparent FlView)? |
Already supported, but not in this PR. The only thing to do is to set app paintable for FlView. |
Hooray! Thanks @huanghongxun for the patience and dedication and thanks for the reviews and merge flutter team! |
Is there any tutorial about how to use this texture on Linux? Does that mean I can write a native OpenGL function render the image then display in flutter texture widget? |
You can render your texture in Flutter's OpenGL context with hardware acceleration. |
@HedgeHao the repo linked by @huanghongxun is mine. It uses a version that is a little older than the one merged, but it should amost work. If you get it working, I'd appreciate a PR, as I have no time right now |
I follow this repo and try to use PixelBufferTexture on my own but texture widget cannot render the data in buffer correctly. Here is my version. else if (strcmp(method, "registerTexture") == 0)
{
self->myTextxure = MY_TEXTURE(g_object_new(my_texture_get_type(), nullptr));
FL_PIXEL_BUFFER_TEXTURE_GET_CLASS(self->myTextxure)->copy_pixels = my_texture_copy_pixels;
fl_texture_registrar_register_texture(self->texture_registrar, FL_TEXTURE(self->myTextxure));
MY_TEXTURE_GET_CLASS(self->myTextxure)->texture_id = reinterpret_cast<int64_t>(FL_TEXTURE(self->myTextxure));
fl_texture_registrar_mark_texture_frame_available(self->texture_registrar, FL_TEXTURE(self->myTextxure));
response = FL_METHOD_RESPONSE(fl_method_success_response_new(fl_value_new_int(MY_TEXTURE_GET_CLASS(self->myTextxure)->texture_id)));
}
else if (strcmp(method, "nativeClick") == 0)
{
int len = 300 * 300 * 4;
uint8_t buffer[len];
for (int i = 0; i < len; i++)
{
buffer[i] = 127;
}
MY_TEXTURE_GET_CLASS(self->myTextxure)->buffer = buffer;
fl_texture_registrar_mark_texture_frame_available(self->texture_registrar, FL_TEXTURE(self->myTextxure));
response = FL_METHOD_RESPONSE(fl_method_success_response_new(nullptr));
} I except after Can someone please help? Thanks a lot! @alexmercerind dart_vlc is such a great work! Wonder if you could help me out with this. |
@HedgeHao I'm happy I can't help out much, however I think that the buffer (whose pointer you are assigning) gets deallocated as soon as the |
I'm willing to try the merged code, but I couldn't compile my code in the dev channel. Anyone knows when this will land on any of the channels? |
@LucasZanella I open a PR. It should work on the latest flutter version on master channel Then I have a further question. Instead of create a pixel buffer directly. I try to use openGL to draw a triangle and get the pixel buffer data then create a texture with that buffer. I thought I can have a triangle render in flutter texture widget but it doesn't work. The code is here. The code work great with GLUT window but not in Flutter. Any ideas? |
Thanks @HedgeHao, PR merged. |
Anyone knows if direct GPU texture is supported yet? Or does it still copy from GPU to CPU and to GPU back again? |
@lattice0 someone please correct me if I'm wrong but I think it still copies from GPU to CPU and to GPU. Engine doesn't support that yet but there is an issue for direct GPU texture support |
I kindly request the answer to the same question (same for macOS). Hardware accelerated rendering is a big concern. Pixel buffers are just not good. If the GL texture in this PR also copies the frame to an intermediate CPU RAM buffer internally, what's the point??? The Playing a 1080p video through pixel buffers will cramp the CPU, redundantly drain the battery. Please consider. Thankyou! |
I haven't tested but the linux texture takes GL Texture name and target. Why would you assume it's copied to CPU and then GPU? On macOS the texture is backed by IOSurface, which is a GPU buffer. |
Add support for external textures to the Linux platform shell.
Related issues
Fixes flutter/flutter#64188.
Design
For API, I introduce an abstract class
FlTexture
for abstration of different OpenGL textures, allowing any other textures to be supported in the future.Subclass
FlPixelBufferTexture
support loading textures from given pixel buffers with RGBA format. For other formats, or textures not from pixel buffers, developer may implement their own texture class.Pre-launch Checklist
writing and running engine tests.
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.