diff --git a/app/src/display.c b/app/src/display.c index 560d5614..6ec9ff8e 100644 --- a/app/src/display.c +++ b/app/src/display.c @@ -373,7 +373,9 @@ sc_display_update_texture(struct sc_display *display, const AVFrame *frame) { enum sc_display_result sc_display_render(struct sc_display *display, const SDL_Rect *geometry, enum sc_orientation orientation) { - SDL_RenderClear(display->renderer); + bool always_ok = SDL_RenderClear(display->renderer); + (void) always_ok; + assert(always_ok); if (display->pending.flags) { bool ok = sc_display_apply_pending(display); @@ -418,6 +420,8 @@ sc_display_render(struct sc_display *display, const SDL_Rect *geometry, } } - SDL_RenderPresent(display->renderer); + always_ok = SDL_RenderPresent(display->renderer); + assert(always_ok); + return SC_DISPLAY_RESULT_OK; } diff --git a/app/src/input_manager.c b/app/src/input_manager.c index 183ace64..e61ee5fc 100644 --- a/app/src/input_manager.c +++ b/app/src/input_manager.c @@ -674,7 +674,9 @@ sc_input_manager_process_touch(struct sc_input_manager *im, int dw; int dh; - SDL_GetWindowSizeInPixels(im->screen->window, &dw, &dh); + bool always_ok = SDL_GetWindowSizeInPixels(im->screen->window, &dw, &dh); + (void) always_ok; + assert(always_ok); // SDL touch event coordinates are normalized in the range [0; 1] int32_t x = event->x * dw; diff --git a/app/src/mouse_capture.c b/app/src/mouse_capture.c index 86aca215..ec27b6f4 100644 --- a/app/src/mouse_capture.c +++ b/app/src/mouse_capture.c @@ -89,8 +89,14 @@ sc_mouse_capture_set_active(struct sc_mouse_capture *mc, bool capture) { SDL_GetGlobalMouseState(&mouse_x, &mouse_y); int x, y, w, h; - SDL_GetWindowPosition(mc->window, &x, &y); - SDL_GetWindowSize(mc->window, &w, &h); + bool always_ok; + (void) always_ok; + + always_ok = SDL_GetWindowPosition(mc->window, &x, &y); + assert(always_ok); + + always_ok = SDL_GetWindowSize(mc->window, &w, &h); + assert(always_ok); bool outside_window = mouse_x < x || mouse_x >= x + w || mouse_y < y || mouse_y >= y + h; diff --git a/app/src/screen.c b/app/src/screen.c index 0ed5c4d1..dce4821d 100644 --- a/app/src/screen.c +++ b/app/src/screen.c @@ -32,7 +32,9 @@ static struct sc_size get_window_size(const struct sc_screen *screen) { int width; int height; - SDL_GetWindowSize(screen->window, &width, &height); + bool always_ok = SDL_GetWindowSize(screen->window, &width, &height); + (void) always_ok; + assert(always_ok); struct sc_size size; size.width = width; @@ -44,7 +46,9 @@ static struct sc_point get_window_position(const struct sc_screen *screen) { int x; int y; - SDL_GetWindowPosition(screen->window, &x, &y); + bool always_ok = SDL_GetWindowPosition(screen->window, &x, &y); + (void) always_ok; + assert(always_ok); struct sc_point point; point.x = x; @@ -58,7 +62,10 @@ set_window_size(struct sc_screen *screen, struct sc_size new_size) { assert(!screen->fullscreen); assert(!screen->maximized); assert(!screen->minimized); - SDL_SetWindowSize(screen->window, new_size.width, new_size.height); + bool always_ok = + SDL_SetWindowSize(screen->window, new_size.width, new_size.height); + (void) always_ok; + assert(always_ok); } // get the preferred display bounds (i.e. the screen bounds with some margins) @@ -171,7 +178,9 @@ sc_screen_update_content_rect(struct sc_screen *screen) { int dw; int dh; - SDL_GetWindowSizeInPixels(screen->window, &dw, &dh); + bool always_ok = SDL_GetWindowSizeInPixels(screen->window, &dw, &dh); + (void) always_ok; + assert(always_ok); struct sc_size content_size = screen->content_size; // The drawable size is the window size * the HiDPI scale @@ -502,7 +511,12 @@ sc_screen_show_initial_window(struct sc_screen *screen) { screen->req.height); set_window_size(screen, window_size); - SDL_SetWindowPosition(screen->window, x, y); + + bool always_ok; + (void) always_ok; + + always_ok = SDL_SetWindowPosition(screen->window, x, y); + assert(always_ok); if (screen->req.fullscreen) { sc_screen_toggle_fullscreen(screen); @@ -512,13 +526,17 @@ sc_screen_show_initial_window(struct sc_screen *screen) { sc_fps_counter_start(&screen->fps_counter); } - SDL_ShowWindow(screen->window); + always_ok = SDL_ShowWindow(screen->window); + assert(always_ok); + sc_screen_update_content_rect(screen); } void sc_screen_hide_window(struct sc_screen *screen) { - SDL_HideWindow(screen->window); + bool always_ok = SDL_HideWindow(screen->window); + (void) always_ok; + assert(always_ok); } void @@ -764,8 +782,16 @@ sc_screen_resize_to_fit(struct sc_screen *screen) { uint32_t new_x = point.x + (window_size.width - optimal_size.width) / 2; uint32_t new_y = point.y + (window_size.height - optimal_size.height) / 2; - SDL_SetWindowSize(screen->window, optimal_size.width, optimal_size.height); - SDL_SetWindowPosition(screen->window, new_x, new_y); + bool always_ok; + (void) always_ok; + + always_ok = SDL_SetWindowSize(screen->window, optimal_size.width, + optimal_size.height); + assert(always_ok); + + always_ok = SDL_SetWindowPosition(screen->window, new_x, new_y); + assert(always_ok); + LOGD("Resized to optimal size: %ux%u", optimal_size.width, optimal_size.height); } @@ -778,13 +804,20 @@ sc_screen_resize_to_pixel_perfect(struct sc_screen *screen) { return; } + bool always_ok; + (void) always_ok; + if (screen->maximized) { - SDL_RestoreWindow(screen->window); + always_ok = SDL_RestoreWindow(screen->window); + assert(always_ok); screen->maximized = false; } struct sc_size content_size = screen->content_size; - SDL_SetWindowSize(screen->window, content_size.width, content_size.height); + always_ok = SDL_SetWindowSize(screen->window, content_size.width, + content_size.height); + assert(always_ok); + LOGD("Resized to pixel-perfect: %ux%u", content_size.width, content_size.height); } @@ -913,10 +946,16 @@ sc_screen_convert_window_to_frame_coords(struct sc_screen *screen, void sc_screen_hidpi_scale_coords(struct sc_screen *screen, int32_t *x, int32_t *y) { + bool always_ok; + (void) always_ok; + // take the HiDPI scaling (dw/ww and dh/wh) into account int ww, wh, dw, dh; - SDL_GetWindowSize(screen->window, &ww, &wh); - SDL_GetWindowSizeInPixels(screen->window, &dw, &dh); + always_ok = SDL_GetWindowSize(screen->window, &ww, &wh); + assert(always_ok); + + always_ok = SDL_GetWindowSizeInPixels(screen->window, &dw, &dh); + assert(always_ok); // scale for HiDPI (64 bits for intermediate multiplications) *x = (int64_t) *x * dw / ww; diff --git a/app/src/usb/screen_otg.c b/app/src/usb/screen_otg.c index ebdc42a2..bf2167ad 100644 --- a/app/src/usb/screen_otg.c +++ b/app/src/usb/screen_otg.c @@ -11,7 +11,10 @@ static void sc_screen_otg_render(struct sc_screen_otg *screen) { - SDL_RenderClear(screen->renderer); + bool always_ok = SDL_RenderClear(screen->renderer); + (void) always_ok; + assert(always_ok); + if (screen->texture) { bool ok = SDL_RenderTexture(screen->renderer, screen->texture, NULL, NULL); @@ -19,7 +22,9 @@ sc_screen_otg_render(struct sc_screen_otg *screen) { LOGW("Could not render texture: %s", SDL_GetError()); } } - SDL_RenderPresent(screen->renderer); + + always_ok = SDL_RenderPresent(screen->renderer); + assert(always_ok); } bool