mirror of
https://github.com/mpv-player/mpv
synced 2025-03-22 11:18:32 +00:00
Add context variable to vo_draw_text callback
Add a context variable and rename the function to osd_draw_text. Create a new vo_draw_text that is a wrapper for VOs using old API.
This commit is contained in:
parent
2bcfe1e077
commit
8716df2a41
@ -96,7 +96,7 @@ static void remove_func(int x0,int y0, int w,int h){
|
||||
}
|
||||
}
|
||||
|
||||
static void draw_func(int x0,int y0, int w,int h,unsigned char* src, unsigned char *srca, int stride){
|
||||
static void draw_func(void *ctx, int x0,int y0, int w,int h,unsigned char* src, unsigned char *srca, int stride){
|
||||
unsigned char* dst;
|
||||
if(!vo_osd_changed_flag && vf->dmpi->planes[0]==vf->priv->fb_ptr){
|
||||
// ok, enough to update the area inside the video, leave the black bands
|
||||
@ -177,7 +177,7 @@ static void draw_osd(struct vf_instance_s* vf_,int w,int h){
|
||||
vo_remove_text(vf->priv->exp_w,vf->priv->exp_h,remove_func);
|
||||
}
|
||||
}
|
||||
vo_draw_text(vf->priv->exp_w,vf->priv->exp_h,draw_func);
|
||||
osd_draw_text(vf->priv->exp_w,vf->priv->exp_h,draw_func, NULL);
|
||||
// save buffer pointer for double buffering detection - yes, i know it's
|
||||
// ugly method, but note that codecs with DR support does the same...
|
||||
if(vf->dmpi)
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <stdint.h>
|
||||
#include "old_vo_wrapper.h"
|
||||
#include "video_out.h"
|
||||
#include "sub.h"
|
||||
|
||||
int old_vo_preinit(struct vo *vo, const char *arg)
|
||||
{
|
||||
@ -78,3 +79,18 @@ void old_vo_uninit(struct vo *vo)
|
||||
vo->driver->old_functions->uninit();
|
||||
}
|
||||
|
||||
|
||||
static void draw_alpha_wrapper(void *ctx, int x0, int y0, int w, int h,
|
||||
unsigned char *src, unsigned char *srca,
|
||||
int stride)
|
||||
{
|
||||
void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) = ctx;
|
||||
draw_alpha(x0, y0, w, h, src, srca, stride);
|
||||
}
|
||||
|
||||
|
||||
void vo_draw_text(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride))
|
||||
{
|
||||
osd_draw_text(dxs, dys, draw_alpha_wrapper, draw_alpha);
|
||||
}
|
||||
|
||||
|
@ -17,4 +17,6 @@ void old_vo_flip_page(struct vo *vo);
|
||||
void old_vo_check_events(struct vo *vo);
|
||||
void old_vo_uninit(struct vo *vo);
|
||||
|
||||
void vo_draw_text(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride));
|
||||
|
||||
#endif
|
||||
|
17
libvo/sub.c
17
libvo/sub.c
@ -154,9 +154,11 @@ static void alloc_buf(mp_osd_obj_t* obj)
|
||||
}
|
||||
|
||||
// renders the buffer
|
||||
inline static void vo_draw_text_from_buffer(mp_osd_obj_t* obj,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){
|
||||
inline static void vo_draw_text_from_buffer(mp_osd_obj_t* obj,void (*draw_alpha)(void *ctx, int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride), void *ctx)
|
||||
{
|
||||
if (obj->allocated > 0) {
|
||||
draw_alpha(obj->bbox.x1,obj->bbox.y1,
|
||||
draw_alpha(ctx,
|
||||
obj->bbox.x1,obj->bbox.y1,
|
||||
obj->bbox.x2-obj->bbox.x1,
|
||||
obj->bbox.y2-obj->bbox.y1,
|
||||
obj->bitmap_buffer,
|
||||
@ -1022,9 +1024,9 @@ inline static void vo_update_spudec_sub(mp_osd_obj_t* obj, int dxs, int dys)
|
||||
obj->flags |= OSDFLAG_BBOX;
|
||||
}
|
||||
|
||||
inline static void vo_draw_spudec_sub(mp_osd_obj_t* obj, void (*draw_alpha)(int x0, int y0, int w, int h, unsigned char* src, unsigned char* srca, int stride))
|
||||
inline static void vo_draw_spudec_sub(mp_osd_obj_t* obj, void (*draw_alpha)(void *ctx, int x0, int y0, int w, int h, unsigned char* src, unsigned char* srca, int stride), void *ctx)
|
||||
{
|
||||
spudec_draw_scaled(vo_spudec, obj->dxs, obj->dys, draw_alpha);
|
||||
spudec_draw_scaled(vo_spudec, obj->dxs, obj->dys, draw_alpha, ctx);
|
||||
}
|
||||
|
||||
void *vo_spudec=NULL;
|
||||
@ -1223,7 +1225,8 @@ void vo_remove_text(int dxs,int dys,void (*remove)(int x0,int y0, int w,int h)){
|
||||
}
|
||||
}
|
||||
|
||||
void vo_draw_text(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){
|
||||
void osd_draw_text(int dxs,int dys,void (*draw_alpha)(void *ctx, int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride), void *ctx)
|
||||
{
|
||||
mp_osd_obj_t* obj=vo_osd_list;
|
||||
vo_update_osd(dxs,dys);
|
||||
while(obj){
|
||||
@ -1231,7 +1234,7 @@ void vo_draw_text(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h,
|
||||
vo_osd_changed_flag=obj->flags&OSDFLAG_CHANGED; // temp hack
|
||||
switch(obj->type){
|
||||
case OSDTYPE_SPU:
|
||||
vo_draw_spudec_sub(obj, draw_alpha); // FIXME
|
||||
vo_draw_spudec_sub(obj, draw_alpha, ctx); // FIXME
|
||||
break;
|
||||
#ifdef USE_DVDNAV
|
||||
case OSDTYPE_DVDNAV:
|
||||
@ -1242,7 +1245,7 @@ void vo_draw_text(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h,
|
||||
case OSDTYPE_OSD:
|
||||
case OSDTYPE_SUBTITLE:
|
||||
case OSDTYPE_PROGBAR:
|
||||
vo_draw_text_from_buffer(obj,draw_alpha);
|
||||
vo_draw_text_from_buffer(obj, draw_alpha, ctx);
|
||||
break;
|
||||
}
|
||||
obj->old_bbox=obj->bbox;
|
||||
|
@ -116,7 +116,7 @@ extern float spu_gaussvar;
|
||||
//extern void vo_draw_text_osd(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride));
|
||||
//extern void vo_draw_text_progbar(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride));
|
||||
//extern void vo_draw_text_sub(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride));
|
||||
extern void vo_draw_text(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride));
|
||||
extern void osd_draw_text(int dxs,int dys,void (*draw_alpha)(void *ctx, int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride), void *ctx);
|
||||
extern void vo_remove_text(int dxs,int dys,void (*remove)(int x0,int y0, int w,int h));
|
||||
|
||||
void vo_init_osd(void);
|
||||
|
@ -87,7 +87,6 @@ static float window_aspect;
|
||||
static BOOL (WINAPI* myGetMonitorInfo)(HMONITOR, LPMONITORINFO) = NULL;
|
||||
static RECT last_rect = {0xDEADC0DE, 0xDEADC0DE, 0xDEADC0DE, 0xDEADC0DE};
|
||||
|
||||
extern void vo_draw_text(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride));
|
||||
extern int vidmode;
|
||||
|
||||
/*****************************************************************************
|
||||
|
@ -81,7 +81,6 @@ static vo_info_t info =
|
||||
LIBVO_EXTERN(macosx)
|
||||
|
||||
extern void mplayer_put_key(int code);
|
||||
extern void vo_draw_text(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride));
|
||||
|
||||
static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, unsigned char *srca, int stride)
|
||||
{
|
||||
|
@ -129,8 +129,6 @@ enum
|
||||
|
||||
#include "osdep/keycodes.h"
|
||||
|
||||
extern void vo_draw_text(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride));
|
||||
|
||||
//PROTOTYPE/////////////////////////////////////////////////////////////////
|
||||
static OSStatus KeyEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData);
|
||||
static OSStatus MouseEventHandler(EventHandlerCallRef nextHandler, EventRef event, void *userData);
|
||||
|
6
spudec.c
6
spudec.c
@ -767,7 +767,7 @@ void sws_spu_image(unsigned char *d1, unsigned char *d2, int dw, int dh, int ds,
|
||||
sws_freeContext(ctx);
|
||||
}
|
||||
|
||||
void spudec_draw_scaled(void *me, unsigned int dxs, unsigned int dys, void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride))
|
||||
void spudec_draw_scaled(void *me, unsigned int dxs, unsigned int dys, void (*draw_alpha)(void *ctx, int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride), void *ctx)
|
||||
{
|
||||
spudec_handle_t *spu = (spudec_handle_t *)me;
|
||||
scale_pixel *table_x;
|
||||
@ -784,7 +784,7 @@ void spudec_draw_scaled(void *me, unsigned int dxs, unsigned int dys, void (*dra
|
||||
|| (spu->orig_frame_width == dxs && spu->orig_frame_height == dys))) {
|
||||
if (spu->image)
|
||||
{
|
||||
draw_alpha(spu->start_col, spu->start_row, spu->width, spu->height,
|
||||
draw_alpha(ctx, spu->start_col, spu->start_row, spu->width, spu->height,
|
||||
spu->image, spu->aimage, spu->stride);
|
||||
spu->spu_changed = 0;
|
||||
}
|
||||
@ -1085,7 +1085,7 @@ nothing_to_do:
|
||||
spu->scaled_start_row = dys*sub_pos/100 - spu->scaled_height;
|
||||
break;
|
||||
}
|
||||
draw_alpha(spu->scaled_start_col, spu->scaled_start_row, spu->scaled_width, spu->scaled_height,
|
||||
draw_alpha(ctx, spu->scaled_start_col, spu->scaled_start_row, spu->scaled_width, spu->scaled_height,
|
||||
spu->scaled_image, spu->scaled_aimage, spu->scaled_stride);
|
||||
spu->spu_changed = 0;
|
||||
}
|
||||
|
2
spudec.h
2
spudec.h
@ -6,7 +6,7 @@
|
||||
void spudec_heartbeat(void *this, unsigned int pts100);
|
||||
void spudec_assemble(void *this, unsigned char *packet, unsigned int len, int pts100);
|
||||
void spudec_draw(void *this, void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride));
|
||||
void spudec_draw_scaled(void *this, unsigned int dxs, unsigned int dys, void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride));
|
||||
void spudec_draw_scaled(void *this, unsigned int dxs, unsigned int dys, void (*draw_alpha)(void *ctx, int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride), void *ctx);
|
||||
void spudec_update_palette(void *this, unsigned int *palette);
|
||||
void *spudec_new_scaled(unsigned int *palette, unsigned int frame_width, unsigned int frame_height);
|
||||
void *spudec_new_scaled_vobsub(unsigned int *palette, unsigned int *cuspal, unsigned int custom, unsigned int frame_width, unsigned int frame_height);
|
||||
|
Loading…
Reference in New Issue
Block a user