Compile using x86 linux

This commit is contained in:
Victor Shcherb 2012-04-30 15:58:02 +02:00
parent ebaaf33a41
commit a20e10e025
11 changed files with 145 additions and 85 deletions

1
Osmand-kernel/osmand/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
*.o

View file

@ -0,0 +1,60 @@
default : all
JAVA := $$JAVA_HOME/bin/java
JAVAC := $$JAVA_HOME/bin/javac
CXX := g++
STRIP := strip
LIBNAME := osmand.lib
#LOCAL_PATH := $(call my-dir)
LOCAL_PATH := .
PROTOBUF := $(LOCAL_PATH)/../protobuf
OSMAND_SKIA_ABS := $(LOCAL_PATH)/../skia/skia_library
LOCAL_C_INCLUDES := -I$(LOCAL_PATH) \
-I$(PROTOBUF) \
-I$(LOCAL_PATH)/../skia \
-I$(OSMAND_SKIA_ABS)/include/core \
-I$(OSMAND_SKIA_ABS)/include/images \
-I$(OSMAND_SKIA_ABS)/include/utils \
-I$(OSMAND_SKIA_ABS)/include/config \
-I$(OSMAND_SKIA_ABS)/include/effects \
-I$(OSMAND_SKIA_ABS)/include/utils/android \
-I$(OSMAND_SKIA_ABS)/src/core
#For hash_map compilation -Wno-deprecated
CPPFLAGS := \
-DGOOGLE_PROTOBUF_NO_RTTI \
-DSK_ALLOW_STATIC_GLOBAL_INITIALIZERS=0 \
-DSK_RELEASE \
-DGR_RELEASE=1 \
-c -fpic -I$(JAVA_HOME)/include \
-DLINUX_BUILD \
$(LOCAL_C_INCLUDES)
# LDFLAGS contains flags passed to the compiler for use during linking
LDFLAGS = -Wl,--hash-style=both
# LIBS contains libraries to link with
LDLIBS = -L/home/victor/projects/OsmAnd/git/Osmand-kernel/jni-prebuilt/x86/ -lskia -lproto -lpng -ljpeg -lgif -lft2_static -lexpat_static -lrt -lm
TARGET = $(shell basename `pwd`)
SOURCES = osmand_log.cpp \
common.cpp \
mapObjects.cpp \
renderRules.cpp \
rendering.cpp \
binaryRead.cpp
DEPS = $(wildcard *.h)
OBJECTS = $(SOURCES:%.cpp=%.o)
all: $(LIBNAME)
$(OBJECTS): $(SOURCES) $(DEPS)
$(LIBNAME): $(OBJECTS)
$(CXX) $(LDFLAGS) -o $(LIBNAME) $(OBJECTS) $(LDLIBS)
$(STRIP) $(LIBNAME)
clean:
$(RM) $(OBJECTS) $(TARGET)

View file

@ -10,15 +10,6 @@
#include <map>
#include <string>
#ifdef LINUX_BUILD
#include <ext/hash_map>
#include <ext/hash_set>
using namespace __gnu_cxx;
#else
#include <hash_map>
#include <hash_set>
#endif
#include "google/protobuf/io/zero_copy_stream_impl.h"
#include "google/protobuf/wire_format_lite.h"
#include "google/protobuf/wire_format_lite.cc"
@ -29,6 +20,7 @@ using namespace __gnu_cxx;
#include "multipolygons.h"
//#include "multipolygons.h"
#include "proto/osmand_odb.pb.h"
using namespace std;
#define DO_(EXPRESSION) if (!(EXPRESSION)) return false
using namespace google::protobuf;
@ -127,18 +119,18 @@ struct MapTreeBounds {
struct MapRoot: MapTreeBounds {
int minZoom ;
int maxZoom ;
vector<MapTreeBounds> bounds;
std::vector<MapTreeBounds> bounds;
};
struct MapIndex {
uint32 length;
int filePointer;
std::string name;
vector<MapRoot> levels;
std::vector<MapRoot> levels;
hash_map<int, tag_value > decodingRules;
HMAP::hash_map<int, tag_value > decodingRules;
// DEFINE hash
//std::hash_map<tag_value, int> encodingRules;
//HMAP::hash_map<tag_value, int> encodingRules;
int nameEncodingType;
int refEncodingType;
@ -147,8 +139,8 @@ struct MapIndex {
int landEncodingType;
int onewayAttribute ;
int onewayReverseAttribute ;
hash_set< int > positiveLayers;
hash_set< int > negativeLayers;
HMAP::hash_set< int > positiveLayers;
HMAP::hash_set< int > negativeLayers;
MapIndex(){
nameEncodingType = refEncodingType = coastlineBrokenEncodingType = coastlineEncodingType = -1;
@ -197,7 +189,7 @@ struct MapIndex {
struct BinaryMapFile {
std::string inputName;
vector<MapIndex> mapIndexes;
std::vector<MapIndex> mapIndexes;
FILE* f;
bool basemap;
@ -551,10 +543,10 @@ MapDataObject* readMapDataObject(io::CodedInputStream* input, MapTreeBounds* tre
contains = true;
}
if (!contains) {
minX = min(minX, x);
maxX = max(maxX, x);
minY = min(minY, y);
maxY = max(maxY, y);
minX = std::min(minX, x);
maxX = std::max(maxX, x);
minY = std::min(minY, y);
maxY = std::max(maxY, y);
}
}
if (!contains) {
@ -568,10 +560,10 @@ MapDataObject* readMapDataObject(io::CodedInputStream* input, MapTreeBounds* tre
}
// READ types
vector< coordinates > innercoordinates;
vector< tag_value > additionalTypes;
vector< tag_value > types;
hash_map< std::string, unsigned int> stringIds;
std::vector< coordinates > innercoordinates;
std::vector< tag_value > additionalTypes;
std::vector< tag_value > types;
HMAP::hash_map< std::string, unsigned int> stringIds;
bool loop = true;
while (loop) {
uint32 t = input->ReadTag();
@ -782,12 +774,12 @@ bool readMapDataBlocks(io::CodedInputStream* input, SearchQuery* req, MapTreeBou
DO_((WireFormatLite::ReadPrimitive<uint32, WireFormatLite::TYPE_UINT32>(input, &length)));
int oldLimit = input->PushLimit(length);
if(results.size() > 0) {
vector<std::string> stringTable;
std::vector<std::string> stringTable;
readStringTable(input, stringTable);
MapDataObject* o;
for (std::vector<MapDataObject*>::iterator obj = results.begin(); obj != results.end(); obj++) {
if ((*obj)->stringIds.size() > 0) {
hash_map<std::string, unsigned int >::iterator val=(*obj)->stringIds.begin();
HMAP::hash_map<std::string, unsigned int >::iterator val=(*obj)->stringIds.begin();
while(val != (*obj)->stringIds.end()){
(*obj)->objectNames[val->first]=stringTable[val->second];
val++;
@ -839,10 +831,10 @@ void searchMapData(io::CodedInputStream* input, MapRoot* root, MapIndex* ind, Se
if (i->right < req->left || i->left > req->right || i->top > req->bottom || i->bottom < req->top) {
continue;
}
vector<MapTreeBounds> foundSubtrees;
std::vector<MapTreeBounds> foundSubtrees;
input->Seek(i->filePointer);
int oldLimit = input->PushLimit(i->length);
searchMapTreeBounds(input, i, root, req, &foundSubtrees);
searchMapTreeBounds(input, &(*i), root, req, &foundSubtrees);
input->PopLimit(oldLimit);
@ -856,7 +848,7 @@ void searchMapData(io::CodedInputStream* input, MapRoot* root, MapIndex* ind, Se
input->Seek(tree->mapDataBlock);
WireFormatLite::ReadPrimitive<uint32, WireFormatLite::TYPE_UINT32>(input, &length);
int oldLimit = input->PushLimit(length);
readMapDataBlocks(input, req, tree, ind);
readMapDataBlocks(input, req, &(*tree), ind);
input->PopLimit(oldLimit);
}
}
@ -879,7 +871,7 @@ extern "C" JNIEXPORT jint JNICALL Java_net_osmand_plus_render_NativeOsmandLibrar
SearchResult* searchRes = new SearchResult();
map<std::string, BinaryMapFile*>::iterator i = openFiles.begin();
hash_set<long long> ids;
HMAP::hash_set<long long> ids;
int count = 0;
bool ocean = false;
std::vector<MapDataObject*> basemapResult;
@ -898,9 +890,9 @@ extern "C" JNIEXPORT jint JNICALL Java_net_osmand_plus_render_NativeOsmandLibrar
req->clearState();
}
q.result.clear();
for (vector<MapIndex>::iterator mapIndex = file->mapIndexes.begin(); mapIndex != file->mapIndexes.end();
for (std::vector<MapIndex>::iterator mapIndex = file->mapIndexes.begin(); mapIndex != file->mapIndexes.end();
mapIndex++) {
for (vector<MapRoot>::iterator mapLevel = mapIndex->levels.begin(); mapLevel != mapIndex->levels.end();
for (std::vector<MapRoot>::iterator mapLevel = mapIndex->levels.begin(); mapLevel != mapIndex->levels.end();
mapLevel++) {
if (q.isCancelled()) {
break;
@ -909,7 +901,7 @@ extern "C" JNIEXPORT jint JNICALL Java_net_osmand_plus_render_NativeOsmandLibrar
if (mapLevel->right >= q.left && q.right >= mapLevel->left && mapLevel->bottom >= q.top
&& q.bottom >= mapLevel->top) {
osmand_log_print(LOG_INFO, "Search map %s", mapIndex->name.c_str());
searchMapData(&cis, mapLevel, mapIndex, &q);
searchMapData(&cis, &(*mapLevel), &(*mapIndex), &q);
}
}
}

View file

@ -1,16 +1,11 @@
#include <string>
#include <vector>
#include <hash_map>
#include <SkPath.h>
#include <SkBitmap.h>
#include <SkImageDecoder.h>
#include <jni.h>
#include <time.h>
// constant CLOCK_MONOTONIC is included in linux time.h
#ifdef LINUX_BUILD
#include <linux/time.h>
#endif
#include "common.h"
#include "osmand_log.h"
@ -300,7 +295,7 @@ int ElapsedTimer::getElapsedTime()
return elapsedTime / 1e6;
}
std::hash_map<std::string, SkBitmap*> cachedBitmaps;
HMAP::hash_map<std::string, SkBitmap*> cachedBitmaps;
SkBitmap* getCachedBitmap(RenderingContext* rc, const std::string& bitmapResource)
{
JNIEnv* env = rc->env;
@ -308,7 +303,7 @@ SkBitmap* getCachedBitmap(RenderingContext* rc, const std::string& bitmapResourc
return NULL;
// Try to find previously cached
std::hash_map<std::string, SkBitmap*>::iterator itPreviouslyCachedBitmap = cachedBitmaps.find(bitmapResource);
HMAP::hash_map<std::string, SkBitmap*>::iterator itPreviouslyCachedBitmap = cachedBitmaps.find(bitmapResource);
if (itPreviouslyCachedBitmap != cachedBitmaps.end())
return itPreviouslyCachedBitmap->second;

View file

@ -4,11 +4,41 @@
#include <jni.h>
#include <string>
#include <vector>
#ifdef LINUX_BUILD
#include <ext/hash_map>
#else
#include <hash_map>
#include <hash_set>
#ifdef LINUX_BUILD
#define HMAP __gnu_cxx
namespace __gnu_cxx {
template<>
struct hash<std::string>
{
hash<char*> h;
size_t operator()(const std::string &s) const
{
return h(s.c_str());
};
};
template<>
struct hash<long long int>
{
size_t
operator()(long long int __x) const
{ return __x; }
};
template<>
struct hash<unsigned long long int>
{
size_t
operator()(unsigned long long int __x) const
{ return __x; }
};
}
#else
#define HMAP std
#endif
using namespace std;
#include <SkPath.h>
#include <SkBitmap.h>

View file

@ -3,14 +3,8 @@
#include <jni.h>
#include <vector>
#ifdef LINUX_BUILD
#include <ext/hash_map>
using namespace __gnu_cxx;
#else
#include <hash_map>
using namespace std;
#endif
#include <string>
#include <limits.h>
#include "common.h"
@ -30,9 +24,9 @@ public:
coordinates points;
std::vector < coordinates > polygonInnerCoordinates;
hash_map< std::string, unsigned int> stringIds;
HMAP::hash_map< std::string, unsigned int> stringIds;
hash_map< std::string, std::string > objectNames;
HMAP::hash_map< std::string, std::string > objectNames;
bool area;
long long id;

View file

@ -2,12 +2,6 @@
#include <stdio.h>
#include <map>
#include <set>
#ifdef LINUX_BUILD
#include <ext/hash_map>
#else
#include <hash_map>
#endif
#include "renderRules.h"
#include "common.h"

View file

@ -3,7 +3,7 @@
#include <jni.h>
#include <string>
#include <mapObjects.h>
#include "mapObjects.h"
class RenderingRuleProperty
{
@ -52,11 +52,11 @@ class RenderingRulesStorage
private:
const static int SHIFT_TAG_VAL = 16;
const static int SIZE_STATES = 7;
std::hash_map<std::string, int> dictionaryMap;
HMAP::hash_map<std::string, int> dictionaryMap;
std::vector<std::string> dictionary;
std::hash_map<int, RenderingRule>* tagValueGlobalRules;
HMAP::hash_map<int, RenderingRule>* tagValueGlobalRules;
std::vector<RenderingRuleProperty> properties;
std::hash_map<std::string, RenderingRuleProperty*> propertyMap;
HMAP::hash_map<std::string, RenderingRuleProperty*> propertyMap;
RenderingRule* createRenderingRule(JNIEnv* env, jobject rRule);
@ -75,7 +75,7 @@ public:
const static int ORDER_RULES = 5;
RenderingRulesStorage(JNIEnv* env, jobject storage) :
javaStorage(storage) {
tagValueGlobalRules = new std::hash_map<int, RenderingRule >[SIZE_STATES];
tagValueGlobalRules = new HMAP::hash_map<int, RenderingRule >[SIZE_STATES];
initDictionary(env);
initProperties(env);
initRules(env);

View file

@ -7,12 +7,6 @@
#include <vector>
#include <algorithm>
#include <set>
#ifdef LINUX_BUILD
#include <ext/hash_map>
using namespace __gnu_cxx;
#else
#include <hash_map>
#endif
#include <time.h>
#include <SkTypes.h>
@ -52,7 +46,7 @@ void calcPoint(std::pair<int, int> c, RenderingContext* rc)
}
std::hash_map<std::string, SkPathEffect*> pathEffects;
HMAP::hash_map<std::string, SkPathEffect*> pathEffects;
SkPathEffect* getDashEffect(std::string input)
{
if(pathEffects.find(input) != pathEffects.end())
@ -190,7 +184,7 @@ int updatePaint(RenderingRuleSearchRequest* req, SkPaint* paint, int ind, int ar
void renderText(MapDataObject* obj, RenderingRuleSearchRequest* req, RenderingContext* rc, std::string tag,
std::string value, float xText, float yText, SkPath* path) {
hash_map<std::string, std::string>::iterator it = obj->objectNames.begin();
HMAP::hash_map<std::string, std::string>::iterator it = obj->objectNames.begin();
while (it != obj->objectNames.end()) {
if (it->second.length() > 0) {
std::string name = it->second;
@ -507,9 +501,9 @@ void drawIconsOverCanvas(RenderingContext* rc, SkCanvas* canvas)
}
}
std::hash_map<int, std::vector<int> > sortObjectsByProperOrder(std::vector <MapDataObject* > mapDataObjects,
HMAP::hash_map<int, std::vector<int> > sortObjectsByProperOrder(std::vector <MapDataObject* > mapDataObjects,
RenderingRuleSearchRequest* req, RenderingContext* rc) {
std::hash_map<int, std::vector<int> > orderMap;
HMAP::hash_map<int, std::vector<int> > orderMap;
if (req != NULL) {
req->clearState();
const int size = mapDataObjects.size();
@ -546,9 +540,9 @@ std::hash_map<int, std::vector<int> > sortObjectsByProperOrder(std::vector <MapD
void doRendering(std::vector <MapDataObject* > mapDataObjects, SkCanvas* canvas, SkPaint* paint,
RenderingRuleSearchRequest* req, RenderingContext* rc) {
// put in order map
hash_map<int, std::vector<int> > orderMap = sortObjectsByProperOrder(mapDataObjects, req, rc);
HMAP::hash_map<int, std::vector<int> > orderMap = sortObjectsByProperOrder(mapDataObjects, req, rc);
std::set<int> keys;
hash_map<int, std::vector<int> >::iterator it = orderMap.begin();
HMAP::hash_map<int, std::vector<int> >::iterator it = orderMap.begin();
while(it != orderMap.end())
{
keys.insert(it->first);

View file

@ -2,12 +2,6 @@
#include <set>
#include <algorithm>
#include <math.h>
#ifdef LINUX_BUILD
#include <ext/hash_map>
using namespace __gnu_cxx;
#else
#include <hash_map>
#endif
#include <time.h>
#include <jni.h>
#include "SkTypes.h"
@ -367,10 +361,14 @@ inline float sqr(float a){
return a*a;
}
inline float absFloat(float a){
return a > 0 ? a : -a;
}
bool intersects(SkRect tRect, float tRot, TextDrawInfo* s)
{
float sRot = s->pathRotate;
if (abs(tRot) < M_PI / 15 && abs(sRot) < M_PI / 15) {
if (absFloat(tRot) < M_PI / 15 && absFloat(sRot) < M_PI / 15) {
return SkRect::Intersects(tRect, s->bounds);
}
float dist = sqrt(sqr(tRect.centerX() - s->bounds.centerX()) + sqr(tRect.centerY() - s->bounds.centerY()));
@ -380,7 +378,7 @@ bool intersects(SkRect tRect, float tRot, TextDrawInfo* s)
SkRect sRect = s->bounds;
// difference close to 90/270 degrees
if(abs(cos(tRot-sRot)) < 0.3 ){
if(absFloat(cos(tRot-sRot)) < 0.3 ){
// rotate one rectangle to 90 degrees
tRot += M_PI_2;
tRect = SkRect::MakeXYWH(tRect.centerX() - tRect.height() / 2, tRect.centerY() - tRect.width() / 2,
@ -388,7 +386,7 @@ bool intersects(SkRect tRect, float tRot, TextDrawInfo* s)
}
// determine difference close to 180/0 degrees
if(abs(sin(tRot-sRot)) < 0.3){
if(absFloat(sin(tRot-sRot)) < 0.3){
// rotate t box
// (calculate offset for t center suppose we rotate around s center)
float diff = atan2(tRect.centerY() - sRect.centerY(), tRect.centerX() - sRect.centerX());

View file

@ -15,7 +15,8 @@
// GNU General Public License for more details.
//
///////////////////////////////////////////////////////////////////
#ifndef _UTF_8_CPP
#define _UTF_8_CPP
#include <stdio.h>
#include <stdlib.h>
@ -113,3 +114,4 @@ int nextWord(uint8_t* s) {
}
return -1;
}
#endif