From dfa2f9bdfb74408b0ad5013db32cfc30faf69060 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sat, 29 Oct 2011 00:57:45 -0400 Subject: [PATCH 01/24] Removed tabs and DOS endlines from SDL_blit_copy.c ... --- src/video/SDL_blit_copy.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/video/SDL_blit_copy.c b/src/video/SDL_blit_copy.c index 65b46a615..96b727ee0 100644 --- a/src/video/SDL_blit_copy.c +++ b/src/video/SDL_blit_copy.c @@ -61,22 +61,21 @@ SDL_memcpyMMX(Uint8 * dst, const Uint8 * src, int len) { int i; - __m64* d64 = (__m64*)dst; - __m64* s64 = (__m64*)src; - - for(i= len / 64; i--;) { - - d64[0] = s64[0]; - d64[1] = s64[1]; - d64[2] = s64[2]; - d64[3] = s64[3]; - d64[4] = s64[4]; - d64[5] = s64[5]; - d64[6] = s64[6]; - d64[7] = s64[7]; - - d64 += 8; - s64 += 8; + __m64* d64 = (__m64*)dst; + __m64* s64 = (__m64*)src; + + for(i= len / 64; i--;) { + d64[0] = s64[0]; + d64[1] = s64[1]; + d64[2] = s64[2]; + d64[3] = s64[3]; + d64[4] = s64[4]; + d64[5] = s64[5]; + d64[6] = s64[6]; + d64[7] = s64[7]; + + d64 += 8; + s64 += 8; } if (len & 63) From 5bc4851e3a8b0a9ac3de1594de6a80aaf052334a Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sat, 29 Oct 2011 01:03:50 -0400 Subject: [PATCH 02/24] SDL_memcpyMMX(): Make sure srcskip and dstskip are 8-byte aligned. Thanks to Patrick Baggett for the fix! --- src/video/SDL_blit_copy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video/SDL_blit_copy.c b/src/video/SDL_blit_copy.c index 96b727ee0..c0cdd23a1 100644 --- a/src/video/SDL_blit_copy.c +++ b/src/video/SDL_blit_copy.c @@ -127,7 +127,7 @@ SDL_BlitCopy(SDL_BlitInfo * info) #endif #ifdef __MMX__ - if (SDL_HasMMX()) { + if (SDL_HasMMX() && !(srcskip & 7) && !(dstskip & 7)) { while (h--) { SDL_memcpyMMX(dst, src, w); src += srcskip; From cde3a8ca19e4488583fd2673486eec1a570466cb Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sat, 29 Oct 2011 01:11:47 -0400 Subject: [PATCH 03/24] SDL_memcpyMMX(): Fixed handling of overflow bytes. Thanks to Mason Wheeler for the fix! --- src/video/SDL_blit_copy.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/video/SDL_blit_copy.c b/src/video/SDL_blit_copy.c index c0cdd23a1..a9f98eb73 100644 --- a/src/video/SDL_blit_copy.c +++ b/src/video/SDL_blit_copy.c @@ -59,6 +59,7 @@ SDL_memcpySSE(Uint8 * dst, const Uint8 * src, int len) static __inline__ void SDL_memcpyMMX(Uint8 * dst, const Uint8 * src, int len) { + const int remain = (len & 63); int i; __m64* d64 = (__m64*)dst; @@ -78,8 +79,11 @@ SDL_memcpyMMX(Uint8 * dst, const Uint8 * src, int len) s64 += 8; } - if (len & 63) - SDL_memcpy(dst, src, len & 63); + if (remain) + { + const int skip = len - remain; + SDL_memcpy(dst + skip, src + skip, remain); + } } #endif /* __MMX__ */ From 26f4ab2d50d26a058d908b5c414b4b09f435f6ad Mon Sep 17 00:00:00 2001 From: Andreas Schiffler Date: Sat, 29 Oct 2011 23:34:19 -0700 Subject: [PATCH 04/24] Add clipboard tests --- .../tests/testclipboard/testclipboard.c | 146 +++++++++++++++++- 1 file changed, 140 insertions(+), 6 deletions(-) diff --git a/test/test-automation/tests/testclipboard/testclipboard.c b/test/test-automation/tests/testclipboard/testclipboard.c index 453844560..6fd272b33 100644 --- a/test/test-automation/tests/testclipboard/testclipboard.c +++ b/test/test-automation/tests/testclipboard/testclipboard.c @@ -5,7 +5,6 @@ #include "../../include/SDL_test.h" - /*! * Note: Add test for clipboard here * @@ -13,22 +12,157 @@ /* Test cases */ static const TestCaseReference test1 = - (TestCaseReference){ "clipboard_test", "description", TEST_DISABLED, 0, 0 }; + (TestCaseReference){ "clipboard_testHasClipboardText", "Check call to SDL_HasClipboardText", TEST_ENABLED, 0, 0 }; + +static const TestCaseReference test2 = + (TestCaseReference){ "clipboard_testGetClipboardText", "Check call to SDL_GetClipboardText", TEST_ENABLED, 0, 0 }; + +static const TestCaseReference test3 = + (TestCaseReference){ "clipboard_testSetClipboardText", "Check call to SDL_SetClipboardText", TEST_ENABLED, 0, 0 }; + +static const TestCaseReference test4 = + (TestCaseReference){ "clipboard_testClipboardTextFunctions", "End-to-end test of SDL_xyzClipboardText functions", TEST_ENABLED, 0, 0 }; /* Test suite */ extern const TestCaseReference *testSuite[] = { - &test1, NULL + &test1, &test2, &test3, &test4, NULL }; TestCaseReference **QueryTestSuite() { return (TestCaseReference **)testSuite; } +void +SetUp(void *arg) +{ + /* Start SDL video */ + int ret = SDL_InitSubSystem( SDL_INIT_VIDEO ); + AssertTrue(ret==0, "SDL_Init(SDL_INIT_VIDEO) failed: %s", SDL_GetError()); +} + +void +TearDown(void *arg) +{ + /* Quit SDL video */ + SDL_QuitSubSystem(SDL_INIT_VIDEO); +} + /** - * @brief Document test case here + * \brief Check call to SDL_HasClipboardText + * + * \sa + * http://wiki.libsdl.org/moin.cgi/SDL_HasClipboardText */ int -clipboard_test(void *arg) +clipboard_testHasClipboardText(void *arg) { - AssertPass(""); + SDL_bool result; + result = SDL_HasClipboardText(); + AssertPass("Call to SDL_HasClipboardText succeeded"); +} + +/** + * \brief Check call to SDL_GetClipboardText + * + * \sa + * http://wiki.libsdl.org/moin.cgi/SDL_GetClipboardText + */ +int +clipboard_testGetClipboardText(void *arg) +{ + char *result; + result = SDL_GetClipboardText(); + AssertPass("Call to SDL_GetClipboardText succeeded"); +} + +/** + * \brief Check call to SDL_SetClipboardText + * \sa + * http://wiki.libsdl.org/moin.cgi/SDL_SetClipboardText + */ +int +clipboard_testSetClipboardText(void *arg) +{ + char *textRef = RandomAsciiString(); + char *text = strdup(textRef); + int result; + result = SDL_SetClipboardText((const char *)text); + AssertTrue( + result == 0, + "Call to SDL_SetClipboardText failed with error %i: %s", + result, SDL_GetError()); + AssertTrue( + strcmp(textRef, text) == 0, + "SDL_SetClipboardText modified input string: expected %s, got %s", + textRef, text); + + /* Cleanup */ + if (textRef) free(textRef); + if (text) free(text); +} + + +/** + * \brief End-to-end test of SDL_xyzClipboardText functions + * \sa + * http://wiki.libsdl.org/moin.cgi/SDL_HasClipboardText + * http://wiki.libsdl.org/moin.cgi/SDL_GetClipboardText + * http://wiki.libsdl.org/moin.cgi/SDL_SetClipboardText + */ +int +clipboard_testClipboardTextFunctions(void *arg) +{ + char *textRef = RandomAsciiString(); + char *text = strdup(textRef); + SDL_bool boolResult; + int intResult; + char *charResult; + + /* Clear clipboard text state */ + boolResult = SDL_HasClipboardText(); + if (boolResult == SDL_TRUE) { + intResult = SDL_SetClipboardText((const char *)NULL); + AssertTrue( + intResult == 0, + "Call to SDL_SetClipboardText("") failed with error %i: %s", + intResult, SDL_GetError()); + charResult = SDL_GetClipboardText(); + boolResult = SDL_HasClipboardText(); + AssertTrue( + boolResult == SDL_FALSE, + "SDL_HasClipboardText returned TRUE, expected FALSE"); + } + + /* Empty clipboard */ + charResult = SDL_GetClipboardText(); + AssertTrue( + charResult != NULL, + "SDL_GetClipboardText returned NULL"); + AssertTrue( + strlen(charResult) == 0, + "SDL_GetClipboardText returned string with length >0: got length %i", + strlen(charResult)); + intResult = SDL_SetClipboardText((const char *)text); + AssertTrue( + intResult == 0, + "Call to SDL_SetClipboardText failed with error %i: %s", + intResult, SDL_GetError()); + AssertTrue( + strcmp(textRef, text) == 0, + "SDL_SetClipboardText modified input string: expected %s, got %s", + textRef, text); + boolResult = SDL_HasClipboardText(); + AssertTrue( + boolResult == SDL_TRUE, + "SDL_HasClipboardText returned FALSE, expected TRUE"); + charResult = SDL_GetClipboardText(); + AssertTrue( + strcmp(textRef, charResult) == 0, + "SDL_GetClipboardText did not return correst string: expected %s, got %s", + textRef, charResult); + + /* Cleanup */ + if (textRef) free(textRef); + if (text) free(text); + if (charResult) free(charResult); } From 83af41000afc41b6e256d0e98c74f6d4d902f879 Mon Sep 17 00:00:00 2001 From: Andreas Schiffler Date: Sat, 29 Oct 2011 23:43:59 -0700 Subject: [PATCH 05/24] Update SDL_HasClipboardText functions to return value based on clipboard content; Fix memory leak in fallback SetClipboard implementation --- include/SDL_clipboard.h | 2 +- src/video/SDL_clipboard.c | 5 ++- src/video/bwindow/SDL_bclipboard.cc | 39 ++++++++++-------------- src/video/cocoa/SDL_cocoaclipboard.m | 22 +++---------- src/video/windows/SDL_windowsclipboard.c | 12 +++++--- src/video/x11/SDL_x11clipboard.c | 21 +++++-------- 6 files changed, 41 insertions(+), 60 deletions(-) diff --git a/include/SDL_clipboard.h b/include/SDL_clipboard.h index fa2ee0855..7c60d6373 100644 --- a/include/SDL_clipboard.h +++ b/include/SDL_clipboard.h @@ -55,7 +55,7 @@ extern DECLSPEC int SDLCALL SDL_SetClipboardText(const char *text); extern DECLSPEC char * SDLCALL SDL_GetClipboardText(void); /** - * \brief Returns whether the clipboard has text + * \brief Returns a flag indicating whether the clipboard exists and contains a text string that it non-empty * * \sa SDL_GetClipboardText() */ diff --git a/src/video/SDL_clipboard.c b/src/video/SDL_clipboard.c index fbfcfb9da..3cc233a89 100644 --- a/src/video/SDL_clipboard.c +++ b/src/video/SDL_clipboard.c @@ -35,6 +35,9 @@ SDL_SetClipboardText(const char *text) if (_this->SetClipboardText) { return _this->SetClipboardText(_this, text); } else { + if (_this->clipboard_text) { + SDL_free(_this->clipboard_text); + } _this->clipboard_text = SDL_strdup(text); return 0; } @@ -64,7 +67,7 @@ SDL_HasClipboardText(void) if (_this->HasClipboardText) { return _this->HasClipboardText(_this); } else { - if (_this->clipboard_text) { + if ((_this->clipboard_text) && (SDL_strlen(_this->clipboard_text)>0)) { return SDL_TRUE; } else { return SDL_FALSE; diff --git a/src/video/bwindow/SDL_bclipboard.cc b/src/video/bwindow/SDL_bclipboard.cc index 90914a1fd..a4560827a 100644 --- a/src/video/bwindow/SDL_bclipboard.cc +++ b/src/video/bwindow/SDL_bclipboard.cc @@ -51,8 +51,9 @@ int BE_SetClipboardText(_THIS, const char *text) { char *BE_GetClipboardText(_THIS) { BMessage *clip = NULL; - const char *text; + const char *text = NULL; ssize_t length; + char *result; if(be_clipboard->Lock()) { if((clip = be_clipboard->Data())) { /* Presumably the string of characters is ascii-format */ @@ -60,37 +61,29 @@ char *BE_GetClipboardText(_THIS) { &length); } else { be_clipboard->Unlock(); - return NULL; } be_clipboard->Unlock(); + } + + if (!text) { + result = SDL_strdup(""); } else { - return NULL; + /* Copy the data and pass on to SDL */ + result = (char*)SDL_calloc(1, sizeof(char*)*length); + SDL_strlcpy(result, text, length); } - /* Copy the data and pass on to SDL */ - char *result = (char*)SDL_calloc(1, sizeof(char*)*length); - SDL_strlcpy(result, text, length); - return result; } SDL_bool BE_HasClipboardText(_THIS) { - BMessage *clip = NULL; - const char *text; - ssize_t length; - SDL_bool retval = SDL_FALSE; - - if(be_clipboard->Lock()) { - if((clip = be_clipboard->Data())) { - /* Presumably the string of characters is ascii-format */ - clip->FindData("text/plain", B_MIME_TYPE, (const void**)&text, - &length); - if( text ) retval = SDL_TRUE; - } - be_clipboard->Unlock(); - } - return retval; - + SDL_bool result = SDL_FALSE; + char *text = BE_GetClipboardText(_this); + if (text) { + result = (SDL_strlen(text)>0) ? SDL_TRUE : SDL_FALSE; + SDL_free(text); + } + return result; } #ifdef __cplusplus diff --git a/src/video/cocoa/SDL_cocoaclipboard.m b/src/video/cocoa/SDL_cocoaclipboard.m index 3166708ce..e575f2ca1 100644 --- a/src/video/cocoa/SDL_cocoaclipboard.m +++ b/src/video/cocoa/SDL_cocoaclipboard.m @@ -94,24 +94,12 @@ SDL_bool Cocoa_HasClipboardText(_THIS) { - NSAutoreleasePool *pool; - NSPasteboard *pasteboard; - NSString *format = GetTextFormat(_this); - NSString *available; - SDL_bool result; - - pool = [[NSAutoreleasePool alloc] init]; - - pasteboard = [NSPasteboard generalPasteboard]; - available = [pasteboard availableTypeFromArray: [NSArray arrayWithObject:format]]; - if ([available isEqualToString:format]) { - result = SDL_TRUE; - } else { - result = SDL_FALSE; + SDL_bool result = SDL_FALSE; + char *text = Cocoa_GetClipboardText(_this); + if (text) { + result = (SDL_strlen(text)>0) ? SDL_TRUE : SDL_FALSE; + SDL_free(text); } - - [pool release]; - return result; } diff --git a/src/video/windows/SDL_windowsclipboard.c b/src/video/windows/SDL_windowsclipboard.c index c854b7f6f..12d02281f 100644 --- a/src/video/windows/SDL_windowsclipboard.c +++ b/src/video/windows/SDL_windowsclipboard.c @@ -136,11 +136,13 @@ WIN_GetClipboardText(_THIS) SDL_bool WIN_HasClipboardText(_THIS) { - if (IsClipboardFormatAvailable(TEXT_FORMAT)) { - return SDL_TRUE; - } else { - return SDL_FALSE; - } + SDL_bool result = SDL_FALSE; + char *text = WIN_GetClipboardText(_this); + if (text) { + result = (SDL_strlen(text)>0) ? SDL_TRUE : SDL_FALSE; + SDL_free(text); + } + return result; } void diff --git a/src/video/x11/SDL_x11clipboard.c b/src/video/x11/SDL_x11clipboard.c index e2c8d9ae9..71f7c9390 100644 --- a/src/video/x11/SDL_x11clipboard.c +++ b/src/video/x11/SDL_x11clipboard.c @@ -129,25 +129,20 @@ X11_GetClipboardText(_THIS) if (!text) { text = SDL_strdup(""); } + return text; } SDL_bool X11_HasClipboardText(_THIS) { - /* Not an easy way to tell with X11, as far as I know... */ - char *text; - SDL_bool retval; - - text = X11_GetClipboardText(_this); - if (*text) { - retval = SDL_TRUE; - } else { - retval = SDL_FALSE; - } - SDL_free(text); - - return retval; + SDL_bool result = SDL_FALSE; + char *text = X11_GetClipboardText(_this); + if (text) { + result = (SDL_strlen(text)>0) ? SDL_TRUE : SDL_FALSE; + SDL_free(text); + } + return result; } #endif /* SDL_VIDEO_DRIVER_X11 */ From 93c63d5c60fe55707baf10a2beeef639132b2dc5 Mon Sep 17 00:00:00 2001 From: Andreas Schiffler Date: Sun, 30 Oct 2011 00:19:13 -0700 Subject: [PATCH 06/24] Fix sdl-haiku buildbot compiler warnings --- src/main/beos/SDL_BApp.h | 3 +++ src/video/SDL_bmp.c | 2 +- src/video/bwindow/SDL_BWin.h | 2 -- src/video/bwindow/SDL_bclipboard.cc | 1 + src/video/bwindow/SDL_bframebuffer.cc | 1 - src/video/bwindow/SDL_bkeyboard.cc | 2 +- src/video/bwindow/SDL_bmodes.cc | 5 +++++ src/video/bwindow/SDL_bopengl.cc | 1 + 8 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/beos/SDL_BApp.h b/src/main/beos/SDL_BApp.h index 3dd3718cc..9f9d5a25f 100644 --- a/src/main/beos/SDL_BApp.h +++ b/src/main/beos/SDL_BApp.h @@ -175,6 +175,9 @@ class SDL_BApp : public BApplication { _PushBackWindow(win); return i; } + + /* TODO: error handling */ + return 0; } /* FIXME: Bad coding practice, but I can't include SDL_BWin.h here. Is diff --git a/src/video/SDL_bmp.c b/src/video/SDL_bmp.c index ec1e541b2..91cbe43cd 100644 --- a/src/video/SDL_bmp.c +++ b/src/video/SDL_bmp.c @@ -49,7 +49,7 @@ SDL_Surface * SDL_LoadBMP_RW(SDL_RWops * src, int freesrc) { SDL_bool was_error; - long fp_offset; + long fp_offset = 0; int bmpPitch; int i, pad; SDL_Surface *surface; diff --git a/src/video/bwindow/SDL_BWin.h b/src/video/bwindow/SDL_BWin.h index ee770d5cd..9967decd9 100644 --- a/src/video/bwindow/SDL_BWin.h +++ b/src/video/bwindow/SDL_BWin.h @@ -300,7 +300,6 @@ class SDL_BWin:public BDirectWindow switch (msg->what) { case B_MOUSE_MOVED: - where; int32 transit; if (msg->FindPoint("where", &where) == B_OK && msg->FindInt32("be:transit", &transit) == B_OK) { @@ -440,7 +439,6 @@ class SDL_BWin:public BDirectWindow _MouseFocusEvent(false); } } else { - static int x = 0, y = 0; /* Change mouse focus */ if (!_mouse_focused) { _MouseFocusEvent(true); diff --git a/src/video/bwindow/SDL_bclipboard.cc b/src/video/bwindow/SDL_bclipboard.cc index a4560827a..028dcac99 100644 --- a/src/video/bwindow/SDL_bclipboard.cc +++ b/src/video/bwindow/SDL_bclipboard.cc @@ -47,6 +47,7 @@ int BE_SetClipboardText(_THIS, const char *text) { } be_clipboard->Unlock(); } + return 0; } char *BE_GetClipboardText(_THIS) { diff --git a/src/video/bwindow/SDL_bframebuffer.cc b/src/video/bwindow/SDL_bframebuffer.cc index f3fb8ef5b..7dbd06717 100644 --- a/src/video/bwindow/SDL_bframebuffer.cc +++ b/src/video/bwindow/SDL_bframebuffer.cc @@ -115,7 +115,6 @@ int BE_UpdateWindowFramebuffer(_THIS, SDL_Window * window, int32 BE_DrawThread(void *data) { SDL_BWin *bwin = (SDL_BWin*)data; - SDL_Window *window = _GetBeApp()->GetSDLWindow(bwin->GetID()); BScreen bscreen; if(!bscreen.IsValid()) { diff --git a/src/video/bwindow/SDL_bkeyboard.cc b/src/video/bwindow/SDL_bkeyboard.cc index c153539ca..03ba7cac2 100644 --- a/src/video/bwindow/SDL_bkeyboard.cc +++ b/src/video/bwindow/SDL_bkeyboard.cc @@ -158,7 +158,7 @@ void BE_InitOSKeymap() { } SDL_Scancode BE_GetScancodeFromBeKey(int32 bkey) { - if(bkey > 0 && bkey < SDL_TABLESIZE(keymap)) { + if(bkey > 0 && bkey < (int32)SDL_TABLESIZE(keymap)) { return keymap[bkey]; } else { return SDL_SCANCODE_UNKNOWN; diff --git a/src/video/bwindow/SDL_bmodes.cc b/src/video/bwindow/SDL_bmodes.cc index 06b412b64..0651cf937 100644 --- a/src/video/bwindow/SDL_bmodes.cc +++ b/src/video/bwindow/SDL_bmodes.cc @@ -184,6 +184,10 @@ int32 BE_BPPToSDLPxFormat(int32 bpp) { return SDL_PIXELFORMAT_INDEX4LSB; break; } + + /* May never get here, but safer and needed to shut up compiler */ + SDL_SetError("Invalid bpp value"); + return 0; } static void _BDisplayModeToSdlDisplayMode(display_mode *bmode, @@ -236,6 +240,7 @@ int BE_InitModes(_THIS) { /* TODO: When Haiku supports multiple display screens, call _AddDisplayScreen() for each of them. */ _AddDisplay(&screen); + return 0; } int BE_QuitModes(_THIS) { diff --git a/src/video/bwindow/SDL_bopengl.cc b/src/video/bwindow/SDL_bopengl.cc index 4d372569b..f4cd9c08e 100644 --- a/src/video/bwindow/SDL_bopengl.cc +++ b/src/video/bwindow/SDL_bopengl.cc @@ -59,6 +59,7 @@ int BE_GL_LoadLibrary(_THIS, const char *path) SDL_arraysize(_this->gl_config.driver_path)); } } + return 0; } void *BE_GL_GetProcAddress(_THIS, const char *proc) From 047125565a2da5bac29c34364c0772cc07aa528d Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 30 Oct 2011 17:31:59 -0400 Subject: [PATCH 07/24] Fixed typo - thanks Sheena! --- include/SDL_log.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/SDL_log.h b/include/SDL_log.h index b48e246fa..cd7358418 100644 --- a/include/SDL_log.h +++ b/include/SDL_log.h @@ -121,7 +121,7 @@ extern DECLSPEC void SDLCALL SDL_LogSetPriority(int category, SDL_LogPriority priority); /** - * \brief Set the priority of a particular log category + * \brief Get the priority of a particular log category */ extern DECLSPEC SDL_LogPriority SDLCALL SDL_LogGetPriority(int category); From 06ef6341fa87dccf75e2d659874bf8d262b2118d Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 30 Oct 2011 17:53:54 -0400 Subject: [PATCH 08/24] The draw color affects RenderClear() as well. (thanks to the feedback form to whoever pointed this out) --- include/SDL_render.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/SDL_render.h b/include/SDL_render.h index bf940d0b4..09ea53c47 100644 --- a/include/SDL_render.h +++ b/include/SDL_render.h @@ -389,7 +389,7 @@ extern DECLSPEC void SDLCALL SDL_RenderGetViewport(SDL_Renderer * renderer, SDL_Rect * rect); /** - * \brief Set the color used for drawing operations (Fill and Line). + * \brief Set the color used for drawing operations (Rect, Line and Clear). * * \param r The red value used to draw on the rendering target. * \param g The green value used to draw on the rendering target. @@ -404,7 +404,7 @@ extern DECLSPEC int SDL_SetRenderDrawColor(SDL_Renderer * renderer, Uint8 a); /** - * \brief Get the color used for drawing operations (Fill and Line). + * \brief Get the color used for drawing operations (Rect, Line and Clear). * * \param r A pointer to the red value used to draw on the rendering target. * \param g A pointer to the green value used to draw on the rendering target. From 084a57f08e1229b9731b1523b42dff01e40ce9fe Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 31 Oct 2011 01:59:54 -0400 Subject: [PATCH 09/24] Fixed warnings on iOS --- src/SDL_log.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SDL_log.c b/src/SDL_log.c index 0f9a84873..40aba9354 100644 --- a/src/SDL_log.c +++ b/src/SDL_log.c @@ -258,7 +258,7 @@ SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va_list } /* Make sure we don't exceed array bounds */ - if (priority < 0 || priority >= SDL_NUM_LOG_PRIORITIES) { + if ((int)priority < 0 || priority >= SDL_NUM_LOG_PRIORITIES) { return; } From 074180c12f71bb5e3dcbb302ae32f6f34859f39b Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 31 Oct 2011 02:44:21 -0400 Subject: [PATCH 10/24] SDL_ConvertPixels() returns 0 on success --- include/SDL_surface.h | 2 ++ src/video/SDL_surface.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/SDL_surface.h b/include/SDL_surface.h index 77b582586..f8c95b275 100644 --- a/include/SDL_surface.h +++ b/include/SDL_surface.h @@ -355,6 +355,8 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat /** * \brief Copy a block of pixels of one format to another format + * + * \return 0 on success, or -1 if there was an error */ extern DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height, Uint32 src_format, diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c index b89adcbd0..62c5f5f3d 100644 --- a/src/video/SDL_surface.c +++ b/src/video/SDL_surface.c @@ -952,7 +952,7 @@ int SDL_ConvertPixels(int width, int height, src = (Uint8*)src + src_pitch; dst = (Uint8*)dst + dst_pitch; } - return SDL_TRUE; + return 0; } if (!SDL_CreateSurfaceOnStack(width, height, src_format, (void*)src, From ff4302b26e2cda6031201aae0498416bbc4206f9 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 31 Oct 2011 02:55:21 -0400 Subject: [PATCH 11/24] Implemented RenderReadPixels for the OpenGL ES 2.0 renderer. --- src/render/opengles2/SDL_render_gles2.c | 54 +++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c index bea8791c8..d4773a0a8 100644 --- a/src/render/opengles2/SDL_render_gles2.c +++ b/src/render/opengles2/SDL_render_gles2.c @@ -786,6 +786,8 @@ static int GLES2_RenderDrawLines(SDL_Renderer *renderer, const SDL_Point *points static int GLES2_RenderFillRects(SDL_Renderer *renderer, const SDL_Rect *rects, int count); static int GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect, const SDL_Rect *dstrect); +static int GLES2_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 pixel_format, void * pixels, int pitch); static void GLES2_RenderPresent(SDL_Renderer *renderer); @@ -1047,6 +1049,57 @@ GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *s return 0; } +static int +GLES2_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 pixel_format, void * pixels, int pitch) +{ + SDL_Window *window = renderer->window; + Uint32 temp_format = SDL_PIXELFORMAT_ABGR8888; + void *temp_pixels; + int temp_pitch; + Uint8 *src, *dst, *tmp; + int w, h, length, rows; + int status; + + GLES2_ActivateRenderer(renderer); + + temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format); + temp_pixels = SDL_malloc(rect->h * temp_pitch); + if (!temp_pixels) { + SDL_OutOfMemory(); + return -1; + } + + SDL_GetWindowSize(window, &w, &h); + + glPixelStorei(GL_PACK_ALIGNMENT, 1); + + glReadPixels(rect->x, (h-rect->y)-rect->h, rect->w, rect->h, + GL_RGBA, GL_UNSIGNED_BYTE, temp_pixels); + + /* Flip the rows to be top-down */ + length = rect->w * SDL_BYTESPERPIXEL(temp_format); + src = (Uint8*)temp_pixels + (rect->h-1)*temp_pitch; + dst = (Uint8*)temp_pixels; + tmp = SDL_stack_alloc(Uint8, length); + rows = rect->h / 2; + while (rows--) { + SDL_memcpy(tmp, dst, length); + SDL_memcpy(dst, src, length); + SDL_memcpy(src, tmp, length); + dst += temp_pitch; + src -= temp_pitch; + } + SDL_stack_free(tmp); + + status = SDL_ConvertPixels(rect->w, rect->h, + temp_format, temp_pixels, temp_pitch, + pixel_format, pixels, pitch); + SDL_free(temp_pixels); + + return status; +} + static void GLES2_RenderPresent(SDL_Renderer *renderer) { @@ -1176,6 +1229,7 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags) renderer->RenderDrawLines = &GLES2_RenderDrawLines; renderer->RenderFillRects = &GLES2_RenderFillRects; renderer->RenderCopy = &GLES2_RenderCopy; + renderer->RenderReadPixels = &GLES2_RenderReadPixels; renderer->RenderPresent = &GLES2_RenderPresent; renderer->DestroyTexture = &GLES2_DestroyTexture; renderer->DestroyRenderer = &GLES2_DestroyRenderer; From 60e5a6f8dad4113dcd4f9af8d874328d5b54453e Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 31 Oct 2011 03:06:32 -0400 Subject: [PATCH 12/24] This code works for OpenGL ES 1.1 as well! :) --- src/render/opengles/SDL_render_gles.c | 54 +++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/render/opengles/SDL_render_gles.c b/src/render/opengles/SDL_render_gles.c index 67565612b..b356fc66a 100644 --- a/src/render/opengles/SDL_render_gles.c +++ b/src/render/opengles/SDL_render_gles.c @@ -64,6 +64,8 @@ static int GLES_RenderFillRects(SDL_Renderer * renderer, static int GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * srcrect, const SDL_Rect * dstrect); +static int GLES_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 pixel_format, void * pixels, int pitch); static void GLES_RenderPresent(SDL_Renderer * renderer); static void GLES_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture); @@ -216,6 +218,7 @@ GLES_CreateRenderer(SDL_Window * window, Uint32 flags) renderer->RenderDrawLines = GLES_RenderDrawLines; renderer->RenderFillRects = GLES_RenderFillRects; renderer->RenderCopy = GLES_RenderCopy; + renderer->RenderReadPixels = GLES_RenderReadPixels; renderer->RenderPresent = GLES_RenderPresent; renderer->DestroyTexture = GLES_DestroyTexture; renderer->DestroyRenderer = GLES_DestroyRenderer; @@ -744,6 +747,57 @@ GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, return 0; } +static int +GLES_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 pixel_format, void * pixels, int pitch) +{ + SDL_Window *window = renderer->window; + Uint32 temp_format = SDL_PIXELFORMAT_ABGR8888; + void *temp_pixels; + int temp_pitch; + Uint8 *src, *dst, *tmp; + int w, h, length, rows; + int status; + + GLES_ActivateRenderer(renderer); + + temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format); + temp_pixels = SDL_malloc(rect->h * temp_pitch); + if (!temp_pixels) { + SDL_OutOfMemory(); + return -1; + } + + SDL_GetWindowSize(window, &w, &h); + + glPixelStorei(GL_PACK_ALIGNMENT, 1); + + glReadPixels(rect->x, (h-rect->y)-rect->h, rect->w, rect->h, + GL_RGBA, GL_UNSIGNED_BYTE, temp_pixels); + + /* Flip the rows to be top-down */ + length = rect->w * SDL_BYTESPERPIXEL(temp_format); + src = (Uint8*)temp_pixels + (rect->h-1)*temp_pitch; + dst = (Uint8*)temp_pixels; + tmp = SDL_stack_alloc(Uint8, length); + rows = rect->h / 2; + while (rows--) { + SDL_memcpy(tmp, dst, length); + SDL_memcpy(dst, src, length); + SDL_memcpy(src, tmp, length); + dst += temp_pitch; + src -= temp_pitch; + } + SDL_stack_free(tmp); + + status = SDL_ConvertPixels(rect->w, rect->h, + temp_format, temp_pixels, temp_pitch, + pixel_format, pixels, pitch); + SDL_free(temp_pixels); + + return status; +} + static void GLES_RenderPresent(SDL_Renderer * renderer) { From 43ced8fb5282bece41fa8a93448c90667b8ab837 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 31 Oct 2011 05:56:58 -0400 Subject: [PATCH 13/24] Lots of fixes importing SDL source wholesale into a new iOS project --- include/SDL_config.h.in | 1 - include/SDL_opengl.h | 4 + src/SDL_error_c.h | 3 + src/audio/alsa/SDL_alsa_audio.c | 10 +- src/audio/android/SDL_androidaudio.c | 4 + src/audio/arts/SDL_artsaudio.c | 8 +- src/audio/baudio/SDL_beaudio.cc | 4 + src/audio/bsd/SDL_bsdaudio.c | 4 + src/audio/directsound/SDL_directsound.c | 4 + src/audio/disk/SDL_diskaudio.c | 4 + src/audio/dsp/SDL_dspaudio.c | 4 + src/audio/esd/SDL_esdaudio.c | 8 +- src/audio/fusionsound/SDL_fsaudio.c | 8 +- src/audio/nas/SDL_nasaudio.c | 8 +- src/audio/nds/SDL_ndsaudio.c | 4 + src/audio/paudio/SDL_paudio.c | 4 + src/audio/pulseaudio/SDL_pulseaudio.c | 2 +- src/audio/qsa/SDL_qsa_audio.c | 4 + src/audio/sun/SDL_sunaudio.c | 14 +- src/audio/ums/SDL_umsaudio.c | 556 ------------------ src/audio/ums/SDL_umsaudio.h | 47 -- src/audio/winmm/SDL_winmm.c | 4 + src/audio/xaudio2/SDL_xaudio2.c | 5 +- src/core/android/SDL_android.cpp | 4 + src/core/windows/SDL_windows.c | 4 + src/events/SDL_gesture.c | 31 +- src/events/SDL_keyboard.c | 17 - src/events/SDL_touch.c | 3 +- src/libm/e_atan2.c | 2 +- src/libm/e_log.c | 2 +- src/libm/e_pow.c | 2 +- src/libm/e_rem_pio2.c | 2 +- src/libm/e_sqrt.c | 2 +- src/libm/k_cos.c | 2 +- src/libm/k_rem_pio2.c | 2 +- src/libm/k_sin.c | 2 +- src/libm/{math.h => math_libm.h} | 7 + src/libm/s_atan.c | 2 +- src/libm/s_copysign.c | 2 +- src/libm/s_cos.c | 2 +- src/libm/s_fabs.c | 2 +- src/libm/s_floor.c | 2 +- src/libm/s_scalbn.c | 2 +- src/libm/s_sin.c | 2 +- src/main/android/SDL_android_main.cpp | 6 + src/main/beos/SDL_BeApp.cc | 8 +- src/main/windows/SDL_windows_main.c | 5 + src/power/beos/SDL_syspower.c | 2 +- src/power/linux/SDL_syspower.c | 2 +- src/power/macosx/SDL_syspower.c | 2 +- src/power/nds/SDL_syspower.c | 2 +- .../uikit/SDL_syspower.h} | 9 +- src/power/uikit/SDL_syspower.m | 3 +- src/power/windows/SDL_syspower.c | 2 +- src/render/SDL_render.c | 2 +- src/render/opengles/SDL_render_gles.c | 3 - src/render/opengles2/SDL_render_gles2.c | 3 - src/render/software/SDL_render_sw.c | 1 + src/stdlib/SDL_string.c | 2 +- src/thread/SDL_thread.c | 1 + src/thread/SDL_thread_c.h | 3 +- src/thread/beos/SDL_syssem.c | 4 + src/thread/beos/SDL_systhread.c | 4 + src/thread/irix/SDL_syssem.c | 230 -------- src/thread/irix/SDL_systhread.c | 81 --- src/thread/nds/SDL_systhread.c | 6 - src/thread/windows/SDL_sysmutex.c | 4 + src/thread/windows/SDL_syssem.c | 4 + src/thread/windows/SDL_systhread.c | 4 + src/thread/windows/win_ce_semaphore.c | 8 +- src/video/SDL_rect.c | 1 + src/video/SDL_shape.c | 4 +- src/video/SDL_video.c | 10 +- src/video/android/SDL_androidevents.c | 4 + src/video/android/SDL_androidgl.c | 4 + src/video/android/SDL_androidkeyboard.c | 4 + src/video/android/SDL_androidtouch.c | 4 + src/video/android/SDL_androidvideo.c | 4 + src/video/android/SDL_androidwindow.c | 4 + src/video/bwindow/SDL_bclipboard.cc | 4 +- src/video/bwindow/SDL_bevents.cc | 5 + src/video/bwindow/SDL_bframebuffer.cc | 5 + src/video/bwindow/SDL_bkeyboard.cc | 5 + src/video/bwindow/SDL_bmodes.cc | 5 +- src/video/bwindow/SDL_bopengl.cc | 10 +- src/video/bwindow/SDL_bvideo.cc | 5 +- src/video/bwindow/SDL_bwindow.cc | 3 + src/video/cocoa/SDL_cocoaclipboard.m | 4 + src/video/cocoa/SDL_cocoaevents.m | 4 + src/video/cocoa/SDL_cocoakeyboard.m | 6 +- src/video/cocoa/SDL_cocoamodes.m | 6 +- src/video/cocoa/SDL_cocoamouse.m | 19 +- src/video/cocoa/SDL_cocoaopengl.m | 4 +- src/video/cocoa/SDL_cocoashape.m | 10 + src/video/cocoa/SDL_cocoavideo.m | 4 + src/video/cocoa/SDL_cocoawindow.m | 6 +- src/video/directfb/SDL_DirectFB_WM.c | 4 + src/video/directfb/SDL_DirectFB_dyn.c | 5 +- src/video/directfb/SDL_DirectFB_events.c | 4 + src/video/directfb/SDL_DirectFB_modes.c | 5 + src/video/directfb/SDL_DirectFB_mouse.c | 6 +- src/video/directfb/SDL_DirectFB_opengl.c | 5 + src/video/directfb/SDL_DirectFB_render.c | 5 + src/video/directfb/SDL_DirectFB_shape.c | 4 + src/video/directfb/SDL_DirectFB_video.c | 5 + src/video/directfb/SDL_DirectFB_window.c | 5 + src/video/dummy/SDL_nullevents.c | 4 + src/video/dummy/SDL_nullframebuffer.c | 5 + src/video/dummy/SDL_nullvideo.c | 4 + src/video/nds/SDL_ndsevents.c | 5 +- src/video/nds/SDL_ndsvideo.c | 4 + src/video/nds/SDL_ndswindow.c | 4 + src/video/pandora/SDL_pandora.c | 6 +- src/video/pandora/SDL_pandora_events.c | 4 + src/video/uikit/SDL_uikitappdelegate.m | 5 + src/video/uikit/SDL_uikitevents.m | 4 + src/video/uikit/SDL_uikitopengles.m | 9 +- src/video/uikit/SDL_uikitopenglview.m | 5 + src/video/uikit/SDL_uikitvideo.m | 8 +- src/video/uikit/SDL_uikitview.m | 8 +- src/video/uikit/SDL_uikitviewcontroller.m | 42 +- src/video/uikit/SDL_uikitwindow.m | 14 +- src/video/windows/SDL_windowsclipboard.c | 4 + src/video/windows/SDL_windowsevents.c | 5 +- src/video/windows/SDL_windowsframebuffer.c | 4 + src/video/windows/SDL_windowskeyboard.c | 4 + src/video/windows/SDL_windowsmodes.c | 4 + src/video/windows/SDL_windowsmouse.c | 5 +- src/video/windows/SDL_windowsopengl.c | 4 + src/video/windows/SDL_windowsshape.c | 6 +- src/video/windows/SDL_windowsvideo.c | 4 + src/video/windows/SDL_windowswindow.c | 4 + src/video/x11/SDL_x11opengl.c | 5 + src/video/x11/SDL_x11opengles.c | 4 +- src/video/x11/imKStoUCS.c | 5 + 135 files changed, 496 insertions(+), 1096 deletions(-) delete mode 100644 src/audio/ums/SDL_umsaudio.c delete mode 100644 src/audio/ums/SDL_umsaudio.h rename src/libm/{math.h => math_libm.h} (91%) rename src/{thread/irix/SDL_systhread_c.h => power/uikit/SDL_syspower.h} (83%) delete mode 100644 src/thread/irix/SDL_syssem.c delete mode 100644 src/thread/irix/SDL_systhread.c diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in index 60aade2c4..9eed823d7 100644 --- a/include/SDL_config.h.in +++ b/include/SDL_config.h.in @@ -233,7 +233,6 @@ #undef SDL_THREAD_PTHREAD #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP -#undef SDL_THREAD_SPROC #undef SDL_THREAD_WINDOWS /* Enable various timer systems */ diff --git a/include/SDL_opengl.h b/include/SDL_opengl.h index 54836df76..fad97447b 100644 --- a/include/SDL_opengl.h +++ b/include/SDL_opengl.h @@ -30,6 +30,8 @@ #include "SDL_config.h" +#ifndef __IPHONEOS__ + #ifdef __WIN32__ #define WIN32_LEAN_AND_MEAN #ifndef NOMINMAX @@ -11123,6 +11125,8 @@ typedef void (APIENTRYP PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, cons /* *INDENT-ON* */ #endif /* NO_SDL_GLEXT */ +#endif /* !__IPHONEOS__ */ + #endif /* _SDL_opengl_h */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/SDL_error_c.h b/src/SDL_error_c.h index 1e63b705a..f346faa04 100644 --- a/src/SDL_error_c.h +++ b/src/SDL_error_c.h @@ -56,6 +56,9 @@ typedef struct SDL_error } args[ERR_MAX_ARGS]; } SDL_error; +/* Defined in SDL_thread.c */ +extern SDL_error *SDL_GetErrBuf(void); + #endif /* _SDL_error_c_h */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/audio/alsa/SDL_alsa_audio.c b/src/audio/alsa/SDL_alsa_audio.c index 523be6e28..eb754ec44 100644 --- a/src/audio/alsa/SDL_alsa_audio.c +++ b/src/audio/alsa/SDL_alsa_audio.c @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_AUDIO_DRIVER_ALSA + /* Allow access to a raw mixing buffer */ #include @@ -33,7 +35,7 @@ #include "../SDL_audio_c.h" #include "SDL_alsa_audio.h" -#ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC +#if SDL_AUDIO_DRIVER_ALSA_DYNAMIC #include "SDL_loadso.h" #endif @@ -84,7 +86,7 @@ static int (*ALSA_snd_pcm_wait)(snd_pcm_t *, int); static int (*ALSA_snd_pcm_sw_params_set_avail_min) (snd_pcm_t *, snd_pcm_sw_params_t *, snd_pcm_uframes_t); -#ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC +#if SDL_AUDIO_DRIVER_ALSA_DYNAMIC #define snd_pcm_hw_params_sizeof ALSA_snd_pcm_hw_params_sizeof #define snd_pcm_sw_params_sizeof ALSA_snd_pcm_sw_params_sizeof @@ -147,7 +149,7 @@ load_alsa_syms(void) #undef SDL_ALSA_SYM -#ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC +#if SDL_AUDIO_DRIVER_ALSA_DYNAMIC static void UnloadALSALibrary(void) @@ -693,4 +695,6 @@ AudioBootStrap ALSA_bootstrap = { "alsa", "ALSA PCM audio", ALSA_Init, 0 }; +#endif /* SDL_AUDIO_DRIVER_ALSA */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/audio/android/SDL_androidaudio.c b/src/audio/android/SDL_androidaudio.c index 425e51dac..f74985ca4 100644 --- a/src/audio/android/SDL_androidaudio.c +++ b/src/audio/android/SDL_androidaudio.c @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_AUDIO_DRIVER_ANDROID + /* Output audio to Android */ #include "SDL_audio.h" @@ -154,4 +156,6 @@ Android_RunAudioThread() SDL_RunAudio(audioDevice); } +#endif /* SDL_AUDIO_DRIVER_ANDROID */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/audio/arts/SDL_artsaudio.c b/src/audio/arts/SDL_artsaudio.c index 0abe283e7..25d7bd40f 100644 --- a/src/audio/arts/SDL_artsaudio.c +++ b/src/audio/arts/SDL_artsaudio.c @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_AUDIO_DRIVER_ARTS + /* Allow access to a raw mixing buffer */ #ifdef HAVE_SIGNAL_H @@ -34,14 +36,14 @@ #include "../SDL_audio_c.h" #include "SDL_artsaudio.h" -#ifdef SDL_AUDIO_DRIVER_ARTS_DYNAMIC +#if SDL_AUDIO_DRIVER_ARTS_DYNAMIC #include "SDL_name.h" #include "SDL_loadso.h" #else #define SDL_NAME(X) X #endif -#ifdef SDL_AUDIO_DRIVER_ARTS_DYNAMIC +#if SDL_AUDIO_DRIVER_ARTS_DYNAMIC static const char *arts_library = SDL_AUDIO_DRIVER_ARTS_DYNAMIC; static void *arts_handle = NULL; @@ -372,4 +374,6 @@ AudioBootStrap ARTS_bootstrap = { "arts", "Analog RealTime Synthesizer", ARTS_Init, 0 }; +#endif /* SDL_AUDIO_DRIVER_ARTS */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/audio/baudio/SDL_beaudio.cc b/src/audio/baudio/SDL_beaudio.cc index 867125f93..310cb53bc 100644 --- a/src/audio/baudio/SDL_beaudio.cc +++ b/src/audio/baudio/SDL_beaudio.cc @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_AUDIO_DRIVER_BEOSAUDIO + /* Allow access to the audio stream on BeOS */ #include @@ -214,4 +216,6 @@ AudioBootStrap BEOSAUDIO_bootstrap = { "baudio", "BeOS BSoundPlayer", BEOSAUDIO_Init, 0 }; +#endif /* SDL_AUDIO_DRIVER_BEOSAUDIO */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/audio/bsd/SDL_bsdaudio.c b/src/audio/bsd/SDL_bsdaudio.c index 7da1687ed..8d1b0895d 100644 --- a/src/audio/bsd/SDL_bsdaudio.c +++ b/src/audio/bsd/SDL_bsdaudio.c @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_AUDIO_DRIVER_BSD + /* * Driver for native OpenBSD/NetBSD audio(4). * vedge@vedge.com.ar. @@ -364,4 +366,6 @@ AudioBootStrap BSD_AUDIO_bootstrap = { "bsd", "BSD audio", BSDAUDIO_Init, 0 }; +#endif /* SDL_AUDIO_DRIVER_BSD */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/audio/directsound/SDL_directsound.c b/src/audio/directsound/SDL_directsound.c index 4e2a48d66..cd5556c90 100644 --- a/src/audio/directsound/SDL_directsound.c +++ b/src/audio/directsound/SDL_directsound.c @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_AUDIO_DRIVER_DSOUND + /* Allow access to a raw mixing buffer */ #include "SDL_timer.h" @@ -549,4 +551,6 @@ AudioBootStrap DSOUND_bootstrap = { "directsound", "DirectSound", DSOUND_Init, 0 }; +#endif /* SDL_AUDIO_DRIVER_DSOUND */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/audio/disk/SDL_diskaudio.c b/src/audio/disk/SDL_diskaudio.c index 283ef22d1..4e68a3951 100644 --- a/src/audio/disk/SDL_diskaudio.c +++ b/src/audio/disk/SDL_diskaudio.c @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_AUDIO_DRIVER_DISK + /* Output raw audio data to a file. */ #if HAVE_STDIO_H @@ -159,4 +161,6 @@ AudioBootStrap DISKAUD_bootstrap = { "disk", "direct-to-disk audio", DISKAUD_Init, 1 }; +#endif /* SDL_AUDIO_DRIVER_DISK */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/audio/dsp/SDL_dspaudio.c b/src/audio/dsp/SDL_dspaudio.c index f61b4aacd..5c4a76921 100644 --- a/src/audio/dsp/SDL_dspaudio.c +++ b/src/audio/dsp/SDL_dspaudio.c @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_AUDIO_DRIVER_OSS + /* Allow access to a raw mixing buffer */ #include /* For perror() */ @@ -312,4 +314,6 @@ AudioBootStrap DSP_bootstrap = { "dsp", "OSS /dev/dsp standard audio", DSP_Init, 0 }; +#endif /* SDL_AUDIO_DRIVER_OSS */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/audio/esd/SDL_esdaudio.c b/src/audio/esd/SDL_esdaudio.c index 4cc8e2914..e824e9564 100644 --- a/src/audio/esd/SDL_esdaudio.c +++ b/src/audio/esd/SDL_esdaudio.c @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_AUDIO_DRIVER_ESD + /* Allow access to an ESD network stream mixing buffer */ #include @@ -34,14 +36,14 @@ #include "../SDL_audio_c.h" #include "SDL_esdaudio.h" -#ifdef SDL_AUDIO_DRIVER_ESD_DYNAMIC +#if SDL_AUDIO_DRIVER_ESD_DYNAMIC #include "SDL_name.h" #include "SDL_loadso.h" #else #define SDL_NAME(X) X #endif -#ifdef SDL_AUDIO_DRIVER_ESD_DYNAMIC +#if SDL_AUDIO_DRIVER_ESD_DYNAMIC static const char *esd_library = SDL_AUDIO_DRIVER_ESD_DYNAMIC; static void *esd_handle = NULL; @@ -345,4 +347,6 @@ AudioBootStrap ESD_bootstrap = { "esd", "Enlightened Sound Daemon", ESD_Init, 0 }; +#endif /* SDL_AUDIO_DRIVER_ESD */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/audio/fusionsound/SDL_fsaudio.c b/src/audio/fusionsound/SDL_fsaudio.c index ebe2eb079..3ba9ba773 100644 --- a/src/audio/fusionsound/SDL_fsaudio.c +++ b/src/audio/fusionsound/SDL_fsaudio.c @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_AUDIO_DRIVER_FUSIONSOUND + /* Allow access to a raw mixing buffer */ #ifdef HAVE_SIGNAL_H @@ -37,7 +39,7 @@ //#define SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC "libfusionsound.so" -#ifdef SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC +#if SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC #include "SDL_name.h" #include "SDL_loadso.h" #else @@ -51,7 +53,7 @@ typedef DFBResult DirectResult; /* Buffers to use - more than 2 gives a lot of latency */ #define FUSION_BUFFERS (2) -#ifdef SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC +#if SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC static const char *fs_library = SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC; static void *fs_handle = NULL; @@ -345,4 +347,6 @@ AudioBootStrap FUSIONSOUND_bootstrap = { "fusionsound", "FusionSound", SDL_FS_Init, 0 }; +#endif /* SDL_AUDIO_DRIVER_FUSIONSOUND */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/audio/nas/SDL_nasaudio.c b/src/audio/nas/SDL_nasaudio.c index 0322e2329..a31faad39 100644 --- a/src/audio/nas/SDL_nasaudio.c +++ b/src/audio/nas/SDL_nasaudio.c @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_AUDIO_DRIVER_NAS + /* Allow access to a raw mixing buffer */ #include @@ -50,7 +52,7 @@ static AuEventHandlerRec *(*NAS_AuRegisterEventHandler) (AuServer *, AuMask, int, AuID, AuEventHandlerCallback, AuPointer); -#ifdef SDL_AUDIO_DRIVER_NAS_DYNAMIC +#if SDL_AUDIO_DRIVER_NAS_DYNAMIC static const char *nas_library = SDL_AUDIO_DRIVER_NAS_DYNAMIC; static void *nas_handle = NULL; @@ -89,7 +91,7 @@ load_nas_syms(void) #undef SDL_NAS_SYM -#ifdef SDL_AUDIO_DRIVER_NAS_DYNAMIC +#if SDL_AUDIO_DRIVER_NAS_DYNAMIC static void UnloadNASLibrary(void) @@ -397,4 +399,6 @@ AudioBootStrap NAS_bootstrap = { "nas", "Network Audio System", NAS_Init, 0 }; +#endif /* SDL_AUDIO_DRIVER_NAS */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/audio/nds/SDL_ndsaudio.c b/src/audio/nds/SDL_ndsaudio.c index abfe2591a..034e1726b 100644 --- a/src/audio/nds/SDL_ndsaudio.c +++ b/src/audio/nds/SDL_ndsaudio.c @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_AUDIO_DRIVER_NDS + /* Output audio to NDS */ #include @@ -122,4 +124,6 @@ AudioBootStrap NDSAUD_bootstrap = { "nds", "SDL NDS audio driver", NDSAUD_Init, 0 /*1? */ }; +#endif /* SDL_AUDIO_DRIVER_NDS */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/audio/paudio/SDL_paudio.c b/src/audio/paudio/SDL_paudio.c index 2036c0c2f..821fa7718 100644 --- a/src/audio/paudio/SDL_paudio.c +++ b/src/audio/paudio/SDL_paudio.c @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_AUDIO_DRIVER_PAUDIO + /* Allow access to a raw mixing buffer */ #include @@ -545,4 +547,6 @@ AudioBootStrap PAUDIO_bootstrap = { "paud", "AIX Paudio", PAUDIO_Init, 0 }; +#endif /* SDL_AUDIO_DRIVER_PAUDIO */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/audio/pulseaudio/SDL_pulseaudio.c b/src/audio/pulseaudio/SDL_pulseaudio.c index 6b2333e02..b3e0b4e58 100644 --- a/src/audio/pulseaudio/SDL_pulseaudio.c +++ b/src/audio/pulseaudio/SDL_pulseaudio.c @@ -106,7 +106,7 @@ static void (*PULSEAUDIO_pa_stream_unref) (pa_stream *); static int load_pulseaudio_syms(void); -#ifdef SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC +#if SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC static const char *pulseaudio_library = SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC; static void *pulseaudio_handle = NULL; diff --git a/src/audio/qsa/SDL_qsa_audio.c b/src/audio/qsa/SDL_qsa_audio.c index 590b089e8..2cf4b8b54 100644 --- a/src/audio/qsa/SDL_qsa_audio.c +++ b/src/audio/qsa/SDL_qsa_audio.c @@ -21,6 +21,8 @@ #include "SDL_config.h" +#if SDL_AUDIO_DRIVER_QSA + #include #include #include @@ -863,4 +865,6 @@ AudioBootStrap QSAAUDIO_bootstrap = { "qsa", "QNX QSA Audio", QSA_Init, 0 }; +#endif /* SDL_AUDIO_DRIVER_QSA */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/audio/sun/SDL_sunaudio.c b/src/audio/sun/SDL_sunaudio.c index 1ae9c7c4d..2768cf30e 100644 --- a/src/audio/sun/SDL_sunaudio.c +++ b/src/audio/sun/SDL_sunaudio.c @@ -1,8 +1,3 @@ -/* I'm gambling no one uses this audio backend...we'll see who emails. :) */ -#error this code has not been updated for SDL 1.3. -#error if no one emails icculus at icculus.org and tells him that this -#error code is needed, this audio backend will eventually be removed from SDL. - /* Simple DirectMedia Layer Copyright (C) 1997-2011 Sam Lantinga @@ -25,6 +20,13 @@ */ #include "SDL_config.h" +#if SDL_AUDIO_DRIVER_SUNAUDIO + +/* I'm gambling no one uses this audio backend...we'll see who emails. :) */ +#error this code has not been updated for SDL 1.3. +#error if no one emails icculus at icculus.org and tells him that this +#error code is needed, this audio backend will eventually be removed from SDL. + /* Allow access to a raw mixing buffer */ #include @@ -450,4 +452,6 @@ snd2au(int sample) return (mask & sample); } +#endif /* SDL_AUDIO_DRIVER_SUNAUDIO */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/audio/ums/SDL_umsaudio.c b/src/audio/ums/SDL_umsaudio.c deleted file mode 100644 index 999ad01e8..000000000 --- a/src/audio/ums/SDL_umsaudio.c +++ /dev/null @@ -1,556 +0,0 @@ -/* I'm gambling no one uses this audio backend...we'll see who emails. :) */ -#error this code has not been updated for SDL 1.3. -#error if no one emails icculus at icculus.org and tells him that this -#error code is needed, this audio backend will eventually be removed from SDL. - -/* - Simple DirectMedia Layer - Copyright (C) 1997-2011 Sam Lantinga - - 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" - -/* Allow access to a raw mixing buffer */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "SDL_audio.h" -#include "../SDL_audio_c.h" -#include "SDL_umsaudio.h" - -#define DEBUG_AUDIO 1 - -/* Audio driver functions */ -static int UMS_OpenAudio(_THIS, SDL_AudioSpec * spec); -static void UMS_PlayAudio(_THIS); -static Uint8 *UMS_GetAudioBuf(_THIS); -static void UMS_CloseAudio(_THIS); - -static UMSAudioDevice_ReturnCode UADOpen(_THIS, string device, string mode, - long flags); -static UMSAudioDevice_ReturnCode UADClose(_THIS); -static UMSAudioDevice_ReturnCode UADGetBitsPerSample(_THIS, long *bits); -static UMSAudioDevice_ReturnCode UADSetBitsPerSample(_THIS, long bits); -static UMSAudioDevice_ReturnCode UADSetSampleRate(_THIS, long rate, - long *set_rate); -static UMSAudioDevice_ReturnCode UADSetByteOrder(_THIS, string byte_order); -static UMSAudioDevice_ReturnCode UADSetAudioFormatType(_THIS, string fmt); -static UMSAudioDevice_ReturnCode UADSetNumberFormat(_THIS, string fmt); -static UMSAudioDevice_ReturnCode UADInitialize(_THIS); -static UMSAudioDevice_ReturnCode UADStart(_THIS); -static UMSAudioDevice_ReturnCode UADStop(_THIS); -static UMSAudioDevice_ReturnCode UADSetTimeFormat(_THIS, - UMSAudioTypes_TimeFormat - fmt); -static UMSAudioDevice_ReturnCode UADWriteBuffSize(_THIS, long *buff_size); -static UMSAudioDevice_ReturnCode UADWriteBuffRemain(_THIS, long *buff_size); -static UMSAudioDevice_ReturnCode UADWriteBuffUsed(_THIS, long *buff_size); -static UMSAudioDevice_ReturnCode UADSetDMABufferSize(_THIS, long bytes, - long *bytes_ret); -static UMSAudioDevice_ReturnCode UADSetVolume(_THIS, long volume); -static UMSAudioDevice_ReturnCode UADSetBalance(_THIS, long balance); -static UMSAudioDevice_ReturnCode UADSetChannels(_THIS, long channels); -static UMSAudioDevice_ReturnCode UADPlayRemainingData(_THIS, boolean block); -static UMSAudioDevice_ReturnCode UADEnableOutput(_THIS, string output, - long *left_gain, - long *right_gain); -static UMSAudioDevice_ReturnCode UADWrite(_THIS, UMSAudioTypes_Buffer * buff, - long samples, - long *samples_written); - -/* Audio driver bootstrap functions */ -static int -Audio_Available(void) -{ - return 1; -} - -static void -Audio_DeleteDevice(_THIS) -{ - if (this->hidden->playbuf._buffer) - SDL_free(this->hidden->playbuf._buffer); - if (this->hidden->fillbuf._buffer) - SDL_free(this->hidden->fillbuf._buffer); - _somFree(this->hidden->umsdev); - SDL_free(this->hidden); - SDL_free(this); -} - -static SDL_AudioDevice * -Audio_CreateDevice(int devindex) -{ - SDL_AudioDevice *this; - - /* - * Allocate and initialize management storage and private management - * storage for this SDL-using library. - */ - this = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice)); - if (this) { - SDL_memset(this, 0, (sizeof *this)); - this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc((sizeof *this->hidden)); - } - if ((this == NULL) || (this->hidden == NULL)) { - SDL_OutOfMemory(); - if (this) { - SDL_free(this); - } - return (0); - } - SDL_memset(this->hidden, 0, (sizeof *this->hidden)); -#ifdef DEBUG_AUDIO - fprintf(stderr, "Creating UMS Audio device\n"); -#endif - - /* - * Calls for UMS env initialization and audio object construction. - */ - this->hidden->ev = somGetGlobalEnvironment(); - this->hidden->umsdev = UMSAudioDeviceNew(); - - /* - * Set the function pointers. - */ - this->OpenAudio = UMS_OpenAudio; - this->WaitAudio = NULL; /* we do blocking output */ - this->PlayAudio = UMS_PlayAudio; - this->GetAudioBuf = UMS_GetAudioBuf; - this->CloseAudio = UMS_CloseAudio; - this->free = Audio_DeleteDevice; - -#ifdef DEBUG_AUDIO - fprintf(stderr, "done\n"); -#endif - return this; -} - -AudioBootStrap UMS_bootstrap = { - "ums", "AIX UMS audio", Audio_Available, Audio_CreateDevice, 0 -}; - -static Uint8 * -UMS_GetAudioBuf(_THIS) -{ -#ifdef DEBUG_AUDIO - fprintf(stderr, "enter UMS_GetAudioBuf\n"); -#endif - return this->hidden->fillbuf._buffer; -/* - long bufSize; - UMSAudioDevice_ReturnCode rc; - - rc = UADSetTimeFormat(this, UMSAudioTypes_Bytes ); - rc = UADWriteBuffSize(this, bufSize ); -*/ -} - -static void -UMS_CloseAudio(_THIS) -{ - UMSAudioDevice_ReturnCode rc; - -#ifdef DEBUG_AUDIO - fprintf(stderr, "enter UMS_CloseAudio\n"); -#endif - rc = UADPlayRemainingData(this, TRUE); - rc = UADStop(this); - rc = UADClose(this); -} - -static void -UMS_PlayAudio(_THIS) -{ - UMSAudioDevice_ReturnCode rc; - long samplesToWrite; - long samplesWritten; - UMSAudioTypes_Buffer swpbuf; - -#ifdef DEBUG_AUDIO - fprintf(stderr, "enter UMS_PlayAudio\n"); -#endif - samplesToWrite = - this->hidden->playbuf._length / this->hidden->bytesPerSample; - do { - rc = UADWrite(this, &this->hidden->playbuf, - samplesToWrite, &samplesWritten); - samplesToWrite -= samplesWritten; - - /* rc values: UMSAudioDevice_Success - * UMSAudioDevice_Failure - * UMSAudioDevice_Preempted - * UMSAudioDevice_Interrupted - * UMSAudioDevice_DeviceError - */ - if (rc == UMSAudioDevice_DeviceError) { -#ifdef DEBUG_AUDIO - fprintf(stderr, "Returning from PlayAudio with devices error\n"); -#endif - return; - } - } while (samplesToWrite > 0); - - SDL_LockAudio(); - SDL_memcpy(&swpbuf, &this->hidden->playbuf, sizeof(UMSAudioTypes_Buffer)); - SDL_memcpy(&this->hidden->playbuf, &this->hidden->fillbuf, - sizeof(UMSAudioTypes_Buffer)); - SDL_memcpy(&this->hidden->fillbuf, &swpbuf, sizeof(UMSAudioTypes_Buffer)); - SDL_UnlockAudio(); - -#ifdef DEBUG_AUDIO - fprintf(stderr, "Wrote audio data and swapped buffer\n"); -#endif -} - -#if 0 -// /* Set the DSP frequency */ -// value = spec->freq; -// if ( ioctl(this->hidden->audio_fd, SOUND_PCM_WRITE_RATE, &value) < 0 ) { -// SDL_SetError("Couldn't set audio frequency"); -// return(-1); -// } -// spec->freq = value; -#endif - -static int -UMS_OpenAudio(_THIS, SDL_AudioSpec * spec) -{ - char *audiodev = "/dev/paud0"; - long lgain; - long rgain; - long outRate; - long outBufSize; - long bitsPerSample; - long samplesPerSec; - long success; - SDL_AudioFormat test_format; - int frag_spec; - UMSAudioDevice_ReturnCode rc; - -#ifdef DEBUG_AUDIO - fprintf(stderr, "enter UMS_OpenAudio\n"); -#endif - rc = UADOpen(this, audiodev, "PLAY", UMSAudioDevice_BlockingIO); - if (rc != UMSAudioDevice_Success) { - SDL_SetError("Couldn't open %s: %s", audiodev, strerror(errno)); - return -1; - } - - rc = UADSetAudioFormatType(this, "PCM"); - - success = 0; - test_format = SDL_FirstAudioFormat(spec->format); - do { -#ifdef DEBUG_AUDIO - fprintf(stderr, "Trying format 0x%4.4x\n", test_format); -#endif - switch (test_format) { - case AUDIO_U8: -/* from the mac code: better ? */ -/* sample_bits = spec->size / spec->samples / spec->channels * 8; */ - success = 1; - bitsPerSample = 8; - rc = UADSetSampleRate(this, spec->freq << 16, &outRate); - rc = UADSetByteOrder(this, "MSB"); /* irrelevant */ - rc = UADSetNumberFormat(this, "UNSIGNED"); - break; - case AUDIO_S8: - success = 1; - bitsPerSample = 8; - rc = UADSetSampleRate(this, spec->freq << 16, &outRate); - rc = UADSetByteOrder(this, "MSB"); /* irrelevant */ - rc = UADSetNumberFormat(this, "SIGNED"); - break; - case AUDIO_S16LSB: - success = 1; - bitsPerSample = 16; - rc = UADSetSampleRate(this, spec->freq << 16, &outRate); - rc = UADSetByteOrder(this, "LSB"); - rc = UADSetNumberFormat(this, "SIGNED"); - break; - case AUDIO_S16MSB: - success = 1; - bitsPerSample = 16; - rc = UADSetSampleRate(this, spec->freq << 16, &outRate); - rc = UADSetByteOrder(this, "MSB"); - rc = UADSetNumberFormat(this, "SIGNED"); - break; - case AUDIO_U16LSB: - success = 1; - bitsPerSample = 16; - rc = UADSetSampleRate(this, spec->freq << 16, &outRate); - rc = UADSetByteOrder(this, "LSB"); - rc = UADSetNumberFormat(this, "UNSIGNED"); - break; - case AUDIO_U16MSB: - success = 1; - bitsPerSample = 16; - rc = UADSetSampleRate(this, spec->freq << 16, &outRate); - rc = UADSetByteOrder(this, "MSB"); - rc = UADSetNumberFormat(this, "UNSIGNED"); - break; - default: - break; - } - if (!success) { - test_format = SDL_NextAudioFormat(); - } - } while (!success && test_format); - - if (success == 0) { - SDL_SetError("Couldn't find any hardware audio formats"); - return -1; - } - - spec->format = test_format; - - for (frag_spec = 0; (0x01 << frag_spec) < spec->size; ++frag_spec); - if ((0x01 << frag_spec) != spec->size) { - SDL_SetError("Fragment size must be a power of two"); - return -1; - } - if (frag_spec > 2048) - frag_spec = 2048; - - this->hidden->bytesPerSample = (bitsPerSample / 8) * spec->channels; - samplesPerSec = this->hidden->bytesPerSample * outRate; - - this->hidden->playbuf._length = 0; - this->hidden->playbuf._maximum = spec->size; - this->hidden->playbuf._buffer = (unsigned char *) SDL_malloc(spec->size); - this->hidden->fillbuf._length = 0; - this->hidden->fillbuf._maximum = spec->size; - this->hidden->fillbuf._buffer = (unsigned char *) SDL_malloc(spec->size); - - rc = UADSetBitsPerSample(this, bitsPerSample); - rc = UADSetDMABufferSize(this, frag_spec, &outBufSize); - rc = UADSetChannels(this, spec->channels); /* functions reduces to mono or stereo */ - - lgain = 100; /*maximum left input gain */ - rgain = 100; /*maimum right input gain */ - rc = UADEnableOutput(this, "LINE_OUT", &lgain, &rgain); - rc = UADInitialize(this); - rc = UADStart(this); - rc = UADSetVolume(this, 100); - rc = UADSetBalance(this, 0); - - /* We're ready to rock and roll. :-) */ - return 0; -} - - -static UMSAudioDevice_ReturnCode -UADGetBitsPerSample(_THIS, long *bits) -{ - return UMSAudioDevice_get_bits_per_sample(this->hidden->umsdev, - this->hidden->ev, bits); -} - -static UMSAudioDevice_ReturnCode -UADSetBitsPerSample(_THIS, long bits) -{ - return UMSAudioDevice_set_bits_per_sample(this->hidden->umsdev, - this->hidden->ev, bits); -} - -static UMSAudioDevice_ReturnCode -UADSetSampleRate(_THIS, long rate, long *set_rate) -{ - /* from the mac code: sample rate = spec->freq << 16; */ - return UMSAudioDevice_set_sample_rate(this->hidden->umsdev, - this->hidden->ev, rate, set_rate); -} - -static UMSAudioDevice_ReturnCode -UADSetByteOrder(_THIS, string byte_order) -{ - return UMSAudioDevice_set_byte_order(this->hidden->umsdev, - this->hidden->ev, byte_order); -} - -static UMSAudioDevice_ReturnCode -UADSetAudioFormatType(_THIS, string fmt) -{ - /* possible PCM, A_LAW or MU_LAW */ - return UMSAudioDevice_set_audio_format_type(this->hidden->umsdev, - this->hidden->ev, fmt); -} - -static UMSAudioDevice_ReturnCode -UADSetNumberFormat(_THIS, string fmt) -{ - /* possible SIGNED, UNSIGNED, or TWOS_COMPLEMENT */ - return UMSAudioDevice_set_number_format(this->hidden->umsdev, - this->hidden->ev, fmt); -} - -static UMSAudioDevice_ReturnCode -UADInitialize(_THIS) -{ - return UMSAudioDevice_initialize(this->hidden->umsdev, this->hidden->ev); -} - -static UMSAudioDevice_ReturnCode -UADStart(_THIS) -{ - return UMSAudioDevice_start(this->hidden->umsdev, this->hidden->ev); -} - -static UMSAudioDevice_ReturnCode -UADSetTimeFormat(_THIS, UMSAudioTypes_TimeFormat fmt) -{ - /* - * Switches the time format to the new format, immediately. - * possible UMSAudioTypes_Msecs, UMSAudioTypes_Bytes or UMSAudioTypes_Samples - */ - return UMSAudioDevice_set_time_format(this->hidden->umsdev, - this->hidden->ev, fmt); -} - -static UMSAudioDevice_ReturnCode -UADWriteBuffSize(_THIS, long *buff_size) -{ - /* - * returns write buffer size in the current time format - */ - return UMSAudioDevice_write_buff_size(this->hidden->umsdev, - this->hidden->ev, buff_size); -} - -static UMSAudioDevice_ReturnCode -UADWriteBuffRemain(_THIS, long *buff_size) -{ - /* - * returns amount of available space in the write buffer - * in the current time format - */ - return UMSAudioDevice_write_buff_remain(this->hidden->umsdev, - this->hidden->ev, buff_size); -} - -static UMSAudioDevice_ReturnCode -UADWriteBuffUsed(_THIS, long *buff_size) -{ - /* - * returns amount of filled space in the write buffer - * in the current time format - */ - return UMSAudioDevice_write_buff_used(this->hidden->umsdev, - this->hidden->ev, buff_size); -} - -static UMSAudioDevice_ReturnCode -UADSetDMABufferSize(_THIS, long bytes, long *bytes_ret) -{ - /* - * Request a new DMA buffer size, maximum requested size 2048. - * Takes effect with next initialize() call. - * Devices may or may not support DMA. - */ - return UMSAudioDevice_set_DMA_buffer_size(this->hidden->umsdev, - this->hidden->ev, - bytes, bytes_ret); -} - -static UMSAudioDevice_ReturnCode -UADSetVolume(_THIS, long volume) -{ - /* - * Set the volume. - * Takes effect immediately. - */ - return UMSAudioDevice_set_volume(this->hidden->umsdev, - this->hidden->ev, volume); -} - -static UMSAudioDevice_ReturnCode -UADSetBalance(_THIS, long balance) -{ - /* - * Set the balance. - * Takes effect immediately. - */ - return UMSAudioDevice_set_balance(this->hidden->umsdev, - this->hidden->ev, balance); -} - -static UMSAudioDevice_ReturnCode -UADSetChannels(_THIS, long channels) -{ - /* - * Set mono or stereo. - * Takes effect with next initialize() call. - */ - if (channels != 1) - channels = 2; - return UMSAudioDevice_set_number_of_channels(this->hidden->umsdev, - this->hidden->ev, channels); -} - -static UMSAudioDevice_ReturnCode -UADOpen(_THIS, string device, string mode, long flags) -{ - return UMSAudioDevice_open(this->hidden->umsdev, - this->hidden->ev, device, mode, flags); -} - -static UMSAudioDevice_ReturnCode -UADWrite(_THIS, UMSAudioTypes_Buffer * buff, - long samples, long *samples_written) -{ - return UMSAudioDevice_write(this->hidden->umsdev, - this->hidden->ev, - buff, samples, samples_written); -} - -static UMSAudioDevice_ReturnCode -UADPlayRemainingData(_THIS, boolean block) -{ - return UMSAudioDevice_play_remaining_data(this->hidden->umsdev, - this->hidden->ev, block); -} - -static UMSAudioDevice_ReturnCode -UADStop(_THIS) -{ - return UMSAudioDevice_stop(this->hidden->umsdev, this->hidden->ev); -} - -static UMSAudioDevice_ReturnCode -UADClose(_THIS) -{ - return UMSAudioDevice_close(this->hidden->umsdev, this->hidden->ev); -} - -static UMSAudioDevice_ReturnCode -UADEnableOutput(_THIS, string output, long *left_gain, long *right_gain) -{ - return UMSAudioDevice_enable_output(this->hidden->umsdev, - this->hidden->ev, - output, left_gain, right_gain); -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/audio/ums/SDL_umsaudio.h b/src/audio/ums/SDL_umsaudio.h deleted file mode 100644 index 3c452225d..000000000 --- a/src/audio/ums/SDL_umsaudio.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2011 Sam Lantinga - - 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_UMSaudio_h -#define _SDL_UMSaudio_h - -#include - -#include "../SDL_sysaudio.h" - -/* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this - -struct SDL_PrivateAudioData -{ - /* Pointer to the (open) UMS audio device */ - Environment *ev; - UMSAudioDevice umsdev; - - /* Raw mixing buffer */ - UMSAudioTypes_Buffer playbuf; - UMSAudioTypes_Buffer fillbuf; - - long bytesPerSample; -}; - -#endif /* _SDL_UMSaudio_h */ -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/audio/winmm/SDL_winmm.c b/src/audio/winmm/SDL_winmm.c index de73f7118..019f7dff2 100644 --- a/src/audio/winmm/SDL_winmm.c +++ b/src/audio/winmm/SDL_winmm.c @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_AUDIO_DRIVER_WINMM + /* Allow access to a raw mixing buffer */ #include "../../core/windows/SDL_windows.h" @@ -406,4 +408,6 @@ AudioBootStrap WINMM_bootstrap = { "winmm", "Windows Waveform Audio", WINMM_Init, 0 }; +#endif /* SDL_AUDIO_DRIVER_WINMM */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/audio/xaudio2/SDL_xaudio2.c b/src/audio/xaudio2/SDL_xaudio2.c index 5287586e8..a1230e4d7 100644 --- a/src/audio/xaudio2/SDL_xaudio2.c +++ b/src/audio/xaudio2/SDL_xaudio2.c @@ -19,14 +19,15 @@ 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" + +#if SDL_AUDIO_DRIVER_XAUDIO2 + #include "../../core/windows/SDL_windows.h" #include "SDL_audio.h" #include "../SDL_audio_c.h" #include "../SDL_sysaudio.h" #include "SDL_assert.h" -#if SDL_AUDIO_DRIVER_XAUDIO2 - #include /* XAudio2 exists as of the March 2008 DirectX SDK */ #if (!defined(_DXSDK_BUILD_MAJOR) || (_DXSDK_BUILD_MAJOR < 1284)) # warning Your DirectX SDK is too old. Disabling XAudio2 support. diff --git a/src/core/android/SDL_android.cpp b/src/core/android/SDL_android.cpp index 0f689ed75..a905c8dae 100644 --- a/src/core/android/SDL_android.cpp +++ b/src/core/android/SDL_android.cpp @@ -21,6 +21,8 @@ #include "SDL_config.h" #include "SDL_stdinc.h" +#ifdef __ANDROID__ + #include "SDL_android.h" extern "C" { @@ -605,4 +607,6 @@ extern "C" int Android_JNI_FileClose(SDL_RWops* ctx) return Android_JNI_FileClose(ctx, true); } +#endif /* __ANDROID__ */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/core/windows/SDL_windows.c b/src/core/windows/SDL_windows.c index e00a399d8..a7c4425bb 100644 --- a/src/core/windows/SDL_windows.c +++ b/src/core/windows/SDL_windows.c @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#ifdef __WIN32__ + #include "SDL_error.h" #include "SDL_windows.h" @@ -59,4 +61,6 @@ WIN_CoUninitialize(void) CoUninitialize(); } +#endif /* __WIN32__ */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/events/SDL_gesture.c b/src/events/SDL_gesture.c index 2d6185355..13bcbf86e 100644 --- a/src/events/SDL_gesture.c +++ b/src/events/SDL_gesture.c @@ -103,7 +103,7 @@ int SDL_RecordGesture(SDL_TouchID touchId) { return (touchId < 0); } -unsigned long SDL_HashDollar(SDL_FloatPoint* points) { +static unsigned long SDL_HashDollar(SDL_FloatPoint* points) { unsigned long hash = 5381; int i; for(i = 0;i < DOLLARNPOINTS; i++) { @@ -242,7 +242,7 @@ int SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src) { } -float dollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ,float ang) { +static float dollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ,float ang) { // SDL_FloatPoint p[DOLLARNPOINTS]; float dist = 0; SDL_FloatPoint p; @@ -257,7 +257,7 @@ float dollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ,float ang) { } -float bestDollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ) { +static float bestDollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ) { //------------BEGIN DOLLAR BLACKBOX----------------// //-TRANSLATED DIRECTLY FROM PSUDEO-CODE AVAILABLE AT-// //-"http://depts.washington.edu/aimgroup/proj/dollar/"-// @@ -294,7 +294,7 @@ float bestDollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ) { } //DollarPath contains raw points, plus (possibly) the calculated length -int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points) { +static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points) { int i; float interval; float dist; @@ -387,7 +387,7 @@ int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points) { return numPoints; } -float dollarRecognize(const SDL_DollarPath *path,int *bestTempl,SDL_GestureTouch* touch) { +static float dollarRecognize(const SDL_DollarPath *path,int *bestTempl,SDL_GestureTouch* touch) { SDL_FloatPoint points[DOLLARNPOINTS]; int i; @@ -431,20 +431,7 @@ int SDL_GestureAddTouch(SDL_Touch* touch) { return 0; } -int SDL_GestureRemoveTouch(SDL_TouchID id) { - int i; - for (i = 0; i < SDL_numGestureTouches; i++) { - if (SDL_gestureTouch[i].id == id) { - SDL_numGestureTouches--; - SDL_memcpy(&SDL_gestureTouch[i], &SDL_gestureTouch[SDL_numGestureTouches], sizeof(SDL_gestureTouch[i])); - return 1; - } - } - return -1; -} - - -SDL_GestureTouch * SDL_GetGestureTouch(SDL_TouchID id) { +static SDL_GestureTouch * SDL_GetGestureTouch(SDL_TouchID id) { int i; for(i = 0;i < SDL_numGestureTouches; i++) { //printf("%i ?= %i\n",SDL_gestureTouch[i].id,id); @@ -453,7 +440,7 @@ SDL_GestureTouch * SDL_GetGestureTouch(SDL_TouchID id) { return NULL; } -int SDL_SendGestureMulti(SDL_GestureTouch* touch,float dTheta,float dDist) { +static int SDL_SendGestureMulti(SDL_GestureTouch* touch,float dTheta,float dDist) { SDL_Event event; event.mgesture.type = SDL_MULTIGESTURE; event.mgesture.touchId = touch->id; @@ -465,7 +452,7 @@ int SDL_SendGestureMulti(SDL_GestureTouch* touch,float dTheta,float dDist) { return SDL_PushEvent(&event) > 0; } -int SDL_SendGestureDollar(SDL_GestureTouch* touch, +static int SDL_SendGestureDollar(SDL_GestureTouch* touch, SDL_GestureID gestureId,float error) { SDL_Event event; event.dgesture.type = SDL_DOLLARGESTURE; @@ -483,7 +470,7 @@ int SDL_SendGestureDollar(SDL_GestureTouch* touch, } -int SDL_SendDollarRecord(SDL_GestureTouch* touch,SDL_GestureID gestureId) { +static int SDL_SendDollarRecord(SDL_GestureTouch* touch,SDL_GestureID gestureId) { SDL_Event event; event.dgesture.type = SDL_DOLLARRECORD; event.dgesture.touchId = touch->id; diff --git a/src/events/SDL_keyboard.c b/src/events/SDL_keyboard.c index 7d990dd94..6424de9db 100644 --- a/src/events/SDL_keyboard.c +++ b/src/events/SDL_keyboard.c @@ -854,23 +854,6 @@ SDL_GetKeyFromScancode(SDL_Scancode scancode) return keyboard->keymap[scancode]; } -SDL_Keycode SDL_GetKeycodeFromName(const char *name) -{ - int i; - - if (!name || !*name) { - return SDL_SCANCODE_UNKNOWN; - } - - for (i = 0; i < SDL_arraysize(SDL_scancode_names); ++i) { - if (SDL_strcasecmp(name, SDL_scancode_names[i]) == 0) { - return (SDL_Scancode)i; - } - } - return SDL_SCANCODE_UNKNOWN; -} - - SDL_Scancode SDL_GetScancodeFromKey(SDL_Keycode key) { diff --git a/src/events/SDL_touch.c b/src/events/SDL_touch.c index 9227ff3d0..c0c005c80 100644 --- a/src/events/SDL_touch.c +++ b/src/events/SDL_touch.c @@ -59,7 +59,7 @@ SDL_GetTouchIndex(int index) return SDL_touchPads[index]; } -int +static int SDL_GetFingerIndexId(SDL_Touch* touch,SDL_FingerID fingerid) { int i; @@ -190,6 +190,7 @@ SDL_GetNumTouch(void) { return SDL_num_touch; } + SDL_Window * SDL_GetTouchFocusWindow(SDL_TouchID id) { diff --git a/src/libm/e_atan2.c b/src/libm/e_atan2.c index f6974bd12..3f1ee5771 100644 --- a/src/libm/e_atan2.c +++ b/src/libm/e_atan2.c @@ -36,7 +36,7 @@ * to produce the hexadecimal values shown. */ -#include "math.h" +#include "math_libm.h" #include "math_private.h" static const double diff --git a/src/libm/e_log.c b/src/libm/e_log.c index 47e8ea452..da64138cd 100644 --- a/src/libm/e_log.c +++ b/src/libm/e_log.c @@ -66,7 +66,7 @@ static const char rcsid[] = * to produce the hexadecimal values shown. */ -#include "math.h" +#include "math_libm.h" #include "math_private.h" #ifdef __STDC__ diff --git a/src/libm/e_pow.c b/src/libm/e_pow.c index f90652c65..9145c4b57 100644 --- a/src/libm/e_pow.c +++ b/src/libm/e_pow.c @@ -59,7 +59,7 @@ static char rcsid[] = "$NetBSD: e_pow.c,v 1.9 1995/05/12 04:57:32 jtc Exp $"; * to produce the hexadecimal values shown. */ -#include "math.h" +#include "math_libm.h" #include "math_private.h" libm_hidden_proto(scalbn) diff --git a/src/libm/e_rem_pio2.c b/src/libm/e_rem_pio2.c index 3578a0fad..a8ffe3142 100644 --- a/src/libm/e_rem_pio2.c +++ b/src/libm/e_rem_pio2.c @@ -21,7 +21,7 @@ static const char rcsid[] = * use __kernel_rem_pio2() */ -#include "math.h" +#include "math_libm.h" #include "math_private.h" libm_hidden_proto(fabs) diff --git a/src/libm/e_sqrt.c b/src/libm/e_sqrt.c index 3c4b25ea5..b8b8bec6f 100644 --- a/src/libm/e_sqrt.c +++ b/src/libm/e_sqrt.c @@ -85,7 +85,7 @@ static const char rcsid[] = *--------------- */ -#include "math.h" +#include "math_libm.h" #include "math_private.h" #ifdef __STDC__ diff --git a/src/libm/k_cos.c b/src/libm/k_cos.c index ab2637eb7..64c50e3fb 100644 --- a/src/libm/k_cos.c +++ b/src/libm/k_cos.c @@ -50,7 +50,7 @@ static const char rcsid[] = * thus, reducing the rounding error in the subtraction. */ -#include "math.h" +#include "math_libm.h" #include "math_private.h" #ifdef __STDC__ diff --git a/src/libm/k_rem_pio2.c b/src/libm/k_rem_pio2.c index 42db4a898..f881d35d6 100644 --- a/src/libm/k_rem_pio2.c +++ b/src/libm/k_rem_pio2.c @@ -131,7 +131,7 @@ static const char rcsid[] = * to produce the hexadecimal values shown. */ -#include "math.h" +#include "math_libm.h" #include "math_private.h" libm_hidden_proto(scalbn) diff --git a/src/libm/k_sin.c b/src/libm/k_sin.c index 250ee6eca..60881575a 100644 --- a/src/libm/k_sin.c +++ b/src/libm/k_sin.c @@ -43,7 +43,7 @@ static const char rcsid[] = * sin(x) = x + (S1*x + (x *(r-y/2)+y)) */ -#include "math.h" +#include "math_libm.h" #include "math_private.h" #ifdef __STDC__ diff --git a/src/libm/math.h b/src/libm/math_libm.h similarity index 91% rename from src/libm/math.h rename to src/libm/math_libm.h index 260b3fed2..6c1f8e9d7 100644 --- a/src/libm/math.h +++ b/src/libm/math_libm.h @@ -28,6 +28,7 @@ #else #define atan SDL_atan #endif +double atan(double x); #ifndef HAVE_ATAN2 #define __ieee754_atan2 SDL_atan2 @@ -38,24 +39,28 @@ #else #define copysign SDL_copysign #endif +double copysign(double x, double y); #ifdef HAVE_COS #define cos SDL_uclibc_cos #else #define cos SDL_cos #endif +double cos(double x); #ifdef HAVE_FABS #define fabs SDL_uclibc_fabs #else #define fabs SDL_fabs #endif +double fabs(double x); #ifdef HAVE_FLOOR #define floor SDL_uclibc_floor #else #define floor SDL_floor #endif +double floor(double x); #ifndef HAVE_LOG #define __ieee754_log SDL_log @@ -70,12 +75,14 @@ #else #define scalbn SDL_scalbn #endif +double scalbn(double x, int n); #ifdef HAVE_SIN #define sin SDL_uclibc_sin #else #define sin SDL_sin #endif +double sin(double x); #ifndef HAVE_SQRT #define __ieee754_sqrt SDL_sqrt diff --git a/src/libm/s_atan.c b/src/libm/s_atan.c index 08cfb08e8..f664f0eb3 100644 --- a/src/libm/s_atan.c +++ b/src/libm/s_atan.c @@ -29,7 +29,7 @@ * to produce the hexadecimal values shown. */ -#include "math.h" +#include "math_libm.h" #include "math_private.h" static const double atanhi[] = { diff --git a/src/libm/s_copysign.c b/src/libm/s_copysign.c index 65e719007..afd43e9a7 100644 --- a/src/libm/s_copysign.c +++ b/src/libm/s_copysign.c @@ -21,7 +21,7 @@ static const char rcsid[] = * with the sign bit of y. */ -#include "math.h" +#include "math_libm.h" #include "math_private.h" libm_hidden_proto(copysign) diff --git a/src/libm/s_cos.c b/src/libm/s_cos.c index 9a568fca2..66b156c9f 100644 --- a/src/libm/s_cos.c +++ b/src/libm/s_cos.c @@ -46,7 +46,7 @@ static const char rcsid[] = * TRIG(x) returns trig(x) nearly rounded */ -#include "math.h" +#include "math_libm.h" #include "math_private.h" libm_hidden_proto(cos) diff --git a/src/libm/s_fabs.c b/src/libm/s_fabs.c index dba666cbc..5cf0c3977 100644 --- a/src/libm/s_fabs.c +++ b/src/libm/s_fabs.c @@ -19,7 +19,7 @@ static const char rcsid[] = * fabs(x) returns the absolute value of x. */ -#include "math.h" +#include "math_libm.h" #include "math_private.h" libm_hidden_proto(fabs) diff --git a/src/libm/s_floor.c b/src/libm/s_floor.c index d6b8f177e..b553d3038 100644 --- a/src/libm/s_floor.c +++ b/src/libm/s_floor.c @@ -24,7 +24,7 @@ static const char rcsid[] = * Inexact flag raised if x not equal to floor(x). */ -#include "math.h" +#include "math_libm.h" #include "math_private.h" #ifdef __STDC__ diff --git a/src/libm/s_scalbn.c b/src/libm/s_scalbn.c index e90631da6..74b979445 100644 --- a/src/libm/s_scalbn.c +++ b/src/libm/s_scalbn.c @@ -22,7 +22,7 @@ static const char rcsid[] = * exponentiation or a multiplication. */ -#include "math.h" +#include "math_libm.h" #include "math_private.h" libm_hidden_proto(copysign) diff --git a/src/libm/s_sin.c b/src/libm/s_sin.c index 1b22f8813..771176619 100644 --- a/src/libm/s_sin.c +++ b/src/libm/s_sin.c @@ -46,7 +46,7 @@ static const char rcsid[] = * TRIG(x) returns trig(x) nearly rounded */ -#include "math.h" +#include "math_libm.h" #include "math_private.h" libm_hidden_proto(sin) diff --git a/src/main/android/SDL_android_main.cpp b/src/main/android/SDL_android_main.cpp index 4058e6b9c..89e41ab7d 100644 --- a/src/main/android/SDL_android_main.cpp +++ b/src/main/android/SDL_android_main.cpp @@ -1,4 +1,8 @@ +#include "SDL_config.h" + +#ifdef __ANDROID__ + /* Include the SDL main definition header */ #include "SDL_main.h" @@ -33,4 +37,6 @@ extern "C" void Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass c exit(status); } +#endif /* __ANDROID__ */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/main/beos/SDL_BeApp.cc b/src/main/beos/SDL_BeApp.cc index 07632f39d..33a7330be 100644 --- a/src/main/beos/SDL_BeApp.cc +++ b/src/main/beos/SDL_BeApp.cc @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#ifdef __BEOS__ + /* Handle the BeApp specific portions of the application */ #include @@ -116,8 +118,6 @@ SDL_QuitBeApp(void) } } - -/* vi: set ts=4 sw=4 expandtab: */ #ifdef __cplusplus } #endif @@ -131,3 +131,7 @@ void SDL_BApp::ClearID(SDL_BWin *bwin) { --i; } } + +#endif /* __BEOS__ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/main/windows/SDL_windows_main.c b/src/main/windows/SDL_windows_main.c index ef50d5d2c..4d60e2d4e 100644 --- a/src/main/windows/SDL_windows_main.c +++ b/src/main/windows/SDL_windows_main.c @@ -3,6 +3,9 @@ The WinMain function -- calls your program's main() function */ +#include "SDL_config.h" + +#ifdef __WIN32__ #include #include @@ -202,4 +205,6 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPTSTR szCmdLine, int sw) return 0; } +#endif /* __WIN32__ */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/power/beos/SDL_syspower.c b/src/power/beos/SDL_syspower.c index 454d48fa1..eb49628b5 100644 --- a/src/power/beos/SDL_syspower.c +++ b/src/power/beos/SDL_syspower.c @@ -21,7 +21,7 @@ #include "SDL_config.h" #ifndef SDL_POWER_DISABLED -#ifdef SDL_POWER_BEOS +#if SDL_POWER_BEOS #include #include diff --git a/src/power/linux/SDL_syspower.c b/src/power/linux/SDL_syspower.c index 9852b789e..2e409488c 100644 --- a/src/power/linux/SDL_syspower.c +++ b/src/power/linux/SDL_syspower.c @@ -21,7 +21,7 @@ #include "SDL_config.h" #ifndef SDL_POWER_DISABLED -#ifdef SDL_POWER_LINUX +#if SDL_POWER_LINUX #include #include diff --git a/src/power/macosx/SDL_syspower.c b/src/power/macosx/SDL_syspower.c index 0434a16e6..b76b5c650 100644 --- a/src/power/macosx/SDL_syspower.c +++ b/src/power/macosx/SDL_syspower.c @@ -21,7 +21,7 @@ #include "SDL_config.h" #ifndef SDL_POWER_DISABLED -#ifdef SDL_POWER_MACOSX +#if SDL_POWER_MACOSX #include #include diff --git a/src/power/nds/SDL_syspower.c b/src/power/nds/SDL_syspower.c index 485a28817..e0a92f235 100644 --- a/src/power/nds/SDL_syspower.c +++ b/src/power/nds/SDL_syspower.c @@ -21,7 +21,7 @@ #include "SDL_config.h" #ifndef SDL_POWER_DISABLED -#ifdef SDL_POWER_NINTENDODS +#if SDL_POWER_NINTENDODS #include "SDL_power.h" diff --git a/src/thread/irix/SDL_systhread_c.h b/src/power/uikit/SDL_syspower.h similarity index 83% rename from src/thread/irix/SDL_systhread_c.h rename to src/power/uikit/SDL_syspower.h index 0e698918c..2bec9e171 100644 --- a/src/thread/irix/SDL_systhread_c.h +++ b/src/power/uikit/SDL_syspower.h @@ -20,8 +20,13 @@ */ #include "SDL_config.h" -#include +#if SDL_POWER_UIKIT -typedef pid_t SYS_ThreadHandle; +#include "SDL_power.h" + +void SDL_UIKit_UpdateBatteryMonitoring(void); +SDL_bool SDL_GetPowerInfo_UIKit(SDL_PowerState * state, int *seconds, int *percent); + +#endif /* SDL_POWER_UIKIT */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/power/uikit/SDL_syspower.m b/src/power/uikit/SDL_syspower.m index 3f6f33d38..2766ef5dd 100644 --- a/src/power/uikit/SDL_syspower.m +++ b/src/power/uikit/SDL_syspower.m @@ -21,13 +21,14 @@ #include "SDL_config.h" #ifndef SDL_POWER_DISABLED -#ifdef SDL_POWER_UIKIT +#if SDL_POWER_UIKIT #import #include "SDL_power.h" #include "SDL_timer.h" #include "SDL_assert.h" +#include "SDL_syspower.h" // turn off the battery monitor if it's been more than X ms since last check. static const int BATTERY_MONITORING_TIMEOUT = 3000; diff --git a/src/power/windows/SDL_syspower.c b/src/power/windows/SDL_syspower.c index 4e3f6f468..0d75a2bcc 100644 --- a/src/power/windows/SDL_syspower.c +++ b/src/power/windows/SDL_syspower.c @@ -21,7 +21,7 @@ #include "SDL_config.h" #ifndef SDL_POWER_DISABLED -#ifdef SDL_POWER_WINDOWS +#if SDL_POWER_WINDOWS #include "../../core/windows/SDL_windows.h" diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index c6de6a853..251ae3cce 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -745,7 +745,7 @@ SDL_UnlockTextureYUV(SDL_Texture * texture) SDL_UnlockTexture(native); } -void +static void SDL_UnlockTextureNative(SDL_Texture * texture) { SDL_Texture *native = texture->native; diff --git a/src/render/opengles/SDL_render_gles.c b/src/render/opengles/SDL_render_gles.c index b356fc66a..844acee35 100644 --- a/src/render/opengles/SDL_render_gles.c +++ b/src/render/opengles/SDL_render_gles.c @@ -581,7 +581,6 @@ static int GLES_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points, int count) { - GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; int i; GLshort *vertices; @@ -603,7 +602,6 @@ static int GLES_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points, int count) { - GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; int i; GLshort *vertices; @@ -632,7 +630,6 @@ static int GLES_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect * rects, int count) { - GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; int i; GLES_SetDrawingState(renderer); diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c index d4773a0a8..fc3a9d31f 100644 --- a/src/render/opengles2/SDL_render_gles2.c +++ b/src/render/opengles2/SDL_render_gles2.c @@ -877,7 +877,6 @@ GLES2_SetDrawingState(SDL_Renderer * renderer) static int GLES2_RenderDrawPoints(SDL_Renderer *renderer, const SDL_Point *points, int count) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; GLfloat *vertices; int idx; @@ -910,7 +909,6 @@ GLES2_RenderDrawPoints(SDL_Renderer *renderer, const SDL_Point *points, int coun static int GLES2_RenderDrawLines(SDL_Renderer *renderer, const SDL_Point *points, int count) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; GLfloat *vertices; int idx; @@ -943,7 +941,6 @@ GLES2_RenderDrawLines(SDL_Renderer *renderer, const SDL_Point *points, int count static int GLES2_RenderFillRects(SDL_Renderer *renderer, const SDL_Rect *rects, int count) { - GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; GLfloat vertices[8]; int idx; diff --git a/src/render/software/SDL_render_sw.c b/src/render/software/SDL_render_sw.c index 30c22727b..ce63f1dee 100644 --- a/src/render/software/SDL_render_sw.c +++ b/src/render/software/SDL_render_sw.c @@ -23,6 +23,7 @@ #if !SDL_RENDER_DISABLED #include "../SDL_sysrender.h" +#include "SDL_render_sw_c.h" #include "SDL_draw.h" #include "SDL_blendfillrect.h" diff --git a/src/stdlib/SDL_string.c b/src/stdlib/SDL_string.c index e3942713a..69a1c8c80 100644 --- a/src/stdlib/SDL_string.c +++ b/src/stdlib/SDL_string.c @@ -31,7 +31,7 @@ #define UTF8_IsLeadByte(c) ((c) >= 0xC0 && (c) <= 0xF4) #define UTF8_IsTrailingByte(c) ((c) >= 0x80 && (c) <= 0xBF) -int UTF8_TrailingBytes(unsigned char c) +static int UTF8_TrailingBytes(unsigned char c) { if (c >= 0xC0 && c <= 0xDF) return 1; diff --git a/src/thread/SDL_thread.c b/src/thread/SDL_thread.c index a1144c176..2f1aeb975 100644 --- a/src/thread/SDL_thread.c +++ b/src/thread/SDL_thread.c @@ -26,6 +26,7 @@ #include "SDL_thread.h" #include "SDL_thread_c.h" #include "SDL_systhread.h" +#include "../SDL_error_c.h" #define ARRAY_CHUNKSIZE 32 /* The array of threads currently active in the application diff --git a/src/thread/SDL_thread_c.h b/src/thread/SDL_thread_c.h index 8474cfb0c..08ebd7bc8 100644 --- a/src/thread/SDL_thread_c.h +++ b/src/thread/SDL_thread_c.h @@ -32,8 +32,6 @@ #include "epoc/SDL_systhread_c.h" #elif SDL_THREAD_PTHREAD #include "pthread/SDL_systhread_c.h" -#elif SDL_THREAD_SPROC -#include "irix/SDL_systhread_c.h" #elif SDL_THREAD_WINDOWS #include "windows/SDL_systhread_c.h" #elif SDL_THREAD_NDS @@ -59,4 +57,5 @@ struct SDL_Thread extern void SDL_RunThread(void *data); #endif /* _SDL_thread_c_h */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/thread/beos/SDL_syssem.c b/src/thread/beos/SDL_syssem.c index 9f966851a..afaccaf1a 100644 --- a/src/thread/beos/SDL_syssem.c +++ b/src/thread/beos/SDL_syssem.c @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#ifdef SDL_THREAD_BEOS + /* Semaphores in the BeOS environment */ #include @@ -148,4 +150,6 @@ SDL_SemPost(SDL_sem * sem) return 0; } +#endif /* SDL_THREAD_BEOS */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/thread/beos/SDL_systhread.c b/src/thread/beos/SDL_systhread.c index cf2f577b7..ff255ff76 100644 --- a/src/thread/beos/SDL_systhread.c +++ b/src/thread/beos/SDL_systhread.c @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#ifdef SDL_THREAD_BEOS + /* BeOS thread management routines for SDL */ #include @@ -120,4 +122,6 @@ SDL_SYS_WaitThread(SDL_Thread * thread) wait_for_thread(thread->handle, &the_status); } +#endif /* SDL_THREAD_BEOS */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/thread/irix/SDL_syssem.c b/src/thread/irix/SDL_syssem.c deleted file mode 100644 index 273b6b17f..000000000 --- a/src/thread/irix/SDL_syssem.c +++ /dev/null @@ -1,230 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2011 Sam Lantinga - - 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_thread.h" -#include "SDL_timer.h" - - -#include -#include -#include -#include -#include -#include - -#include "SDL_error.h" -#include "SDL_thread.h" - - -struct SDL_semaphore -{ - int id; -}; - -/* Not defined by many operating systems, use configure to detect */ -/* -#if !defined(HAVE_SEMUN) -union semun { - int val; - struct semid_ds *buf; - ushort *array; -}; -#endif -*/ - -static struct sembuf op_trywait[2] = { - {0, -1, (IPC_NOWAIT | SEM_UNDO)} /* Decrement semaphore, no block */ -}; - -static struct sembuf op_wait[2] = { - {0, -1, SEM_UNDO} /* Decrement semaphore */ -}; - -static struct sembuf op_post[1] = { - {0, 1, (IPC_NOWAIT | SEM_UNDO)} /* Increment semaphore */ -}; - -/* Create a blockable semaphore */ -SDL_sem * -SDL_CreateSemaphore(Uint32 initial_value) -{ - extern int _creating_thread_lock; /* SDL_threads.c */ - SDL_sem *sem; - union semun init; - - sem = (SDL_sem *) SDL_malloc(sizeof(*sem)); - if (sem == NULL) { - SDL_OutOfMemory(); - return (NULL); - } - sem->id = semget(IPC_PRIVATE, 1, (0600 | IPC_CREAT)); - if (sem->id < 0) { - SDL_SetError("Couldn't create semaphore"); - SDL_free(sem); - return (NULL); - } - init.val = initial_value; /* Initialize semaphore */ - semctl(sem->id, 0, SETVAL, init); - return (sem); -} - -void -SDL_DestroySemaphore(SDL_sem * sem) -{ - if (sem) { -#ifdef __IRIX__ - semctl(sem->id, 0, IPC_RMID); -#else - union semun dummy; - dummy.val = 0; - semctl(sem->id, 0, IPC_RMID, dummy); -#endif - SDL_free(sem); - } -} - -int -SDL_SemTryWait(SDL_sem * sem) -{ - int retval; - - if (!sem) { - SDL_SetError("Passed a NULL semaphore"); - return -1; - } - - retval = 0; - tryagain: - if (semop(sem->id, op_trywait, 1) < 0) { - if (errno == EINTR) { - goto tryagain; - } - retval = SDL_MUTEX_TIMEDOUT; - } - return retval; -} - -int -SDL_SemWait(SDL_sem * sem) -{ - int retval; - - if (!sem) { - SDL_SetError("Passed a NULL semaphore"); - return -1; - } - - retval = 0; - tryagain: - if (semop(sem->id, op_wait, 1) < 0) { - if (errno == EINTR) { - goto tryagain; - } - SDL_SetError("Semaphore operation error"); - retval = -1; - } - return retval; -} - -int -SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) -{ - int retval; - - if (!sem) { - SDL_SetError("Passed a NULL semaphore"); - return -1; - } - - /* Try the easy cases first */ - if (timeout == 0) { - return SDL_SemTryWait(sem); - } - if (timeout == SDL_MUTEX_MAXWAIT) { - return SDL_SemWait(sem); - } - - /* Ack! We have to busy wait... */ - timeout += SDL_GetTicks(); - do { - retval = SDL_SemTryWait(sem); - if (retval == 0) { - break; - } - SDL_Delay(1); - } while (SDL_GetTicks() < timeout); - - return retval; -} - -Uint32 -SDL_SemValue(SDL_sem * sem) -{ - int semval; - Uint32 value; - - value = 0; - if (sem) { - tryagain: -#ifdef __IRIX__ - semval = semctl(sem->id, 0, GETVAL); -#else - { - union semun arg; - arg.val = 0; - semval = semctl(sem->id, 0, GETVAL, arg); - } -#endif - if (semval < 0) { - if (errno == EINTR) { - goto tryagain; - } - } else { - value = (Uint32) semval; - } - } - return value; -} - -int -SDL_SemPost(SDL_sem * sem) -{ - int retval; - - if (!sem) { - SDL_SetError("Passed a NULL semaphore"); - return -1; - } - - retval = 0; - tryagain: - if (semop(sem->id, op_post, 1) < 0) { - if (errno == EINTR) { - goto tryagain; - } - SDL_SetError("Semaphore operation error"); - retval = -1; - } - return retval; -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/thread/irix/SDL_systhread.c b/src/thread/irix/SDL_systhread.c deleted file mode 100644 index d2ed080d0..000000000 --- a/src/thread/irix/SDL_systhread.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2011 Sam Lantinga - - 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" - -/* IRIX thread management routines for SDL */ - -#include -#include -#include -#include -#include - -#include "SDL_thread.h" -#include "../SDL_systhread.h" - - -static int sig_list[] = { - SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGALRM, SIGTERM, SIGCLD, SIGWINCH, - SIGVTALRM, SIGPROF, 0 -}; - - -int -SDL_SYS_CreateThread(SDL_Thread * thread, void *args) -{ - /* Create the thread and go! */ - if (sproc(SDL_RunThread, PR_SALL, args) < 0) { - SDL_SetError("Not enough resources to create thread"); - return (-1); - } - return (0); -} - -void -SDL_SYS_SetupThread(const char *name) -{ - int i; - sigset_t mask; - - /* Mask asynchronous signals for this thread */ - sigemptyset(&mask); - for (i = 0; sig_list[i]; ++i) { - sigaddset(&mask, sig_list[i]); - } - sigprocmask(SIG_BLOCK, &mask, NULL); -} - -SDL_threadID -SDL_ThreadID(void) -{ - return ((SDL_threadID) getpid()); -} - -void -SDL_WaitThread(SDL_Thread * thread, int *status) -{ - errno = 0; - while (errno != ECHILD) { - waitpid(thread->handle, NULL, 0); - } -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/thread/nds/SDL_systhread.c b/src/thread/nds/SDL_systhread.c index 3bdebcee1..0355db870 100644 --- a/src/thread/nds/SDL_systhread.c +++ b/src/thread/nds/SDL_systhread.c @@ -61,10 +61,4 @@ SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) return (0); } -void -SDL_SYS_KillThread(SDL_Thread * thread) -{ - return; -} - /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/thread/windows/SDL_sysmutex.c b/src/thread/windows/SDL_sysmutex.c index 184cd27dd..ab35a9614 100644 --- a/src/thread/windows/SDL_sysmutex.c +++ b/src/thread/windows/SDL_sysmutex.c @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_THREAD_WINDOWS + /* Mutex functions using the Win32 API */ #include "../../core/windows/SDL_windows.h" @@ -90,4 +92,6 @@ SDL_mutexV(SDL_mutex * mutex) return (0); } +#endif /* SDL_THREAD_WINDOWS */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/thread/windows/SDL_syssem.c b/src/thread/windows/SDL_syssem.c index c5589f0c9..b1543dab9 100644 --- a/src/thread/windows/SDL_syssem.c +++ b/src/thread/windows/SDL_syssem.c @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_THREAD_WINDOWS + /* Semaphore functions using the Win32 API */ #include "../../core/windows/SDL_windows.h" @@ -169,4 +171,6 @@ SDL_SemPost(SDL_sem * sem) return 0; } +#endif /* SDL_THREAD_WINDOWS */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/thread/windows/SDL_systhread.c b/src/thread/windows/SDL_systhread.c index 3c133e09c..47bc0d20e 100644 --- a/src/thread/windows/SDL_systhread.c +++ b/src/thread/windows/SDL_systhread.c @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_THREAD_WINDOWS + /* Win32 thread management routines for SDL */ #include "SDL_thread.h" @@ -216,4 +218,6 @@ SDL_SYS_WaitThread(SDL_Thread * thread) CloseHandle(thread->handle); } +#endif /* SDL_THREAD_WINDOWS */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/thread/windows/win_ce_semaphore.c b/src/thread/windows/win_ce_semaphore.c index 62072f562..f243682b7 100644 --- a/src/thread/windows/win_ce_semaphore.c +++ b/src/thread/windows/win_ce_semaphore.c @@ -26,7 +26,11 @@ 6. The wait function emulates WaitForSingleObject only. An emulation of WaitForMultipleObjects is much harder to implement outside the kernel, and it is not clear how to handle a mixture of WCE semaphores and normal - events and mutexes. */ + events and mutexes. +*/ +#include "SDL_config.h" + +#if SDL_THREAD_WINDOWS #include "../../core/windows/SDL_windows.h" @@ -224,4 +228,6 @@ CleanUp(SYNCHHANDLE hSynch, DWORD Flags) return hSynch; } +#endif /* SDL_THREAD_WINDOWS */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/SDL_rect.c b/src/video/SDL_rect.c index 1772166b1..fba69fc2d 100644 --- a/src/video/SDL_rect.c +++ b/src/video/SDL_rect.c @@ -21,6 +21,7 @@ #include "SDL_config.h" #include "SDL_rect.h" +#include "SDL_rect_c.h" SDL_bool diff --git a/src/video/SDL_shape.c b/src/video/SDL_shape.c index 01fad7099..3e0c030f8 100644 --- a/src/video/SDL_shape.c +++ b/src/video/SDL_shape.c @@ -115,7 +115,7 @@ SDL_CalculateShapeBitmap(SDL_WindowShapeMode mode,SDL_Surface *shape,Uint8* bitm SDL_UnlockSurface(shape); } -SDL_ShapeTree* +static SDL_ShapeTree* RecursivelyCalculateShapeTree(SDL_WindowShapeMode mode,SDL_Surface* mask,SDL_Rect dimensions) { int x = 0,y = 0; Uint8* pixel = NULL; @@ -249,7 +249,7 @@ SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *sh return result; } -SDL_bool +static SDL_bool SDL_WindowHasAShape(SDL_Window *window) { if (window == NULL || !SDL_IsShapedWindow(window)) return SDL_FALSE; diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index abed6a824..bb26ff094 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -576,7 +576,7 @@ SDL_GetNumVideoDisplays(void) return _this->num_displays; } -int +static int SDL_GetIndexOfDisplay(SDL_VideoDisplay *display) { int displayIndex; @@ -655,12 +655,6 @@ SDL_AddDisplayMode(SDL_VideoDisplay * display, const SDL_DisplayMode * mode) return SDL_TRUE; } -SDL_VideoDisplay * -SDL_GetFirstDisplay(void) -{ - return &_this->displays[0]; -} - static int SDL_GetNumDisplayModesForDisplay(SDL_VideoDisplay * display) { @@ -847,7 +841,7 @@ SDL_GetClosestDisplayMode(int displayIndex, return SDL_GetClosestDisplayModeForDisplay(display, mode, closest); } -int +static int SDL_SetDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode * mode) { SDL_DisplayMode display_mode; diff --git a/src/video/android/SDL_androidevents.c b/src/video/android/SDL_androidevents.c index 6145cd0c0..ec20b9b8c 100644 --- a/src/video/android/SDL_androidevents.c +++ b/src/video/android/SDL_androidevents.c @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_ANDROID + #include "SDL_androidevents.h" void @@ -28,4 +30,6 @@ Android_PumpEvents(_THIS) /* No polling necessary */ } +#endif /* SDL_VIDEO_DRIVER_ANDROID */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/android/SDL_androidgl.c b/src/video/android/SDL_androidgl.c index f8d47be85..abde8fcd7 100644 --- a/src/video/android/SDL_androidgl.c +++ b/src/video/android/SDL_androidgl.c @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_ANDROID + /* Android SDL video driver implementation */ #include "SDL_video.h" @@ -112,4 +114,6 @@ Android_GL_DeleteContext(_THIS, SDL_GLContext context) __android_log_print(ANDROID_LOG_INFO, "SDL", "[STUB] GL_DeleteContext\n"); } +#endif /* SDL_VIDEO_DRIVER_ANDROID */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/android/SDL_androidkeyboard.c b/src/video/android/SDL_androidkeyboard.c index 70e7e7b2f..df80fdf10 100644 --- a/src/video/android/SDL_androidkeyboard.c +++ b/src/video/android/SDL_androidkeyboard.c @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_ANDROID + #include #include "../../events/SDL_events_c.h" @@ -176,4 +178,6 @@ Android_OnKeyUp(int keycode) return SDL_SendKeyboardKey(SDL_RELEASED, TranslateKeycode(keycode)); } +#endif /* SDL_VIDEO_DRIVER_ANDROID */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/android/SDL_androidtouch.c b/src/video/android/SDL_androidtouch.c index 5ca966697..cf81143dd 100644 --- a/src/video/android/SDL_androidtouch.c +++ b/src/video/android/SDL_androidtouch.c @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_ANDROID + #include #include "SDL_events.h" @@ -85,4 +87,6 @@ void Android_OnTouch(int touch_device_id_in, int pointer_finger_id_in, int actio } } +#endif /* SDL_VIDEO_DRIVER_ANDROID */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/android/SDL_androidvideo.c b/src/video/android/SDL_androidvideo.c index 00c262708..d4d46a8ba 100644 --- a/src/video/android/SDL_androidvideo.c +++ b/src/video/android/SDL_androidvideo.c @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_ANDROID + /* Android SDL video driver implementation */ @@ -166,4 +168,6 @@ Android_SetScreenResolution(int width, int height, Uint32 format) } } +#endif /* SDL_VIDEO_DRIVER_ANDROID */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/android/SDL_androidwindow.c b/src/video/android/SDL_androidwindow.c index e0abadd4e..68107e2c2 100644 --- a/src/video/android/SDL_androidwindow.c +++ b/src/video/android/SDL_androidwindow.c @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_ANDROID + #include "../SDL_sysvideo.h" #include "SDL_androidvideo.h" @@ -62,4 +64,6 @@ Android_DestroyWindow(_THIS, SDL_Window * window) } } +#endif /* SDL_VIDEO_DRIVER_ANDROID */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/bwindow/SDL_bclipboard.cc b/src/video/bwindow/SDL_bclipboard.cc index 028dcac99..41ebfb453 100644 --- a/src/video/bwindow/SDL_bclipboard.cc +++ b/src/video/bwindow/SDL_bclipboard.cc @@ -18,10 +18,11 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ +#include "SDL_config.h" +#if SDL_VIDEO_DRIVER_BWINDOW /* BWindow based framebuffer implementation */ -#include "SDL_config.h" #include #include @@ -91,3 +92,4 @@ SDL_bool BE_HasClipboardText(_THIS) { } /* Extern C */ #endif +#endif /* SDL_VIDEO_DRIVER_BWINDOW */ diff --git a/src/video/bwindow/SDL_bevents.cc b/src/video/bwindow/SDL_bevents.cc index e5ad003ec..bc5c6eb67 100644 --- a/src/video/bwindow/SDL_bevents.cc +++ b/src/video/bwindow/SDL_bevents.cc @@ -18,6 +18,9 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_BWINDOW #include "SDL_bevents.h" @@ -32,3 +35,5 @@ void BE_PumpEvents(_THIS) { #ifdef __cplusplus } #endif + +#endif /* SDL_VIDEO_DRIVER_BWINDOW */ diff --git a/src/video/bwindow/SDL_bframebuffer.cc b/src/video/bwindow/SDL_bframebuffer.cc index 7dbd06717..f24a136d4 100644 --- a/src/video/bwindow/SDL_bframebuffer.cc +++ b/src/video/bwindow/SDL_bframebuffer.cc @@ -18,6 +18,9 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_BWINDOW #include "SDL_bframebuffer.h" @@ -248,3 +251,5 @@ int32 BE_UpdateOnce(SDL_Window *window) { #ifdef __cplusplus } #endif + +#endif /* SDL_VIDEO_DRIVER_BWINDOW */ diff --git a/src/video/bwindow/SDL_bkeyboard.cc b/src/video/bwindow/SDL_bkeyboard.cc index 03ba7cac2..13dbd0929 100644 --- a/src/video/bwindow/SDL_bkeyboard.cc +++ b/src/video/bwindow/SDL_bkeyboard.cc @@ -19,6 +19,9 @@ Sam Lantinga slouken@libsdl.org */ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_BWINDOW #include #include @@ -182,3 +185,5 @@ void BE_SetKeyState(int32 bkey, int8 state) { #ifdef __cplusplus } #endif + +#endif /* SDL_VIDEO_DRIVER_BWINDOW */ diff --git a/src/video/bwindow/SDL_bmodes.cc b/src/video/bwindow/SDL_bmodes.cc index 0651cf937..a68522be8 100644 --- a/src/video/bwindow/SDL_bmodes.cc +++ b/src/video/bwindow/SDL_bmodes.cc @@ -18,8 +18,9 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ +#include "SDL_config.h" - +#if SDL_VIDEO_DRIVER_BWINDOW #include #include @@ -327,3 +328,5 @@ int BE_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode){ #ifdef __cplusplus } #endif + +#endif /* SDL_VIDEO_DRIVER_BWINDOW */ diff --git a/src/video/bwindow/SDL_bopengl.cc b/src/video/bwindow/SDL_bopengl.cc index f4cd9c08e..d2f4e790c 100644 --- a/src/video/bwindow/SDL_bopengl.cc +++ b/src/video/bwindow/SDL_bopengl.cc @@ -18,6 +18,9 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_BWINDOW #include "SDL_bopengl.h" @@ -209,11 +212,8 @@ void BE_GL_RebootContexts(_THIS) { - - - - - #ifdef __cplusplus } #endif + +#endif /* SDL_VIDEO_DRIVER_BWINDOW */ diff --git a/src/video/bwindow/SDL_bvideo.cc b/src/video/bwindow/SDL_bvideo.cc index 0037c04d5..0ff99aff6 100644 --- a/src/video/bwindow/SDL_bvideo.cc +++ b/src/video/bwindow/SDL_bvideo.cc @@ -18,8 +18,9 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ +#include "SDL_config.h" - +#if SDL_VIDEO_DRIVER_BWINDOW #ifdef __cplusplus @@ -168,3 +169,5 @@ void BE_VideoQuit(_THIS) #ifdef __cplusplus } #endif + +#endif /* SDL_VIDEO_DRIVER_BWINDOW */ diff --git a/src/video/bwindow/SDL_bwindow.cc b/src/video/bwindow/SDL_bwindow.cc index 2c550d593..1c97211e7 100644 --- a/src/video/bwindow/SDL_bwindow.cc +++ b/src/video/bwindow/SDL_bwindow.cc @@ -19,6 +19,8 @@ 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_BWINDOW #include "../SDL_sysvideo.h" #include "SDL_BWin.h" @@ -210,3 +212,4 @@ SDL_bool BE_GetWindowWMInfo(_THIS, SDL_Window * window, } #endif +#endif /* SDL_VIDEO_DRIVER_BWINDOW */ diff --git a/src/video/cocoa/SDL_cocoaclipboard.m b/src/video/cocoa/SDL_cocoaclipboard.m index e575f2ca1..2b1b231e0 100644 --- a/src/video/cocoa/SDL_cocoaclipboard.m +++ b/src/video/cocoa/SDL_cocoaclipboard.m @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_COCOA + #include "SDL_cocoavideo.h" #include "../../events/SDL_clipboardevents_c.h" @@ -124,4 +126,6 @@ [pool release]; } +#endif /* SDL_VIDEO_DRIVER_COCOA */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/cocoa/SDL_cocoaevents.m b/src/video/cocoa/SDL_cocoaevents.m index b5e4e0273..321ea76ad 100644 --- a/src/video/cocoa/SDL_cocoaevents.m +++ b/src/video/cocoa/SDL_cocoaevents.m @@ -19,6 +19,8 @@ 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_COCOA #include "SDL_timer.h" #include "SDL_cocoavideo.h" @@ -220,4 +222,6 @@ - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sende [pool release]; } +#endif /* SDL_VIDEO_DRIVER_COCOA */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/cocoa/SDL_cocoakeyboard.m b/src/video/cocoa/SDL_cocoakeyboard.m index c82b7059e..c2da570db 100644 --- a/src/video/cocoa/SDL_cocoakeyboard.m +++ b/src/video/cocoa/SDL_cocoakeyboard.m @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_COCOA + #include "SDL_cocoavideo.h" #include "../../events/SDL_keyboard_c.h" @@ -28,7 +30,7 @@ #include //#define DEBUG_IME NSLog -#define DEBUG_IME (void) +#define DEBUG_IME(...) #ifndef NX_DEVICERCTLKEYMASK #define NX_DEVICELCTLKEYMASK 0x00000001 @@ -733,4 +735,6 @@ - (NSArray *) validAttributesForMarkedText { } +#endif /* SDL_VIDEO_DRIVER_COCOA */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/cocoa/SDL_cocoamodes.m b/src/video/cocoa/SDL_cocoamodes.m index 5babd40d1..cbed0bae9 100644 --- a/src/video/cocoa/SDL_cocoamodes.m +++ b/src/video/cocoa/SDL_cocoamodes.m @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_COCOA + #include "SDL_cocoavideo.h" /* !!! FIXME: clean out the pre-10.6 code when it makes sense to do so. */ @@ -113,7 +115,6 @@ - (void) setFrame:(NSRect)frame; GetDisplayMode(_THIS, const void *moderef, SDL_DisplayMode *mode) { SDL_DisplayModeData *data; - CFNumberRef number; long width, height, bpp, refreshRate; data = (SDL_DisplayModeData *) SDL_malloc(sizeof(*data)); @@ -146,6 +147,7 @@ - (void) setFrame:(NSRect)frame; #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 if (!IS_SNOW_LEOPARD_OR_LATER(_this)) { + CFNumberRef number; CFDictionaryRef vidmode = (CFDictionaryRef) moderef; number = CFDictionaryGetValue(vidmode, kCGDisplayWidth); CFNumberGetValue(number, kCFNumberLongType, &width); @@ -448,4 +450,6 @@ - (void) setFrame:(NSRect)frame; ShowMenuBar(); } +#endif /* SDL_VIDEO_DRIVER_COCOA */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/cocoa/SDL_cocoamouse.m b/src/video/cocoa/SDL_cocoamouse.m index 488bef6b7..024639c71 100644 --- a/src/video/cocoa/SDL_cocoamouse.m +++ b/src/video/cocoa/SDL_cocoamouse.m @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_COCOA + #include "SDL_events.h" #include "SDL_cocoavideo.h" @@ -147,21 +149,6 @@ SDL_SetDefaultCursor(Cocoa_CreateDefaultCursor()); } -static int -ConvertMouseButtonToSDL(int button) -{ - switch (button) - { - case 0: - return(SDL_BUTTON_LEFT); /* 1 */ - case 1: - return(SDL_BUTTON_RIGHT); /* 3 */ - case 2: - return(SDL_BUTTON_MIDDLE); /* 2 */ - } - return button+1; -} - void Cocoa_HandleMouseEvent(_THIS, NSEvent *event) { @@ -202,4 +189,6 @@ { } +#endif /* SDL_VIDEO_DRIVER_COCOA */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/cocoa/SDL_cocoaopengl.m b/src/video/cocoa/SDL_cocoaopengl.m index 6dbf8e122..378ab3c9a 100644 --- a/src/video/cocoa/SDL_cocoaopengl.m +++ b/src/video/cocoa/SDL_cocoaopengl.m @@ -20,11 +20,11 @@ */ #include "SDL_config.h" -#include "SDL_cocoavideo.h" - /* NSOpenGL implementation of SDL OpenGL support */ #if SDL_VIDEO_OPENGL_CGL +#include "SDL_cocoavideo.h" + #include #include #include diff --git a/src/video/cocoa/SDL_cocoashape.m b/src/video/cocoa/SDL_cocoashape.m index 19d432d5f..542a82899 100644 --- a/src/video/cocoa/SDL_cocoashape.m +++ b/src/video/cocoa/SDL_cocoashape.m @@ -19,6 +19,10 @@ 3. This notice may not be removed or altered from any source distribution. */ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_COCOA + #include "SDL_cocoavideo.h" #include "SDL_shape.h" #include "SDL_cocoashape.h" @@ -89,6 +93,8 @@ closure.window = shaper->window; SDL_TraverseShapeTree(data->shape,&ConvertRects,&closure); [closure.path addClip]; + + return 0; } int @@ -97,3 +103,7 @@ assert(data != NULL); return 0; } + +#endif /* SDL_VIDEO_DRIVER_COCOA */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/cocoa/SDL_cocoavideo.m b/src/video/cocoa/SDL_cocoavideo.m index 02d9eefb5..886b2bebc 100644 --- a/src/video/cocoa/SDL_cocoavideo.m +++ b/src/video/cocoa/SDL_cocoavideo.m @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_COCOA + #include "SDL.h" #include "SDL_endian.h" #include "SDL_cocoavideo.h" @@ -259,4 +261,6 @@ return (SDL_assert_state) (clicked - NSAlertFirstButtonReturn); } +#endif /* SDL_VIDEO_DRIVER_COCOA */ + /* vim: set ts=4 sw=4 expandtab: */ diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index f21addc88..f8956e087 100644 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_COCOA + #include "SDL_syswm.h" #include "SDL_timer.h" /* For SDL_GetTicks() */ #include "../SDL_sysvideo.h" @@ -277,8 +279,6 @@ - (void)otherMouseUp:(NSEvent *)theEvent - (void)mouseEntered:(NSEvent *)theEvent { - SDL_Mouse *mouse = SDL_GetMouse(); - SDL_SetMouseFocus(_data->window); SDL_SetCursor(NULL); @@ -991,4 +991,6 @@ - (void)rightMouseDown:(NSEvent *)theEvent } } +#endif /* SDL_VIDEO_DRIVER_COCOA */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/directfb/SDL_DirectFB_WM.c b/src/video/directfb/SDL_DirectFB_WM.c index 56f807612..c079f6381 100644 --- a/src/video/directfb/SDL_DirectFB_WM.c +++ b/src/video/directfb/SDL_DirectFB_WM.c @@ -18,6 +18,9 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_DIRECTFB #include "SDL_DirectFB_video.h" #include "SDL_DirectFB_window.h" @@ -407,3 +410,4 @@ DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window, DFBWindowEvent * evt) return 0; } +#endif /* SDL_VIDEO_DRIVER_DIRECTFB */ diff --git a/src/video/directfb/SDL_DirectFB_dyn.c b/src/video/directfb/SDL_DirectFB_dyn.c index 90075893d..840586b58 100644 --- a/src/video/directfb/SDL_DirectFB_dyn.c +++ b/src/video/directfb/SDL_DirectFB_dyn.c @@ -18,9 +18,10 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ - #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_DIRECTFB + #include "SDL_DirectFB_video.h" #include "SDL_DirectFB_dyn.h" @@ -112,3 +113,5 @@ SDL_DirectFB_UnLoadLibrary(void) { } #endif + +#endif /* SDL_VIDEO_DRIVER_DIRECTFB */ diff --git a/src/video/directfb/SDL_DirectFB_events.c b/src/video/directfb/SDL_DirectFB_events.c index 72bd7452e..1a935144b 100644 --- a/src/video/directfb/SDL_DirectFB_events.c +++ b/src/video/directfb/SDL_DirectFB_events.c @@ -18,6 +18,9 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_DIRECTFB /* Handle the event stream, converting DirectFB input events into SDL events */ @@ -743,3 +746,4 @@ DirectFB_QuitKeyboard(_THIS) } +#endif /* SDL_VIDEO_DRIVER_DIRECTFB */ diff --git a/src/video/directfb/SDL_DirectFB_modes.c b/src/video/directfb/SDL_DirectFB_modes.c index 33573a224..e56e413f6 100644 --- a/src/video/directfb/SDL_DirectFB_modes.c +++ b/src/video/directfb/SDL_DirectFB_modes.c @@ -18,6 +18,9 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_DIRECTFB #include "SDL_DirectFB_video.h" #include "SDL_DirectFB_modes.h" @@ -406,4 +409,6 @@ DirectFB_QuitModes(_THIS) } } +#endif /* SDL_VIDEO_DRIVER_DIRECTFB */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/directfb/SDL_DirectFB_mouse.c b/src/video/directfb/SDL_DirectFB_mouse.c index 980efd725..e83f43ae6 100644 --- a/src/video/directfb/SDL_DirectFB_mouse.c +++ b/src/video/directfb/SDL_DirectFB_mouse.c @@ -18,8 +18,10 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ - #include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_DIRECTFB + #include "SDL_assert.h" #include "SDL_DirectFB_video.h" @@ -387,4 +389,6 @@ DirectFB_QuitMouse(_THIS) #endif +#endif /* SDL_VIDEO_DRIVER_DIRECTFB */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/directfb/SDL_DirectFB_opengl.c b/src/video/directfb/SDL_DirectFB_opengl.c index 4385c8d9e..7c5737c90 100644 --- a/src/video/directfb/SDL_DirectFB_opengl.c +++ b/src/video/directfb/SDL_DirectFB_opengl.c @@ -18,6 +18,9 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_DIRECTFB #include "SDL_DirectFB_video.h" @@ -352,4 +355,6 @@ DirectFB_GL_DestroyWindowContexts(_THIS, SDL_Window * window) #endif +#endif /* SDL_VIDEO_DRIVER_DIRECTFB */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/directfb/SDL_DirectFB_render.c b/src/video/directfb/SDL_DirectFB_render.c index 39ca67a28..a2ca4be41 100644 --- a/src/video/directfb/SDL_DirectFB_render.c +++ b/src/video/directfb/SDL_DirectFB_render.c @@ -18,6 +18,9 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_DIRECTFB //#include "SDL_DirectFB_video.h" #include "SDL_DirectFB_window.h" #include "SDL_DirectFB_modes.h" @@ -1255,4 +1258,6 @@ DirectFB_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect, } #endif +#endif /* SDL_VIDEO_DRIVER_DIRECTFB */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/directfb/SDL_DirectFB_shape.c b/src/video/directfb/SDL_DirectFB_shape.c index dbc71368e..5f8f2d163 100644 --- a/src/video/directfb/SDL_DirectFB_shape.c +++ b/src/video/directfb/SDL_DirectFB_shape.c @@ -18,6 +18,9 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_DIRECTFB #include "SDL_assert.h" #include "SDL_DirectFB_video.h" @@ -128,3 +131,4 @@ DirectFB_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowSh return -1; } +#endif /* SDL_VIDEO_DRIVER_DIRECTFB */ diff --git a/src/video/directfb/SDL_DirectFB_video.c b/src/video/directfb/SDL_DirectFB_video.c index ba7eb9693..83835df2d 100644 --- a/src/video/directfb/SDL_DirectFB_video.c +++ b/src/video/directfb/SDL_DirectFB_video.c @@ -18,6 +18,9 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_DIRECTFB #include "SDL_DirectFB_video.h" @@ -416,3 +419,5 @@ void DirectFB_SetSupportedPixelFormats(SDL_RendererInfo* ri) ri->texture_formats[j++] = pixelformat_tab[i].sdl; ri->num_texture_formats = j; } + +#endif /* SDL_VIDEO_DRIVER_DIRECTFB */ diff --git a/src/video/directfb/SDL_DirectFB_window.c b/src/video/directfb/SDL_DirectFB_window.c index 274451876..094116a36 100644 --- a/src/video/directfb/SDL_DirectFB_window.c +++ b/src/video/directfb/SDL_DirectFB_window.c @@ -18,6 +18,9 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_DIRECTFB #include "SDL_DirectFB_video.h" #include "SDL_DirectFB_modes.h" @@ -520,3 +523,5 @@ DirectFB_AdjustWindowSurface(SDL_Window * window) error: return; } + +#endif /* SDL_VIDEO_DRIVER_DIRECTFB */ diff --git a/src/video/dummy/SDL_nullevents.c b/src/video/dummy/SDL_nullevents.c index c97cbd278..f348f842a 100644 --- a/src/video/dummy/SDL_nullevents.c +++ b/src/video/dummy/SDL_nullevents.c @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_DUMMY + /* Being a null driver, there's no event stream. We just define stubs for most of the API. */ @@ -34,4 +36,6 @@ DUMMY_PumpEvents(_THIS) /* do nothing. */ } +#endif /* SDL_VIDEO_DRIVER_DUMMY */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/dummy/SDL_nullframebuffer.c b/src/video/dummy/SDL_nullframebuffer.c index 44f933681..f9cca9a1d 100644 --- a/src/video/dummy/SDL_nullframebuffer.c +++ b/src/video/dummy/SDL_nullframebuffer.c @@ -20,7 +20,10 @@ */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_DUMMY + #include "../SDL_sysvideo.h" +#include "SDL_nullframebuffer_c.h" #define DUMMY_SURFACE "_SDL_DummySurface" @@ -86,4 +89,6 @@ void SDL_DUMMY_DestroyWindowFramebuffer(_THIS, SDL_Window * window) } } +#endif /* SDL_VIDEO_DRIVER_DUMMY */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/dummy/SDL_nullvideo.c b/src/video/dummy/SDL_nullvideo.c index 4e561ec61..c5c21233e 100644 --- a/src/video/dummy/SDL_nullvideo.c +++ b/src/video/dummy/SDL_nullvideo.c @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_DUMMY + /* Dummy SDL video driver implementation; this is just enough to make an * SDL-based application THINK it's got a working video driver, for * applications that call SDL_Init(SDL_INIT_VIDEO) when they don't need it, @@ -139,4 +141,6 @@ DUMMY_VideoQuit(_THIS) { } +#endif /* SDL_VIDEO_DRIVER_DUMMY */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/nds/SDL_ndsevents.c b/src/video/nds/SDL_ndsevents.c index cd7df0f99..558eda048 100644 --- a/src/video/nds/SDL_ndsevents.c +++ b/src/video/nds/SDL_ndsevents.c @@ -20,8 +20,7 @@ */ #include "SDL_config.h" -/* Being a null driver, there's no event stream. We just define stubs for - most of the API. */ +#if SDL_VIDEO_DRIVER_NDS #include #include @@ -50,4 +49,6 @@ NDS_PumpEvents(_THIS) } } +#endif /* SDL_VIDEO_DRIVER_NDS */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/nds/SDL_ndsvideo.c b/src/video/nds/SDL_ndsvideo.c index d94192b22..98d3d25e8 100644 --- a/src/video/nds/SDL_ndsvideo.c +++ b/src/video/nds/SDL_ndsvideo.c @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_NDS + /* SDL Nintendo DS video driver implementation */ #include @@ -394,4 +396,6 @@ double SDLCALL SDL_pow(double x, double y) return 0; } +#endif /* SDL_VIDEO_DRIVER_NDS */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/nds/SDL_ndswindow.c b/src/video/nds/SDL_ndswindow.c index 16589cf8a..f374a1c08 100644 --- a/src/video/nds/SDL_ndswindow.c +++ b/src/video/nds/SDL_ndswindow.c @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_NDS + #include "SDL_ndsvideo.h" @@ -30,4 +32,6 @@ int NDS_CreateWindow(_THIS, SDL_Window * window) return 0; } +#endif /* SDL_VIDEO_DRIVER_NDS */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/pandora/SDL_pandora.c b/src/video/pandora/SDL_pandora.c index f0a5ec888..880a221f9 100644 --- a/src/video/pandora/SDL_pandora.c +++ b/src/video/pandora/SDL_pandora.c @@ -18,9 +18,11 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_PANDORA /* SDL internals */ -#include "SDL_config.h" #include "../SDL_sysvideo.h" #include "SDL_version.h" #include "SDL_syswm.h" @@ -863,4 +865,6 @@ PND_gl_deletecontext(_THIS, SDL_GLContext context) return; } +#endif /* SDL_VIDEO_DRIVER_PANDORA */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/pandora/SDL_pandora_events.c b/src/video/pandora/SDL_pandora_events.c index c71366564..c6b22b18e 100644 --- a/src/video/pandora/SDL_pandora_events.c +++ b/src/video/pandora/SDL_pandora_events.c @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_PANDORA + /* Being a null driver, there's no event stream. We just define stubs for most of the API. */ @@ -31,4 +33,6 @@ PND_PumpEvents(_THIS) /* Not implemented. */ } +#endif /* SDL_VIDEO_DRIVER_PANDORA */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/uikit/SDL_uikitappdelegate.m b/src/video/uikit/SDL_uikitappdelegate.m index b62e37f90..9a3580051 100644 --- a/src/video/uikit/SDL_uikitappdelegate.m +++ b/src/video/uikit/SDL_uikitappdelegate.m @@ -18,6 +18,9 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_UIKIT #import "../SDL_sysvideo.h" #import "SDL_assert.h" @@ -159,4 +162,6 @@ - (void) applicationDidBecomeActive:(UIApplication*)application @end +#endif /* SDL_VIDEO_DRIVER_UIKIT */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/uikit/SDL_uikitevents.m b/src/video/uikit/SDL_uikitevents.m index 0edffd825..fb91ba233 100644 --- a/src/video/uikit/SDL_uikitevents.m +++ b/src/video/uikit/SDL_uikitevents.m @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_UIKIT + #include "../../events/SDL_events_c.h" #include "SDL_uikitvideo.h" @@ -51,4 +53,6 @@ So what we do is that in the UIApplicationDelegate class (SDLUIApplicationDelega } } +#endif /* SDL_VIDEO_DRIVER_UIKIT */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/uikit/SDL_uikitopengles.m b/src/video/uikit/SDL_uikitopengles.m index 085460653..d8ed4e4d0 100644 --- a/src/video/uikit/SDL_uikitopengles.m +++ b/src/video/uikit/SDL_uikitopengles.m @@ -18,6 +18,9 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_UIKIT #include "SDL_uikitopengles.h" #include "SDL_uikitopenglview.h" @@ -27,6 +30,7 @@ #include "SDL_sysvideo.h" #include "../../events/SDL_keyboard_c.h" #include "../../events/SDL_mouse_c.h" +#include "../../power/uikit/SDL_syspower.h" #include "SDL_loadso.h" #include @@ -73,8 +77,6 @@ int UIKit_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) return 0; } -extern void SDL_UIKit_UpdateBatteryMonitoring(void); - void UIKit_GL_SwapWindow(_THIS, SDL_Window * window) { #ifdef SDL_POWER_UIKIT @@ -101,7 +103,6 @@ SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window) { SDL_uikitopenglview *view; SDL_WindowData *data = (SDL_WindowData *) window->driverdata; - UIScreen *uiscreen = (UIScreen *) SDL_GetDisplayForWindow(window)->driverdata; UIWindow *uiwindow = data->uiwindow; /* construct our view, passing in SDL's OpenGL configuration data */ @@ -150,4 +151,6 @@ void UIKit_GL_DeleteContext(_THIS, SDL_GLContext context) [view release]; } +#endif /* SDL_VIDEO_DRIVER_UIKIT */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/uikit/SDL_uikitopenglview.m b/src/video/uikit/SDL_uikitopenglview.m index 7f03d36b4..ffb298520 100644 --- a/src/video/uikit/SDL_uikitopenglview.m +++ b/src/video/uikit/SDL_uikitopenglview.m @@ -18,6 +18,9 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_UIKIT #import #import @@ -192,4 +195,6 @@ - (void)dealloc @end +#endif /* SDL_VIDEO_DRIVER_UIKIT */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/uikit/SDL_uikitvideo.m b/src/video/uikit/SDL_uikitvideo.m index 6a5cf5cd0..ba154e875 100644 --- a/src/video/uikit/SDL_uikitvideo.m +++ b/src/video/uikit/SDL_uikitvideo.m @@ -18,10 +18,11 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ +#include "SDL_config.h" -#import +#if SDL_VIDEO_DRIVER_UIKIT -#include "SDL_config.h" +#import #include "SDL_video.h" #include "SDL_mouse.h" @@ -143,7 +144,6 @@ static void UIKit_DeleteDevice(SDL_VideoDevice * device) return; } - const NSArray *modes = [uiscreen availableModes]; for (UIScreenMode *uimode in [uiscreen availableModes]) { CGSize size = [uimode size]; mode.format = SDL_PIXELFORMAT_ABGR8888; @@ -274,4 +274,6 @@ static void UIKit_DeleteDevice(SDL_VideoDevice * device) } } +#endif /* SDL_VIDEO_DRIVER_UIKIT */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/uikit/SDL_uikitview.m b/src/video/uikit/SDL_uikitview.m index ad5588ede..e2e69d296 100644 --- a/src/video/uikit/SDL_uikitview.m +++ b/src/video/uikit/SDL_uikitview.m @@ -18,6 +18,9 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_UIKIT #import "SDL_uikitview.h" @@ -28,6 +31,7 @@ #if SDL_IPHONE_KEYBOARD #import "keyinfotable.h" #import "SDL_uikitappdelegate.h" +#import "SDL_uikitkeyboard.h" #import "SDL_uikitwindow.h" #endif @@ -311,7 +315,7 @@ - (BOOL)textFieldShouldReturn:(UITextField*)_textField /* iPhone keyboard addition functions */ #if SDL_IPHONE_KEYBOARD -SDL_uikitview * getWindowView(SDL_Window * window) +static SDL_uikitview * getWindowView(SDL_Window * window) { if (window == NULL) { SDL_SetError("Window does not exist"); @@ -405,4 +409,6 @@ int SDL_iPhoneKeyboardToggle(SDL_Window * window) #endif /* SDL_IPHONE_KEYBOARD */ +#endif /* SDL_VIDEO_DRIVER_UIKIT */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/uikit/SDL_uikitviewcontroller.m b/src/video/uikit/SDL_uikitviewcontroller.m index 3d436fef3..497ef929b 100644 --- a/src/video/uikit/SDL_uikitviewcontroller.m +++ b/src/video/uikit/SDL_uikitviewcontroller.m @@ -1,25 +1,27 @@ /* - Simple DirectMedia Layer - Copyright (C) 1997-2011 Sam Lantinga - - 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. - */ + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + 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" +#if SDL_VIDEO_DRIVER_UIKIT + #include "SDL_video.h" #include "SDL_assert.h" #include "SDL_hints.h" @@ -150,4 +152,6 @@ - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceO SDL_SendWindowEvent(self->window, SDL_WINDOWEVENT_RESIZED, w, h); } +#endif /* SDL_VIDEO_DRIVER_UIKIT */ + @end diff --git a/src/video/uikit/SDL_uikitwindow.m b/src/video/uikit/SDL_uikitwindow.m index 8a0a5b1ad..515f6c9d1 100644 --- a/src/video/uikit/SDL_uikitwindow.m +++ b/src/video/uikit/SDL_uikitwindow.m @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_UIKIT + #include "SDL_syswm.h" #include "SDL_video.h" #include "SDL_mouse.h" @@ -88,11 +90,11 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo [UIApplication sharedApplication].statusBarHidden = NO; } - const UIDeviceOrientation o = [[UIDevice currentDevice] orientation]; - const BOOL landscape = (o == UIDeviceOrientationLandscapeLeft) || - (o == UIDeviceOrientationLandscapeRight); - const BOOL rotate = ( ((window->w > window->h) && (!landscape)) || - ((window->w < window->h) && (landscape)) ); + //const UIDeviceOrientation o = [[UIDevice currentDevice] orientation]; + //const BOOL landscape = (o == UIDeviceOrientationLandscapeLeft) || + // (o == UIDeviceOrientationLandscapeRight); + //const BOOL rotate = ( ((window->w > window->h) && (!landscape)) || + // ((window->w < window->h) && (landscape)) ); // The View Controller will handle rotating the view when the // device orientation changes. This will trigger resize events, if @@ -215,4 +217,6 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo } } +#endif /* SDL_VIDEO_DRIVER_UIKIT */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/windows/SDL_windowsclipboard.c b/src/video/windows/SDL_windowsclipboard.c index 12d02281f..1310a18e1 100644 --- a/src/video/windows/SDL_windowsclipboard.c +++ b/src/video/windows/SDL_windowsclipboard.c @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_WINDOWS + #include "SDL_windowsvideo.h" #include "SDL_windowswindow.h" #include "../../events/SDL_clipboardevents_c.h" @@ -163,4 +165,6 @@ WIN_CheckClipboardUpdate(struct SDL_VideoData * data) } } +#endif /* SDL_VIDEO_DRIVER_WINDOWS */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c index cf382e0d0..62bb92e43 100644 --- a/src/video/windows/SDL_windowsevents.c +++ b/src/video/windows/SDL_windowsevents.c @@ -18,9 +18,10 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ - #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_WINDOWS + #include "SDL_windowsvideo.h" #include "SDL_windowsshape.h" #include "SDL_syswm.h" @@ -694,4 +695,6 @@ SDL_UnregisterApp() } } +#endif /* SDL_VIDEO_DRIVER_WINDOWS */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/windows/SDL_windowsframebuffer.c b/src/video/windows/SDL_windowsframebuffer.c index 3e4c271a3..13948006d 100644 --- a/src/video/windows/SDL_windowsframebuffer.c +++ b/src/video/windows/SDL_windowsframebuffer.c @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_WINDOWS + #include "SDL_windowsvideo.h" #ifndef _WIN32_WCE @@ -121,4 +123,6 @@ void WIN_DestroyWindowFramebuffer(_THIS, SDL_Window * window) } } +#endif /* SDL_VIDEO_DRIVER_WINDOWS */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/windows/SDL_windowskeyboard.c b/src/video/windows/SDL_windowskeyboard.c index ca03e529b..a824505f4 100644 --- a/src/video/windows/SDL_windowskeyboard.c +++ b/src/video/windows/SDL_windowskeyboard.c @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_WINDOWS + #ifdef _WIN32_WCE #define SDL_DISABLE_WINDOWS_IME #endif @@ -1539,4 +1541,6 @@ void IME_Present(SDL_VideoData *videodata) #endif /* SDL_DISABLE_WINDOWS_IME */ +#endif /* SDL_VIDEO_DRIVER_WINDOWS */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/windows/SDL_windowsmodes.c b/src/video/windows/SDL_windowsmodes.c index 4f7a418b9..71092ac93 100644 --- a/src/video/windows/SDL_windowsmodes.c +++ b/src/video/windows/SDL_windowsmodes.c @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_WINDOWS + #include "SDL_windowsvideo.h" /* Windows CE compatibility */ @@ -316,4 +318,6 @@ WIN_QuitModes(_THIS) /* All fullscreen windows should have restored modes by now */ } +#endif /* SDL_VIDEO_DRIVER_WINDOWS */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/windows/SDL_windowsmouse.c b/src/video/windows/SDL_windowsmouse.c index 0b6b4d738..0a0011fa9 100644 --- a/src/video/windows/SDL_windowsmouse.c +++ b/src/video/windows/SDL_windowsmouse.c @@ -18,9 +18,10 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ - #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_WINDOWS + #include "SDL_assert.h" #include "SDL_windowsvideo.h" @@ -162,4 +163,6 @@ WIN_QuitMouse(_THIS) { } +#endif /* SDL_VIDEO_DRIVER_WINDOWS */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/windows/SDL_windowsopengl.c b/src/video/windows/SDL_windowsopengl.c index f9ebf91d2..a69f30864 100644 --- a/src/video/windows/SDL_windowsopengl.c +++ b/src/video/windows/SDL_windowsopengl.c @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_WINDOWS + #include "SDL_windowsvideo.h" /* WGL implementation of SDL OpenGL support */ @@ -605,4 +607,6 @@ WIN_GL_DeleteContext(_THIS, SDL_GLContext context) #endif /* SDL_VIDEO_OPENGL_WGL */ +#endif /* SDL_VIDEO_DRIVER_WINDOWS */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/windows/SDL_windowsshape.c b/src/video/windows/SDL_windowsshape.c index 909c5d35f..e915ae067 100644 --- a/src/video/windows/SDL_windowsshape.c +++ b/src/video/windows/SDL_windowsshape.c @@ -18,8 +18,10 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_WINDOWS -#include #include "SDL_assert.h" #include "SDL_windowsshape.h" #include "SDL_windowsvideo.h" @@ -101,3 +103,5 @@ Win32_ResizeWindowShape(SDL_Window *window) { return 0; } + +#endif /* SDL_VIDEO_DRIVER_WINDOWS */ diff --git a/src/video/windows/SDL_windowsvideo.c b/src/video/windows/SDL_windowsvideo.c index a1495493b..c90e91955 100644 --- a/src/video/windows/SDL_windowsvideo.c +++ b/src/video/windows/SDL_windowsvideo.c @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_WINDOWS + #include "SDL_main.h" #include "SDL_video.h" #include "SDL_mouse.h" @@ -186,4 +188,6 @@ WIN_VideoQuit(_THIS) WIN_QuitMouse(_this); } +#endif /* SDL_VIDEO_DRIVER_WINDOWS */ + /* vim: set ts=4 sw=4 expandtab: */ diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c index b441d9675..3caac8010 100644 --- a/src/video/windows/SDL_windowswindow.c +++ b/src/video/windows/SDL_windowswindow.c @@ -20,6 +20,8 @@ */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_WINDOWS + #include "../SDL_sysvideo.h" #include "../SDL_pixels_c.h" #include "../../events/SDL_keyboard_c.h" @@ -746,4 +748,6 @@ SDL_HelperWindowDestroy(void) } } +#endif /* SDL_VIDEO_DRIVER_WINDOWS */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/x11/SDL_x11opengl.c b/src/video/x11/SDL_x11opengl.c index 2e6d0130f..0cb186b57 100644 --- a/src/video/x11/SDL_x11opengl.c +++ b/src/video/x11/SDL_x11opengl.c @@ -19,6 +19,9 @@ 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_X11 + #include "SDL_x11video.h" #include "SDL_assert.h" @@ -610,4 +613,6 @@ X11_GL_DeleteContext(_THIS, SDL_GLContext context) #endif /* SDL_VIDEO_OPENGL_GLX */ +#endif /* SDL_VIDEO_DRIVER_X11 */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/x11/SDL_x11opengles.c b/src/video/x11/SDL_x11opengles.c index 3e4d42185..0e545d257 100644 --- a/src/video/x11/SDL_x11opengles.c +++ b/src/video/x11/SDL_x11opengles.c @@ -20,7 +20,7 @@ */ #include "SDL_config.h" -#if SDL_VIDEO_OPENGL_ES +#if SDL_VIDEO_DRIVER_X11 && SDL_VIDEO_OPENGL_ES #include "SDL_x11video.h" #include "SDL_x11opengles.h" @@ -360,6 +360,6 @@ X11_GLES_DeleteContext(_THIS, SDL_GLContext context) } -#endif /* SDL_VIDEO_OPENGL_ES */ +#endif /* SDL_VIDEO_DRIVER_X11 && SDL_VIDEO_OPENGL_ES */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/video/x11/imKStoUCS.c b/src/video/x11/imKStoUCS.c index c17a1b304..5dd6b1ddd 100644 --- a/src/video/x11/imKStoUCS.c +++ b/src/video/x11/imKStoUCS.c @@ -22,6 +22,9 @@ be used in advertising or otherwise to promote the sale, use or other deal- ings in this Software without prior written authorization from the XFree86 Project. */ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_X11 /* $XFree86: xc/lib/X11/imKStoUCS.c,v 1.4 2003/04/29 11:29:18 pascal Exp $ */ @@ -343,3 +346,5 @@ X11_KeySymToUcs4(KeySym keysym) else return 0; } + +#endif /* SDL_VIDEO_DRIVER_X11 */ From ee9413e744bc7b435d36cdf5ff01efa75a185654 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Mon, 31 Oct 2011 23:37:57 -0400 Subject: [PATCH 14/24] Fix crash on X servers without UTF-8 support. --- src/video/x11/SDL_x11window.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index 1471185dd..94664fa47 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -265,6 +265,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) Atom _NET_WM_WINDOW_TYPE_NORMAL; int wmstate_count; Atom wmstate_atoms[3]; + Uint32 fevent = 0; #if SDL_VIDEO_DRIVER_X11_XINERAMA /* FIXME @@ -554,28 +555,19 @@ X11_CreateWindow(_THIS, SDL_Window * window) } #ifdef X_HAVE_UTF8_STRING - { - Uint32 fevent = 0; + if (SDL_X11_HAVE_UTF8) { pXGetICValues(((SDL_WindowData *) window->driverdata)->ic, XNFilterEvents, &fevent, NULL); - XSelectInput(display, w, - (FocusChangeMask | EnterWindowMask | LeaveWindowMask | - ExposureMask | ButtonPressMask | ButtonReleaseMask | - PointerMotionMask | KeyPressMask | KeyReleaseMask | - PropertyChangeMask | StructureNotifyMask | - KeymapStateMask | fevent)); - } -#else - { - XSelectInput(display, w, - (FocusChangeMask | EnterWindowMask | LeaveWindowMask | - ExposureMask | ButtonPressMask | ButtonReleaseMask | - PointerMotionMask | KeyPressMask | KeyReleaseMask | - PropertyChangeMask | StructureNotifyMask | - KeymapStateMask)); } #endif + XSelectInput(display, w, + (FocusChangeMask | EnterWindowMask | LeaveWindowMask | + ExposureMask | ButtonPressMask | ButtonReleaseMask | + PointerMotionMask | KeyPressMask | KeyReleaseMask | + PropertyChangeMask | StructureNotifyMask | + KeymapStateMask | fevent)); + XFlush(display); return 0; From 58b6bff66e23be9b5ef6301deacdf8c3190c94be Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 3 Nov 2011 11:51:47 -0400 Subject: [PATCH 15/24] Fixed some preprocessor mistakes introduced in iOS project cleanup. --- src/audio/alsa/SDL_alsa_audio.c | 6 +++--- src/audio/arts/SDL_artsaudio.c | 4 ++-- src/audio/esd/SDL_esdaudio.c | 4 ++-- src/audio/fusionsound/SDL_fsaudio.c | 4 ++-- src/audio/nas/SDL_nasaudio.c | 4 ++-- src/audio/pulseaudio/SDL_pulseaudio.c | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/audio/alsa/SDL_alsa_audio.c b/src/audio/alsa/SDL_alsa_audio.c index eb754ec44..f3e4b0a23 100644 --- a/src/audio/alsa/SDL_alsa_audio.c +++ b/src/audio/alsa/SDL_alsa_audio.c @@ -35,7 +35,7 @@ #include "../SDL_audio_c.h" #include "SDL_alsa_audio.h" -#if SDL_AUDIO_DRIVER_ALSA_DYNAMIC +#ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC #include "SDL_loadso.h" #endif @@ -86,7 +86,7 @@ static int (*ALSA_snd_pcm_wait)(snd_pcm_t *, int); static int (*ALSA_snd_pcm_sw_params_set_avail_min) (snd_pcm_t *, snd_pcm_sw_params_t *, snd_pcm_uframes_t); -#if SDL_AUDIO_DRIVER_ALSA_DYNAMIC +#ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC #define snd_pcm_hw_params_sizeof ALSA_snd_pcm_hw_params_sizeof #define snd_pcm_sw_params_sizeof ALSA_snd_pcm_sw_params_sizeof @@ -149,7 +149,7 @@ load_alsa_syms(void) #undef SDL_ALSA_SYM -#if SDL_AUDIO_DRIVER_ALSA_DYNAMIC +#ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC static void UnloadALSALibrary(void) diff --git a/src/audio/arts/SDL_artsaudio.c b/src/audio/arts/SDL_artsaudio.c index 25d7bd40f..57c29c56b 100644 --- a/src/audio/arts/SDL_artsaudio.c +++ b/src/audio/arts/SDL_artsaudio.c @@ -36,14 +36,14 @@ #include "../SDL_audio_c.h" #include "SDL_artsaudio.h" -#if SDL_AUDIO_DRIVER_ARTS_DYNAMIC +#ifdef SDL_AUDIO_DRIVER_ARTS_DYNAMIC #include "SDL_name.h" #include "SDL_loadso.h" #else #define SDL_NAME(X) X #endif -#if SDL_AUDIO_DRIVER_ARTS_DYNAMIC +#ifdef SDL_AUDIO_DRIVER_ARTS_DYNAMIC static const char *arts_library = SDL_AUDIO_DRIVER_ARTS_DYNAMIC; static void *arts_handle = NULL; diff --git a/src/audio/esd/SDL_esdaudio.c b/src/audio/esd/SDL_esdaudio.c index e824e9564..03ae3278a 100644 --- a/src/audio/esd/SDL_esdaudio.c +++ b/src/audio/esd/SDL_esdaudio.c @@ -36,14 +36,14 @@ #include "../SDL_audio_c.h" #include "SDL_esdaudio.h" -#if SDL_AUDIO_DRIVER_ESD_DYNAMIC +#ifdef SDL_AUDIO_DRIVER_ESD_DYNAMIC #include "SDL_name.h" #include "SDL_loadso.h" #else #define SDL_NAME(X) X #endif -#if SDL_AUDIO_DRIVER_ESD_DYNAMIC +#ifdef SDL_AUDIO_DRIVER_ESD_DYNAMIC static const char *esd_library = SDL_AUDIO_DRIVER_ESD_DYNAMIC; static void *esd_handle = NULL; diff --git a/src/audio/fusionsound/SDL_fsaudio.c b/src/audio/fusionsound/SDL_fsaudio.c index 3ba9ba773..05bd1754e 100644 --- a/src/audio/fusionsound/SDL_fsaudio.c +++ b/src/audio/fusionsound/SDL_fsaudio.c @@ -39,7 +39,7 @@ //#define SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC "libfusionsound.so" -#if SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC +#ifdef SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC #include "SDL_name.h" #include "SDL_loadso.h" #else @@ -53,7 +53,7 @@ typedef DFBResult DirectResult; /* Buffers to use - more than 2 gives a lot of latency */ #define FUSION_BUFFERS (2) -#if SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC +#ifdef SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC static const char *fs_library = SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC; static void *fs_handle = NULL; diff --git a/src/audio/nas/SDL_nasaudio.c b/src/audio/nas/SDL_nasaudio.c index a31faad39..d44f55627 100644 --- a/src/audio/nas/SDL_nasaudio.c +++ b/src/audio/nas/SDL_nasaudio.c @@ -52,7 +52,7 @@ static AuEventHandlerRec *(*NAS_AuRegisterEventHandler) (AuServer *, AuMask, int, AuID, AuEventHandlerCallback, AuPointer); -#if SDL_AUDIO_DRIVER_NAS_DYNAMIC +#ifdef SDL_AUDIO_DRIVER_NAS_DYNAMIC static const char *nas_library = SDL_AUDIO_DRIVER_NAS_DYNAMIC; static void *nas_handle = NULL; @@ -91,7 +91,7 @@ load_nas_syms(void) #undef SDL_NAS_SYM -#if SDL_AUDIO_DRIVER_NAS_DYNAMIC +#ifdef SDL_AUDIO_DRIVER_NAS_DYNAMIC static void UnloadNASLibrary(void) diff --git a/src/audio/pulseaudio/SDL_pulseaudio.c b/src/audio/pulseaudio/SDL_pulseaudio.c index b3e0b4e58..6b2333e02 100644 --- a/src/audio/pulseaudio/SDL_pulseaudio.c +++ b/src/audio/pulseaudio/SDL_pulseaudio.c @@ -106,7 +106,7 @@ static void (*PULSEAUDIO_pa_stream_unref) (pa_stream *); static int load_pulseaudio_syms(void); -#if SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC +#ifdef SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC static const char *pulseaudio_library = SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC; static void *pulseaudio_handle = NULL; From 244d2416fde640f9d6e906d48c44ff30585ad8e4 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 6 Nov 2011 17:05:48 -0500 Subject: [PATCH 16/24] Mac OS X: Fixed build when compiling without Cocoa support. Thanks to Martin Gerhardy for the patch! --- src/SDL_assert.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SDL_assert.c b/src/SDL_assert.c index ba4fb066f..9d6416253 100644 --- a/src/SDL_assert.c +++ b/src/SDL_assert.c @@ -319,7 +319,7 @@ SDL_PromptAssertion(const SDL_assert_data *data, void *userdata) #ifdef __WIN32__ state = SDL_PromptAssertion_windows(data); -#elif __MACOSX__ +#elif defined __MACOSX__ && defined SDL_VIDEO_DRIVER_COCOA /* This has to be done in an Objective-C (*.m) file, so we call out. */ extern SDL_assert_state SDL_PromptAssertion_cocoa(const SDL_assert_data *); state = SDL_PromptAssertion_cocoa(data); From 3be0d4af6ad9918d682681ae33f1097e8561a001 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 7 Nov 2011 00:45:13 -0500 Subject: [PATCH 17/24] Fixed double-free in the shader cache at shutdown --- src/render/opengles2/SDL_render_gles2.c | 36 ++++++++++++++++--------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c index fc3a9d31f..46f6933f0 100644 --- a/src/render/opengles2/SDL_render_gles2.c +++ b/src/render/opengles2/SDL_render_gles2.c @@ -190,24 +190,34 @@ static void GLES2_DestroyRenderer(SDL_Renderer *renderer) { GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; - GLES2_ProgramCacheEntry *entry; - GLES2_ProgramCacheEntry *next; /* Deallocate everything */ if (rdata) { GLES2_ActivateRenderer(renderer); - entry = rdata->program_cache.head; - while (entry) { - glDeleteShader(entry->vertex_shader->id); - glDeleteShader(entry->fragment_shader->id); - SDL_free(entry->vertex_shader); - SDL_free(entry->fragment_shader); - glDeleteProgram(entry->id); - next = entry->next; - SDL_free(entry); - entry = next; - } + { + GLES2_ShaderCacheEntry *entry; + GLES2_ShaderCacheEntry *next; + entry = rdata->shader_cache.head; + while (entry) + { + glDeleteShader(entry->id); + next = entry->next; + SDL_free(entry); + entry = next; + } + } + { + GLES2_ProgramCacheEntry *entry; + GLES2_ProgramCacheEntry *next; + entry = rdata->program_cache.head; + while (entry) { + glDeleteProgram(entry->id); + next = entry->next; + SDL_free(entry); + entry = next; + } + } if (rdata->context) { SDL_GL_DeleteContext(rdata->context); } From 78290b441d1669112873d3296f9678e903758b28 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 7 Nov 2011 02:25:01 -0500 Subject: [PATCH 18/24] Fixed a typo in the header. --- include/SDL_events.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/SDL_events.h b/include/SDL_events.h index 804ac57e7..4ba6c0dde 100644 --- a/include/SDL_events.h +++ b/include/SDL_events.h @@ -280,7 +280,7 @@ typedef struct SDL_JoyButtonEvent /** - * \brief Touch finger motion/finger event structure (event.tmotion.*) + * \brief Touch finger motion/finger event structure (event.tfinger.*) */ typedef struct SDL_TouchFingerEvent { @@ -302,7 +302,7 @@ typedef struct SDL_TouchFingerEvent /** - * \brief Touch finger motion/finger event structure (event.tmotion.*) + * \brief Touch finger motion/finger event structure (event.tbutton.*) */ typedef struct SDL_TouchButtonEvent { From 6cf371852a3a3959f86d0aadd1060be0fe3ebfed Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 7 Nov 2011 02:24:52 -0500 Subject: [PATCH 19/24] Need to send a key up, silly. --- src/video/uikit/SDL_uikitview.m | 1 + 1 file changed, 1 insertion(+) diff --git a/src/video/uikit/SDL_uikitview.m b/src/video/uikit/SDL_uikitview.m index e2e69d296..18ff7e954 100644 --- a/src/video/uikit/SDL_uikitview.m +++ b/src/video/uikit/SDL_uikitview.m @@ -304,6 +304,7 @@ - (BOOL)textField:(UITextField *)_textField shouldChangeCharactersInRange:(NSRan - (BOOL)textFieldShouldReturn:(UITextField*)_textField { SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RETURN); + SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RETURN); [self hideKeyboard]; return YES; } From 1ca94c1fa3dd8dfff6b5eeed2ae8d9eded77efdc Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 7 Nov 2011 23:07:00 -0500 Subject: [PATCH 20/24] Fixed SDL applications being killed immediately after being backgrounded, because they were trying to draw while minimized. --- src/render/SDL_render.c | 38 +++++++++++++++++++++++++ src/render/SDL_sysrender.h | 1 + src/render/opengles/SDL_render_gles.c | 5 ++++ src/render/opengles2/SDL_render_gles2.c | 5 ++++ 4 files changed, 49 insertions(+) diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index 251ae3cce..15a52e6e8 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -111,6 +111,10 @@ SDL_RendererEventWatch(void *userdata, SDL_Event *event) viewport.w = renderer->viewport.w; viewport.h = renderer->viewport.h; SDL_RenderSetViewport(renderer, &viewport); + } else if (event->window.event == SDL_WINDOWEVENT_MINIMIZED) { + renderer->minimized = SDL_TRUE; + } else if (event->window.event == SDL_WINDOWEVENT_RESTORED) { + renderer->minimized = SDL_FALSE; } } } @@ -189,6 +193,12 @@ SDL_CreateRenderer(SDL_Window * window, int index, Uint32 flags) renderer->magic = &renderer_magic; renderer->window = window; + if (SDL_GetWindowFlags(window) & SDL_WINDOW_MINIMIZED) { + renderer->minimized = SDL_TRUE; + } else { + renderer->minimized = SDL_FALSE; + } + SDL_SetWindowData(window, SDL_WINDOWRENDERDATA, renderer); SDL_RenderSetViewport(renderer, NULL); @@ -873,6 +883,10 @@ SDL_RenderClear(SDL_Renderer * renderer) { CHECK_RENDERER_MAGIC(renderer, -1); + /* Don't draw while we're minimized */ + if (renderer->minimized) { + return 0; + } return renderer->RenderClear(renderer); } @@ -899,6 +913,10 @@ SDL_RenderDrawPoints(SDL_Renderer * renderer, if (count < 1) { return 0; } + /* Don't draw while we're minimized */ + if (renderer->minimized) { + return 0; + } return renderer->RenderDrawPoints(renderer, points, count); } @@ -927,6 +945,10 @@ SDL_RenderDrawLines(SDL_Renderer * renderer, if (count < 2) { return 0; } + /* Don't draw while we're minimized */ + if (renderer->minimized) { + return 0; + } return renderer->RenderDrawLines(renderer, points, count); } @@ -976,6 +998,10 @@ SDL_RenderDrawRects(SDL_Renderer * renderer, return 0; } + /* Don't draw while we're minimized */ + if (renderer->minimized) { + return 0; + } for (i = 0; i < count; ++i) { if (SDL_RenderDrawRect(renderer, &rects[i]) < 0) { return -1; @@ -1015,6 +1041,10 @@ SDL_RenderFillRects(SDL_Renderer * renderer, if (count < 1) { return 0; } + /* Don't draw while we're minimized */ + if (renderer->minimized) { + return 0; + } return renderer->RenderFillRects(renderer, rects, count); } @@ -1072,6 +1102,10 @@ SDL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, texture = texture->native; } + /* Don't draw while we're minimized */ + if (renderer->minimized) { + return 0; + } return renderer->RenderCopy(renderer, texture, &real_srcrect, &real_dstrect); } @@ -1121,6 +1155,10 @@ SDL_RenderPresent(SDL_Renderer * renderer) { CHECK_RENDERER_MAGIC(renderer, ); + /* Don't draw while we're minimized */ + if (renderer->minimized) { + return; + } renderer->RenderPresent(renderer); } diff --git a/src/render/SDL_sysrender.h b/src/render/SDL_sysrender.h index c908258f8..368dfc4e3 100644 --- a/src/render/SDL_sysrender.h +++ b/src/render/SDL_sysrender.h @@ -99,6 +99,7 @@ struct SDL_Renderer /* The window associated with the renderer */ SDL_Window *window; + SDL_bool minimized; /* The drawable area within the window */ SDL_Rect viewport; diff --git a/src/render/opengles/SDL_render_gles.c b/src/render/opengles/SDL_render_gles.c index 844acee35..7f4b5c580 100644 --- a/src/render/opengles/SDL_render_gles.c +++ b/src/render/opengles/SDL_render_gles.c @@ -279,6 +279,11 @@ GLES_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) /* Rebind the context to the window area and update matrices */ SDL_CurrentContext = NULL; } + + if (event->event == SDL_WINDOWEVENT_MINIMIZED) { + /* According to Apple documentation, we need to finish drawing NOW! */ + glFinish(); + } } static __inline__ int diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c index 46f6933f0..4e7567469 100644 --- a/src/render/opengles2/SDL_render_gles2.c +++ b/src/render/opengles2/SDL_render_gles2.c @@ -169,6 +169,11 @@ GLES2_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) /* Rebind the context to the window area */ SDL_CurrentContext = NULL; } + + if (event->event == SDL_WINDOWEVENT_MINIMIZED) { + /* According to Apple documentation, we need to finish drawing NOW! */ + glFinish(); + } } static int From 38fe7cf4c7ed46d8b3555a7c30a358486773fcf3 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 7 Nov 2011 23:10:49 -0500 Subject: [PATCH 21/24] Fixed list loop caused when there are two entries in the list and the one being returned is already at the head. --- src/render/opengles2/SDL_render_gles2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c index 4e7567469..0901b95a4 100644 --- a/src/render/opengles2/SDL_render_gles2.c +++ b/src/render/opengles2/SDL_render_gles2.c @@ -470,7 +470,7 @@ GLES2_CacheProgram(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *vertex, } if (entry) { - if (rdata->program_cache.count > 1) + if (rdata->program_cache.head != entry) { if (entry->next) entry->next->prev = entry->prev; From c00d25a58020c1d5ecd902c330860189f1e03d1c Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 8 Nov 2011 00:02:47 -0500 Subject: [PATCH 22/24] Fixed a typo, we should set the driverdata if we are 3.2 or newer. --- src/video/uikit/SDL_uikitvideo.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video/uikit/SDL_uikitvideo.m b/src/video/uikit/SDL_uikitvideo.m index ba154e875..6a0768d3a 100644 --- a/src/video/uikit/SDL_uikitvideo.m +++ b/src/video/uikit/SDL_uikitvideo.m @@ -178,7 +178,7 @@ static void UIKit_DeleteDevice(SDL_VideoDevice * device) // UIScreenMode showed up in 3.2 (the iPad and later). We're // misusing this supports_multiple_displays flag here for that. - if (!SDL_UIKit_supports_multiple_displays) { + if (SDL_UIKit_supports_multiple_displays) { UIScreenMode *uimode = [uiscreen currentMode]; [uimode retain]; // once for the desktop_mode [uimode retain]; // once for the current_mode From c0bb81e63b40dfac6e3eb51cd5ca37bc7913d979 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 8 Nov 2011 00:03:54 -0500 Subject: [PATCH 23/24] The iOS driver sets the fullscreen and shown flags on the window during creation, so we need the mode code to be aware of that, since none of the other fullscreen/shown code paths get run. FIXME: Maybe we need a better way of detecting that? --- src/video/SDL_video.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index bb26ff094..08e534d2b 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -1186,6 +1186,9 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags) SDL_SetWindowTitle(window, title); } SDL_FinishWindowCreation(window, flags); + + /* If the window was created fullscreen, make sure the mode code matches */ + SDL_UpdateFullscreenMode(window, FULLSCREEN_VISIBLE(window)); return window; } From 4106ff679520b2ab8de7b0c2bf4f10d52283040f Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 8 Nov 2011 00:17:41 -0500 Subject: [PATCH 24/24] To answer the FIXME, no, we shouldn't force this. The fullscreen flag implies borderless behavior even though the flag isn't set on the window (in case fullscreen is toggled) --- src/video/uikit/SDL_uikitwindow.m | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/video/uikit/SDL_uikitwindow.m b/src/video/uikit/SDL_uikitwindow.m index 515f6c9d1..4d58a6173 100644 --- a/src/video/uikit/SDL_uikitwindow.m +++ b/src/video/uikit/SDL_uikitwindow.m @@ -69,9 +69,6 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo window->driverdata = data; - // !!! FIXME: should we force this? Shouldn't specifying FULLSCREEN - // !!! FIXME: imply BORDERLESS? - window->flags |= SDL_WINDOW_FULLSCREEN; /* window is always fullscreen */ window->flags |= SDL_WINDOW_SHOWN; /* only one window on iOS, always shown */ // SDL_WINDOW_BORDERLESS controls whether status bar is hidden. @@ -84,7 +81,7 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo } else { window->flags |= SDL_WINDOW_INPUT_FOCUS; // always has input focus - if (window->flags & SDL_WINDOW_BORDERLESS) { + if (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_BORDERLESS)) { [UIApplication sharedApplication].statusBarHidden = YES; } else { [UIApplication sharedApplication].statusBarHidden = NO; @@ -167,7 +164,7 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo /* ignore the size user requested, and make a fullscreen window */ // !!! FIXME: can we have a smaller view? UIWindow *uiwindow = [UIWindow alloc]; - if (window->flags & SDL_WINDOW_BORDERLESS) + if (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_BORDERLESS)) uiwindow = [uiwindow initWithFrame:[uiscreen bounds]]; else uiwindow = [uiwindow initWithFrame:[uiscreen applicationFrame]];