Native rendering
This commit is contained in:
parent
58314c350d
commit
e5ebb96abb
11 changed files with 88 additions and 55 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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*/
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -266,7 +266,7 @@ class RenderingRulesHandler {
|
|||
string attr = attrsMap["name"];
|
||||
map<string, string> 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<string, string> attrsMap;
|
||||
|
|
|
@ -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 <MapDataObject* > 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 <MapDataObject* > mapDataObjects, SkCanvas* canvas,
|
|||
HMAP::hash_map<int, std::vector<int> > orderMap = sortObjectsByProperOrder(mapDataObjects, req, rc);
|
||||
std::set<int> keys;
|
||||
HMAP::hash_map<int, std::vector<int> >::iterator it = orderMap.begin();
|
||||
|
||||
while (it != orderMap.end()) {
|
||||
keys.insert(it->first);
|
||||
it++;
|
||||
}
|
||||
bool shadowDrawn = false;
|
||||
|
||||
for (std::set<int>::iterator ks = keys.begin(); ks != keys.end(); ks++) {
|
||||
if (!shadowDrawn && *ks >= rc->shadowLevelMin && *ks <= rc->shadowLevelMax && rc->getShadowRenderingMode() > 1) {
|
||||
for (std::set<int>::iterator ki = ks; ki != keys.end(); ki++) {
|
||||
|
@ -557,6 +556,7 @@ void doRendering(std::vector <MapDataObject* > 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 <MapDataObject* > 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);
|
||||
}
|
||||
|
|
1
Osmand-kernel/png/.gitignore
vendored
Normal file
1
Osmand-kernel/png/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
build
|
|
@ -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
|
||||
|
|
29
Osmand-kernel/png/Common.mk
Normal file
29
Osmand-kernel/png/Common.mk
Normal file
|
@ -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
|
||||
|
24
Osmand-kernel/png/Makefile
Normal file
24
Osmand-kernel/png/Makefile
Normal file
|
@ -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)
|
|
@ -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 \
|
||||
|
|
Loading…
Reference in a new issue