Initial part of native rendering improvement. Will not render icons, introduces only stability

This commit is contained in:
Alexey Pelykh 2012-03-02 18:24:06 +02:00
parent 8160cc5e5b
commit 8153fb8f70
21 changed files with 1377 additions and 1237 deletions

18
.gitmodules vendored Normal file
View file

@ -0,0 +1,18 @@
[submodule "OsmAnd/jni/jpeg/jpeg_library"]
path = OsmAnd/jni/jpeg/jpeg_library
url = https://android.googlesource.com/platform/external/jpeg.git
[submodule "OsmAnd/jni/skia/skia_library"]
path = OsmAnd/jni/skia/skia_library
url = https://android.googlesource.com/platform/external/skia.git
[submodule "OsmAnd/jni/png/png_library"]
path = OsmAnd/jni/png/png_library
url = https://android.googlesource.com/platform/external/libpng.git
[submodule "OsmAnd/jni/freetype/freetype_library"]
path = OsmAnd/jni/freetype/freetype_library
url = https://android.googlesource.com/platform/external/freetype.git
[submodule "OsmAnd/jni/expat/expat_library"]
path = OsmAnd/jni/expat/expat_library
url = https://android.googlesource.com/platform/external/expat.git
[submodule "OsmAnd/jni/gif/gif_library"]
path = OsmAnd/jni/gif/gif_library
url = https://android.googlesource.com/platform/external/giflib.git

@ -0,0 +1 @@
Subproject commit 28304159f2fea1f702929883c634e52755d6e74b

@ -0,0 +1 @@
Subproject commit 15321e16a085b9b5c85cf029aee86bf57b2e65c1

@ -0,0 +1 @@
Subproject commit b2597268aef084202a8c349d1cc072c03c6e22eb

@ -0,0 +1 @@
Subproject commit d4fad7f50f79626455d88523207e05b868819cd8

View file

@ -8,8 +8,8 @@ ifeq ($(PROTOBUF),)
endif
# Set 'skia' folder only if it's not externally set
ifeq ($(SKIA_ABS),)
SKIA_ABS := $(LOCAL_PATH)/../skia
ifeq ($(OSMAND_SKIA_ABS),)
OSMAND_SKIA_ABS := $(LOCAL_PATH)/../skia/skia_library
endif
# Name of the local module
@ -23,14 +23,15 @@ endif
# Include paths
LOCAL_C_INCLUDES := $(LOCAL_PATH) \
$(PROTOBUF) \
$(SKIA_ABS)/trunk/include/core \
$(SKIA_ABS)/trunk/include/utils \
$(SKIA_ABS)/trunk/include/config \
$(SKIA_ABS)/trunk/include/effects \
$(SKIA_ABS)/trunk/include/utils/android \
$(SKIA_ABS)/trunk/src/core
$(LOCAL_PATH)/../skia \
$(OSMAND_SKIA_ABS)/include/core \
$(OSMAND_SKIA_ABS)/include/images \
$(OSMAND_SKIA_ABS)/include/utils \
$(OSMAND_SKIA_ABS)/include/config \
$(OSMAND_SKIA_ABS)/include/effects \
$(OSMAND_SKIA_ABS)/include/utils/android \
$(OSMAND_SKIA_ABS)/src/core
LOCAL_CPP_EXTENSION := .cpp
LOCAL_SRC_FILES := \
common.cpp \
mapObjects.cpp \
@ -46,6 +47,11 @@ LOCAL_CFLAGS := \
-DSK_USE_POSIX_THREADS \
-DSK_RELEASE \
-DGR_RELEASE=1
ifdef OSMAND_PROFILE_NATIVE_OPERATIONS
LOCAL_CFLAGS += \
-DPROFILE_NATIVE_OPERATIONS
endif
ifneq ($(LOCAL_ARM_NEON),true)
LOCAL_STATIC_LIBRARIES := proto skia

View file

@ -83,7 +83,7 @@ struct SearchQuery {
}
bool isCancelled(){
return globalEnv()->GetBooleanField(o, interruptedField);
return getGlobalJniEnv()->GetBooleanField(o, interruptedField);
}
};
@ -361,7 +361,7 @@ void loadJniBinaryRead() {
extern "C" JNIEXPORT void JNICALL Java_net_osmand_plus_render_NativeOsmandLibrary_deleteSearchResult(JNIEnv* ienv,
jobject obj, jint searchResult) {
// DO NOT DO IT it can leads to messing thread that is not allowed
// setGlobalEnv(ienv);
// setGlobalJniEnv(ienv);
SearchResult* result = (SearchResult*) searchResult;
if(result != NULL){
delete result;
@ -690,7 +690,7 @@ extern "C" JNIEXPORT jint JNICALL Java_net_osmand_plus_render_NativeOsmandLibrar
jobject obj, jint sleft, jint sright, jint stop, jint sbottom, jint zoom, jstring mapName,
jobject renderingRuleSearchRequest, bool skipDuplicates, jint searchResult, jobject objInterrupted) {
// TODO skipDuplicates not supported
setGlobalEnv(ienv);
setGlobalJniEnv(ienv);
SearchResult* result = (SearchResult*) searchResult;
if(result == NULL) {
result = new SearchResult();
@ -702,9 +702,9 @@ extern "C" JNIEXPORT jint JNICALL Java_net_osmand_plus_render_NativeOsmandLibrar
}
BinaryMapFile* file = i->second;
RenderingRuleSearchRequest* req = initSearchRequest(renderingRuleSearchRequest);
jclass clObjInterrupted = globalEnv()->GetObjectClass(objInterrupted);
jclass clObjInterrupted = getGlobalJniEnv()->GetObjectClass(objInterrupted);
jfieldID interruptedField = getFid(clObjInterrupted, "interrupted", "Z");
globalEnv()->DeleteLocalRef(clObjInterrupted);
getGlobalJniEnv()->DeleteLocalRef(clObjInterrupted);
SearchQuery q(sleft,sright, stop, sbottom, req, objInterrupted, interruptedField);
fseek(file->f, 0, 0);
@ -757,7 +757,7 @@ extern "C" JNIEXPORT jint JNICALL Java_net_osmand_plus_render_NativeOsmandLibrar
extern "C" JNIEXPORT jboolean JNICALL Java_net_osmand_plus_render_NativeOsmandLibrary_initBinaryMapFile(JNIEnv* ienv,
jobject obj, jobject path) {
// Verify that the version of the library that we linked against is
setGlobalEnv(ienv);
setGlobalJniEnv(ienv);
const char* utf = ienv->GetStringUTFChars((jstring) path, NULL);
std::string inputName(utf);
ienv->ReleaseStringUTFChars((jstring) path, utf);

View file

@ -1,252 +1,366 @@
#ifndef _OSMAND_COMMON
#define _OSMAND_COMMON
#include <common.h>
#include <android/log.h>
#include <string>
#include <vector>
#include <hash_map>
#include <SkPath.h>
#include <SkBitmap.h>
#include <SkImageDecoder.h>
JNIEnv* globalE;
JavaVM* globalVM;
JNIEnv* globalEnv(){
return globalE;
}
#include "common.h"
JNIEnv* setGlobalEnv(JNIEnv* e) {
globalVM->GetEnv((void**)&globalE, JNI_VERSION_1_4);
// try to avoid problem with different thread attach
// globalE = e;
return globalE;
}
const char* const LOG_TAG = "net.osmand:native";
extern void loadJniCommon();
extern void loadJNIRenderingRules();
extern void loadJNIRendering();
extern void loadJniMapObjects();
extern void loadJniBinaryRead();
JavaVM* globalJVM = NULL;
JNIEnv* globalJniEnv = NULL;
extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
if(vm->GetEnv((void **)&globalE, JNI_VERSION_1_4)){
return JNI_ERR; /* JNI version not supported */
}
globalVM = vm;
loadJniCommon();
loadJNIRendering();
loadJNIRenderingRules();
loadJniMapObjects();
loadJniBinaryRead();
return JNI_VERSION_1_4;
}
//extern "C" JNIEXPORT jboolean JNICALL Java_net_osmand_plus_render_NativeOsmandLibrary_loadLibrary(JNIEnv* ienv) {}
jclass RenderingContextClass;
jfieldID RenderingContext_interrupted;
jclass RenderingIconsClass;
jmethodID RenderingIcons_getIcon;
jclass globalRef(jobject o)
JNIEnv* getGlobalJniEnv()
{
return (jclass) globalEnv()->NewGlobalRef( o);
return globalJniEnv;
}
jfieldID getFid(jclass cls,const char* fieldName, const char* sig )
JNIEnv* setGlobalJniEnv(JNIEnv* e)
{
return globalEnv()->GetFieldID( cls, fieldName, sig);
if(!globalJVM)
__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "No globalJVM set");
globalJVM->GetEnv((void**)&globalJniEnv, JNI_VERSION_1_6);
return globalJniEnv;
}
watcher::watcher() {
elapsedTime = 0;
enableFlag = true;
run = false;
}
void watcher::enable() {
enableFlag = true;
}
void watcher::disable() {
pause();
enableFlag = false;
}
void watcher::start() {
if (!enableFlag) {
return;
}
if (!run) {
clock_gettime(CLOCK_MONOTONIC, &startInit);
// gettimeofday(&startInit, NULL);
}
run = true;
}
void watcher::pause() {
if (!run) {
return;
}
clock_gettime(CLOCK_MONOTONIC, &endInit);
// gettimeofday(&endInit, NULL);
int sec = endInit.tv_sec - startInit.tv_sec;
if (sec > 0) {
elapsedTime += 1e9 * sec;
}
elapsedTime += endInit.tv_nsec - startInit.tv_nsec;
// elapsedTime += (endInit.tv_sec * 1000 + endInit.tv_usec / 1000)
// - (startInit.tv_sec * 1000 + startInit.tv_usec / 1000);
run = false;
}
int watcher::getElapsedTime() {
pause();
return elapsedTime / 1e6;
// Forward declarations
void loadJniCommon();
void loadJniRendering();
void loadJniRenderingRules();
void loadJniMapObjects();
void loadJniBinaryRead();
extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
{
if(vm->GetEnv((void **)&globalJniEnv, JNI_VERSION_1_6))
return JNI_ERR; /* JNI version not supported */
globalJVM = vm;
loadJniCommon();
loadJniRendering();
loadJniRenderingRules();
loadJniMapObjects();
loadJniBinaryRead();
__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "JNI_OnLoad completed");
return JNI_VERSION_1_6;
}
void throwNewException(const char* msg)
{
__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, msg);
getGlobalJniEnv()->ThrowNew(getGlobalJniEnv()->FindClass("java/lang/Exception"), msg);
}
jclass findClass(const char* className, bool mustHave/* = true*/)
{
jclass javaClass = getGlobalJniEnv()->FindClass(className);
if(!javaClass && mustHave)
throwNewException((std::string("Failed to find class ") + className).c_str());
return (jclass)newGlobalRef(javaClass);
}
jobject newGlobalRef(jobject o)
{
return getGlobalJniEnv()->NewGlobalRef(o);
}
jfieldID getFid(jclass cls, const char* fieldName, const char* sig)
{
jfieldID jfield = getGlobalJniEnv()->GetFieldID(cls, fieldName, sig);
if(!jfield)
throwNewException((std::string("Failed to find field ") + fieldName + std::string(" with signature ") + sig).c_str());
return jfield;
}
std::string getStringField(jobject o, jfieldID fid)
{
jstring st = (jstring) globalEnv()->GetObjectField(o, fid);
if(st == NULL)
jstring jstr = (jstring)getGlobalJniEnv()->GetObjectField(o, fid);
if(!jstr)
{
throwNewException("Failed to get object from field");
return std::string();
}
const char* utf = globalEnv()->GetStringUTFChars(st, NULL);
std::string res(utf);
globalEnv()->ReleaseStringUTFChars(st, utf);
globalEnv()->DeleteLocalRef(st);
return res;
const char* utfBytes = getGlobalJniEnv()->GetStringUTFChars(jstr, NULL);
//TODO: I'm not quite sure that if real unicode will happen here, this will work as expected
std::string result(utfBytes);
getGlobalJniEnv()->ReleaseStringUTFChars(jstr, utfBytes);
getGlobalJniEnv()->DeleteLocalRef(jstr);
return result;
}
std::string getString(jstring st) {
if (st == NULL) {
return EMPTY_STRING;
std::string getString(jstring jstr)
{
if(!jstr)
{
throwNewException("NULL jstring passed in");
return std::string();
}
const char* utf = globalEnv()->GetStringUTFChars(st, NULL);
std::string res(utf);
globalEnv()->ReleaseStringUTFChars(st, utf);
return res;
const char* utfBytes = getGlobalJniEnv()->GetStringUTFChars(jstr, NULL);
//TODO: I'm not quite sure that if real unicode will happen here, this will work as expected
std::string result(utfBytes);
getGlobalJniEnv()->ReleaseStringUTFChars(jstr, utfBytes);
return result;
}
std::string getStringMethod(jobject o, jmethodID fid)
{
return getString((jstring) globalEnv()->CallObjectMethod(o, fid));
return getString((jstring)getGlobalJniEnv()->CallObjectMethod(o, fid));
}
std::string getStringMethod(jobject o, jmethodID fid, int i)
{
return getString((jstring) globalEnv()->CallObjectMethod(o, fid, i));
return getString((jstring)getGlobalJniEnv()->CallObjectMethod(o, fid, i));
}
float getDensityValue(RenderingContext* rc, float val) {
if (rc -> highResMode && rc -> density > 1) {
return val * rc -> density * rc -> mapTextSize;
} else {
return val * rc -> mapTextSize;
}
jclass jclass_RenderingContext = NULL;
jfieldID jfield_RenderingContext_interrupted = NULL;
jclass jclass_RenderingIcons = NULL;
jmethodID jmethod_RenderingIcons_getIconAsByteBuffer = NULL;
jfieldID jfield_RenderingContext_leftX = NULL;
jfieldID jfield_RenderingContext_topY = NULL;
jfieldID jfield_RenderingContext_width = NULL;
jfieldID jfield_RenderingContext_height = NULL;
jfieldID jfield_RenderingContext_zoom = NULL;
jfieldID jfield_RenderingContext_rotate = NULL;
jfieldID jfield_RenderingContext_tileDivisor = NULL;
jfieldID jfield_RenderingContext_pointCount = NULL;
jfieldID jfield_RenderingContext_pointInsideCount = NULL;
jfieldID jfield_RenderingContext_visible = NULL;
jfieldID jfield_RenderingContext_allObjects = NULL;
jfieldID jfield_RenderingContext_cosRotateTileSize = NULL;
jfieldID jfield_RenderingContext_sinRotateTileSize = NULL;
jfieldID jfield_RenderingContext_density = NULL;
jfieldID jfield_RenderingContext_highResMode = NULL;
jfieldID jfield_RenderingContext_mapTextSize = NULL;
jfieldID jfield_RenderingContext_shadowRenderingMode = NULL;
jfieldID jfield_RenderingContext_shadowLevelMin = NULL;
jfieldID jfield_RenderingContext_shadowLevelMax = NULL;
jfieldID jfield_RenderingContext_ctx = NULL;
jfieldID jfield_RenderingContext_textRenderingTime = NULL;
jfieldID jfield_RenderingContext_lastRenderedKey = NULL;
void loadJniCommon()
{
jclass_RenderingContext = findClass("net/osmand/plus/render/OsmandRenderer$RenderingContext");
jfield_RenderingContext_interrupted = getFid(jclass_RenderingContext, "interrupted", "Z");
jfield_RenderingContext_leftX = getFid( jclass_RenderingContext, "leftX", "F" );
jfield_RenderingContext_topY = getFid( jclass_RenderingContext, "topY", "F" );
jfield_RenderingContext_width = getFid( jclass_RenderingContext, "width", "I" );
jfield_RenderingContext_height = getFid( jclass_RenderingContext, "height", "I" );
jfield_RenderingContext_zoom = getFid( jclass_RenderingContext, "zoom", "I" );
jfield_RenderingContext_rotate = getFid( jclass_RenderingContext, "rotate", "F" );
jfield_RenderingContext_tileDivisor = getFid( jclass_RenderingContext, "tileDivisor", "F" );
jfield_RenderingContext_pointCount = getFid( jclass_RenderingContext, "pointCount", "I" );
jfield_RenderingContext_pointInsideCount = getFid( jclass_RenderingContext, "pointInsideCount", "I" );
jfield_RenderingContext_visible = getFid( jclass_RenderingContext, "visible", "I" );
jfield_RenderingContext_allObjects = getFid( jclass_RenderingContext, "allObjects", "I" );
jfield_RenderingContext_cosRotateTileSize = getFid( jclass_RenderingContext, "cosRotateTileSize", "F" );
jfield_RenderingContext_sinRotateTileSize = getFid( jclass_RenderingContext, "sinRotateTileSize", "F" );
jfield_RenderingContext_density = getFid( jclass_RenderingContext, "density", "F" );
jfield_RenderingContext_highResMode = getFid( jclass_RenderingContext, "highResMode", "Z" );
jfield_RenderingContext_mapTextSize = getFid( jclass_RenderingContext, "mapTextSize", "F" );
jfield_RenderingContext_shadowRenderingMode = getFid( jclass_RenderingContext, "shadowRenderingMode", "I" );
jfield_RenderingContext_shadowLevelMin = getFid( jclass_RenderingContext, "shadowLevelMin", "I" );
jfield_RenderingContext_shadowLevelMax = getFid( jclass_RenderingContext, "shadowLevelMax", "I" );
jfield_RenderingContext_ctx = getFid( jclass_RenderingContext, "ctx", "Landroid/content/Context;" );
jfield_RenderingContext_textRenderingTime = getFid( jclass_RenderingContext, "textRenderingTime", "I" );
jfield_RenderingContext_lastRenderedKey = getFid( jclass_RenderingContext, "lastRenderedKey", "I" );
jclass_RenderingIcons = findClass("net/osmand/plus/render/RenderingIcons");
jmethod_RenderingIcons_getIconAsByteBuffer = getGlobalJniEnv()->GetStaticMethodID(jclass_RenderingIcons,
"getIconAsByteBuffer",
"(Landroid/content/Context;Ljava/lang/String;)Ljava/nio/ByteBuffer;");
}
SkBitmap* getNativeBitmap(jobject bmpObj){
if(bmpObj == NULL){
return NULL;
}
jclass bmpClass = globalEnv()->GetObjectClass(bmpObj);
SkBitmap* bmp = (SkBitmap*)globalEnv()->CallIntMethod(bmpObj, globalEnv()->GetMethodID(bmpClass, "ni", "()I"));
globalEnv()->DeleteLocalRef(bmpClass);
return bmp;
//TODO: Dead code
/*
void unloadJniCommon() {
getGlobalJniEnv()->DeleteGlobalRef(jclass_RenderingIcons);
getGlobalJniEnv()->DeleteGlobalRef(jclass_RenderingContext);
}
*/
void pullFromJavaRenderingContext(jobject jrc, RenderingContext* rc)
{
rc->leftX = getGlobalJniEnv()->GetFloatField( jrc, jfield_RenderingContext_leftX );
rc->topY = getGlobalJniEnv()->GetFloatField( jrc, jfield_RenderingContext_topY );
rc->width = getGlobalJniEnv()->GetIntField( jrc, jfield_RenderingContext_width );
rc->height = getGlobalJniEnv()->GetIntField( jrc, jfield_RenderingContext_height );
rc->zoom = getGlobalJniEnv()->GetIntField( jrc, jfield_RenderingContext_zoom );
rc->rotate = getGlobalJniEnv()->GetFloatField( jrc, jfield_RenderingContext_rotate );
rc->tileDivisor = getGlobalJniEnv()->GetFloatField( jrc, jfield_RenderingContext_tileDivisor );
rc->pointCount = getGlobalJniEnv()->GetIntField( jrc, jfield_RenderingContext_pointCount );
rc->pointInsideCount = getGlobalJniEnv()->GetIntField( jrc, jfield_RenderingContext_pointInsideCount );
rc->visible = getGlobalJniEnv()->GetIntField( jrc, jfield_RenderingContext_visible );
rc->allObjects = getGlobalJniEnv()->GetIntField( jrc, jfield_RenderingContext_allObjects );
rc->cosRotateTileSize = getGlobalJniEnv()->GetFloatField( jrc, jfield_RenderingContext_cosRotateTileSize );
rc->sinRotateTileSize = getGlobalJniEnv()->GetFloatField( jrc, jfield_RenderingContext_sinRotateTileSize );
rc->density = getGlobalJniEnv()->GetFloatField( jrc, jfield_RenderingContext_density );
rc->highResMode = getGlobalJniEnv()->GetBooleanField( jrc, jfield_RenderingContext_highResMode );
rc->mapTextSize = getGlobalJniEnv()->GetFloatField( jrc, jfield_RenderingContext_mapTextSize );
rc->shadowRenderingMode = getGlobalJniEnv()->GetIntField( jrc, jfield_RenderingContext_shadowRenderingMode );
rc->shadowLevelMin = getGlobalJniEnv()->GetIntField( jrc, jfield_RenderingContext_shadowLevelMin );
rc->shadowLevelMax = getGlobalJniEnv()->GetIntField( jrc, jfield_RenderingContext_shadowLevelMax );
rc->androidContext = getGlobalJniEnv()->GetObjectField(jrc, jfield_RenderingContext_ctx );
rc->lastRenderedKey = 0;
rc->javaRenderingContext = jrc;
}
void pushToJavaRenderingContext(jobject jrc, RenderingContext* rc)
{
getGlobalJniEnv()->SetIntField( jrc, jfield_RenderingContext_pointCount, rc->pointCount);
getGlobalJniEnv()->SetIntField( jrc, jfield_RenderingContext_pointInsideCount, rc->pointInsideCount);
getGlobalJniEnv()->SetIntField( jrc, jfield_RenderingContext_visible, rc->visible);
getGlobalJniEnv()->SetIntField( jrc, jfield_RenderingContext_allObjects, rc->allObjects);
getGlobalJniEnv()->SetIntField( jrc, jfield_RenderingContext_textRenderingTime, rc->textRendering.getElapsedTime());
getGlobalJniEnv()->SetIntField( jrc, jfield_RenderingContext_lastRenderedKey, rc->lastRenderedKey);
getGlobalJniEnv()->DeleteLocalRef(rc->androidContext);
}
TextDrawInfo::TextDrawInfo(std::string itext)
: text(itext)
, drawOnPath(false)
, path(NULL)
, pathRotate(0)
{
}
TextDrawInfo::~TextDrawInfo()
{
if (path)
delete path;
}
IconDrawInfo::IconDrawInfo()
: bmp(NULL)
{
}
RenderingContext::RenderingContext()
: javaRenderingContext(NULL)
, androidContext(NULL)
{
}
RenderingContext::~RenderingContext()
{
std::vector<TextDrawInfo*>::iterator itTextToDraw;
for(itTextToDraw = textToDraw.begin(); itTextToDraw != textToDraw.end(); ++itTextToDraw)
delete (*itTextToDraw);
}
bool RenderingContext::interrupted()
{
return getGlobalJniEnv()->GetBooleanField(javaRenderingContext, jfield_RenderingContext_interrupted);
}
float getDensityValue(RenderingContext* rc, float val)
{
if (rc->highResMode && rc->density > 1)
return val * rc->density * rc->mapTextSize;
else
return val * rc->mapTextSize;
}
ElapsedTimer::ElapsedTimer()
: elapsedTime(0)
, enableFlag(true)
, run(false)
{
}
void ElapsedTimer::enable()
{
enableFlag = true;
}
void ElapsedTimer::disable()
{
pause();
enableFlag = false;
}
void ElapsedTimer::start()
{
if (!enableFlag)
return;
if (!run)
clock_gettime(CLOCK_MONOTONIC, &startInit);
run = true;
}
void ElapsedTimer::pause()
{
if (!run)
return;
clock_gettime(CLOCK_MONOTONIC, &endInit);
int sec = endInit.tv_sec - startInit.tv_sec;
if (sec > 0)
elapsedTime += 1e9 * sec;
elapsedTime += endInit.tv_nsec - startInit.tv_nsec;
run = false;
}
int ElapsedTimer::getElapsedTime()
{
pause();
return elapsedTime / 1e6;
}
std::hash_map<std::string, SkBitmap*> cachedBitmaps;
SkBitmap* getCachedBitmap(RenderingContext* rc, std::string js)
SkBitmap* getCachedBitmap(RenderingContext* rc, std::string bitmapResource)
{
if (cachedBitmaps.find(js) != cachedBitmaps.end()) {
return cachedBitmaps[js];
}
// Try to find previously cached
std::hash_map<std::string, SkBitmap*>::iterator itPreviouslyCachedBitmap = cachedBitmaps.find(bitmapResource);
if (itPreviouslyCachedBitmap != cachedBitmaps.end())
return itPreviouslyCachedBitmap->second;
rc->nativeOperations.pause();
jstring jstr = globalEnv()->NewStringUTF(js.c_str());
jobject bmp = globalEnv()->CallStaticObjectMethod(RenderingIconsClass, RenderingIcons_getIcon, rc->androidContext, jstr);
SkBitmap* res = getNativeBitmap(bmp);
jstring jstr = getGlobalJniEnv()->NewStringUTF(bitmapResource.c_str());
jobject javaIconByteBuffer = getGlobalJniEnv()->CallStaticObjectMethod(jclass_RenderingIcons, jmethod_RenderingIcons_getIconAsByteBuffer, rc->androidContext, jstr);
if(!javaIconByteBuffer)
return NULL;
// Decode bitmap
SkBitmap* iconBitmap = new SkBitmap();
void* bitmapBuffer = getGlobalJniEnv()->GetDirectBufferAddress(javaIconByteBuffer);
size_t bufferLen = getGlobalJniEnv()->GetDirectBufferCapacity(javaIconByteBuffer);
//TODO: JPEG is badly supported! At the moment it needs sdcard to be present (sic). Patch that
if(!SkImageDecoder::DecodeMemory(bitmapBuffer, bufferLen, iconBitmap))
{
// Failed to decode
delete iconBitmap;
rc->nativeOperations.start();
getGlobalJniEnv()->DeleteLocalRef(javaIconByteBuffer);
getGlobalJniEnv()->DeleteLocalRef(jstr);
throwNewException((std::string("Failed to decode ") + bitmapResource).c_str());
return NULL;
}
cachedBitmaps[bitmapResource] = iconBitmap;
rc->nativeOperations.start();
globalEnv()->DeleteLocalRef(bmp);
globalEnv()->DeleteLocalRef(jstr);
if(res != NULL){
res = new SkBitmap(*res);
}
cachedBitmaps[js] = res;
return res;
getGlobalJniEnv()->DeleteLocalRef(javaIconByteBuffer);
getGlobalJniEnv()->DeleteLocalRef(jstr);
return iconBitmap;
}
void loadJniCommon() {
RenderingContextClass = globalRef(globalEnv()->FindClass("net/osmand/plus/render/OsmandRenderer$RenderingContext"));
RenderingContext_interrupted = getFid(RenderingContextClass, "interrupted", "Z");
RenderingIconsClass = globalRef(globalEnv()->FindClass("net/osmand/render/RenderingRule"));
RenderingIconsClass = globalRef(globalEnv()->FindClass("net/osmand/plus/render/RenderingIcons"));
RenderingIcons_getIcon = globalEnv()->GetStaticMethodID(RenderingIconsClass, "getIcon",
"(Landroid/content/Context;Ljava/lang/String;)Landroid/graphics/Bitmap;");
}
void unloadJniCommon() {
globalEnv()->DeleteGlobalRef(RenderingContextClass);
globalEnv()->DeleteGlobalRef(RenderingIconsClass);
}
void copyRenderingContext(jobject orc, RenderingContext* rc)
{
rc->leftX = globalEnv()->GetFloatField( orc, getFid( RenderingContextClass, "leftX", "F" ) );
rc->topY = globalEnv()->GetFloatField( orc, getFid( RenderingContextClass, "topY", "F" ) );
rc->width = globalEnv()->GetIntField( orc, getFid( RenderingContextClass, "width", "I" ) );
rc->height = globalEnv()->GetIntField( orc, getFid( RenderingContextClass, "height", "I" ) );
rc->zoom = globalEnv()->GetIntField( orc, getFid( RenderingContextClass, "zoom", "I" ) );
rc->rotate = globalEnv()->GetFloatField( orc, getFid( RenderingContextClass, "rotate", "F" ) );
rc->tileDivisor = globalEnv()->GetFloatField( orc, getFid( RenderingContextClass, "tileDivisor", "F" ) );
rc->pointCount = globalEnv()->GetIntField( orc, getFid( RenderingContextClass, "pointCount", "I" ) );
rc->pointInsideCount = globalEnv()->GetIntField( orc, getFid( RenderingContextClass, "pointInsideCount", "I" ) );
rc->visible = globalEnv()->GetIntField( orc, getFid( RenderingContextClass, "visible", "I" ) );
rc->allObjects = globalEnv()->GetIntField( orc, getFid( RenderingContextClass, "allObjects", "I" ) );
rc->cosRotateTileSize = globalEnv()->GetFloatField( orc, getFid( RenderingContextClass, "cosRotateTileSize", "F" ) );
rc->sinRotateTileSize = globalEnv()->GetFloatField( orc, getFid( RenderingContextClass, "sinRotateTileSize", "F" ) );
rc->density = globalEnv()->GetFloatField( orc, getFid( RenderingContextClass, "density", "F" ) );
rc->highResMode = globalEnv()->GetBooleanField( orc, getFid( RenderingContextClass, "highResMode", "Z" ) );
rc->mapTextSize = globalEnv()->GetFloatField( orc, getFid( RenderingContextClass, "mapTextSize", "F" ) );
rc->shadowRenderingMode = globalEnv()->GetIntField( orc, getFid( RenderingContextClass, "shadowRenderingMode", "I" ) );
rc->shadowLevelMin = globalEnv()->GetIntField( orc, getFid( RenderingContextClass, "shadowLevelMin", "I" ) );
rc->shadowLevelMax = globalEnv()->GetIntField( orc, getFid( RenderingContextClass, "shadowLevelMax", "I" ) );
rc->androidContext = globalEnv()->GetObjectField(orc, getFid( RenderingContextClass, "ctx", "Landroid/content/Context;"));
rc->lastRenderedKey = 0;
rc->originalRC = orc;
}
void mergeRenderingContext(jobject orc, RenderingContext* rc)
{
globalEnv()->SetIntField( orc, getFid(RenderingContextClass, "pointCount", "I" ) , rc->pointCount);
globalEnv()->SetIntField( orc, getFid(RenderingContextClass, "pointInsideCount", "I" ) , rc->pointInsideCount);
globalEnv()->SetIntField( orc, getFid(RenderingContextClass, "visible", "I" ) , rc->visible);
globalEnv()->SetIntField( orc, getFid(RenderingContextClass, "allObjects", "I" ) , rc->allObjects);
globalEnv()->SetIntField( orc, getFid(RenderingContextClass, "textRenderingTime", "I" ) , rc->textRendering.getElapsedTime());
globalEnv()->SetIntField( orc, getFid(RenderingContextClass, "lastRenderedKey", "I" ) , rc->lastRenderedKey);
globalEnv()->DeleteLocalRef(rc->androidContext);
}
#endif

View file

@ -5,107 +5,101 @@
#include <string>
#include <vector>
#include <hash_map>
#include <SkPath.h>
#include <SkBitmap.h>
// Constants
#define DEBUG_NAT_OPERATIONS
#ifdef DEBUG_NAT_OPERATIONS
#define NAT_COUNT(rc, op) rc->nativeOperations.pause(); op; rc->nativeOperations.start()
#ifdef PROFILE_NATIVE_OPERATIONS
#define PROFILE_NATIVE_OPERATION(rc, op) rc->nativeOperations.pause(); op; rc->nativeOperations.start()
#else
#define NAT_COUNT(rc, op) op;
#define PROFILE_NATIVE_OPERATION(rc, op) op;
#endif
const std::string EMPTY_STRING;
const int WHITE_COLOR = -1;
const int BLACK_COLOR = 0xff000000;
struct RenderingContext;
JNIEnv* globalEnv();
JNIEnv* getGlobalJniEnv();
JNIEnv* setGlobalJniEnv(JNIEnv*);
JNIEnv* setGlobalEnv(JNIEnv* e);
// Android helpers
extern const char* const LOG_TAG;
// JNI Helpers
//extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved);
void throwNewException(const char* msg);
jclass findClass(const char* className, bool mustHave = true);
std::string getString(jstring st);
std::string getStringMethod(jobject o, jmethodID fid, int i);
std::string getStringMethod(jobject o, jmethodID fid);
std::string getStringField(jobject o, jfieldID fid);
jclass globalRef(jobject o);
jfieldID getFid(jclass cls,const char* fieldName, const char* sig );
jobject newGlobalRef(jobject o);
jfieldID getFid(jclass cls, const char* fieldName, const char* sig);
void pullFromJavaRenderingContext(jobject jrc, RenderingContext* rc);
void pushToJavaRenderingContext(jobject jrc, RenderingContext* rc);
class watcher {
class ElapsedTimer
{
private:
long elapsedTime;
bool enableFlag;
// timeval startInit;
// timeval endInit;
timespec startInit;
timespec endInit;
bool run;
public:
watcher();
ElapsedTimer();
void enable();
void disable();
void start();
void pause();
int getElapsedTime();
};
// Rendering context methods
class TextDrawInfo {
public :
struct TextDrawInfo {
TextDrawInfo(std::string);
~TextDrawInfo();
std::string text;
TextDrawInfo(std::string itext) {
text = itext;
drawOnPath = false;
path = NULL;
pathRotate = 0;
}
SkRect bounds;
float centerX;
float centerY;
float textSize ;
float minDistance ;
float textSize;
float minDistance;
int textColor;
int textShadow ;
uint textWrap ;
bool bold ;
int textShadow;
uint textWrap;
bool bold;
std::string shieldRes;
int textOrder;
bool drawOnPath;
SkPath* path;
float pathRotate;
float vOffset ;
float hOffset ;
~TextDrawInfo() {
if (path != NULL) {
delete path;
}
}
float vOffset;
float hOffset;
};
struct IconDrawInfo {
struct IconDrawInfo
{
IconDrawInfo();
SkBitmap* bmp;
float x;
float y;
};
extern jfieldID RenderingContext_interrupted;
struct RenderingContext {
jobject originalRC;
struct RenderingContext
{
RenderingContext();
~RenderingContext();
bool interrupted();
jobject javaRenderingContext;
jobject androidContext;
bool useEnglishNames;
@ -130,9 +124,8 @@ struct RenderingContext {
int visible;
int allObjects;
int lastRenderedKey;
watcher textRendering;
watcher nativeOperations;
class ElapsedTimer textRendering;
class ElapsedTimer nativeOperations;
// use to calculate points
float calcX;
@ -146,23 +139,10 @@ struct RenderingContext {
// not expect any shadow
int shadowLevelMin;
int shadowLevelMax;
bool interrupted() {
return globalEnv()->GetBooleanField(originalRC, RenderingContext_interrupted);
}
~RenderingContext() {
for (uint i = 0; i < textToDraw.size(); i++) {
delete textToDraw.at(i);
}
}
};
void copyRenderingContext(jobject orc, RenderingContext* rc);
void mergeRenderingContext(jobject orc, RenderingContext* rc);
float getDensityValue(RenderingContext* rc, float val);
SkBitmap* getCachedBitmap(RenderingContext* rc, std::string js);
SkBitmap* getNativeBitmap(jobject bmpObj);
SkBitmap* getCachedBitmap(RenderingContext* rc, std::string bitmapResource);
#endif /*_OSMAND_COMMON_H*/

View file

@ -36,24 +36,24 @@ std::vector <BaseMapDataObject* > marshalObjects(jobjectArray binaryMapDataObjec
{
std::vector<BaseMapDataObject*> v;
const size_t size = globalEnv()->GetArrayLength(binaryMapDataObjects);
const size_t size = getGlobalJniEnv()->GetArrayLength(binaryMapDataObjects);
size_t i = 0;
for (; i < size; i++) {
jobject binaryMapDataObject = (jobject) globalEnv()->GetObjectArrayElement(binaryMapDataObjects, i);
if (globalEnv()->IsInstanceOf(binaryMapDataObject, MultiPolygonClass)) {
jobject binaryMapDataObject = (jobject) getGlobalJniEnv()->GetObjectArrayElement(binaryMapDataObjects, i);
if (getGlobalJniEnv()->IsInstanceOf(binaryMapDataObject, MultiPolygonClass)) {
MultiPolygonObject* o = new MultiPolygonObject();
v.push_back((BaseMapDataObject* )o);
o->layer = globalEnv()->CallIntMethod(binaryMapDataObject, MultiPolygon_getLayer);
o->layer = getGlobalJniEnv()->CallIntMethod(binaryMapDataObject, MultiPolygon_getLayer);
o->tag = getStringMethod(binaryMapDataObject, MultiPolygon_getTag);
o->value = getStringMethod(binaryMapDataObject, MultiPolygon_getValue);
int boundsCount = globalEnv()->CallIntMethod(binaryMapDataObject, MultiPolygon_getBoundsCount);
int boundsCount = getGlobalJniEnv()->CallIntMethod(binaryMapDataObject, MultiPolygon_getBoundsCount);
for (int ji = 0; ji < boundsCount; ji++) {
int cnt = globalEnv()->CallIntMethod(binaryMapDataObject, MultiPolygon_getBoundPointsCount, ji);
int cnt = getGlobalJniEnv()->CallIntMethod(binaryMapDataObject, MultiPolygon_getBoundPointsCount, ji);
std::vector<std::pair<int, int> > vs;
for (int js = 0; js < cnt; js++) {
int xt = globalEnv()->CallIntMethod(binaryMapDataObject, MultiPolygon_getPoint31XTile, js, ji);
int yt = globalEnv()->CallIntMethod(binaryMapDataObject, MultiPolygon_getPoint31YTile, js, ji);
int xt = getGlobalJniEnv()->CallIntMethod(binaryMapDataObject, MultiPolygon_getPoint31XTile, js, ji);
int yt = getGlobalJniEnv()->CallIntMethod(binaryMapDataObject, MultiPolygon_getPoint31YTile, js, ji);
vs.push_back( std::pair<int, int> (xt, yt) );
}
@ -64,40 +64,40 @@ std::vector <BaseMapDataObject* > marshalObjects(jobjectArray binaryMapDataObjec
} else {
jintArray types = (jintArray) globalEnv()->CallObjectMethod(binaryMapDataObject, BinaryMapDataObject_getTypes);
jintArray types = (jintArray) getGlobalJniEnv()->CallObjectMethod(binaryMapDataObject, BinaryMapDataObject_getTypes);
if (types != NULL) {
MapDataObject* o = new MapDataObject();
jint sizeTypes = globalEnv()->GetArrayLength(types);
jint* els = globalEnv()->GetIntArrayElements(types, NULL);
jint sizeTypes = getGlobalJniEnv()->GetArrayLength(types);
jint* els = getGlobalJniEnv()->GetIntArrayElements(types, NULL);
int j = 0;
for (; j < sizeTypes; j++) {
int wholeType = els[j];
o->types.push_back(wholeType);
jobject pair = globalEnv()->CallObjectMethod(binaryMapDataObject, BinaryMapDataObject_getTagValue, j);
jobject pair = getGlobalJniEnv()->CallObjectMethod(binaryMapDataObject, BinaryMapDataObject_getTagValue, j);
if (pair != NULL) {
std::string tag = getStringField(pair, TagValuePair_tag);
std::string value = getStringField(pair, TagValuePair_value);
o->tagValues.push_back( std::pair<std:: string, std::string>(tag, value));
globalEnv()->DeleteLocalRef(pair);
getGlobalJniEnv()->DeleteLocalRef(pair);
} else {
o->tagValues.push_back( std::pair<std:: string, std::string>(EMPTY_STRING, EMPTY_STRING));
o->tagValues.push_back( std::pair<std:: string, std::string>(std::string(), std::string()));
}
}
jint sizePoints = globalEnv()->CallIntMethod(binaryMapDataObject, BinaryMapDataObject_getPointsLength);
jint sizePoints = getGlobalJniEnv()->CallIntMethod(binaryMapDataObject, BinaryMapDataObject_getPointsLength);
for (j = 0; j < sizePoints; j++) {
int tx = globalEnv()->CallIntMethod(binaryMapDataObject, BinaryMapDataObject_getPoint31XTile, j);
int ty = globalEnv()->CallIntMethod(binaryMapDataObject, BinaryMapDataObject_getPoint31YTile, j);
int tx = getGlobalJniEnv()->CallIntMethod(binaryMapDataObject, BinaryMapDataObject_getPoint31XTile, j);
int ty = getGlobalJniEnv()->CallIntMethod(binaryMapDataObject, BinaryMapDataObject_getPoint31YTile, j);
o->points.push_back(std::pair<int, int>(tx, ty));
}
o->name = getStringMethod(binaryMapDataObject, BinaryMapDataObject_getName);
o->highwayAttributes = globalEnv()->CallIntMethod(binaryMapDataObject, BinaryMapDataObject_getHighwayAttributes);
globalEnv()->ReleaseIntArrayElements(types, els, JNI_ABORT);
globalEnv()->DeleteLocalRef(types);
o->highwayAttributes = getGlobalJniEnv()->CallIntMethod(binaryMapDataObject, BinaryMapDataObject_getHighwayAttributes);
getGlobalJniEnv()->ReleaseIntArrayElements(types, els, JNI_ABORT);
getGlobalJniEnv()->DeleteLocalRef(types);
v.push_back((BaseMapDataObject* )o);
}
}
globalEnv()->DeleteLocalRef(binaryMapDataObject);
getGlobalJniEnv()->DeleteLocalRef(binaryMapDataObject);
}
return v;
@ -115,38 +115,38 @@ void deleteObjects(std::vector <BaseMapDataObject* > & v)
void loadJniMapObjects()
{
MultiPolygonClass = globalRef(globalEnv()->FindClass("net/osmand/osm/MultyPolygon"));
MultiPolygon_getTag = globalEnv()->GetMethodID(MultiPolygonClass, "getTag", "()Ljava/lang/String;");
MultiPolygon_getValue = globalEnv()->GetMethodID(MultiPolygonClass, "getValue", "()Ljava/lang/String;");
MultiPolygon_getName = globalEnv()->GetMethodID(MultiPolygonClass, "getName", "(I)Ljava/lang/String;");
MultiPolygon_getLayer = globalEnv()->GetMethodID(MultiPolygonClass, "getLayer", "()I");
MultiPolygon_getPoint31XTile = globalEnv()->GetMethodID(MultiPolygonClass, "getPoint31XTile", "(II)I");
MultiPolygon_getPoint31YTile = globalEnv()->GetMethodID(MultiPolygonClass, "getPoint31YTile", "(II)I");
MultiPolygon_getBoundsCount = globalEnv()->GetMethodID(MultiPolygonClass, "getBoundsCount", "()I");
MultiPolygon_getBoundPointsCount = globalEnv()->GetMethodID(MultiPolygonClass, "getBoundPointsCount", "(I)I");
MultiPolygonClass = findClass("net/osmand/osm/MultyPolygon");
MultiPolygon_getTag = getGlobalJniEnv()->GetMethodID(MultiPolygonClass, "getTag", "()Ljava/lang/String;");
MultiPolygon_getValue = getGlobalJniEnv()->GetMethodID(MultiPolygonClass, "getValue", "()Ljava/lang/String;");
MultiPolygon_getName = getGlobalJniEnv()->GetMethodID(MultiPolygonClass, "getName", "(I)Ljava/lang/String;");
MultiPolygon_getLayer = getGlobalJniEnv()->GetMethodID(MultiPolygonClass, "getLayer", "()I");
MultiPolygon_getPoint31XTile = getGlobalJniEnv()->GetMethodID(MultiPolygonClass, "getPoint31XTile", "(II)I");
MultiPolygon_getPoint31YTile = getGlobalJniEnv()->GetMethodID(MultiPolygonClass, "getPoint31YTile", "(II)I");
MultiPolygon_getBoundsCount = getGlobalJniEnv()->GetMethodID(MultiPolygonClass, "getBoundsCount", "()I");
MultiPolygon_getBoundPointsCount = getGlobalJniEnv()->GetMethodID(MultiPolygonClass, "getBoundPointsCount", "(I)I");
BinaryMapDataObjectClass = globalRef(globalEnv()->FindClass("net/osmand/binary/BinaryMapDataObject"));
BinaryMapDataObject_getPointsLength = globalEnv()->GetMethodID(BinaryMapDataObjectClass, "getPointsLength", "()I");
BinaryMapDataObject_getPoint31YTile = globalEnv()->GetMethodID(BinaryMapDataObjectClass, "getPoint31YTile", "(I)I");
BinaryMapDataObject_getPoint31XTile = globalEnv()->GetMethodID(BinaryMapDataObjectClass, "getPoint31XTile", "(I)I");
BinaryMapDataObject_getHighwayAttributes = globalEnv()->GetMethodID(BinaryMapDataObjectClass, "getHighwayAttributes", "()I");
BinaryMapDataObject_getTypes = globalEnv()->GetMethodID(BinaryMapDataObjectClass, "getTypes", "()[I");
BinaryMapDataObject_getName = globalEnv()->GetMethodID(BinaryMapDataObjectClass, "getName", "()Ljava/lang/String;");
BinaryMapDataObject_getTagValue = globalEnv()->GetMethodID(BinaryMapDataObjectClass, "getTagValue",
BinaryMapDataObjectClass = findClass("net/osmand/binary/BinaryMapDataObject");
BinaryMapDataObject_getPointsLength = getGlobalJniEnv()->GetMethodID(BinaryMapDataObjectClass, "getPointsLength", "()I");
BinaryMapDataObject_getPoint31YTile = getGlobalJniEnv()->GetMethodID(BinaryMapDataObjectClass, "getPoint31YTile", "(I)I");
BinaryMapDataObject_getPoint31XTile = getGlobalJniEnv()->GetMethodID(BinaryMapDataObjectClass, "getPoint31XTile", "(I)I");
BinaryMapDataObject_getHighwayAttributes = getGlobalJniEnv()->GetMethodID(BinaryMapDataObjectClass, "getHighwayAttributes", "()I");
BinaryMapDataObject_getTypes = getGlobalJniEnv()->GetMethodID(BinaryMapDataObjectClass, "getTypes", "()[I");
BinaryMapDataObject_getName = getGlobalJniEnv()->GetMethodID(BinaryMapDataObjectClass, "getName", "()Ljava/lang/String;");
BinaryMapDataObject_getTagValue = getGlobalJniEnv()->GetMethodID(BinaryMapDataObjectClass, "getTagValue",
"(I)Lnet/osmand/binary/BinaryMapIndexReader$TagValuePair;");
TagValuePairClass = globalRef(globalEnv()->FindClass("net/osmand/binary/BinaryMapIndexReader$TagValuePair"));
TagValuePair_tag = globalEnv()->GetFieldID(TagValuePairClass, "tag", "Ljava/lang/String;");
TagValuePair_value = globalEnv()->GetFieldID(TagValuePairClass, "value", "Ljava/lang/String;");
TagValuePairClass = findClass("net/osmand/binary/BinaryMapIndexReader$TagValuePair");
TagValuePair_tag = getGlobalJniEnv()->GetFieldID(TagValuePairClass, "tag", "Ljava/lang/String;");
TagValuePair_value = getGlobalJniEnv()->GetFieldID(TagValuePairClass, "value", "Ljava/lang/String;");
}
void unloadJniMapObjects()
{
globalEnv()->DeleteGlobalRef( MultiPolygonClass );
globalEnv()->DeleteGlobalRef( BinaryMapDataObjectClass );
globalEnv()->DeleteGlobalRef( TagValuePairClass );
getGlobalJniEnv()->DeleteGlobalRef( MultiPolygonClass );
getGlobalJniEnv()->DeleteGlobalRef( BinaryMapDataObjectClass );
getGlobalJniEnv()->DeleteGlobalRef( TagValuePairClass );
}
int getNegativeWayLayer(int type) {

View file

@ -69,7 +69,7 @@ RenderingRuleProperty* RenderingRulesStorage::getProperty(const char* st) {
std::string RenderingRulesStorage::getDictionaryValue(int i) {
if (i < 0) {
return EMPTY_STRING;
return std::string();
}
return dictionary.at(i);
}
@ -79,54 +79,54 @@ int RenderingRulesStorage::getDictionaryValue(std::string s) {
}
void RenderingRulesStorage::initDictionary() {
jobject listDictionary = globalEnv()->GetObjectField(javaStorage, RenderingRulesStorageClass_dictionary);
uint sz = globalEnv()->CallIntMethod(listDictionary, List_size);
jobject listDictionary = getGlobalJniEnv()->GetObjectField(javaStorage, RenderingRulesStorageClass_dictionary);
uint sz = getGlobalJniEnv()->CallIntMethod(listDictionary, List_size);
uint i = 0;
for (; i < sz; i++) {
jstring st = (jstring) globalEnv()->CallObjectMethod(listDictionary, List_get, i);
jstring st = (jstring) getGlobalJniEnv()->CallObjectMethod(listDictionary, List_get, i);
// if(st != NULL)
// {
const char* utf = globalEnv()->GetStringUTFChars(st, NULL);
const char* utf = getGlobalJniEnv()->GetStringUTFChars(st, NULL);
std::string d = std::string(utf);
globalEnv()->ReleaseStringUTFChars(st, utf);
globalEnv()->DeleteLocalRef(st);
getGlobalJniEnv()->ReleaseStringUTFChars(st, utf);
getGlobalJniEnv()->DeleteLocalRef(st);
dictionary.push_back(d);
dictionaryMap[d] = i;
// }
}
globalEnv()->DeleteLocalRef(listDictionary);
getGlobalJniEnv()->DeleteLocalRef(listDictionary);
}
void RenderingRulesStorage::initProperties() {
jobject props = globalEnv()->GetObjectField(javaStorage, RenderingRulesStorage_PROPS);
jobject listProps = globalEnv()->GetObjectField(props, RenderingRuleStorageProperties_rules);
uint sz = globalEnv()->CallIntMethod(listProps, List_size);
jobject props = getGlobalJniEnv()->GetObjectField(javaStorage, RenderingRulesStorage_PROPS);
jobject listProps = getGlobalJniEnv()->GetObjectField(props, RenderingRuleStorageProperties_rules);
uint sz = getGlobalJniEnv()->CallIntMethod(listProps, List_size);
uint i = 0;
for (; i < sz; i++) {
jobject rulePrope = globalEnv()->CallObjectMethod(listProps, List_get, i);
bool input = (globalEnv()->GetBooleanField(rulePrope, RenderingRuleProperty_input) == JNI_TRUE);
int type = globalEnv()->GetIntField(rulePrope, RenderingRuleProperty_type);
jobject rulePrope = getGlobalJniEnv()->CallObjectMethod(listProps, List_get, i);
bool input = (getGlobalJniEnv()->GetBooleanField(rulePrope, RenderingRuleProperty_input) == JNI_TRUE);
int type = getGlobalJniEnv()->GetIntField(rulePrope, RenderingRuleProperty_type);
std::string name = getStringField(rulePrope, RenderingRuleProperty_attrName);
RenderingRuleProperty* prop = new RenderingRuleProperty(type, input, name, i);
properties.push_back(*prop);
propertyMap[name] = prop;
globalEnv()->DeleteLocalRef(rulePrope);
getGlobalJniEnv()->DeleteLocalRef(rulePrope);
}
globalEnv()->DeleteLocalRef(props);
globalEnv()->DeleteLocalRef(listProps);
getGlobalJniEnv()->DeleteLocalRef(props);
getGlobalJniEnv()->DeleteLocalRef(listProps);
}
void RenderingRulesStorage::initRules() {
for (int i = 1; i < SIZE_STATES; i++) {
jobjectArray rules = (jobjectArray) globalEnv()->CallObjectMethod(javaStorage, RenderingRulesStorage_getRules,
jobjectArray rules = (jobjectArray) getGlobalJniEnv()->CallObjectMethod(javaStorage, RenderingRulesStorage_getRules,
i);
jsize len = globalEnv()->GetArrayLength(rules);
jsize len = getGlobalJniEnv()->GetArrayLength(rules);
for (jsize j = 0; j < len; j++) {
jobject rRule = globalEnv()->GetObjectArrayElement(rules, j);
jobject rRule = getGlobalJniEnv()->GetObjectArrayElement(rules, j);
RenderingRule* rule = createRenderingRule(rRule);
globalEnv()->DeleteLocalRef(rRule);
getGlobalJniEnv()->DeleteLocalRef(rRule);
if (rule != NULL) {
jsize psz = rule->properties.size();
@ -145,69 +145,69 @@ void RenderingRulesStorage::initRules() {
}
}
}
globalEnv()->DeleteLocalRef(rules);
getGlobalJniEnv()->DeleteLocalRef(rules);
}
}
RenderingRule* RenderingRulesStorage::createRenderingRule(jobject rRule) {
RenderingRule* rule = new RenderingRule;
jobjectArray props = (jobjectArray) globalEnv()->GetObjectField(rRule, RenderingRule_properties);
jintArray intProps = (jintArray) globalEnv()->GetObjectField(rRule, RenderingRule_intProperties);
jfloatArray floatProps = (jfloatArray) globalEnv()->GetObjectField(rRule, RenderingRule_floatProperties);
jobject ifChildren = globalEnv()->GetObjectField(rRule, RenderingRule_ifChildren);
jobject ifElseChildren = globalEnv()->GetObjectField(rRule, RenderingRule_ifElseChildren);
jobjectArray props = (jobjectArray) getGlobalJniEnv()->GetObjectField(rRule, RenderingRule_properties);
jintArray intProps = (jintArray) getGlobalJniEnv()->GetObjectField(rRule, RenderingRule_intProperties);
jfloatArray floatProps = (jfloatArray) getGlobalJniEnv()->GetObjectField(rRule, RenderingRule_floatProperties);
jobject ifChildren = getGlobalJniEnv()->GetObjectField(rRule, RenderingRule_ifChildren);
jobject ifElseChildren = getGlobalJniEnv()->GetObjectField(rRule, RenderingRule_ifElseChildren);
jsize sz = globalEnv()->GetArrayLength(props);
jsize sz = getGlobalJniEnv()->GetArrayLength(props);
if (floatProps != NULL) {
jfloat* fe = globalEnv()->GetFloatArrayElements(floatProps, NULL);
jfloat* fe = getGlobalJniEnv()->GetFloatArrayElements(floatProps, NULL);
for (int j = 0; j < sz; j++) {
rule->floatProperties.push_back(fe[j]);
}
globalEnv()->ReleaseFloatArrayElements(floatProps, fe, JNI_ABORT);
globalEnv()->DeleteLocalRef(floatProps);
getGlobalJniEnv()->ReleaseFloatArrayElements(floatProps, fe, JNI_ABORT);
getGlobalJniEnv()->DeleteLocalRef(floatProps);
} else {
rule->floatProperties.assign(sz, 0);
}
if (intProps != NULL) {
jint* ie = globalEnv()->GetIntArrayElements(intProps, NULL);
jint* ie = getGlobalJniEnv()->GetIntArrayElements(intProps, NULL);
for (int j = 0; j < sz; j++) {
rule->intProperties.push_back(ie[j]);
}
globalEnv()->ReleaseIntArrayElements(intProps, ie, JNI_ABORT);
globalEnv()->DeleteLocalRef(intProps);
getGlobalJniEnv()->ReleaseIntArrayElements(intProps, ie, JNI_ABORT);
getGlobalJniEnv()->DeleteLocalRef(intProps);
} else {
rule->intProperties.assign(sz, -1);
}
for (jsize i = 0; i < sz; i++) {
jobject prop = globalEnv()->GetObjectArrayElement(props, i);
jobject prop = getGlobalJniEnv()->GetObjectArrayElement(props, i);
std::string attr = getStringField(prop, RenderingRuleProperty_attrName);
RenderingRuleProperty* p = getProperty(attr.c_str());
rule->properties.push_back(p);
globalEnv()->DeleteLocalRef(prop);
getGlobalJniEnv()->DeleteLocalRef(prop);
}
globalEnv()->DeleteLocalRef(props);
getGlobalJniEnv()->DeleteLocalRef(props);
if (ifChildren != NULL) {
sz = globalEnv()->CallIntMethod(ifChildren, List_size);
sz = getGlobalJniEnv()->CallIntMethod(ifChildren, List_size);
for (jsize i = 0; i < sz; i++) {
jobject o = globalEnv()->CallObjectMethod(ifChildren, List_get, i);
jobject o = getGlobalJniEnv()->CallObjectMethod(ifChildren, List_get, i);
rule->ifChildren.push_back(*createRenderingRule(o));
globalEnv()->DeleteLocalRef(o);
getGlobalJniEnv()->DeleteLocalRef(o);
}
globalEnv()->DeleteLocalRef(ifChildren);
getGlobalJniEnv()->DeleteLocalRef(ifChildren);
}
if (ifElseChildren != NULL) {
sz = globalEnv()->CallIntMethod(ifElseChildren, List_size);
sz = getGlobalJniEnv()->CallIntMethod(ifElseChildren, List_size);
for (jsize i = 0; i < sz; i++) {
jobject o = globalEnv()->CallObjectMethod(ifElseChildren, List_get, i);
jobject o = getGlobalJniEnv()->CallObjectMethod(ifElseChildren, List_get, i);
rule->ifElseChildren.push_back(*createRenderingRule(o));
globalEnv()->DeleteLocalRef(o);
getGlobalJniEnv()->DeleteLocalRef(o);
}
globalEnv()->DeleteLocalRef(ifElseChildren);
getGlobalJniEnv()->DeleteLocalRef(ifElseChildren);
}
return rule;
@ -218,67 +218,67 @@ RenderingRulesStorage* defaultStorage = NULL;
void RenderingRuleSearchRequest::initObject(jobject rrs) {
jsize sz;
jobjectArray oa = (jobjectArray) globalEnv()->GetObjectField(rrs, RenderingRuleSearchRequest_props);
sz = globalEnv()->GetArrayLength(oa);
jobjectArray oa = (jobjectArray) getGlobalJniEnv()->GetObjectField(rrs, RenderingRuleSearchRequest_props);
sz = getGlobalJniEnv()->GetArrayLength(oa);
std::vector<RenderingRuleProperty*> requestProps;
for (jsize i = 0; i < sz; i++) {
jobject prop = globalEnv()->GetObjectArrayElement(oa, i);
jobject prop = getGlobalJniEnv()->GetObjectArrayElement(oa, i);
std::string attr = getStringField(prop, RenderingRuleProperty_attrName);
RenderingRuleProperty* p = storage->getProperty(attr.c_str());
requestProps.push_back(p);
globalEnv()->DeleteLocalRef(prop);
getGlobalJniEnv()->DeleteLocalRef(prop);
}
globalEnv()->DeleteLocalRef(oa);
getGlobalJniEnv()->DeleteLocalRef(oa);
sz = storage->getPropertiesSize();
{
values = new int[sz];
jintArray ia = (jintArray) globalEnv()->GetObjectField(rrs, RenderingRuleSearchRequest_values);
jint* ie = globalEnv()->GetIntArrayElements(ia, NULL);
jintArray ia = (jintArray) getGlobalJniEnv()->GetObjectField(rrs, RenderingRuleSearchRequest_values);
jint* ie = getGlobalJniEnv()->GetIntArrayElements(ia, NULL);
for (int i = 0; i < sz; i++) {
values[requestProps.at(i)->id] = ie[i];
}
globalEnv()->ReleaseIntArrayElements(ia, ie, JNI_ABORT);
globalEnv()->DeleteLocalRef(ia);
getGlobalJniEnv()->ReleaseIntArrayElements(ia, ie, JNI_ABORT);
getGlobalJniEnv()->DeleteLocalRef(ia);
}
{
fvalues = new float[sz];
jfloatArray ia = (jfloatArray) globalEnv()->GetObjectField(rrs, RenderingRuleSearchRequest_fvalues);
jfloat* ie = globalEnv()->GetFloatArrayElements(ia, NULL);
jfloatArray ia = (jfloatArray) getGlobalJniEnv()->GetObjectField(rrs, RenderingRuleSearchRequest_fvalues);
jfloat* ie = getGlobalJniEnv()->GetFloatArrayElements(ia, NULL);
for (int i = 0; i < sz; i++) {
fvalues[requestProps.at(i)->id] = ie[i];
}
globalEnv()->ReleaseFloatArrayElements(ia, ie, JNI_ABORT);
globalEnv()->DeleteLocalRef(ia);
getGlobalJniEnv()->ReleaseFloatArrayElements(ia, ie, JNI_ABORT);
getGlobalJniEnv()->DeleteLocalRef(ia);
}
{
savedValues = new int[sz];
jintArray ia = (jintArray) globalEnv()->GetObjectField(rrs, RenderingRuleSearchRequest_values);
jint* ie = globalEnv()->GetIntArrayElements(ia, NULL);
jintArray ia = (jintArray) getGlobalJniEnv()->GetObjectField(rrs, RenderingRuleSearchRequest_values);
jint* ie = getGlobalJniEnv()->GetIntArrayElements(ia, NULL);
for (int i = 0; i < sz; i++) {
savedValues[requestProps.at(i)->id] = ie[i];
}
globalEnv()->ReleaseIntArrayElements(ia, ie, JNI_ABORT);
globalEnv()->DeleteLocalRef(ia);
getGlobalJniEnv()->ReleaseIntArrayElements(ia, ie, JNI_ABORT);
getGlobalJniEnv()->DeleteLocalRef(ia);
}
{
savedFvalues = new float[sz];
jfloatArray ia = (jfloatArray) globalEnv()->GetObjectField(rrs, RenderingRuleSearchRequest_fvalues);
jfloat* ie = globalEnv()->GetFloatArrayElements(ia, NULL);
jfloatArray ia = (jfloatArray) getGlobalJniEnv()->GetObjectField(rrs, RenderingRuleSearchRequest_fvalues);
jfloat* ie = getGlobalJniEnv()->GetFloatArrayElements(ia, NULL);
for (int i = 0; i < sz; i++) {
savedFvalues[requestProps.at(i)->id] = ie[i];
}
globalEnv()->ReleaseFloatArrayElements(ia, ie, JNI_ABORT);
globalEnv()->DeleteLocalRef(ia);
getGlobalJniEnv()->ReleaseFloatArrayElements(ia, ie, JNI_ABORT);
getGlobalJniEnv()->DeleteLocalRef(ia);
}
}
extern "C" JNIEXPORT void JNICALL Java_net_osmand_plus_render_NativeOsmandLibrary_initRenderingRulesStorage(JNIEnv* ienv,
jobject obj, jobject storage) {
setGlobalEnv(ienv);
setGlobalJniEnv(ienv);
if (defaultStorage == NULL || defaultStorage->javaStorage != storage) {
// multi thread will not work?
if (defaultStorage != NULL) {
@ -291,7 +291,7 @@ extern "C" JNIEXPORT void JNICALL Java_net_osmand_plus_render_NativeOsmandLibrar
RenderingRuleSearchRequest::RenderingRuleSearchRequest(jobject rrs) :
renderingRuleSearch(rrs) {
jobject storage = globalEnv()->GetObjectField(rrs, RenderingRuleSearchRequest_storage);
jobject storage = getGlobalJniEnv()->GetObjectField(rrs, RenderingRuleSearchRequest_storage);
if (defaultStorage == NULL || defaultStorage->javaStorage != storage) {
// multi thread will not work?
if (defaultStorage != NULL) {
@ -299,7 +299,7 @@ RenderingRuleSearchRequest::RenderingRuleSearchRequest(jobject rrs) :
}
defaultStorage = new RenderingRulesStorage(storage);
}
globalEnv()->DeleteLocalRef(storage);
getGlobalJniEnv()->DeleteLocalRef(storage);
this->storage = defaultStorage;
PROPS = new RenderingRulesStorageProperties(this->storage);
initObject(rrs);
@ -330,7 +330,7 @@ int RenderingRuleSearchRequest::getIntPropertyValue(RenderingRuleProperty* prop,
std::string RenderingRuleSearchRequest::getStringPropertyValue(RenderingRuleProperty* prop) {
if (prop == NULL) {
return EMPTY_STRING;
return std::string();
}
int s = values[prop->id];
return storage->getDictionaryValue(s);
@ -486,59 +486,58 @@ RenderingRuleSearchRequest* initSearchRequest(jobject renderingRuleSearchRequest
return new RenderingRuleSearchRequest(renderingRuleSearchRequest);
}
void loadJNIRenderingRules() {
RenderingRuleClass = globalRef(globalEnv()->FindClass("net/osmand/render/RenderingRule"));
RenderingRule_properties = globalEnv()->GetFieldID(RenderingRuleClass, "properties",
void loadJniRenderingRules() {
RenderingRuleClass = findClass("net/osmand/render/RenderingRule");
RenderingRule_properties = getGlobalJniEnv()->GetFieldID(RenderingRuleClass, "properties",
"[Lnet/osmand/render/RenderingRuleProperty;");
RenderingRule_intProperties = globalEnv()->GetFieldID(RenderingRuleClass, "intProperties", "[I");
RenderingRule_floatProperties = globalEnv()->GetFieldID(RenderingRuleClass, "floatProperties", "[F");
RenderingRule_ifElseChildren = globalEnv()->GetFieldID(RenderingRuleClass, "ifElseChildren", "Ljava/util/List;");
RenderingRule_ifChildren = globalEnv()->GetFieldID(RenderingRuleClass, "ifChildren", "Ljava/util/List;");
RenderingRule_intProperties = getGlobalJniEnv()->GetFieldID(RenderingRuleClass, "intProperties", "[I");
RenderingRule_floatProperties = getGlobalJniEnv()->GetFieldID(RenderingRuleClass, "floatProperties", "[F");
RenderingRule_ifElseChildren = getGlobalJniEnv()->GetFieldID(RenderingRuleClass, "ifElseChildren", "Ljava/util/List;");
RenderingRule_ifChildren = getGlobalJniEnv()->GetFieldID(RenderingRuleClass, "ifChildren", "Ljava/util/List;");
RenderingRuleStoragePropertiesClass = globalRef(
globalEnv()->FindClass("net/osmand/render/RenderingRuleStorageProperties"));
RenderingRuleStorageProperties_rules = globalEnv()->GetFieldID(RenderingRuleStoragePropertiesClass, "rules",
RenderingRuleStoragePropertiesClass = findClass("net/osmand/render/RenderingRuleStorageProperties");
RenderingRuleStorageProperties_rules = getGlobalJniEnv()->GetFieldID(RenderingRuleStoragePropertiesClass, "rules",
"Ljava/util/List;");
RenderingRulePropertyClass = globalRef(globalEnv()->FindClass("net/osmand/render/RenderingRuleProperty"));
RenderingRuleProperty_type = globalEnv()->GetFieldID(RenderingRulePropertyClass, "type", "I");
RenderingRuleProperty_input = globalEnv()->GetFieldID(RenderingRulePropertyClass, "input", "Z");
RenderingRuleProperty_attrName = globalEnv()->GetFieldID(RenderingRulePropertyClass, "attrName",
RenderingRulePropertyClass = findClass("net/osmand/render/RenderingRuleProperty");
RenderingRuleProperty_type = getGlobalJniEnv()->GetFieldID(RenderingRulePropertyClass, "type", "I");
RenderingRuleProperty_input = getGlobalJniEnv()->GetFieldID(RenderingRulePropertyClass, "input", "Z");
RenderingRuleProperty_attrName = getGlobalJniEnv()->GetFieldID(RenderingRulePropertyClass, "attrName",
"Ljava/lang/String;");
RenderingRulesStorageClass = globalRef(globalEnv()->FindClass("net/osmand/render/RenderingRulesStorage"));
RenderingRulesStorageClass_dictionary = globalEnv()->GetFieldID(RenderingRulesStorageClass, "dictionary",
RenderingRulesStorageClass = findClass("net/osmand/render/RenderingRulesStorage");
RenderingRulesStorageClass_dictionary = getGlobalJniEnv()->GetFieldID(RenderingRulesStorageClass, "dictionary",
"Ljava/util/List;");
RenderingRulesStorage_PROPS = globalEnv()->GetFieldID(RenderingRulesStorageClass, "PROPS",
RenderingRulesStorage_PROPS = getGlobalJniEnv()->GetFieldID(RenderingRulesStorageClass, "PROPS",
"Lnet/osmand/render/RenderingRuleStorageProperties;");
RenderingRulesStorage_getRules = globalEnv()->GetMethodID(RenderingRulesStorageClass, "getRules",
RenderingRulesStorage_getRules = getGlobalJniEnv()->GetMethodID(RenderingRulesStorageClass, "getRules",
"(I)[Lnet/osmand/render/RenderingRule;");
ListClass = globalRef(globalEnv()->FindClass("java/util/List"));
List_size = globalEnv()->GetMethodID(ListClass, "size", "()I");
List_get = globalEnv()->GetMethodID(ListClass, "get", "(I)Ljava/lang/Object;");
ListClass = findClass("java/util/List");
List_size = getGlobalJniEnv()->GetMethodID(ListClass, "size", "()I");
List_get = getGlobalJniEnv()->GetMethodID(ListClass, "get", "(I)Ljava/lang/Object;");
RenderingRuleSearchRequestClass = globalRef(globalEnv()->FindClass("net/osmand/render/RenderingRuleSearchRequest"));
RenderingRuleSearchRequest_storage = globalEnv()->GetFieldID(RenderingRuleSearchRequestClass, "storage",
RenderingRuleSearchRequestClass = findClass("net/osmand/render/RenderingRuleSearchRequest");
RenderingRuleSearchRequest_storage = getGlobalJniEnv()->GetFieldID(RenderingRuleSearchRequestClass, "storage",
"Lnet/osmand/render/RenderingRulesStorage;");
RenderingRuleSearchRequest_props = globalEnv()->GetFieldID(RenderingRuleSearchRequestClass, "props",
RenderingRuleSearchRequest_props = getGlobalJniEnv()->GetFieldID(RenderingRuleSearchRequestClass, "props",
"[Lnet/osmand/render/RenderingRuleProperty;");
RenderingRuleSearchRequest_values = globalEnv()->GetFieldID(RenderingRuleSearchRequestClass, "values", "[I");
RenderingRuleSearchRequest_fvalues = globalEnv()->GetFieldID(RenderingRuleSearchRequestClass, "fvalues", "[F");
RenderingRuleSearchRequest_savedValues = globalEnv()->GetFieldID(RenderingRuleSearchRequestClass, "savedValues",
RenderingRuleSearchRequest_values = getGlobalJniEnv()->GetFieldID(RenderingRuleSearchRequestClass, "values", "[I");
RenderingRuleSearchRequest_fvalues = getGlobalJniEnv()->GetFieldID(RenderingRuleSearchRequestClass, "fvalues", "[F");
RenderingRuleSearchRequest_savedValues = getGlobalJniEnv()->GetFieldID(RenderingRuleSearchRequestClass, "savedValues",
"[I");
RenderingRuleSearchRequest_savedFvalues = globalEnv()->GetFieldID(RenderingRuleSearchRequestClass, "savedFvalues",
RenderingRuleSearchRequest_savedFvalues = getGlobalJniEnv()->GetFieldID(RenderingRuleSearchRequestClass, "savedFvalues",
"[F");
}
void unloadJniRenderRules() {
globalEnv()->DeleteGlobalRef(RenderingRuleSearchRequestClass);
globalEnv()->DeleteGlobalRef(RenderingRuleClass);
globalEnv()->DeleteGlobalRef(RenderingRulePropertyClass);
globalEnv()->DeleteGlobalRef(RenderingRuleStoragePropertiesClass);
globalEnv()->DeleteGlobalRef(RenderingRulesStorageClass);
globalEnv()->DeleteGlobalRef(ListClass);
getGlobalJniEnv()->DeleteGlobalRef(RenderingRuleSearchRequestClass);
getGlobalJniEnv()->DeleteGlobalRef(RenderingRuleClass);
getGlobalJniEnv()->DeleteGlobalRef(RenderingRulePropertyClass);
getGlobalJniEnv()->DeleteGlobalRef(RenderingRuleStoragePropertiesClass);
getGlobalJniEnv()->DeleteGlobalRef(RenderingRulesStorageClass);
getGlobalJniEnv()->DeleteGlobalRef(ListClass);
}

File diff suppressed because it is too large Load diff

View file

@ -193,10 +193,10 @@ void drawWrappedText(RenderingContext* rc, SkCanvas* cv, TextDrawInfo* text, flo
pos++;
}
if(lastSpace == -1) {
NAT_COUNT(rc, drawTextOnCanvas(cv, text->text.substr(start, pos), text->centerX, text->centerY + line * (textSize + 2), paintText, text->textShadow));
PROFILE_NATIVE_OPERATION(rc, drawTextOnCanvas(cv, text->text.substr(start, pos), text->centerX, text->centerY + line * (textSize + 2), paintText, text->textShadow));
start = pos;
} else {
NAT_COUNT(rc, drawTextOnCanvas(cv, text->text.substr(start, lastSpace), text->centerX, text->centerY + line * (textSize + 2), paintText, text->textShadow));
PROFILE_NATIVE_OPERATION(rc, drawTextOnCanvas(cv, text->text.substr(start, lastSpace), text->centerX, text->centerY + line * (textSize + 2), paintText, text->textShadow));
start = lastSpace + 1;
limit += (start - pos) - 1;
}
@ -204,7 +204,7 @@ void drawWrappedText(RenderingContext* rc, SkCanvas* cv, TextDrawInfo* text, flo
}
} else {
NAT_COUNT(rc, drawTextOnCanvas(cv, text->text, text->centerX, text->centerY, paintText, text->textShadow));
PROFILE_NATIVE_OPERATION(rc, drawTextOnCanvas(cv, text->text, text->centerX, text->centerY, paintText, text->textShadow));
}
}
@ -514,7 +514,7 @@ void drawTextOverCanvas(RenderingContext* rc, SkCanvas* cv) {
}
if (text->drawOnPath && text->path != NULL) {
if (text->textShadow > 0) {
paintText.setColor(WHITE_COLOR);
paintText.setColor(0xFFFFFFFF);
paintText.setStyle(SkPaint::kStroke_Style);
paintText.setStrokeWidth(2 + text->textShadow);
rc->nativeOperations.pause();

@ -0,0 +1 @@
Subproject commit 17b24482db9fb75020b91a9c17f2014beebc86ed

View file

@ -1,13 +0,0 @@
# To develop Skia targeting Android,
# copy this file to your root development directory as ".gclient"
# and then run "gclient sync".
solutions = [
{
"name" : "android",
"url" : "https://skia.googlecode.com/svn/android",
},
{
"name" : "trunk",
"url" : "https://skia.googlecode.com/svn/trunk",
},
]

View file

@ -1,6 +0,0 @@
*
!.gitignore
!.gclient
!Android.mk
!FakeHost.mk
!FontHostConfiguration_android.cpp

View file

@ -11,11 +11,27 @@ LOCAL_MODULE := skia_neon
LOCAL_ARM_NEON := true
endif
ifeq ($(SKIA_LOC),)
SKIA_LOC := .
ifeq ($(OSMAND_SKIA_LOC),)
OSMAND_SKIA_LOC := ./skia_library
endif
ifeq ($(SKIA_ABS),)
SKIA_ABS := $(LOCAL_PATH)
ifeq ($(OSMAND_SKIA_ABS),)
OSMAND_SKIA_ABS := $(LOCAL_PATH)/skia_library
endif
ifeq ($(OSMAND_FREETYPE_ABS),)
OSMAND_FREETYPE_ABS := $(LOCAL_PATH)/../freetype/freetype_library
endif
ifeq ($(OSMAND_PNG_ABS),)
OSMAND_PNG_ABS := $(LOCAL_PATH)/../png/png_library
endif
ifeq ($(OSMAND_GIF_ABS),)
OSMAND_GIF_ABS := $(LOCAL_PATH)/../gif/gif_library
endif
ifeq ($(OSMAND_EXPAT_ABS),)
OSMAND_EXPAT_ABS := $(LOCAL_PATH)/../expat/expat_library
endif
ifeq ($(OSMAND_JPEG_ABS),)
OSMAND_JPEG_ABS := $(LOCAL_PATH)/../jpeg/jpeg_library
endif
LOCAL_ARM_MODE := arm
@ -35,251 +51,259 @@ ifeq ($(LOCAL_ARM_NEON),true)
endif
LOCAL_SRC_FILES := \
$(SKIA_LOC)/trunk/src/core/Sk64.cpp \
$(SKIA_LOC)/trunk/src/core/SkAAClip.cpp \
$(SKIA_LOC)/trunk/src/core/SkAdvancedTypefaceMetrics.cpp \
$(SKIA_LOC)/trunk/src/core/SkAlphaRuns.cpp \
$(SKIA_LOC)/trunk/src/core/SkBitmap.cpp \
$(SKIA_LOC)/trunk/src/core/SkBitmapProcShader.cpp \
$(SKIA_LOC)/trunk/src/core/SkBitmapProcState.cpp \
$(SKIA_LOC)/trunk/src/core/SkBitmapProcState_matrixProcs.cpp \
$(SKIA_LOC)/trunk/src/core/SkBitmapSampler.cpp \
$(SKIA_LOC)/trunk/src/core/SkBitmap_scroll.cpp \
$(SKIA_LOC)/trunk/src/core/SkBlitMask_D32.cpp \
$(SKIA_LOC)/trunk/src/core/SkBlitRow_D16.cpp \
$(SKIA_LOC)/trunk/src/core/SkBlitRow_D32.cpp \
$(SKIA_LOC)/trunk/src/core/SkBlitRow_D4444.cpp \
$(SKIA_LOC)/trunk/src/core/SkBlitter.cpp \
$(SKIA_LOC)/trunk/src/core/SkBlitter_4444.cpp \
$(SKIA_LOC)/trunk/src/core/SkBlitter_A1.cpp \
$(SKIA_LOC)/trunk/src/core/SkBlitter_A8.cpp \
$(SKIA_LOC)/trunk/src/core/SkBlitter_ARGB32.cpp \
$(SKIA_LOC)/trunk/src/core/SkBlitter_RGB16.cpp \
$(SKIA_LOC)/trunk/src/core/SkBlitter_Sprite.cpp \
$(SKIA_LOC)/trunk/src/core/SkBuffer.cpp \
$(SKIA_LOC)/trunk/src/core/SkCanvas.cpp \
$(SKIA_LOC)/trunk/src/core/SkChunkAlloc.cpp \
$(SKIA_LOC)/trunk/src/core/SkClampRange.cpp \
$(SKIA_LOC)/trunk/src/core/SkClipStack.cpp \
$(SKIA_LOC)/trunk/src/core/SkColor.cpp \
$(SKIA_LOC)/trunk/src/core/SkColorFilter.cpp \
$(SKIA_LOC)/trunk/src/core/SkColorTable.cpp \
$(SKIA_LOC)/trunk/src/core/SkConfig8888.cpp \
$(SKIA_LOC)/trunk/src/core/SkComposeShader.cpp \
$(SKIA_LOC)/trunk/src/core/SkConcaveToTriangles.cpp \
$(SKIA_LOC)/trunk/src/core/SkCordic.cpp \
$(SKIA_LOC)/trunk/src/core/SkCubicClipper.cpp \
$(SKIA_LOC)/trunk/src/core/SkData.cpp \
$(SKIA_LOC)/trunk/src/core/SkDebug.cpp \
$(SKIA_LOC)/trunk/src/core/SkDeque.cpp \
$(SKIA_LOC)/trunk/src/core/SkDevice.cpp \
$(SKIA_LOC)/trunk/src/core/SkDither.cpp \
$(SKIA_LOC)/trunk/src/core/SkDraw.cpp \
$(SKIA_LOC)/trunk/src/core/SkEdgeBuilder.cpp \
$(SKIA_LOC)/trunk/src/core/SkEdgeClipper.cpp \
$(SKIA_LOC)/trunk/src/core/SkEdge.cpp \
$(SKIA_LOC)/trunk/src/core/SkFilterProc.cpp \
$(SKIA_LOC)/trunk/src/core/SkFlattenable.cpp \
$(SKIA_LOC)/trunk/src/core/SkFloat.cpp \
$(SKIA_LOC)/trunk/src/core/SkFloatBits.cpp \
$(SKIA_LOC)/trunk/src/core/SkFontHost.cpp \
$(SKIA_LOC)/trunk/src/core/SkGeometry.cpp \
$(SKIA_LOC)/trunk/src/core/SkGlyphCache.cpp \
$(SKIA_LOC)/trunk/src/core/SkGraphics.cpp \
$(SKIA_LOC)/trunk/src/core/SkLineClipper.cpp \
$(SKIA_LOC)/trunk/src/core/SkMallocPixelRef.cpp \
$(SKIA_LOC)/trunk/src/core/SkMask.cpp \
$(SKIA_LOC)/trunk/src/core/SkMaskFilter.cpp \
$(SKIA_LOC)/trunk/src/core/SkMath.cpp \
$(SKIA_LOC)/trunk/src/core/SkMatrix.cpp \
$(SKIA_LOC)/trunk/src/core/SkMetaData.cpp \
$(SKIA_LOC)/trunk/src/core/SkMMapStream.cpp \
$(SKIA_LOC)/trunk/src/core/SkPackBits.cpp \
$(SKIA_LOC)/trunk/src/core/SkPaint.cpp \
$(SKIA_LOC)/trunk/src/core/SkPath.cpp \
$(SKIA_LOC)/trunk/src/core/SkPathEffect.cpp \
$(SKIA_LOC)/trunk/src/core/SkPathHeap.cpp \
$(SKIA_LOC)/trunk/src/core/SkPathMeasure.cpp \
$(SKIA_LOC)/trunk/src/core/SkPicture.cpp \
$(SKIA_LOC)/trunk/src/core/SkPictureFlat.cpp \
$(SKIA_LOC)/trunk/src/core/SkPicturePlayback.cpp \
$(SKIA_LOC)/trunk/src/core/SkPictureRecord.cpp \
$(SKIA_LOC)/trunk/src/core/SkPixelRef.cpp \
$(SKIA_LOC)/trunk/src/core/SkPoint.cpp \
$(SKIA_LOC)/trunk/src/core/SkProcSpriteBlitter.cpp \
$(SKIA_LOC)/trunk/src/core/SkPtrRecorder.cpp \
$(SKIA_LOC)/trunk/src/core/SkQuadClipper.cpp \
$(SKIA_LOC)/trunk/src/core/SkRasterClip.cpp \
$(SKIA_LOC)/trunk/src/core/SkRasterizer.cpp \
$(SKIA_LOC)/trunk/src/core/SkRect.cpp \
$(SKIA_LOC)/trunk/src/core/SkRefDict.cpp \
$(SKIA_LOC)/trunk/src/core/SkRegion.cpp \
$(SKIA_LOC)/trunk/src/core/SkRegion_path.cpp \
$(SKIA_LOC)/trunk/src/core/SkScalar.cpp \
$(SKIA_LOC)/trunk/src/core/SkScalerContext.cpp \
$(SKIA_LOC)/trunk/src/core/SkScan.cpp \
$(SKIA_LOC)/trunk/src/core/SkScan_AntiPath.cpp \
$(SKIA_LOC)/trunk/src/core/SkScan_Antihair.cpp \
$(SKIA_LOC)/trunk/src/core/SkScan_Hairline.cpp \
$(SKIA_LOC)/trunk/src/core/SkScan_Path.cpp \
$(SKIA_LOC)/trunk/src/core/SkShader.cpp \
$(SKIA_LOC)/trunk/src/core/SkShape.cpp \
$(SKIA_LOC)/trunk/src/core/SkSpriteBlitter_ARGB32.cpp \
$(SKIA_LOC)/trunk/src/core/SkSpriteBlitter_RGB16.cpp \
$(SKIA_LOC)/trunk/src/core/SkStream.cpp \
$(SKIA_LOC)/trunk/src/core/SkString.cpp \
$(SKIA_LOC)/trunk/src/core/SkStroke.cpp \
$(SKIA_LOC)/trunk/src/core/SkStrokerPriv.cpp \
$(SKIA_LOC)/trunk/src/core/SkTSearch.cpp \
$(SKIA_LOC)/trunk/src/core/SkTypeface.cpp \
$(SKIA_LOC)/trunk/src/core/SkTypefaceCache.cpp \
$(SKIA_LOC)/trunk/src/core/SkUnPreMultiply.cpp \
$(SKIA_LOC)/trunk/src/core/SkUtils.cpp \
$(SKIA_LOC)/trunk/src/core/SkFlate.cpp \
$(SKIA_LOC)/trunk/src/core/SkWriter32.cpp \
$(SKIA_LOC)/trunk/src/core/SkXfermode.cpp \
$(SKIA_LOC)/trunk/src/effects/Sk1DPathEffect.cpp \
$(SKIA_LOC)/trunk/src/effects/Sk2DPathEffect.cpp \
$(SKIA_LOC)/trunk/src/effects/SkAvoidXfermode.cpp \
$(SKIA_LOC)/trunk/src/effects/SkArithmeticMode.cpp \
$(SKIA_LOC)/trunk/src/effects/SkBitmapCache.cpp \
$(SKIA_LOC)/trunk/src/effects/SkBlurDrawLooper.cpp \
$(SKIA_LOC)/trunk/src/effects/SkBlurImageFilter.cpp \
$(SKIA_LOC)/trunk/src/effects/SkBlurMask.cpp \
$(SKIA_LOC)/trunk/src/effects/SkBlurMaskFilter.cpp \
$(SKIA_LOC)/trunk/src/effects/SkColorFilters.cpp \
$(SKIA_LOC)/trunk/src/effects/SkColorMatrixFilter.cpp \
$(SKIA_LOC)/trunk/src/effects/SkCornerPathEffect.cpp \
$(SKIA_LOC)/trunk/src/effects/SkDashPathEffect.cpp \
$(SKIA_LOC)/trunk/src/effects/SkDiscretePathEffect.cpp \
$(SKIA_LOC)/trunk/src/effects/SkEffects.cpp \
$(SKIA_LOC)/trunk/src/effects/SkEmbossMask.cpp \
$(SKIA_LOC)/trunk/src/effects/SkEmbossMaskFilter.cpp \
$(SKIA_LOC)/trunk/src/effects/SkGradientShader.cpp \
$(SKIA_LOC)/trunk/src/effects/SkGroupShape.cpp \
$(SKIA_LOC)/trunk/src/effects/SkKernel33MaskFilter.cpp \
$(SKIA_LOC)/trunk/src/effects/SkLayerDrawLooper.cpp \
$(SKIA_LOC)/trunk/src/effects/SkLayerRasterizer.cpp \
$(SKIA_LOC)/trunk/src/effects/SkPaintFlagsDrawFilter.cpp \
$(SKIA_LOC)/trunk/src/effects/SkPixelXorXfermode.cpp \
$(SKIA_LOC)/trunk/src/effects/SkPorterDuff.cpp \
$(SKIA_LOC)/trunk/src/effects/SkRectShape.cpp \
$(SKIA_LOC)/trunk/src/effects/SkTableColorFilter.cpp \
$(SKIA_LOC)/trunk/src/effects/SkTableMaskFilter.cpp \
$(SKIA_LOC)/trunk/src/effects/SkTestImageFilters.cpp \
$(SKIA_LOC)/trunk/src/effects/SkTransparentShader.cpp \
$(SKIA_LOC)/trunk/src/images/bmpdecoderhelper.cpp \
$(SKIA_LOC)/trunk/src/images/SkCreateRLEPixelRef.cpp \
$(SKIA_LOC)/trunk/src/images/SkFDStream.cpp \
$(SKIA_LOC)/trunk/src/images/SkFlipPixelRef.cpp \
$(SKIA_LOC)/trunk/src/images/SkImageDecoder.cpp \
$(SKIA_LOC)/trunk/src/images/SkImageDecoder_Factory.cpp \
$(SKIA_LOC)/trunk/src/images/SkImageDecoder_libbmp.cpp \
$(SKIA_LOC)/trunk/src/images/SkImageDecoder_libgif.cpp \
$(SKIA_LOC)/trunk/src/images/SkImageDecoder_libico.cpp \
$(SKIA_LOC)/trunk/src/images/SkImageDecoder_libpng.cpp \
$(SKIA_LOC)/trunk/src/images/SkImageDecoder_wbmp.cpp \
$(SKIA_LOC)/trunk/src/images/SkImageEncoder.cpp \
$(SKIA_LOC)/trunk/src/images/SkImageEncoder_Factory.cpp \
$(SKIA_LOC)/trunk/src/images/SkImageRef.cpp \
$(SKIA_LOC)/trunk/src/images/SkImageRefPool.cpp \
$(SKIA_LOC)/trunk/src/images/SkImageRef_GlobalPool.cpp \
$(SKIA_LOC)/trunk/src/images/SkMovie.cpp \
$(SKIA_LOC)/trunk/src/images/SkMovie_gif.cpp \
$(SKIA_LOC)/trunk/src/images/SkPageFlipper.cpp \
$(SKIA_LOC)/trunk/src/images/SkScaledBitmapSampler.cpp \
$(SKIA_LOC)/trunk/src/ports/SkDebug_android.cpp \
$(SKIA_LOC)/trunk/src/ports/SkGlobalInitialization_default.cpp \
$(SKIA_LOC)/trunk/src/ports/SkFontHost_FreeType.cpp \
$(SKIA_LOC)/trunk/src/ports/SkFontHost_sandbox_none.cpp \
$(SKIA_LOC)/trunk/src/ports/SkFontHost_android.cpp \
$(SKIA_LOC)/trunk/src/ports/SkFontHost_gamma.cpp \
$(SKIA_LOC)/trunk/src/ports/SkFontHost_tables.cpp \
$(SKIA_LOC)/trunk/src/ports/SkMemory_malloc.cpp \
$(SKIA_LOC)/trunk/src/ports/SkOSFile_stdio.cpp \
$(SKIA_LOC)/trunk/src/ports/SkTime_Unix.cpp \
$(SKIA_LOC)/trunk/src/ports/SkThread_pthread.cpp \
$(SKIA_LOC)/trunk/src/utils/SkBoundaryPatch.cpp \
$(SKIA_LOC)/trunk/src/utils/SkCamera.cpp \
$(SKIA_LOC)/trunk/src/utils/SkColorMatrix.cpp \
$(SKIA_LOC)/trunk/src/utils/SkCubicInterval.cpp \
$(SKIA_LOC)/trunk/src/utils/SkCullPoints.cpp \
$(SKIA_LOC)/trunk/src/utils/SkDumpCanvas.cpp \
$(SKIA_LOC)/trunk/src/utils/SkInterpolator.cpp \
$(SKIA_LOC)/trunk/src/utils/SkLayer.cpp \
$(SKIA_LOC)/trunk/src/utils/SkMatrix44.cpp \
$(SKIA_LOC)/trunk/src/utils/SkMeshUtils.cpp \
$(SKIA_LOC)/trunk/src/utils/SkNinePatch.cpp \
$(SKIA_LOC)/trunk/src/utils/SkNWayCanvas.cpp \
$(SKIA_LOC)/trunk/src/utils/SkOSFile.cpp \
$(SKIA_LOC)/trunk/src/utils/SkParse.cpp \
$(SKIA_LOC)/trunk/src/utils/SkParseColor.cpp \
$(SKIA_LOC)/trunk/src/utils/SkParsePath.cpp \
$(SKIA_LOC)/trunk/src/utils/SkProxyCanvas.cpp \
$(SKIA_LOC)/trunk/src/utils/SkSfntUtils.cpp \
$(SKIA_LOC)/trunk/src/utils/SkUnitMappers.cpp
$(OSMAND_SKIA_LOC)/src/core/Sk64.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkAAClip.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkAdvancedTypefaceMetrics.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkAlphaRuns.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkBitmap.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkBitmapProcShader.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkBitmapProcState.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkBitmapProcState_matrixProcs.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkBitmapSampler.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkBitmap_scroll.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkBlitMask_D32.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkBlitRow_D16.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkBlitRow_D32.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkBlitRow_D4444.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkBlitter.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkBlitter_4444.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkBlitter_A1.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkBlitter_A8.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkBlitter_ARGB32.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkBlitter_RGB16.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkBlitter_Sprite.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkBuffer.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkCanvas.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkChunkAlloc.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkClampRange.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkClipStack.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkColor.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkColorFilter.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkColorTable.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkComposeShader.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkConcaveToTriangles.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkCordic.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkCubicClipper.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkData.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkDebug.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkDeque.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkDevice.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkDither.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkDraw.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkEdgeBuilder.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkEdgeClipper.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkEdge.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkFilterProc.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkFlattenable.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkFloat.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkFloatBits.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkFontHost.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkGeometry.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkGlyphCache.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkGraphics.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkLineClipper.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkMallocPixelRef.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkMask.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkMaskFilter.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkMath.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkMatrix.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkMetaData.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkMMapStream.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkPackBits.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkPaint.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkPath.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkPathEffect.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkPathHeap.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkPathMeasure.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkPicture.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkPictureFlat.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkPicturePlayback.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkPictureRecord.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkPixelRef.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkPoint.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkProcSpriteBlitter.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkPtrRecorder.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkQuadClipper.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkRasterClip.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkRasterizer.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkRect.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkRefDict.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkRegion.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkRegion_path.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkScalar.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkScalerContext.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkScan.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkScan_AntiPath.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkScan_Antihair.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkScan_Hairline.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkScan_Path.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkShader.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkShape.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkSpriteBlitter_ARGB32.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkSpriteBlitter_RGB16.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkStream.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkString.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkStroke.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkStrokerPriv.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkTSearch.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkTypeface.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkTypefaceCache.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkUnPreMultiply.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkUtils.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkFlate.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkWriter32.cpp \
$(OSMAND_SKIA_LOC)/src/core/SkXfermode.cpp \
$(OSMAND_SKIA_LOC)/src/effects/Sk1DPathEffect.cpp \
$(OSMAND_SKIA_LOC)/src/effects/Sk2DPathEffect.cpp \
$(OSMAND_SKIA_LOC)/src/effects/SkAvoidXfermode.cpp \
$(OSMAND_SKIA_LOC)/src/effects/SkArithmeticMode.cpp \
$(OSMAND_SKIA_LOC)/src/effects/SkBitmapCache.cpp \
$(OSMAND_SKIA_LOC)/src/effects/SkBlurDrawLooper.cpp \
$(OSMAND_SKIA_LOC)/src/effects/SkBlurImageFilter.cpp \
$(OSMAND_SKIA_LOC)/src/effects/SkBlurMask.cpp \
$(OSMAND_SKIA_LOC)/src/effects/SkBlurMaskFilter.cpp \
$(OSMAND_SKIA_LOC)/src/effects/SkColorFilters.cpp \
$(OSMAND_SKIA_LOC)/src/effects/SkColorMatrixFilter.cpp \
$(OSMAND_SKIA_LOC)/src/effects/SkCornerPathEffect.cpp \
$(OSMAND_SKIA_LOC)/src/effects/SkDashPathEffect.cpp \
$(OSMAND_SKIA_LOC)/src/effects/SkDiscretePathEffect.cpp \
$(OSMAND_SKIA_LOC)/src/effects/SkEffects.cpp \
$(OSMAND_SKIA_LOC)/src/effects/SkEmbossMask.cpp \
$(OSMAND_SKIA_LOC)/src/effects/SkEmbossMaskFilter.cpp \
$(OSMAND_SKIA_LOC)/src/effects/SkGradientShader.cpp \
$(OSMAND_SKIA_LOC)/src/effects/SkGroupShape.cpp \
$(OSMAND_SKIA_LOC)/src/effects/SkKernel33MaskFilter.cpp \
$(OSMAND_SKIA_LOC)/src/effects/SkLayerDrawLooper.cpp \
$(OSMAND_SKIA_LOC)/src/effects/SkLayerRasterizer.cpp \
$(OSMAND_SKIA_LOC)/src/effects/SkPaintFlagsDrawFilter.cpp \
$(OSMAND_SKIA_LOC)/src/effects/SkPixelXorXfermode.cpp \
$(OSMAND_SKIA_LOC)/src/effects/SkPorterDuff.cpp \
$(OSMAND_SKIA_LOC)/src/effects/SkRectShape.cpp \
$(OSMAND_SKIA_LOC)/src/effects/SkTableColorFilter.cpp \
$(OSMAND_SKIA_LOC)/src/effects/SkTableMaskFilter.cpp \
$(OSMAND_SKIA_LOC)/src/effects/SkTestImageFilters.cpp \
$(OSMAND_SKIA_LOC)/src/effects/SkTransparentShader.cpp \
$(OSMAND_SKIA_LOC)/src/images/bmpdecoderhelper.cpp \
$(OSMAND_SKIA_LOC)/src/images/SkCreateRLEPixelRef.cpp \
$(OSMAND_SKIA_LOC)/src/images/SkFDStream.cpp \
$(OSMAND_SKIA_LOC)/src/images/SkFlipPixelRef.cpp \
$(OSMAND_SKIA_LOC)/src/images/SkImageDecoder.cpp \
$(OSMAND_SKIA_LOC)/src/images/SkImageDecoder_Factory.cpp \
$(OSMAND_SKIA_LOC)/src/images/SkImageDecoder_libbmp.cpp \
$(OSMAND_SKIA_LOC)/src/images/SkImageDecoder_libgif.cpp \
$(OSMAND_SKIA_LOC)/src/images/SkImageDecoder_libico.cpp \
$(OSMAND_SKIA_LOC)/src/images/SkImageDecoder_libjpeg.cpp \
$(OSMAND_SKIA_LOC)/src/images/SkImageDecoder_libpng.cpp \
$(OSMAND_SKIA_LOC)/src/images/SkImageDecoder_wbmp.cpp \
$(OSMAND_SKIA_LOC)/src/images/SkImageEncoder.cpp \
$(OSMAND_SKIA_LOC)/src/images/SkImageEncoder_Factory.cpp \
$(OSMAND_SKIA_LOC)/src/images/SkImageRef.cpp \
$(OSMAND_SKIA_LOC)/src/images/SkImageRefPool.cpp \
$(OSMAND_SKIA_LOC)/src/images/SkImageRef_GlobalPool.cpp \
$(OSMAND_SKIA_LOC)/src/images/SkMovie.cpp \
$(OSMAND_SKIA_LOC)/src/images/SkMovie_gif.cpp \
$(OSMAND_SKIA_LOC)/src/images/SkPageFlipper.cpp \
$(OSMAND_SKIA_LOC)/src/images/SkScaledBitmapSampler.cpp \
$(OSMAND_SKIA_LOC)/src/ports/SkDebug_android.cpp \
$(OSMAND_SKIA_LOC)/src/ports/SkGlobalInitialization_default.cpp \
$(OSMAND_SKIA_LOC)/src/ports/SkFontHost_FreeType.cpp \
$(OSMAND_SKIA_LOC)/src/ports/SkFontHost_sandbox_none.cpp \
$(OSMAND_SKIA_LOC)/src/ports/SkFontHost_android.cpp \
$(OSMAND_SKIA_LOC)/src/ports/SkFontHost_gamma.cpp \
$(OSMAND_SKIA_LOC)/src/ports/SkFontHost_tables.cpp \
$(OSMAND_SKIA_LOC)/src/ports/SkMemory_malloc.cpp \
$(OSMAND_SKIA_LOC)/src/ports/SkOSFile_stdio.cpp \
$(OSMAND_SKIA_LOC)/src/ports/SkTime_Unix.cpp \
$(OSMAND_SKIA_LOC)/src/ports/SkThread_pthread.cpp \
$(OSMAND_SKIA_LOC)/src/utils/SkBoundaryPatch.cpp \
$(OSMAND_SKIA_LOC)/src/utils/SkCamera.cpp \
$(OSMAND_SKIA_LOC)/src/utils/SkColorMatrix.cpp \
$(OSMAND_SKIA_LOC)/src/utils/SkCubicInterval.cpp \
$(OSMAND_SKIA_LOC)/src/utils/SkCullPoints.cpp \
$(OSMAND_SKIA_LOC)/src/utils/SkDumpCanvas.cpp \
$(OSMAND_SKIA_LOC)/src/utils/SkInterpolator.cpp \
$(OSMAND_SKIA_LOC)/src/utils/SkLayer.cpp \
$(OSMAND_SKIA_LOC)/src/utils/SkMatrix44.cpp \
$(OSMAND_SKIA_LOC)/src/utils/SkMeshUtils.cpp \
$(OSMAND_SKIA_LOC)/src/utils/SkNinePatch.cpp \
$(OSMAND_SKIA_LOC)/src/utils/SkNWayCanvas.cpp \
$(OSMAND_SKIA_LOC)/src/utils/SkOSFile.cpp \
$(OSMAND_SKIA_LOC)/src/utils/SkParse.cpp \
$(OSMAND_SKIA_LOC)/src/utils/SkParseColor.cpp \
$(OSMAND_SKIA_LOC)/src/utils/SkParsePath.cpp \
$(OSMAND_SKIA_LOC)/src/utils/SkProxyCanvas.cpp \
$(OSMAND_SKIA_LOC)/src/utils/SkSfntUtils.cpp \
$(OSMAND_SKIA_LOC)/src/utils/SkUnitMappers.cpp
# This file is replacement of $(SKIA_LOC)/trunk/src/ports/FontHostConfiguration_android.cpp
# This file is replacement of $(OSMAND_SKIA_LOC)/src/ports/FontHostConfiguration_android.cpp
LOCAL_SRC_FILES += \
FontHostConfiguration_android.cpp
LOCAL_C_INCLUDES += \
$(SKIA_ABS)/trunk/src/ports
$(OSMAND_SKIA_ABS)/src/ports
ifeq ($(TARGET_ARCH),arm)
ifeq ($(LOCAL_ARM_NEON),true)
LOCAL_SRC_FILES += \
$(SKIA_LOC)/trunk/src/opts/memset16_neon.S \
$(SKIA_LOC)/trunk/src/opts/memset32_neon.S
$(OSMAND_SKIA_LOC)/src/opts/memset16_neon.S \
$(OSMAND_SKIA_LOC)/src/opts/memset32_neon.S
endif
LOCAL_SRC_FILES += \
$(SKIA_LOC)/trunk/src/opts/opts_check_arm.cpp \
$(SKIA_LOC)/trunk/src/opts/memset.arm.S \
$(SKIA_LOC)/trunk/src/opts/SkBitmapProcState_opts_arm.cpp \
$(SKIA_LOC)/trunk/src/opts/SkBlitRow_opts_arm.cpp
$(OSMAND_SKIA_LOC)/src/opts/opts_check_arm.cpp \
$(OSMAND_SKIA_LOC)/src/opts/memset.arm.S \
$(OSMAND_SKIA_LOC)/src/opts/SkBitmapProcState_opts_arm.cpp \
$(OSMAND_SKIA_LOC)/src/opts/SkBlitRow_opts_arm.cpp
else
LOCAL_SRC_FILES += \
$(SKIA_LOC)/trunk/src/opts/SkBlitRow_opts_none.cpp \
$(SKIA_LOC)/trunk/src/opts/SkBitmapProcState_opts_none.cpp \
$(SKIA_LOC)/trunk/src/opts/SkUtils_opts_none.cpp
$(OSMAND_SKIA_LOC)/src/opts/SkBlitRow_opts_none.cpp \
$(OSMAND_SKIA_LOC)/src/opts/SkBitmapProcState_opts_none.cpp \
$(OSMAND_SKIA_LOC)/src/opts/SkUtils_opts_none.cpp
endif
LOCAL_SHARED_LIBRARIES := \
libcutils \
libjpeg \
libutils \
libz
LOCAL_STATIC_LIBRARIES := \
libft2 \
ifeq ($(LOCAL_ARM_NEON),true)
LOCAL_STATIC_LIBRARIES += \
libjpeg_neon \
libft2_static_neon \
libpng_neon \
libgif_neon \
libexpat_static_neon
else
LOCAL_STATIC_LIBRARIES += \
libjpeg \
libft2_static \
libpng \
libgif \
libexpat_static
endif
LOCAL_C_INCLUDES += \
$(SKIA_ABS)/trunk/src/core \
$(SKIA_ABS)/trunk/include/core \
$(SKIA_ABS)/trunk/include/config \
$(SKIA_ABS)/trunk/include/effects \
$(SKIA_ABS)/trunk/include/images \
$(SKIA_ABS)/trunk/include/utils \
$(SKIA_ABS)/trunk/include/xml \
$(SKIA_ABS)/android/third_party/externals/freetype/include \
$(SKIA_ABS)/android/third_party/externals/png \
$(SKIA_ABS)/android/third_party/externals/gif \
$(SKIA_ABS)/android/third_party/externals/expat/lib
$(LOCAL_PATH) \
$(OSMAND_SKIA_ABS)/src/core \
$(OSMAND_SKIA_ABS)/include/core \
$(OSMAND_SKIA_ABS)/include/config \
$(OSMAND_SKIA_ABS)/include/effects \
$(OSMAND_SKIA_ABS)/include/images \
$(OSMAND_SKIA_ABS)/include/utils \
$(OSMAND_SKIA_ABS)/include/xml \
$(OSMAND_FREETYPE_ABS)/include \
$(OSMAND_PNG_ABS) \
$(OSMAND_GIF_ABS) \
$(OSMAND_EXPAT_ABS)/lib \
$(OSMAND_JPEG_ABS)
ifeq ($(NO_FALLBACK_FONT),true)
LOCAL_CFLAGS += -DNO_FALLBACK_FONT
endif
LOCAL_CFLAGS += \
-DSK_SCALAR_IS_FLOAT \
-DSK_CAN_USE_FLOAT \
-DSK_BUILD_FOR_ANDROID \
-DSK_BUILD_FOR_ANDROID_NDK \
-DSK_ALLOW_STATIC_GLOBAL_INITIALIZERS=0 \
@ -298,11 +322,4 @@ include $(BUILD_STATIC_LIBRARY)
# Fix some errors
BUILD_HOST_EXECUTABLE := $(LOCAL_PATH)/FakeHost.mk
BUILD_HOST_STATIC_LIBRARY := $(LOCAL_PATH)/FakeHost.mk
# Import skia externals
$(call import-add-path,$(SKIA_ABS)/android/third_party/externals)
$(call import-module,expat)
$(call import-module,freetype)
$(call import-module,gif)
$(call import-module,png)
BUILD_HOST_STATIC_LIBRARY := $(LOCAL_PATH)/FakeHost.mk

@ -0,0 +1 @@
Subproject commit 1cab2921ab279367f8206cdadc9259d12e603548

View file

@ -73,7 +73,8 @@ public class NativeOsmandLibrary {
Bitmap bitmap, int requestedBitmapWidth, int requestedBitmapHeight, int rowBytes, boolean isTransparent,
boolean useEnglishNames, RenderingRuleSearchRequest render, int defaultColor) {
if (searchResultHandler == null) {
return new RenderingGenerationResult(null, "Error searchresult = null");
log.error("Error searchresult = null"); //$NON-NLS-1$
return new RenderingGenerationResult(null);
}
if(android.os.Build.VERSION.SDK_INT >= 8) // Android 2.2+
@ -131,14 +132,11 @@ public class NativeOsmandLibrary {
}
public static class RenderingGenerationResult {
public RenderingGenerationResult(ByteBuffer bitmap, String msg) {
public RenderingGenerationResult(ByteBuffer bitmap) {
bitmapBuffer = bitmap;
debugMessage = msg;
}
public final ByteBuffer bitmapBuffer;
public final String debugMessage;
}
private static native void deleteSearchResult(int searchResultHandle);

View file

@ -226,7 +226,7 @@ public class OsmandRenderer {
notifyListeners(notifyList);
long time = System.currentTimeMillis() - now;
rc.renderingDebugInfo = String.format("Rendering: %s ms (%s text)\n"
+ "(%s points, %s points inside, %s of %s objects visible)\n" + res.debugMessage,//$NON-NLS-1$
+ "(%s points, %s points inside, %s of %s objects visible)\n",//$NON-NLS-1$
time, rc.textRenderingTime, rc.pointCount, rc.pointInsideCount, rc.visible, rc.allObjects);
// See upper note

View file

@ -3,16 +3,23 @@ package net.osmand.plus.render;
import java.lang.reflect.Field;
import java.util.LinkedHashMap;
import java.util.Map;
import java.nio.ByteBuffer;
import java.io.InputStream;
import org.apache.commons.logging.Log;
import android.content.Context;
import android.graphics.Bitmap;
import android.util.DisplayMetrics;
import android.view.WindowManager;
import android.content.res.AssetFileDescriptor;
import net.osmand.plus.R;
import net.osmand.plus.R.drawable;
import net.osmand.LogUtil;
public class RenderingIcons {
private static final Log log = LogUtil.getLog(RenderingIcons.class);
private static Map<String, Integer> icons = new LinkedHashMap<String, Integer>();
private static Map<String, Bitmap> iconsBmp = new LinkedHashMap<String, Bitmap>();
@ -22,6 +29,37 @@ public class RenderingIcons {
return icons.containsKey(s);
}
public static ByteBuffer getIconAsByteBuffer(Context ctx, String s) {
Integer resId = icons.get(s);
// Quite bad error
if(resId == null)
return null;
try {
final AssetFileDescriptor iconAssetFd = ctx.getResources().openRawResourceFd(resId.intValue());
if(iconAssetFd == null)
return null;
final long iconAssetLen = iconAssetFd.getLength();
final ByteBuffer iconByteBuffer = ByteBuffer.allocate((int)iconAssetLen);
final InputStream inputStream = iconAssetFd.createInputStream();
if(inputStream == null)
return null;
long consumedBytes = 0;
while(consumedBytes < iconAssetLen) {
consumedBytes += inputStream.read(iconByteBuffer.array(), (int)(iconByteBuffer.arrayOffset() + consumedBytes), (int)(iconAssetLen - consumedBytes));
}
iconAssetFd.close();
return iconByteBuffer;
} catch(Throwable e) {
log.error("Failed to get byte stream from icon", e); //$NON-NLS-1$
return null;
}
}
public static Bitmap getIcon(Context ctx, String s){
if(!iconsBmp.containsKey(s)){
Integer resId = icons.get(s);