summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUoti Urpala <uau@symbol.nonexistent.invalid>2008-04-04 06:36:36 +0300
committerUoti Urpala <uau@symbol.nonexistent.invalid>2008-04-23 13:41:04 +0300
commit8716df2a41f6ff05f59577a0433401ea141226f3 (patch)
tree491d1c9e1cf862294283335ade557100c2181baf
parent2bcfe1e077fe043751d3f7c73c82be761629419f (diff)
downloadmpv-8716df2a41f6ff05f59577a0433401ea141226f3.tar.bz2
mpv-8716df2a41f6ff05f59577a0433401ea141226f3.tar.xz
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.
-rw-r--r--libmpcodecs/vf_expand.c4
-rw-r--r--libvo/old_vo_wrapper.c16
-rw-r--r--libvo/old_vo_wrapper.h2
-rw-r--r--libvo/sub.c17
-rw-r--r--libvo/sub.h2
-rw-r--r--libvo/vo_directx.c1
-rw-r--r--libvo/vo_macosx.m1
-rw-r--r--libvo/vo_quartz.c2
-rw-r--r--spudec.c6
-rw-r--r--spudec.h2
10 files changed, 35 insertions, 18 deletions
diff --git a/libmpcodecs/vf_expand.c b/libmpcodecs/vf_expand.c
index 44a5549e19..8c4f1445a7 100644
--- a/libmpcodecs/vf_expand.c
+++ b/libmpcodecs/vf_expand.c
@@ -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)
diff --git a/libvo/old_vo_wrapper.c b/libvo/old_vo_wrapper.c
index b52622321a..d4af6fcc10 100644
--- a/libvo/old_vo_wrapper.c
+++ b/libvo/old_vo_wrapper.c
@@ -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);
+}
+
diff --git a/libvo/old_vo_wrapper.h b/libvo/old_vo_wrapper.h
index e6d20ce5ca..8c89790b85 100644
--- a/libvo/old_vo_wrapper.h
+++ b/libvo/old_vo_wrapper.h
@@ -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
diff --git a/libvo/sub.c b/libvo/sub.c
index aeb68d216b..3330baa718 100644
--- a/libvo/sub.c
+++ b/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;
diff --git a/libvo/sub.h b/libvo/sub.h
index f15b4e6c8d..d978935bf2 100644
--- a/libvo/sub.h
+++ b/libvo/sub.h
@@ -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);
diff --git a/libvo/vo_directx.c b/libvo/vo_directx.c
index a241631bea..5d3bd355e3 100644
--- a/libvo/vo_directx.c
+++ b/libvo/vo_directx.c
@@ -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;
/*****************************************************************************
diff --git a/libvo/vo_macosx.m b/libvo/vo_macosx.m
index 04d395ae56..5039fa3283 100644
--- a/libvo/vo_macosx.m
+++ b/libvo/vo_macosx.m
@@ -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)
{
diff --git a/libvo/vo_quartz.c b/libvo/vo_quartz.c
index 40e704905b..ddaedd8b99 100644
--- a/libvo/vo_quartz.c
+++ b/libvo/vo_quartz.c
@@ -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);
diff --git a/spudec.c b/spudec.c
index 6e7899b13f..2904908e59 100644
--- a/spudec.c
+++ b/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;
}
diff --git a/spudec.h b/spudec.h
index f3cafbd514..10c9668f8e 100644
--- a/spudec.h
+++ b/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);