mirror of
https://github.com/mpv-player/mpv
synced 2025-04-11 04:01:31 +00:00
Refactor smalltex/tinytex EOSD optimization in vo_gl
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28849 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
b6d7a2552c
commit
b33adcdd02
@ -76,6 +76,13 @@ static GLuint osdtex[MAX_OSD_PARTS];
|
|||||||
static GLuint osdatex[MAX_OSD_PARTS];
|
static GLuint osdatex[MAX_OSD_PARTS];
|
||||||
#endif
|
#endif
|
||||||
static GLuint *eosdtex;
|
static GLuint *eosdtex;
|
||||||
|
#define LARGE_EOSD_TEX_SIZE 512
|
||||||
|
#define TINYTEX_SIZE 16
|
||||||
|
#define TINYTEX_COLS (LARGE_EOSD_TEX_SIZE/TINYTEX_SIZE)
|
||||||
|
#define TINYTEX_MAX (TINYTEX_COLS*TINYTEX_COLS)
|
||||||
|
#define SMALLTEX_SIZE 32
|
||||||
|
#define SMALLTEX_COLS (LARGE_EOSD_TEX_SIZE/SMALLTEX_SIZE)
|
||||||
|
#define SMALLTEX_MAX (SMALLTEX_COLS*SMALLTEX_COLS)
|
||||||
static GLuint largeeosdtex[2];
|
static GLuint largeeosdtex[2];
|
||||||
//! Display lists that draw the OSD parts
|
//! Display lists that draw the OSD parts
|
||||||
static GLuint osdDispList[MAX_OSD_PARTS];
|
static GLuint osdDispList[MAX_OSD_PARTS];
|
||||||
@ -286,6 +293,24 @@ static void clearEOSD(void) {
|
|||||||
|
|
||||||
static void do_render_osd(int);
|
static void do_render_osd(int);
|
||||||
|
|
||||||
|
static inline int is_tinytex(ass_image_t *i, int tinytexcur) {
|
||||||
|
return i->w < TINYTEX_SIZE && i->h < TINYTEX_SIZE && tinytexcur < TINYTEX_MAX;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int is_smalltex(ass_image_t *i, int smalltexcur) {
|
||||||
|
return i->w < SMALLTEX_SIZE && i->h < SMALLTEX_SIZE && smalltexcur < SMALLTEX_MAX;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void tinytex_pos(int tinytexcur, int *x, int *y) {
|
||||||
|
*x = (tinytexcur % TINYTEX_COLS) * TINYTEX_SIZE;
|
||||||
|
*y = (tinytexcur / TINYTEX_COLS) * TINYTEX_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void smalltex_pos(int smalltexcur, int *x, int *y) {
|
||||||
|
*x = (smalltexcur % SMALLTEX_COLS) * SMALLTEX_SIZE;
|
||||||
|
*y = (smalltexcur / SMALLTEX_COLS) * SMALLTEX_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief construct display list from ass image list
|
* \brief construct display list from ass image list
|
||||||
* \param img image list to create OSD from.
|
* \param img image list to create OSD from.
|
||||||
@ -311,17 +336,17 @@ static void genEOSD(mp_eosd_images_t *imgs) {
|
|||||||
if (!largeeosdtex[0]) {
|
if (!largeeosdtex[0]) {
|
||||||
glGenTextures(2, largeeosdtex);
|
glGenTextures(2, largeeosdtex);
|
||||||
BindTexture(gl_target, largeeosdtex[0]);
|
BindTexture(gl_target, largeeosdtex[0]);
|
||||||
glCreateClearTex(gl_target, GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, scale_type, 512, 512, 0);
|
glCreateClearTex(gl_target, GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, scale_type, LARGE_EOSD_TEX_SIZE, LARGE_EOSD_TEX_SIZE, 0);
|
||||||
BindTexture(gl_target, largeeosdtex[1]);
|
BindTexture(gl_target, largeeosdtex[1]);
|
||||||
glCreateClearTex(gl_target, GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, scale_type, 512, 512, 0);
|
glCreateClearTex(gl_target, GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, scale_type, LARGE_EOSD_TEX_SIZE, LARGE_EOSD_TEX_SIZE, 0);
|
||||||
}
|
}
|
||||||
for (i = img; i; i = i->next)
|
for (i = img; i; i = i->next)
|
||||||
{
|
{
|
||||||
if (i->w <= 0 || i->h <= 0 || i->stride < i->w)
|
if (i->w <= 0 || i->h <= 0 || i->stride < i->w)
|
||||||
continue;
|
continue;
|
||||||
if (i->w < 16 && i->h < 16 && tinytexcur < 1024)
|
if (is_tinytex(i, tinytexcur))
|
||||||
tinytexcur++;
|
tinytexcur++;
|
||||||
else if (i->w < 32 && i->h < 32 && smalltexcur < 256)
|
else if (is_smalltex(i, smalltexcur))
|
||||||
smalltexcur++;
|
smalltexcur++;
|
||||||
else
|
else
|
||||||
eosdtexCnt++;
|
eosdtexCnt++;
|
||||||
@ -339,14 +364,12 @@ static void genEOSD(mp_eosd_images_t *imgs) {
|
|||||||
mp_msg(MSGT_VO, MSGL_V, "Invalid dimensions OSD for part!\n");
|
mp_msg(MSGT_VO, MSGL_V, "Invalid dimensions OSD for part!\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (i->w < 16 && i->h < 16 && tinytexcur < 1024) {
|
if (is_tinytex(i, tinytexcur)) {
|
||||||
x = (tinytexcur & 31) << 4;
|
tinytex_pos(tinytexcur, &x, &y);
|
||||||
y = (tinytexcur >> 5) << 4;
|
|
||||||
BindTexture(gl_target, largeeosdtex[0]);
|
BindTexture(gl_target, largeeosdtex[0]);
|
||||||
tinytexcur++;
|
tinytexcur++;
|
||||||
} else if (i->w < 32 && i->h < 32 && smalltexcur < 256) {
|
} else if (is_smalltex(i, smalltexcur)) {
|
||||||
x = (smalltexcur & 15) << 5;
|
smalltex_pos(smalltexcur, &x, &y);
|
||||||
y = (smalltexcur >> 4) << 5;
|
|
||||||
BindTexture(gl_target, largeeosdtex[1]);
|
BindTexture(gl_target, largeeosdtex[1]);
|
||||||
smalltexcur++;
|
smalltexcur++;
|
||||||
} else {
|
} else {
|
||||||
@ -366,16 +389,14 @@ skip_upload:
|
|||||||
if (i->w <= 0 || i->h <= 0 || i->stride < i->w)
|
if (i->w <= 0 || i->h <= 0 || i->stride < i->w)
|
||||||
continue;
|
continue;
|
||||||
glColor4ub(i->color >> 24, (i->color >> 16) & 0xff, (i->color >> 8) & 0xff, 255 - (i->color & 0xff));
|
glColor4ub(i->color >> 24, (i->color >> 16) & 0xff, (i->color >> 8) & 0xff, 255 - (i->color & 0xff));
|
||||||
if (i->w < 16 && i->h < 16 && tinytexcur < 1024) {
|
if (is_tinytex(i, tinytexcur)) {
|
||||||
x = (tinytexcur & 31) << 4;
|
tinytex_pos(tinytexcur, &x, &y);
|
||||||
y = (tinytexcur >> 5) << 4;
|
sx = sy = LARGE_EOSD_TEX_SIZE;
|
||||||
sx = sy = 512;
|
|
||||||
BindTexture(gl_target, largeeosdtex[0]);
|
BindTexture(gl_target, largeeosdtex[0]);
|
||||||
tinytexcur++;
|
tinytexcur++;
|
||||||
} else if (i->w < 32 && i->h < 32 && smalltexcur < 256) {
|
} else if (is_smalltex(i, smalltexcur)) {
|
||||||
x = (smalltexcur & 15) << 5;
|
smalltex_pos(smalltexcur, &x, &y);
|
||||||
y = (smalltexcur >> 4) << 5;
|
sx = sy = LARGE_EOSD_TEX_SIZE;
|
||||||
sx = sy = 512;
|
|
||||||
BindTexture(gl_target, largeeosdtex[1]);
|
BindTexture(gl_target, largeeosdtex[1]);
|
||||||
smalltexcur++;
|
smalltexcur++;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user