📄 ggi.c
字号:
* a non null value if an error occurred. *****************************************************************************/static int Manage( vout_thread_t *p_vout ){ struct timeval tv = { 0, 1000 }; /* 1 millisecond */ gii_event_mask mask; gii_event event; vlc_value_t val; mask = emKeyboard | emPtrButtonPress | emPtrButtonRelease; ggiEventPoll( p_vout->p_sys->p_display, mask, &tv ); while( ggiEventsQueued( p_vout->p_sys->p_display, mask) ) { ggiEventRead( p_vout->p_sys->p_display, &event, mask); switch( event.any.type ) { case evKeyRelease: switch( event.key.sym ) { case 'q': case 'Q': case GIIUC_Escape: p_vout->p_vlc->b_die = 1; break; default: break; } break; case evPtrButtonRelease: switch( event.pbutton.button ) { case GII_PBUTTON_LEFT: val.b_bool = VLC_TRUE; var_Set( p_vout, "mouse-clicked", val ); break; case GII_PBUTTON_RIGHT: { intf_thread_t *p_intf; p_intf = vlc_object_find( p_vout, VLC_OBJECT_INTF, FIND_ANYWHERE ); if( p_intf ) { p_intf->b_menu_change = 1; vlc_object_release( p_intf ); } } break; } break; default: break; } } return( 0 );}/***************************************************************************** * Display: displays previously rendered output *****************************************************************************/static void Display( vout_thread_t *p_vout, picture_t *p_pic ){#define p_b p_vout->p_sys->pp_buffer p_pic->p->p_pixels = p_b[ p_vout->p_sys->i_index ]->write; /* Change display frame */ if( p_vout->p_sys->b_must_acquire ) { ggiResourceRelease( p_b[ p_vout->p_sys->i_index ]->resource ); } ggiSetDisplayFrame( p_vout->p_sys->p_display, p_b[ p_vout->p_sys->i_index ]->frame ); /* Swap buffers and change write frame */ p_vout->p_sys->i_index ^= 1; p_pic->p->p_pixels = p_b[ p_vout->p_sys->i_index ]->write; if( p_vout->p_sys->b_must_acquire ) { ggiResourceAcquire( p_b[ p_vout->p_sys->i_index ]->resource, GGI_ACTYPE_WRITE ); } ggiSetWriteFrame( p_vout->p_sys->p_display, p_b[ p_vout->p_sys->i_index ]->frame ); /* Flush the output so that it actually displays */ ggiFlush( p_vout->p_sys->p_display );#undef p_b}/* following functions are local *//***************************************************************************** * OpenDisplay: open and initialize GGI device ***************************************************************************** * Open and initialize display according to preferences specified in the vout * thread fields. *****************************************************************************/static int OpenDisplay( vout_thread_t *p_vout ){#define p_b p_vout->p_sys->pp_buffer ggi_color col_fg; /* foreground color */ ggi_color col_bg; /* background color */ int i_index; /* all purposes index */ char *psz_display; /* Initialize library */ if( ggiInit() ) { msg_Err( p_vout, "cannot initialize GGI library" ); return( 1 ); } /* Open display */ psz_display = config_GetPsz( p_vout, "ggi_display" ); p_vout->p_sys->p_display = ggiOpen( psz_display, NULL ); if( psz_display ) free( psz_display ); if( p_vout->p_sys->p_display == NULL ) { msg_Err( p_vout, "cannot open GGI default display" ); ggiExit(); return( 1 ); } /* Find most appropriate mode */ p_vout->p_sys->mode.frames = 2; /* 2 buffers */ p_vout->p_sys->mode.visible.x = config_GetInt( p_vout, "width" ); p_vout->p_sys->mode.visible.y = config_GetInt( p_vout, "height" ); p_vout->p_sys->mode.virt.x = GGI_AUTO; p_vout->p_sys->mode.virt.y = GGI_AUTO; p_vout->p_sys->mode.size.x = GGI_AUTO; p_vout->p_sys->mode.size.y = GGI_AUTO; p_vout->p_sys->mode.graphtype = GT_15BIT; /* minimum usable depth */ p_vout->p_sys->mode.dpp.x = GGI_AUTO; p_vout->p_sys->mode.dpp.y = GGI_AUTO; ggiCheckMode( p_vout->p_sys->p_display, &p_vout->p_sys->mode ); /* FIXME: Check that returned mode has some minimum properties */ /* Set mode */ if( ggiSetMode( p_vout->p_sys->p_display, &p_vout->p_sys->mode ) ) { msg_Err( p_vout, "cannot set GGI mode" ); ggiClose( p_vout->p_sys->p_display ); ggiExit(); return( 1 ); } /* Check buffers properties */ p_vout->p_sys->b_must_acquire = 0; for( i_index = 0; i_index < 2; i_index++ ) { /* Get buffer address */ p_vout->p_sys->pp_buffer[ i_index ] = (ggi_directbuffer *)ggiDBGetBuffer( p_vout->p_sys->p_display, i_index ); if( p_b[ i_index ] == NULL ) { msg_Err( p_vout, "double buffering is not possible" ); ggiClose( p_vout->p_sys->p_display ); ggiExit(); return( 1 ); } /* Check buffer properties */ if( ! ( p_b[ i_index ]->type & GGI_DB_SIMPLE_PLB ) || ( p_b[ i_index ]->page_size != 0 ) || ( p_b[ i_index ]->write == NULL ) || ( p_b[ i_index ]->noaccess != 0 ) || ( p_b[ i_index ]->align != 0 ) ) { msg_Err( p_vout, "incorrect video memory type" ); ggiClose( p_vout->p_sys->p_display ); ggiExit(); return( 1 ); } /* Check if buffer needs to be acquired before write */ if( ggiResourceMustAcquire( p_b[ i_index ]->resource ) ) { p_vout->p_sys->b_must_acquire = 1; } } /* Set graphic context colors */ col_fg.r = col_fg.g = col_fg.b = -1; col_bg.r = col_bg.g = col_bg.b = 0; if( ggiSetGCForeground(p_vout->p_sys->p_display, ggiMapColor(p_vout->p_sys->p_display,&col_fg)) || ggiSetGCBackground(p_vout->p_sys->p_display, ggiMapColor(p_vout->p_sys->p_display,&col_bg)) ) { msg_Err( p_vout, "cannot set colors" ); ggiClose( p_vout->p_sys->p_display ); ggiExit(); return( 1 ); } /* Set clipping for text */ if( ggiSetGCClipping( p_vout->p_sys->p_display, 0, 0, p_vout->p_sys->mode.visible.x, p_vout->p_sys->mode.visible.y ) ) { msg_Err( p_vout, "cannot set clipping" ); ggiClose( p_vout->p_sys->p_display ); ggiExit(); return( 1 ); } /* FIXME: set palette in 8bpp */ p_vout->p_sys->i_bits_per_pixel = p_b[ 0 ]->buffer.plb.pixelformat->depth; return( 0 );#undef p_b}/***************************************************************************** * CloseDisplay: close and reset GGI device ***************************************************************************** * This function returns all resources allocated by OpenDisplay and restore * the original state of the device. *****************************************************************************/static void CloseDisplay( vout_thread_t *p_vout ){ /* Restore original mode and close display */ ggiClose( p_vout->p_sys->p_display ); /* Exit library */ ggiExit();}/***************************************************************************** * SetPalette: sets an 8 bpp palette *****************************************************************************/static void SetPalette( vout_thread_t *p_vout, uint16_t *red, uint16_t *green, uint16_t *blue ){ ggi_color colors[256]; int i; /* Fill colors with color information */ for( i = 0; i < 256; i++ ) { colors[ i ].r = red[ i ]; colors[ i ].g = green[ i ]; colors[ i ].b = blue[ i ]; colors[ i ].a = 0; } /* Set palette */ if( ggiSetPalette( p_vout->p_sys->p_display, 0, 256, colors ) < 0 ) { msg_Err( p_vout, "failed to set palette" ); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -