diff options
Diffstat (limited to 'libvo/vo_x11.c')
-rw-r--r-- | libvo/vo_x11.c | 86 |
1 files changed, 26 insertions, 60 deletions
diff --git a/libvo/vo_x11.c b/libvo/vo_x11.c index d43601f7c2..c23dd47fd2 100644 --- a/libvo/vo_x11.c +++ b/libvo/vo_x11.c @@ -24,6 +24,7 @@ #include "config.h" #include "video_out.h" #include "aspect.h" +#include "csputils.h" #include "osd.h" #include "libmpcodecs/mp_image.h" #include "libmpcodecs/vfcap.h" @@ -42,6 +43,8 @@ #endif #include "sub/sub.h" +#include "sub/dec_sub.h" +#include "sub/draw_bmp.h" #include "libmpcodecs/sws_utils.h" #define MODE_RGB 0x1 @@ -113,42 +116,6 @@ static void check_events(struct vo *vo) flip_page(vo); } -static void draw_alpha_32(int x0, int y0, int w, int h, unsigned char *src, - unsigned char *srca, int stride, - unsigned char *dst, uint32_t dst_width) -{ - vo_draw_alpha_rgb32(w, h, src, srca, stride, - dst + 4 * (y0 * dst_width + x0), - 4 * dst_width); -} - -static void draw_alpha_24(int x0, int y0, int w, int h, unsigned char *src, - unsigned char *srca, int stride, - unsigned char *dst, uint32_t dst_width) -{ - vo_draw_alpha_rgb24(w, h, src, srca, stride, - dst + 3 * (y0 * dst_width + x0), - 3 * dst_width); -} - -static void draw_alpha_16(int x0, int y0, int w, int h, unsigned char *src, - unsigned char *srca, int stride, - unsigned char *dst, uint32_t dst_width) -{ - vo_draw_alpha_rgb16(w, h, src, srca, stride, - dst + 2 * (y0 * dst_width + x0), - 2 * dst_width); -} - -static void draw_alpha_15(int x0, int y0, int w, int h, unsigned char *src, - unsigned char *srca, int stride, - unsigned char *dst, uint32_t dst_width) -{ - vo_draw_alpha_rgb15(w, h, src, srca, stride, - dst + 2 * (y0 * dst_width + x0), - 2 * dst_width); -} - static void getMyXImage(struct priv *p) { struct vo *vo = p->vo; @@ -457,36 +424,35 @@ static void Display_Image(struct priv *p, XImage *myximage, uint8_t *ImageData) p->myximage->data -= p->out_offset; } -static void draw_osd_elem(void *ctx, int x0, int y0, int w, int h, - unsigned char *src, unsigned char *srca, int stride) +static struct mp_image get_x_buffer(struct priv *p) { - struct priv *p = ctx; - - switch (p->myximage->bits_per_pixel) { - case 24: - draw_alpha_24(x0, y0, w, h, src, srca, stride, p->ImageData, - p->image_width); - break; - case 32: - draw_alpha_32(x0, y0, w, h, src, srca, stride, p->ImageData, - p->image_width); - break; - case 15: - draw_alpha_15(x0, y0, w, h, src, srca, stride, p->ImageData, - p->image_width); - break; - case 16: - draw_alpha_16(x0, y0, w, h, src, srca, stride, p->ImageData, - p->image_width); - break; - default:; - } + struct mp_image img = {0}; + img.w = img.width = p->image_width; + img.h = img.height = p->image_height; + mp_image_setfmt(&img, p->out_format); + + img.planes[0] = p->ImageData; + img.stride[0] = p->image_width * ((p->bpp + 7) / 8); + + return img; } static void draw_osd(struct vo *vo, struct osd_state *osd) { struct priv *p = vo->priv; - osd_draw_text(osd, p->image_width, p->image_height, draw_osd_elem, p); + + struct mp_image img = get_x_buffer(p); + + struct mp_csp_details csp = MP_CSP_DETAILS_DEFAULTS; + + struct sub_render_params subparams = { + .pts = osd->vo_sub_pts, + .dim = {.w = img.w, .h = img.h}, + .normal_scale = 1, + .vsfilter_scale = 1, + }; + + osd_draw_on_image(osd, &img, &csp, &subparams); } static void flip_page(struct vo *vo) |