Add compilation flag for HIDPI workaround

The HIDPI workaround is enabled by default. Expose a flag to be able to
disable it.
This commit is contained in:
Romain Vimont 2019-11-06 19:23:15 +01:00
parent 42780d0b0e
commit 97ee02ada6
4 changed files with 16 additions and 0 deletions

View file

@ -115,6 +115,9 @@ conf.set('WINDOWS_NOCONSOLE', get_option('windows_noconsole'))
# run a server debugger and wait for a client to be attached
conf.set('SERVER_DEBUGGER', get_option('server_debugger'))
# enable a workaround for bug #15
conf.set('HIDPI_WORKAROUND', get_option('hidpi_workaround'))
configure_file(configuration: conf, output: 'config.h')
src_dir = include_directories('src')

View file

@ -134,6 +134,7 @@ create_texture(SDL_Renderer *renderer, struct size frame_size) {
frame_size.width, frame_size.height);
}
#ifdef HIDPI_WORKAROUND
static void
screen_get_sizes(struct screen *screen, struct screen_sizes *out) {
int ww, wh, dw, dh;
@ -144,6 +145,7 @@ screen_get_sizes(struct screen *screen, struct screen_sizes *out) {
out->window.width = dw;
out->window.height = dh;
}
#endif
// This may be called more than once to work around SDL bugs
static bool
@ -167,7 +169,9 @@ screen_init_renderer_and_texture(struct screen *screen) {
return false;
}
#ifdef HIDPI_WORKAROUND
screen_get_sizes(screen, &screen->sizes);
#endif
return true;
}
@ -298,6 +302,7 @@ screen_update_frame(struct screen *screen, struct video_buffer *vb) {
return true;
}
#ifdef HIDPI_WORKAROUND
// workaround for <https://github.com/Genymobile/scrcpy/issues/15>
static inline bool
screen_fix_hidpi(struct screen *screen) {
@ -318,14 +323,19 @@ screen_fix_hidpi(struct screen *screen) {
screen->renderer = NULL;
return false;
}
LOGI("Renderer reset after hidpi scaling changed");
}
return true;
}
#endif
void
screen_window_resized(struct screen *screen) {
#ifdef HIDPI_WORKAROUND
screen_fix_hidpi(screen);
#endif
screen_render(screen);
}

View file

@ -20,10 +20,12 @@ struct screen {
bool has_frame;
bool fullscreen;
bool no_window;
#ifdef HIDPI_WORKAROUND
struct screen_sizes {
struct size window;
struct size drawable;
} sizes;
#endif
};
#define SCREEN_INITIALIZER { \

View file

@ -5,3 +5,4 @@ option('windows_noconsole', type: 'boolean', value: false, description: 'Disable
option('prebuilt_server', type: 'string', description: 'Path of the prebuilt server')
option('portable', type: 'boolean', value: false, description: 'Use scrcpy-server from the same directory as the scrcpy executable')
option('server_debugger', type: 'boolean', value: false, description: 'Run a server debugger and wait for a client to be attached')
option('hidpi_workaround', type: 'boolean', value: true, description: 'Enable a workaround for bug #15')