Skip to content

SDL: add idiotic workaround to be less blurry on HiDPI#1602

Merged
Frenzie merged 2 commits into
koreader:masterfrom
Frenzie:deranged-so-called-hidpi-stuff-that-used-to-work-much-better-for-decades
Apr 18, 2023
Merged

SDL: add idiotic workaround to be less blurry on HiDPI#1602
Frenzie merged 2 commits into
koreader:masterfrom
Frenzie:deranged-so-called-hidpi-stuff-that-used-to-work-much-better-for-decades

Conversation

@Frenzie

@Frenzie Frenzie commented Apr 18, 2023

Copy link
Copy Markdown
Member

Fixes #1300


This change is Reviewable

Frenzie added 2 commits April 18, 2023 20:49
SDL_GetRendererInfo could be useful to check for supported flags.

SDL_GetOutputSize is required to get some kind of half-functioning output for so-called "HiDPI," which is broken by design.
Naturally we supported so-called HiDPI since the mesozoic era of over a decade ago. You'll find that Windows XP and ancient X11 for example also support it much better than modern roughly post-2015 operating systems, contrary to rampant claims by the clueless.
@Frenzie

Frenzie commented Apr 18, 2023

Copy link
Copy Markdown
Member Author

NB I had the displeasure of looking at macOS bad blurry scaling for the past half hour and I'd like to take this opportunity to state to the person I don't recall who told me that macOS is sharp that they are completely and utterly bloody wrong.

a. It sizes things down from 2x so it will never not be blurry.
b. If you go beyond 2x it doesn't go to 3x so it's blurry in the bad way

@Frenzie

Frenzie commented Apr 18, 2023

Copy link
Copy Markdown
Member Author

Mac resolutions.

The way it works is:

  • 2160 x 3840 is 1x
  • everything else is 2x, i.e., scaled down on everything "above" 1080p (in reality it's always 2160p)
  • even though beyond 1080p it should be 3x it's still 2x, where it's scaled up instead — even worse than scaled down!

2023-04-18 21 28 03

@Frenzie

Frenzie commented Apr 18, 2023

Copy link
Copy Markdown
Member Author

Anyway, on Windows things have been more or less good since Windows 8 (although they were better in 7), there's a glimmer of light in XWayland of all places, and I understand Wayland itself will also start to behave sanely at some point in the future, so with any luck we can soon go back to the world of 2015 where everything "HiDPI" worked the way it should:
image

@Frenzie Frenzie requested a review from NiLuJe April 18, 2023 19:57
h = h or SDL.h
local output_w = ffi.new("int[1]", 0)
local output_h = ffi.new("int[1]", 0)
if SDL.SDL.SDL_GetRendererOutputSize(SDL.renderer, output_w, output_h) == 0 and tonumber(output_w[0]) ~= w then

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I assume the double SDL is an unfortunate side-effect of our own ffi wrapper being named SDL, and the C namespace for the actual SDL lib being named SDL too?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, we could change one of them if desired for clarity. The construct occurs a fair bit throughout the code dealing with SDL I'm sure. ;-)

The one called S in SDL2_0.lua is called SDL in framebuffer here.

local S = {
w = 0, h = 0,
screen = nil,
renderer = nil,
texture = nil,
SDL = SDL,
}

@NiLuJe

NiLuJe commented Apr 18, 2023

Copy link
Copy Markdown
Member

I think I grok the intent, but I'm unfamiliar with both SDL internals and HiDPI woes in general to say much about it, but I imagine it's at least less worse than before ;).

@Frenzie

Frenzie commented Apr 18, 2023

Copy link
Copy Markdown
Member Author

Afaik it should be perfect on Windows… potentially with some additional hacks to rub Windows' nose in the fact that yes, we can do HiDPI. ;-P (Which you can also easily do as a user btw.)

Edit:
Here's what I had to do to get The Great Ace Attorney (a recent game!) to not run at upscaled 720p but at proper 2160p. You'd likely have to do the same to KOReader without special hacks in the code to tell Windows 8+ to quit being a complete dumbass.

@Frenzie Frenzie merged commit ac93e1a into koreader:master Apr 18, 2023
@Frenzie Frenzie deleted the deranged-so-called-hidpi-stuff-that-used-to-work-much-better-for-decades branch April 18, 2023 20:46
Frenzie added a commit to Frenzie/koreader that referenced this pull request Apr 18, 2023
Fixes <koreader#8630>. Might require the `SDL_VIDEODRIVER=wayland` environment variable.

Includes:

* SDL: add idiotic workaround to be less blurry on HiDPI (koreader/koreader-base#1602)
* SDL: avoid silly ABS_MT_TRACKING_ID for mouse button presses (koreader/koreader-base#1600)
Frenzie added a commit to koreader/koreader that referenced this pull request Apr 18, 2023
Fixes <#8630>. Might require the `SDL_VIDEODRIVER=wayland` environment variable.

Includes:

* SDL: add idiotic workaround to be less blurry on HiDPI (koreader/koreader-base#1602)
* SDL: avoid silly ABS_MT_TRACKING_ID for mouse button presses (koreader/koreader-base#1600)
0xstillb pushed a commit to 0xstillb/koreader-thai that referenced this pull request May 9, 2026
Fixes <koreader#8630>. Might require the `SDL_VIDEODRIVER=wayland` environment variable.

Includes:

* SDL: add idiotic workaround to be less blurry on HiDPI (koreader/koreader-base#1602)
* SDL: avoid silly ABS_MT_TRACKING_ID for mouse button presses (koreader/koreader-base#1600)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SDL: do something with SDL_GL_GetDrawableSize

2 participants