Skip to content

Commit 4dfab01

Browse files
committed
Update SDL2, SDL2_ttf, SDL2_mixer, SDL2_image to latest releases
1 parent f4a91b0 commit 4dfab01

File tree

13 files changed

+106
-142
lines changed

13 files changed

+106
-142
lines changed

pythonforandroid/bootstraps/sdl2/build/src/main/java/org/kivy/android/PythonActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ protected void onPostExecute(String result) {
199199
))) {
200200
// Because sometimes the app will get stuck here and never
201201
// actually run, ensure that it gets launched if we're active:
202-
mActivity.onResume();
202+
mActivity.resumeNativeThread();
203203
}
204204
}
205205

Lines changed: 35 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
--- a/src/main/java/org/libsdl/app/SDLActivity.java
22
+++ b/src/main/java/org/libsdl/app/SDLActivity.java
3-
@@ -94,6 +94,8 @@
3+
@@ -225,6 +225,8 @@
44
// This is what SDL runs in. It invokes SDL_main(), eventually
55
protected static Thread mSDLThread;
6-
6+
77
+ public static int keyboardInputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;
88
+
99
protected static SDLGenericMotionListener_API12 getMotionListener() {
1010
if (mMotionListener == null) {
1111
if (Build.VERSION.SDK_INT >= 26) {
12-
@@ -196,6 +198,15 @@
12+
@@ -323,6 +325,15 @@
1313
Log.v(TAG, "onCreate()");
1414
super.onCreate(savedInstanceState);
15-
15+
1616
+ SDLActivity.initialize();
1717
+ // So we can call stuff from static callbacks
1818
+ mSingleton = this;
@@ -22,70 +22,54 @@
2222
+ // and we can't run setup tasks until that thread completes.
2323
+ protected void finishLoad() {
2424
+
25-
// Load shared libraries
26-
String errorMsgBrokenLib = "";
2725
try {
28-
@@ -639,7 +650,7 @@
26+
Thread.currentThread().setName("SDLActivity");
27+
} catch (Exception e) {
28+
@@ -824,7 +835,7 @@
2929
Handler commandHandler = new SDLCommandHandler();
30-
30+
3131
// Send a message from the SDLMain thread
3232
- boolean sendCommand(int command, Object data) {
3333
+ protected boolean sendCommand(int command, Object data) {
3434
Message msg = commandHandler.obtainMessage();
3535
msg.arg1 = command;
3636
msg.obj = data;
37-
@@ -1051,6 +1062,21 @@
38-
return Arrays.copyOf(filtered, used);
37+
@@ -1302,6 +1313,20 @@
38+
return SDLActivity.mSurface.getNativeSurface();
3939
}
40-
41-
+ /**
42-
+ * Calls turnActive() on singleton to keep loading screen active
43-
+ */
44-
+ public static void triggerAppConfirmedActive() {
45-
+ mSingleton.appConfirmedActive();
46-
+ }
47-
+
48-
+ /**
49-
+ * Trick needed for loading screen, overridden by PythonActivity
50-
+ * to keep loading screen active
51-
+ */
52-
+ public void appConfirmedActive() {
53-
+ }
54-
+
40+
41+
+ /**
42+
+ * Calls turnActive() on singleton to keep loading screen active
43+
+ */
44+
+ public static void triggerAppConfirmedActive() {
45+
+ mSingleton.appConfirmedActive();
46+
+ }
47+
+
48+
+ /**
49+
+ * Trick needed for loading screen, overridden by PythonActivity
50+
+ * to keep loading screen active
51+
+ */
52+
+ public void appConfirmedActive() {
53+
+ }
5554
+
56-
// APK expansion files support
57-
58-
/** com.android.vending.expansion.zipfile.ZipResourceFile object or null. */
59-
@@ -1341,14 +1367,13 @@
60-
};
61-
62-
public void onSystemUiVisibilityChange(int visibility) {
63-
- if (SDLActivity.mFullscreenModeActive && (visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0 || (visibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0) {
64-
-
65-
+ // SDL2 BUGFIX (see sdl bug #4424 ) - REMOVE WHEN FIXED IN UPSTREAM !!
66-
+ if (SDLActivity.mFullscreenModeActive && ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0 || (visibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0)) {
67-
Handler handler = getWindow().getDecorView().getHandler();
68-
if (handler != null) {
69-
handler.removeCallbacks(rehideSystemUi); // Prevent a hide loop.
70-
handler.postDelayed(rehideSystemUi, 2000);
71-
}
72-
-
55+
// Input
56+
57+
/**
58+
@@ -1795,7 +1820,7 @@
7359
}
74-
}
75-
76-
@@ -1475,6 +1500,7 @@
77-
String[] arguments = SDLActivity.mSingleton.getArguments();
78-
60+
7961
Log.v("SDL", "Running main function " + function + " from library " + library);
62+
-
8063
+ SDLActivity.mSingleton.appConfirmedActive();
8164
SDLActivity.nativeRunMain(library, function, arguments);
82-
65+
8366
Log.v("SDL", "Finished main function");
84-
@@ -2002,7 +2028,7 @@
67+
@@ -2316,7 +2341,7 @@
8568
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
8669
ic = new SDLInputConnection(this, true);
87-
88-
- outAttrs.inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;
70+
71+
- outAttrs.inputType = InputType.TYPE_CLASS_TEXT;
8972
+ outAttrs.inputType = SDLActivity.keyboardInputType;
9073
outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_EXTRACT_UI
9174
| EditorInfo.IME_FLAG_NO_FULLSCREEN /* API 11 */;
75+

pythonforandroid/recipes/kivy/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ class KivyRecipe(CythonRecipe):
1414
depends = ['sdl2', 'pyjnius', 'setuptools']
1515
python_depends = ['certifi']
1616

17+
# sdl-gl-swapwindow-nogil.patch is needed to avoid a deadlock.
18+
# See: https://github.com/kivy/kivy/pull/8025
19+
# WARNING: Remove this patch when a new Kivy version is released.
20+
patches = ['sdl-gl-swapwindow-nogil.patch']
21+
1722
def cythonize_build(self, env, build_dir='.'):
1823
super().cythonize_build(env, build_dir=build_dir)
1924

@@ -48,7 +53,7 @@ def get_recipe_env(self, arch):
4853
env['KIVY_SDL2_PATH'] = ':'.join([
4954
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL', 'include'),
5055
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_image'),
51-
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_mixer'),
56+
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_mixer', 'include'),
5257
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_ttf'),
5358
])
5459

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
diff --git a/kivy/core/window/_window_sdl2.pyx b/kivy/core/window/_window_sdl2.pyx
2+
index 46e15ec63..5002cd0f9 100644
3+
--- a/kivy/core/window/_window_sdl2.pyx
4+
+++ b/kivy/core/window/_window_sdl2.pyx
5+
@@ -746,7 +746,13 @@ cdef class _WindowSDL2Storage:
6+
pass
7+
8+
def flip(self):
9+
- SDL_GL_SwapWindow(self.win)
10+
+ # On Android (and potentially other platforms), SDL_GL_SwapWindow may
11+
+ # lock the thread waiting for a mutex from another thread to be
12+
+ # released. Calling SDL_GL_SwapWindow with the GIL released allow the
13+
+ # other thread to run (e.g. to process the event filter callback) and
14+
+ # release the mutex SDL_GL_SwapWindow is waiting for.
15+
+ with nogil:
16+
+ SDL_GL_SwapWindow(self.win)
17+
18+
def save_bytes_in_png(self, filename, data, int width, int height):
19+
cdef SDL_Surface *surface = SDL_CreateRGBSurfaceFrom(
20+
diff --git a/kivy/lib/sdl2.pxi b/kivy/lib/sdl2.pxi
21+
index 6a539de6d..3a5a69d23 100644
22+
--- a/kivy/lib/sdl2.pxi
23+
+++ b/kivy/lib/sdl2.pxi
24+
@@ -627,7 +627,7 @@ cdef extern from "SDL.h":
25+
cdef SDL_GLContext SDL_GL_GetCurrentContext()
26+
cdef int SDL_GL_SetSwapInterval(int interval)
27+
cdef int SDL_GL_GetSwapInterval()
28+
- cdef void SDL_GL_SwapWindow(SDL_Window * window)
29+
+ cdef void SDL_GL_SwapWindow(SDL_Window * window) nogil
30+
cdef void SDL_GL_DeleteContext(SDL_GLContext context)
31+
32+
cdef int SDL_NumJoysticks()

pythonforandroid/recipes/sdl2/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77

88
class LibSDL2Recipe(BootstrapNDKRecipe):
9-
version = "2.0.9"
10-
url = "https://www.libsdl.org/release/SDL2-{version}.tar.gz"
11-
md5sum = 'f2ecfba915c54f7200f504d8b48a5dfe'
9+
version = "2.24.0"
10+
url = "https://github.com/libsdl-org/SDL/releases/download/release-{version}/SDL2-{version}.tar.gz"
11+
md5sum = 'cf539ffe9e0dd6f943ac9de75fd2e56e'
1212

1313
dir_name = 'SDL'
1414

@@ -22,7 +22,7 @@ def get_recipe_env(self, arch=None, with_flags_in_cc=True, with_python=True):
2222

2323
def should_build(self, arch):
2424
libdir = join(self.get_build_dir(arch.arch), "../..", "libs", arch.arch)
25-
libs = ['libhidapi.so', 'libmain.so', 'libSDL2.so', 'libSDL2_image.so', 'libSDL2_mixer.so', 'libSDL2_ttf.so']
25+
libs = ['libmain.so', 'libSDL2.so', 'libSDL2_image.so', 'libSDL2_mixer.so', 'libSDL2_ttf.so']
2626
return not all(exists(join(libdir, x)) for x in libs)
2727

2828
def build_arch(self, arch):
Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1+
import os
2+
import sh
3+
from pythonforandroid.logger import shprint
14
from pythonforandroid.recipe import BootstrapNDKRecipe
5+
from pythonforandroid.util import current_directory
26

37

48
class LibSDL2Image(BootstrapNDKRecipe):
5-
version = '2.0.4'
6-
url = 'https://www.libsdl.org/projects/SDL_image/release/SDL2_image-{version}.tar.gz'
9+
version = '2.6.2'
10+
url = 'https://github.com/libsdl-org/SDL_image/releases/download/release-{version}/SDL2_image-{version}.tar.gz'
711
dir_name = 'SDL2_image'
812

9-
patches = ['toggle_jpg_png_webp.patch',
10-
'extra_cflags.patch',
11-
]
13+
patches = ['enable-webp.patch']
14+
15+
def build_arch(self, arch, *extra_args):
16+
with current_directory(os.path.join(self.get_build_dir(arch.arch), "external")):
17+
shprint(sh.Command("./download.sh"))
18+
super().build_arch(arch, *extra_args)
1219

1320

1421
recipe = LibSDL2Image()

pythonforandroid/recipes/sdl2_image/add_ndk_platform_include_dir.patch

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff -Naur SDL2_image.orig/Android.mk SDL2_image/Android.mk
2+
--- SDL2_image.orig/Android.mk 2022-10-03 20:51:52.000000000 +0200
3+
+++ SDL2_image/Android.mk 2022-10-03 20:52:48.000000000 +0200
4+
@@ -32,7 +32,7 @@
5+
6+
# Enable this if you want to support loading WebP images
7+
# The library path should be a relative path to this directory.
8+
-SUPPORT_WEBP ?= false
9+
+SUPPORT_WEBP := true
10+
WEBP_LIBRARY_PATH := external/libwebp
11+
12+

pythonforandroid/recipes/sdl2_image/extra_cflags.patch

Lines changed: 0 additions & 11 deletions
This file was deleted.

pythonforandroid/recipes/sdl2_image/toggle_jpg_png_webp.patch

Lines changed: 0 additions & 25 deletions
This file was deleted.

pythonforandroid/recipes/sdl2_mixer/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33

44
class LibSDL2Mixer(BootstrapNDKRecipe):
5-
version = '2.0.4'
6-
url = 'https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-{version}.tar.gz'
5+
version = '2.6.2'
6+
url = 'https://github.com/libsdl-org/SDL_mixer/releases/download/release-{version}/SDL2_mixer-{version}.tar.gz'
77
dir_name = 'SDL2_mixer'
88

9-
patches = ['toggle_modplug_mikmod_smpeg_ogg.patch']
10-
119

1210
recipe = LibSDL2Mixer()

pythonforandroid/recipes/sdl2_mixer/toggle_modplug_mikmod_smpeg_ogg.patch

Lines changed: 0 additions & 25 deletions
This file was deleted.

pythonforandroid/recipes/sdl2_ttf/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33

44
class LibSDL2TTF(BootstrapNDKRecipe):
5-
version = '2.0.15'
6-
url = 'https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-{version}.tar.gz'
5+
version = '2.20.1'
6+
url = 'https://github.com/libsdl-org/SDL_ttf/releases/download/release-{version}/SDL2_ttf-{version}.tar.gz'
77
dir_name = 'SDL2_ttf'
88

99

0 commit comments

Comments
 (0)