Merge pull request #180 from alexey-pelykh/newNdkBranch
NEON support, fixed bug in JNI signature, release compilation of native ...
This commit is contained in:
commit
b9f1dfc3e9
11 changed files with 144 additions and 170 deletions
|
@ -1 +1,12 @@
|
|||
include $(all-subdir-makefiles)
|
||||
OSMAND_MAKEFILES := $(all-subdir-makefiles)
|
||||
|
||||
# By default, include makefiles only once
|
||||
include $(OSMAND_MAKEFILES)
|
||||
|
||||
# If we may support NEON, include them once more
|
||||
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
|
||||
|
||||
OSMAND_NEON := true
|
||||
include $(OSMAND_MAKEFILES)
|
||||
|
||||
endif
|
|
@ -1,3 +1,8 @@
|
|||
APP_STL := stlport_shared
|
||||
APP_ABI := armeabi
|
||||
APP_ABI := armeabi armeabi-v7a
|
||||
APP_CPPFLAGS := -fno-rtti -fno-exceptions
|
||||
|
||||
ifndef OSMAND_DEBUG_NATIVE
|
||||
# Force release compilation in release optimizations, even if application is debuggable by manifest
|
||||
APP_OPTIM := release
|
||||
endif
|
22
OsmAnd/jni/cpufeatures_proxy/Android.mk
Executable file
22
OsmAnd/jni/cpufeatures_proxy/Android.mk
Executable file
|
@ -0,0 +1,22 @@
|
|||
# This is built only for ARMv5
|
||||
ifneq ($(TARGET_ARCH_ABI),armeabi-v7a)
|
||||
ifneq ($(LOCAL_ARM_NEON),true)
|
||||
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
# Name of the local module
|
||||
LOCAL_MODULE := cpufeatures_proxy
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
cpuCheck.cpp
|
||||
|
||||
LOCAL_STATIC_LIBRARIES := cpufeatures
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
$(call import-module,android/cpufeatures)
|
||||
|
||||
endif
|
||||
endif
|
18
OsmAnd/jni/cpufeatures_proxy/cpuCheck.cpp
Executable file
18
OsmAnd/jni/cpufeatures_proxy/cpuCheck.cpp
Executable file
|
@ -0,0 +1,18 @@
|
|||
#include <jni.h>
|
||||
#include <cpu-features.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
JNIEXPORT jint JNICALL Java_net_osmand_plus_render_NativeOsmandLibrary_getCpuCount( JNIEnv* ienv, jobject obj) {
|
||||
return android_getCpuCount();
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_net_osmand_plus_render_NativeOsmandLibrary_cpuHasNeonSupport( JNIEnv* ienv, jobject obj) {
|
||||
return (android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM && (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) == ANDROID_CPU_ARM_FEATURE_NEON) ? JNI_TRUE : JNI_FALSE;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -13,7 +13,12 @@ ifeq ($(SKIA_ABS),)
|
|||
endif
|
||||
|
||||
# Name of the local module
|
||||
ifneq ($(OSMAND_NEON),true)
|
||||
LOCAL_MODULE := osmand
|
||||
else
|
||||
LOCAL_MODULE := osmand_neon
|
||||
LOCAL_ARM_NEON := true
|
||||
endif
|
||||
|
||||
# Include paths
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH) \
|
||||
|
@ -26,8 +31,11 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH) \
|
|||
$(SKIA_ABS)/trunk/src/core
|
||||
|
||||
LOCAL_CPP_EXTENSION := .cpp
|
||||
LOCAL_SRC_FILES := common.cpp mapObjects.cpp \
|
||||
renderRules.cpp rendering.cpp \
|
||||
LOCAL_SRC_FILES := \
|
||||
common.cpp \
|
||||
mapObjects.cpp \
|
||||
renderRules.cpp \
|
||||
rendering.cpp \
|
||||
binaryRead.cpp
|
||||
|
||||
LOCAL_CFLAGS := \
|
||||
|
@ -39,7 +47,11 @@ LOCAL_CFLAGS := \
|
|||
-DSK_RELEASE \
|
||||
-DGR_RELEASE=1
|
||||
|
||||
ifneq ($(LOCAL_ARM_NEON),true)
|
||||
LOCAL_STATIC_LIBRARIES := proto skia
|
||||
else
|
||||
LOCAL_STATIC_LIBRARIES := proto_neon skia_neon
|
||||
endif
|
||||
|
||||
LOCAL_LDLIBS := -llog
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ void RenderingRulesStorage::initProperties() {
|
|||
uint i = 0;
|
||||
for (; i < sz; i++) {
|
||||
jobject rulePrope = globalEnv()->CallObjectMethod(listProps, List_get, i);
|
||||
bool input = globalEnv()->GetIntField(rulePrope, RenderingRuleProperty_input);
|
||||
bool input = (globalEnv()->GetBooleanField(rulePrope, RenderingRuleProperty_input) == JNI_TRUE);
|
||||
int type = globalEnv()->GetIntField(rulePrope, RenderingRuleProperty_type);
|
||||
std::string name = getStringField(rulePrope, RenderingRuleProperty_attrName);
|
||||
RenderingRuleProperty* prop = new RenderingRuleProperty(type, input, name, i);
|
||||
|
|
|
@ -711,11 +711,15 @@ JNIEXPORT jobject JNICALL Java_net_osmand_plus_render_NativeOsmandLibrary_genera
|
|||
bitmap->setConfig(SkBitmap::kARGB_8888_Config, requestedBitmapWidth, requestedBitmapHeight);
|
||||
else
|
||||
bitmap->setConfig(SkBitmap::kRGB_565_Config, requestedBitmapWidth, requestedBitmapHeight);
|
||||
bitmap->allocPixels();
|
||||
|
||||
sprintf(debugMessage, "Allocated %d bytes!", bitmap->getSize());
|
||||
void* bitmapData = malloc(bitmap->getSize());
|
||||
|
||||
//TODO: Quite possible increase of speed - [re]allocate buffer only if size changed in greated direction?
|
||||
sprintf(debugMessage, "Allocated %d bytes at %p", bitmap->getSize(), bitmapData);
|
||||
__android_log_print(ANDROID_LOG_WARN, "net.osmand", debugMessage);
|
||||
|
||||
bitmap->setPixels(bitmapData);
|
||||
|
||||
SkCanvas* canvas = new SkCanvas(*bitmap);
|
||||
canvas->drawColor(defaultColor);
|
||||
|
||||
|
@ -746,10 +750,6 @@ JNIEXPORT jobject JNICALL Java_net_osmand_plus_render_NativeOsmandLibrary_genera
|
|||
mergeRenderingContext(renderingContext, &rc);
|
||||
__android_log_print(ANDROID_LOG_WARN, "net.osmand", "End Rendering image");
|
||||
|
||||
// Create byte array
|
||||
jbyteArray bitmapByteArray = ienv->NewByteArray(bitmap->getSize());
|
||||
ienv->SetByteArrayRegion(bitmapByteArray, 0, bitmap->getSize(), (jbyte*)bitmap->getPixels());
|
||||
|
||||
// delete variables
|
||||
delete paint;
|
||||
delete canvas;
|
||||
|
@ -763,8 +763,7 @@ JNIEXPORT jobject JNICALL Java_net_osmand_plus_render_NativeOsmandLibrary_genera
|
|||
sprintf(debugMessage, "Result class = %p", resultClass);
|
||||
__android_log_print(ANDROID_LOG_WARN, "net.osmand", debugMessage);
|
||||
|
||||
/* Get the method ID for the String(char[]) constructor */
|
||||
jmethodID resultClassCtorId = ienv->GetMethodID(resultClass, "<init>", "([BLjava/lang/String;)V");
|
||||
jmethodID resultClassCtorId = ienv->GetMethodID(resultClass, "<init>", "(Ljava/nio/ByteBuffer;Ljava/lang/String;)V");
|
||||
|
||||
sprintf(debugMessage, "Result class ctor = %p", resultClassCtorId);
|
||||
__android_log_print(ANDROID_LOG_WARN, "net.osmand", debugMessage);
|
||||
|
@ -775,15 +774,30 @@ JNIEXPORT jobject JNICALL Java_net_osmand_plus_render_NativeOsmandLibrary_genera
|
|||
sprintf(debugMessage, "Native ok (init %d, rendering %d) ", initObjects.getElapsedTime(), rc.nativeOperations.getElapsedTime());
|
||||
#endif
|
||||
|
||||
/* Construct a result object */
|
||||
jobject resultObject = ienv->NewObject(resultClass, resultClassCtorId, bitmapByteArray, globalEnv()->NewStringUTF(debugMessage));
|
||||
// Allocate ctor paramters
|
||||
jobject bitmapBuffer = ienv->NewDirectByteBuffer(bitmapData, bitmap->getSize());
|
||||
jstring message = globalEnv()->NewStringUTF(debugMessage);
|
||||
|
||||
/* Construct a result object */
|
||||
jobject resultObject = ienv->NewObject(resultClass, resultClassCtorId, bitmapBuffer, message);
|
||||
|
||||
/* Free local references */
|
||||
ienv->DeleteLocalRef(bitmapByteArray);
|
||||
ienv->DeleteLocalRef(resultClass);
|
||||
return resultObject;
|
||||
}
|
||||
|
||||
JNIEXPORT jobject JNICALL Java_net_osmand_plus_render_NativeOsmandLibrary_releaseRenderingGenerationResults( JNIEnv* ienv, jobject obj,
|
||||
jobject results) {
|
||||
setGlobalEnv(ienv);
|
||||
|
||||
jclass resultClass = ienv->FindClass("net/osmand/plus/render/NativeOsmandLibrary$RenderingGenerationResult");
|
||||
if(!resultClass)
|
||||
resultClass = ienv->FindClass("net/osmand/render/NativeOsmandLibrary$RenderingGenerationResult");
|
||||
jfieldID resultClass_bitmapBuffer = globalEnv()->GetFieldID(resultClass, "bitmapBuffer", "Ljava/nio/ByteBuffer;");
|
||||
jobject bitmapBuffer = globalEnv()->GetObjectField(results, resultClass_bitmapBuffer);
|
||||
|
||||
void *buffer = ienv->GetDirectBufferAddress(bitmapBuffer);
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -13,10 +13,14 @@ CC_LITE_SRC_FILES := \
|
|||
google/protobuf/io/zero_copy_stream.cc \
|
||||
google/protobuf/io/zero_copy_stream_impl_lite.cc
|
||||
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
ifneq ($(OSMAND_NEON),true)
|
||||
LOCAL_MODULE := proto
|
||||
else
|
||||
LOCAL_MODULE := proto_neon
|
||||
LOCAL_ARM_NEON := true
|
||||
endif
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
|
||||
LOCAL_CPP_EXTENSION := .cc
|
||||
|
|
|
@ -2,6 +2,15 @@
|
|||
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
ifneq ($(OSMAND_NEON),true)
|
||||
LOCAL_MODULE := skia
|
||||
else
|
||||
LOCAL_MODULE := skia_neon
|
||||
LOCAL_ARM_NEON := true
|
||||
endif
|
||||
|
||||
ifeq ($(SKIA_LOC),)
|
||||
SKIA_LOC := .
|
||||
endif
|
||||
|
@ -9,8 +18,6 @@ ifeq ($(SKIA_ABS),)
|
|||
SKIA_ABS := $(LOCAL_PATH)
|
||||
endif
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_ARM_MODE := arm
|
||||
|
||||
# need a flag to tell the C side when we're on devices with large memory
|
||||
|
@ -23,11 +30,10 @@ ifneq ($(ARCH_ARM_HAVE_VFP),true)
|
|||
LOCAL_CFLAGS += -DSK_SOFTWARE_FLOAT
|
||||
endif
|
||||
|
||||
ifeq ($(ARCH_ARM_HAVE_NEON),true)
|
||||
ifeq ($(LOCAL_ARM_NEON),true)
|
||||
LOCAL_CFLAGS += -D__ARM_HAVE_NEON
|
||||
endif
|
||||
|
||||
LOCAL_MODULE := skia
|
||||
LOCAL_SRC_FILES := \
|
||||
$(SKIA_LOC)/trunk/src/core/Sk64.cpp \
|
||||
$(SKIA_LOC)/trunk/src/core/SkAAClip.cpp \
|
||||
|
@ -221,7 +227,7 @@ LOCAL_C_INCLUDES += \
|
|||
|
||||
ifeq ($(TARGET_ARCH),arm)
|
||||
|
||||
ifeq ($(ARCH_ARM_HAVE_NEON),true)
|
||||
ifeq ($(LOCAL_ARM_NEON),true)
|
||||
LOCAL_SRC_FILES += \
|
||||
$(SKIA_LOC)/trunk/src/opts/memset16_neon.S \
|
||||
$(SKIA_LOC)/trunk/src/opts/memset32_neon.S
|
||||
|
@ -271,7 +277,7 @@ ifeq ($(NO_FALLBACK_FONT),true)
|
|||
LOCAL_CFLAGS += -DNO_FALLBACK_FONT
|
||||
endif
|
||||
|
||||
LOCAL_CFLAGS := \
|
||||
LOCAL_CFLAGS += \
|
||||
-DSK_SCALAR_IS_FLOAT \
|
||||
-DSK_CAN_USE_FLOAT \
|
||||
-DSK_BUILD_FOR_ANDROID \
|
||||
|
@ -290,136 +296,6 @@ LOCAL_LDLIBS += -lz -llog
|
|||
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
#############################################################
|
||||
# Build the skia gpu (ganesh) library
|
||||
#
|
||||
|
||||
# include $(CLEAR_VARS)
|
||||
|
||||
# LOCAL_ARM_MODE := arm
|
||||
|
||||
# ifneq ($(ARCH_ARM_HAVE_VFP),true)
|
||||
# LOCAL_CFLAGS += -DSK_SOFTWARE_FLOAT
|
||||
# endif
|
||||
|
||||
# ifeq ($(ARCH_ARM_HAVE_NEON),true)
|
||||
# LOCAL_CFLAGS += -DGR_ANDROID_BUILD=1
|
||||
# endif
|
||||
|
||||
# LOCAL_SRC_FILES:= \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrPrintf_skia.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/SkGLContext.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/SkGpuCanvas.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/SkGpuDevice.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/SkGr.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/SkGrFontScaler.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/SkGrTexturePixelRef.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/SkNullGLContext.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/android/SkNativeGLContext_android.cpp
|
||||
|
||||
# LOCAL_SRC_FILES += \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrAAHairLinePathRenderer.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrAddPathRenderers_aahairline.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrAllocPool.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrAtlas.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrBufferAllocPool.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrClip.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrContext.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrDefaultPathRenderer.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrDrawTarget.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrGLCreateNullInterface.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrGLDefaultInterface_native.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrGLIndexBuffer.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrGLInterface.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrGLProgram.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrGLRenderTarget.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrGLSL.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrGLStencilBuffer.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrGLTexture.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrGLUtil.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrGLVertexBuffer.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrGpu.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrGpuFactory.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrGpuGL.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrGpuGLShaders.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrInOrderDrawBuffer.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrMatrix.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrMemory.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrPathRendererChain.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrPathRenderer.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrPathUtils.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrRectanizer.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrRenderTarget.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrResource.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrResourceCache.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrStencil.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrStencilBuffer.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrTesselatedPathRenderer.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrTextContext.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrTextStrike.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/GrTexture.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/gr_unittests.cpp \
|
||||
# $(SKIA_LOC)/trunk/src/gpu/android/GrGLCreateNativeInterface_android.cpp
|
||||
|
||||
# LOCAL_STATIC_LIBRARIES := libskiatess
|
||||
# LOCAL_SHARED_LIBRARIES := \
|
||||
# libcutils \
|
||||
# libutils \
|
||||
# libskia \
|
||||
# libEGL \
|
||||
# libGLESv2
|
||||
|
||||
# LOCAL_C_INCLUDES += \
|
||||
# $(SKIA_ABS)/trunk/include/core \
|
||||
# $(SKIA_ABS)/trunk/include/config \
|
||||
# $(SKIA_ABS)/trunk/include/gpu \
|
||||
# $(SKIA_ABS)/trunk/src/core \
|
||||
# $(SKIA_ABS)/trunk/src/gpu \
|
||||
# $(SKIA_ABS)/trunk/third_party/glu
|
||||
|
||||
# LOCAL_MODULE := libskiagpu
|
||||
# LOCAL_MODULE_TAGS := optional
|
||||
|
||||
# include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
# #############################################################
|
||||
# # Build the skia gpu (ganesh) library
|
||||
# #
|
||||
|
||||
# include $(CLEAR_VARS)
|
||||
|
||||
# LOCAL_ARM_MODE := arm
|
||||
|
||||
# LOCAL_SRC_FILES := \
|
||||
# third_party/glu/libtess/dict.c \
|
||||
# third_party/glu/libtess/geom.c \
|
||||
# third_party/glu/libtess/memalloc.c \
|
||||
# third_party/glu/libtess/mesh.c \
|
||||
# third_party/glu/libtess/normal.c \
|
||||
# third_party/glu/libtess/priorityq.c \
|
||||
# third_party/glu/libtess/render.c \
|
||||
# third_party/glu/libtess/sweep.c \
|
||||
# third_party/glu/libtess/tess.c \
|
||||
# third_party/glu/libtess/tessmono.c
|
||||
|
||||
# LOCAL_SHARED_LIBRARIES := \
|
||||
# libcutils \
|
||||
# libutils \
|
||||
# libEGL \
|
||||
# libGLESv2
|
||||
|
||||
# LOCAL_C_INCLUDES += \
|
||||
# $(LOCAL_PATH)/third_party/glu \
|
||||
# $(LOCAL_PATH)/third_party/glu/libtess \
|
||||
# frameworks/base/opengl/include
|
||||
|
||||
# LOCAL_LDLIBS += -lpthread
|
||||
|
||||
# LOCAL_MODULE:= libskiatess
|
||||
# LOCAL_MODULE_TAGS := optional
|
||||
|
||||
# include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
# Fix some errors
|
||||
BUILD_HOST_EXECUTABLE := $(LOCAL_PATH)/FakeHost.mk
|
||||
BUILD_HOST_STATIC_LIBRARY := $(LOCAL_PATH)/FakeHost.mk
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
package net.osmand.plus.render;
|
||||
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import net.osmand.LogUtil;
|
||||
import net.osmand.plus.render.OsmandRenderer.RenderingContext;
|
||||
import net.osmand.render.RenderingRuleSearchRequest;
|
||||
import net.osmand.render.RenderingRulesStorage;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
public class NativeOsmandLibrary {
|
||||
|
@ -22,8 +24,15 @@ public class NativeOsmandLibrary {
|
|||
try {
|
||||
log.debug("Loading native stlport_shared..."); //$NON-NLS-1$
|
||||
System.loadLibrary("stlport_shared");
|
||||
log.debug("Loading native cpufeatures_proxy..."); //$NON-NLS-1$
|
||||
System.loadLibrary("cpufeatures_proxy");
|
||||
if(!cpuHasNeonSupport()) {
|
||||
log.debug("Loading native osmand..."); //$NON-NLS-1$
|
||||
System.loadLibrary("osmand");
|
||||
} else {
|
||||
log.debug("Loading native osmand with NEON..."); //$NON-NLS-1$
|
||||
System.loadLibrary("osmand_neon");
|
||||
}
|
||||
log.debug("Creating NativeOsmandLibrary instance..."); //$NON-NLS-1$
|
||||
library = new NativeOsmandLibrary();
|
||||
log.debug("Initializing rendering rules storage..."); //$NON-NLS-1$
|
||||
|
@ -34,7 +43,6 @@ public class NativeOsmandLibrary {
|
|||
log.error("Failed to load native library", e); //$NON-NLS-1$
|
||||
isNativeSupported = false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -115,12 +123,12 @@ public class NativeOsmandLibrary {
|
|||
}
|
||||
|
||||
public static class RenderingGenerationResult {
|
||||
public RenderingGenerationResult(byte[] bitmap, String msg) {
|
||||
bitmapArray = bitmap;
|
||||
public RenderingGenerationResult(ByteBuffer bitmap, String msg) {
|
||||
bitmapBuffer = bitmap;
|
||||
debugMessage = msg;
|
||||
}
|
||||
|
||||
public final byte[] bitmapArray;
|
||||
public final ByteBuffer bitmapBuffer;
|
||||
|
||||
public final String debugMessage;
|
||||
}
|
||||
|
@ -129,12 +137,16 @@ public class NativeOsmandLibrary {
|
|||
|
||||
private static native boolean initBinaryMapFile(String filePath);
|
||||
|
||||
private static native boolean initRenderingRulesStorage(RenderingRulesStorage storage);
|
||||
private static native void initRenderingRulesStorage(RenderingRulesStorage storage);
|
||||
|
||||
private static native RenderingGenerationResult generateRendering(RenderingContext rc, int searchResultHandler,
|
||||
int requestedBitmapWidth, int requestedBitmapHeight, boolean isTransparent, boolean useEnglishNames,
|
||||
RenderingRuleSearchRequest render, int defaultColor);
|
||||
public static native void releaseRenderingGenerationResults(RenderingGenerationResult results);
|
||||
|
||||
private static native int searchObjectsForRendering(int sleft, int sright, int stop, int sbottom, int zoom, String mapnaem,
|
||||
RenderingRuleSearchRequest request, boolean skipDuplicates, int searchResultHandler, Object objectWithInterruptedField);
|
||||
|
||||
public static native int getCpuCount();
|
||||
public static native boolean cpuHasNeonSupport();
|
||||
}
|
||||
|
|
|
@ -225,9 +225,9 @@ public class OsmandRenderer {
|
|||
+ "(%s points, %s points inside, %s of %s objects visible)\n" + res.debugMessage,//$NON-NLS-1$
|
||||
time, rc.textRenderingTime, rc.pointCount, rc.pointInsideCount, rc.visible, rc.allObjects);
|
||||
|
||||
if(res.bitmapArray != null) {
|
||||
final ByteBuffer bitmapByteBuffer = ByteBuffer.wrap(res.bitmapArray);
|
||||
bmp.copyPixelsFromBuffer(bitmapByteBuffer);
|
||||
if(res.bitmapBuffer != null) {
|
||||
bmp.copyPixelsFromBuffer(res.bitmapBuffer);
|
||||
NativeOsmandLibrary.releaseRenderingGenerationResults(res);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
Loading…
Reference in a new issue