OSD variant for vo_gl.c that behaves more like the one of other vos.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@13661 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
reimar 2004-10-17 19:32:47 +00:00
parent 79d2eb0fb9
commit 69a5c44698
2 changed files with 30 additions and 7 deletions

View File

@ -2539,6 +2539,12 @@ Number of lines copied to texture in one piece (default: 4).
.IPs (no)osd .IPs (no)osd
Enable or disable support for OSD rendering via OpenGL (default: enabled). Enable or disable support for OSD rendering via OpenGL (default: enabled).
Mostly for testing, you should use \-osdlevel 0 to disable OSD. Mostly for testing, you should use \-osdlevel 0 to disable OSD.
.IPs (no)scaled-osd
Changes the way the OSD behaves when the size of the
window changes (default: disabled).
When enabled behaves more like the other vos, better for fixed-size fonts.
Disabled looks much better with freetype fonts and uses the
borders in fullscreen mode.
.IPs (no)aspect .IPs (no)aspect
Enable or disable aspect scaling and pan and scan support (default: enabled). Enable or disable aspect scaling and pan and scan support (default: enabled).
Disabling might increase speed. Disabling might increase speed.

View File

@ -44,6 +44,7 @@ static int wsGLXAttrib[] = { GLX_RGBA,
None }; None };
static int use_osd; static int use_osd;
static int scaled_osd;
#define MAX_OSD_PARTS 20 #define MAX_OSD_PARTS 20
static GLuint osdtex[MAX_OSD_PARTS]; static GLuint osdtex[MAX_OSD_PARTS];
#ifndef FAST_OSD #ifndef FAST_OSD
@ -90,11 +91,13 @@ static void resize(int x,int y){
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); glLoadIdentity();
if (!scaled_osd) {
#ifdef HAVE_FREETYPE #ifdef HAVE_FREETYPE
// adjust font size to display size // adjust font size to display size
force_load_font = 1; force_load_font = 1;
#endif #endif
vo_osd_changed(1); vo_osd_changed(OSDTYPE_OSD);
}
} }
static int find_gl_format (uint32_t format) static int find_gl_format (uint32_t format)
@ -325,6 +328,7 @@ static void create_osd_texture(int x0, int y0, int w, int h,
// initialize to 8 to avoid special-casing on alignment // initialize to 8 to avoid special-casing on alignment
int sx = 8, sy = 8; int sx = 8, sy = 8;
GLfloat xcov, ycov; GLfloat xcov, ycov;
GLint scale_type = (scaled_osd) ? GL_LINEAR : GL_NEAREST;
char *clearTexture; char *clearTexture;
while (sx < w) sx *= 2; while (sx < w) sx *= 2;
while (sy < h) sy *= 2; while (sy < h) sy *= 2;
@ -345,8 +349,8 @@ static void create_osd_texture(int x0, int y0, int w, int h,
glBindTexture(GL_TEXTURE_2D, osdtex[osdtexCnt]); glBindTexture(GL_TEXTURE_2D, osdtex[osdtexCnt]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, sx, sy, 0, glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, sx, sy, 0,
GL_LUMINANCE, GL_UNSIGNED_BYTE, clearTexture); GL_LUMINANCE, GL_UNSIGNED_BYTE, clearTexture);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, scale_type);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, scale_type);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_LUMINANCE, glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_LUMINANCE,
GL_UNSIGNED_BYTE, src); GL_UNSIGNED_BYTE, src);
@ -355,8 +359,8 @@ static void create_osd_texture(int x0, int y0, int w, int h,
glBindTexture(GL_TEXTURE_2D, osdatex[osdtexCnt]); glBindTexture(GL_TEXTURE_2D, osdatex[osdtexCnt]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, sx, sy, 0, glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, sx, sy, 0,
GL_LUMINANCE, GL_UNSIGNED_BYTE, clearTexture); GL_LUMINANCE, GL_UNSIGNED_BYTE, clearTexture);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, scale_type);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, scale_type);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_ALPHA, glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_ALPHA,
GL_UNSIGNED_BYTE, srca); GL_UNSIGNED_BYTE, srca);
#endif #endif
@ -405,6 +409,7 @@ static void create_osd_texture(int x0, int y0, int w, int h,
static void draw_osd(void) static void draw_osd(void)
{ {
int i; int i;
int osd_h, osd_w;
if (!use_osd) return; if (!use_osd) return;
if (vo_osd_changed(0)) { if (vo_osd_changed(0)) {
for (i = 0; i < osdtexCnt; i++) { for (i = 0; i < osdtexCnt; i++) {
@ -415,8 +420,10 @@ static void draw_osd(void)
glDeleteLists(osdDispList[i], 1); glDeleteLists(osdDispList[i], 1);
} }
osdtexCnt = 0; osdtexCnt = 0;
// draw OSD with full resolution
vo_draw_text(vo_dwidth, vo_dheight, create_osd_texture); osd_w = (scaled_osd) ? image_width : vo_dwidth;
osd_h = (scaled_osd) ? image_height : vo_dheight;
vo_draw_text(osd_w, osd_h, create_osd_texture);
} }
} }
@ -437,15 +444,18 @@ flip_page(void)
if (osdtexCnt > 0) { if (osdtexCnt > 0) {
// set special rendering parameters // set special rendering parameters
if (!scaled_osd) {
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glPushMatrix(); glPushMatrix();
glLoadIdentity(); glLoadIdentity();
glOrtho(0, vo_dwidth, vo_dheight, 0, -1, 1); glOrtho(0, vo_dwidth, vo_dheight, 0, -1, 1);
}
glEnable(GL_BLEND); glEnable(GL_BLEND);
// draw OSD // draw OSD
glCallLists(osdtexCnt, GL_UNSIGNED_INT, osdDispList); glCallLists(osdtexCnt, GL_UNSIGNED_INT, osdDispList);
// set rendering parameters back to defaults // set rendering parameters back to defaults
glDisable (GL_BLEND); glDisable (GL_BLEND);
if (!scaled_osd)
glPopMatrix(); glPopMatrix();
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);
} }
@ -518,6 +528,7 @@ static uint32_t preinit(const char *arg)
unsigned int parse_pos = 0; unsigned int parse_pos = 0;
many_fmts = 0; many_fmts = 0;
use_osd = 1; use_osd = 1;
scaled_osd = 0;
use_aspect = 1; use_aspect = 1;
slice_height = 4; slice_height = 4;
if(arg) if(arg)
@ -535,6 +546,12 @@ static uint32_t preinit(const char *arg)
} else if (strncmp (&arg[parse_pos], "noosd", 5) == 0) { } else if (strncmp (&arg[parse_pos], "noosd", 5) == 0) {
parse_pos += 5; parse_pos += 5;
use_osd = 0; use_osd = 0;
} else if (strncmp (&arg[parse_pos], "scaled-osd", 10) == 0) {
parse_pos += 10;
scaled_osd = 1;
} else if (strncmp (&arg[parse_pos], "noscaled-osd", 12) == 0) {
parse_pos += 12;
scaled_osd = 0;
} else if (strncmp (&arg[parse_pos], "aspect", 6) == 0) { } else if (strncmp (&arg[parse_pos], "aspect", 6) == 0) {
parse_pos += 6; parse_pos += 6;
use_aspect = 1; use_aspect = 1;