Skip to content

Commit

Permalink
vo_gpu_next: add --border-background option
Browse files Browse the repository at this point in the history
Allow for setting the border background independently from the
background option.
  • Loading branch information
Dudemanguy committed Feb 26, 2024
1 parent be198c0 commit bc4003d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions DOCS/interface-changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Interface changes
- rename `--background` to `--background-color`
- remove `--alpha` and reintroduce `--background` option for better control
over blending alpha components into specific background types
- add `--border-background` option
--- mpv 0.37.0 ---
- `--save-position-on-quit` and its associated commands now store state files
in %LOCALAPPDATA% instead of %APPDATA% directory by default on Windows.
Expand Down
4 changes: 4 additions & 0 deletions DOCS/man/options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6941,6 +6941,10 @@ them.
Color used to draw parts of the mpv window not covered by video. See the
``--sub-color`` option for how colors are defined.

``--border-background=<none|color|tiles>``
Same as ``--background`` but only applies to the black bar/border area of
the window. ``vo=gpu-next`` only. Defaults to ``color``.

``--opengl-rectangle-textures``
Force use of rectangle textures (default: no). Normally this shouldn't have
any advantages over normal textures. Note that hardware decoding overrides
Expand Down
13 changes: 12 additions & 1 deletion video/out/vo_gpu_next.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ static void update_lut(struct priv *p, struct user_lut *lut);

struct gl_next_opts {
bool delayed_peak;
int border_background;
float corner_rounding;
bool inter_preserve;
struct user_lut lut;
Expand All @@ -186,6 +187,10 @@ const struct m_opt_choice_alternatives lut_types[] = {
const struct m_sub_options gl_next_conf = {
.opts = (const struct m_option[]) {
{"allow-delayed-peak-detect", OPT_BOOL(delayed_peak)},
{"border-background", OPT_CHOICE(border_background,
{"none", BACKGROUND_NONE},
{"color", BACKGROUND_COLOR},
{"tiles", BACKGROUND_TILES})},
{"corner-rounding", OPT_FLOAT(corner_rounding), M_RANGE(0, 1)},
{"interpolation-preserve", OPT_BOOL(inter_preserve)},
{"lut", OPT_STRING(lut.opt), .flags = M_OPT_FILE},
Expand All @@ -199,6 +204,7 @@ const struct m_sub_options gl_next_conf = {
{0},
},
.defaults = &(struct gl_next_opts) {
.border_background = BACKGROUND_COLOR,
.inter_preserve = true,
},
.size = sizeof(struct gl_next_opts),
Expand Down Expand Up @@ -1458,9 +1464,13 @@ static void update_ra_ctx_options(struct vo *vo)
{
struct priv *p = vo->priv;
struct gl_video_opts *gl_opts = p->opts_cache->opts;
bool border_alpha = (p->next_opts->border_background == BACKGROUND_COLOR &&
gl_opts->background_color.a != 255) ||
p->next_opts->border_background == BACKGROUND_NONE;
p->ra_ctx->opts.want_alpha = (gl_opts->background == BACKGROUND_COLOR &&
gl_opts->background_color.a != 255) ||
gl_opts->background == BACKGROUND_NONE;
gl_opts->background == BACKGROUND_NONE ||
border_alpha;
}

static int control(struct vo *vo, uint32_t request, void *data)
Expand Down Expand Up @@ -2100,6 +2110,7 @@ static void update_render_options(struct vo *vo)
{ BACKGROUND_TILES, PL_CLEAR_TILES },
};
pars->params.background = map_background_types[opts->background][1];
pars->params.border = map_background_types[p->next_opts->border_background][1];
#else
pars->params.blend_against_tiles = opts->background == BACKGROUND_TILES;
#endif
Expand Down

0 comments on commit bc4003d

Please sign in to comment.