Updated SDL 1.3 to the latest hg-5868:33245988e8a2 , video resize is not supported yet

This commit is contained in:
pelya
2011-12-05 19:46:32 +02:00
parent 2fe92bdcf9
commit aae35bbf37
678 changed files with 35446 additions and 77654 deletions

View File

@@ -1,35 +1,30 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
Simple DirectMedia Layer
Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_config.h"
#ifdef SDL_TIMER_WINCE
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <mmsystem.h>
#include "../../core/windows/SDL_windows.h"
#include "SDL_thread.h"
#include "SDL_timer.h"
#include "../SDL_timer_c.h"
static Uint64 start_date;
static Uint64 start_ticks;
@@ -70,6 +65,14 @@ wce_rel_date(void)
return ((Sint32) (wce_date() - start_date));
}
/* Recard start-time of application for reference */
void
SDL_StartTicks(void)
{
start_date = wce_date();
start_ticks = wce_ticks();
}
/* Return time in ms relative to when SDL was started */
Uint32
SDL_GetTicks()
@@ -83,6 +86,18 @@ SDL_GetTicks()
return ((Uint32) wce_rel_ticks());
}
Uint64
SDL_GetPerformanceCounter(void)
{
return SDL_GetTicks();
}
Uint64
SDL_GetPerformanceFrequency(void)
{
return 1000;
}
/* Give up approx. givem milliseconds to the OS. */
void
SDL_Delay(Uint32 ms)
@@ -90,122 +105,6 @@ SDL_Delay(Uint32 ms)
Sleep(ms);
}
/* Recard start-time of application for reference */
void
SDL_StartTicks(void)
{
start_date = wce_date();
start_ticks = wce_ticks();
}
static UINT WIN_timer;
#if ( _WIN32_WCE <= 420 )
static HANDLE timersThread = 0;
static HANDLE timersQuitEvent = 0;
DWORD
TimersThreadProc(void *data)
{
while (WaitForSingleObject(timersQuitEvent, 10) == WAIT_TIMEOUT) {
SDL_ThreadedTimerCheck();
}
return 0;
}
int
SDL_SYS_TimerInit(void)
{
// create a thread to process a threaded timers
// SetTimer does not suit the needs because
// TimerCallbackProc will be called only when WM_TIMER occured
timersQuitEvent = CreateEvent(0, TRUE, FALSE, 0);
if (!timersQuitEvent) {
SDL_SetError("Cannot create event for timers thread");
return -1;
}
timersThread = CreateThread(NULL, 0, TimersThreadProc, 0, 0, 0);
if (!timersThread) {
SDL_SetError
("Cannot create timers thread, check amount of RAM available");
return -1;
}
SetThreadPriority(timersThread, THREAD_PRIORITY_HIGHEST);
return (SDL_SetTimerThreaded(1));
}
void
SDL_SYS_TimerQuit(void)
{
SetEvent(timersQuitEvent);
if (WaitForSingleObject(timersThread, 2000) == WAIT_TIMEOUT)
TerminateThread(timersThread, 0);
CloseHandle(timersThread);
CloseHandle(timersQuitEvent);
return;
}
#else
#pragma comment(lib, "mmtimer.lib")
/* Data to handle a single periodic alarm */
static UINT timerID = 0;
static void CALLBACK
HandleAlarm(UINT uID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2)
{
SDL_ThreadedTimerCheck();
}
int
SDL_SYS_TimerInit(void)
{
MMRESULT result;
/* Set timer resolution */
result = timeBeginPeriod(TIMER_RESOLUTION);
if (result != TIMERR_NOERROR) {
SDL_SetError("Warning: Can't set %d ms timer resolution",
TIMER_RESOLUTION);
}
/* Allow 10 ms of drift so we don't chew on CPU */
timerID =
timeSetEvent(TIMER_RESOLUTION, 1, HandleAlarm, 0, TIME_PERIODIC);
if (!timerID) {
SDL_SetError("timeSetEvent() failed");
return (-1);
}
return (SDL_SetTimerThreaded(1));
}
void
SDL_SYS_TimerQuit(void)
{
if (timerID) {
timeKillEvent(timerID);
}
timeEndPeriod(TIMER_RESOLUTION);
}
#endif
int
SDL_SYS_StartTimer(void)
{
SDL_SetError("Internal logic error: WinCE uses threaded timer");
return (-1);
}
void
SDL_SYS_StopTimer(void)
{
return;
}
#endif /* SDL_TIMER_WINCE */
/* vi: set ts=4 sw=4 expandtab: */