Merge pull request #196 from alexey-pelykh/uiCodeReferencesRefactor

Additional native code cleanup
This commit is contained in:
vshcherb 2012-03-18 03:24:35 -07:00
commit 6f6befa7af
16 changed files with 70 additions and 51 deletions

View file

@ -1,13 +1,29 @@
OSMAND_MAKEFILES := $(all-subdir-makefiles)
# Protect from previous builds
ifneq ($(TARGET_ARCH_ABI),armeabi-v7a)
OSMAND_BUILDING_NEON_LIBRARY := false
endif
# OSMAND_FORCE_NEON_SUPPORT is used to force only NEON support on ARMv7a
ifdef OSMAND_FORCE_NEON_SUPPORT
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
OSMAND_BUILDING_NEON_LIBRARY := true
endif
endif
# By default, include makefiles only once
include $(OSMAND_MAKEFILES)
# If we may support NEON, include them once more
# If we're not asked not to support NEON and not asked to support only NEON ARMv7a, then
# make additional build
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
ifndef OSMAND_SKIP_NEON_SUPPORT
ifndef OSMAND_FORCE_NEON_SUPPORT
OSMAND_NEON := true
OSMAND_BUILDING_NEON_LIBRARY := true
include $(OSMAND_MAKEFILES)
endif
endif
endif

View file

@ -1,7 +1,21 @@
APP_STL := stlport_shared
APP_ABI := armeabi armeabi-v7a
APP_ABI := all
APP_CPPFLAGS := -fno-rtti -fno-exceptions
ifdef OSMAND_X86_ONLY
APP_ABI := x86
else
ifdef OSMAND_ARM_ONLY
APP_ABI := armeabi armeabi-v7a
endif
ifdef OSMAND_ARMv5_ONLY
APP_ABI := armeabi
endif
ifdef OSMAND_ARMv7a_ONLY
APP_ABI := armeabi-v7a
endif
endif
ifndef OSMAND_DEBUG_NATIVE
# Force release compilation in release optimizations, even if application is debuggable by manifest
APP_OPTIM := release

View file

@ -1,5 +1,5 @@
# Do not build for NEON
ifneq ($(OSMAND_NEON),true)
ifneq ($(OSMAND_BUILDING_NEON_LIBRARY),true)
LOCAL_PATH := $(call my-dir)

View file

@ -2,7 +2,7 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
ifneq ($(OSMAND_NEON),true)
ifneq ($(OSMAND_BUILDING_NEON_LIBRARY),true)
LOCAL_MODULE := libexpat_static
else
LOCAL_MODULE := libexpat_static_neon

View file

@ -50,7 +50,7 @@ LOCAL_CFLAGS += "-DFT2_BUILD_LIBRARY"
LOCAL_CFLAGS += -O2
ifneq ($(OSMAND_NEON),true)
ifneq ($(OSMAND_BUILDING_NEON_LIBRARY),true)
LOCAL_MODULE := libft2_static
else
LOCAL_MODULE := libft2_static_neon

View file

@ -18,7 +18,7 @@ LOCAL_C_INCLUDES += \
LOCAL_CFLAGS += -Wno-format -DHAVE_CONFIG_H
ifneq ($(OSMAND_NEON),true)
ifneq ($(OSMAND_BUILDING_NEON_LIBRARY),true)
LOCAL_MODULE := libgif
else
LOCAL_MODULE := libgif_neon

View file

@ -74,7 +74,7 @@ ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
LOCAL_CFLAGS += -DANDROID_ARMV6_IDCT
endif
ifneq ($(OSMAND_NEON),true)
ifneq ($(OSMAND_BUILDING_NEON_LIBRARY),true)
LOCAL_MODULE := libjpeg
else
LOCAL_MODULE := libjpeg_neon

View file

@ -13,7 +13,7 @@ ifeq ($(OSMAND_SKIA_ABS),)
endif
# Name of the local module
ifneq ($(OSMAND_NEON),true)
ifneq ($(OSMAND_BUILDING_NEON_LIBRARY),true)
LOCAL_MODULE := osmand
else
LOCAL_MODULE := osmand_neon

View file

@ -17,8 +17,6 @@
#include "multipolygons.h"
#include "proto/osmand_odb.pb.h"
char errorMsg[1024];
#define INT_MAX 0x7fffffff /* max value for an int */
#define DO_(EXPRESSION) if (!(EXPRESSION)) return false
using namespace google::protobuf;
using namespace google::protobuf::internal;
@ -347,8 +345,7 @@ bool initMapStructure(io::CodedInputStream* input, BinaryMapFile* file) {
}
}
if (version != versionConfirm) {
__android_log_print(ANDROID_LOG_WARN, "net.osmand",
"Corrupted file. It should be ended as it starts with version");
__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Corrupted file. It should be ended as it starts with version");
return false;
}
return true;
@ -746,9 +743,8 @@ extern "C" JNIEXPORT jint JNICALL Java_net_osmand_plus_render_NativeOsmandLibrar
proccessMultiPolygons(multyPolygons, q.left, q.right, q.bottom, q.top, q.zoom, result->result);
if(q.result.size() > 0) {
sprintf(errorMsg, "Search : tree - read( %d), accept( %d), objs - visit( %d), accept(%d), in result(%d) ", q.numberOfReadSubtrees,
q.numberOfAcceptedSubtrees, q.numberOfVisitedObjects, q.numberOfAcceptedObjects, result->result.size());
__android_log_print(ANDROID_LOG_INFO, "net.osmand", errorMsg);
__android_log_print(ANDROID_LOG_INFO, LOG_TAG, "Search : tree - read( %d), accept( %d), objs - visit( %d), accept(%d), in result(%d) ", q.numberOfReadSubtrees,
q.numberOfAcceptedSubtrees, q.numberOfVisitedObjects, q.numberOfAcceptedObjects, result->result.size());
}
delete req;
return (jint)result;
@ -771,8 +767,7 @@ extern "C" JNIEXPORT jboolean JNICALL Java_net_osmand_plus_render_NativeOsmandLi
FILE* file = fopen(inputName.c_str(), "r");
if (file == NULL) {
sprintf(errorMsg, "File could not be open to read from C : %s", inputName.c_str());
__android_log_print(ANDROID_LOG_WARN, "net.osmand", errorMsg);
__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "File could not be open to read from C : %s", inputName.c_str());
return false;
}
BinaryMapFile* mapFile = new BinaryMapFile();
@ -782,8 +777,7 @@ extern "C" JNIEXPORT jboolean JNICALL Java_net_osmand_plus_render_NativeOsmandLi
io::CodedInputStream cis(&input);
cis.SetTotalBytesLimit(INT_MAX, INT_MAX >> 2);
if (!initMapStructure(&cis, mapFile)) {
sprintf(errorMsg, "File not initialised : %s", inputName.c_str());
__android_log_print(ANDROID_LOG_WARN, "net.osmand", errorMsg);
__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "File not initialised : %s", inputName.c_str());
delete mapFile;
return false;
}

View file

@ -45,7 +45,7 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
loadJniMapObjects();
loadJniBinaryRead();
__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "JNI_OnLoad completed");
__android_log_print(ANDROID_LOG_INFO, LOG_TAG, "JNI_OnLoad completed");
return JNI_VERSION_1_6;
}

View file

@ -14,7 +14,7 @@ class BaseMapDataObject
{
public :
static const unsigned int UNDEFINED_STRING = 0x7fffffff;
static const unsigned int UNDEFINED_STRING = INT_MAX;
const int type;
static const int MAP_DATA_OBJECT = 1;
static const int MULTI_POLYGON = 2;

View file

@ -10,10 +10,6 @@
#include "common.h"
#include "mapObjects.h"
#define INT_MAX 0x7fffffff /* max value for an int */
#define INT_MIN (-0x7fffffff-1) /* min value for an int */
char textMsg[1024] ;
struct tagValueType {
int type;
std::string tag;
@ -118,7 +114,7 @@ MultiPolygonObject* processMultiPolygon(int leftX, int rightX, int bottomY, int
whole.push_back(int_pair(leftX, bottomY));
whole.push_back(int_pair(rightX, bottomY));
completedRings.push_back(whole);
__android_log_print(ANDROID_LOG_INFO, "net.osmand", "!!! Isolated island !!!");
__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "!!! Isolated island !!!");
}
}
@ -161,14 +157,13 @@ void proccessMultiPolygons(std::map<tagValueType, std::vector<MapDataObject*> >&
completedRingNames.clear();
incompletedRingNames.clear();
sprintf(textMsg, "Process multipolygon %s %s direct list %d rev %d", val->first.tag.c_str(), val->first.value.c_str(), directList->size(), inverselist->size());
__android_log_print(ANDROID_LOG_INFO, "net.osmand", textMsg);
__android_log_print(ANDROID_LOG_INFO, LOG_TAG, "Process multipolygon %s %s direct list %d rev %d", val->first.tag.c_str(), val->first.value.c_str(), directList->size(), inverselist->size());
MultiPolygonObject* pl = processMultiPolygon(leftX, rightX, bottomY, topY, completedRings, incompletedRings,
completedRingNames, incompletedRingNames, val->first, *directList, *inverselist, zoom);
if (pl != NULL) {
listPolygons.push_back(pl);
} else {
__android_log_print(ANDROID_LOG_INFO, "net.osmand", "Multipolygon skipped");
__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Multipolygon skipped");
}
}
}
@ -361,7 +356,7 @@ void unifyIncompletedRings(std::vector<std::vector<int_pair> >& incompletedRings
// System.err
// .println(MessageFormat.format(dbId + str, dx, dy, dsx, dsy, leftX + "", topY + "", rightX + "", bottomY + "")); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
// }
__android_log_print(ANDROID_LOG_INFO, "net.osmand", "Error processing multipolygon");
__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Error processing multipolygon");
} else {
nonvisitedRings.insert(j);
}

View file

@ -723,16 +723,16 @@ extern "C" JNIEXPORT jobject JNICALL Java_net_osmand_plus_render_NativeOsmandLib
if(AndroidBitmap_getInfo(getGlobalJniEnv(), targetBitmap, &bitmapInfo) != ANDROID_BITMAP_RESUT_SUCCESS)
__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Failed to execute AndroidBitmap_getInfo");
__android_log_print(ANDROID_LOG_WARN, LOG_TAG, "Creating SkBitmap in native w:%d h:%d s:%d f:%d!", bitmapInfo.width, bitmapInfo.height, bitmapInfo.stride, bitmapInfo.format);
__android_log_print(ANDROID_LOG_INFO, LOG_TAG, "Creating SkBitmap in native w:%d h:%d s:%d f:%d!", bitmapInfo.width, bitmapInfo.height, bitmapInfo.stride, bitmapInfo.format);
SkBitmap* bitmap = new SkBitmap();
if(bitmapInfo.format == ANDROID_BITMAP_FORMAT_RGBA_8888) {
int rowBytes = bitmapInfo.stride;
__android_log_print(ANDROID_LOG_WARN, LOG_TAG, "Row bytes for RGBA_8888 is %d", rowBytes);
__android_log_print(ANDROID_LOG_INFO, LOG_TAG, "Row bytes for RGBA_8888 is %d", rowBytes);
bitmap->setConfig(SkBitmap::kARGB_8888_Config, bitmapInfo.width, bitmapInfo.height, rowBytes);
} else if(bitmapInfo.format == ANDROID_BITMAP_FORMAT_RGB_565) {
int rowBytes = bitmapInfo.stride;
__android_log_print(ANDROID_LOG_WARN, LOG_TAG, "Row bytes for RGB_565 is %d", rowBytes);
__android_log_print(ANDROID_LOG_INFO, LOG_TAG, "Row bytes for RGB_565 is %d", rowBytes);
bitmap->setConfig(SkBitmap::kRGB_565_Config, bitmapInfo.width, bitmapInfo.height, rowBytes);
} else {
__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Unknown target bitmap format");
@ -742,7 +742,7 @@ extern "C" JNIEXPORT jobject JNICALL Java_net_osmand_plus_render_NativeOsmandLib
if(AndroidBitmap_lockPixels(getGlobalJniEnv(), targetBitmap, &lockedBitmapData) != ANDROID_BITMAP_RESUT_SUCCESS || !lockedBitmapData) {
__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Failed to execute AndroidBitmap_lockPixels");
}
__android_log_print(ANDROID_LOG_WARN, LOG_TAG, "Locked %d bytes at %p", bitmap->getSize(), lockedBitmapData);
__android_log_print(ANDROID_LOG_INFO, LOG_TAG, "Locked %d bytes at %p", bitmap->getSize(), lockedBitmapData);
bitmap->setPixels(lockedBitmapData);
@ -751,7 +751,7 @@ extern "C" JNIEXPORT jobject JNICALL Java_net_osmand_plus_render_NativeOsmandLib
SkPaint* paint = new SkPaint;
paint->setAntiAlias(true);
__android_log_print(ANDROID_LOG_WARN, LOG_TAG, "Initializing rendering");
__android_log_print(ANDROID_LOG_INFO, LOG_TAG, "Initializing rendering");
ElapsedTimer initObjects;
initObjects.start();
@ -762,7 +762,7 @@ extern "C" JNIEXPORT jobject JNICALL Java_net_osmand_plus_render_NativeOsmandLib
SearchResult* result = ((SearchResult*) searchResult);
// std::vector <BaseMapDataObject* > mapDataObjects = marshalObjects(binaryMapDataObjects);
__android_log_print(ANDROID_LOG_WARN, LOG_TAG, "Rendering image");
__android_log_print(ANDROID_LOG_INFO, LOG_TAG, "Rendering image");
initObjects.pause();
@ -774,7 +774,7 @@ extern "C" JNIEXPORT jobject JNICALL Java_net_osmand_plus_render_NativeOsmandLib
rc.nativeOperations.pause();
pushToJavaRenderingContext(renderingContext, &rc);
__android_log_print(ANDROID_LOG_WARN, LOG_TAG, "End Rendering image");
__android_log_print(ANDROID_LOG_INFO, LOG_TAG, "End Rendering image");
if(AndroidBitmap_unlockPixels(ienv, targetBitmap) != ANDROID_BITMAP_RESUT_SUCCESS) {
__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "Failed to execute AndroidBitmap_unlockPixels");
}
@ -791,9 +791,9 @@ extern "C" JNIEXPORT jobject JNICALL Java_net_osmand_plus_render_NativeOsmandLib
jmethodID resultClassCtorId = getGlobalJniEnv()->GetMethodID(resultClass, "<init>", "(Ljava/nio/ByteBuffer;)V");
#ifdef DEBUG_NAT_OPERATIONS
__android_log_print(ANDROID_LOG_WARN, LOG_TAG,"Native ok (init %d, native op %d) ", initObjects.getElapsedTime(), rc.nativeOperations.getElapsedTime());
__android_log_print(ANDROID_LOG_INFO, LOG_TAG,"Native ok (init %d, native op %d) ", initObjects.getElapsedTime(), rc.nativeOperations.getElapsedTime());
#else
__android_log_print(ANDROID_LOG_WARN, LOG_TAG, "Native ok (init %d, rendering %d) ", initObjects.getElapsedTime(), rc.nativeOperations.getElapsedTime());
__android_log_print(ANDROID_LOG_INFO, LOG_TAG, "Native ok (init %d, rendering %d) ", initObjects.getElapsedTime(), rc.nativeOperations.getElapsedTime());
#endif
/* Construct a result object */
@ -810,7 +810,7 @@ extern "C" JNIEXPORT jobject JNICALL Java_net_osmand_plus_render_NativeOsmandLib
jboolean useEnglishNames, jobject renderingRuleSearchRequest, jint defaultColor) {
setGlobalJniEnv(ienv);
__android_log_print(ANDROID_LOG_WARN, LOG_TAG, "Creating SkBitmap in native w:%d h:%d!", requestedBitmapWidth, requestedBitmapHeight);
__android_log_print(ANDROID_LOG_INFO, LOG_TAG, "Creating SkBitmap in native w:%d h:%d!", requestedBitmapWidth, requestedBitmapHeight);
SkBitmap* bitmap = new SkBitmap();
if(isTransparent == JNI_TRUE)
@ -827,7 +827,7 @@ extern "C" JNIEXPORT jobject JNICALL Java_net_osmand_plus_render_NativeOsmandLib
bitmapDataSize = bitmap->getSize();
bitmapData = malloc(bitmapDataSize);
__android_log_print(ANDROID_LOG_WARN, LOG_TAG, "Allocated %d bytes at %p", bitmapDataSize, bitmapData);
__android_log_print(ANDROID_LOG_INFO, LOG_TAG, "Allocated %d bytes at %p", bitmapDataSize, bitmapData);
}
bitmap->setPixels(bitmapData);
@ -837,7 +837,7 @@ extern "C" JNIEXPORT jobject JNICALL Java_net_osmand_plus_render_NativeOsmandLib
SkPaint* paint = new SkPaint;
paint->setAntiAlias(true);
__android_log_print(ANDROID_LOG_WARN, LOG_TAG, "Initializing rendering");
__android_log_print(ANDROID_LOG_INFO, LOG_TAG, "Initializing rendering");
ElapsedTimer initObjects;
initObjects.start();
@ -848,7 +848,7 @@ extern "C" JNIEXPORT jobject JNICALL Java_net_osmand_plus_render_NativeOsmandLib
SearchResult* result = ((SearchResult*) searchResult);
// std::vector <BaseMapDataObject* > mapDataObjects = marshalObjects(binaryMapDataObjects);
__android_log_print(ANDROID_LOG_WARN, LOG_TAG, "Rendering image");
__android_log_print(ANDROID_LOG_INFO, LOG_TAG, "Rendering image");
initObjects.pause();
@ -860,7 +860,7 @@ extern "C" JNIEXPORT jobject JNICALL Java_net_osmand_plus_render_NativeOsmandLib
rc.nativeOperations.pause();
pushToJavaRenderingContext(renderingContext, &rc);
__android_log_print(ANDROID_LOG_WARN, LOG_TAG, "End Rendering image");
__android_log_print(ANDROID_LOG_INFO, LOG_TAG, "End Rendering image");
// delete variables
delete paint;
@ -874,9 +874,9 @@ extern "C" JNIEXPORT jobject JNICALL Java_net_osmand_plus_render_NativeOsmandLib
jmethodID resultClassCtorId = ienv->GetMethodID(resultClass, "<init>", "(Ljava/nio/ByteBuffer;)V");
#ifdef DEBUG_NAT_OPERATIONS
__android_log_print(ANDROID_LOG_WARN, LOG_TAG, "Native ok (init %d, native op %d) ", initObjects.getElapsedTime(), rc.nativeOperations.getElapsedTime());
__android_log_print(ANDROID_LOG_INFO, LOG_TAG, "Native ok (init %d, native op %d) ", initObjects.getElapsedTime(), rc.nativeOperations.getElapsedTime());
#else
__android_log_print(ANDROID_LOG_WARN, LOG_TAG, "Native ok (init %d, rendering %d) ", initObjects.getElapsedTime(), rc.nativeOperations.getElapsedTime());
__android_log_print(ANDROID_LOG_INFO, LOG_TAG, "Native ok (init %d, rendering %d) ", initObjects.getElapsedTime(), rc.nativeOperations.getElapsedTime());
#endif
// Allocate ctor paramters

View file

@ -50,7 +50,7 @@ LOCAL_C_INCLUDES += $(common_C_INCLUDES) \
LOCAL_SHARED_LIBRARIES := \
libz
ifneq ($(OSMAND_NEON),true)
ifneq ($(OSMAND_BUILDING_NEON_LIBRARY),true)
LOCAL_MODULE := libpng
else
LOCAL_MODULE := libpng_neon

View file

@ -15,7 +15,7 @@ CC_LITE_SRC_FILES := \
include $(CLEAR_VARS)
ifneq ($(OSMAND_NEON),true)
ifneq ($(OSMAND_BUILDING_NEON_LIBRARY),true)
LOCAL_MODULE := proto
else
LOCAL_MODULE := proto_neon

View file

@ -4,7 +4,7 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
ifneq ($(OSMAND_NEON),true)
ifneq ($(OSMAND_BUILDING_NEON_LIBRARY),true)
LOCAL_MODULE := skia
else
LOCAL_MODULE := skia_neon