Skip to content
Permalink
Browse files

Required changes for Android development

Required changes by the play store for releasing apps, also working openal implementation.

LIBPNG updated
  • Loading branch information
marauder2k7 committed Sep 15, 2019
1 parent e49e982 commit 446c8ec4a5ab1f0320a605b556957c6349cbb19d
Showing with 32,939 additions and 30,566 deletions.
  1. +4 −4 engine/compilers/android-studio/app/build.gradle
  2. +14 −8 engine/compilers/android-studio/app/src/main/jni/Android.mk
  3. +1 −1 engine/compilers/android-studio/app/src/main/jni/Application.mk
  4. +6 −2 engine/compilers/android-studio/build.gradle
  5. +1 −0 engine/compilers/android-studio/gradle.properties
  6. +232 −0 engine/lib/lpng/arm/arm_init.c
  7. +235 −0 engine/lib/lpng/arm/filter_neon.S
  8. +2,934 −2,926 engine/lib/lpng/png.c
  9. +2,586 −2,726 engine/lib/lpng/png.h
  10. +598 −598 engine/lib/lpng/pngconf.h
  11. +153 −153 engine/lib/lpng/pngdebug.h
  12. +688 −688 engine/lib/lpng/pngerror.c
  13. +1,170 −1,170 engine/lib/lpng/pngget.c
  14. +268 −268 engine/lib/lpng/pnginfo.h
  15. +667 −667 engine/lib/lpng/pngmem.c
  16. +1,227 −1,227 engine/lib/lpng/pngpread.c
  17. +1,761 −1,772 engine/lib/lpng/pngpriv.h
  18. +1,298 −1,298 engine/lib/lpng/pngread.c
  19. +176 −176 engine/lib/lpng/pngrio.c
  20. +5,073 −5,073 engine/lib/lpng/pngrtran.c
  21. +4,153 −4,132 engine/lib/lpng/pngrutil.c
  22. +1,441 −1,347 engine/lib/lpng/pngset.c
  23. +353 −353 engine/lib/lpng/pngstruct.h
  24. +2,073 −0 engine/lib/lpng/pngtest.c
  25. +781 −781 engine/lib/lpng/pngtrans.c
  26. +256 −256 engine/lib/lpng/pngwio.c
  27. +1,452 −1,452 engine/lib/lpng/pngwrite.c
  28. +645 −645 engine/lib/lpng/pngwtran.c
  29. +2,680 −2,835 engine/lib/lpng/pngwutil.c
  30. BIN engine/lib/openal/Android/armeabi-v7a/libopenal.so
  31. +1 −1 engine/lib/openal/Android/openal-soft-master/AndroidManifest.xml
  32. +3 −3 engine/lib/openal/Android/openal-soft-master/Makefile
  33. +5 −2 engine/lib/openal/Android/openal-soft-master/jni/Android.mk
  34. +1 −1 engine/lib/openal/Android/openal-soft-master/jni/Application.mk
  35. +2 −0 engine/lib/openal/Android/openal-soft-master/jni/OpenAL/build.mk
  36. +1 −1 engine/lib/openal/Android/openal-soft-master/project.properties
  37. BIN engine/lib/openal/Android/x86/libopenal.so
  38. BIN engine/lib/openal/Android/x86_64/libopenal.so
@@ -1,7 +1,7 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '26.0.2'
compileSdkVersion 28
buildToolsVersion '28.0.3'
externalNativeBuild {
ndkBuild {
path './src/main/jni/Android.mk'
@@ -10,7 +10,7 @@ android {
defaultConfig {
applicationId "com.garagegames.torque2d"
minSdkVersion 19
targetSdkVersion 25
targetSdkVersion 28

sourceSets.main {
assets.srcDirs = [
@@ -19,7 +19,7 @@ android {
]

ndk {
abiFilters 'x86', 'x86_64', 'armeabi-v7a'
abiFilters 'x86', 'x86_64', 'armeabi-v7a' , 'arm64-v8a'
}
}

@@ -31,13 +31,13 @@ include $(PREBUILT_SHARED_LIBRARY)

#freetype2 lib for generating fonts on device
LOCAL_PATH := $(MY_LOCAL_PATH)

include $(CLEAR_VARS)

LOCAL_MODULE := freetype-prebuilt
LOCAL_SRC_FILES := ../../../../../../lib/freetype/android/lib/$(TARGET_ARCH_ABI)/libfreetype.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../../../../lib/freetype/android/include $(LOCAL_PATH)/../../../../../../lib/freetype/android/include/freetype2

include $(PREBUILT_STATIC_LIBRARY)

LOCAL_PATH := $(MY_LOCAL_PATH)
@@ -107,11 +107,11 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH) \
$(LOCAL_PATH)/../../../../../../source/platformAndroid \
$(LOCAL_PATH)/../../../../../../source/sim \
$(LOCAL_PATH)/../../../../../../source/spine \
$(LOCAL_PATH)/../../../../../../source/string
$(LOCAL_PATH)/../../../../../../source/string
# $(LOCAL_PATH)/../../../../../../source/testing \
# $(LOCAL_PATH)/../../../../../../source/testing/tests \

LOCAL_SRC_FILES := ../../../../../../lib/ljpeg/jcapimin.c \
../../../../../../lib/ljpeg/jcapistd.c \
../../../../../../lib/ljpeg/jccoefct.c \
@@ -602,12 +602,12 @@ LOCAL_SRC_FILES := ../../../../../../lib/ljpeg/jcapimin.c \
../../../../../../source/gui/editor/guiInspector.cc \
../../../../../../source/gui/editor/guiInspectorTypes.cc \
../../../../../../source/gui/editor/guiMenuBar.cc \
../../../../../../source/gui/editor/guiSeparatorCtrl.cc
../../../../../../source/gui/editor/guiSeparatorCtrl.cc
# ../../../../../../source/testing/tests/platformFileIoTests.cc \
# ../../../../../../source/testing/tests/platformMemoryTests.cc \
# ../../../../../../source/testing/tests/platformStringTests.cc \
# ../../../../../../source/testing/unitTesting.cc

ifeq ($(APP_OPTIM),debug)
LOCAL_CFLAGS := -DENABLE_CONSOLE_MSGS -D__ANDROID__ -DTORQUE_DEBUG -DTORQUE_OS_ANDROID -DGL_GLEXT_PROTOTYPES -O0 -fsigned-char
LOCAL_CPPFLAGS := -std=gnu++11 -frtti $(LOCAL_CFLAGS)
@@ -619,6 +619,12 @@ LOCAL_LDLIBS := -llog -landroid -lEGL -lGLESv1_CM -lz -lOpenSLES -L../../../.
LOCAL_STATIC_LIBRARIES := freetype-prebuilt
LOCAL_SHARED_LIBRARIES := libopenal-prebuilt

ifeq ($(TARGET_ARCH_ABI),$(filter $(TARGET_ARCH_ABI), arm64-v8a))
LOCAL_CFLAGS := -DHAVE_NEON=1
LOCAL_ARM_NEON := true

endif

LOCAL_ARM_MODE := arm

include $(BUILD_SHARED_LIBRARY)
@@ -1,4 +1,4 @@
APP_PLATFORM := android-16
APP_STL := c++_static
APP_OPTIM := release
APP_ABI := armeabi-v7a x86 x86_64
APP_ABI := armeabi-v7a x86 x86_64 arm64-v8a
@@ -1,18 +1,22 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
ext {
var = '3.5.0'
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath "com.android.tools.build:gradle:3.5.0"
}
}

allprojects {
repositories {
google()
jcenter()
}
}
@@ -0,0 +1 @@
org.gradle.jvmargs=-Xmx2g -XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
@@ -0,0 +1,232 @@

/* arm_init.c - NEON optimised filter functions
*
* Copyright (c) 2013 Glenn Randers-Pehrson
* Written by Mans Rullgard, 2011.
* Last changed in libpng 1.6.8 [December 19, 2013]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h
*/
/* Below, after checking __linux__, various non-C90 POSIX 1003.1 functions are
* called.
*/
#define _POSIX_SOURCE 1

#include "../pngpriv.h"

#ifdef PNG_READ_SUPPORTED
#if PNG_ARM_NEON_OPT > 0
#ifdef PNG_ARM_NEON_CHECK_SUPPORTED /* Do run-time checks */
#include <signal.h> /* for sig_atomic_t */

#ifdef __ANDROID__
/* Linux provides access to information about CPU capabilites via
* /proc/self/auxv, however Android blocks this while still claiming to be
* Linux. The Andoid NDK, however, provides appropriate support.
*
* Documentation: http://www.kandroid.org/ndk/docs/CPU-ARM-NEON.html
*/
#include <cpu-features.h>

static int
png_have_neon(png_structp png_ptr)
{
/* This is a whole lot easier than the mess below, however it is probably
* implemented as below, therefore it is better to cache the result (these
* function calls may be slow!)
*/
PNG_UNUSED(png_ptr)
return android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM &&
(android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0;
}
#elif defined(__linux__)
/* The generic __linux__ implementation requires reading /proc/self/auxv and
* looking at each element for one that records NEON capabilities.
*/
#include <unistd.h> /* for POSIX 1003.1 */
#include <errno.h> /* for EINTR */

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <elf.h>
#include <asm/hwcap.h>

/* A read call may be interrupted, in which case it returns -1 and sets errno to
* EINTR if nothing was done, otherwise (if something was done) a partial read
* may result.
*/
static size_t
safe_read(png_structp png_ptr, int fd, void *buffer_in, size_t nbytes)
{
size_t ntotal = 0;
char *buffer = png_voidcast(char*, buffer_in);

while (nbytes > 0)
{
unsigned int nread;
int iread;

/* Passing nread > INT_MAX to read is implementation defined in POSIX
* 1003.1, therefore despite the unsigned argument portable code must
* limit the value to INT_MAX!
*/
if (nbytes > INT_MAX)
nread = INT_MAX;

else
nread = (unsigned int)/*SAFE*/nbytes;

iread = read(fd, buffer, nread);

if (iread == -1)
{
/* This is the devil in the details, a read can terminate early with 0
* bytes read because of EINTR, yet it still returns -1 otherwise end
* of file cannot be distinguished.
*/
if (errno != EINTR)
{
png_warning(png_ptr, "/proc read failed");
return 0; /* I.e., a permanent failure */
}
}

else if (iread < 0)
{
/* Not a valid 'read' result: */
png_warning(png_ptr, "OS /proc read bug");
return 0;
}

else if (iread > 0)
{
/* Continue reading until a permanent failure, or EOF */
buffer += iread;
nbytes -= (unsigned int)/*SAFE*/iread;
ntotal += (unsigned int)/*SAFE*/iread;
}

else
return ntotal;
}

return ntotal; /* nbytes == 0 */
}

static int
png_have_neon(png_structp png_ptr)
{
int fd = open("/proc/self/auxv", O_RDONLY);
Elf32_auxv_t aux;

/* Failsafe: failure to open means no NEON */
if (fd == -1)
{
png_warning(png_ptr, "/proc/self/auxv open failed");
return 0;
}

while (safe_read(png_ptr, fd, &aux, sizeof aux) == sizeof aux)
{
if (aux.a_type == AT_HWCAP && (aux.a_un.a_val & HWCAP_NEON) != 0)
{
close(fd);
return 1;
}
}

close(fd);
return 0;
}
#else
/* We don't know how to do a run-time check on this system */
# error "no support for run-time ARM NEON checks"
#endif /* OS checks */
#endif /* PNG_ARM_NEON_CHECK_SUPPORTED */

#ifndef PNG_ALIGNED_MEMORY_SUPPORTED
# error "ALIGNED_MEMORY is required; set: -DPNG_ALIGNED_MEMORY_SUPPORTED"
#endif

void
png_init_filter_functions_neon(png_structp pp, unsigned int bpp)
{
/* The switch statement is compiled in for ARM_NEON_API, the call to
* png_have_neon is compiled in for ARM_NEON_CHECK. If both are defined
* the check is only performed if the API has not set the NEON option on
* or off explicitly. In this case the check controls what happens.
*
* If the CHECK is not compiled in and the option is UNSET the behavior prior
* to 1.6.7 was to use the NEON code - this was a bug caused by having the
* wrong order of the 'ON' and 'default' cases. UNSET now defaults to OFF,
* as documented in png.h
*/
#ifdef PNG_ARM_NEON_API_SUPPORTED
switch ((pp->options >> PNG_ARM_NEON) & 3)
{
case PNG_OPTION_UNSET:
/* Allow the run-time check to execute if it has been enabled -
* thus both API and CHECK can be turned on. If it isn't supported
* this case will fall through to the 'default' below, which just
* returns.
*/
#endif /* PNG_ARM_NEON_API_SUPPORTED */
#ifdef PNG_ARM_NEON_CHECK_SUPPORTED
{
static volatile sig_atomic_t no_neon = -1; /* not checked */

if (no_neon < 0)
no_neon = !png_have_neon(pp);

if (no_neon)
return;
}
#ifdef PNG_ARM_NEON_API_SUPPORTED
break;
#endif
#endif /* PNG_ARM_NEON_CHECK_SUPPORTED */

#ifdef PNG_ARM_NEON_API_SUPPORTED
default: /* OFF or INVALID */
return;

case PNG_OPTION_ON:
/* Option turned on */
break;
}
#endif

/* IMPORTANT: any new external functions used here must be declared using
* PNG_INTERNAL_FUNCTION in ../pngpriv.h. This is required so that the
* 'prefix' option to configure works:
*
* ./configure --with-libpng-prefix=foobar_
*
* Verify you have got this right by running the above command, doing a build
* and examining pngprefix.h; it must contain a #define for every external
* function you add. (Notice that this happens automatically for the
* initialization function.)
*/
pp->read_filter[PNG_FILTER_VALUE_UP-1] = png_read_filter_row_up_neon;

if (bpp == 3)
{
pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub3_neon;
pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg3_neon;
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
png_read_filter_row_paeth3_neon;
}

else if (bpp == 4)
{
pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub4_neon;
pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg4_neon;
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
png_read_filter_row_paeth4_neon;
}
}
#endif /* PNG_ARM_NEON_OPT > 0 */
#endif /* PNG_READ_SUPPORTED */

0 comments on commit 446c8ec

Please sign in to comment.
You can’t perform that action at this time.