diff --git a/DataExtractionOSM/src/net/osmand/NativeLibrary.java b/DataExtractionOSM/src/net/osmand/NativeLibrary.java index cc320f492a..6467e098cd 100644 --- a/DataExtractionOSM/src/net/osmand/NativeLibrary.java +++ b/DataExtractionOSM/src/net/osmand/NativeLibrary.java @@ -17,8 +17,8 @@ public class NativeLibrary { public static class NativeSearchResult { - public int nativeHandler; - private NativeSearchResult(int nativeHandler) { + public long nativeHandler; + private NativeSearchResult(long nativeHandler) { this.nativeHandler = nativeHandler; } @@ -57,7 +57,7 @@ public class NativeLibrary { } - protected static native void deleteSearchResult(int searchResultHandle); + protected static native void deleteSearchResult(long searchResultHandle); protected static native boolean initBinaryMapFile(String filePath); @@ -66,10 +66,10 @@ public class NativeLibrary { protected static native void initRenderingRulesStorage(RenderingRulesStorage storage); - protected static native RenderingGenerationResult generateRenderingIndirect(RenderingContext rc, int searchResultHandler, + protected static native RenderingGenerationResult generateRenderingIndirect(RenderingContext rc, long searchResultHandler, boolean isTransparent, RenderingRuleSearchRequest render, boolean encodePng); - protected static native int searchNativeObjectsForRendering(int sleft, int sright, int stop, int sbottom, int zoom, + protected static native long searchNativeObjectsForRendering(int sleft, int sright, int stop, int sbottom, int zoom, RenderingRuleSearchRequest request, boolean skipDuplicates, Object objectWithInterruptedField, String msgIfNothingFound); } diff --git a/OsmAnd/src/net/osmand/plus/render/NativeOsmandLibrary.java b/OsmAnd/src/net/osmand/plus/render/NativeOsmandLibrary.java index 8ef4a04b7d..06e92ce9f1 100644 --- a/OsmAnd/src/net/osmand/plus/render/NativeOsmandLibrary.java +++ b/OsmAnd/src/net/osmand/plus/render/NativeOsmandLibrary.java @@ -95,7 +95,7 @@ public class NativeOsmandLibrary extends NativeLibrary { } - private static native RenderingGenerationResult generateRenderingDirect(RenderingContext rc, int searchResultHandler, + private static native RenderingGenerationResult generateRenderingDirect(RenderingContext rc, long searchResultHandler, Bitmap bitmap, RenderingRuleSearchRequest render); public static native int getCpuCount(); diff --git a/Osmand-kernel/Makefile b/Osmand-kernel/Makefile index ae506919f2..0bf27fcbda 100755 --- a/Osmand-kernel/Makefile +++ b/Osmand-kernel/Makefile @@ -2,10 +2,12 @@ build : cd protobuf; $(MAKE) cd png; $(MAKE) cd skia; $(MAKE) + cd freetype; $(MAKE) cd osmand; $(MAKE) clean : cd protobuf; $(MAKE) clean cd png; $(MAKE) clean cd skia; $(MAKE) clean + cd freetype; $(MAKE) clean cd osmand; $(MAKE) clean diff --git a/Osmand-kernel/osmand/Makefile b/Osmand-kernel/osmand/Makefile index 01becd583b..336c895f7e 100644 --- a/Osmand-kernel/osmand/Makefile +++ b/Osmand-kernel/osmand/Makefile @@ -22,7 +22,7 @@ CPPFLAGS := \ -DSK_ALLOW_STATIC_GLOBAL_INITIALIZERS=0 \ -DSK_RELEASE \ -DGR_RELEASE=1 \ - -c -Fpic -I$(JAVA_HOME)/include \ + -c -fPIC -I$(JAVA_HOME)/include \ -DHASH_MAP_GNU \ $(C_INCLUDES) diff --git a/Osmand-kernel/osmand/src/binaryRead.cpp b/Osmand-kernel/osmand/src/binaryRead.cpp index ba923f2582..cf476957bc 100644 --- a/Osmand-kernel/osmand/src/binaryRead.cpp +++ b/Osmand-kernel/osmand/src/binaryRead.cpp @@ -364,7 +364,7 @@ MapDataObject* readMapDataObject(CodedInputStream* input, MapTreeBounds* tree, S int px = tree->left & MASK_TO_READ; int py = tree->top & MASK_TO_READ; bool contains = false; - long long id = 0; + int64 id = 0; int minX = INT_MAX; int maxX = 0; int minY = INT_MAX; @@ -484,10 +484,10 @@ MapDataObject* readMapDataObject(CodedInputStream* input, MapTreeBounds* tree, S break; default: { if (WireFormatLite::GetTagWireType(t) == WireFormatLite::WIRETYPE_END_GROUP) { - return false; + return NULL; } if (!skipUnknownFields(input, t)) { - return false; + return NULL; } break; } @@ -601,7 +601,7 @@ bool searchMapTreeBounds(CodedInputStream* input, MapTreeBounds* current, MapTre } bool readMapDataBlocks(CodedInputStream* input, SearchQuery* req, MapTreeBounds* tree, MapIndex* root) { - long long baseId = 0; + int64 baseId = 0; int tag; std::vector< MapDataObject* > results; while ((tag = input->ReadTag()) != 0) { diff --git a/Osmand-kernel/osmand/src/binaryRead.h b/Osmand-kernel/osmand/src/binaryRead.h index 5de8133d59..0573ec12d2 100644 --- a/Osmand-kernel/osmand/src/binaryRead.h +++ b/Osmand-kernel/osmand/src/binaryRead.h @@ -181,9 +181,6 @@ struct SearchQuery { SearchQuery(int l, int r, int t, int b, RenderingRuleSearchRequest* req, ResultPublisher* publisher) : req(req), left(l), right(r), top(t), bottom(b),publisher(publisher) { - if(publisher == NULL) { - publisher = new ResultPublisher(); - } numberOfAcceptedObjects = numberOfVisitedObjects = 0; numberOfAcceptedSubtrees = numberOfReadSubtrees = 0; ocean = land = false; diff --git a/Osmand-kernel/osmand/src/java_wrap.cpp b/Osmand-kernel/osmand/src/java_wrap.cpp index 1bc6df43a0..42f2359b41 100644 --- a/Osmand-kernel/osmand/src/java_wrap.cpp +++ b/Osmand-kernel/osmand/src/java_wrap.cpp @@ -18,7 +18,7 @@ JavaVM* globalJVM = NULL; void loadJniRenderingContext(JNIEnv* env); void loadJniRenderingRules(JNIEnv* env); -static int simplePngSize = 93; +static const int simplePngSize = 93; static void* simplePng = new uint8[simplePngSize]{ 0x89 ,0x50 ,0x4E ,0x47 ,0x0D ,0x0A ,0x1A ,0x0A , 0x00 ,0x00 ,0x00 ,0x0D ,0x49 ,0x48 ,0x44 ,0x52 , @@ -60,7 +60,7 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) } extern "C" JNIEXPORT void JNICALL Java_net_osmand_NativeLibrary_deleteSearchResult(JNIEnv* ienv, - jobject obj, jint searchResult) { + jobject obj, jlong searchResult) { ResultPublisher* result = (ResultPublisher*) searchResult; if(result != NULL){ delete result; @@ -119,7 +119,7 @@ RenderingRuleSearchRequest* initSearchRequest(JNIEnv* env, jobject renderingRule } -extern "C" JNIEXPORT jint JNICALL Java_net_osmand_NativeLibrary_searchNativeObjectsForRendering(JNIEnv* ienv, +extern "C" JNIEXPORT jlong JNICALL Java_net_osmand_NativeLibrary_searchNativeObjectsForRendering(JNIEnv* ienv, jobject obj, jint sleft, jint sright, jint stop, jint sbottom, jint zoom, jobject renderingRuleSearchRequest, bool skipDuplicates, jobject objInterrupted, jstring msgNothingFound) { RenderingRuleSearchRequest* req = initSearchRequest(ienv, renderingRuleSearchRequest); @@ -137,7 +137,7 @@ extern "C" JNIEXPORT jint JNICALL Java_net_osmand_NativeLibrary_searchNativeObje ResultPublisher* res = searchObjectsForRendering(&q, skipDuplicates, getString(ienv, msgNothingFound)); delete req; - return (jint) j; + return (jlong) j; } @@ -148,7 +148,7 @@ extern "C" JNIEXPORT jint JNICALL Java_net_osmand_NativeLibrary_searchNativeObje #include extern "C" JNIEXPORT jobject JNICALL Java_net_osmand_plus_render_NativeOsmandLibrary_generateRenderingDirect( JNIEnv* ienv, jobject obj, - jobject renderingContext, jint searchResult, jobject targetBitmap, jobject renderingRuleSearchRequest) { + jobject renderingContext, jlong searchResult, jobject targetBitmap, jobject renderingRuleSearchRequest) { // libJniGraphics interface typedef int (*PTR_AndroidBitmap_getInfo)(JNIEnv*, jobject, AndroidBitmapInfo*); @@ -266,7 +266,7 @@ extern "C" JNIEXPORT jobject JNICALL Java_net_osmand_plus_render_NativeOsmandLib void* bitmapData = NULL; size_t bitmapDataSize = 0; extern "C" JNIEXPORT jobject JNICALL Java_net_osmand_NativeLibrary_generateRenderingIndirect( JNIEnv* ienv, - jobject obj, jobject renderingContext, jint searchResult, jboolean isTransparent, + jobject obj, jobject renderingContext, jlong searchResult, jboolean isTransparent, jobject renderingRuleSearchRequest, jboolean encodePNG) { JNIRenderingContext rc; diff --git a/Osmand-kernel/osmand/src/osmand_log.cpp b/Osmand-kernel/osmand/src/osmand_log.cpp index d43516a2e7..ccdc4777cd 100644 --- a/Osmand-kernel/osmand/src/osmand_log.cpp +++ b/Osmand-kernel/osmand/src/osmand_log.cpp @@ -11,13 +11,13 @@ void osmand_log_print(int type, const char* msg, ...) { va_list args; va_start( args, msg); if(type == LOG_ERROR) { - __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, msg, args); + __android_log_vprint(ANDROID_LOG_ERROR, LOG_TAG, msg, args); } else if(type == LOG_INFO) { - __android_log_print(ANDROID_LOG_INFO, LOG_TAG, msg, args); + __android_log_vprint(ANDROID_LOG_INFO, LOG_TAG, msg, args); } else if(type == LOG_WARN) { - __android_log_print(ANDROID_LOG_WARN, LOG_TAG, msg, args); + __android_log_vprint(ANDROID_LOG_WARN, LOG_TAG, msg, args); } else { - __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, msg, args); + __android_log_vprint(ANDROID_LOG_DEBUG, LOG_TAG, msg, args); } va_end(args); } diff --git a/Osmand-kernel/osmand/src/osmand_main.cpp b/Osmand-kernel/osmand/src/osmand_main.cpp index 2e0217bb24..ee9cc51f5f 100644 --- a/Osmand-kernel/osmand/src/osmand_main.cpp +++ b/Osmand-kernel/osmand/src/osmand_main.cpp @@ -191,8 +191,8 @@ void runSimpleRendering( string renderingFileName, string resourceDir, Rendering RenderingRulesStorage* st = new RenderingRulesStorage(renderingFileName.c_str()); st->parseRulesFromXmlInputStream(renderingFileName.c_str(), NULL); RenderingRuleSearchRequest* searchRequest = new RenderingRuleSearchRequest(st); - SearchQuery q(floor(info->left), floor(info->right), ceil(info->top), ceil(info->bottom), searchRequest, - new ResultPublisher()); + ResultPublisher* publisher = new ResultPublisher(); + SearchQuery q(floor(info->left), floor(info->right), ceil(info->top), ceil(info->bottom), searchRequest, publisher); q.zoom = info->zoom; ResultPublisher* res = searchObjectsForRendering(&q, true, "Nothing found"); @@ -244,6 +244,7 @@ void runSimpleRendering( string renderingFileName, string resourceDir, Rendering } else { osmand_log_print(LOG_INFO, "Tile successfully saved to %s", info->tileFileName.c_str()); } + delete publisher; delete canvas; delete bitmap; free(bitmapData); diff --git a/Osmand-kernel/osmand/src/renderRules.cpp b/Osmand-kernel/osmand/src/renderRules.cpp index d3b105cd09..3e6f21beaf 100644 --- a/Osmand-kernel/osmand/src/renderRules.cpp +++ b/Osmand-kernel/osmand/src/renderRules.cpp @@ -390,6 +390,7 @@ void RenderingRulesStorage::parseRulesFromXmlInputStream(const char* filename, R done = true; } if (XML_Parse(parser, buffer, len, done) == XML_STATUS_ERROR) { + fclose(file); return; } } @@ -428,6 +429,7 @@ void RenderingRulesStorage::parseRulesFromXmlInputStream(const char* filename, R } } + fclose(file); } diff --git a/Osmand-kernel/osmand/src/rendering.cpp b/Osmand-kernel/osmand/src/rendering.cpp index cb5e12c79a..31adde6ded 100644 --- a/Osmand-kernel/osmand/src/rendering.cpp +++ b/Osmand-kernel/osmand/src/rendering.cpp @@ -248,21 +248,25 @@ void drawOneWayPaints(RenderingContext* rc, SkCanvas* cv, SkPath* p) { p->setStrokeWidth(1); p->setPathEffect(arrowDashEffect1)->unref(); oneWayPaints.push_back(*p); + delete p; p = oneWayPaint(); p->setStrokeWidth(2); p->setPathEffect(arrowDashEffect2)->unref(); oneWayPaints.push_back(*p); + delete p; p = oneWayPaint(); p->setStrokeWidth(3); p->setPathEffect(arrowDashEffect3)->unref(); oneWayPaints.push_back(*p); + delete p; p = oneWayPaint(); p->setStrokeWidth(4); p->setPathEffect(arrowDashEffect4)->unref(); oneWayPaints.push_back(*p); + delete p; } for (size_t i = 0; i < oneWayPaints.size(); i++) { diff --git a/Osmand-kernel/protobuf/Makefile b/Osmand-kernel/protobuf/Makefile index e2fe6e6cbf..b4e10497d8 100644 --- a/Osmand-kernel/protobuf/Makefile +++ b/Osmand-kernel/protobuf/Makefile @@ -4,7 +4,7 @@ CPP_FILE_EXTENSION = cc LIBNAME := libproto.a PREBUILT_DIR = ../jni-prebuilt/linux-x86/ OBJECTS = $(LOCAL_SRC_FILES:%.$(CPP_FILE_EXTENSION)=build/obj/%.o) -CPPFLAGS := -DGOOGLE_PROTOBUF_NO_RTTI -I. +CPPFLAGS := -DGOOGLE_PROTOBUF_NO_RTTI -I. -fPIC LDLIBS = -lpthread target : $(PREBUILT_DIR)/$(LIBNAME) diff --git a/Osmand-kernel/skia/Makefile b/Osmand-kernel/skia/Makefile index c8cef1efc1..a16dd15686 100644 --- a/Osmand-kernel/skia/Makefile +++ b/Osmand-kernel/skia/Makefile @@ -29,6 +29,7 @@ CPPFLAGS := -DSK_RELEASE \ -DNDEBUG \ -fno-rtti \ -fno-exceptions \ + -fPIC \ $(C_INCLUDES) LDLIBS = -lpthread