diff --git a/Osmand-kernel/Makefile b/Osmand-kernel/Makefile index 5924054e33..ae506919f2 100755 --- a/Osmand-kernel/Makefile +++ b/Osmand-kernel/Makefile @@ -1,9 +1,11 @@ build : cd protobuf; $(MAKE) + cd png; $(MAKE) cd skia; $(MAKE) cd osmand; $(MAKE) clean : cd protobuf; $(MAKE) clean + cd png; $(MAKE) clean cd skia; $(MAKE) clean cd osmand; $(MAKE) clean diff --git a/Osmand-kernel/osmand/Makefile b/Osmand-kernel/osmand/Makefile index 5f33dd5c87..60cd0414f4 100644 --- a/Osmand-kernel/osmand/Makefile +++ b/Osmand-kernel/osmand/Makefile @@ -9,7 +9,7 @@ LOCAL_SRC_FILES += src/osmand_main.cpp LDFLAGS = -Wl,--hash-style=both -shared LDRUNFLAGS = -Wl,--hash-style=both -LDLIBS = -L$(PREBUILT_DIR) -lskia -lproto -lpthread -lrt -lft2 -lexpat +LDLIBS = -L$(PREBUILT_DIR) -lskia -lproto -lpthread -lrt -lft2 -lexpat -lpng -lz CPP_FILE_EXTENSION = cpp OBJECTS = $(LOCAL_SRC_FILES:src/%.$(CPP_FILE_EXTENSION)=build/obj/%.o) diff --git a/Osmand-kernel/osmand/src/common.h b/Osmand-kernel/osmand/src/common.h index 049868c96c..e69374b5c8 100644 --- a/Osmand-kernel/osmand/src/common.h +++ b/Osmand-kernel/osmand/src/common.h @@ -201,7 +201,8 @@ public : int shadowLevelMax; public: - RenderingContext() : shadowLevelMax(0), shadowLevelMin(256), density(true), useEnglishNames(false){ + RenderingContext() : shadowLevelMax(0), shadowLevelMin(256), density(true), useEnglishNames(false), pointCount(0), + pointInsideCount(0), visible(0), allObjects(0){ setRotate(0); setZoom(15); } @@ -291,4 +292,6 @@ double get31LatitudeY(int tileY); double getTileNumberX(float zoom, double longitude); double getTileNumberY(float zoom, double latitude); +double getPowZoom(float zoom); + #endif /*_OSMAND_COMMON_H*/ diff --git a/Osmand-kernel/osmand/src/osmand_main.cpp b/Osmand-kernel/osmand/src/osmand_main.cpp index fbefb9d5df..5b0a181f64 100644 --- a/Osmand-kernel/osmand/src/osmand_main.cpp +++ b/Osmand-kernel/osmand/src/osmand_main.cpp @@ -217,7 +217,10 @@ void runSimpleRendering(string fileName, string renderingFileName, RenderingInfo rc.setShadowRenderingMode(searchRequest->getIntPropertyValue(searchRequest->props()->R_ATTR_INT_VALUE)); //rc.setShadowRenderingColor(searchRequest->getIntPropertyValue(searchRequest->props()->R_SHADOW_COLOR)); } - rc.setLocation(info->left, info->top); + rc.setLocation( + ((double)info->left)/getPowZoom(31-info->zoom), + ((double)info->top)/getPowZoom(31-info->zoom) + ); rc.setDimension(info->width, info->height); rc.setZoom(info->zoom); rc.setRotate(0); @@ -226,18 +229,12 @@ void runSimpleRendering(string fileName, string renderingFileName, RenderingInfo initObjects.pause(); SkCanvas* canvas = new SkCanvas(*bitmap); canvas->drawColor(defaultMapColor); - doRendering(res->result, canvas, searchRequest, &rc); osmand_log_print(LOG_INFO, "End Rendering image"); osmand_log_print(LOG_INFO, "Native ok (init %d, rendering %d) ", initObjects.getElapsedTime(), rc.nativeOperations.getElapsedTime()); - for(int i=100; i<200; i++) { - printf("\n"); - for(int j=100; j<200; j++) { - printf("%s ", colorToString(bitmap->getColor(i,j)).c_str()); - } - } - if (!SkImageEncoder::EncodeFile(info->tileFileName.c_str(), *bitmap, SkImageEncoder::kPNG_Type, 100)) { + SkImageEncoder* enc = SkImageEncoder::Create(SkImageEncoder::kPNG_Type); + if (enc != NULL && !enc->encodeFile(info->tileFileName.c_str(), *bitmap, 100)) { osmand_log_print(LOG_ERROR, "FAIL to save tile to %s", info->tileFileName.c_str()); } else { osmand_log_print(LOG_INFO, "Tile successfully saved to %s", info->tileFileName.c_str()); @@ -280,7 +277,7 @@ int main(int argc, char **argv) { // "default.render.xml" // ); // 2. Test simple rendering - char** tst = new char*[5] {"", "-renderingOutputFile=/home/victor/1.png","-zoom=11", "-lt=3,3", "-lbox=-80,22"}; + char** tst = new char*[5] {"", "-renderingOutputFile=/home/victor/1.png","-zoom=11", "-lt=5,5", "-lbox=-80,22"}; RenderingInfo* info = new RenderingInfo(5, tst); runSimpleRendering(string("/home/victor/projects/OsmAnd/data/osm-gen/Cuba2.obf"), string("/home/victor/projects/OsmAnd/git/DataExtractionOSM/src/net/osmand/render/default.render.xml"), info); diff --git a/Osmand-kernel/osmand/src/renderRules.cpp b/Osmand-kernel/osmand/src/renderRules.cpp index 4dbaf8bc65..a1e09dff97 100644 --- a/Osmand-kernel/osmand/src/renderRules.cpp +++ b/Osmand-kernel/osmand/src/renderRules.cpp @@ -266,7 +266,7 @@ class RenderingRulesHandler { string attr = attrsMap["name"]; map empty; RenderingRule* root = new RenderingRule(empty,t->storage); - t->storage->renderingAttributes[name] = root; + t->storage->renderingAttributes[attr] = root; t->st.push(GroupRules(root)); } else if ("renderingProperty" == name) { map attrsMap; diff --git a/Osmand-kernel/osmand/src/rendering.cpp b/Osmand-kernel/osmand/src/rendering.cpp index 4d383cb511..cb5e12c79a 100644 --- a/Osmand-kernel/osmand/src/rendering.cpp +++ b/Osmand-kernel/osmand/src/rendering.cpp @@ -435,18 +435,18 @@ void drawPoint(MapDataObject* mObj, RenderingRuleSearchRequest* req, SkCanvas* c void drawObject(RenderingContext* rc, MapDataObject* mObj, SkCanvas* cv, RenderingRuleSearchRequest* req, SkPaint* paint, int l, int renderText, int drawOnlyShadow) { - rc->allObjects++; - int t = mObj->objectType; - tag_value pair = mObj->types.at(l); - if (t == 1 && !drawOnlyShadow) { - // point - drawPoint(mObj, req, cv, paint, rc, pair, renderText); - } else if (t == 2) { - drawPolyline(mObj, req, cv, paint, rc, pair, mObj->getSimpleLayer(), drawOnlyShadow); - } else if (t == 3 && !drawOnlyShadow) { - // polygon - drawPolygon(mObj, req, cv, paint, rc, pair); - } + rc->allObjects++; + int t = mObj->objectType; + tag_value pair = mObj->types.at(l); + if (t == 1 && !drawOnlyShadow) { + // point + drawPoint(mObj, req, cv, paint, rc, pair, renderText); + } else if (t == 2) { + drawPolyline(mObj, req, cv, paint, rc, pair, mObj->getSimpleLayer(), drawOnlyShadow); + } else if (t == 3 && !drawOnlyShadow) { + // polygon + drawPolygon(mObj, req, cv, paint, rc, pair); + } } @@ -529,7 +529,6 @@ void doRendering(std::vector mapDataObjects, SkCanvas* canvas, RenderingRuleSearchRequest* req, RenderingContext* rc) { rc->nativeOperations.start(); - SkPaint* paint = new SkPaint; paint->setAntiAlias(true); @@ -537,12 +536,12 @@ void doRendering(std::vector mapDataObjects, SkCanvas* canvas, HMAP::hash_map > orderMap = sortObjectsByProperOrder(mapDataObjects, req, rc); std::set keys; HMAP::hash_map >::iterator it = orderMap.begin(); + while (it != orderMap.end()) { keys.insert(it->first); it++; } bool shadowDrawn = false; - for (std::set::iterator ks = keys.begin(); ks != keys.end(); ks++) { if (!shadowDrawn && *ks >= rc->shadowLevelMin && *ks <= rc->shadowLevelMax && rc->getShadowRenderingMode() > 1) { for (std::set::iterator ki = ks; ki != keys.end(); ki++) { @@ -557,6 +556,7 @@ void doRendering(std::vector mapDataObjects, SkCanvas* canvas, MapDataObject* mapObject = mapDataObjects.at(ind); // show text only for main type + drawObject(rc, mapObject, canvas, req, paint, l, l == 0, true); } } @@ -588,4 +588,7 @@ void doRendering(std::vector mapDataObjects, SkCanvas* canvas, delete paint; rc->nativeOperations.pause(); + osmand_log_print(LOG_INFO, "Native ok (rendering %d, text %d ms) \n (%d points, %d points inside, %d of %d objects visible)\n", + rc->nativeOperations.getElapsedTime(), rc->textRendering.getElapsedTime(), + rc->pointCount, rc->pointInsideCount, rc->visible, rc->allObjects); } diff --git a/Osmand-kernel/png/.gitignore b/Osmand-kernel/png/.gitignore new file mode 100644 index 0000000000..378eac25d3 --- /dev/null +++ b/Osmand-kernel/png/.gitignore @@ -0,0 +1 @@ +build diff --git a/Osmand-kernel/png/Android.mk b/Osmand-kernel/png/Android.mk index 69156321cb..07b9fa15cd 100755 --- a/Osmand-kernel/png/Android.mk +++ b/Osmand-kernel/png/Android.mk @@ -1,13 +1,6 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) -ifeq ($(OSMAND_PNG_LOC),) - OSMAND_PNG_LOC := ./png_library -endif -ifeq ($(OSMAND_PNG_ABS),) - OSMAND_PNG_ABS := $(LOCAL_PATH)/png_library -endif - LOCAL_SHARED_LIBRARIES := \ libz @@ -16,28 +9,9 @@ LOCAL_MODULE := png else LOCAL_MODULE := png_neon endif - +LIBPNG ifneq ($(OSMAND_USE_PREBUILT),true) -common_SRC_FILES := \ - $(OSMAND_PNG_LOC)/png.c \ - $(OSMAND_PNG_LOC)/pngerror.c \ - $(OSMAND_PNG_LOC)/pnggccrd.c \ - $(OSMAND_PNG_LOC)/pngget.c \ - $(OSMAND_PNG_LOC)/pngmem.c \ - $(OSMAND_PNG_LOC)/pngpread.c \ - $(OSMAND_PNG_LOC)/pngread.c \ - $(OSMAND_PNG_LOC)/pngrio.c \ - $(OSMAND_PNG_LOC)/pngrtran.c \ - $(OSMAND_PNG_LOC)/pngrutil.c \ - $(OSMAND_PNG_LOC)/pngset.c \ - $(OSMAND_PNG_LOC)/pngtrans.c \ - $(OSMAND_PNG_LOC)/pngvcrd.c \ - $(OSMAND_PNG_LOC)/pngwio.c \ - $(OSMAND_PNG_LOC)/pngwrite.c \ - $(OSMAND_PNG_LOC)/pngwtran.c \ - $(OSMAND_PNG_LOC)/pngwutil.c - common_CFLAGS := -fvisibility=hidden ## -fomit-frame-pointer ifeq ($(HOST_OS),windows) @@ -54,7 +28,6 @@ common_C_INCLUDES += common_COPY_HEADERS_TO := libpng common_COPY_HEADERS := png.h pngconf.h pngusr.h -LOCAL_SRC_FILES := $(common_SRC_FILES) LOCAL_CFLAGS += $(common_CFLAGS) LOCAL_C_INCLUDES += $(common_C_INCLUDES) \ external/zlib diff --git a/Osmand-kernel/png/Common.mk b/Osmand-kernel/png/Common.mk new file mode 100644 index 0000000000..1797699a99 --- /dev/null +++ b/Osmand-kernel/png/Common.mk @@ -0,0 +1,29 @@ +OSMAND_PNG_LOC := ./png_library + +OSMAND_PNG_ABS := $(LOCAL_PATH)/png_library + +LOCAL_SRC_FILES:= \ + $(OSMAND_PNG_LOC)/png.c \ + $(OSMAND_PNG_LOC)/pngerror.c \ + $(OSMAND_PNG_LOC)/pnggccrd.c \ + $(OSMAND_PNG_LOC)/pngget.c \ + $(OSMAND_PNG_LOC)/pngmem.c \ + $(OSMAND_PNG_LOC)/pngpread.c \ + $(OSMAND_PNG_LOC)/pngread.c \ + $(OSMAND_PNG_LOC)/pngrio.c \ + $(OSMAND_PNG_LOC)/pngrtran.c \ + $(OSMAND_PNG_LOC)/pngrutil.c \ + $(OSMAND_PNG_LOC)/pngset.c \ + $(OSMAND_PNG_LOC)/pngtrans.c \ + $(OSMAND_PNG_LOC)/pngvcrd.c \ + $(OSMAND_PNG_LOC)/pngwio.c \ + $(OSMAND_PNG_LOC)/pngwrite.c \ + $(OSMAND_PNG_LOC)/pngwtran.c \ + $(OSMAND_PNG_LOC)/pngwutil.c + +LOCAL_C_INCLUDES += \ + $(OSMAND_PNG_ABS)/ + +LOCAL_CFLAGS += -W -Wall +LOCAL_CFLAGS += -fPIC -DPIC -fvisibility=hidden -fpermissive + diff --git a/Osmand-kernel/png/Makefile b/Osmand-kernel/png/Makefile new file mode 100644 index 0000000000..936da1810d --- /dev/null +++ b/Osmand-kernel/png/Makefile @@ -0,0 +1,24 @@ +LOCAL_PATH = . +include Common.mk + +CPP_FILE_EXTENSION = c +LIBNAME := libpng.a +PREBUILT_DIR = ../jni-prebuilt/linux-x86/ +OBJECTS = $(LOCAL_SRC_FILES:%.$(CPP_FILE_EXTENSION)=build/obj/%.o) +C_INCLUDES := $(addprefix -I, $(LOCAL_C_INCLUDES)) +CPPFLAGS = $(LOCAL_CFLAGS) $(C_INCLUDES) + +target : $(PREBUILT_DIR)/$(LIBNAME) + +$(PREBUILT_DIR)/$(LIBNAME) : build/$(LIBNAME) + cp build/$(LIBNAME) $(PREBUILT_DIR)/$(LIBNAME) + +build/$(LIBNAME): $(OBJECTS) + ar -rf build/$(LIBNAME) $(OBJECTS) + +build/obj/%.o : %.$(CPP_FILE_EXTENSION) $(LOCAL_C_INCLUDES) + @mkdir -p `dirname $@` + $(CXX) -o $@ -c $*.$(CPP_FILE_EXTENSION) $(CPPFLAGS) + +clean: + $(RM) $(OBJECTS) build/$(LIBNAME) \ No newline at end of file diff --git a/Osmand-kernel/skia/Makefile b/Osmand-kernel/skia/Makefile index 46256962d5..c8cef1efc1 100644 --- a/Osmand-kernel/skia/Makefile +++ b/Osmand-kernel/skia/Makefile @@ -24,6 +24,7 @@ C_INCLUDES := $(addprefix -I, $(LOCAL_C_INCLUDES)) CPPFLAGS := -DSK_RELEASE \ -DGR_RELEASE=1 \ + -DSK_ENABLE_LIBPNG \ -DSK_ALLOW_STATIC_GLOBAL_INITIALIZERS=0 \ -DNDEBUG \ -fno-rtti \