Remove prepare_for_frame()

Inline the function body in its only caller.

This will simplify further refactors.
This commit is contained in:
Romain Vimont 2025-07-03 18:36:17 +02:00
commit 6a0529ca13

View file

@ -619,16 +619,17 @@ sc_screen_init_size(struct sc_screen *screen) {
return res != SC_DISPLAY_RESULT_ERROR;
}
// recreate the texture and resize the window if the frame size has changed
static enum sc_display_result
prepare_for_frame(struct sc_screen *screen, struct sc_size new_frame_size) {
static bool
sc_screen_apply_frame(struct sc_screen *screen) {
assert(screen->video);
if (screen->frame_size.width == new_frame_size.width
&& screen->frame_size.height == new_frame_size.height) {
return SC_DISPLAY_RESULT_OK;
}
sc_fps_counter_add_rendered_frame(&screen->fps_counter);
AVFrame *frame = screen->frame;
struct sc_size new_frame_size = {frame->width, frame->height};
if (screen->frame_size.width != new_frame_size.width
|| screen->frame_size.height != new_frame_size.height) {
// frame dimension changed
screen->frame_size = new_frame_size;
@ -638,18 +639,8 @@ prepare_for_frame(struct sc_screen *screen, struct sc_size new_frame_size) {
sc_screen_update_content_rect(screen);
return sc_display_set_texture_size(&screen->display, screen->frame_size);
}
static bool
sc_screen_apply_frame(struct sc_screen *screen) {
assert(screen->video);
sc_fps_counter_add_rendered_frame(&screen->fps_counter);
AVFrame *frame = screen->frame;
struct sc_size new_frame_size = {frame->width, frame->height};
enum sc_display_result res = prepare_for_frame(screen, new_frame_size);
enum sc_display_result res =
sc_display_set_texture_size(&screen->display, screen->frame_size);
if (res == SC_DISPLAY_RESULT_ERROR) {
return false;
}
@ -657,8 +648,10 @@ sc_screen_apply_frame(struct sc_screen *screen) {
// Not an error, but do not continue
return true;
}
}
res = sc_display_update_texture(&screen->display, frame);
enum sc_display_result res =
sc_display_update_texture(&screen->display, frame);
if (res == SC_DISPLAY_RESULT_ERROR) {
return false;
}