Changeset 6d9536c7663f926889b44a6deb125152acfb3508

Show
Ignore:
Timestamp:
04/09/08 18:00:29 (3 months ago)
Author:
Antoine Cellerier <dionoea@videolan.org>
git-committer:
Antoine Cellerier <dionoea@videolan.org> 1220544029 +0200
git-parent:

[52c11814434e412fed940ffa9b4f1d9f2db56d47]

git-author:
Antoine Cellerier <dionoea@videolan.org> 1220544009 +0200
Message:

Add mouse cursor drawing support in x11 screen.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • NEWS

    r355d80f r6d9536c  
    11Changes between 0.9.1 and 1.0.0-git: 
    22------------------------------------ 
     3 
     4Inputs: 
     5 * Mouse cursor support in x11 screen module 
    36 
    47Decoders: 
  • modules/access/screen/screen.c

    r62ec225 r6d9536c  
    7474#endif 
    7575 
     76#ifdef SCREEN_MOUSE 
     77#define MOUSE_TEXT N_( "Mouse pointer image" ) 
     78#define MOUSE_LONGTEXT N_( \ 
     79    "If specifed, will use the image to draw the mouse pointer on the " \ 
     80    "capture." ) 
     81#endif 
     82 
    7683static int  Open ( vlc_object_t * ); 
    7784static void Close( vlc_object_t * ); 
     
    100107    add_bool( "screen-follow-mouse", false, NULL, FOLLOW_MOUSE_TEXT, 
    101108              FOLLOW_MOUSE_LONGTEXT, true ); 
     109#endif 
     110 
     111#ifdef SCREEN_MOUSE 
     112    add_string( "screen-mouse-image", "", NULL, MOUSE_TEXT, MOUSE_LONGTEXT, 
     113                true ); 
    102114#endif 
    103115 
     
    190202#endif 
    191203 
     204#ifdef SCREEN_MOUSE 
     205    char * psz_mouse = var_CreateGetNonEmptyString( p_demux, 
     206                                                    "screen-mouse-image" ); 
     207    if( psz_mouse ) 
     208    { 
     209        image_handler_t *p_image; 
     210        video_format_t fmt_in, fmt_out; 
     211        msg_Dbg( p_demux, "Using %s for the mouse pointer image", psz_mouse ); 
     212        memset( &fmt_in, 0, sizeof( fmt_in ) ); 
     213        memset( &fmt_out, 0, sizeof( fmt_out ) ); 
     214        fmt_out.i_chroma = VLC_FOURCC('R','G','B','A'); 
     215        p_image = image_HandlerCreate( p_demux ); 
     216        if( p_image ) 
     217        { 
     218            p_sys->p_mouse = 
     219                image_ReadUrl( p_image, psz_mouse, &fmt_in, &fmt_out ); 
     220            image_HandlerDelete( p_image ); 
     221        } 
     222        if( !p_sys->p_mouse ) 
     223            msg_Err( p_demux, "Failed to open mouse pointer image (%s)", 
     224                     psz_mouse ); 
     225    } 
     226#endif 
     227 
    192228    p_sys->es = es_out_Add( p_demux->out, &p_sys->fmt ); 
    193229 
     
    204240 
    205241    screen_CloseCapture( p_demux ); 
     242#ifdef SCREEN_MOUSE 
     243    if( p_sys->p_mouse ) 
     244        picture_Release( p_sys->p_mouse ); 
     245#endif 
    206246    free( p_sys ); 
    207247} 
  • modules/access/screen/screen.h

    r96973d2 r6d9536c  
    2828#if !defined( HAVE_WIN32 ) && !defined( HAVE_BEOS ) && !defined( HAVE_DARWIN ) 
    2929#   define SCREEN_SUBSCREEN 
     30#   define SCREEN_MOUSE 
     31#endif 
     32 
     33#ifdef SCREEN_MOUSE 
     34#   include <vlc_image.h> 
    3035#endif 
    3136 
     
    5257#endif 
    5358 
     59#ifdef SCREEN_MOUSE 
     60    picture_t *p_mouse; 
     61    filter_t *p_blend; 
     62    picture_t src; 
     63    picture_t dst; 
     64#endif 
     65 
    5466    screen_data_t *p_data; 
    5567}; 
  • modules/access/screen/x11.c

    r3561b9b r6d9536c  
    8383 
    8484    es_format_Init( &p_sys->fmt, VIDEO_ES, i_chroma ); 
     85    p_sys->fmt.video.i_visible_width = 
    8586    p_sys->fmt.video.i_width  = win_info.width; 
     87    p_sys->fmt.video.i_visible_height = 
    8688    p_sys->fmt.video.i_height = win_info.height; 
    8789    p_sys->fmt.video.i_bits_per_pixel = win_info.depth; 
     90    p_sys->fmt.video.i_chroma = i_chroma; 
    8891 
    8992#if 0 
     
    103106 
    104107    XCloseDisplay( p_display ); 
     108    if( p_sys->p_blend ) 
     109    { 
     110        module_Unneed( p_sys->p_blend, p_sys->p_blend->p_module ); 
     111        vlc_object_detach( p_sys->p_blend ); 
     112        vlc_object_release( p_sys->p_blend ); 
     113    } 
    105114    return VLC_SUCCESS; 
    106115} 
     
    113122    XImage *image; 
    114123    int i_size; 
    115  
    116     if( p_sys->b_follow_mouse ) 
     124    int root_x = 0, root_y = 0; 
     125 
     126    if( p_sys->b_follow_mouse || p_sys->p_mouse ) 
    117127    { 
    118128        Window root = DefaultRootWindow( p_display ), child; 
    119         int root_x, root_y; 
    120129        int win_x, win_y; 
    121130        unsigned int mask; 
     
    124133            &mask ) ) 
    125134        { 
    126             root_x -= p_sys->i_width/2; 
    127             if( root_x < 0 ) root_x = 0; 
    128             p_sys->i_left = __MIN( (unsigned int)root_x, 
    129                                    p_sys->i_screen_width - p_sys->i_width ); 
    130             root_y -= p_sys->i_height/2; 
    131             if( root_y < 0 ) root_y = 0; 
    132             p_sys->i_top = __MIN( (unsigned int)root_y, 
    133                                   p_sys->i_screen_height - p_sys->i_height ); 
     135            if( p_sys->b_follow_mouse ) 
     136            { 
     137                root_x -= p_sys->i_width/2; 
     138                if( root_x < 0 ) root_x = 0; 
     139                p_sys->i_left = __MIN( (unsigned int)root_x, 
     140                                       p_sys->i_screen_width - p_sys->i_width ); 
     141                root_y -= p_sys->i_height/2; 
     142                if( root_y < 0 ) root_y = 0; 
     143                p_sys->i_top = __MIN( (unsigned int)root_y, 
     144                                      p_sys->i_screen_height - p_sys->i_height ); 
     145            } 
    134146        } 
    135147        else 
     
    157169    } 
    158170 
    159     vlc_memcpy( p_block->p_buffer, image->data, i_size ); 
     171    if( !p_sys->p_mouse ) 
     172        vlc_memcpy( p_block->p_buffer, image->data, i_size ); 
     173    else 
     174    { 
     175        if( !p_sys->src.i_planes ) 
     176            vout_InitPicture( p_demux, &p_sys->src, 
     177                              p_sys->fmt.video.i_chroma, 
     178                              p_sys->fmt.video.i_width, 
     179                              p_sys->fmt.video.i_height, 
     180                              p_sys->fmt.video.i_aspect ); 
     181        if( !p_sys->dst.i_planes ) 
     182            vout_InitPicture( p_demux, &p_sys->dst, 
     183                              p_sys->fmt.video.i_chroma, 
     184                              p_sys->fmt.video.i_width, 
     185                              p_sys->fmt.video.i_height, 
     186                              p_sys->fmt.video.i_aspect ); 
     187        if( !p_sys->p_blend ) 
     188        { 
     189            p_sys->p_blend = vlc_object_create( p_demux, sizeof(filter_t) ); 
     190            if( !p_sys->p_blend ) 
     191                msg_Err( p_demux, "Could not allocate memory for blending module" ); 
     192            else 
     193            { 
     194                es_format_Init( &p_sys->p_blend->fmt_in, VIDEO_ES, 
     195                                VLC_FOURCC('R','G','B','A') ); 
     196                p_sys->p_blend->fmt_in.video = p_sys->p_mouse->format; 
     197                p_sys->p_blend->fmt_out = p_sys->fmt; 
     198                p_sys->p_blend->p_module = 
     199                    module_Need( p_sys->p_blend, "video blending", 0, 0 ); 
     200                if( !p_sys->p_blend->p_module ) 
     201                { 
     202                    msg_Err( p_demux, "Could not load video blending module" ); 
     203                    vlc_object_detach( p_sys->p_blend ); 
     204                    vlc_object_release( p_sys->p_blend ); 
     205                    p_sys->p_blend = NULL; 
     206                } 
     207            } 
     208        } 
     209        if( p_sys->p_blend ) 
     210        { 
     211            /* FIXME: why is this memcpy needed?!? (bug in blend?) */ 
     212            vlc_memcpy( p_block->p_buffer, image->data, i_size ); 
     213            p_sys->dst.p->p_pixels = p_block->p_buffer; 
     214            p_sys->src.p->p_pixels = image->data; 
     215            p_sys->p_blend->pf_video_blend( p_sys->p_blend, 
     216                                            &p_sys->dst, 
     217                                            &p_sys->src, 
     218                                            p_sys->p_mouse, 
     219                                            root_x, 
     220                                            root_y, 
     221                                            255 ); 
     222        } 
     223        else 
     224        { 
     225            picture_Release( p_sys->p_mouse ); 
     226            p_sys->p_mouse = NULL; 
     227            vlc_memcpy( p_block->p_buffer, image->data, i_size ); 
     228        } 
     229    } 
    160230 
    161231    XDestroyImage( image );