src/video/winrt/SDL_winrtevents.cpp
changeset 8582 c3e9a2b93517
parent 8531 d481485a1b85
child 8609 d59f0f12bf07
     1.1 --- a/src/video/winrt/SDL_winrtevents.cpp	Tue Mar 04 19:49:11 2014 -0500
     1.2 +++ b/src/video/winrt/SDL_winrtevents.cpp	Sun Mar 09 11:06:11 2014 -0700
     1.3 @@ -22,15 +22,15 @@
     1.4  
     1.5  #if SDL_VIDEO_DRIVER_WINRT
     1.6  
     1.7 -/*
     1.8 - * Windows includes:
     1.9 - */
    1.10 -#include <Windows.h>
    1.11 -using namespace Windows::UI::Core;
    1.12 -using Windows::UI::Core::CoreCursor;
    1.13 -
    1.14 -/*
    1.15 - * SDL includes:
    1.16 +/*
    1.17 + * Windows includes:
    1.18 + */
    1.19 +#include <Windows.h>
    1.20 +using namespace Windows::UI::Core;
    1.21 +using Windows::UI::Core::CoreCursor;
    1.22 +
    1.23 +/*
    1.24 + * SDL includes:
    1.25   */
    1.26  #include "SDL_winrtevents_c.h"
    1.27  #include "../../core/winrt/SDL_winrtapp_common.h"
    1.28 @@ -63,89 +63,89 @@
    1.29  
    1.30  
    1.31  /* XAML Thread management */
    1.32 -
    1.33 -enum SDL_XAMLAppThreadState
    1.34 -{
    1.35 -    ThreadState_NotLaunched = 0,
    1.36 -    ThreadState_Running,
    1.37 -    ThreadState_Yielding
    1.38 +
    1.39 +enum SDL_XAMLAppThreadState
    1.40 +{
    1.41 +    ThreadState_NotLaunched = 0,
    1.42 +    ThreadState_Running,
    1.43 +    ThreadState_Yielding
    1.44  };
    1.45  
    1.46 -static SDL_XAMLAppThreadState _threadState = ThreadState_NotLaunched;
    1.47 -static SDL_Thread * _XAMLThread = nullptr;
    1.48 -static SDL_mutex * _mutex = nullptr;
    1.49 -static SDL_cond * _cond = nullptr;
    1.50 -
    1.51 -static void
    1.52 -WINRT_YieldXAMLThread()
    1.53 -{
    1.54 -    SDL_LockMutex(_mutex);
    1.55 -    SDL_assert(_threadState == ThreadState_Running);
    1.56 -    _threadState = ThreadState_Yielding;
    1.57 -    SDL_UnlockMutex(_mutex);
    1.58 -
    1.59 -    SDL_CondSignal(_cond);
    1.60 -
    1.61 -    SDL_LockMutex(_mutex);
    1.62 -    while (_threadState != ThreadState_Running) {
    1.63 -        SDL_CondWait(_cond, _mutex);
    1.64 -    }
    1.65 -    SDL_UnlockMutex(_mutex);
    1.66 -}
    1.67 -
    1.68 -static int
    1.69 -WINRT_XAMLThreadMain(void * userdata)
    1.70 -{
    1.71 -    // TODO, WinRT: pass the C-style main() a reasonably realistic
    1.72 -    // representation of command line arguments.
    1.73 -    int argc = 0;
    1.74 -    char **argv = NULL;
    1.75 -    return WINRT_SDLAppEntryPoint(argc, argv);
    1.76 -}
    1.77 -
    1.78 -void
    1.79 -WINRT_CycleXAMLThread()
    1.80 -{
    1.81 -    switch (_threadState) {
    1.82 -        case ThreadState_NotLaunched:
    1.83 -        {
    1.84 -            _cond = SDL_CreateCond();
    1.85 -
    1.86 -            _mutex = SDL_CreateMutex();
    1.87 -            _threadState = ThreadState_Running;
    1.88 -            _XAMLThread = SDL_CreateThread(WINRT_XAMLThreadMain, "SDL/XAML App Thread", nullptr);
    1.89 -
    1.90 -            SDL_LockMutex(_mutex);
    1.91 -            while (_threadState != ThreadState_Yielding) {
    1.92 -                SDL_CondWait(_cond, _mutex);
    1.93 -            }
    1.94 -            SDL_UnlockMutex(_mutex);
    1.95 -
    1.96 -            break;
    1.97 -        }
    1.98 -
    1.99 -        case ThreadState_Running:
   1.100 -        {
   1.101 -            SDL_assert(false);
   1.102 -            break;
   1.103 -        }
   1.104 -
   1.105 -        case ThreadState_Yielding:
   1.106 -        {
   1.107 -            SDL_LockMutex(_mutex);
   1.108 -            SDL_assert(_threadState == ThreadState_Yielding);
   1.109 -            _threadState = ThreadState_Running;
   1.110 -            SDL_UnlockMutex(_mutex);
   1.111 -
   1.112 -            SDL_CondSignal(_cond);
   1.113 -
   1.114 -            SDL_LockMutex(_mutex);
   1.115 -            while (_threadState != ThreadState_Yielding) {
   1.116 -                SDL_CondWait(_cond, _mutex);
   1.117 -            }
   1.118 -            SDL_UnlockMutex(_mutex);
   1.119 -        }
   1.120 -    }
   1.121 +static SDL_XAMLAppThreadState _threadState = ThreadState_NotLaunched;
   1.122 +static SDL_Thread * _XAMLThread = nullptr;
   1.123 +static SDL_mutex * _mutex = nullptr;
   1.124 +static SDL_cond * _cond = nullptr;
   1.125 +
   1.126 +static void
   1.127 +WINRT_YieldXAMLThread()
   1.128 +{
   1.129 +    SDL_LockMutex(_mutex);
   1.130 +    SDL_assert(_threadState == ThreadState_Running);
   1.131 +    _threadState = ThreadState_Yielding;
   1.132 +    SDL_UnlockMutex(_mutex);
   1.133 +
   1.134 +    SDL_CondSignal(_cond);
   1.135 +
   1.136 +    SDL_LockMutex(_mutex);
   1.137 +    while (_threadState != ThreadState_Running) {
   1.138 +        SDL_CondWait(_cond, _mutex);
   1.139 +    }
   1.140 +    SDL_UnlockMutex(_mutex);
   1.141 +}
   1.142 +
   1.143 +static int
   1.144 +WINRT_XAMLThreadMain(void * userdata)
   1.145 +{
   1.146 +    // TODO, WinRT: pass the C-style main() a reasonably realistic
   1.147 +    // representation of command line arguments.
   1.148 +    int argc = 0;
   1.149 +    char **argv = NULL;
   1.150 +    return WINRT_SDLAppEntryPoint(argc, argv);
   1.151 +}
   1.152 +
   1.153 +void
   1.154 +WINRT_CycleXAMLThread()
   1.155 +{
   1.156 +    switch (_threadState) {
   1.157 +        case ThreadState_NotLaunched:
   1.158 +        {
   1.159 +            _cond = SDL_CreateCond();
   1.160 +
   1.161 +            _mutex = SDL_CreateMutex();
   1.162 +            _threadState = ThreadState_Running;
   1.163 +            _XAMLThread = SDL_CreateThread(WINRT_XAMLThreadMain, "SDL/XAML App Thread", nullptr);
   1.164 +
   1.165 +            SDL_LockMutex(_mutex);
   1.166 +            while (_threadState != ThreadState_Yielding) {
   1.167 +                SDL_CondWait(_cond, _mutex);
   1.168 +            }
   1.169 +            SDL_UnlockMutex(_mutex);
   1.170 +
   1.171 +            break;
   1.172 +        }
   1.173 +
   1.174 +        case ThreadState_Running:
   1.175 +        {
   1.176 +            SDL_assert(false);
   1.177 +            break;
   1.178 +        }
   1.179 +
   1.180 +        case ThreadState_Yielding:
   1.181 +        {
   1.182 +            SDL_LockMutex(_mutex);
   1.183 +            SDL_assert(_threadState == ThreadState_Yielding);
   1.184 +            _threadState = ThreadState_Running;
   1.185 +            SDL_UnlockMutex(_mutex);
   1.186 +
   1.187 +            SDL_CondSignal(_cond);
   1.188 +
   1.189 +            SDL_LockMutex(_mutex);
   1.190 +            while (_threadState != ThreadState_Yielding) {
   1.191 +                SDL_CondWait(_cond, _mutex);
   1.192 +            }
   1.193 +            SDL_UnlockMutex(_mutex);
   1.194 +        }
   1.195 +    }
   1.196  }
   1.197  
   1.198  #endif /* SDL_VIDEO_DRIVER_WINRT */