/***************************************************************************** * Render: render previously calculated output *****************************************************************************/ static void Render( vout_thread_t *p_vout, picture_t *p_pic ) { cucul_set_color( p_vout->p_sys->p_cv, CUCUL_COLOR_DEFAULT, CUCUL_COLOR_BLACK ); cucul_clear_canvas( p_vout->p_sys->p_cv ); cucul_dither_bitmap( p_vout->p_sys->p_cv, 0, 0, cucul_get_canvas_width( p_vout->p_sys->p_cv ) - 1, cucul_get_canvas_height( p_vout->p_sys->p_cv ) - 1, p_vout->p_sys->p_dither, p_pic->p->p_pixels ); }
/** * Compute the place in canvas unit. */ static void Place(vout_display_t *vd, vout_display_place_t *place) { vout_display_sys_t *sys = vd->sys; vout_display_PlacePicture(place, &vd->source, vd->cfg, false); const int canvas_width = cucul_get_canvas_width(sys->cv); const int canvas_height = cucul_get_canvas_height(sys->cv); const int display_width = caca_get_display_width(sys->dp); const int display_height = caca_get_display_height(sys->dp); if (display_width > 0 && display_height > 0) { place->x = place->x * canvas_width / display_width; place->y = place->y * canvas_height / display_height; place->width = (place->width * canvas_width + display_width/2) / display_width; place->height = (place->height * canvas_height + display_height/2) / display_height; } else { place->x = 0; place->y = 0; place->width = canvas_width; place->height = display_height; } }
/***************************************************************************** * Manage: handle libcaca events ***************************************************************************** * This function should be called regularly by video output thread. It manages * console events. It returns a non null value on error. *****************************************************************************/ static int Manage( vout_thread_t *p_vout ) { #ifdef CACA_API_VERSION_1 struct caca_event ev; #else int ev; #endif while( caca_get_event(p_vout->p_sys->p_dp, CACA_EVENT_ANY, &ev, 0) ) { playlist_t *p_playlist; vlc_value_t val; #ifdef CACA_API_VERSION_1 switch( ev.type ) #else switch( ev ) #endif { case CACA_EVENT_KEY_RELEASE: #ifdef CACA_API_VERSION_1 switch( ev.data.key.ch ) #else switch( ev & 0x00ffffff ) #endif { case 'q': val.i_int = KEY_MODIFIER_CTRL | 'q'; break; case ' ': val.i_int = KEY_SPACE; break; default: continue; } var_Set( p_vout->p_libvlc, "key-pressed", val ); break; case CACA_EVENT_RESIZE: /* Acknowledge the resize */ caca_refresh_display( p_vout->p_sys->p_dp ); break; #ifdef CACA_API_VERSION_1 case CACA_EVENT_MOUSE_MOTION: val.i_int = ev.data.mouse.x * p_vout->render.i_width / cucul_get_canvas_width( p_vout->p_sys->p_cv ); var_Set( p_vout, "mouse-x", val ); val.i_int = ev.data.mouse.y * p_vout->render.i_height / cucul_get_canvas_height( p_vout->p_sys->p_cv ); var_Set( p_vout, "mouse-y", val ); val.b_bool = VLC_TRUE; var_Set( p_vout, "mouse-moved", val ); break; case CACA_EVENT_MOUSE_RELEASE: val.b_bool = VLC_TRUE; var_Set( p_vout, "mouse-clicked", val ); break; case CACA_EVENT_QUIT: { p_playlist = vlc_object_find( p_vout, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist ) { playlist_Stop( p_playlist ); vlc_object_release( p_playlist ); } p_vout->p_libvlc->b_die = VLC_TRUE; break; } #endif default: break; } } return VLC_SUCCESS; }