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

Refactor GL rendering to prepare for GTK4 #50754

Merged
merged 11 commits into from
Feb 29, 2024

Conversation

robert-ancell
Copy link
Contributor

@robert-ancell robert-ancell commented Feb 19, 2024

Refactor GL rendering to prepare for GTK4

  • Remove FlGLArea - we can just use GtkGLArea directly
  • Stop using gdk_cairo_draw_from_gl, it's not available in GTK4.
  • Rename FlRendererGL to FlRendererGdk, this was implying that FlRenderer could be something other than OpenGL which is not the case currently.
  • Remove unnecessary virtual methods in FlRenderer, just implement them as standard methods.

Related: flutter/flutter#143408

@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.

@robert-ancell
Copy link
Contributor Author

Questions for reviewers:

  • Does this still work correctly with headless more? I don't know enough about that case to be sure it's been tested.
  • I've had to go quite low level with rendering (i.e. writing the shaders). The other platforms don't seem to have had to do this. Does it seem reasonable? This is something we can probably simplify using GSK (GTK Scene Kit) in GTK4.

Copy link
Contributor

@gspencergoog gspencergoog left a comment

Choose a reason for hiding this comment

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

32384589-a60f0e74-c078-11e7-9bc1-e5b5287aea9d

@gspencergoog
Copy link
Contributor

It looks good to me, but to be honest I don't know the answers to your questions: it does seem odd that we'd need to go down to shaders to define a rectangular texture blit, but I guess it also gives us lots of flexibility if we need more functionality later. As long as it doesn't incur a performance penalty, and isn't too complex to implement, I don't see a problem with it.

Copy link
Member

@cbracken cbracken left a comment

Choose a reason for hiding this comment

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

LGTM stamp from a Japanese personal seal

lgtm with just a couple minor nits.

shell/platform/linux/fl_renderer.cc Show resolved Hide resolved
shell/platform/linux/fl_renderer.cc Show resolved Hide resolved
shell/platform/linux/fl_renderer.cc Outdated Show resolved Hide resolved
- Remove FlGLArea - we can just use GtkGLArea directly
- Stop using gdk_cairo_draw_from_gl, it's not available in GTK4.
- Rename FlRendererGL to FlRendererGdk, this was implying that FlRenderer could
  be something other than OpenGL which is not the case currently.
- Remove unnecessary virtual methods in FlRenderer, just implement them as
  standard methods.
@robert-ancell
Copy link
Contributor Author

Thanks for the reviews! I'm going to have a few more people look this over / test this before landing it.

@Hixie
Copy link
Contributor

Hixie commented Feb 26, 2024

test-exempt: code refactor with no semantic change

@loic-sharma
Copy link
Member

loic-sharma commented Feb 29, 2024

I've had to go quite low level with rendering (i.e. writing the shaders). The other platforms don't seem to have had to do this.

From my recollection, gdk_cairo_draw_from_gl used cairo_image_surface_get_data, which in turn uses glReadPixel. You might be able to re-use that approach to avoid writing shaders, but I suspect glReadPixel might be worse for performance.

Does Linux have to support GLES 2? I ask as Windows uses glBlitFramebuffer, which requires GLES 3 (which we can use thanks to ANGLE).

@robert-ancell
Copy link
Contributor Author

GTK is designed to work with GLES 2+.

@robert-ancell robert-ancell merged commit 6b857de into flutter:main Feb 29, 2024
25 checks passed
@robert-ancell robert-ancell deleted the standard-gtk-gl-area branch February 29, 2024 21:24
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 29, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 29, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Mar 1, 2024
…144436)

flutter/engine@7e8fefe...6f80444

2024-02-29 [email protected] [Impeller] use specific format for bootstrap texture. (flutter/engine#51082)
2024-02-29 [email protected] [Impeller] remove warning about device transient depth+stencil. (flutter/engine#51033)
2024-02-29 [email protected] Refactor GL rendering to prepare for GTK4 (flutter/engine#50754)
2024-02-29 [email protected] Reland "[skwasm] Clip pictures if they go beyond the bounds of the window." (flutter/engine#51077)
2024-02-29 [email protected] Revert "[macOS] Use CVDisplayLink to drive repaint (#49159)" (flutter/engine#51095)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
robert-ancell added a commit to robert-ancell/flutter-engine that referenced this pull request May 29, 2024
…ontext

Solved by having three contexts - one for GDK and two for Flutter.

Regression introduced in flutter#50754

Fixes flutter/flutter#148653
robert-ancell added a commit that referenced this pull request Jun 3, 2024
…ontext (#53103)

Fix rendering corruption by Flutter and GDK sharing the same OpenGL
context

Solved by having three contexts - one for GDK and two for Flutter.

Regression introduced in #50754

Fixes flutter/flutter#148653
flutteractionsbot pushed a commit to flutteractionsbot/engine that referenced this pull request Jun 3, 2024
…ontext (flutter#53103)

Fix rendering corruption by Flutter and GDK sharing the same OpenGL
context

Solved by having three contexts - one for GDK and two for Flutter.

Regression introduced in flutter#50754

Fixes flutter/flutter#148653
@darkwater darkwater mentioned this pull request Jul 23, 2024
8 tasks
auto-submit bot pushed a commit that referenced this pull request Jul 26, 2024
GLArea.has-alpha defaults to false, which makes it impossible for a Flutter app to be transparent.

The additional change to glClearColor is to prevent a black flash when the application starts, before Flutter widgets become visible. This will also affect applications that aren't transparent, by showing the default GTK background color instead of black. This will not make the window transparent, because the developer currently has to add some code to their `linux/my_application.cc` to support transparency.

Fixes flutter/flutter#152154

Transparent windows were possible before #50754. Would it be ok to add a test for this to prevent breaking transparency again in the future?

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants