You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@corinthia.apache.org by ja...@apache.org on 2015/03/23 17:18:51 UTC
[03/83] [abbrv] [partial] incubator-corinthia git commit: removed SDL2
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/d1484ae0/DocFormats/platform/3rdparty/SDL2-2.0.3/src/core/winrt/SDL_winrtapp_direct3d.cpp
----------------------------------------------------------------------
diff --git a/DocFormats/platform/3rdparty/SDL2-2.0.3/src/core/winrt/SDL_winrtapp_direct3d.cpp b/DocFormats/platform/3rdparty/SDL2-2.0.3/src/core/winrt/SDL_winrtapp_direct3d.cpp
deleted file mode 100644
index 2fd20a8..0000000
--- a/DocFormats/platform/3rdparty/SDL2-2.0.3/src/core/winrt/SDL_winrtapp_direct3d.cpp
+++ /dev/null
@@ -1,699 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2014 Sam Lantinga <sl...@libsdl.org>
-
- 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.
-
- 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:
-
- 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_internal.h"
-
-/* Standard C++11 includes */
-#include <functional>
-#include <string>
-#include <sstream>
-using namespace std;
-
-
-/* Windows includes */
-#include "ppltasks.h"
-using namespace concurrency;
-using namespace Windows::ApplicationModel;
-using namespace Windows::ApplicationModel::Core;
-using namespace Windows::ApplicationModel::Activation;
-using namespace Windows::Devices::Input;
-using namespace Windows::Graphics::Display;
-using namespace Windows::Foundation;
-using namespace Windows::System;
-using namespace Windows::UI::Core;
-using namespace Windows::UI::Input;
-
-#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
-using namespace Windows::Phone::UI::Input;
-#endif
-
-
-/* SDL includes */
-extern "C" {
-#include "../../SDL_internal.h"
-#include "SDL_assert.h"
-#include "SDL_events.h"
-#include "SDL_hints.h"
-#include "SDL_log.h"
-#include "SDL_main.h"
-#include "SDL_stdinc.h"
-#include "SDL_render.h"
-#include "../../video/SDL_sysvideo.h"
-//#include "../../SDL_hints_c.h"
-#include "../../events/SDL_events_c.h"
-#include "../../events/SDL_keyboard_c.h"
-#include "../../events/SDL_mouse_c.h"
-#include "../../events/SDL_windowevents_c.h"
-#include "../../render/SDL_sysrender.h"
-#include "../windows/SDL_windows.h"
-}
-
-#include "../../video/winrt/SDL_winrtevents_c.h"
-#include "../../video/winrt/SDL_winrtvideo_cpp.h"
-#include "SDL_winrtapp_common.h"
-#include "SDL_winrtapp_direct3d.h"
-
-
-// Compile-time debugging options:
-// To enable, uncomment; to disable, comment them out.
-//#define LOG_POINTER_EVENTS 1
-//#define LOG_WINDOW_EVENTS 1
-//#define LOG_ORIENTATION_EVENTS 1
-
-
-// HACK, DLudwig: record a reference to the global, WinRT 'app'/view.
-// SDL/WinRT will use this throughout its code.
-//
-// TODO, WinRT: consider replacing SDL_WinRTGlobalApp with something
-// non-global, such as something created inside
-// SDL_InitSubSystem(SDL_INIT_VIDEO), or something inside
-// SDL_CreateWindow().
-SDL_WinRTApp ^ SDL_WinRTGlobalApp = nullptr;
-
-ref class SDLApplicationSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource
-{
-public:
- virtual Windows::ApplicationModel::Core::IFrameworkView^ CreateView();
-};
-
-IFrameworkView^ SDLApplicationSource::CreateView()
-{
- // TODO, WinRT: see if this function (CreateView) can ever get called
- // more than once. For now, just prevent it from ever assigning
- // SDL_WinRTGlobalApp more than once.
- SDL_assert(!SDL_WinRTGlobalApp);
- SDL_WinRTApp ^ app = ref new SDL_WinRTApp();
- if (!SDL_WinRTGlobalApp)
- {
- SDL_WinRTGlobalApp = app;
- }
- return app;
-}
-
-int SDL_WinRTInitNonXAMLApp(int (*mainFunction)(int, char **))
-{
- WINRT_SDLAppEntryPoint = mainFunction;
- auto direct3DApplicationSource = ref new SDLApplicationSource();
- CoreApplication::Run(direct3DApplicationSource);
- return 0;
-}
-
-static void WINRT_SetDisplayOrientationsPreference(void *userdata, const char *name, const char *oldValue, const char *newValue)
-{
- SDL_assert(SDL_strcmp(name, SDL_HINT_ORIENTATIONS) == 0);
-
- // Start with no orientation flags, then add each in as they're parsed
- // from newValue.
- unsigned int orientationFlags = 0;
- if (newValue) {
- std::istringstream tokenizer(newValue);
- while (!tokenizer.eof()) {
- std::string orientationName;
- std::getline(tokenizer, orientationName, ' ');
- if (orientationName == "LandscapeLeft") {
- orientationFlags |= (unsigned int) DisplayOrientations::LandscapeFlipped;
- } else if (orientationName == "LandscapeRight") {
- orientationFlags |= (unsigned int) DisplayOrientations::Landscape;
- } else if (orientationName == "Portrait") {
- orientationFlags |= (unsigned int) DisplayOrientations::Portrait;
- } else if (orientationName == "PortraitUpsideDown") {
- orientationFlags |= (unsigned int) DisplayOrientations::PortraitFlipped;
- }
- }
- }
-
- // If no valid orientation flags were specified, use a reasonable set of defaults:
- if (!orientationFlags) {
- // TODO, WinRT: consider seeing if an app's default orientation flags can be found out via some API call(s).
- orientationFlags = (unsigned int) ( \
- DisplayOrientations::Landscape |
- DisplayOrientations::LandscapeFlipped |
- DisplayOrientations::Portrait |
- DisplayOrientations::PortraitFlipped);
- }
-
- // Set the orientation/rotation preferences. Please note that this does
- // not constitute a 100%-certain lock of a given set of possible
- // orientations. According to Microsoft's documentation on WinRT [1]
- // when a device is not capable of being rotated, Windows may ignore
- // the orientation preferences, and stick to what the device is capable of
- // displaying.
- //
- // [1] Documentation on the 'InitialRotationPreference' setting for a
- // Windows app's manifest file describes how some orientation/rotation
- // preferences may be ignored. See
- // http://msdn.microsoft.com/en-us/library/windows/apps/hh700343.aspx
- // for details. Microsoft's "Display orientation sample" also gives an
- // outline of how Windows treats device rotation
- // (http://code.msdn.microsoft.com/Display-Orientation-Sample-19a58e93).
-#if NTDDI_VERSION > NTDDI_WIN8
- DisplayInformation::AutoRotationPreferences = (DisplayOrientations) orientationFlags;
-#else
- DisplayProperties::AutoRotationPreferences = (DisplayOrientations) orientationFlags;
-#endif
-}
-
-static void
-WINRT_ProcessWindowSizeChange()
-{
- // Make the new window size be the one true fullscreen mode.
- // This change was initially done, in part, to allow the Direct3D 11.1
- // renderer to receive window-resize events as a device rotates.
- // Before, rotating a device from landscape, to portrait, and then
- // back to landscape would cause the Direct3D 11.1 swap buffer to
- // not get resized appropriately. SDL would, on the rotation from
- // landscape to portrait, re-resize the SDL window to it's initial
- // size (landscape). On the subsequent rotation, SDL would drop the
- // window-resize event as it appeared the SDL window didn't change
- // size, and the Direct3D 11.1 renderer wouldn't resize its swap
- // chain.
- SDL_DisplayMode newDisplayMode;
- if (WINRT_CalcDisplayModeUsingNativeWindow(&newDisplayMode) != 0) {
- return;
- }
-
- // Make note of the old display mode, and it's old driverdata.
- SDL_DisplayMode oldDisplayMode;
- SDL_zero(oldDisplayMode);
- if (WINRT_GlobalSDLVideoDevice) {
- oldDisplayMode = WINRT_GlobalSDLVideoDevice->displays[0].desktop_mode;
- }
-
- // Setup the new display mode in the appropriate spots.
- if (WINRT_GlobalSDLVideoDevice) {
- // Make a full copy of the display mode for display_modes[0],
- // one with with a separately malloced 'driverdata' field.
- // SDL_VideoQuit(), if called, will attempt to free the driverdata
- // fields in 'desktop_mode' and each entry in the 'display_modes'
- // array.
- if (WINRT_GlobalSDLVideoDevice->displays[0].display_modes[0].driverdata) {
- // Free the previous mode's memory
- SDL_free(WINRT_GlobalSDLVideoDevice->displays[0].display_modes[0].driverdata);
- WINRT_GlobalSDLVideoDevice->displays[0].display_modes[0].driverdata = NULL;
- }
- if (WINRT_DuplicateDisplayMode(&(WINRT_GlobalSDLVideoDevice->displays[0].display_modes[0]), &newDisplayMode) != 0) {
- // Uh oh, something went wrong. A malloc call probably failed.
- SDL_free(newDisplayMode.driverdata);
- return;
- }
-
- // Install 'newDisplayMode' into 'current_mode' and 'desktop_mode'.
- WINRT_GlobalSDLVideoDevice->displays[0].current_mode = newDisplayMode;
- WINRT_GlobalSDLVideoDevice->displays[0].desktop_mode = newDisplayMode;
- }
-
- if (WINRT_GlobalSDLWindow) {
- // Send a window-resize event to the rest of SDL, and to apps:
- SDL_SendWindowEvent(
- WINRT_GlobalSDLWindow,
- SDL_WINDOWEVENT_RESIZED,
- newDisplayMode.w,
- newDisplayMode.h);
-
-#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
- // HACK: On Windows Phone, make sure that orientation changes from
- // Landscape to LandscapeFlipped, Portrait to PortraitFlipped,
- // or vice-versa on either of those two, lead to the Direct3D renderer
- // getting updated.
- const DisplayOrientations oldOrientation = ((SDL_DisplayModeData *)oldDisplayMode.driverdata)->currentOrientation;
- const DisplayOrientations newOrientation = ((SDL_DisplayModeData *)newDisplayMode.driverdata)->currentOrientation;
-
- if ((oldOrientation == DisplayOrientations::Landscape && newOrientation == DisplayOrientations::LandscapeFlipped) ||
- (oldOrientation == DisplayOrientations::LandscapeFlipped && newOrientation == DisplayOrientations::Landscape) ||
- (oldOrientation == DisplayOrientations::Portrait && newOrientation == DisplayOrientations::PortraitFlipped) ||
- (oldOrientation == DisplayOrientations::PortraitFlipped && newOrientation == DisplayOrientations::Portrait))
- {
- // One of the reasons this event is getting sent out is because SDL
- // will ignore requests to send out SDL_WINDOWEVENT_RESIZED events
- // if and when the event size doesn't change (and the Direct3D 11.1
- // renderer doesn't get the memo).
- //
- // Make sure that the display/window size really didn't change. If
- // it did, then a SDL_WINDOWEVENT_SIZE_CHANGED event got sent, and
- // the Direct3D 11.1 renderer picked it up, presumably.
- if (oldDisplayMode.w == newDisplayMode.w &&
- oldDisplayMode.h == newDisplayMode.h)
- {
- SDL_SendWindowEvent(
- WINRT_GlobalSDLWindow,
- SDL_WINDOWEVENT_SIZE_CHANGED,
- newDisplayMode.w,
- newDisplayMode.h);
- }
- }
-#endif
- }
-
- // Finally, free the 'driverdata' field of the old 'desktop_mode'.
- if (oldDisplayMode.driverdata) {
- SDL_free(oldDisplayMode.driverdata);
- oldDisplayMode.driverdata = NULL;
- }
-}
-
-SDL_WinRTApp::SDL_WinRTApp() :
- m_windowClosed(false),
- m_windowVisible(true)
-{
-}
-
-void SDL_WinRTApp::Initialize(CoreApplicationView^ applicationView)
-{
- applicationView->Activated +=
- ref new TypedEventHandler<CoreApplicationView^, IActivatedEventArgs^>(this, &SDL_WinRTApp::OnActivated);
-
- CoreApplication::Suspending +=
- ref new EventHandler<SuspendingEventArgs^>(this, &SDL_WinRTApp::OnSuspending);
-
- CoreApplication::Resuming +=
- ref new EventHandler<Platform::Object^>(this, &SDL_WinRTApp::OnResuming);
-
- CoreApplication::Exiting +=
- ref new EventHandler<Platform::Object^>(this, &SDL_WinRTApp::OnExiting);
-}
-
-#if NTDDI_VERSION > NTDDI_WIN8
-void SDL_WinRTApp::OnOrientationChanged(DisplayInformation^ sender, Object^ args)
-#else
-void SDL_WinRTApp::OnOrientationChanged(Object^ sender)
-#endif
-{
-#if LOG_ORIENTATION_EVENTS==1
- CoreWindow^ window = CoreWindow::GetForCurrentThread();
- if (window) {
- SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d, CoreWindow Size={%f,%f}\n",
- __FUNCTION__,
- (int)DisplayProperties::CurrentOrientation,
- (int)DisplayProperties::NativeOrientation,
- (int)DisplayProperties::AutoRotationPreferences,
- window->Bounds.Width,
- window->Bounds.Height);
- } else {
- SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d\n",
- __FUNCTION__,
- (int)DisplayProperties::CurrentOrientation,
- (int)DisplayProperties::NativeOrientation,
- (int)DisplayProperties::AutoRotationPreferences);
- }
-#endif
-
-#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
- // On Windows Phone, treat an orientation change as a change in window size.
- // The native window's size doesn't seem to change, however SDL will simulate
- // a window size change.
- WINRT_ProcessWindowSizeChange();
-#endif
-}
-
-void SDL_WinRTApp::SetWindow(CoreWindow^ window)
-{
-#if LOG_WINDOW_EVENTS==1
- SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d, window Size={%f,%f}\n",
- __FUNCTION__,
- (int)DisplayProperties::CurrentOrientation,
- (int)DisplayProperties::NativeOrientation,
- (int)DisplayProperties::AutoRotationPreferences,
- window->Bounds.Width,
- window->Bounds.Height);
-#endif
-
- window->SizeChanged +=
- ref new TypedEventHandler<CoreWindow^, WindowSizeChangedEventArgs^>(this, &SDL_WinRTApp::OnWindowSizeChanged);
-
- window->VisibilityChanged +=
- ref new TypedEventHandler<CoreWindow^, VisibilityChangedEventArgs^>(this, &SDL_WinRTApp::OnVisibilityChanged);
-
- window->Closed +=
- ref new TypedEventHandler<CoreWindow^, CoreWindowEventArgs^>(this, &SDL_WinRTApp::OnWindowClosed);
-
-#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
- window->PointerCursor = ref new CoreCursor(CoreCursorType::Arrow, 0);
-#endif
-
- window->PointerPressed +=
- ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerPressed);
-
- window->PointerMoved +=
- ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerMoved);
-
- window->PointerReleased +=
- ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerReleased);
-
- window->PointerWheelChanged +=
- ref new TypedEventHandler<CoreWindow^, PointerEventArgs^>(this, &SDL_WinRTApp::OnPointerWheelChanged);
-
-#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
- // Retrieves relative-only mouse movements:
- Windows::Devices::Input::MouseDevice::GetForCurrentView()->MouseMoved +=
- ref new TypedEventHandler<MouseDevice^, MouseEventArgs^>(this, &SDL_WinRTApp::OnMouseMoved);
-#endif
-
- window->KeyDown +=
- ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &SDL_WinRTApp::OnKeyDown);
-
- window->KeyUp +=
- ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(this, &SDL_WinRTApp::OnKeyUp);
-
-#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
- HardwareButtons::BackPressed +=
- ref new EventHandler<BackPressedEventArgs^>(this, &SDL_WinRTApp::OnBackButtonPressed);
-#endif
-
-#if NTDDI_VERSION > NTDDI_WIN8
- DisplayInformation::GetForCurrentView()->OrientationChanged +=
- ref new TypedEventHandler<Windows::Graphics::Display::DisplayInformation^, Object^>(this, &SDL_WinRTApp::OnOrientationChanged);
-#else
- DisplayProperties::OrientationChanged +=
- ref new DisplayPropertiesEventHandler(this, &SDL_WinRTApp::OnOrientationChanged);
-#endif
-
- // Register the hint, SDL_HINT_ORIENTATIONS, with SDL.
- // TODO, WinRT: see if an app's default orientation can be found out via WinRT API(s), then set the initial value of SDL_HINT_ORIENTATIONS accordingly.
- SDL_AddHintCallback(SDL_HINT_ORIENTATIONS, WINRT_SetDisplayOrientationsPreference, NULL);
-
-#if WINAPI_FAMILY == WINAPI_FAMILY_APP // for Windows 8/8.1/RT apps... (and not Phone apps)
- // Make sure we know when a user has opened the app's settings pane.
- // This is needed in order to display a privacy policy, which needs
- // to be done for network-enabled apps, as per Windows Store requirements.
- using namespace Windows::UI::ApplicationSettings;
- SettingsPane::GetForCurrentView()->CommandsRequested +=
- ref new TypedEventHandler<SettingsPane^, SettingsPaneCommandsRequestedEventArgs^>
- (this, &SDL_WinRTApp::OnSettingsPaneCommandsRequested);
-#endif
-}
-
-void SDL_WinRTApp::Load(Platform::String^ entryPoint)
-{
-}
-
-void SDL_WinRTApp::Run()
-{
- SDL_SetMainReady();
- if (WINRT_SDLAppEntryPoint)
- {
- // TODO, WinRT: pass the C-style main() a reasonably realistic
- // representation of command line arguments.
- int argc = 0;
- char **argv = NULL;
- WINRT_SDLAppEntryPoint(argc, argv);
- }
-}
-
-void SDL_WinRTApp::PumpEvents()
-{
- if (!m_windowClosed)
- {
- if (m_windowVisible)
- {
- CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);
- }
- else
- {
- CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessOneAndAllPending);
- }
- }
-}
-
-void SDL_WinRTApp::Uninitialize()
-{
-}
-
-#if WINAPI_FAMILY == WINAPI_FAMILY_APP
-void SDL_WinRTApp::OnSettingsPaneCommandsRequested(
- Windows::UI::ApplicationSettings::SettingsPane ^p,
- Windows::UI::ApplicationSettings::SettingsPaneCommandsRequestedEventArgs ^args)
-{
- using namespace Platform;
- using namespace Windows::UI::ApplicationSettings;
- using namespace Windows::UI::Popups;
-
- String ^privacyPolicyURL = nullptr; // a URL to an app's Privacy Policy
- String ^privacyPolicyLabel = nullptr; // label/link text
- const char *tmpHintValue = NULL; // SDL_GetHint-retrieved value, used immediately
- wchar_t *tmpStr = NULL; // used for UTF8 to UCS2 conversion
-
- // Setup a 'Privacy Policy' link, if one is available (via SDL_GetHint):
- tmpHintValue = SDL_GetHint(SDL_HINT_WINRT_PRIVACY_POLICY_URL);
- if (tmpHintValue && tmpHintValue[0] != '\0') {
- // Convert the privacy policy's URL to UCS2:
- tmpStr = WIN_UTF8ToString(tmpHintValue);
- privacyPolicyURL = ref new String(tmpStr);
- SDL_free(tmpStr);
-
- // Optionally retrieve custom label-text for the link. If this isn't
- // available, a default value will be used instead.
- tmpHintValue = SDL_GetHint(SDL_HINT_WINRT_PRIVACY_POLICY_LABEL);
- if (tmpHintValue && tmpHintValue[0] != '\0') {
- tmpStr = WIN_UTF8ToString(tmpHintValue);
- privacyPolicyLabel = ref new String(tmpStr);
- SDL_free(tmpStr);
- } else {
- privacyPolicyLabel = ref new String(L"Privacy Policy");
- }
-
- // Register the link, along with a handler to be called if and when it is
- // clicked:
- auto cmd = ref new SettingsCommand(L"privacyPolicy", privacyPolicyLabel,
- ref new UICommandInvokedHandler([=](IUICommand ^) {
- Windows::System::Launcher::LaunchUriAsync(ref new Uri(privacyPolicyURL));
- }));
- args->Request->ApplicationCommands->Append(cmd);
- }
-}
-#endif // if WINAPI_FAMILY == WINAPI_FAMILY_APP
-
-void SDL_WinRTApp::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEventArgs^ args)
-{
-#if LOG_WINDOW_EVENTS==1
- SDL_Log("%s, size={%f,%f}, current orientation=%d, native orientation=%d, auto rot. pref=%d, WINRT_GlobalSDLWindow?=%s\n",
- __FUNCTION__,
- args->Size.Width, args->Size.Height,
- (int)DisplayProperties::CurrentOrientation,
- (int)DisplayProperties::NativeOrientation,
- (int)DisplayProperties::AutoRotationPreferences,
- (WINRT_GlobalSDLWindow ? "yes" : "no"));
-#endif
-
- WINRT_ProcessWindowSizeChange();
-}
-
-void SDL_WinRTApp::OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEventArgs^ args)
-{
-#if LOG_WINDOW_EVENTS==1
- SDL_Log("%s, visible?=%s, WINRT_GlobalSDLWindow?=%s\n",
- __FUNCTION__,
- (args->Visible ? "yes" : "no"),
- (WINRT_GlobalSDLWindow ? "yes" : "no"));
-#endif
-
- m_windowVisible = args->Visible;
- if (WINRT_GlobalSDLWindow) {
- SDL_bool wasSDLWindowSurfaceValid = WINRT_GlobalSDLWindow->surface_valid;
-
- if (args->Visible) {
- SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_WINDOWEVENT_SHOWN, 0, 0);
- } else {
- SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_WINDOWEVENT_HIDDEN, 0, 0);
- }
-
- // HACK: Prevent SDL's window-hide handling code, which currently
- // triggers a fake window resize (possibly erronously), from
- // marking the SDL window's surface as invalid.
- //
- // A better solution to this probably involves figuring out if the
- // fake window resize can be prevented.
- WINRT_GlobalSDLWindow->surface_valid = wasSDLWindowSurfaceValid;
- }
-}
-
-void SDL_WinRTApp::OnWindowClosed(CoreWindow^ sender, CoreWindowEventArgs^ args)
-{
-#if LOG_WINDOW_EVENTS==1
- SDL_Log("%s\n", __FUNCTION__);
-#endif
- m_windowClosed = true;
-}
-
-void SDL_WinRTApp::OnActivated(CoreApplicationView^ applicationView, IActivatedEventArgs^ args)
-{
- CoreWindow::GetForCurrentThread()->Activate();
-}
-
-static int SDLCALL RemoveAppSuspendAndResumeEvents(void * userdata, SDL_Event * event)
-{
- if (event->type == SDL_WINDOWEVENT)
- {
- switch (event->window.event)
- {
- case SDL_WINDOWEVENT_MINIMIZED:
- case SDL_WINDOWEVENT_RESTORED:
- // Return 0 to indicate that the event should be removed from the
- // event queue:
- return 0;
- default:
- break;
- }
- }
-
- // Return 1 to indicate that the event should stay in the event queue:
- return 1;
-}
-
-void SDL_WinRTApp::OnSuspending(Platform::Object^ sender, SuspendingEventArgs^ args)
-{
- // Save app state asynchronously after requesting a deferral. Holding a deferral
- // indicates that the application is busy performing suspending operations. Be
- // aware that a deferral may not be held indefinitely. After about five seconds,
- // the app will be forced to exit.
- SuspendingDeferral^ deferral = args->SuspendingOperation->GetDeferral();
- create_task([this, deferral]()
- {
- // Send a window-minimized event immediately to observers.
- // CoreDispatcher::ProcessEvents, which is the backbone on which
- // SDL_WinRTApp::PumpEvents is built, will not return to its caller
- // once it sends out a suspend event. Any events posted to SDL's
- // event queue won't get received until the WinRT app is resumed.
- // SDL_AddEventWatch() may be used to receive app-suspend events on
- // WinRT.
- //
- // In order to prevent app-suspend events from being received twice:
- // first via a callback passed to SDL_AddEventWatch, and second via
- // SDL's event queue, the event will be sent to SDL, then immediately
- // removed from the queue.
- if (WINRT_GlobalSDLWindow)
- {
- SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_WINDOWEVENT_MINIMIZED, 0, 0); // TODO: see if SDL_WINDOWEVENT_SIZE_CHANGED should be getting triggered here (it is, currently)
- SDL_FilterEvents(RemoveAppSuspendAndResumeEvents, 0);
- }
-
- SDL_SendAppEvent(SDL_APP_WILLENTERBACKGROUND);
- SDL_SendAppEvent(SDL_APP_DIDENTERBACKGROUND);
-
- deferral->Complete();
- });
-}
-
-void SDL_WinRTApp::OnResuming(Platform::Object^ sender, Platform::Object^ args)
-{
- SDL_SendAppEvent(SDL_APP_WILLENTERFOREGROUND);
- SDL_SendAppEvent(SDL_APP_DIDENTERFOREGROUND);
-
- // Restore any data or state that was unloaded on suspend. By default, data
- // and state are persisted when resuming from suspend. Note that this event
- // does not occur if the app was previously terminated.
- if (WINRT_GlobalSDLWindow)
- {
- SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_WINDOWEVENT_RESTORED, 0, 0); // TODO: see if SDL_WINDOWEVENT_SIZE_CHANGED should be getting triggered here (it is, currently)
-
- // Remove the app-resume event from the queue, as is done with the
- // app-suspend event.
- //
- // TODO, WinRT: consider posting this event to the queue even though
- // its counterpart, the app-suspend event, effectively has to be
- // processed immediately.
- SDL_FilterEvents(RemoveAppSuspendAndResumeEvents, 0);
- }
-}
-
-void SDL_WinRTApp::OnExiting(Platform::Object^ sender, Platform::Object^ args)
-{
- SDL_SendAppEvent(SDL_APP_TERMINATING);
-}
-
-static void
-WINRT_LogPointerEvent(const char * header, Windows::UI::Core::PointerEventArgs ^ args, Windows::Foundation::Point transformedPoint)
-{
- Windows::UI::Input::PointerPoint ^ pt = args->CurrentPoint;
- SDL_Log("%s: Position={%f,%f}, Transformed Pos={%f, %f}, MouseWheelDelta=%d, FrameId=%d, PointerId=%d, SDL button=%d\n",
- header,
- pt->Position.X, pt->Position.Y,
- transformedPoint.X, transformedPoint.Y,
- pt->Properties->MouseWheelDelta,
- pt->FrameId,
- pt->PointerId,
- WINRT_GetSDLButtonForPointerPoint(pt));
-}
-
-void SDL_WinRTApp::OnPointerPressed(CoreWindow^ sender, PointerEventArgs^ args)
-{
-#if LOG_POINTER_EVENTS
- WINRT_LogPointerEvent("pointer pressed", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position, TransformToSDLWindowSize));
-#endif
-
- WINRT_ProcessPointerPressedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint);
-}
-
-void SDL_WinRTApp::OnPointerMoved(CoreWindow^ sender, PointerEventArgs^ args)
-{
-#if LOG_POINTER_EVENTS
- WINRT_LogPointerEvent("pointer moved", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position, TransformToSDLWindowSize));
-#endif
-
- WINRT_ProcessPointerMovedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint);
-}
-
-void SDL_WinRTApp::OnPointerReleased(CoreWindow^ sender, PointerEventArgs^ args)
-{
-#if LOG_POINTER_EVENTS
- WINRT_LogPointerEvent("pointer released", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position, TransformToSDLWindowSize));
-#endif
-
- WINRT_ProcessPointerReleasedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint);
-}
-
-void SDL_WinRTApp::OnPointerWheelChanged(CoreWindow^ sender, PointerEventArgs^ args)
-{
-#if LOG_POINTER_EVENTS
- WINRT_LogPointerEvent("pointer wheel changed", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position, TransformToSDLWindowSize));
-#endif
-
- WINRT_ProcessPointerWheelChangedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint);
-}
-
-void SDL_WinRTApp::OnMouseMoved(MouseDevice^ mouseDevice, MouseEventArgs^ args)
-{
- WINRT_ProcessMouseMovedEvent(WINRT_GlobalSDLWindow, args);
-}
-
-void SDL_WinRTApp::OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args)
-{
- WINRT_ProcessKeyDownEvent(args);
-}
-
-void SDL_WinRTApp::OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args)
-{
- WINRT_ProcessKeyUpEvent(args);
-}
-
-#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
-void SDL_WinRTApp::OnBackButtonPressed(Platform::Object^ sender, Windows::Phone::UI::Input::BackPressedEventArgs^ args)
-{
- SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_AC_BACK);
- SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_AC_BACK);
-
- const char *hint = SDL_GetHint(SDL_HINT_WINRT_HANDLE_BACK_BUTTON);
- if (hint) {
- if (*hint == '1') {
- args->Handled = true;
- }
- }
-}
-#endif
-
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/d1484ae0/DocFormats/platform/3rdparty/SDL2-2.0.3/src/core/winrt/SDL_winrtapp_direct3d.h
----------------------------------------------------------------------
diff --git a/DocFormats/platform/3rdparty/SDL2-2.0.3/src/core/winrt/SDL_winrtapp_direct3d.h b/DocFormats/platform/3rdparty/SDL2-2.0.3/src/core/winrt/SDL_winrtapp_direct3d.h
deleted file mode 100644
index 6dc9a6c..0000000
--- a/DocFormats/platform/3rdparty/SDL2-2.0.3/src/core/winrt/SDL_winrtapp_direct3d.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2014 Sam Lantinga <sl...@libsdl.org>
-
- 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.
-
- 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:
-
- 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 <Windows.h>
-
-extern int SDL_WinRTInitNonXAMLApp(int (*mainFunction)(int, char **));
-
-ref class SDL_WinRTApp sealed : public Windows::ApplicationModel::Core::IFrameworkView
-{
-public:
- SDL_WinRTApp();
-
- // IFrameworkView Methods.
- virtual void Initialize(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView);
- virtual void SetWindow(Windows::UI::Core::CoreWindow^ window);
- virtual void Load(Platform::String^ entryPoint);
- virtual void Run();
- virtual void Uninitialize();
-
-internal:
- // SDL-specific methods
- void PumpEvents();
-
-protected:
- // Event Handlers.
-
-#if WINAPI_FAMILY == WINAPI_FAMILY_APP // for Windows 8/8.1/RT apps... (and not Phone apps)
- void OnSettingsPaneCommandsRequested(
- Windows::UI::ApplicationSettings::SettingsPane ^p,
- Windows::UI::ApplicationSettings::SettingsPaneCommandsRequestedEventArgs ^args);
-#endif // if WINAPI_FAMILY == WINAPI_FAMILY_APP
-
-#if NTDDI_VERSION > NTDDI_WIN8
- void OnOrientationChanged(Windows::Graphics::Display::DisplayInformation^ sender, Platform::Object^ args);
-#else
- void OnOrientationChanged(Platform::Object^ sender);
-#endif
- void OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args);
- void OnLogicalDpiChanged(Platform::Object^ sender);
- void OnActivated(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView, Windows::ApplicationModel::Activation::IActivatedEventArgs^ args);
- void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ args);
- void OnResuming(Platform::Object^ sender, Platform::Object^ args);
- void OnExiting(Platform::Object^ sender, Platform::Object^ args);
- void OnWindowClosed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CoreWindowEventArgs^ args);
- void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args);
- void OnPointerPressed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
- void OnPointerReleased(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
- void OnPointerWheelChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
- void OnPointerMoved(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args);
- void OnMouseMoved(Windows::Devices::Input::MouseDevice^ mouseDevice, Windows::Devices::Input::MouseEventArgs^ args);
- void OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args);
- void OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args);
-
-#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
- void OnBackButtonPressed(Platform::Object^ sender, Windows::Phone::UI::Input::BackPressedEventArgs^ args);
-#endif
-
-private:
- bool m_windowClosed;
- bool m_windowVisible;
-};
-
-extern SDL_WinRTApp ^ SDL_WinRTGlobalApp;
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/d1484ae0/DocFormats/platform/3rdparty/SDL2-2.0.3/src/core/winrt/SDL_winrtapp_xaml.cpp
----------------------------------------------------------------------
diff --git a/DocFormats/platform/3rdparty/SDL2-2.0.3/src/core/winrt/SDL_winrtapp_xaml.cpp b/DocFormats/platform/3rdparty/SDL2-2.0.3/src/core/winrt/SDL_winrtapp_xaml.cpp
deleted file mode 100644
index 38694e1..0000000
--- a/DocFormats/platform/3rdparty/SDL2-2.0.3/src/core/winrt/SDL_winrtapp_xaml.cpp
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2014 Sam Lantinga <sl...@libsdl.org>
-
- 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.
-
- 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:
-
- 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.
-*/
-
-/* Windows includes */
-#include <agile.h>
-#include <Windows.h>
-
-#if WINAPI_FAMILY == WINAPI_FAMILY_APP
-#include <windows.ui.xaml.media.dxinterop.h>
-#endif
-
-
-/* SDL includes */
-#include "../../SDL_internal.h"
-#include "SDL.h"
-#include "../../video/winrt/SDL_winrtevents_c.h"
-#include "../../video/winrt/SDL_winrtvideo_cpp.h"
-#include "SDL_winrtapp_common.h"
-#include "SDL_winrtapp_xaml.h"
-
-
-
-/* SDL-internal globals: */
-SDL_bool WINRT_XAMLWasEnabled = SDL_FALSE;
-
-#if WINAPI_FAMILY == WINAPI_FAMILY_APP
-extern "C"
-ISwapChainBackgroundPanelNative * WINRT_GlobalSwapChainBackgroundPanelNative = NULL;
-static Windows::Foundation::EventRegistrationToken WINRT_XAMLAppEventToken;
-#endif
-
-
-/*
- * Input event handlers (XAML)
- */
-#if WINAPI_FAMILY == WINAPI_FAMILY_APP
-
-static void
-WINRT_OnPointerPressedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args)
-{
- WINRT_ProcessPointerPressedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr));
-}
-
-static void
-WINRT_OnPointerMovedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args)
-{
- WINRT_ProcessPointerMovedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr));
-}
-
-static void
-WINRT_OnPointerReleasedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args)
-{
- WINRT_ProcessPointerReleasedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr));
-}
-
-static void
-WINRT_OnPointerWheelChangedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args)
-{
- WINRT_ProcessPointerWheelChangedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr));
-}
-
-#endif // WINAPI_FAMILY == WINAPI_FAMILY_APP
-
-
-/*
- * XAML-to-SDL Rendering Callback
- */
-#if WINAPI_FAMILY == WINAPI_FAMILY_APP
-
-static void
-WINRT_OnRenderViaXAML(_In_ Platform::Object^ sender, _In_ Platform::Object^ args)
-{
- WINRT_CycleXAMLThread();
-}
-
-#endif // WINAPI_FAMILY == WINAPI_FAMILY_APP
-
-
-/*
- * SDL + XAML Initialization
- */
-
-int
-SDL_WinRTInitXAMLApp(int (*mainFunction)(int, char **), void * backgroundPanelAsIInspectable)
-{
-#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
- return SDL_SetError("XAML support is not yet available in Windows Phone.");
-#else
- // Declare C++/CX namespaces:
- using namespace Platform;
- using namespace Windows::Foundation;
- using namespace Windows::UI::Core;
- using namespace Windows::UI::Xaml;
- using namespace Windows::UI::Xaml::Controls;
- using namespace Windows::UI::Xaml::Input;
- using namespace Windows::UI::Xaml::Media;
-
- // Make sure we have a valid XAML element (to draw onto):
- if ( ! backgroundPanelAsIInspectable) {
- return SDL_SetError("'backgroundPanelAsIInspectable' can't be NULL");
- }
-
- Platform::Object ^ backgroundPanel = reinterpret_cast<Object ^>((IInspectable *) backgroundPanelAsIInspectable);
- SwapChainBackgroundPanel ^swapChainBackgroundPanel = dynamic_cast<SwapChainBackgroundPanel ^>(backgroundPanel);
- if ( ! swapChainBackgroundPanel) {
- return SDL_SetError("An unknown or unsupported type of XAML control was specified.");
- }
-
- // Setup event handlers:
- swapChainBackgroundPanel->PointerPressed += ref new PointerEventHandler(WINRT_OnPointerPressedViaXAML);
- swapChainBackgroundPanel->PointerReleased += ref new PointerEventHandler(WINRT_OnPointerReleasedViaXAML);
- swapChainBackgroundPanel->PointerWheelChanged += ref new PointerEventHandler(WINRT_OnPointerWheelChangedViaXAML);
- swapChainBackgroundPanel->PointerMoved += ref new PointerEventHandler(WINRT_OnPointerMovedViaXAML);
-
- // Setup for rendering:
- IInspectable *panelInspectable = (IInspectable*) reinterpret_cast<IInspectable*>(swapChainBackgroundPanel);
- panelInspectable->QueryInterface(__uuidof(ISwapChainBackgroundPanelNative), (void **)&WINRT_GlobalSwapChainBackgroundPanelNative);
-
- WINRT_XAMLAppEventToken = CompositionTarget::Rendering::add(ref new EventHandler<Object^>(WINRT_OnRenderViaXAML));
-
- // Make sure the app is ready to call the SDL-centric main() function:
- WINRT_SDLAppEntryPoint = mainFunction;
- SDL_SetMainReady();
-
- // Make sure video-init knows that we're initializing XAML:
- SDL_bool oldXAMLWasEnabledValue = WINRT_XAMLWasEnabled;
- WINRT_XAMLWasEnabled = SDL_TRUE;
-
- // Make sure video modes are detected now, while we still have access to the WinRT
- // CoreWindow. WinRT will not allow the app's CoreWindow to be accessed via the
- // SDL/WinRT thread.
- if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) {
- // SDL_InitSubSystem will, on error, set the SDL error. Let that propogate to
- // the caller to here:
- WINRT_XAMLWasEnabled = oldXAMLWasEnabledValue;
- return -1;
- }
-
- // All done, for now.
- return 0;
-#endif // WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP / else
-}
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/d1484ae0/DocFormats/platform/3rdparty/SDL2-2.0.3/src/core/winrt/SDL_winrtapp_xaml.h
----------------------------------------------------------------------
diff --git a/DocFormats/platform/3rdparty/SDL2-2.0.3/src/core/winrt/SDL_winrtapp_xaml.h b/DocFormats/platform/3rdparty/SDL2-2.0.3/src/core/winrt/SDL_winrtapp_xaml.h
deleted file mode 100644
index 2296475..0000000
--- a/DocFormats/platform/3rdparty/SDL2-2.0.3/src/core/winrt/SDL_winrtapp_xaml.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2014 Sam Lantinga <sl...@libsdl.org>
-
- 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.
-
- 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:
-
- 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"
-
-#ifndef _SDL_winrtapp_xaml_h
-#define _SDL_winrtapp_xaml_h
-
-#include "SDL_types.h"
-
-#ifdef __cplusplus
-extern SDL_bool WINRT_XAMLWasEnabled;
-extern int SDL_WinRTInitXAMLApp(int (*mainFunction)(int, char **), void * backgroundPanelAsIInspectable);
-#endif // ifdef __cplusplus
-
-#endif // ifndef _SDL_winrtapp_xaml_h
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/d1484ae0/DocFormats/platform/3rdparty/SDL2-2.0.3/src/cpuinfo/SDL_cpuinfo.c
----------------------------------------------------------------------
diff --git a/DocFormats/platform/3rdparty/SDL2-2.0.3/src/cpuinfo/SDL_cpuinfo.c b/DocFormats/platform/3rdparty/SDL2-2.0.3/src/cpuinfo/SDL_cpuinfo.c
deleted file mode 100644
index 6a529ae..0000000
--- a/DocFormats/platform/3rdparty/SDL2-2.0.3/src/cpuinfo/SDL_cpuinfo.c
+++ /dev/null
@@ -1,727 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2014 Sam Lantinga <sl...@libsdl.org>
-
- 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.
-
- 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:
-
- 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.
-*/
-#ifdef TEST_MAIN
-#include "SDL_config.h"
-#else
-#include "../SDL_internal.h"
-#endif
-
-#if defined(__WIN32__)
-#include "../core/windows/SDL_windows.h"
-#endif
-
-/* CPU feature detection for SDL */
-
-#include "SDL_cpuinfo.h"
-
-#ifdef HAVE_SYSCONF
-#include <unistd.h>
-#endif
-#ifdef HAVE_SYSCTLBYNAME
-#include <sys/types.h>
-#include <sys/sysctl.h>
-#endif
-#if defined(__MACOSX__) && (defined(__ppc__) || defined(__ppc64__))
-#include <sys/sysctl.h> /* For AltiVec check */
-#elif defined(__OpenBSD__) && defined(__powerpc__)
-#include <sys/param.h>
-#include <sys/sysctl.h> /* For AltiVec check */
-#include <machine/cpu.h>
-#elif SDL_ALTIVEC_BLITTERS && HAVE_SETJMP
-#include <signal.h>
-#include <setjmp.h>
-#endif
-
-#define CPU_HAS_RDTSC 0x00000001
-#define CPU_HAS_ALTIVEC 0x00000002
-#define CPU_HAS_MMX 0x00000004
-#define CPU_HAS_3DNOW 0x00000008
-#define CPU_HAS_SSE 0x00000010
-#define CPU_HAS_SSE2 0x00000020
-#define CPU_HAS_SSE3 0x00000040
-#define CPU_HAS_SSE41 0x00000100
-#define CPU_HAS_SSE42 0x00000200
-#define CPU_HAS_AVX 0x00000400
-
-#if SDL_ALTIVEC_BLITTERS && HAVE_SETJMP && !__MACOSX__ && !__OpenBSD__
-/* This is the brute force way of detecting instruction sets...
- the idea is borrowed from the libmpeg2 library - thanks!
- */
-static jmp_buf jmpbuf;
-static void
-illegal_instruction(int sig)
-{
- longjmp(jmpbuf, 1);
-}
-#endif /* HAVE_SETJMP */
-
-static SDL_INLINE int
-CPU_haveCPUID(void)
-{
- int has_CPUID = 0;
-/* *INDENT-OFF* */
-#if defined(__GNUC__) && defined(i386)
- __asm__ (
-" pushfl # Get original EFLAGS \n"
-" popl %%eax \n"
-" movl %%eax,%%ecx \n"
-" xorl $0x200000,%%eax # Flip ID bit in EFLAGS \n"
-" pushl %%eax # Save new EFLAGS value on stack \n"
-" popfl # Replace current EFLAGS value \n"
-" pushfl # Get new EFLAGS \n"
-" popl %%eax # Store new EFLAGS in EAX \n"
-" xorl %%ecx,%%eax # Can not toggle ID bit, \n"
-" jz 1f # Processor=80486 \n"
-" movl $1,%0 # We have CPUID support \n"
-"1: \n"
- : "=m" (has_CPUID)
- :
- : "%eax", "%ecx"
- );
-#elif defined(__GNUC__) && defined(__x86_64__)
-/* Technically, if this is being compiled under __x86_64__ then it has
- CPUid by definition. But it's nice to be able to prove it. :) */
- __asm__ (
-" pushfq # Get original EFLAGS \n"
-" popq %%rax \n"
-" movq %%rax,%%rcx \n"
-" xorl $0x200000,%%eax # Flip ID bit in EFLAGS \n"
-" pushq %%rax # Save new EFLAGS value on stack \n"
-" popfq # Replace current EFLAGS value \n"
-" pushfq # Get new EFLAGS \n"
-" popq %%rax # Store new EFLAGS in EAX \n"
-" xorl %%ecx,%%eax # Can not toggle ID bit, \n"
-" jz 1f # Processor=80486 \n"
-" movl $1,%0 # We have CPUID support \n"
-"1: \n"
- : "=m" (has_CPUID)
- :
- : "%rax", "%rcx"
- );
-#elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
- __asm {
- pushfd ; Get original EFLAGS
- pop eax
- mov ecx, eax
- xor eax, 200000h ; Flip ID bit in EFLAGS
- push eax ; Save new EFLAGS value on stack
- popfd ; Replace current EFLAGS value
- pushfd ; Get new EFLAGS
- pop eax ; Store new EFLAGS in EAX
- xor eax, ecx ; Can not toggle ID bit,
- jz done ; Processor=80486
- mov has_CPUID,1 ; We have CPUID support
-done:
- }
-#elif defined(_MSC_VER) && defined(_M_X64)
- has_CPUID = 1;
-#elif defined(__sun) && defined(__i386)
- __asm (
-" pushfl \n"
-" popl %eax \n"
-" movl %eax,%ecx \n"
-" xorl $0x200000,%eax \n"
-" pushl %eax \n"
-" popfl \n"
-" pushfl \n"
-" popl %eax \n"
-" xorl %ecx,%eax \n"
-" jz 1f \n"
-" movl $1,-8(%ebp) \n"
-"1: \n"
- );
-#elif defined(__sun) && defined(__amd64)
- __asm (
-" pushfq \n"
-" popq %rax \n"
-" movq %rax,%rcx \n"
-" xorl $0x200000,%eax \n"
-" pushq %rax \n"
-" popfq \n"
-" pushfq \n"
-" popq %rax \n"
-" xorl %ecx,%eax \n"
-" jz 1f \n"
-" movl $1,-8(%rbp) \n"
-"1: \n"
- );
-#endif
-/* *INDENT-ON* */
- return has_CPUID;
-}
-
-#if defined(__GNUC__) && defined(i386)
-#define cpuid(func, a, b, c, d) \
- __asm__ __volatile__ ( \
-" pushl %%ebx \n" \
-" cpuid \n" \
-" movl %%ebx, %%esi \n" \
-" popl %%ebx \n" : \
- "=a" (a), "=S" (b), "=c" (c), "=d" (d) : "a" (func))
-#elif defined(__GNUC__) && defined(__x86_64__)
-#define cpuid(func, a, b, c, d) \
- __asm__ __volatile__ ( \
-" pushq %%rbx \n" \
-" cpuid \n" \
-" movq %%rbx, %%rsi \n" \
-" popq %%rbx \n" : \
- "=a" (a), "=S" (b), "=c" (c), "=d" (d) : "a" (func))
-#elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
-#define cpuid(func, a, b, c, d) \
- __asm { \
- __asm mov eax, func \
- __asm cpuid \
- __asm mov a, eax \
- __asm mov b, ebx \
- __asm mov c, ecx \
- __asm mov d, edx \
-}
-#elif defined(_MSC_VER) && defined(_M_X64)
-#define cpuid(func, a, b, c, d) \
-{ \
- int CPUInfo[4]; \
- __cpuid(CPUInfo, func); \
- a = CPUInfo[0]; \
- b = CPUInfo[1]; \
- c = CPUInfo[2]; \
- d = CPUInfo[3]; \
-}
-#else
-#define cpuid(func, a, b, c, d) \
- a = b = c = d = 0
-#endif
-
-static SDL_INLINE int
-CPU_getCPUIDFeatures(void)
-{
- int features = 0;
- int a, b, c, d;
-
- cpuid(0, a, b, c, d);
- if (a >= 1) {
- cpuid(1, a, b, c, d);
- features = d;
- }
- return features;
-}
-
-static SDL_INLINE int
-CPU_haveRDTSC(void)
-{
- if (CPU_haveCPUID()) {
- return (CPU_getCPUIDFeatures() & 0x00000010);
- }
- return 0;
-}
-
-static SDL_INLINE int
-CPU_haveAltiVec(void)
-{
- volatile int altivec = 0;
-#if (defined(__MACOSX__) && (defined(__ppc__) || defined(__ppc64__))) || (defined(__OpenBSD__) && defined(__powerpc__))
-#ifdef __OpenBSD__
- int selectors[2] = { CTL_MACHDEP, CPU_ALTIVEC };
-#else
- int selectors[2] = { CTL_HW, HW_VECTORUNIT };
-#endif
- int hasVectorUnit = 0;
- size_t length = sizeof(hasVectorUnit);
- int error = sysctl(selectors, 2, &hasVectorUnit, &length, NULL, 0);
- if (0 == error)
- altivec = (hasVectorUnit != 0);
-#elif SDL_ALTIVEC_BLITTERS && HAVE_SETJMP
- void (*handler) (int sig);
- handler = signal(SIGILL, illegal_instruction);
- if (setjmp(jmpbuf) == 0) {
- asm volatile ("mtspr 256, %0\n\t" "vand %%v0, %%v0, %%v0"::"r" (-1));
- altivec = 1;
- }
- signal(SIGILL, handler);
-#endif
- return altivec;
-}
-
-static SDL_INLINE int
-CPU_haveMMX(void)
-{
- if (CPU_haveCPUID()) {
- return (CPU_getCPUIDFeatures() & 0x00800000);
- }
- return 0;
-}
-
-static SDL_INLINE int
-CPU_have3DNow(void)
-{
- if (CPU_haveCPUID()) {
- int a, b, c, d;
-
- cpuid(0x80000000, a, b, c, d);
- if (a >= 0x80000001) {
- cpuid(0x80000001, a, b, c, d);
- return (d & 0x80000000);
- }
- }
- return 0;
-}
-
-static SDL_INLINE int
-CPU_haveSSE(void)
-{
- if (CPU_haveCPUID()) {
- return (CPU_getCPUIDFeatures() & 0x02000000);
- }
- return 0;
-}
-
-static SDL_INLINE int
-CPU_haveSSE2(void)
-{
- if (CPU_haveCPUID()) {
- return (CPU_getCPUIDFeatures() & 0x04000000);
- }
- return 0;
-}
-
-static SDL_INLINE int
-CPU_haveSSE3(void)
-{
- if (CPU_haveCPUID()) {
- int a, b, c, d;
-
- cpuid(0, a, b, c, d);
- if (a >= 1) {
- cpuid(1, a, b, c, d);
- return (c & 0x00000001);
- }
- }
- return 0;
-}
-
-static SDL_INLINE int
-CPU_haveSSE41(void)
-{
- if (CPU_haveCPUID()) {
- int a, b, c, d;
-
- cpuid(1, a, b, c, d);
- if (a >= 1) {
- cpuid(1, a, b, c, d);
- return (c & 0x00080000);
- }
- }
- return 0;
-}
-
-static SDL_INLINE int
-CPU_haveSSE42(void)
-{
- if (CPU_haveCPUID()) {
- int a, b, c, d;
-
- cpuid(1, a, b, c, d);
- if (a >= 1) {
- cpuid(1, a, b, c, d);
- return (c & 0x00100000);
- }
- }
- return 0;
-}
-
-static SDL_INLINE int
-CPU_haveAVX(void)
-{
- if (CPU_haveCPUID()) {
- int a, b, c, d;
-
- cpuid(1, a, b, c, d);
- if (a >= 1) {
- cpuid(1, a, b, c, d);
- return (c & 0x10000000);
- }
- }
- return 0;
-}
-
-static int SDL_CPUCount = 0;
-
-int
-SDL_GetCPUCount(void)
-{
- if (!SDL_CPUCount) {
-#if defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN)
- if (SDL_CPUCount <= 0) {
- SDL_CPUCount = (int)sysconf(_SC_NPROCESSORS_ONLN);
- }
-#endif
-#ifdef HAVE_SYSCTLBYNAME
- if (SDL_CPUCount <= 0) {
- size_t size = sizeof(SDL_CPUCount);
- sysctlbyname("hw.ncpu", &SDL_CPUCount, &size, NULL, 0);
- }
-#endif
-#ifdef __WIN32__
- if (SDL_CPUCount <= 0) {
- SYSTEM_INFO info;
- GetSystemInfo(&info);
- SDL_CPUCount = info.dwNumberOfProcessors;
- }
-#endif
- /* There has to be at least 1, right? :) */
- if (SDL_CPUCount <= 0) {
- SDL_CPUCount = 1;
- }
- }
- return SDL_CPUCount;
-}
-
-/* Oh, such a sweet sweet trick, just not very useful. :) */
-static const char *
-SDL_GetCPUType(void)
-{
- static char SDL_CPUType[13];
-
- if (!SDL_CPUType[0]) {
- int i = 0;
- int a, b, c, d;
-
- if (CPU_haveCPUID()) {
- cpuid(0x00000000, a, b, c, d);
- SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8;
- SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8;
- SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8;
- SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8;
- SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8;
- SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8;
- SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8;
- SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8;
- SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8;
- SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8;
- SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8;
- SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8;
- }
- if (!SDL_CPUType[0]) {
- SDL_strlcpy(SDL_CPUType, "Unknown", sizeof(SDL_CPUType));
- }
- }
- return SDL_CPUType;
-}
-
-
-#ifdef TEST_MAIN /* !!! FIXME: only used for test at the moment. */
-static const char *
-SDL_GetCPUName(void)
-{
- static char SDL_CPUName[48];
-
- if (!SDL_CPUName[0]) {
- int i = 0;
- int a, b, c, d;
-
- if (CPU_haveCPUID()) {
- cpuid(0x80000000, a, b, c, d);
- if (a >= 0x80000004) {
- cpuid(0x80000002, a, b, c, d);
- SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8;
- SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8;
- SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8;
- SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8;
- SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8;
- SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8;
- SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8;
- SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8;
- SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8;
- SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8;
- SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8;
- SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8;
- SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8;
- SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8;
- SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8;
- SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8;
- cpuid(0x80000003, a, b, c, d);
- SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8;
- SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8;
- SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8;
- SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8;
- SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8;
- SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8;
- SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8;
- SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8;
- SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8;
- SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8;
- SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8;
- SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8;
- SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8;
- SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8;
- SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8;
- SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8;
- cpuid(0x80000004, a, b, c, d);
- SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8;
- SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8;
- SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8;
- SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8;
- SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8;
- SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8;
- SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8;
- SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8;
- SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8;
- SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8;
- SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8;
- SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8;
- SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8;
- SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8;
- SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8;
- SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8;
- }
- }
- if (!SDL_CPUName[0]) {
- SDL_strlcpy(SDL_CPUName, "Unknown", sizeof(SDL_CPUName));
- }
- }
- return SDL_CPUName;
-}
-#endif
-
-int
-SDL_GetCPUCacheLineSize(void)
-{
- const char *cpuType = SDL_GetCPUType();
-
- if (SDL_strcmp(cpuType, "GenuineIntel") == 0) {
- int a, b, c, d;
-
- cpuid(0x00000001, a, b, c, d);
- return (((b >> 8) & 0xff) * 8);
- } else if (SDL_strcmp(cpuType, "AuthenticAMD") == 0) {
- int a, b, c, d;
-
- cpuid(0x80000005, a, b, c, d);
- return (c & 0xff);
- } else {
- /* Just make a guess here... */
- return SDL_CACHELINE_SIZE;
- }
-}
-
-static Uint32 SDL_CPUFeatures = 0xFFFFFFFF;
-
-static Uint32
-SDL_GetCPUFeatures(void)
-{
- if (SDL_CPUFeatures == 0xFFFFFFFF) {
- SDL_CPUFeatures = 0;
- if (CPU_haveRDTSC()) {
- SDL_CPUFeatures |= CPU_HAS_RDTSC;
- }
- if (CPU_haveAltiVec()) {
- SDL_CPUFeatures |= CPU_HAS_ALTIVEC;
- }
- if (CPU_haveMMX()) {
- SDL_CPUFeatures |= CPU_HAS_MMX;
- }
- if (CPU_have3DNow()) {
- SDL_CPUFeatures |= CPU_HAS_3DNOW;
- }
- if (CPU_haveSSE()) {
- SDL_CPUFeatures |= CPU_HAS_SSE;
- }
- if (CPU_haveSSE2()) {
- SDL_CPUFeatures |= CPU_HAS_SSE2;
- }
- if (CPU_haveSSE3()) {
- SDL_CPUFeatures |= CPU_HAS_SSE3;
- }
- if (CPU_haveSSE41()) {
- SDL_CPUFeatures |= CPU_HAS_SSE41;
- }
- if (CPU_haveSSE42()) {
- SDL_CPUFeatures |= CPU_HAS_SSE42;
- }
- if (CPU_haveAVX()) {
- SDL_CPUFeatures |= CPU_HAS_AVX;
- }
- }
- return SDL_CPUFeatures;
-}
-
-SDL_bool
-SDL_HasRDTSC(void)
-{
- if (SDL_GetCPUFeatures() & CPU_HAS_RDTSC) {
- return SDL_TRUE;
- }
- return SDL_FALSE;
-}
-
-SDL_bool
-SDL_HasAltiVec(void)
-{
- if (SDL_GetCPUFeatures() & CPU_HAS_ALTIVEC) {
- return SDL_TRUE;
- }
- return SDL_FALSE;
-}
-
-SDL_bool
-SDL_HasMMX(void)
-{
- if (SDL_GetCPUFeatures() & CPU_HAS_MMX) {
- return SDL_TRUE;
- }
- return SDL_FALSE;
-}
-
-SDL_bool
-SDL_Has3DNow(void)
-{
- if (SDL_GetCPUFeatures() & CPU_HAS_3DNOW) {
- return SDL_TRUE;
- }
- return SDL_FALSE;
-}
-
-SDL_bool
-SDL_HasSSE(void)
-{
- if (SDL_GetCPUFeatures() & CPU_HAS_SSE) {
- return SDL_TRUE;
- }
- return SDL_FALSE;
-}
-
-SDL_bool
-SDL_HasSSE2(void)
-{
- if (SDL_GetCPUFeatures() & CPU_HAS_SSE2) {
- return SDL_TRUE;
- }
- return SDL_FALSE;
-}
-
-SDL_bool
-SDL_HasSSE3(void)
-{
- if (SDL_GetCPUFeatures() & CPU_HAS_SSE3) {
- return SDL_TRUE;
- }
- return SDL_FALSE;
-}
-
-SDL_bool
-SDL_HasSSE41(void)
-{
- if (SDL_GetCPUFeatures() & CPU_HAS_SSE41) {
- return SDL_TRUE;
- }
- return SDL_FALSE;
-}
-
-SDL_bool
-SDL_HasSSE42(void)
-{
- if (SDL_GetCPUFeatures() & CPU_HAS_SSE42) {
- return SDL_TRUE;
- }
- return SDL_FALSE;
-}
-
-SDL_bool
-SDL_HasAVX(void)
-{
- if (SDL_GetCPUFeatures() & CPU_HAS_AVX) {
- return SDL_TRUE;
- }
- return SDL_FALSE;
-}
-
-static int SDL_SystemRAM = 0;
-
-int
-SDL_GetSystemRAM(void)
-{
- if (!SDL_SystemRAM) {
-#if defined(HAVE_SYSCONF) && defined(_SC_PHYS_PAGES) && defined(_SC_PAGESIZE)
- if (SDL_SystemRAM <= 0) {
- SDL_SystemRAM = (int)((Sint64)sysconf(_SC_PHYS_PAGES) * sysconf(_SC_PAGESIZE) / (1024*1024));
- }
-#endif
-#ifdef HAVE_SYSCTLBYNAME
- if (SDL_SystemRAM <= 0) {
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
-#ifdef HW_REALMEM
- int mib[2] = {CTL_HW, HW_REALMEM};
-#else
- /* might only report up to 2 GiB */
- int mib[2] = {CTL_HW, HW_PHYSMEM};
-#endif /* HW_REALMEM */
-#else
- int mib[2] = {CTL_HW, HW_MEMSIZE};
-#endif /* __FreeBSD__ || __FreeBSD_kernel__ */
- Uint64 memsize = 0;
- size_t len = sizeof(memsize);
-
- if (sysctl(mib, 2, &memsize, &len, NULL, 0) == 0) {
- SDL_SystemRAM = (int)(memsize / (1024*1024));
- }
- }
-#endif
-#ifdef __WIN32__
- if (SDL_SystemRAM <= 0) {
- MEMORYSTATUSEX stat;
- stat.dwLength = sizeof(stat);
- if (GlobalMemoryStatusEx(&stat)) {
- SDL_SystemRAM = (int)(stat.ullTotalPhys / (1024 * 1024));
- }
- }
-#endif
- }
- return SDL_SystemRAM;
-}
-
-
-#ifdef TEST_MAIN
-
-#include <stdio.h>
-
-int
-main()
-{
- printf("CPU count: %d\n", SDL_GetCPUCount());
- printf("CPU type: %s\n", SDL_GetCPUType());
- printf("CPU name: %s\n", SDL_GetCPUName());
- printf("CacheLine size: %d\n", SDL_GetCPUCacheLineSize());
- printf("RDTSC: %d\n", SDL_HasRDTSC());
- printf("Altivec: %d\n", SDL_HasAltiVec());
- printf("MMX: %d\n", SDL_HasMMX());
- printf("3DNow: %d\n", SDL_Has3DNow());
- printf("SSE: %d\n", SDL_HasSSE());
- printf("SSE2: %d\n", SDL_HasSSE2());
- printf("SSE3: %d\n", SDL_HasSSE3());
- printf("SSE4.1: %d\n", SDL_HasSSE41());
- printf("SSE4.2: %d\n", SDL_HasSSE42());
- printf("AVX: %d\n", SDL_HasAVX());
- printf("RAM: %d MB\n", SDL_GetSystemRAM());
- return 0;
-}
-
-#endif /* TEST_MAIN */
-
-/* vi: set ts=4 sw=4 expandtab: */
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/d1484ae0/DocFormats/platform/3rdparty/SDL2-2.0.3/src/dynapi/SDL_dynapi.c
----------------------------------------------------------------------
diff --git a/DocFormats/platform/3rdparty/SDL2-2.0.3/src/dynapi/SDL_dynapi.c b/DocFormats/platform/3rdparty/SDL2-2.0.3/src/dynapi/SDL_dynapi.c
deleted file mode 100644
index 220ec9b..0000000
--- a/DocFormats/platform/3rdparty/SDL2-2.0.3/src/dynapi/SDL_dynapi.c
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2014 Sam Lantinga <sl...@libsdl.org>
-
- 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.
-
- 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:
-
- 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"
-#include "SDL_dynapi.h"
-
-#if SDL_DYNAMIC_API
-
-#include "SDL.h"
-
-/* !!! FIXME: Shouldn't these be included in SDL.h? */
-#include "SDL_shape.h"
-#include "SDL_syswm.h"
-
-/* This is the version of the dynamic API. This doesn't match the SDL version
- and should not change until there's been a major revamp in API/ABI.
- So 2.0.5 adds functions over 2.0.4? This number doesn't change;
- the sizeof (jump_table) changes instead. But 2.1.0 changes how a function
- works in an incompatible way or removes a function? This number changes,
- since sizeof (jump_table) isn't sufficient anymore. It's likely
- we'll forget to bump every time we add a function, so this is the
- failsafe switch for major API change decisions. Respect it and use it
- sparingly. */
-#define SDL_DYNAPI_VERSION 1
-
-static void SDL_InitDynamicAPI(void);
-
-
-/* BE CAREFUL CALLING ANY SDL CODE IN HERE, IT WILL BLOW UP.
- Even self-contained stuff might call SDL_Error and break everything. */
-
-
-/* behold, the macro salsa! */
-
-/* !!! FIXME: ...disabled...until we write it. :) */
-#define DISABLE_JUMP_MAGIC 1
-
-#if DISABLE_JUMP_MAGIC
-/* Can't use the macro for varargs nonsense. This is atrocious. */
-#define SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, logname, prio) \
- _static void SDL_Log##logname##name(int category, const char *fmt, ...) { \
- va_list ap; initcall; va_start(ap, fmt); \
- jump_table.SDL_LogMessageV(category, SDL_LOG_PRIORITY_##prio, fmt, ap); \
- va_end(ap); \
- }
-
-#define SDL_DYNAPI_VARARGS(_static, name, initcall) \
- _static int SDL_SetError##name(const char *fmt, ...) { \
- char buf[512]; /* !!! FIXME: dynamic allocation */ \
- va_list ap; initcall; va_start(ap, fmt); \
- jump_table.SDL_vsnprintf(buf, sizeof (buf), fmt, ap); \
- va_end(ap); \
- return jump_table.SDL_SetError("%s", buf); \
- } \
- _static int SDL_sscanf##name(const char *buf, const char *fmt, ...) { \
- int retval; va_list ap; initcall; va_start(ap, fmt); \
- retval = jump_table.SDL_vsscanf(buf, fmt, ap); \
- va_end(ap); \
- return retval; \
- } \
- _static int SDL_snprintf##name(char *buf, size_t buflen, const char *fmt, ...) { \
- int retval; va_list ap; initcall; va_start(ap, fmt); \
- retval = jump_table.SDL_vsnprintf(buf, buflen, fmt, ap); \
- va_end(ap); \
- return retval; \
- } \
- _static void SDL_Log##name(const char *fmt, ...) { \
- va_list ap; initcall; va_start(ap, fmt); \
- jump_table.SDL_LogMessageV(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, fmt, ap); \
- va_end(ap); \
- } \
- _static void SDL_LogMessage##name(int category, SDL_LogPriority priority, const char *fmt, ...) { \
- va_list ap; initcall; va_start(ap, fmt); \
- jump_table.SDL_LogMessageV(category, priority, fmt, ap); \
- va_end(ap); \
- } \
- SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Verbose, VERBOSE) \
- SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Debug, DEBUG) \
- SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Info, INFO) \
- SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Warn, WARN) \
- SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Error, ERROR) \
- SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Critical, CRITICAL)
-#endif
-
-
-/* Typedefs for function pointers for jump table, and predeclare funcs */
-/* The DEFAULT funcs will init jump table and then call real function. */
-/* The REAL funcs are the actual functions, name-mangled to not clash. */
-#define SDL_DYNAPI_PROC(rc,fn,params,args,ret) \
- typedef rc (*SDL_DYNAPIFN_##fn) params; \
- static rc fn##_DEFAULT params; \
- extern rc fn##_REAL params;
-#include "SDL_dynapi_procs.h"
-#undef SDL_DYNAPI_PROC
-
-/* The jump table! */
-typedef struct {
- #define SDL_DYNAPI_PROC(rc,fn,params,args,ret) SDL_DYNAPIFN_##fn fn;
- #include "SDL_dynapi_procs.h"
- #undef SDL_DYNAPI_PROC
-} SDL_DYNAPI_jump_table;
-
-/* Predeclare the default functions for initializing the jump table. */
-#define SDL_DYNAPI_PROC(rc,fn,params,args,ret) static rc fn##_DEFAULT params;
-#include "SDL_dynapi_procs.h"
-#undef SDL_DYNAPI_PROC
-
-/* The actual jump table. */
-static SDL_DYNAPI_jump_table jump_table = {
- #define SDL_DYNAPI_PROC(rc,fn,params,args,ret) fn##_DEFAULT,
- #include "SDL_dynapi_procs.h"
- #undef SDL_DYNAPI_PROC
-};
-
-/* Default functions init the function table then call right thing. */
-#if DISABLE_JUMP_MAGIC
-#define SDL_DYNAPI_PROC(rc,fn,params,args,ret) \
- static rc fn##_DEFAULT params { \
- SDL_InitDynamicAPI(); \
- ret jump_table.fn args; \
- }
-#define SDL_DYNAPI_PROC_NO_VARARGS 1
-#include "SDL_dynapi_procs.h"
-#undef SDL_DYNAPI_PROC
-#undef SDL_DYNAPI_PROC_NO_VARARGS
-SDL_DYNAPI_VARARGS(static, _DEFAULT, SDL_InitDynamicAPI())
-#else
-/* !!! FIXME: need the jump magic. */
-#error Write me.
-#endif
-
-/* Public API functions to jump into the jump table. */
-#if DISABLE_JUMP_MAGIC
-#define SDL_DYNAPI_PROC(rc,fn,params,args,ret) \
- rc fn params { ret jump_table.fn args; }
-#define SDL_DYNAPI_PROC_NO_VARARGS 1
-#include "SDL_dynapi_procs.h"
-#undef SDL_DYNAPI_PROC
-#undef SDL_DYNAPI_PROC_NO_VARARGS
-SDL_DYNAPI_VARARGS(,,)
-#else
-/* !!! FIXME: need the jump magic. */
-#error Write me.
-#endif
-
-
-
-/* Here's the exported entry point that fills in the jump table. */
-/* Use specific types when an "int" might suffice to keep this sane. */
-typedef Sint32 (SDLCALL *SDL_DYNAPI_ENTRYFN)(Uint32 apiver, void *table, Uint32 tablesize);
-extern DECLSPEC Sint32 SDLCALL SDL_DYNAPI_entry(Uint32, void *, Uint32);
-
-Sint32
-SDL_DYNAPI_entry(Uint32 apiver, void *table, Uint32 tablesize)
-{
- SDL_DYNAPI_jump_table *output_jump_table = (SDL_DYNAPI_jump_table *) table;
-
- if (apiver != SDL_DYNAPI_VERSION) {
- /* !!! FIXME: can maybe handle older versions? */
- return -1; /* not compatible. */
- } else if (tablesize > sizeof (jump_table)) {
- return -1; /* newer version of SDL with functions we can't provide. */
- }
-
- /* Init our jump table first. */
- #define SDL_DYNAPI_PROC(rc,fn,params,args,ret) jump_table.fn = fn##_REAL;
- #include "SDL_dynapi_procs.h"
- #undef SDL_DYNAPI_PROC
-
- /* Then the external table... */
- if (output_jump_table != &jump_table) {
- jump_table.SDL_memcpy(output_jump_table, &jump_table, tablesize);
- }
-
- /* Safe to call SDL functions now; jump table is initialized! */
-
- return 0; /* success! */
-}
-
-
-/* Obviously we can't use SDL_LoadObject() to load SDL. :) */
-/* Also obviously, we never close the loaded library. */
-#if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__)
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN 1
-#endif
-#include <windows.h>
-static SDL_INLINE void *get_sdlapi_entry(const char *fname, const char *sym)
-{
- HANDLE lib = LoadLibraryA(fname);
- return lib ? GetProcAddress(lib, sym) : NULL;
-}
-
-#elif defined(__HAIKU__)
-#include <os/kernel/image.h>
-static SDL_INLINE void *get_sdlapi_entry(const char *fname, const char *sym)
-{
- image_id lib = load_add_on(fname);
- void *retval = NULL;
- if ((lib < 0) || (get_image_symbol(lib, sym, B_SYMBOL_TYPE_TEXT, &retval) != B_NO_ERROR)) {
- retval = NULL;
- }
- return retval;
-}
-#elif defined(unix) || defined(__unix__) || defined(__APPLE__)
-#include <dlfcn.h>
-static SDL_INLINE void *get_sdlapi_entry(const char *fname, const char *sym)
-{
- void *lib = dlopen(fname, RTLD_NOW | RTLD_LOCAL);
- return lib ? dlsym(lib, sym) : NULL;
-}
-#else
-#error Please define your platform.
-#endif
-
-
-static void
-SDL_InitDynamicAPILocked(void)
-{
- const char *libname = SDL_getenv_REAL("SDL_DYNAMIC_API");
- SDL_DYNAPI_ENTRYFN entry = SDL_DYNAPI_entry; /* funcs from here by default. */
-
- if (libname) {
- entry = (SDL_DYNAPI_ENTRYFN) get_sdlapi_entry(libname, "SDL_DYNAPI_entry");
- if (!entry) {
- /* !!! FIXME: fail to startup here instead? */
- /* !!! FIXME: definitely warn user. */
- /* Just fill in the function pointers from this library. */
- entry = SDL_DYNAPI_entry;
- }
- }
-
- if (entry(SDL_DYNAPI_VERSION, &jump_table, sizeof (jump_table)) < 0) {
- /* !!! FIXME: fail to startup here instead? */
- /* !!! FIXME: definitely warn user. */
- /* Just fill in the function pointers from this library. */
- if (entry != SDL_DYNAPI_entry) {
- if (!SDL_DYNAPI_entry(SDL_DYNAPI_VERSION, &jump_table, sizeof (jump_table))) {
- /* !!! FIXME: now we're screwed. Should definitely abort now. */
- }
- }
- }
-
- /* we intentionally never close the newly-loaded lib, of course. */
-}
-
-static void
-SDL_InitDynamicAPI(void)
-{
- /* So the theory is that every function in the jump table defaults to
- * calling this function, and then replaces itself with a version that
- * doesn't call this function anymore. But it's possible that, in an
- * extreme corner case, you can have a second thread hit this function
- * while the jump table is being initialized by the first.
- * In this case, a spinlock is really painful compared to what spinlocks
- * _should_ be used for, but this would only happen once, and should be
- * insanely rare, as you would have to spin a thread outside of SDL (as
- * SDL_CreateThread() would also call this function before building the
- * new thread).
- */
- static volatile SDL_bool already_initialized = SDL_FALSE;
-
- /* SDL_AtomicLock calls SDL mutex functions to emulate if
- SDL_ATOMIC_DISABLED, which we can't do here, so in such a
- configuration, you're on your own. */
- #if !SDL_ATOMIC_DISABLED
- static SDL_SpinLock lock = 0;
- SDL_AtomicLock_REAL(&lock);
- #endif
-
- if (!already_initialized) {
- SDL_InitDynamicAPILocked();
- already_initialized = SDL_TRUE;
- }
-
- #if !SDL_ATOMIC_DISABLED
- SDL_AtomicUnlock_REAL(&lock);
- #endif
-}
-
-#endif /* SDL_DYNAMIC_API */
-
-/* vi: set ts=4 sw=4 expandtab: */
-
http://git-wip-us.apache.org/repos/asf/incubator-corinthia/blob/d1484ae0/DocFormats/platform/3rdparty/SDL2-2.0.3/src/dynapi/SDL_dynapi.h
----------------------------------------------------------------------
diff --git a/DocFormats/platform/3rdparty/SDL2-2.0.3/src/dynapi/SDL_dynapi.h b/DocFormats/platform/3rdparty/SDL2-2.0.3/src/dynapi/SDL_dynapi.h
deleted file mode 100644
index d318552..0000000
--- a/DocFormats/platform/3rdparty/SDL2-2.0.3/src/dynapi/SDL_dynapi.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2014 Sam Lantinga <sl...@libsdl.org>
-
- 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.
-
- 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:
-
- 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.
-*/
-
-#ifndef _SDL_dynapi_h
-#define _SDL_dynapi_h
-
-/* IMPORTANT:
- This is the master switch to disabling the dynamic API. We made it so you
- have to hand-edit an internal source file in SDL to turn it off; you
- can do it if you want it badly enough, but hopefully you won't want to.
- You should understand the ramifications of turning this off: it makes it
- hard to update your SDL in the field, and impossible if you've statically
- linked SDL into your app. Understand that platforms change, and if we can't
- drop in an updated SDL, your application can definitely break some time
- in the future, even if it's fine today.
- To be sure, as new system-level video and audio APIs are introduced, an
- updated SDL can transparently take advantage of them, but your program will
- not without this feature. Think hard before turning it off.
-*/
-#ifdef SDL_DYNAMIC_API /* Tried to force it on the command line? */
-#error Nope, you have to edit this file to force this off.
-#endif
-
-#ifdef __APPLE__
-#include "TargetConditionals.h"
-#endif
-
-#if TARGET_OS_IPHONE /* probably not useful on iOS. */
-#define SDL_DYNAMIC_API 0
-#elif SDL_BUILDING_WINRT /* probaly not useful on WinRT, given current .dll loading restrictions */
-#define SDL_DYNAMIC_API 0
-#else /* everyone else. */
-#define SDL_DYNAMIC_API 1
-#endif
-
-#endif
-
-/* vi: set ts=4 sw=4 expandtab: */