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
Codechanges to SDL2 driver to increase readability (and make it more like Win32 driver) #8605
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TrueBrain
force-pushed
the
sdl-cleanup
branch
from
January 24, 2021 12:02
43d8726
to
8d6b155
Compare
michicc
reviewed
Jan 30, 2021
This is already done by CMake: if SDL2 is not detected, this file is not included.
There was no default resolution fallback, and the code was different from the win32 driver. It is now named the same and much more similar.
This makes the code a bit more readable, as both intentions are more clear, and there is less nesting in the main function.
All SDL_NNN errors print SDL_GetError, except for this one place.
It now follows more what the Win32 driver does, and has far less exceptions and special casing. MakePalette creates the Palette and prepares surface. UpdatePalette updates the Palette. CheckPaletteAnim checks if UpdatePalette needs to be called and marks the whole screen dirty so DrawSurfaceToScreen will do a full redraw.
The original code is "strictly correct", but just reads really weird, and we use MakeDirty() in several other places instead too.
TrueBrain
force-pushed
the
sdl-cleanup
branch
from
January 30, 2021 20:17
8d6b155
to
68a72a9
Compare
michicc
approved these changes
Jan 30, 2021
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.
Might be fine 🍤
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation / Problem
While working on adding OpenGL support to SDL2, I found various of things in the SDL2 code that were either hard to read, made the control-flow difficult to understand, or was just a pile of "lets add this and this and this and this" in a single function.
Additionally, for OpenGL we plan to unify the naming and flow of Win32 and SDL2 driver a bit more, so when you read one or the other, you have better grasp of what is going on.
Description
This PR should make absolute zero change to what SDL2 is actually doing. That is, I did my best to not make any real change, but only move code, make it more readable, make it more like Win32, etc. If there is any change, this is most likely not intended.
Few exceptions (as always):
Tip for reviewer: review this commit by commit, they are all fixing a single problem, and they do not depend on each other. It could as well have been 11 separate PRs.
Limitations
Checklist for review
Some things are not automated, and forgotten often. This list is a reminder for the reviewers.