mirror of
https://github.com/Genymobile/scrcpy.git
synced 2026-04-21 01:33:36 +00:00
Add --render-fit feature
Add an option to configure how the rendering fits the window. The default, `--render-fit=letterbox`, preserves the aspect ratio and fits the window as best as possible, adding black bars at the top/bottom or left/right if needed. This has been the only behavior scrcpy supported so far. Another mode, `--render-fit=disabled`, renders the display at the top-left corner without scaling. This mode will be useful for virtual display resizing.
This commit is contained in:
parent
3b068b669e
commit
f7c5f71ea0
9 changed files with 76 additions and 2 deletions
|
|
@ -158,7 +158,16 @@ sc_screen_is_relative_mode(struct sc_screen *screen) {
|
|||
|
||||
static void
|
||||
compute_content_rect(struct sc_size render_size, struct sc_size content_size,
|
||||
bool can_upscale, SDL_FRect *rect) {
|
||||
bool can_upscale, enum sc_render_fit render_fit,
|
||||
SDL_FRect *rect) {
|
||||
if (render_fit == SC_RENDER_FIT_DISABLED) {
|
||||
rect->x = 0;
|
||||
rect->y = 0;
|
||||
rect->w = content_size.width;
|
||||
rect->h = content_size.height;
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_optimal_size(render_size, content_size)) {
|
||||
rect->x = 0;
|
||||
rect->y = 0;
|
||||
|
|
@ -202,7 +211,7 @@ sc_screen_update_content_rect(struct sc_screen *screen) {
|
|||
struct sc_size render_size =
|
||||
sc_sdl_get_render_output_size(screen->renderer);
|
||||
compute_content_rect(render_size, screen->content_size, can_upscale,
|
||||
&screen->rect);
|
||||
screen->render_fit, &screen->rect);
|
||||
}
|
||||
|
||||
// render the texture to the renderer
|
||||
|
|
@ -406,6 +415,7 @@ sc_screen_init(struct sc_screen *screen,
|
|||
screen->video = params->video;
|
||||
screen->camera = params->camera;
|
||||
screen->window_aspect_ratio_lock = params->window_aspect_ratio_lock;
|
||||
screen->render_fit = params->render_fit;
|
||||
|
||||
screen->req.x = params->window_x;
|
||||
screen->req.y = params->window_y;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue