jni: new Tesselator
This commit is contained in:
parent
59ab24da90
commit
7db70f239f
.gitmodules
jni
.cprojectAndroid.mkApplication.mkMakefilebuild-windows32.xmlbuild-windows64.xmlbuild.xmlcp.sh
vtm-ext-libsjni
Android.mkApplication.mkbuild-android32.xmlbuild-linux64.xmlbuild.xml
gl
jni-headers
libtess2memcpy_wrap.corg.oscim.utils.TessJNI.cpporg.oscim.utils.tess.Tesselator.cpporg.oscim.utils.tess.Tesselator.hsrc
5
.gitmodules
vendored
5
.gitmodules
vendored
@ -1,3 +1,8 @@
|
||||
[submodule "vtm-ext-libs"]
|
||||
path = vtm-ext-libs
|
||||
url = https://github.com/hjanetzek/vtm-ext-libs.git
|
||||
|
||||
[submodule "libtess2"]
|
||||
path = jni/jni/libtess2
|
||||
url = https://github.com/memononen/libtess2.git
|
||||
|
||||
|
@ -18,13 +18,13 @@
|
||||
<folderInfo id="cdt.managedbuild.toolchain.gnu.base.1587393048.116574534" name="/" resourcePath="">
|
||||
<toolChain id="cdt.managedbuild.toolchain.gnu.base.223412825" name="cdt.managedbuild.toolchain.gnu.base" superClass="cdt.managedbuild.toolchain.gnu.base">
|
||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.target.gnu.platform.base.385578518" name="Debug Platform" osList="linux,hpux,aix,qnx" superClass="cdt.managedbuild.target.gnu.platform.base"/>
|
||||
<builder id="cdt.managedbuild.target.gnu.builder.base.156937647" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.base"/>
|
||||
<builder command="make" enableCleanBuild="false" enabledIncrementalBuild="false" id="cdt.managedbuild.target.gnu.builder.base.156937647" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.base"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.archiver.base.1823835369" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.base.360207042" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base">
|
||||
<option id="gnu.cpp.compiler.option.preprocessor.def.145805607" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="CORE_EXPORT"/>
|
||||
</option>
|
||||
<option id="gnu.cpp.compiler.option.include.paths.1744312971" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
|
||||
<option id="gnu.cpp.compiler.option.include.paths.1744312971" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/vtm-jni}""/>
|
||||
</option>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.111801070" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
|
||||
@ -67,5 +67,9 @@
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</scannerConfigBuildInfo>
|
||||
</storageModule>
|
||||
<storageModule moduleId="refreshScope"/>
|
||||
<storageModule moduleId="refreshScope" versionNumber="2">
|
||||
<configuration configurationName="Default">
|
||||
<resource resourceType="PROJECT" workspacePath="/vtm-jni"/>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
</cproject>
|
||||
|
@ -1,26 +0,0 @@
|
||||
LOCAL_PATH:= $(call my-dir)
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := vtm-jni
|
||||
LOCAL_C_INCLUDES := .
|
||||
|
||||
LOCAL_CFLAGS := $(LOCAL_C_INCLUDES:%=-I%) -O2 -Wall -D__ANDROID__ -Wall -std=c99 -O2 -ffast-math
|
||||
LOCAL_CPPFLAGS := $(LOCAL_C_INCLUDES:%=-I%) -O2 -Wall -D__ANDROID__ -Wall -std=c99 -O2 -ffast-math
|
||||
LOCAL_LDLIBS := -lm -llog
|
||||
LOCAL_ARM_MODE := arm
|
||||
|
||||
LOCAL_SRC_FILES := gl/utils.c\
|
||||
tessellate/TessellateJni.c\
|
||||
tessellate/render.c\
|
||||
tessellate/memalloc.c\
|
||||
tessellate/geom.c\
|
||||
tessellate/dict.c\
|
||||
tessellate/tessmono.c\
|
||||
tessellate/normal.c\
|
||||
tessellate/tessellate.c\
|
||||
tessellate/mesh.c\
|
||||
tessellate/tess.c\
|
||||
tessellate/priorityq.c\
|
||||
tessellate/sweep.c
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
@ -1 +0,0 @@
|
||||
APP_ABI := armeabi armeabi-v7a x86
|
@ -1,2 +0,0 @@
|
||||
all:
|
||||
|
@ -1,156 +0,0 @@
|
||||
<project name="vtm-jni-Windows-32" basedir="." default="postcompile">
|
||||
<!-- include the environment -->
|
||||
<property environment="env"/>
|
||||
<!-- output directory for temporary object files -->
|
||||
<property name="buildDir" value="target/windows32" />
|
||||
<!-- output directory for the shared library -->
|
||||
<property name="libsDir" value="../libs/windows32" />
|
||||
<!-- the name of the shared library -->
|
||||
<property name="libName" value="vtm-jni.dll"/>
|
||||
<!-- the jni header jniPlatform to use -->
|
||||
<property name="jniPlatform" value="win32"/>
|
||||
<!-- the compilerPrefix for the C & C++ compilers -->
|
||||
<property name="compilerPrefix" value="i686-w64-mingw32-"/>
|
||||
<!-- the compilerSuffix for the C & C++ compilers -->
|
||||
<property name="compilerSuffix" value="" />
|
||||
|
||||
<!-- define gcc compiler, options and files to compile -->
|
||||
<property name="gcc" value="${compilerPrefix}gcc${compilerSuffix}"/>
|
||||
<property name="gcc-opts" value="-c -Wall -O2 -mfpmath=sse -msse2 -fmessage-length=0 -m32 -Wall -std=c99 -O2 -ffast-math"/>
|
||||
<fileset id="gcc-files" dir="./">
|
||||
<exclude name="target/"/>
|
||||
<include name="memcpy_wrap.c"/>
|
||||
<include name="gl/utils.c"/>
|
||||
<include name="tessellate/dict.c"/>
|
||||
<include name="tessellate/mesh.c"/>
|
||||
<include name="tessellate/render.c"/>
|
||||
<include name="tessellate/tess.c"/>
|
||||
<include name="tessellate/geom.c"/>
|
||||
<include name="tessellate/memalloc.c"/>
|
||||
<include name="tessellate/normal.c"/>
|
||||
<include name="tessellate/priorityq.c"/>
|
||||
<include name="tessellate/sweep.c"/>
|
||||
<include name="tessellate/tessmono.c"/>
|
||||
<include name="tessellate/tessellate.c"/>
|
||||
<include name="tessellate/TessellateJni.c"/>
|
||||
|
||||
|
||||
</fileset>
|
||||
|
||||
<!-- define g++ compiler, options and files to compile -->
|
||||
<property name="g++" value="${compilerPrefix}g++${compilerSuffix}"/>
|
||||
<property name="g++-opts" value="-c -Wall -O2 -mfpmath=sse -msse2 -fmessage-length=0 -m32 -Wall -std=c99 -O2 -ffast-math"/>
|
||||
<fileset id="g++-files" dir="./">
|
||||
<exclude name="target/"/>
|
||||
<include name="**/*.cpp"/>
|
||||
|
||||
|
||||
</fileset>
|
||||
|
||||
<!-- define linker and options -->
|
||||
<property name="linker" value="${compilerPrefix}g++${compilerSuffix}"/>
|
||||
<property name="linker-opts" value="-Wl,--kill-at -shared -m32 -static-libgcc -static-libstdc++"/>
|
||||
<property name="libraries" value=""/>
|
||||
|
||||
<!-- cleans the build directory, removes all object files and shared libs -->
|
||||
<target name="clean">
|
||||
<delete includeemptydirs="true" quiet="true">
|
||||
<fileset dir="${buildDir}"/>
|
||||
<fileset dir="${libsDir}" includes="**/*" excludes="**/.svn"/>
|
||||
</delete>
|
||||
</target>
|
||||
|
||||
<target name="precompile">
|
||||
<condition property="compiler-found">
|
||||
<and>
|
||||
<or>
|
||||
<!-- Include both b/c Windows might be either -->
|
||||
<available file="${g++}" filepath="${env.PATH}"/>
|
||||
<available file="${g++}" filepath="${env.Path}"/>
|
||||
</or>
|
||||
<or>
|
||||
<!-- Include both b/c Windows might be either -->
|
||||
<available file="${gcc}" filepath="${env.PATH}"/>
|
||||
<available file="${gcc}" filepath="${env.Path}"/>
|
||||
</or>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="has-compiler">
|
||||
<equals arg1="${compiler-found}" arg2="true"/>
|
||||
</condition>
|
||||
|
||||
</target>
|
||||
|
||||
<target name="create-build-dir" depends="precompile" if="has-compiler">
|
||||
<!-- FIXME this is pretty nasty :/ -->
|
||||
<copy todir="${buildDir}">
|
||||
<fileset refid="g++-files"/>
|
||||
<fileset refid="gcc-files"/>
|
||||
</copy>
|
||||
<delete>
|
||||
<fileset dir="${buildDir}">
|
||||
<include name="*"/>
|
||||
<exclude name="*.o"/>
|
||||
</fileset>
|
||||
</delete>
|
||||
</target>
|
||||
|
||||
<!-- compiles all C and C++ files to object files in the build directory -->
|
||||
<target name="compile" depends="create-build-dir" if="has-compiler">
|
||||
<mkdir dir="${buildDir}"/>
|
||||
<apply failonerror="true" executable="${g++}" dest="${buildDir}" verbose="true">
|
||||
<arg line="${g++-opts}"/>
|
||||
<arg value="-Ijni-headers"/>
|
||||
<arg value="-Ijni-headers/${jniPlatform}"/>
|
||||
<arg value="-I."/>
|
||||
<arg value="-I."/>
|
||||
|
||||
<srcfile/>
|
||||
<arg value="-o"/>
|
||||
<targetfile/>
|
||||
<fileset refid="g++-files"/>
|
||||
<compositemapper>
|
||||
<mapper type="glob" from="*.cpp" to="*.o"/>
|
||||
<mapper type="glob" from="*.mm" to="*.o"/>
|
||||
</compositemapper>
|
||||
</apply>
|
||||
<apply failonerror="true" executable="${gcc}" dest="${buildDir}" verbose="true">
|
||||
<arg line="${gcc-opts}"/>
|
||||
<arg value="-Ijni-headers"/>
|
||||
<arg value="-Ijni-headers/${jniPlatform}"/>
|
||||
<arg value="-I."/>
|
||||
<arg value="-I."/>
|
||||
|
||||
<srcfile/>
|
||||
<arg value="-o"/>
|
||||
<targetfile/>
|
||||
<fileset refid="gcc-files"/>
|
||||
<compositemapper>
|
||||
<mapper type="glob" from="*.c" to="*.o"/>
|
||||
<mapper type="glob" from="*.m" to="*.o"/>
|
||||
</compositemapper>
|
||||
</apply>
|
||||
</target>
|
||||
|
||||
<!-- links the shared library based on the previously compiled object files -->
|
||||
<target name="link" depends="compile" if="has-compiler">
|
||||
<fileset dir="${buildDir}" id="objFileSet">
|
||||
<patternset>
|
||||
<include name="**/*.o" />
|
||||
</patternset>
|
||||
</fileset>
|
||||
<pathconvert pathsep=" " property="objFiles" refid="objFileSet" />
|
||||
<mkdir dir="${libsDir}" />
|
||||
<exec executable="${linker}" failonerror="true" dir="${buildDir}">
|
||||
<arg line="${linker-opts}" />
|
||||
<arg value="-o" />
|
||||
<arg path="${libsDir}/${libName}" />
|
||||
<arg line="${objFiles}"/>
|
||||
<arg line="${libraries}" />
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="postcompile" depends="link">
|
||||
|
||||
</target>
|
||||
</project>
|
@ -1,156 +0,0 @@
|
||||
<project name="vtm-jni-Windows-64" basedir="." default="postcompile">
|
||||
<!-- include the environment -->
|
||||
<property environment="env"/>
|
||||
<!-- output directory for temporary object files -->
|
||||
<property name="buildDir" value="target/windows64" />
|
||||
<!-- output directory for the shared library -->
|
||||
<property name="libsDir" value="../libs/windows64" />
|
||||
<!-- the name of the shared library -->
|
||||
<property name="libName" value="vtm-jni64.dll"/>
|
||||
<!-- the jni header jniPlatform to use -->
|
||||
<property name="jniPlatform" value="win32"/>
|
||||
<!-- the compilerPrefix for the C & C++ compilers -->
|
||||
<property name="compilerPrefix" value="x86_64-w64-mingw32-"/>
|
||||
<!-- the compilerSuffix for the C & C++ compilers -->
|
||||
<property name="compilerSuffix" value="" />
|
||||
|
||||
<!-- define gcc compiler, options and files to compile -->
|
||||
<property name="gcc" value="${compilerPrefix}gcc${compilerSuffix}"/>
|
||||
<property name="gcc-opts" value="-c -Wall -O2 -mfpmath=sse -msse2 -fmessage-length=0 -m64 -Wall -std=c99 -O2 -ffast-math"/>
|
||||
<fileset id="gcc-files" dir="./">
|
||||
<exclude name="target/"/>
|
||||
<include name="memcpy_wrap.c"/>
|
||||
<include name="gl/utils.c"/>
|
||||
<include name="tessellate/dict.c"/>
|
||||
<include name="tessellate/mesh.c"/>
|
||||
<include name="tessellate/render.c"/>
|
||||
<include name="tessellate/tess.c"/>
|
||||
<include name="tessellate/geom.c"/>
|
||||
<include name="tessellate/memalloc.c"/>
|
||||
<include name="tessellate/normal.c"/>
|
||||
<include name="tessellate/priorityq.c"/>
|
||||
<include name="tessellate/sweep.c"/>
|
||||
<include name="tessellate/tessmono.c"/>
|
||||
<include name="tessellate/tessellate.c"/>
|
||||
<include name="tessellate/TessellateJni.c"/>
|
||||
|
||||
|
||||
</fileset>
|
||||
|
||||
<!-- define g++ compiler, options and files to compile -->
|
||||
<property name="g++" value="${compilerPrefix}g++${compilerSuffix}"/>
|
||||
<property name="g++-opts" value="-c -Wall -O2 -mfpmath=sse -msse2 -fmessage-length=0 -m64 -Wall -std=c99 -O2 -ffast-math"/>
|
||||
<fileset id="g++-files" dir="./">
|
||||
<exclude name="target/"/>
|
||||
<include name="**/*.cpp"/>
|
||||
|
||||
|
||||
</fileset>
|
||||
|
||||
<!-- define linker and options -->
|
||||
<property name="linker" value="${compilerPrefix}g++${compilerSuffix}"/>
|
||||
<property name="linker-opts" value="-Wl,--kill-at -shared -static-libgcc -static-libstdc++ -m64"/>
|
||||
<property name="libraries" value=""/>
|
||||
|
||||
<!-- cleans the build directory, removes all object files and shared libs -->
|
||||
<target name="clean">
|
||||
<delete includeemptydirs="true" quiet="true">
|
||||
<fileset dir="${buildDir}"/>
|
||||
<fileset dir="${libsDir}" includes="**/*" excludes="**/.svn"/>
|
||||
</delete>
|
||||
</target>
|
||||
|
||||
<target name="precompile">
|
||||
<condition property="compiler-found">
|
||||
<and>
|
||||
<or>
|
||||
<!-- Include both b/c Windows might be either -->
|
||||
<available file="${g++}" filepath="${env.PATH}"/>
|
||||
<available file="${g++}" filepath="${env.Path}"/>
|
||||
</or>
|
||||
<or>
|
||||
<!-- Include both b/c Windows might be either -->
|
||||
<available file="${gcc}" filepath="${env.PATH}"/>
|
||||
<available file="${gcc}" filepath="${env.Path}"/>
|
||||
</or>
|
||||
</and>
|
||||
</condition>
|
||||
<condition property="has-compiler">
|
||||
<equals arg1="${compiler-found}" arg2="true"/>
|
||||
</condition>
|
||||
|
||||
</target>
|
||||
|
||||
<target name="create-build-dir" depends="precompile" if="has-compiler">
|
||||
<!-- FIXME this is pretty nasty :/ -->
|
||||
<copy todir="${buildDir}">
|
||||
<fileset refid="g++-files"/>
|
||||
<fileset refid="gcc-files"/>
|
||||
</copy>
|
||||
<delete>
|
||||
<fileset dir="${buildDir}">
|
||||
<include name="*"/>
|
||||
<exclude name="*.o"/>
|
||||
</fileset>
|
||||
</delete>
|
||||
</target>
|
||||
|
||||
<!-- compiles all C and C++ files to object files in the build directory -->
|
||||
<target name="compile" depends="create-build-dir" if="has-compiler">
|
||||
<mkdir dir="${buildDir}"/>
|
||||
<apply failonerror="true" executable="${g++}" dest="${buildDir}" verbose="true">
|
||||
<arg line="${g++-opts}"/>
|
||||
<arg value="-Ijni-headers"/>
|
||||
<arg value="-Ijni-headers/${jniPlatform}"/>
|
||||
<arg value="-I."/>
|
||||
<arg value="-I."/>
|
||||
|
||||
<srcfile/>
|
||||
<arg value="-o"/>
|
||||
<targetfile/>
|
||||
<fileset refid="g++-files"/>
|
||||
<compositemapper>
|
||||
<mapper type="glob" from="*.cpp" to="*.o"/>
|
||||
<mapper type="glob" from="*.mm" to="*.o"/>
|
||||
</compositemapper>
|
||||
</apply>
|
||||
<apply failonerror="true" executable="${gcc}" dest="${buildDir}" verbose="true">
|
||||
<arg line="${gcc-opts}"/>
|
||||
<arg value="-Ijni-headers"/>
|
||||
<arg value="-Ijni-headers/${jniPlatform}"/>
|
||||
<arg value="-I."/>
|
||||
<arg value="-I."/>
|
||||
|
||||
<srcfile/>
|
||||
<arg value="-o"/>
|
||||
<targetfile/>
|
||||
<fileset refid="gcc-files"/>
|
||||
<compositemapper>
|
||||
<mapper type="glob" from="*.c" to="*.o"/>
|
||||
<mapper type="glob" from="*.m" to="*.o"/>
|
||||
</compositemapper>
|
||||
</apply>
|
||||
</target>
|
||||
|
||||
<!-- links the shared library based on the previously compiled object files -->
|
||||
<target name="link" depends="compile" if="has-compiler">
|
||||
<fileset dir="${buildDir}" id="objFileSet">
|
||||
<patternset>
|
||||
<include name="**/*.o" />
|
||||
</patternset>
|
||||
</fileset>
|
||||
<pathconvert pathsep=" " property="objFiles" refid="objFileSet" />
|
||||
<mkdir dir="${libsDir}" />
|
||||
<exec executable="${linker}" failonerror="true" dir="${buildDir}">
|
||||
<arg line="${linker-opts}" />
|
||||
<arg value="-o" />
|
||||
<arg path="${libsDir}/${libName}" />
|
||||
<arg line="${objFiles}"/>
|
||||
<arg line="${libraries}" />
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="postcompile" depends="link">
|
||||
|
||||
</target>
|
||||
</project>
|
@ -1,34 +0,0 @@
|
||||
<project name="vtm-jni-natives" basedir="." default="all">
|
||||
<target name="clean">
|
||||
|
||||
</target>
|
||||
|
||||
<target name="compile-natives">
|
||||
|
||||
</target>
|
||||
|
||||
<target name="pack-natives">
|
||||
<jar destfile="../libs/vtm-jni-natives.jar">
|
||||
<manifest>
|
||||
<!-- Who is building this jar? -->
|
||||
<attribute name="Built-By" value="${user.name}" />
|
||||
<!-- Information about the program itself -->
|
||||
<attribute name="Implementation-Vendor" value="VTM" />
|
||||
<attribute name="Implementation-Title" value="VTM" />
|
||||
<attribute name="Implementation-Version" value="0.5.9" />
|
||||
</manifest>
|
||||
|
||||
<fileset dir="../libs/linux64" includes="libvtm-jni64.so" />
|
||||
<!--
|
||||
<fileset dir="../libs/macosx32" includes="libvtm-jni.dylib"/>
|
||||
<fileset dir="../libs/macosx64" includes="libvtm-jni64.dylib"/>
|
||||
<fileset dir="../libs/windows32" includes="gdx.dll"/>
|
||||
<fileset dir="../libs/windows64" includes="gdx64.dll"/>
|
||||
<fileset dir="../libs/linux32" includes="libvtm-jni.so"/>
|
||||
-->
|
||||
|
||||
</jar>
|
||||
</target>
|
||||
|
||||
<target name="all" depends="compile-natives,pack-natives" />
|
||||
</project>
|
2
jni/cp.sh
Executable file
2
jni/cp.sh
Executable file
@ -0,0 +1,2 @@
|
||||
cp libs/armeabi/libvtm-jni.so ../vtm-ext-libs/vtm-android/armeabi
|
||||
cp libs/armeabi-v7a/libvtm-jni.so ../vtm-ext-libs/vtm-android/armeabi-v7a
|
22
jni/jni/Android.mk
Normal file
22
jni/jni/Android.mk
Normal file
@ -0,0 +1,22 @@
|
||||
LOCAL_PATH:= $(call my-dir)
|
||||
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_LDLIBS := -lm -llog
|
||||
LOCAL_ARM_MODE := arm
|
||||
|
||||
LOCAL_SRC_FILES := libtess2/Source/sweep.c\
|
||||
libtess2/Source/priorityq.c\
|
||||
libtess2/Source/bucketalloc.c\
|
||||
libtess2/Source/geom.c\
|
||||
libtess2/Source/tess.c\
|
||||
libtess2/Source/dict.c\
|
||||
libtess2/Source/mesh.c\
|
||||
org.oscim.utils.tess.Tesselator.cpp\
|
||||
gl/utils.c
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
2
jni/jni/Application.mk
Normal file
2
jni/jni/Application.mk
Normal file
@ -0,0 +1,2 @@
|
||||
APP_ABI := armeabi armeabi-v7a x86
|
||||
APP_PLATFORM := android-8
|
@ -16,30 +16,25 @@
|
||||
|
||||
<!-- define gcc compiler, options and files to compile -->
|
||||
<property name="gcc" value="${compilerPrefix}gcc${compilerSuffix}"/>
|
||||
<property name="gcc-opts" value="-c -Wall -O2 -mfpmath=sse -msse -fmessage-length=0 -m64 -fPIC -Wall -std=c99 -O2 -ffast-math"/>
|
||||
<property name="gcc-opts" value="-c -Wall -O2 -mfpmath=sse -msse -fmessage-length=0 -m64 -fPIC -Wall -std=c99 -O2 -ffast-math -DNDEBUG"/>
|
||||
<fileset id="gcc-files" dir="./">
|
||||
<exclude name="target/"/>
|
||||
<include name="memcpy_wrap.c"/>
|
||||
<include name="gl/utils.c"/>
|
||||
<include name="tessellate/dict.c"/>
|
||||
<include name="tessellate/mesh.c"/>
|
||||
<include name="tessellate/render.c"/>
|
||||
<include name="tessellate/tess.c"/>
|
||||
<include name="tessellate/geom.c"/>
|
||||
<include name="tessellate/memalloc.c"/>
|
||||
<include name="tessellate/normal.c"/>
|
||||
<include name="tessellate/priorityq.c"/>
|
||||
<include name="tessellate/sweep.c"/>
|
||||
<include name="tessellate/tessmono.c"/>
|
||||
<include name="tessellate/tessellate.c"/>
|
||||
<include name="tessellate/TessellateJni.c"/>
|
||||
<include name="libtess2/Source/bucketalloc.c"/>
|
||||
<include name="libtess2/Source/dict.c"/>
|
||||
<include name="libtess2/Source/geom.c"/>
|
||||
<include name="libtess2/Source/mesh.c"/>
|
||||
<include name="libtess2/Source/priorityq.c"/>
|
||||
<include name="libtess2/Source/sweep.c"/>
|
||||
<include name="libtess2/Source/tess.c"/>
|
||||
|
||||
|
||||
</fileset>
|
||||
|
||||
<!-- define g++ compiler, options and files to compile -->
|
||||
<property name="g++" value="${compilerPrefix}g++${compilerSuffix}"/>
|
||||
<property name="g++-opts" value="-c -Wall -O2 -mfpmath=sse -msse -fmessage-length=0 -m64 -fPIC -Wall -std=c99 -O2 -ffast-math"/>
|
||||
<property name="g++-opts" value="-c -Wall -O2 -mfpmath=sse -msse -fmessage-length=0 -m64 -fPIC -Wall -std=c99 -O2 -ffast-math -DNDEBUG"/>
|
||||
<fileset id="g++-files" dir="./">
|
||||
<exclude name="target/"/>
|
||||
<include name="**/*.cpp"/>
|
||||
@ -104,6 +99,7 @@
|
||||
<arg value="-Ijni-headers/${jniPlatform}"/>
|
||||
<arg value="-I."/>
|
||||
<arg value="-I."/>
|
||||
<arg value="-Ilibtess2/Include"/>
|
||||
|
||||
<srcfile/>
|
||||
<arg value="-o"/>
|
||||
@ -120,6 +116,7 @@
|
||||
<arg value="-Ijni-headers/${jniPlatform}"/>
|
||||
<arg value="-I."/>
|
||||
<arg value="-I."/>
|
||||
<arg value="-Ilibtess2/Include"/>
|
||||
|
||||
<srcfile/>
|
||||
<arg value="-o"/>
|
32
jni/jni/build.xml
Normal file
32
jni/jni/build.xml
Normal file
@ -0,0 +1,32 @@
|
||||
<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>
|
||||
|
||||
<target name="all" depends="compile-natives,pack-natives"/>
|
||||
</project>
|
523
jni/jni/jni-headers/classfile_constants.h
Normal file
523
jni/jni/jni-headers/classfile_constants.h
Normal file
@ -0,0 +1,523 @@
|
||||
/*
|
||||
* %W% %E%
|
||||
*
|
||||
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CLASSFILE_CONSTANTS_H
|
||||
#define CLASSFILE_CONSTANTS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Flags */
|
||||
|
||||
enum {
|
||||
JVM_ACC_PUBLIC = 0x0001,
|
||||
JVM_ACC_PRIVATE = 0x0002,
|
||||
JVM_ACC_PROTECTED = 0x0004,
|
||||
JVM_ACC_STATIC = 0x0008,
|
||||
JVM_ACC_FINAL = 0x0010,
|
||||
JVM_ACC_SYNCHRONIZED = 0x0020,
|
||||
JVM_ACC_SUPER = 0x0020,
|
||||
JVM_ACC_VOLATILE = 0x0040,
|
||||
JVM_ACC_BRIDGE = 0x0040,
|
||||
JVM_ACC_TRANSIENT = 0x0080,
|
||||
JVM_ACC_VARARGS = 0x0080,
|
||||
JVM_ACC_NATIVE = 0x0100,
|
||||
JVM_ACC_INTERFACE = 0x0200,
|
||||
JVM_ACC_ABSTRACT = 0x0400,
|
||||
JVM_ACC_STRICT = 0x0800,
|
||||
JVM_ACC_SYNTHETIC = 0x1000,
|
||||
JVM_ACC_ANNOTATION = 0x2000,
|
||||
JVM_ACC_ENUM = 0x4000
|
||||
};
|
||||
|
||||
/* Used in newarray instruction. */
|
||||
|
||||
enum {
|
||||
JVM_T_BOOLEAN = 4,
|
||||
JVM_T_CHAR = 5,
|
||||
JVM_T_FLOAT = 6,
|
||||
JVM_T_DOUBLE = 7,
|
||||
JVM_T_BYTE = 8,
|
||||
JVM_T_SHORT = 9,
|
||||
JVM_T_INT = 10,
|
||||
JVM_T_LONG = 11
|
||||
};
|
||||
|
||||
/* Constant Pool Entries */
|
||||
|
||||
enum {
|
||||
JVM_CONSTANT_Utf8 = 1,
|
||||
JVM_CONSTANT_Unicode = 2, /* unused */
|
||||
JVM_CONSTANT_Integer = 3,
|
||||
JVM_CONSTANT_Float = 4,
|
||||
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
|
||||
};
|
||||
|
||||
/* StackMapTable type item numbers */
|
||||
|
||||
enum {
|
||||
JVM_ITEM_Top = 0,
|
||||
JVM_ITEM_Integer = 1,
|
||||
JVM_ITEM_Float = 2,
|
||||
JVM_ITEM_Double = 3,
|
||||
JVM_ITEM_Long = 4,
|
||||
JVM_ITEM_Null = 5,
|
||||
JVM_ITEM_UninitializedThis = 6,
|
||||
JVM_ITEM_Object = 7,
|
||||
JVM_ITEM_Uninitialized = 8
|
||||
};
|
||||
|
||||
/* Type signatures */
|
||||
|
||||
enum {
|
||||
JVM_SIGNATURE_ARRAY = '[',
|
||||
JVM_SIGNATURE_BYTE = 'B',
|
||||
JVM_SIGNATURE_CHAR = 'C',
|
||||
JVM_SIGNATURE_CLASS = 'L',
|
||||
JVM_SIGNATURE_ENDCLASS = ';',
|
||||
JVM_SIGNATURE_ENUM = 'E',
|
||||
JVM_SIGNATURE_FLOAT = 'F',
|
||||
JVM_SIGNATURE_DOUBLE = 'D',
|
||||
JVM_SIGNATURE_FUNC = '(',
|
||||
JVM_SIGNATURE_ENDFUNC = ')',
|
||||
JVM_SIGNATURE_INT = 'I',
|
||||
JVM_SIGNATURE_LONG = 'J',
|
||||
JVM_SIGNATURE_SHORT = 'S',
|
||||
JVM_SIGNATURE_VOID = 'V',
|
||||
JVM_SIGNATURE_BOOLEAN = 'Z'
|
||||
};
|
||||
|
||||
/* Opcodes */
|
||||
|
||||
enum {
|
||||
JVM_OPC_nop = 0,
|
||||
JVM_OPC_aconst_null = 1,
|
||||
JVM_OPC_iconst_m1 = 2,
|
||||
JVM_OPC_iconst_0 = 3,
|
||||
JVM_OPC_iconst_1 = 4,
|
||||
JVM_OPC_iconst_2 = 5,
|
||||
JVM_OPC_iconst_3 = 6,
|
||||
JVM_OPC_iconst_4 = 7,
|
||||
JVM_OPC_iconst_5 = 8,
|
||||
JVM_OPC_lconst_0 = 9,
|
||||
JVM_OPC_lconst_1 = 10,
|
||||
JVM_OPC_fconst_0 = 11,
|
||||
JVM_OPC_fconst_1 = 12,
|
||||
JVM_OPC_fconst_2 = 13,
|
||||
JVM_OPC_dconst_0 = 14,
|
||||
JVM_OPC_dconst_1 = 15,
|
||||
JVM_OPC_bipush = 16,
|
||||
JVM_OPC_sipush = 17,
|
||||
JVM_OPC_ldc = 18,
|
||||
JVM_OPC_ldc_w = 19,
|
||||
JVM_OPC_ldc2_w = 20,
|
||||
JVM_OPC_iload = 21,
|
||||
JVM_OPC_lload = 22,
|
||||
JVM_OPC_fload = 23,
|
||||
JVM_OPC_dload = 24,
|
||||
JVM_OPC_aload = 25,
|
||||
JVM_OPC_iload_0 = 26,
|
||||
JVM_OPC_iload_1 = 27,
|
||||
JVM_OPC_iload_2 = 28,
|
||||
JVM_OPC_iload_3 = 29,
|
||||
JVM_OPC_lload_0 = 30,
|
||||
JVM_OPC_lload_1 = 31,
|
||||
JVM_OPC_lload_2 = 32,
|
||||
JVM_OPC_lload_3 = 33,
|
||||
JVM_OPC_fload_0 = 34,
|
||||
JVM_OPC_fload_1 = 35,
|
||||
JVM_OPC_fload_2 = 36,
|
||||
JVM_OPC_fload_3 = 37,
|
||||
JVM_OPC_dload_0 = 38,
|
||||
JVM_OPC_dload_1 = 39,
|
||||
JVM_OPC_dload_2 = 40,
|
||||
JVM_OPC_dload_3 = 41,
|
||||
JVM_OPC_aload_0 = 42,
|
||||
JVM_OPC_aload_1 = 43,
|
||||
JVM_OPC_aload_2 = 44,
|
||||
JVM_OPC_aload_3 = 45,
|
||||
JVM_OPC_iaload = 46,
|
||||
JVM_OPC_laload = 47,
|
||||
JVM_OPC_faload = 48,
|
||||
JVM_OPC_daload = 49,
|
||||
JVM_OPC_aaload = 50,
|
||||
JVM_OPC_baload = 51,
|
||||
JVM_OPC_caload = 52,
|
||||
JVM_OPC_saload = 53,
|
||||
JVM_OPC_istore = 54,
|
||||
JVM_OPC_lstore = 55,
|
||||
JVM_OPC_fstore = 56,
|
||||
JVM_OPC_dstore = 57,
|
||||
JVM_OPC_astore = 58,
|
||||
JVM_OPC_istore_0 = 59,
|
||||
JVM_OPC_istore_1 = 60,
|
||||
JVM_OPC_istore_2 = 61,
|
||||
JVM_OPC_istore_3 = 62,
|
||||
JVM_OPC_lstore_0 = 63,
|
||||
JVM_OPC_lstore_1 = 64,
|
||||
JVM_OPC_lstore_2 = 65,
|
||||
JVM_OPC_lstore_3 = 66,
|
||||
JVM_OPC_fstore_0 = 67,
|
||||
JVM_OPC_fstore_1 = 68,
|
||||
JVM_OPC_fstore_2 = 69,
|
||||
JVM_OPC_fstore_3 = 70,
|
||||
JVM_OPC_dstore_0 = 71,
|
||||
JVM_OPC_dstore_1 = 72,
|
||||
JVM_OPC_dstore_2 = 73,
|
||||
JVM_OPC_dstore_3 = 74,
|
||||
JVM_OPC_astore_0 = 75,
|
||||
JVM_OPC_astore_1 = 76,
|
||||
JVM_OPC_astore_2 = 77,
|
||||
JVM_OPC_astore_3 = 78,
|
||||
JVM_OPC_iastore = 79,
|
||||
JVM_OPC_lastore = 80,
|
||||
JVM_OPC_fastore = 81,
|
||||
JVM_OPC_dastore = 82,
|
||||
JVM_OPC_aastore = 83,
|
||||
JVM_OPC_bastore = 84,
|
||||
JVM_OPC_castore = 85,
|
||||
JVM_OPC_sastore = 86,
|
||||
JVM_OPC_pop = 87,
|
||||
JVM_OPC_pop2 = 88,
|
||||
JVM_OPC_dup = 89,
|
||||
JVM_OPC_dup_x1 = 90,
|
||||
JVM_OPC_dup_x2 = 91,
|
||||
JVM_OPC_dup2 = 92,
|
||||
JVM_OPC_dup2_x1 = 93,
|
||||
JVM_OPC_dup2_x2 = 94,
|
||||
JVM_OPC_swap = 95,
|
||||
JVM_OPC_iadd = 96,
|
||||
JVM_OPC_ladd = 97,
|
||||
JVM_OPC_fadd = 98,
|
||||
JVM_OPC_dadd = 99,
|
||||
JVM_OPC_isub = 100,
|
||||
JVM_OPC_lsub = 101,
|
||||
JVM_OPC_fsub = 102,
|
||||
JVM_OPC_dsub = 103,
|
||||
JVM_OPC_imul = 104,
|
||||
JVM_OPC_lmul = 105,
|
||||
JVM_OPC_fmul = 106,
|
||||
JVM_OPC_dmul = 107,
|
||||
JVM_OPC_idiv = 108,
|
||||
JVM_OPC_ldiv = 109,
|
||||
JVM_OPC_fdiv = 110,
|
||||
JVM_OPC_ddiv = 111,
|
||||
JVM_OPC_irem = 112,
|
||||
JVM_OPC_lrem = 113,
|
||||
JVM_OPC_frem = 114,
|
||||
JVM_OPC_drem = 115,
|
||||
JVM_OPC_ineg = 116,
|
||||
JVM_OPC_lneg = 117,
|
||||
JVM_OPC_fneg = 118,
|
||||
JVM_OPC_dneg = 119,
|
||||
JVM_OPC_ishl = 120,
|
||||
JVM_OPC_lshl = 121,
|
||||
JVM_OPC_ishr = 122,
|
||||
JVM_OPC_lshr = 123,
|
||||
JVM_OPC_iushr = 124,
|
||||
JVM_OPC_lushr = 125,
|
||||
JVM_OPC_iand = 126,
|
||||
JVM_OPC_land = 127,
|
||||
JVM_OPC_ior = 128,
|
||||
JVM_OPC_lor = 129,
|
||||
JVM_OPC_ixor = 130,
|
||||
JVM_OPC_lxor = 131,
|
||||
JVM_OPC_iinc = 132,
|
||||
JVM_OPC_i2l = 133,
|
||||
JVM_OPC_i2f = 134,
|
||||
JVM_OPC_i2d = 135,
|
||||
JVM_OPC_l2i = 136,
|
||||
JVM_OPC_l2f = 137,
|
||||
JVM_OPC_l2d = 138,
|
||||
JVM_OPC_f2i = 139,
|
||||
JVM_OPC_f2l = 140,
|
||||
JVM_OPC_f2d = 141,
|
||||
JVM_OPC_d2i = 142,
|
||||
JVM_OPC_d2l = 143,
|
||||
JVM_OPC_d2f = 144,
|
||||
JVM_OPC_i2b = 145,
|
||||
JVM_OPC_i2c = 146,
|
||||
JVM_OPC_i2s = 147,
|
||||
JVM_OPC_lcmp = 148,
|
||||
JVM_OPC_fcmpl = 149,
|
||||
JVM_OPC_fcmpg = 150,
|
||||
JVM_OPC_dcmpl = 151,
|
||||
JVM_OPC_dcmpg = 152,
|
||||
JVM_OPC_ifeq = 153,
|
||||
JVM_OPC_ifne = 154,
|
||||
JVM_OPC_iflt = 155,
|
||||
JVM_OPC_ifge = 156,
|
||||
JVM_OPC_ifgt = 157,
|
||||
JVM_OPC_ifle = 158,
|
||||
JVM_OPC_if_icmpeq = 159,
|
||||
JVM_OPC_if_icmpne = 160,
|
||||
JVM_OPC_if_icmplt = 161,
|
||||
JVM_OPC_if_icmpge = 162,
|
||||
JVM_OPC_if_icmpgt = 163,
|
||||
JVM_OPC_if_icmple = 164,
|
||||
JVM_OPC_if_acmpeq = 165,
|
||||
JVM_OPC_if_acmpne = 166,
|
||||
JVM_OPC_goto = 167,
|
||||
JVM_OPC_jsr = 168,
|
||||
JVM_OPC_ret = 169,
|
||||
JVM_OPC_tableswitch = 170,
|
||||
JVM_OPC_lookupswitch = 171,
|
||||
JVM_OPC_ireturn = 172,
|
||||
JVM_OPC_lreturn = 173,
|
||||
JVM_OPC_freturn = 174,
|
||||
JVM_OPC_dreturn = 175,
|
||||
JVM_OPC_areturn = 176,
|
||||
JVM_OPC_return = 177,
|
||||
JVM_OPC_getstatic = 178,
|
||||
JVM_OPC_putstatic = 179,
|
||||
JVM_OPC_getfield = 180,
|
||||
JVM_OPC_putfield = 181,
|
||||
JVM_OPC_invokevirtual = 182,
|
||||
JVM_OPC_invokespecial = 183,
|
||||
JVM_OPC_invokestatic = 184,
|
||||
JVM_OPC_invokeinterface = 185,
|
||||
JVM_OPC_xxxunusedxxx = 186,
|
||||
JVM_OPC_new = 187,
|
||||
JVM_OPC_newarray = 188,
|
||||
JVM_OPC_anewarray = 189,
|
||||
JVM_OPC_arraylength = 190,
|
||||
JVM_OPC_athrow = 191,
|
||||
JVM_OPC_checkcast = 192,
|
||||
JVM_OPC_instanceof = 193,
|
||||
JVM_OPC_monitorenter = 194,
|
||||
JVM_OPC_monitorexit = 195,
|
||||
JVM_OPC_wide = 196,
|
||||
JVM_OPC_multianewarray = 197,
|
||||
JVM_OPC_ifnull = 198,
|
||||
JVM_OPC_ifnonnull = 199,
|
||||
JVM_OPC_goto_w = 200,
|
||||
JVM_OPC_jsr_w = 201,
|
||||
JVM_OPC_MAX = 201
|
||||
};
|
||||
|
||||
/* Opcode length initializer, use with something like:
|
||||
* unsigned char opcode_length[JVM_OPC_MAX+1] = JVM_OPCODE_LENGTH_INITIALIZER;
|
||||
*/
|
||||
#define JVM_OPCODE_LENGTH_INITIALIZER { \
|
||||
1, /* nop */ \
|
||||
1, /* aconst_null */ \
|
||||
1, /* iconst_m1 */ \
|
||||
1, /* iconst_0 */ \
|
||||
1, /* iconst_1 */ \
|
||||
1, /* iconst_2 */ \
|
||||
1, /* iconst_3 */ \
|
||||
1, /* iconst_4 */ \
|
||||
1, /* iconst_5 */ \
|
||||
1, /* lconst_0 */ \
|
||||
1, /* lconst_1 */ \
|
||||
1, /* fconst_0 */ \
|
||||
1, /* fconst_1 */ \
|
||||
1, /* fconst_2 */ \
|
||||
1, /* dconst_0 */ \
|
||||
1, /* dconst_1 */ \
|
||||
2, /* bipush */ \
|
||||
3, /* sipush */ \
|
||||
2, /* ldc */ \
|
||||
3, /* ldc_w */ \
|
||||
3, /* ldc2_w */ \
|
||||
2, /* iload */ \
|
||||
2, /* lload */ \
|
||||
2, /* fload */ \
|
||||
2, /* dload */ \
|
||||
2, /* aload */ \
|
||||
1, /* iload_0 */ \
|
||||
1, /* iload_1 */ \
|
||||
1, /* iload_2 */ \
|
||||
1, /* iload_3 */ \
|
||||
1, /* lload_0 */ \
|
||||
1, /* lload_1 */ \
|
||||
1, /* lload_2 */ \
|
||||
1, /* lload_3 */ \
|
||||
1, /* fload_0 */ \
|
||||
1, /* fload_1 */ \
|
||||
1, /* fload_2 */ \
|
||||
1, /* fload_3 */ \
|
||||
1, /* dload_0 */ \
|
||||
1, /* dload_1 */ \
|
||||
1, /* dload_2 */ \
|
||||
1, /* dload_3 */ \
|
||||
1, /* aload_0 */ \
|
||||
1, /* aload_1 */ \
|
||||
1, /* aload_2 */ \
|
||||
1, /* aload_3 */ \
|
||||
1, /* iaload */ \
|
||||
1, /* laload */ \
|
||||
1, /* faload */ \
|
||||
1, /* daload */ \
|
||||
1, /* aaload */ \
|
||||
1, /* baload */ \
|
||||
1, /* caload */ \
|
||||
1, /* saload */ \
|
||||
2, /* istore */ \
|
||||
2, /* lstore */ \
|
||||
2, /* fstore */ \
|
||||
2, /* dstore */ \
|
||||
2, /* astore */ \
|
||||
1, /* istore_0 */ \
|
||||
1, /* istore_1 */ \
|
||||
1, /* istore_2 */ \
|
||||
1, /* istore_3 */ \
|
||||
1, /* lstore_0 */ \
|
||||
1, /* lstore_1 */ \
|
||||
1, /* lstore_2 */ \
|
||||
1, /* lstore_3 */ \
|
||||
1, /* fstore_0 */ \
|
||||
1, /* fstore_1 */ \
|
||||
1, /* fstore_2 */ \
|
||||
1, /* fstore_3 */ \
|
||||
1, /* dstore_0 */ \
|
||||
1, /* dstore_1 */ \
|
||||
1, /* dstore_2 */ \
|
||||
1, /* dstore_3 */ \
|
||||
1, /* astore_0 */ \
|
||||
1, /* astore_1 */ \
|
||||
1, /* astore_2 */ \
|
||||
1, /* astore_3 */ \
|
||||
1, /* iastore */ \
|
||||
1, /* lastore */ \
|
||||
1, /* fastore */ \
|
||||
1, /* dastore */ \
|
||||
1, /* aastore */ \
|
||||
1, /* bastore */ \
|
||||
1, /* castore */ \
|
||||
1, /* sastore */ \
|
||||
1, /* pop */ \
|
||||
1, /* pop2 */ \
|
||||
1, /* dup */ \
|
||||
1, /* dup_x1 */ \
|
||||
1, /* dup_x2 */ \
|
||||
1, /* dup2 */ \
|
||||
1, /* dup2_x1 */ \
|
||||
1, /* dup2_x2 */ \
|
||||
1, /* swap */ \
|
||||
1, /* iadd */ \
|
||||
1, /* ladd */ \
|
||||
1, /* fadd */ \
|
||||
1, /* dadd */ \
|
||||
1, /* isub */ \
|
||||
1, /* lsub */ \
|
||||
1, /* fsub */ \
|
||||
1, /* dsub */ \
|
||||
1, /* imul */ \
|
||||
1, /* lmul */ \
|
||||
1, /* fmul */ \
|
||||
1, /* dmul */ \
|
||||
1, /* idiv */ \
|
||||
1, /* ldiv */ \
|
||||
1, /* fdiv */ \
|
||||
1, /* ddiv */ \
|
||||
1, /* irem */ \
|
||||
1, /* lrem */ \
|
||||
1, /* frem */ \
|
||||
1, /* drem */ \
|
||||
1, /* ineg */ \
|
||||
1, /* lneg */ \
|
||||
1, /* fneg */ \
|
||||
1, /* dneg */ \
|
||||
1, /* ishl */ \
|
||||
1, /* lshl */ \
|
||||
1, /* ishr */ \
|
||||
1, /* lshr */ \
|
||||
1, /* iushr */ \
|
||||
1, /* lushr */ \
|
||||
1, /* iand */ \
|
||||
1, /* land */ \
|
||||
1, /* ior */ \
|
||||
1, /* lor */ \
|
||||
1, /* ixor */ \
|
||||
1, /* lxor */ \
|
||||
3, /* iinc */ \
|
||||
1, /* i2l */ \
|
||||
1, /* i2f */ \
|
||||
1, /* i2d */ \
|
||||
1, /* l2i */ \
|
||||
1, /* l2f */ \
|
||||
1, /* l2d */ \
|
||||
1, /* f2i */ \
|
||||
1, /* f2l */ \
|
||||
1, /* f2d */ \
|
||||
1, /* d2i */ \
|
||||
1, /* d2l */ \
|
||||
1, /* d2f */ \
|
||||
1, /* i2b */ \
|
||||
1, /* i2c */ \
|
||||
1, /* i2s */ \
|
||||
1, /* lcmp */ \
|
||||
1, /* fcmpl */ \
|
||||
1, /* fcmpg */ \
|
||||
1, /* dcmpl */ \
|
||||
1, /* dcmpg */ \
|
||||
3, /* ifeq */ \
|
||||
3, /* ifne */ \
|
||||
3, /* iflt */ \
|
||||
3, /* ifge */ \
|
||||
3, /* ifgt */ \
|
||||
3, /* ifle */ \
|
||||
3, /* if_icmpeq */ \
|
||||
3, /* if_icmpne */ \
|
||||
3, /* if_icmplt */ \
|
||||
3, /* if_icmpge */ \
|
||||
3, /* if_icmpgt */ \
|
||||
3, /* if_icmple */ \
|
||||
3, /* if_acmpeq */ \
|
||||
3, /* if_acmpne */ \
|
||||
3, /* goto */ \
|
||||
3, /* jsr */ \
|
||||
2, /* ret */ \
|
||||
99, /* tableswitch */ \
|
||||
99, /* lookupswitch */ \
|
||||
1, /* ireturn */ \
|
||||
1, /* lreturn */ \
|
||||
1, /* freturn */ \
|
||||
1, /* dreturn */ \
|
||||
1, /* areturn */ \
|
||||
1, /* return */ \
|
||||
3, /* getstatic */ \
|
||||
3, /* putstatic */ \
|
||||
3, /* getfield */ \
|
||||
3, /* putfield */ \
|
||||
3, /* invokevirtual */ \
|
||||
3, /* invokespecial */ \
|
||||
3, /* invokestatic */ \
|
||||
5, /* invokeinterface */ \
|
||||
0, /* xxxunusedxxx */ \
|
||||
3, /* new */ \
|
||||
2, /* newarray */ \
|
||||
3, /* anewarray */ \
|
||||
1, /* arraylength */ \
|
||||
1, /* athrow */ \
|
||||
3, /* checkcast */ \
|
||||
3, /* instanceof */ \
|
||||
1, /* monitorenter */ \
|
||||
1, /* monitorexit */ \
|
||||
0, /* wide */ \
|
||||
4, /* multianewarray */ \
|
||||
3, /* ifnull */ \
|
||||
3, /* ifnonnull */ \
|
||||
5, /* goto_w */ \
|
||||
5 /* jsr_w */ \
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* CLASSFILE_CONSTANTS */
|
278
jni/jni/jni-headers/jawt.h
Normal file
278
jni/jni/jni-headers/jawt.h
Normal file
@ -0,0 +1,278 @@
|
||||
/*
|
||||
* %W% %E%
|
||||
*
|
||||
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#ifndef _JAVASOFT_JAWT_H_
|
||||
#define _JAVASOFT_JAWT_H_
|
||||
|
||||
#include "jni.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* AWT native interface (new in JDK 1.3)
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* There may be future extensions to this API depending on demand.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Since this is a native API, any program which uses it cannot be considered
|
||||
* 100% pure java.
|
||||
*/
|
||||
|
||||
/*
|
||||
* AWT Native Drawing Surface (JAWT_DrawingSurface).
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*******************
|
||||
* EXAMPLE OF USAGE:
|
||||
*******************
|
||||
*
|
||||
* In Win32, a programmer wishes to access the HWND of a canvas to perform
|
||||
* native rendering into it. The programmer has declared the paint() method
|
||||
* for their canvas subclass to be native:
|
||||
*
|
||||
*
|
||||
* MyCanvas.java:
|
||||
*
|
||||
* import java.awt.*;
|
||||
*
|
||||
* public class MyCanvas extends Canvas {
|
||||
*
|
||||
* static {
|
||||
* System.loadLibrary("mylib");
|
||||
* }
|
||||
*
|
||||
* public native void paint(Graphics g);
|
||||
* }
|
||||
*
|
||||
*
|
||||
* myfile.c:
|
||||
*
|
||||
* #include "jawt_md.h"
|
||||
* #include <assert.h>
|
||||
*
|
||||
* JNIEXPORT void JNICALL
|
||||
* Java_MyCanvas_paint(JNIEnv* env, jobject canvas, jobject graphics)
|
||||
* {
|
||||
* JAWT awt;
|
||||
* JAWT_DrawingSurface* ds;
|
||||
* JAWT_DrawingSurfaceInfo* dsi;
|
||||
* JAWT_Win32DrawingSurfaceInfo* dsi_win;
|
||||
* jboolean result;
|
||||
* jint lock;
|
||||
*
|
||||
* // Get the AWT
|
||||
* awt.version = JAWT_VERSION_1_3;
|
||||
* result = JAWT_GetAWT(env, &awt);
|
||||
* assert(result != JNI_FALSE);
|
||||
*
|
||||
* // Get the drawing surface
|
||||
* ds = awt.GetDrawingSurface(env, canvas);
|
||||
* assert(ds != NULL);
|
||||
*
|
||||
* // Lock the drawing surface
|
||||
* lock = ds->Lock(ds);
|
||||
* assert((lock & JAWT_LOCK_ERROR) == 0);
|
||||
*
|
||||
* // Get the drawing surface info
|
||||
* dsi = ds->GetDrawingSurfaceInfo(ds);
|
||||
*
|
||||
* // Get the platform-specific drawing info
|
||||
* dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
|
||||
*
|
||||
* //////////////////////////////
|
||||
* // !!! DO PAINTING HERE !!! //
|
||||
* //////////////////////////////
|
||||
*
|
||||
* // Free the drawing surface info
|
||||
* ds->FreeDrawingSurfaceInfo(dsi);
|
||||
*
|
||||
* // Unlock the drawing surface
|
||||
* ds->Unlock(ds);
|
||||
*
|
||||
* // Free the drawing surface
|
||||
* awt.FreeDrawingSurface(ds);
|
||||
* }
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* JAWT_Rectangle
|
||||
* Structure for a native rectangle.
|
||||
*/
|
||||
typedef struct jawt_Rectangle {
|
||||
jint x;
|
||||
jint y;
|
||||
jint width;
|
||||
jint height;
|
||||
} JAWT_Rectangle;
|
||||
|
||||
struct jawt_DrawingSurface;
|
||||
|
||||
/*
|
||||
* JAWT_DrawingSurfaceInfo
|
||||
* Structure for containing the underlying drawing information of a component.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
void* platformInfo;
|
||||
/* Cached pointer to the underlying drawing surface */
|
||||
struct jawt_DrawingSurface* ds;
|
||||
/* Bounding rectangle of the drawing surface */
|
||||
JAWT_Rectangle bounds;
|
||||
/* Number of rectangles in the clip */
|
||||
jint clipSize;
|
||||
/* Clip rectangle array */
|
||||
JAWT_Rectangle* clip;
|
||||
} JAWT_DrawingSurfaceInfo;
|
||||
|
||||
#define JAWT_LOCK_ERROR 0x00000001
|
||||
#define JAWT_LOCK_CLIP_CHANGED 0x00000002
|
||||
#define JAWT_LOCK_BOUNDS_CHANGED 0x00000004
|
||||
#define JAWT_LOCK_SURFACE_CHANGED 0x00000008
|
||||
|
||||
/*
|
||||
* JAWT_DrawingSurface
|
||||
* Structure for containing the underlying drawing information of a component.
|
||||
* All operations on a JAWT_DrawingSurface MUST be performed from the same
|
||||
* thread as the call to GetDrawingSurface.
|
||||
*/
|
||||
typedef struct jawt_DrawingSurface {
|
||||
/*
|
||||
* Cached reference to the Java environment of the calling thread.
|
||||
* If Lock(), Unlock(), GetDrawingSurfaceInfo() or
|
||||
* FreeDrawingSurfaceInfo() are called from a different thread,
|
||||
* this data member should be set before calling those functions.
|
||||
*/
|
||||
JNIEnv* env;
|
||||
/* Cached reference to the target object */
|
||||
jobject target;
|
||||
/*
|
||||
* Lock the surface of the target component for native rendering.
|
||||
* When finished drawing, the surface must be unlocked with
|
||||
* Unlock(). This function returns a bitmask with one or more of the
|
||||
* following values:
|
||||
*
|
||||
* JAWT_LOCK_ERROR - When an error has occurred and the surface could not
|
||||
* be locked.
|
||||
*
|
||||
* JAWT_LOCK_CLIP_CHANGED - When the clip region has changed.
|
||||
*
|
||||
* JAWT_LOCK_BOUNDS_CHANGED - When the bounds of the surface have changed.
|
||||
*
|
||||
* JAWT_LOCK_SURFACE_CHANGED - When the surface itself has changed
|
||||
*/
|
||||
jint (JNICALL *Lock)
|
||||
(struct jawt_DrawingSurface* ds);
|
||||
/*
|
||||
* Get the drawing surface info.
|
||||
* The value returned may be cached, but the values may change if
|
||||
* additional calls to Lock() or Unlock() are made.
|
||||
* Lock() must be called before this can return a valid value.
|
||||
* Returns NULL if an error has occurred.
|
||||
* When finished with the returned value, FreeDrawingSurfaceInfo must be
|
||||
* called.
|
||||
*/
|
||||
JAWT_DrawingSurfaceInfo* (JNICALL *GetDrawingSurfaceInfo)
|
||||
(struct jawt_DrawingSurface* ds);
|
||||
/*
|
||||
* Free the drawing surface info.
|
||||
*/
|
||||
void (JNICALL *FreeDrawingSurfaceInfo)
|
||||
(JAWT_DrawingSurfaceInfo* dsi);
|
||||
/*
|
||||
* Unlock the drawing surface of the target component for native rendering.
|
||||
*/
|
||||
void (JNICALL *Unlock)
|
||||
(struct jawt_DrawingSurface* ds);
|
||||
} JAWT_DrawingSurface;
|
||||
|
||||
/*
|
||||
* JAWT
|
||||
* Structure for containing native AWT functions.
|
||||
*/
|
||||
typedef struct jawt {
|
||||
/*
|
||||
* Version of this structure. This must always be set before
|
||||
* calling JAWT_GetAWT()
|
||||
*/
|
||||
jint version;
|
||||
/*
|
||||
* Return a drawing surface from a target jobject. This value
|
||||
* may be cached.
|
||||
* Returns NULL if an error has occurred.
|
||||
* Target must be a java.awt.Component (should be a Canvas
|
||||
* or Window for native rendering).
|
||||
* FreeDrawingSurface() must be called when finished with the
|
||||
* returned JAWT_DrawingSurface.
|
||||
*/
|
||||
JAWT_DrawingSurface* (JNICALL *GetDrawingSurface)
|
||||
(JNIEnv* env, jobject target);
|
||||
/*
|
||||
* Free the drawing surface allocated in GetDrawingSurface.
|
||||
*/
|
||||
void (JNICALL *FreeDrawingSurface)
|
||||
(JAWT_DrawingSurface* ds);
|
||||
/*
|
||||
* Since 1.4
|
||||
* Locks the entire AWT for synchronization purposes
|
||||
*/
|
||||
void (JNICALL *Lock)(JNIEnv* env);
|
||||
/*
|
||||
* Since 1.4
|
||||
* Unlocks the entire AWT for synchronization purposes
|
||||
*/
|
||||
void (JNICALL *Unlock)(JNIEnv* env);
|
||||
/*
|
||||
* Since 1.4
|
||||
* Returns a reference to a java.awt.Component from a native
|
||||
* platform handle. On Windows, this corresponds to an HWND;
|
||||
* on Solaris and Linux, this is a Drawable. 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 component could be
|
||||
* found with matching platform information.
|
||||
*/
|
||||
jobject (JNICALL *GetComponent)(JNIEnv* env, void* platformInfo);
|
||||
|
||||
} JAWT;
|
||||
|
||||
/*
|
||||
* Get the AWT native structure. This function returns JNI_FALSE if
|
||||
* an error occurs.
|
||||
*/
|
||||
_JNI_IMPORT_OR_EXPORT_
|
||||
jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt);
|
||||
|
||||
#define JAWT_VERSION_1_3 0x00010003
|
||||
#define JAWT_VERSION_1_4 0x00010004
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* !_JAVASOFT_JAWT_H_ */
|
237
jni/jni/jni-headers/jdwpTransport.h
Normal file
237
jni/jni/jni-headers/jdwpTransport.h
Normal file
@ -0,0 +1,237 @@
|
||||
/*
|
||||
* %W% %E%
|
||||
*
|
||||
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Java Debug Wire Protocol Transport Service Provider Interface.
|
||||
*/
|
||||
|
||||
#ifndef JDWPTRANSPORT_H
|
||||
#define JDWPTRANSPORT_H
|
||||
|
||||
#include "jni.h"
|
||||
|
||||
enum {
|
||||
JDWPTRANSPORT_VERSION_1_0 = 0x00010000
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct jdwpTransportNativeInterface_;
|
||||
|
||||
struct _jdwpTransportEnv;
|
||||
|
||||
#ifdef __cplusplus
|
||||
typedef _jdwpTransportEnv jdwpTransportEnv;
|
||||
#else
|
||||
typedef const struct jdwpTransportNativeInterface_ *jdwpTransportEnv;
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* Errors. Universal errors with JVMTI/JVMDI equivalents keep the
|
||||
* values the same.
|
||||
*/
|
||||
typedef enum {
|
||||
JDWPTRANSPORT_ERROR_NONE = 0,
|
||||
JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT = 103,
|
||||
JDWPTRANSPORT_ERROR_OUT_OF_MEMORY = 110,
|
||||
JDWPTRANSPORT_ERROR_INTERNAL = 113,
|
||||
JDWPTRANSPORT_ERROR_ILLEGAL_STATE = 201,
|
||||
JDWPTRANSPORT_ERROR_IO_ERROR = 202,
|
||||
JDWPTRANSPORT_ERROR_TIMEOUT = 203,
|
||||
JDWPTRANSPORT_ERROR_MSG_NOT_AVAILABLE = 204
|
||||
} jdwpTransportError;
|
||||
|
||||
|
||||
/*
|
||||
* Structure to define capabilities
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned int can_timeout_attach :1;
|
||||
unsigned int can_timeout_accept :1;
|
||||
unsigned int can_timeout_handshake :1;
|
||||
unsigned int reserved3 :1;
|
||||
unsigned int reserved4 :1;
|
||||
unsigned int reserved5 :1;
|
||||
unsigned int reserved6 :1;
|
||||
unsigned int reserved7 :1;
|
||||
unsigned int reserved8 :1;
|
||||
unsigned int reserved9 :1;
|
||||
unsigned int reserved10 :1;
|
||||
unsigned int reserved11 :1;
|
||||
unsigned int reserved12 :1;
|
||||
unsigned int reserved13 :1;
|
||||
unsigned int reserved14 :1;
|
||||
unsigned int reserved15 :1;
|
||||
} JDWPTransportCapabilities;
|
||||
|
||||
|
||||
/*
|
||||
* Structures to define packet layout.
|
||||
*
|
||||
* See: http://java.sun.com/j2se/1.5/docs/guide/jpda/jdwp-spec.html
|
||||
*/
|
||||
|
||||
enum {
|
||||
JDWPTRANSPORT_FLAGS_NONE = 0x0,
|
||||
JDWPTRANSPORT_FLAGS_REPLY = 0x80
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
jint len;
|
||||
jint id;
|
||||
jbyte flags;
|
||||
jbyte cmdSet;
|
||||
jbyte cmd;
|
||||
jbyte *data;
|
||||
} jdwpCmdPacket;
|
||||
|
||||
typedef struct {
|
||||
jint len;
|
||||
jint id;
|
||||
jbyte flags;
|
||||
jshort errorCode;
|
||||
jbyte *data;
|
||||
} jdwpReplyPacket;
|
||||
|
||||
typedef struct {
|
||||
union {
|
||||
jdwpCmdPacket cmd;
|
||||
jdwpReplyPacket reply;
|
||||
} type;
|
||||
} jdwpPacket;
|
||||
|
||||
/*
|
||||
* JDWP functions called by the transport.
|
||||
*/
|
||||
typedef struct jdwpTransportCallback {
|
||||
void *(*alloc)(jint numBytes); /* Call this for all allocations */
|
||||
void (*free)(void *buffer); /* Call this for all deallocations */
|
||||
} jdwpTransportCallback;
|
||||
|
||||
typedef jint (JNICALL *jdwpTransport_OnLoad_t)(JavaVM *jvm,
|
||||
jdwpTransportCallback *callback,
|
||||
jint version,
|
||||
jdwpTransportEnv** env);
|
||||
|
||||
|
||||
|
||||
/* Function Interface */
|
||||
|
||||
struct jdwpTransportNativeInterface_ {
|
||||
/* 1 : RESERVED */
|
||||
void *reserved1;
|
||||
|
||||
/* 2 : Get Capabilities */
|
||||
jdwpTransportError (JNICALL *GetCapabilities)(jdwpTransportEnv* env,
|
||||
JDWPTransportCapabilities *capabilities_ptr);
|
||||
|
||||
/* 3 : Attach */
|
||||
jdwpTransportError (JNICALL *Attach)(jdwpTransportEnv* env,
|
||||
const char* address,
|
||||
jlong attach_timeout,
|
||||
jlong handshake_timeout);
|
||||
|
||||
/* 4: StartListening */
|
||||
jdwpTransportError (JNICALL *StartListening)(jdwpTransportEnv* env,
|
||||
const char* address,
|
||||
char** actual_address);
|
||||
|
||||
/* 5: StopListening */
|
||||
jdwpTransportError (JNICALL *StopListening)(jdwpTransportEnv* env);
|
||||
|
||||
/* 6: Accept */
|
||||
jdwpTransportError (JNICALL *Accept)(jdwpTransportEnv* env,
|
||||
jlong accept_timeout,
|
||||
jlong handshake_timeout);
|
||||
|
||||
/* 7: IsOpen */
|
||||
jboolean (JNICALL *IsOpen)(jdwpTransportEnv* env);
|
||||
|
||||
/* 8: Close */
|
||||
jdwpTransportError (JNICALL *Close)(jdwpTransportEnv* env);
|
||||
|
||||
/* 9: ReadPacket */
|
||||
jdwpTransportError (JNICALL *ReadPacket)(jdwpTransportEnv* env,
|
||||
jdwpPacket *pkt);
|
||||
|
||||
/* 10: Write Packet */
|
||||
jdwpTransportError (JNICALL *WritePacket)(jdwpTransportEnv* env,
|
||||
const jdwpPacket* pkt);
|
||||
|
||||
/* 11: GetLastError */
|
||||
jdwpTransportError (JNICALL *GetLastError)(jdwpTransportEnv* env,
|
||||
char** error);
|
||||
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Use inlined functions so that C++ code can use syntax such as
|
||||
* env->Attach("mymachine:5000", 10*1000, 0);
|
||||
*
|
||||
* rather than using C's :-
|
||||
*
|
||||
* (*env)->Attach(env, "mymachine:5000", 10*1000, 0);
|
||||
*/
|
||||
struct _jdwpTransportEnv {
|
||||
const struct jdwpTransportNativeInterface_ *functions;
|
||||
#ifdef __cplusplus
|
||||
|
||||
jdwpTransportError GetCapabilities(JDWPTransportCapabilities *capabilities_ptr) {
|
||||
return functions->GetCapabilities(this, capabilities_ptr);
|
||||
}
|
||||
|
||||
jdwpTransportError Attach(const char* address, jlong attach_timeout,
|
||||
jlong handshake_timeout) {
|
||||
return functions->Attach(this, address, attach_timeout, handshake_timeout);
|
||||
}
|
||||
|
||||
jdwpTransportError StartListening(const char* address,
|
||||
char** actual_address) {
|
||||
return functions->StartListening(this, address, actual_address);
|
||||
}
|
||||
|
||||
jdwpTransportError StopListening(void) {
|
||||
return functions->StopListening(this);
|
||||
}
|
||||
|
||||
jdwpTransportError Accept(jlong accept_timeout, jlong handshake_timeout) {
|
||||
return functions->Accept(this, accept_timeout, handshake_timeout);
|
||||
}
|
||||
|
||||
jboolean IsOpen(void) {
|
||||
return functions->IsOpen(this);
|
||||
}
|
||||
|
||||
jdwpTransportError Close(void) {
|
||||
return functions->Close(this);
|
||||
}
|
||||
|
||||
jdwpTransportError ReadPacket(jdwpPacket *pkt) {
|
||||
return functions->ReadPacket(this, pkt);
|
||||
}
|
||||
|
||||
jdwpTransportError WritePacket(const jdwpPacket* pkt) {
|
||||
return functions->WritePacket(this, pkt);
|
||||
}
|
||||
|
||||
jdwpTransportError GetLastError(char** error) {
|
||||
return functions->GetLastError(this, error);
|
||||
}
|
||||
|
||||
|
||||
#endif /* __cplusplus */
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* JDWPTRANSPORT_H */
|
||||
|
1944
jni/jni/jni-headers/jni.h
Normal file
1944
jni/jni/jni-headers/jni.h
Normal file
File diff suppressed because it is too large
Load Diff
43
jni/jni/jni-headers/linux/jawt_md.h
Normal file
43
jni/jni/jni-headers/linux/jawt_md.h
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* @(#)jawt_md.h 1.13 10/03/23
|
||||
*
|
||||
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#ifndef _JAVASOFT_JAWT_MD_H_
|
||||
#define _JAVASOFT_JAWT_MD_H_
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Intrinsic.h>
|
||||
#include "jawt.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* X11-specific declarations for AWT native interface.
|
||||
* See notes in jawt.h for an example of use.
|
||||
*/
|
||||
typedef struct jawt_X11DrawingSurfaceInfo {
|
||||
Drawable drawable;
|
||||
Display* display;
|
||||
VisualID visualID;
|
||||
Colormap colormapID;
|
||||
int depth;
|
||||
/*
|
||||
* Since 1.4
|
||||
* Returns a pixel value from a set of RGB values.
|
||||
* This is useful for paletted color (256 color) modes.
|
||||
*/
|
||||
int (JNICALL *GetAWTColor)(JAWT_DrawingSurface* ds,
|
||||
int r, int g, int b);
|
||||
} JAWT_X11DrawingSurfaceInfo;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !_JAVASOFT_JAWT_MD_H_ */
|
24
jni/jni/jni-headers/linux/jni_md.h
Normal file
24
jni/jni/jni-headers/linux/jni_md.h
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* @(#)jni_md.h 1.20 10/03/23
|
||||
*
|
||||
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#ifndef _JAVASOFT_JNI_MD_H_
|
||||
#define _JAVASOFT_JNI_MD_H_
|
||||
|
||||
#define JNIEXPORT
|
||||
#define JNIIMPORT
|
||||
#define JNICALL
|
||||
|
||||
typedef int jint;
|
||||
#ifdef _LP64 /* 64-bit Solaris */
|
||||
typedef long jlong;
|
||||
#else
|
||||
typedef long long jlong;
|
||||
#endif
|
||||
|
||||
typedef signed char jbyte;
|
||||
|
||||
#endif /* !_JAVASOFT_JNI_MD_H_ */
|
23
jni/jni/jni-headers/mac/jni_md.h
Normal file
23
jni/jni/jni-headers/mac/jni_md.h
Normal file
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* @(#)jni_md.h 1.19 05/11/17
|
||||
*
|
||||
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
|
||||
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#ifndef _JAVASOFT_JNI_MD_H_
|
||||
#define _JAVASOFT_JNI_MD_H_
|
||||
|
||||
#define JNIEXPORT __attribute__((visibility("default")))
|
||||
#define JNIIMPORT
|
||||
#define JNICALL
|
||||
|
||||
#if __LP64__
|
||||
typedef int jint;
|
||||
#else
|
||||
typedef long jint;
|
||||
#endif
|
||||
typedef long long jlong;
|
||||
typedef signed char jbyte;
|
||||
|
||||
#endif /* !_JAVASOFT_JNI_MD_H_ */
|
41
jni/jni/jni-headers/win32/jawt_md.h
Normal file
41
jni/jni/jni-headers/win32/jawt_md.h
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* %W% %E%
|
||||
*
|
||||
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#ifndef _JAVASOFT_JAWT_MD_H_
|
||||
#define _JAVASOFT_JAWT_MD_H_
|
||||
|
||||
#include <windows.h>
|
||||
#include "jawt.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Win32-specific declarations for AWT native interface.
|
||||
* See notes in jawt.h for an example of use.
|
||||
*/
|
||||
typedef struct jawt_Win32DrawingSurfaceInfo {
|
||||
/* Native window, DDB, or DIB handle */
|
||||
union {
|
||||
HWND hwnd;
|
||||
HBITMAP hbitmap;
|
||||
void* pbits;
|
||||
};
|
||||
/*
|
||||
* This HDC should always be used instead of the HDC returned from
|
||||
* BeginPaint() or any calls to GetDC().
|
||||
*/
|
||||
HDC hdc;
|
||||
HPALETTE hpalette;
|
||||
} JAWT_Win32DrawingSurfaceInfo;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !_JAVASOFT_JAWT_MD_H_ */
|
19
jni/jni/jni-headers/win32/jni_md.h
Normal file
19
jni/jni/jni-headers/win32/jni_md.h
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* %W% %E%
|
||||
*
|
||||
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#ifndef _JAVASOFT_JNI_MD_H_
|
||||
#define _JAVASOFT_JNI_MD_H_
|
||||
|
||||
#define JNIEXPORT __declspec(dllexport)
|
||||
#define JNIIMPORT __declspec(dllimport)
|
||||
#define JNICALL __stdcall
|
||||
|
||||
typedef long jint;
|
||||
typedef __int64 jlong;
|
||||
typedef signed char jbyte;
|
||||
|
||||
#endif /* !_JAVASOFT_JNI_MD_H_ */
|
1
jni/jni/libtess2
Submodule
1
jni/jni/libtess2
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit a43504d78a5695ca07cf3706e34abfdfd5b4343b
|
237
jni/jni/org.oscim.utils.TessJNI.cpp
Normal file
237
jni/jni/org.oscim.utils.TessJNI.cpp
Normal file
@ -0,0 +1,237 @@
|
||||
#include <org.oscim.utils.TessJNI.h>
|
||||
|
||||
//@line:114
|
||||
|
||||
#include <tesselator.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
void* heapAlloc( void* userData, unsigned int size ){
|
||||
TESS_NOTUSED( userData );
|
||||
return malloc( size );
|
||||
}
|
||||
void* heapRealloc( void *userData, void* ptr, unsigned int size ){
|
||||
TESS_NOTUSED( userData );
|
||||
return realloc( ptr, size );
|
||||
}
|
||||
void heapFree( void* userData, void* ptr ){
|
||||
TESS_NOTUSED( userData );
|
||||
free( ptr );
|
||||
}
|
||||
JNIEXPORT jlong JNICALL Java_org_oscim_utils_TessJNI_newTess(JNIEnv* env, jclass clazz, jint size) {
|
||||
|
||||
|
||||
//@line:131
|
||||
{
|
||||
if (size <= 0)
|
||||
return (long)tessNewTess(0);
|
||||
if (size > 10)
|
||||
size = 10;
|
||||
TESSalloc ma;
|
||||
memset(&ma, 0, sizeof(ma));
|
||||
ma.memalloc = heapAlloc;
|
||||
ma.memfree = heapFree;
|
||||
ma.memrealloc = heapRealloc;
|
||||
//ma.userData = (void*)&allocated;
|
||||
ma.meshEdgeBucketSize = 2 << size; // 512
|
||||
ma.meshVertexBucketSize = 2 << size; // 512
|
||||
ma.meshFaceBucketSize = 1 << size; // 256
|
||||
ma.dictNodeBucketSize = 2 << size; // 512
|
||||
ma.regionBucketSize = 1 << size; // 256
|
||||
ma.extraVertices = 8;
|
||||
//ma.extraVertices = 256;
|
||||
return (long)tessNewTess(&ma);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_oscim_utils_TessJNI_freeTess(JNIEnv* env, jclass clazz, jlong inst) {
|
||||
|
||||
|
||||
//@line:151
|
||||
{
|
||||
tessDeleteTess((TESStesselator*) inst);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_oscim_utils_TessJNI_addContour(JNIEnv* env, jclass clazz, jlong inst, jint size, jfloatArray obj_contour, jint stride, jint offset, jint count) {
|
||||
float* contour = (float*)env->GetPrimitiveArrayCritical(obj_contour, 0);
|
||||
|
||||
|
||||
//@line:164
|
||||
{
|
||||
tessAddContour((TESStesselator*) inst, size, contour + (offset * stride), stride, count);
|
||||
}
|
||||
env->ReleasePrimitiveArrayCritical(obj_contour, contour, 0);
|
||||
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_oscim_utils_TessJNI_addMultiContour2D(JNIEnv* env, jclass clazz, jlong inst, jintArray obj_index, jfloatArray obj_contour, jint idxStart, jint idxCount) {
|
||||
int* index = (int*)env->GetPrimitiveArrayCritical(obj_index, 0);
|
||||
float* contour = (float*)env->GetPrimitiveArrayCritical(obj_contour, 0);
|
||||
|
||||
|
||||
//@line:167
|
||||
{
|
||||
TESStesselator* tess = (TESStesselator*) inst;
|
||||
int offset = 0;
|
||||
// start at 0 to get the correct offset in contour..
|
||||
for (int i = 0; i < idxStart + idxCount; i++){
|
||||
int len = index[i];
|
||||
if ((len % 2 != 0) || (len < 0))
|
||||
break;
|
||||
if (len < 6 || i < idxStart) {
|
||||
offset += len;
|
||||
continue;
|
||||
}
|
||||
tessAddContour(tess, 2, contour + offset, 8, len >> 1);
|
||||
offset += len;
|
||||
}
|
||||
}
|
||||
env->ReleasePrimitiveArrayCritical(obj_index, index, 0);
|
||||
env->ReleasePrimitiveArrayCritical(obj_contour, contour, 0);
|
||||
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_oscim_utils_TessJNI_tessContour2D(JNIEnv* env, jclass clazz, jlong inst, jint windingRule, jint elementType, jint polySize, jint vertexSize) {
|
||||
|
||||
|
||||
//@line:194
|
||||
{
|
||||
return tessTesselate((TESStesselator*) inst, windingRule, elementType, polySize, vertexSize, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_oscim_utils_TessJNI_getVertexCount(JNIEnv* env, jclass clazz, jlong inst) {
|
||||
|
||||
|
||||
//@line:197
|
||||
{
|
||||
return tessGetVertexCount((TESStesselator*) inst);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static inline jboolean wrapped_Java_org_oscim_utils_TessJNI_getVertices
|
||||
(JNIEnv* env, jclass clazz, jlong inst, jfloatArray obj_out, jint offset, jint length, float* out) {
|
||||
|
||||
//@line:203
|
||||
{
|
||||
const TESSreal* vertices = tessGetVertices((TESStesselator*) inst);
|
||||
if (!vertices)
|
||||
return 0;
|
||||
memcpy(out, vertices + offset, length * sizeof(TESSreal));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_oscim_utils_TessJNI_getVertices(JNIEnv* env, jclass clazz, jlong inst, jfloatArray obj_out, jint offset, jint length) {
|
||||
float* out = (float*)env->GetPrimitiveArrayCritical(obj_out, 0);
|
||||
|
||||
jboolean JNI_returnValue = wrapped_Java_org_oscim_utils_TessJNI_getVertices(env, clazz, inst, obj_out, offset, length, out);
|
||||
|
||||
env->ReleasePrimitiveArrayCritical(obj_out, out, 0);
|
||||
|
||||
return JNI_returnValue;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_oscim_utils_TessJNI_getVerticesS(JNIEnv* env, jclass clazz, jlong inst, jshortArray obj_out, jint offset, jint length, jfloat scale) {
|
||||
short* out = (short*)env->GetPrimitiveArrayCritical(obj_out, 0);
|
||||
|
||||
|
||||
//@line:213
|
||||
{
|
||||
const TESSreal* vertices = tessGetVertices((TESStesselator*) inst);
|
||||
for(int i = 0; i < length; i++)
|
||||
out[i] = (short)(vertices[offset++] * scale + 0.5f);
|
||||
}
|
||||
env->ReleasePrimitiveArrayCritical(obj_out, out, 0);
|
||||
|
||||
}
|
||||
|
||||
static inline jboolean wrapped_Java_org_oscim_utils_TessJNI_getVertexIndices
|
||||
(JNIEnv* env, jclass clazz, jlong inst, jintArray obj_out, jint offset, jint length, int* out) {
|
||||
|
||||
//@line:225
|
||||
{
|
||||
const TESSindex* indices = tessGetVertexIndices((TESStesselator*) inst);
|
||||
if (!indices)
|
||||
return 0;
|
||||
memcpy(out, indices + offset, length * sizeof(TESSindex));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_oscim_utils_TessJNI_getVertexIndices(JNIEnv* env, jclass clazz, jlong inst, jintArray obj_out, jint offset, jint length) {
|
||||
int* out = (int*)env->GetPrimitiveArrayCritical(obj_out, 0);
|
||||
|
||||
jboolean JNI_returnValue = wrapped_Java_org_oscim_utils_TessJNI_getVertexIndices(env, clazz, inst, obj_out, offset, length, out);
|
||||
|
||||
env->ReleasePrimitiveArrayCritical(obj_out, out, 0);
|
||||
|
||||
return JNI_returnValue;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_oscim_utils_TessJNI_getElementCount(JNIEnv* env, jclass clazz, jlong inst) {
|
||||
|
||||
|
||||
//@line:235
|
||||
{
|
||||
return tessGetElementCount((TESStesselator*) inst);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static inline jboolean wrapped_Java_org_oscim_utils_TessJNI_getElements
|
||||
(JNIEnv* env, jclass clazz, jlong inst, jintArray obj_out, jint offset, jint length, int* out) {
|
||||
|
||||
//@line:241
|
||||
{
|
||||
const TESSindex* elements = tessGetElements((TESStesselator*) inst);
|
||||
if (!elements)
|
||||
return 0;
|
||||
memcpy(out, elements + offset, length * sizeof(TESSindex));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_oscim_utils_TessJNI_getElements(JNIEnv* env, jclass clazz, jlong inst, jintArray obj_out, jint offset, jint length) {
|
||||
int* out = (int*)env->GetPrimitiveArrayCritical(obj_out, 0);
|
||||
|
||||
jboolean JNI_returnValue = wrapped_Java_org_oscim_utils_TessJNI_getElements(env, clazz, inst, obj_out, offset, length, out);
|
||||
|
||||
env->ReleasePrimitiveArrayCritical(obj_out, out, 0);
|
||||
|
||||
return JNI_returnValue;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_oscim_utils_TessJNI_getElementsS(JNIEnv* env, jclass clazz, jlong inst, jshortArray obj_out, jint offset, jint length) {
|
||||
short* out = (short*)env->GetPrimitiveArrayCritical(obj_out, 0);
|
||||
|
||||
|
||||
//@line:251
|
||||
{
|
||||
const TESSindex* elements = tessGetElements((TESStesselator*) inst);
|
||||
for(int i = 0; i < length; i++)
|
||||
out[i] = (short)elements[offset++];
|
||||
}
|
||||
env->ReleasePrimitiveArrayCritical(obj_out, out, 0);
|
||||
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_oscim_utils_TessJNI_getElementsWithInputVertexIds(JNIEnv* env, jclass clazz, jlong inst, jshortArray obj_out, jint dstOffset, jint offset, jint length) {
|
||||
short* out = (short*)env->GetPrimitiveArrayCritical(obj_out, 0);
|
||||
|
||||
|
||||
//@line:259
|
||||
{
|
||||
const TESSindex* elements = tessGetElements((TESStesselator*) inst);
|
||||
const TESSindex* indices = tessGetVertexIndices((TESStesselator*) inst);
|
||||
for(int i = 0; i < length; i++)
|
||||
out[dstOffset++] = (short)(indices[elements[offset++]]);
|
||||
}
|
||||
env->ReleasePrimitiveArrayCritical(obj_out, out, 0);
|
||||
|
||||
}
|
||||
|
224
jni/jni/org.oscim.utils.tess.Tesselator.cpp
Normal file
224
jni/jni/org.oscim.utils.tess.Tesselator.cpp
Normal file
@ -0,0 +1,224 @@
|
||||
#include <org.oscim.utils.tess.Tesselator.h>
|
||||
|
||||
//@line:103
|
||||
|
||||
#include <tesselator.h>
|
||||
#include <string.h>
|
||||
JNIEXPORT jlong JNICALL Java_org_oscim_utils_tess_Tesselator_newTess(JNIEnv* env, jclass clazz) {
|
||||
|
||||
|
||||
//@line:107
|
||||
{
|
||||
return (long)tessNewTess(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_oscim_utils_tess_Tesselator_freeTess(JNIEnv* env, jclass clazz, jlong inst) {
|
||||
|
||||
|
||||
//@line:111
|
||||
{
|
||||
tessDeleteTess((TESStesselator*) inst);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_oscim_utils_tess_Tesselator_addContour(JNIEnv* env, jclass clazz, jlong inst, jint size, jfloatArray obj_contour, jint stride, jint offset, jint count) {
|
||||
float* contour = (float*)env->GetPrimitiveArrayCritical(obj_contour, 0);
|
||||
|
||||
|
||||
//@line:125
|
||||
{
|
||||
tessAddContour((TESStesselator*) inst, size, contour + (offset * stride), stride, count);
|
||||
}
|
||||
env->ReleasePrimitiveArrayCritical(obj_contour, contour, 0);
|
||||
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_oscim_utils_tess_Tesselator_addMultiContour2D(JNIEnv* env, jclass clazz, jlong inst, jintArray obj_index, jfloatArray obj_contour, jint idxStart, jint idxCount) {
|
||||
int* index = (int*)env->GetPrimitiveArrayCritical(obj_index, 0);
|
||||
float* contour = (float*)env->GetPrimitiveArrayCritical(obj_contour, 0);
|
||||
|
||||
|
||||
//@line:129
|
||||
{
|
||||
TESStesselator* tess = (TESStesselator*) inst;
|
||||
int offset = 0;
|
||||
|
||||
for (int i = 0; i < idxStart + idxCount; i++){
|
||||
int len = index[i];
|
||||
|
||||
if ((len % 2 != 0) || (len < 0))
|
||||
break;
|
||||
|
||||
if (len < 6 || i < idxStart) {
|
||||
offset += len;
|
||||
continue;
|
||||
}
|
||||
|
||||
tessAddContour(tess, 2, contour + offset, 8, len >> 1);
|
||||
|
||||
offset += len;
|
||||
}
|
||||
}
|
||||
env->ReleasePrimitiveArrayCritical(obj_index, index, 0);
|
||||
env->ReleasePrimitiveArrayCritical(obj_contour, contour, 0);
|
||||
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_oscim_utils_tess_Tesselator_tessContour2D(JNIEnv* env, jclass clazz, jlong inst, jint windingRule, jint elementType, jint polySize, jint vertexSize) {
|
||||
|
||||
|
||||
//@line:161
|
||||
{
|
||||
return tessTesselate((TESStesselator*) inst, windingRule, elementType, polySize, vertexSize, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_oscim_utils_tess_Tesselator_getVertexCount(JNIEnv* env, jclass clazz, jlong inst) {
|
||||
|
||||
|
||||
//@line:165
|
||||
{
|
||||
return tessGetVertexCount((TESStesselator*) inst);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static inline jboolean wrapped_Java_org_oscim_utils_tess_Tesselator_getVertices
|
||||
(JNIEnv* env, jclass clazz, jlong inst, jfloatArray obj_out, jint offset, jint length, float* out) {
|
||||
|
||||
//@line:172
|
||||
{
|
||||
const TESSIOreal* vertices = tessGetVertices((TESStesselator*) inst);
|
||||
|
||||
//const TESSreal* vertices = tessGetVertices((TESStesselator*) inst);
|
||||
|
||||
if (!vertices)
|
||||
return 0;
|
||||
|
||||
memcpy(out, vertices + offset, length * sizeof(TESSIOreal));
|
||||
|
||||
//memcpy(out, vertices + offset, length * sizeof(TESSreal));
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_oscim_utils_tess_Tesselator_getVertices(JNIEnv* env, jclass clazz, jlong inst, jfloatArray obj_out, jint offset, jint length) {
|
||||
float* out = (float*)env->GetPrimitiveArrayCritical(obj_out, 0);
|
||||
|
||||
jboolean JNI_returnValue = wrapped_Java_org_oscim_utils_tess_Tesselator_getVertices(env, clazz, inst, obj_out, offset, length, out);
|
||||
|
||||
env->ReleasePrimitiveArrayCritical(obj_out, out, 0);
|
||||
|
||||
return JNI_returnValue;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_oscim_utils_tess_Tesselator_getVerticesS(JNIEnv* env, jclass clazz, jlong inst, jshortArray obj_out, jint offset, jint length, jfloat scale) {
|
||||
short* out = (short*)env->GetPrimitiveArrayCritical(obj_out, 0);
|
||||
|
||||
|
||||
//@line:190
|
||||
{
|
||||
const TESSIOreal* vertices = tessGetVertices((TESStesselator*) inst);
|
||||
|
||||
//const TESSreal* vertices = tessGetVertices((TESStesselator*) inst);
|
||||
|
||||
for(int i = 0; i < length; i++)
|
||||
out[i] = (short)(vertices[offset++] * scale + 0.5f);
|
||||
}
|
||||
env->ReleasePrimitiveArrayCritical(obj_out, out, 0);
|
||||
|
||||
}
|
||||
|
||||
static inline jboolean wrapped_Java_org_oscim_utils_tess_Tesselator_getVertexIndices
|
||||
(JNIEnv* env, jclass clazz, jlong inst, jintArray obj_out, jint offset, jint length, int* out) {
|
||||
|
||||
//@line:206
|
||||
{
|
||||
const TESSindex* indices = tessGetVertexIndices((TESStesselator*) inst);
|
||||
if (!indices)
|
||||
return 0;
|
||||
|
||||
memcpy(out, indices + offset, length * sizeof(TESSindex));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_oscim_utils_tess_Tesselator_getVertexIndices(JNIEnv* env, jclass clazz, jlong inst, jintArray obj_out, jint offset, jint length) {
|
||||
int* out = (int*)env->GetPrimitiveArrayCritical(obj_out, 0);
|
||||
|
||||
jboolean JNI_returnValue = wrapped_Java_org_oscim_utils_tess_Tesselator_getVertexIndices(env, clazz, inst, obj_out, offset, length, out);
|
||||
|
||||
env->ReleasePrimitiveArrayCritical(obj_out, out, 0);
|
||||
|
||||
return JNI_returnValue;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_oscim_utils_tess_Tesselator_getElementCount(JNIEnv* env, jclass clazz, jlong inst) {
|
||||
|
||||
|
||||
//@line:218
|
||||
{
|
||||
return tessGetElementCount((TESStesselator*) inst);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static inline jboolean wrapped_Java_org_oscim_utils_tess_Tesselator_getElements
|
||||
(JNIEnv* env, jclass clazz, jlong inst, jintArray obj_out, jint offset, jint length, int* out) {
|
||||
|
||||
//@line:225
|
||||
{
|
||||
const TESSindex* elements = tessGetElements((TESStesselator*) inst);
|
||||
if (!elements)
|
||||
return 0;
|
||||
|
||||
memcpy(out, elements + offset, length * sizeof(TESSindex));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_oscim_utils_tess_Tesselator_getElements(JNIEnv* env, jclass clazz, jlong inst, jintArray obj_out, jint offset, jint length) {
|
||||
int* out = (int*)env->GetPrimitiveArrayCritical(obj_out, 0);
|
||||
|
||||
jboolean JNI_returnValue = wrapped_Java_org_oscim_utils_tess_Tesselator_getElements(env, clazz, inst, obj_out, offset, length, out);
|
||||
|
||||
env->ReleasePrimitiveArrayCritical(obj_out, out, 0);
|
||||
|
||||
return JNI_returnValue;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_oscim_utils_tess_Tesselator_getElementsS(JNIEnv* env, jclass clazz, jlong inst, jshortArray obj_out, jint offset, jint length) {
|
||||
short* out = (short*)env->GetPrimitiveArrayCritical(obj_out, 0);
|
||||
|
||||
|
||||
//@line:238
|
||||
{
|
||||
const TESSindex* elements = tessGetElements((TESStesselator*) inst);
|
||||
for(int i = 0; i < length; i++)
|
||||
out[i] = (short)elements[offset++];
|
||||
}
|
||||
env->ReleasePrimitiveArrayCritical(obj_out, out, 0);
|
||||
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_oscim_utils_tess_Tesselator_getElementsWithInputVertexIds(JNIEnv* env, jclass clazz, jlong inst, jshortArray obj_out, jint dstOffset, jint offset, jint length) {
|
||||
short* out = (short*)env->GetPrimitiveArrayCritical(obj_out, 0);
|
||||
|
||||
|
||||
//@line:247
|
||||
{
|
||||
const TESSindex* elements = tessGetElements((TESStesselator*) inst);
|
||||
const TESSindex* indices = tessGetVertexIndices((TESStesselator*) inst);
|
||||
|
||||
for(int i = 0; i < length; i++)
|
||||
out[dstOffset++] = (short)indices[elements[offset++]];
|
||||
}
|
||||
env->ReleasePrimitiveArrayCritical(obj_out, out, 0);
|
||||
|
||||
}
|
||||
|
155
jni/jni/org.oscim.utils.tess.Tesselator.h
Normal file
155
jni/jni/org.oscim.utils.tess.Tesselator.h
Normal file
@ -0,0 +1,155 @@
|
||||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class org_oscim_utils_tess_Tesselator */
|
||||
|
||||
#ifndef _Included_org_oscim_utils_tess_Tesselator
|
||||
#define _Included_org_oscim_utils_tess_Tesselator
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* Class: org_oscim_utils_tess_Tesselator
|
||||
* Method: newTess
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_org_oscim_utils_tess_Tesselator_newTess
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: org_oscim_utils_tess_Tesselator
|
||||
* Method: freeTess
|
||||
* Signature: (J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_oscim_utils_tess_Tesselator_freeTess
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: org_oscim_utils_tess_Tesselator
|
||||
* Method: addContour
|
||||
* Signature: (JI[FIII)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_oscim_utils_tess_Tesselator_addContour
|
||||
(JNIEnv *, jclass, jlong, jint, jfloatArray, jint, jint, jint);
|
||||
|
||||
/*
|
||||
* Class: org_oscim_utils_tess_Tesselator
|
||||
* Method: addMultiContour2D
|
||||
* Signature: (J[I[FII)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_oscim_utils_tess_Tesselator_addMultiContour2D
|
||||
(JNIEnv *, jclass, jlong, jintArray, jfloatArray, jint, jint);
|
||||
|
||||
/*
|
||||
* Class: org_oscim_utils_tess_Tesselator
|
||||
* Method: tessContour2D
|
||||
* Signature: (JIIII)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_oscim_utils_tess_Tesselator_tessContour2D
|
||||
(JNIEnv *, jclass, jlong, jint, jint, jint, jint);
|
||||
|
||||
/*
|
||||
* Class: org_oscim_utils_tess_Tesselator
|
||||
* Method: getVertexCount
|
||||
* Signature: (J)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_oscim_utils_tess_Tesselator_getVertexCount
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: org_oscim_utils_tess_Tesselator
|
||||
* Method: getVertices
|
||||
* Signature: (J[FII)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_oscim_utils_tess_Tesselator_getVertices
|
||||
(JNIEnv *, jclass, jlong, jfloatArray, jint, jint);
|
||||
|
||||
/*
|
||||
* Class: org_oscim_utils_tess_Tesselator
|
||||
* Method: getVerticesS
|
||||
* Signature: (J[SIIF)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_oscim_utils_tess_Tesselator_getVerticesS
|
||||
(JNIEnv *, jclass, jlong, jshortArray, jint, jint, jfloat);
|
||||
|
||||
/*
|
||||
* Class: org_oscim_utils_tess_Tesselator
|
||||
* Method: getVertexIndices
|
||||
* Signature: (J[III)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_oscim_utils_tess_Tesselator_getVertexIndices
|
||||
(JNIEnv *, jclass, jlong, jintArray, jint, jint);
|
||||
|
||||
/*
|
||||
* Class: org_oscim_utils_tess_Tesselator
|
||||
* Method: getElementCount
|
||||
* Signature: (J)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_oscim_utils_tess_Tesselator_getElementCount
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: org_oscim_utils_tess_Tesselator
|
||||
* Method: getElements
|
||||
* Signature: (J[III)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_org_oscim_utils_tess_Tesselator_getElements
|
||||
(JNIEnv *, jclass, jlong, jintArray, jint, jint);
|
||||
|
||||
/*
|
||||
* Class: org_oscim_utils_tess_Tesselator
|
||||
* Method: getElementsS
|
||||
* Signature: (J[SII)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_oscim_utils_tess_Tesselator_getElementsS
|
||||
(JNIEnv *, jclass, jlong, jshortArray, jint, jint);
|
||||
|
||||
/*
|
||||
* Class: org_oscim_utils_tess_Tesselator
|
||||
* Method: getElementsWithInputVertexIds
|
||||
* Signature: (J[SIII)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_oscim_utils_tess_Tesselator_getElementsWithInputVertexIds
|
||||
(JNIEnv *, jclass, jlong, jshortArray, jint, jint, jint);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
/* Header for class org_oscim_utils_tess_Tesselator_ElementType */
|
||||
|
||||
#ifndef _Included_org_oscim_utils_tess_Tesselator_ElementType
|
||||
#define _Included_org_oscim_utils_tess_Tesselator_ElementType
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#undef org_oscim_utils_tess_Tesselator_ElementType_POLYGONS
|
||||
#define org_oscim_utils_tess_Tesselator_ElementType_POLYGONS 0L
|
||||
#undef org_oscim_utils_tess_Tesselator_ElementType_CONNECTED_POLYGONS
|
||||
#define org_oscim_utils_tess_Tesselator_ElementType_CONNECTED_POLYGONS 1L
|
||||
#undef org_oscim_utils_tess_Tesselator_ElementType_BOUNDARY_CONTOURS
|
||||
#define org_oscim_utils_tess_Tesselator_ElementType_BOUNDARY_CONTOURS 2L
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
/* Header for class org_oscim_utils_tess_Tesselator_WindingRule */
|
||||
|
||||
#ifndef _Included_org_oscim_utils_tess_Tesselator_WindingRule
|
||||
#define _Included_org_oscim_utils_tess_Tesselator_WindingRule
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#undef org_oscim_utils_tess_Tesselator_WindingRule_ODD
|
||||
#define org_oscim_utils_tess_Tesselator_WindingRule_ODD 0L
|
||||
#undef org_oscim_utils_tess_Tesselator_WindingRule_NONZERO
|
||||
#define org_oscim_utils_tess_Tesselator_WindingRule_NONZERO 1L
|
||||
#undef org_oscim_utils_tess_Tesselator_WindingRule_POSITIVE
|
||||
#define org_oscim_utils_tess_Tesselator_WindingRule_POSITIVE 2L
|
||||
#undef org_oscim_utils_tess_Tesselator_WindingRule_NEGATIVE
|
||||
#define org_oscim_utils_tess_Tesselator_WindingRule_NEGATIVE 3L
|
||||
#undef org_oscim_utils_tess_Tesselator_WindingRule_ABS_GEQ_TWO
|
||||
#define org_oscim_utils_tess_Tesselator_WindingRule_ABS_GEQ_TWO 4L
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -2,30 +2,24 @@ import com.badlogic.gdx.jnigen.AntScriptGenerator;
|
||||
import com.badlogic.gdx.jnigen.BuildConfig;
|
||||
import com.badlogic.gdx.jnigen.BuildTarget;
|
||||
import com.badlogic.gdx.jnigen.BuildTarget.TargetOs;
|
||||
import com.badlogic.gdx.jnigen.NativeCodeGenerator;
|
||||
|
||||
public class JniBuilder {
|
||||
public static void main(String[] args) {
|
||||
String[] headers = { "." };
|
||||
public static void main(String[] args) throws Exception {
|
||||
String[] headers = { ".", "libtess2/Include" };
|
||||
String[] sources = {
|
||||
// Matrix stuff
|
||||
"gl/utils.c",
|
||||
|
||||
// libtessellate
|
||||
"tessellate/dict.c",
|
||||
"tessellate/mesh.c",
|
||||
"tessellate/render.c",
|
||||
"tessellate/tess.c",
|
||||
"tessellate/geom.c",
|
||||
"tessellate/memalloc.c",
|
||||
"tessellate/normal.c",
|
||||
"tessellate/priorityq.c",
|
||||
"tessellate/sweep.c",
|
||||
"tessellate/tessmono.c",
|
||||
"tessellate/tessellate.c",
|
||||
"tessellate/TessellateJni.c"
|
||||
"libtess2/Source/bucketalloc.c",
|
||||
"libtess2/Source/dict.c",
|
||||
"libtess2/Source/geom.c",
|
||||
"libtess2/Source/mesh.c",
|
||||
"libtess2/Source/priorityq.c",
|
||||
"libtess2/Source/sweep.c",
|
||||
"libtess2/Source/tess.c",
|
||||
};
|
||||
|
||||
String cflags = " -Wall -std=c99 -O2 -ffast-math";
|
||||
cflags += " -DNDEBUG"; /* disable debug in libtess2 */
|
||||
|
||||
//BuildTarget win32home = BuildTarget
|
||||
// .newDefaultTarget(TargetOs.Windows, false);
|
||||
@ -87,20 +81,22 @@ public class JniBuilder {
|
||||
ios.cFlags += cflags;
|
||||
ios.cppFlags += cflags;
|
||||
|
||||
//new NativeCodeGenerator().generate();
|
||||
new AntScriptGenerator().generate(new BuildConfig("vtm-jni"),
|
||||
// mac,
|
||||
// win32home,
|
||||
// win32,
|
||||
// win64,
|
||||
// lin32,
|
||||
lin64,
|
||||
android
|
||||
//ios
|
||||
new NativeCodeGenerator().generate();
|
||||
|
||||
new AntScriptGenerator()
|
||||
.generate(new BuildConfig("vtm-jni"),
|
||||
android,
|
||||
lin64,
|
||||
lin32,
|
||||
mac,
|
||||
ios,
|
||||
//win32home,
|
||||
win32,
|
||||
win64
|
||||
);
|
||||
|
||||
// BuildExecutor.executeAnt("jni/build-windows32home.xml", "-v clean");
|
||||
// BuildExecutor.executeAnt("jni/build-windows32home.xml", "-v");
|
||||
// BuildExecutor.executeAnt("jni/build-linux64.xml", "-v");
|
||||
// BuildExecutor.executeAnt("jni/build.xml", "pack-natives -v");
|
||||
}
|
||||
}
|
||||
|
339
jni/src/org/oscim/utils/tess/Tesselator.java
Normal file
339
jni/src/org/oscim/utils/tess/Tesselator.java
Normal file
@ -0,0 +1,339 @@
|
||||
package org.oscim.utils.tess;
|
||||
|
||||
import static java.lang.System.out;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Tesselator {
|
||||
|
||||
private long inst;
|
||||
|
||||
public Tesselator() {
|
||||
inst = newTess();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() {
|
||||
dispose();
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
if (inst != 0) {
|
||||
freeTess(inst);
|
||||
inst = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* See OpenGL Red Book for description of the winding rules
|
||||
* http://www.glprogramming.com/red/chapter11.html
|
||||
*/
|
||||
public static final class WindingRule {
|
||||
public static final int ODD = 0;
|
||||
public static final int NONZERO = 1;
|
||||
public static final int POSITIVE = 2;
|
||||
public static final int NEGATIVE = 3;
|
||||
public static final int ABS_GEQ_TWO = 4;
|
||||
}
|
||||
|
||||
public static final class ElementType {
|
||||
public static final int POLYGONS = 0;
|
||||
public static final int CONNECTED_POLYGONS = 1;
|
||||
public static final int BOUNDARY_CONTOURS = 2;
|
||||
}
|
||||
|
||||
public void addContour2D(float[] points) {
|
||||
addContour2D(points, 0, points.length >> 1);
|
||||
}
|
||||
|
||||
public void addContour2D(float[] points, int offset, int length) {
|
||||
if (length < 6)
|
||||
return;
|
||||
if ((length % 2 != 0) || (offset % 2 != 0) || (points.length >> 1) < (offset + length))
|
||||
throw new IllegalArgumentException("Invalid input: length:" + length
|
||||
+ ", offset:" + offset
|
||||
+ ", points.length:" + points.length);
|
||||
|
||||
addContour(inst, 2, points, 8, offset, length);
|
||||
}
|
||||
|
||||
public void addContour2D(int[] index, float[] contour) {
|
||||
addMultiContour2D(inst, index, contour, 0, index.length);
|
||||
}
|
||||
|
||||
public boolean tesselate(int windingRule, int elementType) {
|
||||
return tessContour2D(inst, windingRule, elementType, 3, 2) == 1;
|
||||
}
|
||||
|
||||
public int getVertexCount() {
|
||||
return getVertexCount(inst);
|
||||
}
|
||||
|
||||
public int getElementCount() {
|
||||
return getElementCount(inst);
|
||||
}
|
||||
|
||||
public void getVertices(float[] out, int offset, int length) {
|
||||
getVertices(inst, out, offset, length);
|
||||
}
|
||||
|
||||
public void getVertices(short[] out, int offset, int length, float scale) {
|
||||
getVerticesS(inst, out, offset, length, scale);
|
||||
}
|
||||
|
||||
public void getElements(int[] out, int offset, int length) {
|
||||
getElements(inst, out, offset, length);
|
||||
}
|
||||
|
||||
public void getElements(short[] out, int offset, int length) {
|
||||
getElementsS(inst, out, offset, length);
|
||||
}
|
||||
|
||||
public void getVertexIndices(int[] out, int offset, int length) {
|
||||
getVertexIndices(inst, out, offset, length);
|
||||
}
|
||||
|
||||
public void getElementsWithInputVertexIds(short[] out, int dstOffset, int offset, int length) {
|
||||
getElementsWithInputVertexIds(inst, out, dstOffset, offset, length);
|
||||
}
|
||||
|
||||
// @formatter:off
|
||||
|
||||
/*JNI
|
||||
#include <tesselator.h>
|
||||
#include <string.h>
|
||||
*/
|
||||
private static native long newTess(); /* {
|
||||
return (long)tessNewTess(0);
|
||||
} */
|
||||
|
||||
private static native void freeTess(long inst); /* {
|
||||
tessDeleteTess((TESStesselator*) inst);
|
||||
} */
|
||||
|
||||
/**
|
||||
* Adds a contour to be tesselated.
|
||||
* The type of the vertex coordinates is assumed to be TESSreal.
|
||||
*
|
||||
* @param tess - pointer to tesselator object.
|
||||
* @param size - number of coordinates per vertex. Must be 2 or 3.
|
||||
* @param pointer - pointer to the first coordinate of the first vertex in the array.
|
||||
* @param stride - defines offset in bytes between consecutive vertices.
|
||||
* @param count - number of vertices in contour.
|
||||
*/
|
||||
private static native void addContour(long inst, int size, float[] contour, int stride, int offset, int count);/* {
|
||||
tessAddContour((TESStesselator*) inst, size, contour + (offset * stride), stride, count);
|
||||
} */
|
||||
|
||||
private static native void addMultiContour2D(long inst, int[] index, float[] contour, int idxStart, int idxCount);/* {
|
||||
TESStesselator* tess = (TESStesselator*) inst;
|
||||
int offset = 0;
|
||||
|
||||
for (int i = 0; i < idxStart + idxCount; i++){
|
||||
int len = index[i];
|
||||
|
||||
if ((len % 2 != 0) || (len < 0))
|
||||
break;
|
||||
|
||||
if (len < 6 || i < idxStart) {
|
||||
offset += len;
|
||||
continue;
|
||||
}
|
||||
|
||||
tessAddContour(tess, 2, contour + offset, 8, len >> 1);
|
||||
|
||||
offset += len;
|
||||
}
|
||||
} */
|
||||
|
||||
/**
|
||||
* Tesselate contours.
|
||||
*
|
||||
* @param tess - pointer to tesselator object.
|
||||
* @param windingRule - winding rules used for tesselation, must be one of TessWindingRule.
|
||||
* @param elementType - defines the tesselation result element type, must be one of TessElementType.
|
||||
* @param polySize - defines maximum vertices per polygons if output is polygons.
|
||||
* @param vertexSize - defines the number of coordinates in tesselation result vertex, must be 2 or 3.
|
||||
* @param normal - defines the normal of the input contours, of null the normal is calculated automatically.
|
||||
* @return 1 if succeed, 0 if failed.
|
||||
*/
|
||||
private static native int tessContour2D(long inst, int windingRule, int elementType, int polySize, int vertexSize);/*{
|
||||
return tessTesselate((TESStesselator*) inst, windingRule, elementType, polySize, vertexSize, 0);
|
||||
} */
|
||||
|
||||
private static native int getVertexCount(long inst); /*{
|
||||
return tessGetVertexCount((TESStesselator*) inst);
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Returns pointer to first coordinate of first vertex.
|
||||
*/
|
||||
private static native boolean getVertices(long inst, float[] out, int offset, int length);/*{
|
||||
const TESSIOreal* vertices = tessGetVertices((TESStesselator*) inst);
|
||||
|
||||
//const TESSreal* vertices = tessGetVertices((TESStesselator*) inst);
|
||||
|
||||
if (!vertices)
|
||||
return 0;
|
||||
|
||||
memcpy(out, vertices + offset, length * sizeof(TESSIOreal));
|
||||
|
||||
//memcpy(out, vertices + offset, length * sizeof(TESSreal));
|
||||
|
||||
return 1;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Returns pointer to first coordinate of first vertex.
|
||||
*/
|
||||
private static native void getVerticesS(long inst, short[] out, int offset, int length, float scale);/*{
|
||||
const TESSIOreal* vertices = tessGetVertices((TESStesselator*) inst);
|
||||
|
||||
//const TESSreal* vertices = tessGetVertices((TESStesselator*) inst);
|
||||
|
||||
for(int i = 0; i < length; i++)
|
||||
out[i] = (short)(vertices[offset++] * scale + 0.5f);
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Returns pointer to first vertex index.
|
||||
*
|
||||
* Vertex indices can be used to map the generated vertices to the original vertices.
|
||||
* Every point added using tessAddContour() will get a new index starting at 0.
|
||||
* New vertices generated at the intersections of segments are assigned value TESS_UNDEF.
|
||||
*/
|
||||
private static native boolean getVertexIndices(long inst, int[] out, int offset, int length);/* {
|
||||
const TESSindex* indices = tessGetVertexIndices((TESStesselator*) inst);
|
||||
if (!indices)
|
||||
return 0;
|
||||
|
||||
memcpy(out, indices + offset, length * sizeof(TESSindex));
|
||||
return 1;
|
||||
} */
|
||||
|
||||
/**
|
||||
* Returns number of elements in the the tesselated output.
|
||||
*/
|
||||
private static native int getElementCount(long inst);/*{
|
||||
return tessGetElementCount((TESStesselator*) inst);
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Returns pointer to the first element.
|
||||
*/
|
||||
private static native boolean getElements(long inst, int[] out, int offset, int length);/*{
|
||||
const TESSindex* elements = tessGetElements((TESStesselator*) inst);
|
||||
if (!elements)
|
||||
return 0;
|
||||
|
||||
memcpy(out, elements + offset, length * sizeof(TESSindex));
|
||||
return 1;
|
||||
}*/
|
||||
|
||||
|
||||
/**
|
||||
* Returns pointer to the first element.
|
||||
*/
|
||||
private static native void getElementsS(long inst, short[] out, int offset, int length);/*{
|
||||
const TESSindex* elements = tessGetElements((TESStesselator*) inst);
|
||||
for(int i = 0; i < length; i++)
|
||||
out[i] = (short)elements[offset++];
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Returns list of triangles indices (or to the first element of convex polygons).
|
||||
*/
|
||||
private static native void getElementsWithInputVertexIds(long inst, short[] out, int dstOffset, int offset, int length);/*{
|
||||
const TESSindex* elements = tessGetElements((TESStesselator*) inst);
|
||||
const TESSindex* indices = tessGetVertexIndices((TESStesselator*) inst);
|
||||
|
||||
for(int i = 0; i < length; i++)
|
||||
out[dstOffset++] = (short)indices[elements[offset++]];
|
||||
}*/
|
||||
|
||||
//@formatter:on
|
||||
public static void main(String[] args) throws Exception {
|
||||
System.load(new File("libs/linux64/libvtm-jni64.so").getAbsolutePath());
|
||||
Tesselator tess = new Tesselator();
|
||||
|
||||
float[] c1 = new float[] {
|
||||
0, 0,
|
||||
4, 0,
|
||||
4, 4,
|
||||
0, 4,
|
||||
};
|
||||
|
||||
float[] c2 = new float[] {
|
||||
1, 1,
|
||||
1, 2,
|
||||
2, 2,
|
||||
2, 1
|
||||
};
|
||||
|
||||
float[] c3 = new float[] {
|
||||
0, 0,
|
||||
4, 0,
|
||||
4, 4,
|
||||
0, 4,
|
||||
|
||||
1, 1,
|
||||
1, 2,
|
||||
2, 2,
|
||||
2, 1
|
||||
};
|
||||
|
||||
int polySize = 3;
|
||||
|
||||
addContour(tess.inst, 2, c1, 8, 0, c1.length / 2);
|
||||
|
||||
//addContour(tess.inst, 2, c2, 8, c2.length / 2);
|
||||
|
||||
//addContour(tess.inst, 2, c3, 8, c3.length / 2);
|
||||
|
||||
//int[] index = { 8, 8, -1 };
|
||||
|
||||
//addMultiContour2D(tess.inst, index, c3, 0, 4);
|
||||
out.println("yup");
|
||||
|
||||
tessContour2D(tess.inst,
|
||||
WindingRule.POSITIVE,
|
||||
ElementType.POLYGONS,
|
||||
polySize, 2);
|
||||
|
||||
out.println("y0!");
|
||||
|
||||
int nElem = getElementCount(tess.inst);
|
||||
int nVert = getVertexCount(tess.inst);
|
||||
|
||||
out.println(nVert + "/" + nElem);
|
||||
|
||||
short[] elems = new short[nElem * polySize];
|
||||
getElementsS(tess.inst, elems, 0, nElem * polySize);
|
||||
|
||||
out.println(Arrays.toString(elems));
|
||||
|
||||
int half = nElem * polySize / 2;
|
||||
elems = new short[half];
|
||||
getElementsS(tess.inst, elems, half, half);
|
||||
|
||||
out.println(Arrays.toString(elems));
|
||||
|
||||
float[] verts = new float[nVert * 2];
|
||||
getVertices(tess.inst, verts, 0, nVert * 2);
|
||||
|
||||
out.println(Arrays.toString(verts));
|
||||
|
||||
short[] ids = new short[nElem * polySize];
|
||||
getElementsWithInputVertexIds(tess.inst, ids, 0, 0, ids.length);
|
||||
|
||||
out.println(Arrays.toString(ids));
|
||||
|
||||
for (int i = 0; i < nElem * polySize; i++) {
|
||||
out.println(c3[ids[i] * 2] + ", " + c3[ids[i] * 2 + 1]);
|
||||
}
|
||||
out.println();
|
||||
|
||||
freeTess(tess.inst);
|
||||
}
|
||||
}
|
@ -1 +1 @@
|
||||
Subproject commit aa46ea2bc10ed0be07ebc26538c57f3595adc4e8
|
||||
Subproject commit 8959fe9f2517d919a17258a062a8b499d224491c
|
Loading…
x
Reference in New Issue
Block a user