|
|
|
|
@@ -157,7 +157,7 @@ get_initial_optimal_size(struct size content_size, uint16_t req_width,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
update_content_rect(struct screen *screen) {
|
|
|
|
|
screen_update_content_rect(struct screen *screen) {
|
|
|
|
|
int dw;
|
|
|
|
|
int dh;
|
|
|
|
|
SDL_GL_GetDrawableSize(screen->window, &dw, &dh);
|
|
|
|
|
@@ -325,7 +325,12 @@ screen_init_rendering(struct screen *screen, const char *window_title,
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
update_content_rect(screen);
|
|
|
|
|
// Reset the window size to trigger a SIZE_CHANGED event, to workaround
|
|
|
|
|
// HiDPI issues with some SDL renderers when several displays having
|
|
|
|
|
// different HiDPI scaling are connected
|
|
|
|
|
SDL_SetWindowSize(screen->window, window_size.width, window_size.height);
|
|
|
|
|
|
|
|
|
|
screen_update_content_rect(screen);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
@@ -402,8 +407,7 @@ screen_set_rotation(struct screen *screen, unsigned rotation) {
|
|
|
|
|
screen->rotation = rotation;
|
|
|
|
|
LOGI("Display rotation set to %u", rotation);
|
|
|
|
|
|
|
|
|
|
update_content_rect(screen);
|
|
|
|
|
screen_render(screen);
|
|
|
|
|
screen_render(screen, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// recreate the texture and resize the window if the frame size has changed
|
|
|
|
|
@@ -420,7 +424,7 @@ prepare_for_frame(struct screen *screen, struct size new_frame_size) {
|
|
|
|
|
get_rotated_size(new_frame_size, screen->rotation);
|
|
|
|
|
set_content_size(screen, new_content_size);
|
|
|
|
|
|
|
|
|
|
update_content_rect(screen);
|
|
|
|
|
screen_update_content_rect(screen);
|
|
|
|
|
|
|
|
|
|
LOGI("New texture: %" PRIu16 "x%" PRIu16,
|
|
|
|
|
screen->frame_size.width, screen->frame_size.height);
|
|
|
|
|
@@ -462,12 +466,16 @@ screen_update_frame(struct screen *screen, struct video_buffer *vb) {
|
|
|
|
|
update_texture(screen, frame);
|
|
|
|
|
mutex_unlock(vb->mutex);
|
|
|
|
|
|
|
|
|
|
screen_render(screen);
|
|
|
|
|
screen_render(screen, false);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
screen_render(struct screen *screen) {
|
|
|
|
|
screen_render(struct screen *screen, bool update_content_rect) {
|
|
|
|
|
if (update_content_rect) {
|
|
|
|
|
screen_update_content_rect(screen);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SDL_RenderClear(screen->renderer);
|
|
|
|
|
if (screen->rotation == 0) {
|
|
|
|
|
SDL_RenderCopy(screen->renderer, screen->texture, NULL, &screen->rect);
|
|
|
|
|
@@ -510,8 +518,7 @@ screen_switch_fullscreen(struct screen *screen) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LOGD("Switched to %s mode", screen->fullscreen ? "fullscreen" : "windowed");
|
|
|
|
|
update_content_rect(screen);
|
|
|
|
|
screen_render(screen);
|
|
|
|
|
screen_render(screen, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
@@ -549,12 +556,10 @@ screen_handle_window_event(struct screen *screen,
|
|
|
|
|
const SDL_WindowEvent *event) {
|
|
|
|
|
switch (event->event) {
|
|
|
|
|
case SDL_WINDOWEVENT_EXPOSED:
|
|
|
|
|
update_content_rect(screen);
|
|
|
|
|
screen_render(screen);
|
|
|
|
|
screen_render(screen, true);
|
|
|
|
|
break;
|
|
|
|
|
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
|
|
|
|
update_content_rect(screen);
|
|
|
|
|
screen_render(screen);
|
|
|
|
|
screen_render(screen, true);
|
|
|
|
|
break;
|
|
|
|
|
case SDL_WINDOWEVENT_MAXIMIZED:
|
|
|
|
|
screen->maximized = true;
|
|
|
|
|
|