Skip to content

Commit

Permalink
Native libraries (#1126)
Browse files Browse the repository at this point in the history
  • Loading branch information
devemux86 authored May 20, 2024
1 parent 56d6368 commit 9ce2628
Show file tree
Hide file tree
Showing 45 changed files with 8,581 additions and 632 deletions.
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

4 changes: 2 additions & 2 deletions jni/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'java'
apply plugin: 'application'

dependencies {
implementation "com.badlogicgames.gdx:gdx-jnigen:$gdxVersion"
implementation 'com.badlogicgames.gdx:gdx-jnigen:2.5.1'
}

sourceSets {
Expand Down
18 changes: 9 additions & 9 deletions jni/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ include $(CLEAR_VARS)
LOCAL_MODULE := vtm-jni
LOCAL_C_INCLUDES := . libtess2/Include

LOCAL_CFLAGS := $(LOCAL_C_INCLUDES:%=-I%) -O2 -Wall -D__ANDROID__ -Wall -std=c99 -O2 -ffast-math -DNDEBUG
LOCAL_CPPFLAGS := $(LOCAL_C_INCLUDES:%=-I%) -O2 -Wall -D__ANDROID__ -Wall -std=c99 -O2 -ffast-math -DNDEBUG
LOCAL_CFLAGS := $(LOCAL_C_INCLUDES:%=-I%) -O2 -Wall -D__ANDROID__ -Wall -O2 -ffast-math -DNDEBUG
LOCAL_CPPFLAGS := $(LOCAL_C_INCLUDES:%=-I%) -O2 -Wall -D__ANDROID__ -Wall -O2 -ffast-math -DNDEBUG
LOCAL_LDLIBS := -lm -llog
LOCAL_ARM_MODE := arm

LOCAL_SRC_FILES := org.oscim.utils.TessJNI.cpp\
libtess2/Source/sweep.c\
libtess2/Source/priorityq.c\
libtess2/Source/bucketalloc.c\
libtess2/Source/geom.c\
LOCAL_SRC_FILES := libtess2/Source/dict.c\
libtess2/Source/tess.c\
libtess2/Source/dict.c\
libtess2/Source/geom.c\
libtess2/Source/bucketalloc.c\
libtess2/Source/mesh.c\
gl/utils.c
libtess2/Source/sweep.c\
libtess2/Source/priorityq.c\
gl/utils.c\
org_oscim_utils_TessJNI.cpp

include $(BUILD_SHARED_LIBRARY)
4 changes: 2 additions & 2 deletions jni/jni/Application.mk
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
APP_ABI := armeabi armeabi-v7a x86
APP_PLATFORM := android-8
APP_ABI := all
APP_PLATFORM := android-9
1 change: 1 addition & 0 deletions jni/jni/build-android32.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@
<condition property="has-ndk-build">
<equals arg1="${ndk-build-found}" arg2="true"/>
</condition>
<fail message="ndk-build not found. Have you set NDK_HOME?" unless="has-ndk-build"/>
</target>
</project>
13 changes: 0 additions & 13 deletions jni/jni/build.xml
Original file line number Diff line number Diff line change
@@ -1,29 +1,16 @@
<project name="vtm-jni-natives" basedir="." default="all">
<target name="clean">
<ant antfile="build-android32.xml" target="clean"/>
<ant antfile="build-linux64.xml" target="clean"/>
<ant antfile="build-linux32.xml" target="clean"/>
<ant antfile="build-windows32.xml" target="clean"/>
<ant antfile="build-windows64.xml" target="clean"/>

</target>

<target name="compile-natives">
<ant antfile="build-android32.xml"/>
<ant antfile="build-linux64.xml"/>
<ant antfile="build-linux32.xml"/>
<ant antfile="build-windows32.xml"/>
<ant antfile="build-windows64.xml"/>

</target>

<target name="pack-natives">
<jar destfile="../libs/vtm-jni-natives.jar">
<fileset dir="../libs/linux64" includes="libvtm-jni64.so"/>
<fileset dir="../libs/linux32" includes="libvtm-jni.so"/>
<fileset dir="../libs/macosx32" includes="libvtm-jni.so"/>
<fileset dir="../libs/windows32" includes="libvtm-jni.dylib"/>
<fileset dir="../libs/windows64" includes="libvtm-jni.a"/>

</jar>
</target>
Expand Down
79 changes: 69 additions & 10 deletions jni/jni/jni-headers/classfile_constants.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
/*
* %W% %E%
*
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
* Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

#ifndef CLASSFILE_CONSTANTS_H
Expand All @@ -13,6 +30,10 @@
extern "C" {
#endif

/* Classfile version number for this information */
#define JVM_CLASSFILE_MAJOR_VERSION 55
#define JVM_CLASSFILE_MINOR_VERSION 0

/* Flags */

enum {
Expand All @@ -33,9 +54,29 @@ enum {
JVM_ACC_STRICT = 0x0800,
JVM_ACC_SYNTHETIC = 0x1000,
JVM_ACC_ANNOTATION = 0x2000,
JVM_ACC_ENUM = 0x4000
JVM_ACC_ENUM = 0x4000,
JVM_ACC_MODULE = 0x8000
};

#define JVM_ACC_PUBLIC_BIT 0
#define JVM_ACC_PRIVATE_BIT 1
#define JVM_ACC_PROTECTED_BIT 2
#define JVM_ACC_STATIC_BIT 3
#define JVM_ACC_FINAL_BIT 4
#define JVM_ACC_SYNCHRONIZED_BIT 5
#define JVM_ACC_SUPER_BIT 5
#define JVM_ACC_VOLATILE_BIT 6
#define JVM_ACC_BRIDGE_BIT 6
#define JVM_ACC_TRANSIENT_BIT 7
#define JVM_ACC_VARARGS_BIT 7
#define JVM_ACC_NATIVE_BIT 8
#define JVM_ACC_INTERFACE_BIT 9
#define JVM_ACC_ABSTRACT_BIT 10
#define JVM_ACC_STRICT_BIT 11
#define JVM_ACC_SYNTHETIC_BIT 12
#define JVM_ACC_ANNOTATION_BIT 13
#define JVM_ACC_ENUM_BIT 14

/* Used in newarray instruction. */

enum {
Expand All @@ -56,14 +97,32 @@ enum {
JVM_CONSTANT_Unicode = 2, /* unused */
JVM_CONSTANT_Integer = 3,
JVM_CONSTANT_Float = 4,
JVM_CONSTANT_Long = 5,
JVM_CONSTANT_Long = 5,
JVM_CONSTANT_Double = 6,
JVM_CONSTANT_Class = 7,
JVM_CONSTANT_String = 8,
JVM_CONSTANT_Fieldref = 9,
JVM_CONSTANT_Methodref = 10,
JVM_CONSTANT_InterfaceMethodref = 11,
JVM_CONSTANT_NameAndType = 12
JVM_CONSTANT_NameAndType = 12,
JVM_CONSTANT_MethodHandle = 15, // JSR 292
JVM_CONSTANT_MethodType = 16, // JSR 292
JVM_CONSTANT_Dynamic = 17,
JVM_CONSTANT_InvokeDynamic = 18,
JVM_CONSTANT_ExternalMax = 18
};

/* JVM_CONSTANT_MethodHandle subtypes */
enum {
JVM_REF_getField = 1,
JVM_REF_getStatic = 2,
JVM_REF_putField = 3,
JVM_REF_putStatic = 4,
JVM_REF_invokeVirtual = 5,
JVM_REF_invokeStatic = 6,
JVM_REF_invokeSpecial = 7,
JVM_REF_newInvokeSpecial = 8,
JVM_REF_invokeInterface = 9
};

/* StackMapTable type item numbers */
Expand Down Expand Up @@ -289,7 +348,7 @@ enum {
JVM_OPC_invokespecial = 183,
JVM_OPC_invokestatic = 184,
JVM_OPC_invokeinterface = 185,
JVM_OPC_xxxunusedxxx = 186,
JVM_OPC_invokedynamic = 186,
JVM_OPC_new = 187,
JVM_OPC_newarray = 188,
JVM_OPC_anewarray = 189,
Expand Down Expand Up @@ -498,7 +557,7 @@ enum {
3, /* invokespecial */ \
3, /* invokestatic */ \
5, /* invokeinterface */ \
0, /* xxxunusedxxx */ \
5, /* invokedynamic */ \
3, /* new */ \
2, /* newarray */ \
3, /* anewarray */ \
Expand Down
116 changes: 97 additions & 19 deletions jni/jni/jni-headers/jawt.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
/*
* %W% %E%
* Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

#ifndef _JAVASOFT_JAWT_H_
Expand All @@ -15,23 +33,27 @@ extern "C" {
#endif

/*
* AWT native interface (new in JDK 1.3)
* AWT native interface.
*
* The AWT native interface allows a native C or C++ application a means
* by which to access native structures in AWT. This is to facilitate moving
* legacy C and C++ applications to Java and to target the needs of the
* community who, at present, wish to do their own native rendering to canvases
* for performance reasons. Standard extensions such as Java3D also require a
* means to access the underlying native data structures of AWT.
* developers who need to do their own native rendering to canvases
* for performance or other reasons.
*
* Conversely it also provides mechanisms for an application which already
* has a native window to provide that to AWT for AWT rendering.
*
* There may be future extensions to this API depending on demand.
* Since every platform may be different in its native data structures
* and APIs for windowing systems the application must necessarily
* provided per-platform source and compile and deliver per-platform
* native code to use this API.
*
* A VM does not have to implement this API in order to pass the JCK.
* It is recommended, however, that this API is implemented on VMs that support
* standard extensions, such as Java3D.
* These interfaces are not part of the Java SE specification and
* a VM is not required to implement this API. However it is strongly
* recommended that all implementations which support headful AWT
* also support these interfaces.
*
* Since this is a native API, any program which uses it cannot be considered
* 100% pure java.
*/

/*
Expand All @@ -40,7 +62,7 @@ extern "C" {
* For each platform, there is a native drawing surface structure. This
* platform-specific structure can be found in jawt_md.h. It is recommended
* that additional platforms follow the same model. It is also recommended
* that VMs on Win32 and Solaris support the existing structures in jawt_md.h.
* that VMs on all platforms support the existing structures in jawt_md.h.
*
*******************
* EXAMPLE OF USAGE:
Expand Down Expand Up @@ -80,8 +102,8 @@ extern "C" {
* jboolean result;
* jint lock;
*
* // Get the AWT
* awt.version = JAWT_VERSION_1_3;
* // Get the AWT. Request version 9 to access features in that release.
* awt.version = JAWT_VERSION_9;
* result = JAWT_GetAWT(env, &awt);
* assert(result != JNI_FALSE);
*
Expand Down Expand Up @@ -136,7 +158,9 @@ typedef struct jawt_DrawingSurfaceInfo {
/*
* Pointer to the platform-specific information. This can be safely
* cast to a JAWT_Win32DrawingSurfaceInfo on Windows or a
* JAWT_X11DrawingSurfaceInfo on Solaris. See jawt_md.h for details.
* JAWT_X11DrawingSurfaceInfo on Linux and Solaris. On Mac OS X this is a
* pointer to a NSObject that conforms to the JAWT_SurfaceLayers
* protocol. See jawt_md.h for details.
*/
void* platformInfo;
/* Cached pointer to the underlying drawing surface */
Expand Down Expand Up @@ -203,7 +227,7 @@ typedef struct jawt_DrawingSurface {
*/
void (JNICALL *FreeDrawingSurfaceInfo)
(JAWT_DrawingSurfaceInfo* dsi);
/*
/*
* Unlock the drawing surface of the target component for native rendering.
*/
void (JNICALL *Unlock)
Expand All @@ -217,7 +241,8 @@ typedef struct jawt_DrawingSurface {
typedef struct jawt {
/*
* Version of this structure. This must always be set before
* calling JAWT_GetAWT()
* calling JAWT_GetAWT(). It affects the functions returned.
* Must be one of the known pre-defined versions.
*/
jint version;
/*
Expand Down Expand Up @@ -259,6 +284,50 @@ typedef struct jawt {
*/
jobject (JNICALL *GetComponent)(JNIEnv* env, void* platformInfo);

/**
* Since 9
* Creates a java.awt.Frame placed in a native container. Container is
* referenced by the native platform handle. For example on Windows this
* corresponds to an HWND. For other platforms, see the appropriate
* machine-dependent header file for a description. The reference returned
* by this function is a local reference that is only valid in this
* environment. This function returns a NULL reference if no frame could be
* created with matching platform information.
*/
jobject (JNICALL *CreateEmbeddedFrame) (JNIEnv *env, void* platformInfo);

/**
* Since 9
* Moves and resizes the embedded frame. The new location of the top-left
* corner is specified by x and y parameters relative to the native parent
* component. The new size is specified by width and height.
*
* The embedded frame should be created by CreateEmbeddedFrame() method, or
* this function will not have any effect.
*
* java.awt.Component.setLocation() and java.awt.Component.setBounds() for
* EmbeddedFrame really don't move it within the native parent. These
* methods always locate the embedded frame at (0, 0) for backward
* compatibility. To allow moving embedded frames this method was
* introduced, and it works just the same way as setLocation() and
* setBounds() for usual, non-embedded components.
*
* Using usual get/setLocation() and get/setBounds() together with this new
* method is not recommended.
*/
void (JNICALL *SetBounds) (JNIEnv *env, jobject embeddedFrame,
jint x, jint y, jint w, jint h);
/**
* Since 9
* Synthesize a native message to activate or deactivate an EmbeddedFrame
* window depending on the value of parameter doActivate, if "true"
* activates the window; otherwise, deactivates the window.
*
* The embedded frame should be created by CreateEmbeddedFrame() method, or
* this function will not have any effect.
*/
void (JNICALL *SynthesizeWindowActivation) (JNIEnv *env,
jobject embeddedFrame, jboolean doActivate);
} JAWT;

/*
Expand All @@ -268,8 +337,17 @@ typedef struct jawt {
_JNI_IMPORT_OR_EXPORT_
jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt);

/*
* Specify one of these constants as the JAWT.version
* Specifying an earlier version will limit the available functions to
* those provided in that earlier version of JAWT.
* See the "Since" note on each API. Methods with no "Since"
* may be presumed to be present in JAWT_VERSION_1_3.
*/
#define JAWT_VERSION_1_3 0x00010003
#define JAWT_VERSION_1_4 0x00010004
#define JAWT_VERSION_1_7 0x00010007
#define JAWT_VERSION_9 0x00090000

#ifdef __cplusplus
} /* extern "C" */
Expand Down
Loading

0 comments on commit 9ce2628

Please sign in to comment.