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

Avoid color flash on window creation and resizing #71289

Merged
merged 2 commits into from
Jan 12, 2023

Conversation

RandomShaper
Copy link
Member

On Windows (and maybe in some other windowing systems), when Godot creates a window, it's painted in white before the renderer has a chance to setup a swap chain or context. Windows being stretched also get the newly added region painted in that striking white for the brief time Godot can render something meaningful there.

This PR adds a little framework to let platform display managers to use a more suitable color in those early moments of the new pixels, plus it leverages it for Windows, where the flash of white is annoying.

All orbits around the concept of early clear color override:

  • The very startup of the engine sets the color to the same of the splash screen.
  • The editor and project manager use the theme background for that.
  • In any other situation, as long as the rendering server has already been created, the default clear color is used.

I'm making this PR with the expectation that X11 and MacOS maintainers assess whether those platforms would benefit from this.

BEFORE 🤮

before.mp4

AFTER 😍

after.mp4

@bruvzg
Copy link
Member

bruvzg commented Jan 12, 2023

On macOS, it's transition to the splash screen too fast to see background, but a few pixels of it can be visible if you resize the window really fast, so it will be useful.

#71295

Copy link
Member

@clayjohn clayjohn left a comment

Choose a reason for hiding this comment

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

Looks good to me too

@clayjohn clayjohn merged commit 2189314 into godotengine:master Jan 12, 2023
@Kemeros
Copy link

Kemeros commented Jan 13, 2023

Thank you SO MUCH! ❤️❤️❤️

@Riteo
Copy link
Contributor

Riteo commented Jan 21, 2023

Just for reference, Wayland "fixes" this problem by not mapping the window at all until a valid buffer is sent.

@RandomShaper
Copy link
Member Author

Good to know. And how does resizing look there?

@Riteo
Copy link
Contributor

Riteo commented Jan 21, 2023

@RandomShaper I think that it depends on the compositor, but sway and (IIRC) KDE look a bit... Meh, they resize the decorations and keep the buffer as-is, which is kinda ugly. No garbage, just transparency, but it still looks bad. There is a scaling thingamajig (wl_viewport) that can stretch the buffer in the meantime, but I didn't have much luck using it (random issues popped up) and it didn't look pretty either.

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.

6 participants