From ebaaf33a41220845bc29493591c00f1768748d52 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Mon, 30 Apr 2012 13:33:05 +0200 Subject: [PATCH] Confiure workspace --- Osmand-kernel/.cproject | 54 +++++++++++---- .../org.eclipse.cdt.codan.core.prefs | 66 +++++++++++++++++++ Osmand-kernel/Android.mk | 2 +- Osmand-kernel/osmand/binaryRead.cpp | 35 ++++++---- Osmand-kernel/osmand/common.cpp | 8 ++- Osmand-kernel/osmand/common.h | 4 ++ Osmand-kernel/osmand/mapObjects.h | 16 +++-- Osmand-kernel/osmand/multipolygons.h | 4 ++ Osmand-kernel/osmand/osmand_log.cpp | 2 +- Osmand-kernel/osmand/renderRules.cpp | 9 ++- Osmand-kernel/osmand/rendering.cpp | 18 +++-- Osmand-kernel/osmand/textdraw.cpp | 35 ++++++---- 12 files changed, 200 insertions(+), 53 deletions(-) create mode 100644 Osmand-kernel/.settings/org.eclipse.cdt.codan.core.prefs diff --git a/Osmand-kernel/.cproject b/Osmand-kernel/.cproject index 77c2ad2ef6..b9e5d45f26 100644 --- a/Osmand-kernel/.cproject +++ b/Osmand-kernel/.cproject @@ -29,14 +29,23 @@ + @@ -58,6 +67,24 @@ + + + + + + @@ -79,16 +106,7 @@ - - - - - - - - - - + @@ -97,8 +115,20 @@ + + + + + + + + + + + + diff --git a/Osmand-kernel/.settings/org.eclipse.cdt.codan.core.prefs b/Osmand-kernel/.settings/org.eclipse.cdt.codan.core.prefs new file mode 100644 index 0000000000..207bfae0e0 --- /dev/null +++ b/Osmand-kernel/.settings/org.eclipse.cdt.codan.core.prefs @@ -0,0 +1,66 @@ +eclipse.preferences.version=1 +org.eclipse.cdt.codan.checkers.errnoreturn=Warning +org.eclipse.cdt.codan.checkers.errnoreturn.params={implicit\=>false} +org.eclipse.cdt.codan.checkers.errreturnvalue=Error +org.eclipse.cdt.codan.checkers.errreturnvalue.params={} +org.eclipse.cdt.codan.checkers.noreturn=Error +org.eclipse.cdt.codan.checkers.noreturn.params={implicit\=>false} +org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation=Error +org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem=Error +org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem=Warning +org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={} +org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem=Error +org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={} +org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning +org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={no_break_comment\=>"no break",last_case_param\=>true,empty_case_param\=>false} +org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning +org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={unknown\=>false,exceptions\=>()} +org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=Error +org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem=-Error +org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.InvalidArguments=-Error +org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem=Error +org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem=-Error +org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem=-Error +org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem=-Error +org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker=-Info +org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={pattern\=>"^[a-z]",macro\=>true,exceptions\=>()} +org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem=Warning +org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={} +org.eclipse.cdt.codan.internal.checkers.OverloadProblem=Error +org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem=Error +org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem=Error +org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={} +org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={} +org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem=Warning +org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={macro\=>true,exceptions\=>()} +org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem=Warning +org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={paramNot\=>false} +org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem=Warning +org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={else\=>false,afterelse\=>false} +org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem=Warning +org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={macro\=>true} +org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem=Warning +org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={macro\=>true} +org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning +org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={macro\=>true,exceptions\=>("@(\#)","$Id")} +org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=-Info +org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +useParentScope=false diff --git a/Osmand-kernel/Android.mk b/Osmand-kernel/Android.mk index f9de066cf8..a201197c30 100755 --- a/Osmand-kernel/Android.mk +++ b/Osmand-kernel/Android.mk @@ -1,4 +1,4 @@ -_ANDROID_BUILD := true +ANDROID_BUILD := true OSMAND_MAKEFILES := $(all-subdir-makefiles) # By default, include makefiles only once diff --git a/Osmand-kernel/osmand/binaryRead.cpp b/Osmand-kernel/osmand/binaryRead.cpp index 1c60f470f5..57fab7a26d 100644 --- a/Osmand-kernel/osmand/binaryRead.cpp +++ b/Osmand-kernel/osmand/binaryRead.cpp @@ -8,8 +8,17 @@ #include #include #include +#include + +#ifdef LINUX_BUILD +#include +#include +using namespace __gnu_cxx; +#else #include #include +#endif + #include "google/protobuf/io/zero_copy_stream_impl.h" #include "google/protobuf/wire_format_lite.h" #include "google/protobuf/wire_format_lite.cc" @@ -127,7 +136,7 @@ struct MapIndex { std::string name; vector levels; - std::hash_map decodingRules; + hash_map decodingRules; // DEFINE hash //std::hash_map encodingRules; @@ -138,8 +147,8 @@ struct MapIndex { int landEncodingType; int onewayAttribute ; int onewayReverseAttribute ; - std::hash_set< int > positiveLayers; - std::hash_set< int > negativeLayers; + hash_set< int > positiveLayers; + hash_set< int > negativeLayers; MapIndex(){ nameEncodingType = refEncodingType = coastlineBrokenEncodingType = coastlineEncodingType = -1; @@ -559,10 +568,10 @@ MapDataObject* readMapDataObject(io::CodedInputStream* input, MapTreeBounds* tre } // READ types - std::vector< coordinates > innercoordinates; - std::vector< tag_value > additionalTypes; - std::vector< tag_value > types; - std::hash_map< std::string, unsigned int> stringIds; + vector< coordinates > innercoordinates; + vector< tag_value > additionalTypes; + vector< tag_value > types; + hash_map< std::string, unsigned int> stringIds; bool loop = true; while (loop) { uint32 t = input->ReadTag(); @@ -773,14 +782,14 @@ bool readMapDataBlocks(io::CodedInputStream* input, SearchQuery* req, MapTreeBou DO_((WireFormatLite::ReadPrimitive(input, &length))); int oldLimit = input->PushLimit(length); if(results.size() > 0) { - std::vector stringTable; + vector stringTable; readStringTable(input, stringTable); MapDataObject* o; for (std::vector::iterator obj = results.begin(); obj != results.end(); obj++) { if ((*obj)->stringIds.size() > 0) { - std::hash_map::iterator val=(*obj)->stringIds.begin(); + hash_map::iterator val=(*obj)->stringIds.begin(); while(val != (*obj)->stringIds.end()){ - (*obj)->objectNames[val->first]=stringTable.at(val->second); + (*obj)->objectNames[val->first]=stringTable[val->second]; val++; } } @@ -869,8 +878,8 @@ extern "C" JNIEXPORT jint JNICALL Java_net_osmand_plus_render_NativeOsmandLibrar q.zoom = zoom; SearchResult* searchRes = new SearchResult(); - std::map::iterator i = openFiles.begin(); - std::hash_set ids; + map::iterator i = openFiles.begin(); + hash_set ids; int count = 0; bool ocean = false; std::vector basemapResult; @@ -910,7 +919,7 @@ extern "C" JNIEXPORT jint JNICALL Java_net_osmand_plus_render_NativeOsmandLibrar } if (!q.isCancelled()) { std::vector::iterator r = q.result.begin(); - tempResult.reserve(q.result.size() + tempResult.size()); + tempResult.reserve((size_t)(q.result.size() + tempResult.size())); for (; r != q.result.end(); r++) { // TODO skip duplicates doesn't work correctly with basemap (id < 0?) if (skipDuplicates && (*r)->id > 0 && false) { diff --git a/Osmand-kernel/osmand/common.cpp b/Osmand-kernel/osmand/common.cpp index 82c2494783..62ad01d2dc 100644 --- a/Osmand-kernel/osmand/common.cpp +++ b/Osmand-kernel/osmand/common.cpp @@ -5,6 +5,12 @@ #include #include #include +#include + +// constant CLOCK_MONOTONIC is included in linux time.h +#ifdef LINUX_BUILD + #include +#endif #include "common.h" #include "osmand_log.h" @@ -314,7 +320,7 @@ SkBitmap* getCachedBitmap(RenderingContext* rc, const std::string& bitmapResourc return NULL; jbyte* bitmapBuffer = env->GetByteArrayElements(javaIconRawData, NULL); - size_t bufferLen = env->GetArrayLength(javaIconRawData); + jint bufferLen = env->GetArrayLength(javaIconRawData); // Decode bitmap SkBitmap* iconBitmap = new SkBitmap(); diff --git a/Osmand-kernel/osmand/common.h b/Osmand-kernel/osmand/common.h index dcbb39c5d7..fc771ea4df 100644 --- a/Osmand-kernel/osmand/common.h +++ b/Osmand-kernel/osmand/common.h @@ -4,7 +4,11 @@ #include #include #include +#ifdef LINUX_BUILD +#include +#else #include +#endif #include #include diff --git a/Osmand-kernel/osmand/mapObjects.h b/Osmand-kernel/osmand/mapObjects.h index 4526dbc027..4f6188ceb1 100644 --- a/Osmand-kernel/osmand/mapObjects.h +++ b/Osmand-kernel/osmand/mapObjects.h @@ -3,14 +3,20 @@ #include #include +#ifdef LINUX_BUILD +#include +using namespace __gnu_cxx; +#else #include +using namespace std; +#endif #include #include "common.h" -typedef std::pair tag_value; -typedef std::pair int_pair; -typedef std::vector< std::pair > coordinates; +typedef pair tag_value; +typedef pair int_pair; +typedef vector< pair > coordinates; class MapDataObject @@ -24,9 +30,9 @@ public: coordinates points; std::vector < coordinates > polygonInnerCoordinates; - std::hash_map< std::string, unsigned int> stringIds; + hash_map< std::string, unsigned int> stringIds; - std::hash_map< std::string, std::string > objectNames; + hash_map< std::string, std::string > objectNames; bool area; long long id; diff --git a/Osmand-kernel/osmand/multipolygons.h b/Osmand-kernel/osmand/multipolygons.h index a3fbadf750..796e47bf0b 100644 --- a/Osmand-kernel/osmand/multipolygons.h +++ b/Osmand-kernel/osmand/multipolygons.h @@ -2,7 +2,11 @@ #include #include #include +#ifdef LINUX_BUILD +#include +#else #include +#endif #include "renderRules.h" diff --git a/Osmand-kernel/osmand/osmand_log.cpp b/Osmand-kernel/osmand/osmand_log.cpp index c6015b5db0..22032ef6b7 100644 --- a/Osmand-kernel/osmand/osmand_log.cpp +++ b/Osmand-kernel/osmand/osmand_log.cpp @@ -2,7 +2,7 @@ #define _OSMAND_LOG_CPP -#ifdef _ANDROID_BUILD +#ifdef ANDROID_BUILD #include const char* const LOG_TAG = "net.osmand:native"; diff --git a/Osmand-kernel/osmand/renderRules.cpp b/Osmand-kernel/osmand/renderRules.cpp index d96aa69b19..65fdf57d8e 100644 --- a/Osmand-kernel/osmand/renderRules.cpp +++ b/Osmand-kernel/osmand/renderRules.cpp @@ -6,7 +6,12 @@ #include #include #include +#ifdef LINUX_BUILD +#include +using namespace __gnu_cxx; +#else #include +#endif #include "renderRules.h" #include "common.h" @@ -51,7 +56,7 @@ RenderingRuleProperty* RenderingRulesStorage::getProperty(int i) { } RenderingRule* RenderingRulesStorage::getRule(int state, int itag, int ivalue) { - std::hash_map::iterator it = (tagValueGlobalRules[state]).find( + hash_map::iterator it = (tagValueGlobalRules[state]).find( (itag << SHIFT_TAG_VAL) | ivalue); if (it == tagValueGlobalRules[state].end()) { return NULL; @@ -60,7 +65,7 @@ RenderingRule* RenderingRulesStorage::getRule(int state, int itag, int ivalue) { } RenderingRuleProperty* RenderingRulesStorage::getProperty(const char* st) { - std::hash_map::iterator i = propertyMap.find(st); + hash_map::iterator i = propertyMap.find(st); if (i == propertyMap.end()) { return NULL; } diff --git a/Osmand-kernel/osmand/rendering.cpp b/Osmand-kernel/osmand/rendering.cpp index 7dc282b99d..16307e80d2 100644 --- a/Osmand-kernel/osmand/rendering.cpp +++ b/Osmand-kernel/osmand/rendering.cpp @@ -1,6 +1,5 @@ #include #include "osmand_log.h" -#include #include #include @@ -8,7 +7,12 @@ #include #include #include +#ifdef LINUX_BUILD +#include +using namespace __gnu_cxx; +#else #include +#endif #include #include @@ -186,7 +190,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) { - std::hash_map::iterator it = obj->objectNames.begin(); + hash_map::iterator it = obj->objectNames.begin(); while (it != obj->objectNames.end()) { if (it->second.length() > 0) { std::string name = it->second; @@ -542,9 +546,9 @@ std::hash_map > sortObjectsByProperOrder(std::vector mapDataObjects, SkCanvas* canvas, SkPaint* paint, RenderingRuleSearchRequest* req, RenderingContext* rc) { // put in order map - std::hash_map > orderMap = sortObjectsByProperOrder(mapDataObjects, req, rc); + hash_map > orderMap = sortObjectsByProperOrder(mapDataObjects, req, rc); std::set keys; - std::hash_map >::iterator it = orderMap.begin(); + hash_map >::iterator it = orderMap.begin(); while(it != orderMap.end()) { keys.insert(it->first); @@ -603,6 +607,9 @@ void loadJniRendering(JNIEnv* env) jmethod_JUnidecode_unidecode = env->GetStaticMethodID(jclass_JUnidecode, "unidecode", "(Ljava/lang/String;)Ljava/lang/String;"); } +#ifdef ANDROID_BUILD +#include + extern "C" JNIEXPORT jobject JNICALL Java_net_osmand_plus_render_NativeOsmandLibrary_generateRendering_1Direct( JNIEnv* ienv, jobject obj, jobject renderingContext, jint searchResult, jobject targetBitmap, @@ -697,7 +704,7 @@ extern "C" JNIEXPORT jobject JNICALL Java_net_osmand_plus_render_NativeOsmandLib pushToJavaRenderingContext(ienv, renderingContext, &rc); osmand_log_print(LOG_INFO, "End Rendering image"); if(dl_AndroidBitmap_unlockPixels(ienv, targetBitmap) != ANDROID_BITMAP_RESUT_SUCCESS) { - osmand_log_print(LOG_ERROR, "Failed to execute AndroidBitmap_unlockPixels"); + osmand_log_print(LOG_ERROR, "Failed to execute AndroidBitmap_unlockPixels"); } // delete variables @@ -722,6 +729,7 @@ extern "C" JNIEXPORT jobject JNICALL Java_net_osmand_plus_render_NativeOsmandLib return resultObject; } +#endif void* bitmapData = NULL; size_t bitmapDataSize = 0; diff --git a/Osmand-kernel/osmand/textdraw.cpp b/Osmand-kernel/osmand/textdraw.cpp index e558905e8b..50a15bd59f 100644 --- a/Osmand-kernel/osmand/textdraw.cpp +++ b/Osmand-kernel/osmand/textdraw.cpp @@ -1,7 +1,13 @@ #include #include #include +#include +#ifdef LINUX_BUILD +#include +using namespace __gnu_cxx; +#else #include +#endif #include #include #include "SkTypes.h" @@ -24,7 +30,7 @@ private : SkRect bounds; node(SkRect& b) : bounds(b) { - std::memset(children,0,4*sizeof(node*)); + memset(children,0,4*sizeof(node*)); } ~node() { @@ -211,7 +217,7 @@ bool calculatePathToRotate(RenderingContext* rc, TextDrawInfo* p) { py += points[i].fY - points[i - 1].fY; } if (px != 0 || py != 0) { - p->pathRotate = std::atan2(py, px); + p->pathRotate = atan2(py, px); } return true; } @@ -231,7 +237,7 @@ bool calculatePathToRotate(RenderingContext* rc, TextDrawInfo* p) { bool inside = points[i].fX >= 0 && points[i].fX <= rc->width && points[i].fY >= 0 && points[i].fY <= rc->height; if (i > 0) { - float d = std::sqrt( + float d = sqrt( (points[i].fX - points[i - 1].fX) * (points[i].fX - points[i - 1].fX) + (points[i].fY - points[i - 1].fY) * (points[i].fY - points[i - 1].fY)); distances.push_back(d); @@ -302,12 +308,12 @@ bool calculatePathToRotate(RenderingContext* rc, TextDrawInfo* p) { py += points[i].fY - points[i - 1].fY; } float scale = 0.5f; - float plen = std::sqrt(px * px + py * py); + float plen = sqrt(px * px + py * py); // vector ox,oy orthogonal to px,py to measure height float ox = -py; float oy = px; if(plen > 0) { - float rot = std::atan2(py, px); + float rot = atan2(py, px); if (rot < 0) rot += M_PI * 2; if (rot > M_PI_2 && rot < 3 * M_PI_2) { rot += M_PI; @@ -400,7 +406,10 @@ bool intersects(SkRect tRect, float tRot, TextDrawInfo* s) bool intersects(TextDrawInfo* t, TextDrawInfo* s) { return intersects(t->bounds, t->pathRotate, s); } -std::vector search; +inline float max(float a, float b) { + return a > b ? a : b; +} +vector searchText; bool findTextIntersection(SkCanvas* cv, RenderingContext* rc, quad_tree& boundIntersections, TextDrawInfo* text, SkPaint* paintText, SkPaint* paintIcon) { paintText->measureText(text->text.c_str(), text->text.length(), &text->bounds); @@ -422,20 +431,20 @@ bool findTextIntersection(SkCanvas* cv, RenderingContext* rc, quad_treebounds, text->pathRotate, paintIcon, text->text, NULL/*paintText*/); - boundIntersections.query_in_box(text->bounds, search); - for (uint i = 0; i < search.size(); i++) { - TextDrawInfo* t = search.at(i); + boundIntersections.query_in_box(text->bounds, searchText); + for (uint i = 0; i < searchText.size(); i++) { + TextDrawInfo* t = searchText.at(i); if (intersects(text, t)) { return true; } } if(text->minDistance > 0) { SkRect boundsSearch = text->bounds; - boundsSearch.inset(-getDensityValue(rc, std::max(5.0f, text->minDistance)), -getDensityValue(rc, 15)); - boundIntersections.query_in_box(boundsSearch, search); + boundsSearch.inset(-getDensityValue(rc, max(5.0f, text->minDistance)), -getDensityValue(rc, 15)); + boundIntersections.query_in_box(boundsSearch, searchText); // drawTestBox(cv, &boundsSearch, text->pathRotate, paintIcon, text->text, paintText); - for (uint i = 0; i < search.size(); i++) { - TextDrawInfo* t = search.at(i); + for (uint i = 0; i < searchText.size(); i++) { + TextDrawInfo* t = searchText.at(i); if (t->minDistance > 0 && t->text == text->text && intersects(boundsSearch, text->pathRotate, t)) { return true; }