changeset 31809:1c9d6499e37c

More readable OSD rendering code.
author reimar
date Sun, 01 Aug 2010 17:36:15 +0000
parents 7b6e0890b6a9
children 41241a72f4d8
files libvo/vo_gl.c
diffstat 1 files changed, 12 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/vo_gl.c	Sun Aug 01 13:58:35 2010 +0000
+++ b/libvo/vo_gl.c	Sun Aug 01 17:36:15 2010 +0000
@@ -751,11 +751,16 @@
   osdtexCnt++;
 }
 
+#define RENDER_OSD  1
+#define RENDER_EOSD 2
+
 /**
  * \param type bit 0: render OSD, bit 1: render EOSD
  */
 static void do_render_osd(int type) {
-  if (((type & 1) && osdtexCnt > 0) || ((type & 2) && eosdDispList)) {
+  int draw_osd  = (type & RENDER_OSD)  && osdtexCnt > 0;
+  int draw_eosd = (type & RENDER_EOSD) && eosdDispList;
+  if (draw_osd || draw_eosd) {
     // set special rendering parameters
     if (!scaled_osd) {
       mpglMatrixMode(GL_PROJECTION);
@@ -764,11 +769,11 @@
       mpglOrtho(0, vo_dwidth, vo_dheight, 0, -1, 1);
     }
     mpglEnable(GL_BLEND);
-    if ((type & 2) && eosdDispList) {
+    if (draw_eosd) {
       mpglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
       mpglCallList(eosdDispList);
     }
-    if ((type & 1) && osdtexCnt > 0) {
+    if (draw_osd) {
       mpglColor4ub((osd_color >> 16) & 0xff, (osd_color >> 8) & 0xff, osd_color & 0xff, 0xff - (osd_color >> 24));
       // draw OSD
 #ifndef FAST_OSD
@@ -797,7 +802,7 @@
     vo_draw_text_ext(osd_w, osd_h, ass_border_x, ass_border_y, ass_border_x, ass_border_y,
                      image_width, image_height, create_osd_texture);
   }
-  if (vo_doublebuffering) do_render_osd(1);
+  if (vo_doublebuffering) do_render_osd(RENDER_OSD);
 }
 
 static void do_render(void) {
@@ -840,14 +845,14 @@
       mpglClear(GL_COLOR_BUFFER_BIT);
   } else {
     do_render();
-    do_render_osd(3);
+    do_render_osd(RENDER_OSD | RENDER_EOSD);
     if (use_glFinish) mpglFinish();
     else mpglFlush();
   }
 }
 
 static void redraw(void) {
-  if (vo_doublebuffering) { do_render(); do_render_osd(3); }
+  if (vo_doublebuffering) { do_render(); do_render_osd(RENDER_OSD | RENDER_EOSD); }
   flip_page();
 }
 
@@ -1314,7 +1319,7 @@
     if (!data)
       return VO_FALSE;
     genEOSD(data);
-    if (vo_doublebuffering) do_render_osd(2);
+    if (vo_doublebuffering) do_render_osd(RENDER_EOSD);
     return VO_TRUE;
   case VOCTRL_GET_EOSD_RES:
     {