set_texture_from_surface

This commit is contained in:
Romain Vimont 2026-01-28 19:39:24 +01:00
parent 704555a034
commit 72658ef5aa
3 changed files with 59 additions and 65 deletions

View file

@ -414,26 +414,6 @@ sc_screen_init(struct sc_screen *screen,
goto error_destroy_fps_counter;
}
ok = SDL_StartTextInput(screen->window);
if (!ok) {
LOGE("Could not enable text input: %s", SDL_GetError());
goto error_destroy_window;
}
SDL_Surface *icon = sc_icon_load_scrcpy();
if (icon) {
if (!SDL_SetWindowIcon(screen->window, icon)) {
LOGW("Could not set window icon: %s", SDL_GetError());
}
} else if (params->video) {
// just a warning
LOGW("Could not load icon");
} else {
// without video, the icon is used as window content, it must be present
LOGE("Could not load icon");
goto error_destroy_window;
}
screen->renderer = SDL_CreateRenderer(screen->window, NULL);
if (!screen->renderer) {
LOGE("Could not create renderer: %s", SDL_GetError());
@ -464,26 +444,47 @@ sc_screen_init(struct sc_screen *screen,
}
#endif
SDL_Surface *icon_novideo;
bool mipmaps;
if (params->video) {
icon_novideo = NULL;
mipmaps = params->mipmaps;
} else {
icon_novideo = icon;
mipmaps = false;
screen->content_size.width = icon->w;
screen->content_size.height = icon->h;
}
ok = sc_display_init(&screen->display, screen->renderer, icon_novideo,
mipmaps);
if (icon) {
sc_icon_destroy(icon);
}
bool mipmaps = params->video;
ok = sc_display_init(&screen->display, screen->renderer, mipmaps);
if (!ok) {
goto error_destroy_renderer;
}
ok = SDL_StartTextInput(screen->window);
if (!ok) {
LOGE("Could not enable text input: %s", SDL_GetError());
goto error_destroy_display;
}
SDL_Surface *icon = sc_icon_load_scrcpy();
if (icon) {
if (!SDL_SetWindowIcon(screen->window, icon)) {
LOGW("Could not set window icon: %s", SDL_GetError());
}
} else if (params->video) {
// just a warning
LOGW("Could not load icon");
} else {
// without video, the icon is used as window content, it must be present
LOGE("Could not load icon");
goto error_destroy_display;
}
if (!params->video) {
assert(icon);
screen->content_size.width = icon->w;
screen->content_size.height = icon->h;
ok = sc_display_set_texture_from_surface(&screen->display, icon);
if (!ok) {
sc_icon_destroy(icon);
goto error_destroy_display;
}
}
if (icon) {
sc_icon_destroy(icon);
}
screen->frame = av_frame_alloc();
if (!screen->frame) {
LOG_OOM();