mirror of https://github.com/mpv-player/mpv
vo_rpi: actually draw a black background
Also factor the display size initialization into a separate function. For some reason this seems to work, although setting the background color using this 1x1 pixel bitmap does not work. I blame the RPI beign a terrible piece of hardware with even worse drivers.
This commit is contained in:
parent
382434d45a
commit
6ae66e717f
|
@ -57,6 +57,7 @@ struct osd_part {
|
|||
struct priv {
|
||||
DISPMANX_DISPLAY_HANDLE_T display;
|
||||
DISPMANX_ELEMENT_HANDLE_T window;
|
||||
DISPMANX_RESOURCE_HANDLE_T window_back;
|
||||
DISPMANX_UPDATE_HANDLE_T update;
|
||||
uint32_t w, h;
|
||||
|
||||
|
@ -239,6 +240,64 @@ static void resize(struct vo *vo)
|
|||
MP_WARN(vo, "could not set video rectangle\n");
|
||||
}
|
||||
|
||||
static int update_display_size(struct vo *vo)
|
||||
{
|
||||
struct priv *p = vo->priv;
|
||||
|
||||
uint32_t n_w = 0, n_h = 0;
|
||||
if (graphics_get_display_size(0, &n_w, &n_h) < 0) {
|
||||
MP_FATAL(vo, "Could not get display size.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (p->w == n_w && p->h == n_h)
|
||||
return 0;
|
||||
|
||||
p->w = n_w;
|
||||
p->h = n_h;
|
||||
|
||||
MP_VERBOSE(vo, "Display size: %dx%d\n", p->w, p->h);
|
||||
|
||||
if (p->window)
|
||||
vc_dispmanx_element_remove(p->update, p->window);
|
||||
if (p->window_back)
|
||||
vc_dispmanx_resource_delete(p->window_back);
|
||||
p->window = 0;
|
||||
p->window_back = 0;
|
||||
|
||||
VC_IMAGE_TYPE_T format = VC_IMAGE_ARGB8888; // assuming RPI is always LE
|
||||
p->window_back = vc_dispmanx_resource_create(format, 1 | (4 << 16), 1,
|
||||
&(int32_t){0});
|
||||
if (!p->window_back) {
|
||||
MP_ERR(vo, "Could not create background bitmap.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint32_t px = 0;
|
||||
VC_RECT_T rc = {.width = 1, .height = 1};
|
||||
vc_dispmanx_resource_write_data(p->window_back, format, 4, &px, &rc);
|
||||
|
||||
// Use the whole screen.
|
||||
VC_RECT_T dst = {.width = p->w, .height = p->h};
|
||||
VC_RECT_T src = {.width = 1 << 16, .height = 1 << 16};
|
||||
VC_DISPMANX_ALPHA_T alpha = {
|
||||
.flags = DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS,
|
||||
.opacity = 0xFF,
|
||||
};
|
||||
p->window = vc_dispmanx_element_add(p->update, p->display, p->background_layer,
|
||||
&dst, p->window_back, &src,
|
||||
DISPMANX_PROTECTION_NONE, &alpha, 0, 0);
|
||||
if (!p->window) {
|
||||
MP_FATAL(vo, "Could not add DISPMANX element.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
vc_dispmanx_update_submit_sync(p->update);
|
||||
p->update = vc_dispmanx_update_start(10);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void flip_page(struct vo *vo)
|
||||
{
|
||||
struct priv *p = vo->priv;
|
||||
|
@ -479,6 +538,11 @@ static void uninit(struct vo *vo)
|
|||
|
||||
wipe_osd(vo);
|
||||
|
||||
if (p->window)
|
||||
vc_dispmanx_element_remove(p->update, p->window);
|
||||
if (p->window_back)
|
||||
vc_dispmanx_resource_delete(p->window_back);
|
||||
|
||||
if (p->update)
|
||||
vc_dispmanx_update_submit_sync(p->update);
|
||||
|
||||
|
@ -521,30 +585,8 @@ static int preinit(struct vo *vo)
|
|||
goto fail;
|
||||
}
|
||||
|
||||
if (graphics_get_display_size(0, &p->w, &p->h) < 0) {
|
||||
MP_FATAL(vo, "Could not get display size.\n");
|
||||
if (update_display_size(vo) < 0)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
MP_VERBOSE(vo, "Display size: %dx%d\n", p->w, p->h);
|
||||
|
||||
// Just use the whole screen.
|
||||
VC_RECT_T dst = {.width = p->w, .height = p->h};
|
||||
VC_RECT_T src = {.width = p->w << 16, .height = p->h << 16};
|
||||
VC_DISPMANX_ALPHA_T alpha = {
|
||||
.flags = DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS,
|
||||
.opacity = 0xFF,
|
||||
};
|
||||
p->window = vc_dispmanx_element_add(p->update, p->display, p->background_layer,
|
||||
&dst, 0, &src, DISPMANX_PROTECTION_NONE,
|
||||
&alpha, 0, 0);
|
||||
if (!p->window) {
|
||||
MP_FATAL(vo, "Could not add DISPMANX element.\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
vc_dispmanx_update_submit_sync(p->update);
|
||||
p->update = vc_dispmanx_update_start(10);
|
||||
|
||||
return 0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue