lv_drivers icon indicating copy to clipboard operation
lv_drivers copied to clipboard

feat(sdl): add SDL_HIGHDPI define to allow high DPI render

Open slightc opened this issue 1 year ago • 7 comments

#309

slightc avatar Mar 21 '24 12:03 slightc

The docs says

window should be created in high-DPI mode if supported (>= SDL 2.0.1)

So it won't be used if not supported. Therefore I wonder if we can add it unconditionally.

kisvegabor avatar Mar 25 '24 19:03 kisvegabor

I think that should be a config field, it is up to the user to decide on their own

slightc avatar Mar 25 '24 23:03 slightc

The docs says

window should be created in high-DPI mode if supported (>= SDL 2.0.1)

So it won't be used if not supported. Therefore I wonder if we can add it unconditionally.

you mean like?

#if defined(SDL_HIGHDPI) && SDL_HIGHDPI && SDL_VERSION_ATLEAST(2, 0, 1)
    flag |= SDL_WINDOW_ALLOW_HIGHDPI;
#endif

to https://github.com/lvgl/lv_drivers/blob/0091dc612facc94dce1061a9b78d641c77f1791a/sdl/sdl.c#L336


edit: nvm, i misread unconditionally as conditionally, my bad 😄

ITotalJustice avatar Mar 28 '24 19:03 ITotalJustice

I think use SDL_HIGHDPI macro definition check, that should be defined by those in need, no need for additional version checking (want to keep simplicity).

slightc avatar Apr 01 '24 15:04 slightc

The version check is internal and we need to add it only once. IMO it's simpler than having a new config option which is visible for all the users.

So if there is no objection and if it's not harmful I vote for adding SDL_HIGHDPI (if the SDL version id high enough).

kisvegabor avatar Apr 02 '24 18:04 kisvegabor

emm, that like this?

#ifndef SDL_HIGHDPI
# define SDL_HIGHDPI  SDL_VERSION_ATLEAST(2, 0, 1)
#endif

#if SDL_HIGHDPI
    flag |= SDL_WINDOW_ALLOW_HIGHDPI;
#endif

slightc avatar Apr 03 '24 03:04 slightc

Or just:

#if SDL_VERSION_ATLEAST(2, 0, 1)
    flag |= SDL_WINDOW_ALLOW_HIGHDPI;
#endif

kisvegabor avatar Apr 05 '24 18:04 kisvegabor

@kisvegabor I'm update it, I think that may best can be force enable/disable by developer, so still use the SDL_HIGHDPI, this PR maybe OK?

slightc avatar May 25 '24 09:05 slightc

Could you add it to lvgl master too?

kisvegabor avatar May 30 '24 19:05 kisvegabor