Skip to content

Commit 5e7a1fa

Browse files
authored
Update SDL2, SDL2_ttf, SDL2_mixer, SDL2_image to latest releases (kivy#2673)
1 parent 25f3a53 commit 5e7a1fa

File tree

14 files changed

+126
-143
lines changed

14 files changed

+126
-143
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: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
11
import glob
22
from os.path import basename, exists, join
3+
import sys
4+
import packaging.version
35

46
import sh
57
from pythonforandroid.recipe import CythonRecipe
68
from pythonforandroid.toolchain import current_directory, shprint
79

810

11+
def is_kivy_affected_by_deadlock_issue(recipe=None, arch=None):
12+
with current_directory(join(recipe.get_build_dir(arch.arch), "kivy")):
13+
kivy_version = shprint(
14+
sh.Command(sys.executable),
15+
"-c",
16+
"import _version; print(_version.__version__)",
17+
)
18+
19+
return packaging.version.parse(
20+
str(kivy_version)
21+
) < packaging.version.Version("2.2.0.dev0")
22+
23+
924
class KivyRecipe(CythonRecipe):
1025
version = '2.1.0'
1126
url = 'https://github.com/kivy/kivy/archive/{version}.zip'
@@ -14,6 +29,11 @@ class KivyRecipe(CythonRecipe):
1429
depends = ['sdl2', 'pyjnius', 'setuptools']
1530
python_depends = ['certifi']
1631

32+
# sdl-gl-swapwindow-nogil.patch is needed to avoid a deadlock.
33+
# See: https://github.com/kivy/kivy/pull/8025
34+
# WARNING: Remove this patch when a new Kivy version is released.
35+
patches = [("sdl-gl-swapwindow-nogil.patch", is_kivy_affected_by_deadlock_issue)]
36+
1737
def cythonize_build(self, env, build_dir='.'):
1838
super().cythonize_build(env, build_dir=build_dir)
1939

@@ -48,7 +68,7 @@ def get_recipe_env(self, arch):
4868
env['KIVY_SDL2_PATH'] = ':'.join([
4969
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL', 'include'),
5070
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_image'),
51-
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_mixer'),
71+
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_mixer', 'include'),
5272
join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_ttf'),
5373
])
5474

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: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
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 prebuild_arch(self, arch):
16+
# We do not have a folder for each arch on BootstrapNDKRecipe, so we
17+
# need to skip the external deps download if we already have done it.
18+
external_deps_dir = os.path.join(self.get_build_dir(arch.arch), "external")
19+
if not os.path.exists(os.path.join(external_deps_dir, "libwebp")):
20+
with current_directory(external_deps_dir):
21+
shprint(sh.Command("./download.sh"))
22+
super().prebuild_arch(arch)
1223

1324

1425
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.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy