示例#1
0
static int compare_modes_by_res(const void* mode1, const void* mode2)
{
    if (PgGetVideoModeInfo(*(unsigned short*)mode1, &mode_info) < 0)
    {
        return 0;
    }

    key1 = mode_info.width * mode_info.height;

    if (PgGetVideoModeInfo(*(unsigned short*)mode2, &mode_info) < 0)
    {
        return 0;
    }

    key2 = mode_info.width * mode_info.height;

    if (key1 > key2)
    {
        return 1;
    }
    else
    {
        if (key1 == key2)
        {
           return 0;
        }
        else
        {
            return -1;
        }
    }
}
示例#2
0
/* if requested bpp is not found the mode with closest bpp is returned */
int
get_mode_any_format(int width, int height, int bpp)
{
    int i, closest, delta, min_delta;

    if (PgGetVideoModeList(&mode_list) < 0) {
        return -1;
    }

    SDL_qsort(mode_list.modes, mode_list.num_modes, sizeof(unsigned short),
              compare_modes_by_res);

    for (i = 0; i < mode_list.num_modes; i++) {
        if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0) {
            return 0;
        }
        if ((mode_info.width == width) && (mode_info.height == height)) {
            break;
        }
    }

    if (i < mode_list.num_modes) {
        /* get closest bpp */
        closest = i++;
        if (mode_info.bits_per_pixel == bpp) {
            return mode_list.modes[closest];
        }

        min_delta = abs(mode_info.bits_per_pixel - bpp);

        while (1) {
            if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0) {
                return 0;
            }

            if ((mode_info.width != width)
                || (mode_info.height != height)) {
                break;
            } else {
                if (mode_info.bits_per_pixel == bpp) {
                    closest = i;
                    break;
                } else {
                    delta = abs(mode_info.bits_per_pixel - bpp);
                    if (delta < min_delta) {
                        closest = i;
                        min_delta = delta;
                    }
                    i++;
                }
            }
        }
        return mode_list.modes[closest];
    }

    return 0;
}
示例#3
0
static int
compare_modes_by_res(const void *mode1, const void *mode2)
{
    PgVideoModeInfo_t mode1_info;
    PgVideoModeInfo_t mode2_info;

    if (PgGetVideoModeInfo(*(unsigned short *) mode1, &mode1_info) < 0) {
        return 0;
    }

    if (PgGetVideoModeInfo(*(unsigned short *) mode2, &mode2_info) < 0) {
        return 0;
    }

    if (mode1_info.width == mode2_info.width) {
        return mode2_info.height - mode1_info.height;
    } else {
        return mode2_info.width - mode1_info.width;
    }
}
示例#4
0
/* if there is no mode then zero is returned             */
int ph_GetVideoMode(int width, int height, int bpp)
{
    int i;
    int modestage=0;
    int closestmode=0;

    if (PgGetVideoModeList(&mode_list) < 0)
    {
        return -1;
    }

    /* special case for the double-sized 320x200 mode */
    if ((width==640) && (height==400))
    {
       modestage=1;
    }

    /* search list for exact match */
    for (i=0; i<mode_list.num_modes; i++)
    {
        if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
        {
            return 0;
        }

        if ((mode_info.width == width) && (mode_info.height == height) && 
            (mode_info.bits_per_pixel == bpp))
        {
            return mode_list.modes[i];
        }
        else
        {
           if ((modestage) && (mode_info.width == width) && (mode_info.height == height+80) && 
               (mode_info.bits_per_pixel == bpp))
           {
              modestage=2;
              closestmode=mode_list.modes[i];
           }
        }
    }

    /* if we are here, then no 640x400xbpp mode found and we'll emulate it via 640x480xbpp mode */
    if (modestage==2)
    {
       return closestmode;
    }

    return (i == mode_list.num_modes) ? 0 : mode_list.modes[i];
}
示例#5
0
int ph_EnterFullScreen(_THIS, SDL_Surface* screen, int fmode)
{
    PgDisplaySettings_t settings;
    int mode;
    char* refreshrate;
    int refreshratenum;

    if (!currently_fullscreen)
    {
        /* Get the video mode and set it */
        if (screen->flags & SDL_ANYFORMAT)
        {
            if ((mode = get_mode_any_format(screen->w, screen->h, screen->format->BitsPerPixel)) == 0)
            {
                SDL_SetError("ph_EnterFullScreen(): can't find appropriate video mode !\n");
                return 0;
            }
        }
        else
        {
            if ((mode = ph_GetVideoMode(screen->w, screen->h, screen->format->BitsPerPixel)) == 0)
            {
                SDL_SetError("ph_EnterFullScreen(): can't find appropriate video mode !\n");
                return 0;
            }
            if (PgGetVideoModeInfo(mode, &mode_info) < 0)
            {
                SDL_SetError("ph_EnterFullScreen(): can't get video mode capabilities !\n");
                return 0;
            }
            if (mode_info.height != screen->h)
            {
               if ((mode_info.height==480) && (screen->h==400))
               {
                  videomode_emulatemode=1;
               }
            }
            else
            {
               videomode_emulatemode=0;
            }
        }

        /* save old video mode caps */
        PgGetVideoMode(&settings);
        old_video_mode=settings.mode;
        old_refresh_rate=settings.refresh;

        /* setup new video mode */
        settings.mode = mode;
        settings.refresh = 0;
        settings.flags = 0;

        refreshrate=SDL_getenv("SDL_PHOTON_FULLSCREEN_REFRESH");
        if (refreshrate!=NULL)
        {
           if (SDL_sscanf(refreshrate, "%d", &refreshratenum)==1)
           {
               settings.refresh = refreshratenum;
           }
        }

        if (PgSetVideoMode(&settings) < 0)
        {
            SDL_SetError("ph_EnterFullScreen(): PgSetVideoMode() call failed !\n");
            return 0;
        }

        if (this->screen)
        {
            if ((this->screen->flags & SDL_OPENGL)==SDL_OPENGL)
            {
#if !SDL_VIDEO_OPENGL || (_NTO_VERSION < 630)
                return 0; /* 6.3.0 */
#endif
            }
        }

        if (fmode==0)
        {
            if (OCImage.direct_context==NULL)
            {
                OCImage.direct_context=(PdDirectContext_t*)PdCreateDirectContext();
                if (!OCImage.direct_context)
                {
                    SDL_SetError("ph_EnterFullScreen(): Can't create direct context !\n");
                    ph_LeaveFullScreen(this);
                    return 0;
                }
            }
            OCImage.oldDC=PdDirectStart(OCImage.direct_context);
        }

        currently_fullscreen = 1;
    }
    PgFlush();

    return 1;
}
static int ph_VideoInit(_THIS, SDL_PixelFormat *vformat)
{
    PgHWCaps_t my_hwcaps;
    int i;

    window=NULL;
    desktoppal=SDLPH_PAL_NONE;

#ifdef HAVE_OPENGL
    oglctx=NULL;
    oglflags=0;
    oglbpp=0;
#endif /* HAVE_OPENGL */
    
    old_video_mode=-1;
    old_refresh_rate=-1;
	
    if (NULL == (event = malloc(EVENT_SIZE)))
    {
        SDL_OutOfMemory();
        return -1;
    }
    memset(event, 0x00, EVENT_SIZE);

    window = ph_CreateWindow(this);
    if (window == NULL)
    {
        SDL_SetError("ph_VideoInit(): Couldn't create video window !\n");
        return -1;
    }

    /* Create the blank cursor */
    SDL_BlankCursor = this->CreateWMCursor(this, blank_cdata, blank_cmask,
                                          (int)BLANK_CWIDTH, (int)BLANK_CHEIGHT,
                                          (int)BLANK_CHOTX, (int)BLANK_CHOTY);

    if (SDL_BlankCursor == NULL)
    {
        return -1;
    }

    if (PgGetGraphicsHWCaps(&my_hwcaps) < 0)
    {
        SDL_SetError("ph_VideoInit(): GetGraphicsHWCaps function failed !\n");
        this->FreeWMCursor(this, SDL_BlankCursor);
        return -1;
    }

    if (PgGetVideoModeInfo(my_hwcaps.current_video_mode, &desktop_mode) < 0)
    {
        SDL_SetError("ph_VideoInit(): PgGetVideoModeInfo function failed !\n");
        this->FreeWMCursor(this, SDL_BlankCursor);
        return -1;
    }

    /* We need to return BytesPerPixel as it in used by CreateRGBsurface */
    vformat->BitsPerPixel = desktop_mode.bits_per_pixel;
    vformat->BytesPerPixel = desktop_mode.bytes_per_scanline/desktop_mode.width;
    desktopbpp = desktop_mode.bits_per_pixel;
    
    /* save current palette */
    if (desktopbpp==8)
    {
        PgGetPalette(savedpal);
        PgGetPalette(syspalph);
    }
    else
    {
        for(i=0; i<_Pg_MAX_PALETTE; i++)
        {
            savedpal[i]=PgRGB(0, 0, 0);
            syspalph[i]=PgRGB(0, 0, 0);
        }
    }
         
    currently_fullscreen = 0;
    currently_hided = 0;
    current_overlay = NULL;

    OCImage.direct_context = NULL;
    OCImage.offscreen_context = NULL;
    OCImage.offscreen_backcontext = NULL;
    OCImage.oldDC = NULL;
    OCImage.CurrentFrameData = NULL;
    OCImage.FrameData0 = NULL;
    OCImage.FrameData1 = NULL;

    
    this->info.wm_available = 1;
    
    return 0;
}
示例#7
0
文件: vout.c 项目: FLYKingdom/vlc
/*****************************************************************************
 * QNXInitDisplay: check screen resolution, depth, amount of video ram, etc
 *****************************************************************************/
static int QNXInitDisplay( vout_thread_t * p_vout )
{
    PgHWCaps_t hwcaps;
    PgDisplaySettings_t cfg;
    PgVideoModeInfo_t minfo;

    /* get graphics card hw capabilities */
    if( PgGetGraphicsHWCaps( &hwcaps ) != 0 )
    {
        msg_Err( p_vout, "unable to get gfx card capabilities" );
        return( 1 );
    }

    /* get current video mode */
    if( PgGetVideoMode( &cfg ) != 0 )
    {
        msg_Err( p_vout, "unable to get current video mode" );
        return( 1 );
    }

    /* get video mode info */
    if( PgGetVideoModeInfo( cfg.mode, &minfo ) != 0 )
    {
        msg_Err( p_vout, "unable to get info for video mode" );
        return( 1 );
    }

    if( p_vout->p_sys->i_mode == MODE_VIDEO_OVERLAY )
    {
        int i = 0;
        PgScalerCaps_t vcaps;

        if( ( p_vout->p_sys->p_channel =
            PgCreateVideoChannel( Pg_VIDEO_CHANNEL_SCALER, 0 ) ) == NULL )
        {
            msg_Err( p_vout, "unable to create video channel" );
            printf("errno = %d\n", errno);
            p_vout->p_sys->i_mode = MODE_NORMAL_MEM;
        }
        else
        {
            vcaps.size = sizeof( vcaps );
            while( PgGetScalerCapabilities( p_vout->p_sys->p_channel,
                                            i++, &vcaps ) == 0 )
            {
                printf("vcaps.format = 0x%x\n", vcaps.format);
                if( vcaps.format == Pg_VIDEO_FORMAT_YV12 ||
                    vcaps.format == Pg_VIDEO_FORMAT_YUV420 ||
                    vcaps.format == Pg_VIDEO_FORMAT_YUY2 ||
                    vcaps.format == Pg_VIDEO_FORMAT_UYVY ||
                    vcaps.format == Pg_VIDEO_FORMAT_RGB555 ||
                    vcaps.format == Pg_VIDEO_FORMAT_RGB565 ||
                    vcaps.format == Pg_VIDEO_FORMAT_RGB8888 )
                {
                    p_vout->p_sys->i_vc_flags  = vcaps.flags;
                    p_vout->p_sys->i_vc_format = vcaps.format;
                }

                vcaps.size = sizeof( vcaps );
            }

            if( p_vout->p_sys->i_vc_format == 0 )
            {
                msg_Warn( p_vout, "need YV12, YUY2 or RGB8888 overlay" );

                p_vout->p_sys->i_mode = MODE_NORMAL_MEM;
            }
        }
    }

    /* use video ram if we have enough available */
    if( p_vout->p_sys->i_mode == MODE_NORMAL_MEM &&
        (minfo.bits_per_pixel != 8) &&
        hwcaps.currently_available_video_ram >=
        ( ( minfo.width * minfo.height * minfo.bits_per_pixel * MAX_DIRECTBUFFERS) / 8 ) )
    {
        p_vout->p_sys->i_mode = MODE_VIDEO_MEM;
        printf("Using video memory...\n");
    }

    p_vout->p_sys->i_img_type = minfo.type;
    p_vout->p_sys->screen_dim.w = minfo.width;
    p_vout->p_sys->screen_dim.h = minfo.height;
    p_vout->p_sys->i_screen_depth = minfo.bits_per_pixel;

    switch( p_vout->p_sys->i_screen_depth )
    {
        case 8:
            p_vout->output.i_chroma = VLC_CODEC_RGB8;
            p_vout->p_sys->i_bytes_per_pixel = 1;
            p_vout->output.pf_setpalette = SetPalette;
            break;

        case 15:
            p_vout->output.i_chroma = VLC_CODEC_RGB15;
            p_vout->p_sys->i_bytes_per_pixel = 2;
            p_vout->output.i_rmask = 0x7c00;
            p_vout->output.i_gmask = 0x03e0;
            p_vout->output.i_bmask = 0x001f;
            break;

        case 16:
            p_vout->output.i_chroma = VLC_CODEC_RGB16;
            p_vout->p_sys->i_bytes_per_pixel = 2;
            p_vout->output.i_rmask = 0xf800;
            p_vout->output.i_gmask = 0x07e0;
            p_vout->output.i_bmask = 0x001f;
            break;

        case 24:
            p_vout->output.i_chroma = VLC_CODEC_RGB24;
            p_vout->p_sys->i_bytes_per_pixel = 3;
            p_vout->output.i_rmask = 0xff0000;
            p_vout->output.i_gmask = 0x00ff00;
            p_vout->output.i_bmask = 0x0000ff;
            break;

        case 32:
        default:
            p_vout->output.i_chroma = VLC_CODEC_RGB32;
            p_vout->p_sys->i_bytes_per_pixel = 4;
            p_vout->output.i_rmask = 0xff0000;
            p_vout->output.i_gmask = 0x00ff00;
            p_vout->output.i_bmask = 0x0000ff;
            break;
    }

    return( 0 );
}