Exemplo n.º 1
0
void
SDL_Delay(Uint32 ms)
{
    Uint32 now, then, elapsed;
#if !SDL_THREADS_DISABLED
    int is_event_thread;
    if (riscos_using_threads) {
        is_event_thread = 0;
        if (SDL_EventThreadID()) {
            if (SDL_EventThreadID() == SDL_ThreadID())
                is_event_thread = 1;
        } else if (SDL_ThreadID() == riscos_main_thread)
            is_event_thread = 1;
    } else
        is_event_thread = 1;
#endif

    /*TODO: Next version of Unixlib may allow us to use usleep here */
    /*      for non event threads */

    /* Set the timeout interval - Linux only needs to do this once */
    then = SDL_GetTicks();

    do {
        /* Do background tasks required while sleeping as we are not multithreaded */
#if SDL_THREADS_DISABLED
        RISCOS_BackgroundTasks();
#else
        /* For threaded build only run background tasks in event thread */
        if (is_event_thread)
            RISCOS_BackgroundTasks();
#endif

        /* Calculate the time interval left (in case of interrupt) */
        now = SDL_GetTicks();
        elapsed = (now - then);
        then = now;
        if (elapsed >= ms) {
            break;
        }
        ms -= elapsed;
#if !SDL_THREADS_DISABLED
        /* Need to yield to let other threads have a go */
        if (riscos_using_threads)
            pthread_yield();
#endif

    } while (1);
}
Exemplo n.º 2
0
static int NX_ToggleFullScreen (_THIS, int on)
{
    SDL_Rect rect ;
    Uint32   event_thread ;
    
    Dprintf ("enter NX_ToggleFullScreen\n") ;

    // Don't switch if we don't own the window
    if (SDL_windowid) return 0 ;
    
    // Don't lock if we are the event thread
    event_thread = SDL_EventThreadID () ;
    if (event_thread && (SDL_ThreadID () == event_thread)) {
        event_thread = 0 ;
    }
    if (event_thread) {
        SDL_Lock_EventThread() ;
    }
    
    if (on) {
        NX_EnterFullScreen (this) ;
    } else {
        this -> screen -> flags &= ~ SDL_FULLSCREEN ;
        NX_LeaveFullScreen (this) ;
    }

    rect.x = rect.y = 0 ;
    rect.w = this -> screen -> w, rect.h = this -> screen -> h ;
    NX_NormalUpdate (this, 1, & rect) ;

    if (event_thread) {
        SDL_Unlock_EventThread () ;
    }
    
    Dprintf ("leave NX_ToggleFullScreen\n") ;
    return 1 ;
}