summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPetri Hintukainen <phintuka@users.sourceforge.net>2014-05-13 15:33:12 +0300
committerPetri Hintukainen <phintuka@users.sourceforge.net>2014-05-13 15:33:12 +0300
commit4998bbecfc734db37374a12ee8458a5fb33c9ef5 (patch)
tree57dd2426c4f6e3352555f4e6e64439d2c2d5385e /src
parent15f8b6aaa9c6fd0c93accb819023cbb7d65c555c (diff)
downloadxine-lib-4998bbecfc734db37374a12ee8458a5fb33c9ef5.tar.gz
xine-lib-4998bbecfc734db37374a12ee8458a5fb33c9ef5.tar.bz2
simplify opengl2_overlay_blend()
Diffstat (limited to 'src')
-rw-r--r--src/video_out/video_out_opengl2.c89
1 files changed, 27 insertions, 62 deletions
diff --git a/src/video_out/video_out_opengl2.c b/src/video_out/video_out_opengl2.c
index c0f0b064a..0fc66ef6e 100644
--- a/src/video_out/video_out_opengl2.c
+++ b/src/video_out/video_out_opengl2.c
@@ -519,44 +519,33 @@ static int opengl2_check_textures_size( opengl2_driver_t *this_gen, int w, int h
return 1;
}
-static int opengl2_process_ovl( opengl2_driver_t *this_gen, vo_overlay_t *overlay )
-{
- //fprintf(stderr, "opengl2_process_ovl\n");
- opengl2_overlay_t *ovl = &this_gen->overlays[this_gen->ovl_changed-1];
-
- if ( overlay->width<=0 || overlay->height<=0 )
- return 0;
- if ( (overlay->width*overlay->height)!=(ovl->ovl_w*ovl->ovl_h) )
- ovl->ovl_rgba = (uint8_t*)realloc( ovl->ovl_rgba, overlay->width*overlay->height*4 );
- ovl->ovl_w = overlay->width;
- ovl->ovl_h = overlay->height;
- ovl->ovl_x = overlay->x;
- ovl->ovl_y = overlay->y;
- ovl->unscaled = overlay->unscaled;
- ovl->extent_width = overlay->extent_width;
- ovl->extent_height = overlay->extent_height;
- if ( overlay->extent_width == -1 )
- ovl->vid_scale = 1;
- else
- ovl->vid_scale = 0;
- ovl->type = GL_BGRA;
+static void opengl2_overlay_begin (vo_driver_t *this_gen, vo_frame_t *frame_gen, int changed)
+{
+ //fprintf(stderr, "opengl2_overlay_begin\n");
+ opengl2_driver_t *this = (opengl2_driver_t *) this_gen;
- _x_overlay_to_argb32(overlay, (uint32_t*)ovl->ovl_rgba, overlay->width, "BGRA");
- return 1;
+ if ( changed )
+ this->ovl_changed = 1;
}
-static int opengl2_process_rgba_ovl( opengl2_driver_t *this_gen, vo_overlay_t *overlay )
+static void opengl2_overlay_blend (vo_driver_t *this_gen, vo_frame_t *frame_gen, vo_overlay_t *overlay)
{
- opengl2_overlay_t *ovl = &this_gen->overlays[this_gen->ovl_changed-1];
+ opengl2_driver_t *this = (opengl2_driver_t *) this_gen;
+
+ if ( !this->ovl_changed || this->ovl_changed>XINE_VORAW_MAX_OVL )
+ return;
if ( overlay->width<=0 || overlay->height<=0 )
- return 0;
+ return;
- if ( (overlay->width*overlay->height)!=(ovl->ovl_w*ovl->ovl_h) )
- ovl->ovl_rgba = (uint8_t*)realloc( ovl->ovl_rgba, overlay->width*overlay->height*4 );
+ opengl2_overlay_t *ovl = &this->overlays[this->ovl_changed-1];
+ if ( (overlay->width*overlay->height)!=(ovl->ovl_w*ovl->ovl_h) ) {
+ free(ovl->ovl_rgba);
+ ovl->ovl_rgba = (uint8_t*)malloc( overlay->width*overlay->height*sizeof(uint32_t) );
+ }
ovl->ovl_w = overlay->width;
ovl->ovl_h = overlay->height;
ovl->ovl_x = overlay->x;
@@ -570,46 +559,22 @@ static int opengl2_process_rgba_ovl( opengl2_driver_t *this_gen, vo_overlay_t *o
ovl->vid_scale = 0;
ovl->type = GL_BGRA;
- memcpy(ovl->ovl_rgba, overlay->argb_layer->buffer, overlay->width * overlay->height * 4);
-
- return 1;
-}
-
-
-static void opengl2_overlay_begin (vo_driver_t *this_gen, vo_frame_t *frame_gen, int changed)
-{
- //fprintf(stderr, "opengl2_overlay_begin\n");
- opengl2_driver_t *this = (opengl2_driver_t *) this_gen;
-
- if ( changed )
- this->ovl_changed = 1;
-}
-
-
-static void opengl2_overlay_blend (vo_driver_t *this_gen, vo_frame_t *frame_gen, vo_overlay_t *overlay)
-{
- opengl2_driver_t *this = (opengl2_driver_t *) this_gen;
-
- if ( !this->ovl_changed || this->ovl_changed>XINE_VORAW_MAX_OVL )
- return;
-
if (overlay->argb_layer && overlay->argb_layer->buffer) {
-
pthread_mutex_lock(&overlay->argb_layer->mutex); /* buffer can be changed or freed while unlocked */
+ memcpy(ovl->ovl_rgba, overlay->argb_layer->buffer, overlay->width * overlay->height * sizeof(uint32_t));
+ /* TODO: this could be done without this memcpy() ... */
+ pthread_mutex_unlock(&overlay->argb_layer->mutex);
- if (overlay->argb_layer->buffer) {
- if ( opengl2_process_rgba_ovl( this, overlay ) )
- ++this->ovl_changed;
+ ++this->ovl_changed;
+
+ } else if (overlay->rle) {
+ if (!overlay->rgb_clut || !overlay->hili_rgb_clut) {
+ _x_overlay_clut_yuv2rgb(overlay);
}
- pthread_mutex_unlock(&overlay->argb_layer->mutex);
- }
+ _x_overlay_to_argb32(overlay, (uint32_t*)ovl->ovl_rgba, overlay->width, "BGRA");
- else if (overlay->rle) {
- if (!overlay->rgb_clut || !overlay->hili_rgb_clut)
- _x_overlay_clut_yuv2rgb(overlay);
- if ( opengl2_process_ovl( this, overlay ) )
- ++this->ovl_changed;
+ ++this->ovl_changed;
}
}