Modify rendering bitmap loading
This commit is contained in:
parent
fdcb956e06
commit
dfe0380714
8 changed files with 184 additions and 261 deletions
|
@ -31,6 +31,7 @@
|
|||
<listOptionValue builtIn="false" value="/home/victor/projects/android-ndk-r6b/platforms/android-3/arch-arm/usr/include"/>
|
||||
<listOptionValue builtIn="false" value="/home/victor/projects/android/external/skia/include/core"/>
|
||||
<listOptionValue builtIn="false" value="/home/victor/projects/android/frameworks/base/include"/>
|
||||
<listOptionValue builtIn="false" value="/home/victor/projects/android/external/skia/include/effects"/>
|
||||
</option>
|
||||
<inputType id="com.android.tool.compiler.g++.input.478508689" superClass="com.android.tool.compiler.g++.input"/>
|
||||
</tool>
|
||||
|
|
|
@ -27,126 +27,14 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/jni \
|
|||
$(SKIA_FOLDER)/include/core \
|
||||
$(SKIA_FOLDER)/include/utils \
|
||||
$(SKIA_FOLDER)/include/config \
|
||||
$(SKIA_FOLDER)/include/effects \
|
||||
$(SKIA_FOLDER)/include/utils/android \
|
||||
$(SKIA_FOLDER)/src/core \
|
||||
$(ANDROID_FOLDER)/system/core/include \
|
||||
$(ANDROID_FOLDER)/frameworks/base/include
|
||||
|
||||
|
||||
# skia/src/core/SkAdvancedTypefaceMetrics.cpp
|
||||
# skia/src/core/SkDrawing.cpp \
|
||||
|
||||
LOCAL_SRC_FILES := osmand/rendering.cpp
|
||||
# $(SKIA_SRC)/src/ports/SkDebug_stdio.cpp \
|
||||
# $(SKIA_SRC)/src/ports/SkFontHost_simple.cpp \
|
||||
# $(SKIA_SRC)/src/ports/SkFontHost_gamma.cpp \
|
||||
# $(SKIA_SRC)/src/ports/SkGlobals_global.cpp \
|
||||
# $(SKIA_SRC)/src/ports/SkOSFile_stdio.cpp \
|
||||
# $(SKIA_SRC)/src/opts/SkBlitRow_opts_none.cpp \
|
||||
# $(SKIA_SRC)/src/core/Sk64.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkAAClip.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkAlphaRuns.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkBitmap.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkBitmapProcShader.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkBitmapProcState.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkBitmapProcState_matrixProcs.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkBitmapSampler.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkBitmap_scroll.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkBlitMask_D32.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkBlitRow_D16.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkBlitRow_D32.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkBlitRow_D4444.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkBlitter.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkBlitter_4444.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkBlitter_A1.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkBlitter_A8.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkBlitter_ARGB32.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkBlitter_RGB16.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkBlitter_Sprite.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkBuffer.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkCanvas.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkChunkAlloc.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkClampRange.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkClipStack.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkColor.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkColorFilter.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkColorTable.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkComposeShader.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkConcaveToTriangles.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkCordic.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkCubicClipper.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkData.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkDebug.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkDeque.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkDevice.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkDither.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkDraw.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkEdge.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkEdgeBuilder.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkEdgeClipper.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkFilterProc.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkFlate.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkFlattenable.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkFloat.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkFloatBits.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkFontHost.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkGeometry.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkGlobals.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkGlyphCache.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkGraphics.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkLineClipper.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkMallocPixelRef.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkMask.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkMaskFilter.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkMath.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkMatrix.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkMemory_stdlib.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkMetaData.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkMMapStream.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkPackBits.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkPaint.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkPath.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkPathEffect.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkPathHeap.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkPathMeasure.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkPicture.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkPictureFlat.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkPicturePlayback.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkPictureRecord.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkPixelRef.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkPoint.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkProcSpriteBlitter.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkPtrRecorder.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkQuadClipper.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkRasterClip.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkRasterizer.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkRect.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkRefDict.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkRegion.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkRegion_path.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkRegion_rects.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkScalar.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkScalerContext.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkScan.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkScan_Antihair.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkScan_AntiPath.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkScan_Hairline.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkScan_Path.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkShader.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkShape.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkSpriteBlitter_ARGB32.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkSpriteBlitter_RGB16.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkStream.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkString.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkStroke.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkStrokerPriv.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkTSearch.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkTypeface.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkTypefaceCache.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkUnPreMultiply.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkUtils.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkWriter32.cpp \
|
||||
# $(SKIA_SRC)/src/core/SkXfermode.cpp
|
||||
|
||||
|
||||
LOCAL_CFLAGS := -Wall -g
|
||||
|
@ -157,7 +45,6 @@ LOCAL_LDLIBS := -ldl -llog -lcutils
|
|||
LOCAL_SHARED_LIBRARIES := skia2.2
|
||||
# libcutils \
|
||||
# libutils \
|
||||
# libskia \
|
||||
# libandroid_runtime \
|
||||
# libGLESv2
|
||||
|
||||
|
|
|
@ -7,6 +7,11 @@
|
|||
|
||||
#include "SkTypes.h"
|
||||
#include "SkBitmap.h"
|
||||
#include "SkShader.h"
|
||||
#include "SkBitmapProcShader.h"
|
||||
#include "SkPathEffect.h"
|
||||
#include "SkBlurDrawLooper.h"
|
||||
#include "SkDashPathEffect.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkPaint.h"
|
||||
#include "SkPath.h"
|
||||
|
@ -23,23 +28,8 @@ jclass CanvasClass;
|
|||
jmethodID Canvas_drawPath;
|
||||
jfieldID Canvas_nativeCanvas;
|
||||
|
||||
jclass PaintClass;
|
||||
jmethodID PaintClass_setStrokeWidth;
|
||||
jmethodID PaintClass_setStrokeCap;
|
||||
jmethodID PaintClass_setPathEffect;
|
||||
jmethodID PaintClass_setStyle;
|
||||
jmethodID PaintClass_setColor;
|
||||
jclass BitmapFactoryClass;
|
||||
|
||||
jclass PaintStyleClass;
|
||||
jobject PaintStyle_STROKE;
|
||||
jobject PaintStyle_FILL_AND_STROKE;
|
||||
|
||||
jclass DashPathEffect;
|
||||
jmethodID DashPathEffect_init;
|
||||
|
||||
jclass CapClass;
|
||||
jobject CapClass_BUTT;
|
||||
jmethodID CapClass_valueOf;
|
||||
|
||||
jclass MapRenderingTypesClass;
|
||||
jmethodID MapRenderingTypes_getMainObjectType;
|
||||
|
@ -140,8 +130,6 @@ jfieldID getFid(jclass cls,const char* fieldName, const char* sig )
|
|||
rc -> calcX = rc -> cosRotateTileSize * dTileX - rc -> sinRotateTileSize * dTileY;
|
||||
rc -> calcY = rc -> sinRotateTileSize * dTileX + rc -> cosRotateTileSize * dTileY;
|
||||
|
||||
// sprintf(debugMessage, "Coordinates %f %f", rc->calcX, rc->calcY);
|
||||
// __android_log_print(ANDROID_LOG_WARN, "net.osmand", debugMessage);
|
||||
if(rc -> calcX >= 0 && rc -> calcX < rc -> width &&
|
||||
rc -> calcY >= 0 && rc -> calcY < rc ->height){
|
||||
rc -> pointInsideCount++;
|
||||
|
@ -196,20 +184,19 @@ float getFloatPropertyValue(jobject renderingRuleSearch, const char* prop)
|
|||
return res;
|
||||
}
|
||||
|
||||
jobject getDashEffect(jstring dashes){
|
||||
int length = env->GetStringLength( dashes);
|
||||
const char* chars = env->GetStringUTFChars( dashes, NULL);
|
||||
SkPathEffect* getDashEffect(const char* chars){
|
||||
int i = 0;
|
||||
char fval[10];
|
||||
int flength = 0;
|
||||
jfloat primFloats[20];
|
||||
float primFloats[20];
|
||||
int floatLen = 0;
|
||||
for(;i<=length;i++)
|
||||
for(;;i++)
|
||||
{
|
||||
if(i == length)
|
||||
if(chars[i] == 0)
|
||||
{
|
||||
if(flength > 0) { fval[flength] = 0;
|
||||
primFloats[floatLen++] = atof(fval); flength = 0;}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -223,16 +210,13 @@ jobject getDashEffect(jstring dashes){
|
|||
}
|
||||
}
|
||||
}
|
||||
env->ReleaseStringUTFChars( dashes, chars);
|
||||
jfloatArray floatArray = env->NewFloatArray( floatLen);
|
||||
env->SetFloatArrayRegion(floatArray, 0, floatLen, primFloats);
|
||||
jobject dashEffect = env->NewObject( DashPathEffect, DashPathEffect_init, floatArray, 0);
|
||||
env->DeleteLocalRef( floatArray);
|
||||
return dashEffect;
|
||||
return new SkDashPathEffect(primFloats, floatLen, 0);
|
||||
}
|
||||
|
||||
int updatePaint(jobject renderingRuleSearch, SkPaint* paint, int ind, int area,
|
||||
RenderingContext* rc) {
|
||||
|
||||
// TODO cache shaders
|
||||
// TODO path effects
|
||||
int updatePaint(jobject renderingRuleSearch, SkPaint* paint, int ind, int area, RenderingContext* rc) {
|
||||
const char* rColor;
|
||||
const char* rStrokeW;
|
||||
const char* rCap;
|
||||
|
@ -253,45 +237,79 @@ int updatePaint(jobject renderingRuleSearch, SkPaint* paint, int ind, int area,
|
|||
rCap = "R_CAP_3";
|
||||
rPathEff = "R_PATH_EFFECT_3";
|
||||
}
|
||||
if (!area) {
|
||||
// TODO not complete
|
||||
if (area) {
|
||||
paint->setStyle(SkPaint::kStrokeAndFill_Style);
|
||||
paint->setStrokeWidth(0);
|
||||
} else {
|
||||
float stroke = getFloatPropertyValue(renderingRuleSearch, rStrokeW);
|
||||
if (!(stroke > 0)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int color = getIntPropertyValue(renderingRuleSearch, rColor);
|
||||
paint->setStyle(SkPaint::kStroke_Style);
|
||||
paint->setColor(color);
|
||||
paint->setStrokeWidth(stroke);
|
||||
jstring cap = getStringPropertyValue(renderingRuleSearch, rCap);
|
||||
jstring pathEff = getStringPropertyValue(renderingRuleSearch, rPathEff);
|
||||
jstring capStr = getStringPropertyValue(renderingRuleSearch, rCap);
|
||||
jstring pathEffStr = getStringPropertyValue(renderingRuleSearch, rPathEff);
|
||||
|
||||
if (cap != NULL && env->GetStringLength( cap) > 0) {
|
||||
jobject capObj = env->CallStaticObjectMethod( CapClass, CapClass_valueOf, cap);
|
||||
// TODO
|
||||
paint->setStrokeCap(SkPaint::kButt_Cap);
|
||||
env->DeleteLocalRef( capObj);
|
||||
if (capStr != NULL && env->GetStringLength(capStr) > 0) {
|
||||
const char* cap = env->GetStringUTFChars(capStr, NULL);
|
||||
if (strcmp("BUTT", cap) == 0) {
|
||||
paint->setStrokeCap(SkPaint::kButt_Cap);
|
||||
} else if (strcmp("ROUND", cap) == 0) {
|
||||
paint->setStrokeCap(SkPaint::kRound_Cap);
|
||||
} else if (strcmp("SQUARE", cap) == 0) {
|
||||
paint->setStrokeCap(SkPaint::kSquare_Cap);
|
||||
}
|
||||
env->ReleaseStringUTFChars(capStr, cap);
|
||||
} else {
|
||||
paint->setStrokeCap(SkPaint::kButt_Cap);
|
||||
}
|
||||
|
||||
if (pathEff != NULL && env->GetStringLength(pathEff) > 0) {
|
||||
// TODO
|
||||
//jobject pathObj = getDashEffect(pathEff);
|
||||
//env->CallVoidMethod( paint, PaintClass_setPathEffect, pathObj);
|
||||
// env->DeleteLocalRef( pathObj );
|
||||
if (pathEffStr != NULL && env->GetStringLength(pathEffStr) > 0) {
|
||||
const char* pathEff = env->GetStringUTFChars(pathEffStr, NULL);
|
||||
SkPathEffect* p = getDashEffect(pathEff);
|
||||
paint->setPathEffect(p);
|
||||
p->unref();
|
||||
env->ReleaseStringUTFChars(pathEffStr, pathEff);
|
||||
} else {
|
||||
paint-> setPathEffect(NULL);
|
||||
paint->setPathEffect(NULL);
|
||||
}
|
||||
|
||||
env->DeleteLocalRef( cap);
|
||||
env->DeleteLocalRef( pathEff);
|
||||
|
||||
return 1;
|
||||
env->DeleteLocalRef(capStr);
|
||||
env->DeleteLocalRef(pathEffStr);
|
||||
}
|
||||
|
||||
return 0;
|
||||
int color = getIntPropertyValue(renderingRuleSearch, rColor);
|
||||
paint->setColor(color);
|
||||
|
||||
if (ind == 0) {
|
||||
// Integer resId = RenderingIcons.getIcons().get(req.getStringPropertyValue(req.ALL.R_SHADER));
|
||||
// if(resId != null){
|
||||
// p.setColor(Color.BLACK);
|
||||
// p.setShader(getShader(resId));
|
||||
// } else {
|
||||
// p.setShader(null);
|
||||
// }
|
||||
|
||||
} else {
|
||||
paint->setShader(NULL);
|
||||
}
|
||||
|
||||
// do not check shadow color here
|
||||
if (rc->shadowRenderingMode != 1 || ind != 0) {
|
||||
paint->setLooper(NULL);
|
||||
} else {
|
||||
int shadowColor = getIntPropertyValue(renderingRuleSearch, "R_SHADOW_COLOR");
|
||||
int shadowLayer = getIntPropertyValue(renderingRuleSearch, "R_SHADOW_RADIUS");
|
||||
if (shadowColor == 0) {
|
||||
shadowLayer = 0;
|
||||
}
|
||||
if (shadowLayer > 0) {
|
||||
paint->setLooper(new SkBlurDrawLooper(shadowLayer, 0, 0, shadowColor))->unref();
|
||||
}
|
||||
paint->setLooper(NULL);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void drawPolyline(jobject binaryMapDataObject, jobject renderingRuleSearch, SkCanvas* cv, SkPaint* paint,
|
||||
|
@ -322,7 +340,6 @@ int updatePaint(jobject renderingRuleSearch, SkPaint* paint, int ind, int area,
|
|||
|
||||
int rendered = env->CallBooleanMethod( renderingRuleSearch,
|
||||
RenderingRuleSearchRequest_search, 2);
|
||||
// __android_log_print(ANDROID_LOG_WARN, "net.osmand", "Search done");
|
||||
env->DeleteLocalRef( tag);
|
||||
env->DeleteLocalRef( value);
|
||||
if (!rendered || !updatePaint(renderingRuleSearch, paint, 0, 0, rc)) {
|
||||
|
@ -330,21 +347,15 @@ int updatePaint(jobject renderingRuleSearch, SkPaint* paint, int ind, int area,
|
|||
}
|
||||
|
||||
rc->visible++;
|
||||
// __android_log_print(ANDROID_LOG_WARN, "net.osmand", "About to draw");
|
||||
SkPath path ;
|
||||
int i = 0;
|
||||
float px = 0;
|
||||
float py = 0;
|
||||
for (; i < length; i++) {
|
||||
calcPoint(binaryMapDataObject, i, rc);
|
||||
if (i == 0) {
|
||||
path.moveTo(rc->calcX, rc->calcY);
|
||||
} else {
|
||||
// cv->drawLine(px, py, rc->calcX, rc->calcY, *paint);
|
||||
path.lineTo(rc->calcX, rc->calcY);
|
||||
}
|
||||
px = rc->calcX;
|
||||
py = rc->calcY;
|
||||
}
|
||||
if (i > 0) {
|
||||
if (drawOnlyShadow) {
|
||||
|
@ -361,7 +372,59 @@ int updatePaint(jobject renderingRuleSearch, SkPaint* paint, int ind, int area,
|
|||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void drawPolygon(jobject binaryMapDataObject, jobject renderingRuleSearch, SkCanvas* cv, SkPaint* paint,
|
||||
RenderingContext* rc, jobject pair) {
|
||||
if (renderingRuleSearch == NULL || pair == NULL) {
|
||||
return;
|
||||
}
|
||||
jint length = env->CallIntMethod(binaryMapDataObject, BinaryMapDataObject_getPointsLength);
|
||||
if (length <= 2) {
|
||||
return;
|
||||
}
|
||||
jstring tag = (jstring) env->GetObjectField(pair, TagValuePair_tag);
|
||||
jstring value = (jstring) env->GetObjectField(pair, TagValuePair_value);
|
||||
|
||||
env->CallVoidMethod(renderingRuleSearch, RenderingRuleSearchRequest_setInitialTagValueZoom, tag, value, rc->zoom);
|
||||
|
||||
int rendered = env->CallBooleanMethod(renderingRuleSearch, RenderingRuleSearchRequest_search, 3);
|
||||
env->DeleteLocalRef(tag);
|
||||
env->DeleteLocalRef(value);
|
||||
|
||||
float xText = 0;
|
||||
float yText = 0;
|
||||
if (!rendered || !updatePaint(renderingRuleSearch, paint, 0, 1, rc)) {
|
||||
return;
|
||||
}
|
||||
|
||||
rc->visible++;
|
||||
SkPath path;
|
||||
int i = 0;
|
||||
float px = 0;
|
||||
float py = 0;
|
||||
for (; i < length; i++) {
|
||||
calcPoint(binaryMapDataObject, i, rc);
|
||||
if (i == 0) {
|
||||
path.moveTo(rc->calcX, rc->calcY);
|
||||
} else {
|
||||
path.lineTo(rc->calcX, rc->calcY);
|
||||
}
|
||||
xText += px;
|
||||
yText += py;
|
||||
}
|
||||
|
||||
cv->drawPath(path, *paint);
|
||||
if (updatePaint(renderingRuleSearch, paint, 1, 0, rc)) {
|
||||
cv->drawPath(path, *paint);
|
||||
}
|
||||
|
||||
// TODO polygon text
|
||||
// String name = obj.getName();
|
||||
// if(name != null){
|
||||
// drawPointText(render, rc, pair, xText / len, yText / len, name);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
void drawObject(RenderingContext* rc, jobject binaryMapDataObject, SkCanvas* cv,
|
||||
|
@ -390,16 +453,12 @@ void drawObject(RenderingContext* rc, jobject binaryMapDataObject, SkCanvas* cv,
|
|||
int layer = env->CallStaticIntMethod( MapRenderingTypesClass,
|
||||
MapRenderingTypes_getNegativeWayLayer, mainType);
|
||||
// __android_log_print(ANDROID_LOG_WARN, "net.osmand", "Draw polyline");
|
||||
|
||||
drawPolyline(binaryMapDataObject, renderingRuleSearch, cv, paint, rc, pair, layer, drawOnlyShadow);
|
||||
} else if(t == 3 && !drawOnlyShadow) {
|
||||
// polygon
|
||||
|
||||
// drawPolygon(obj, render, canvas, rc, pair);
|
||||
drawPolygon(binaryMapDataObject, renderingRuleSearch, cv, paint, rc, pair);
|
||||
}
|
||||
|
||||
env->DeleteLocalRef( pair);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -466,27 +525,6 @@ void initLibrary(jobject rc)
|
|||
"(Landroid/graphics/Path;Landroid/graphics/Paint;)V" );
|
||||
Canvas_nativeCanvas = env->GetFieldID( CanvasClass, "mNativeCanvas","I" );
|
||||
|
||||
PaintClass = globalRef(env->FindClass( "android/graphics/Paint"));
|
||||
PaintClass_setColor = env->GetMethodID( PaintClass, "setColor", "(I)V" );
|
||||
PaintClass_setStrokeWidth = env->GetMethodID( PaintClass, "setStrokeWidth", "(F)V" );
|
||||
PaintClass_setStrokeCap = env->GetMethodID( PaintClass, "setStrokeCap", "(Landroid/graphics/Paint$Cap;)V" );
|
||||
PaintClass_setPathEffect = env->GetMethodID( PaintClass, "setPathEffect",
|
||||
"(Landroid/graphics/PathEffect;)Landroid/graphics/PathEffect;" );
|
||||
PaintClass_setStyle = env->GetMethodID( PaintClass, "setStyle", "(Landroid/graphics/Paint$Style;)V" );
|
||||
|
||||
DashPathEffect = globalRef(env->FindClass( "android/graphics/DashPathEffect"));
|
||||
DashPathEffect_init =env->GetMethodID( DashPathEffect, "<init>", "([FF)V" );
|
||||
|
||||
CapClass = globalRef(env->FindClass( "android/graphics/Paint$Cap"));
|
||||
CapClass_valueOf = env->GetStaticMethodID( CapClass, "valueOf", "(Ljava/lang/String;)Landroid/graphics/Paint$Cap;" );
|
||||
CapClass_BUTT = globalRef(env->GetStaticObjectField( CapClass,
|
||||
env-> GetStaticFieldID( CapClass, "BUTT","Landroid/graphics/Paint$Cap;")));
|
||||
|
||||
PaintStyleClass = globalRef(env->FindClass( "android/graphics/Paint$Style"));
|
||||
PaintStyle_FILL_AND_STROKE = globalObj(env->GetStaticObjectField( PaintStyleClass,
|
||||
env-> GetStaticFieldID( PaintStyleClass, "FILL_AND_STROKE","Landroid/graphics/Paint$Style;")));
|
||||
PaintStyle_STROKE = globalObj(env->GetStaticObjectField( PaintStyleClass,
|
||||
env-> GetStaticFieldID( PaintStyleClass, "STROKE","Landroid/graphics/Paint$Style;")));
|
||||
|
||||
RenderingContextClass = globalRef(env->GetObjectClass( rc));
|
||||
RenderingContextClass_interrupted = getFid( RenderingContextClass, "interrupted", "Z" );
|
||||
|
@ -544,14 +582,7 @@ void unloadLibrary()
|
|||
env->DeleteGlobalRef( MapRenderingTypesClass );
|
||||
env->DeleteGlobalRef( PathClass );
|
||||
env->DeleteGlobalRef( CanvasClass );
|
||||
env->DeleteGlobalRef( PaintClass );
|
||||
env->DeleteGlobalRef( RenderingContextClass );
|
||||
env->DeleteGlobalRef( DashPathEffect );
|
||||
env->DeleteGlobalRef( CapClass );
|
||||
env->DeleteGlobalRef( CapClass_BUTT );
|
||||
env->DeleteGlobalRef( PaintStyleClass );
|
||||
env->DeleteGlobalRef( PaintStyle_FILL_AND_STROKE );
|
||||
env->DeleteGlobalRef( PaintStyle_STROKE );
|
||||
env->DeleteGlobalRef( TagValuePairClass);
|
||||
env->DeleteGlobalRef( RenderingRuleSearchRequestClass);
|
||||
env->DeleteGlobalRef( RenderingRulePropertyClass);
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
set solib-search-path /home/victor/projects/OsmAnd/git/OsmAnd/obj/local/armeabi
|
||||
directory /home/victor/projects/android-ndk-r6b/platforms/android-8/arch-arm/usr/include /home/victor/projects/OsmAnd/git/OsmAnd/jni/jni /home/victor/projects/android//external/skia/include/core /home/victor/projects/android//external/skia/include/utils /home/victor/projects/android//external/skia/include/config /home/victor/projects/android//external/skia/include/utils/android /home/victor/projects/android//external/skia/src/core /home/victor/projects/android//system/core/include /home/victor/projects/android//frameworks/base/include /home/victor/projects/android-ndk-r6b/sources/cxx-stl/system/include
|
||||
directory /home/victor/projects/android-ndk-r6b/platforms/android-8/arch-arm/usr/include /home/victor/projects/OsmAnd/git/OsmAnd/jni/jni /home/victor/projects/android//external/skia/include/core /home/victor/projects/android//external/skia/include/utils /home/victor/projects/android//external/skia/include/config /home/victor/projects/android//external/skia/include/effects /home/victor/projects/android//external/skia/include/utils/android /home/victor/projects/android//external/skia/src/core /home/victor/projects/android//system/core/include /home/victor/projects/android//frameworks/base/include /home/victor/projects/android-ndk-r6b/sources/cxx-stl/system/include
|
||||
|
|
Binary file not shown.
|
@ -3,9 +3,6 @@ package net.osmand.plus.render;
|
|||
import gnu.trove.list.array.TIntArrayList;
|
||||
import gnu.trove.map.hash.TIntObjectHashMap;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
@ -30,7 +27,6 @@ import org.apache.commons.logging.Log;
|
|||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.BitmapShader;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
|
@ -66,8 +62,7 @@ public class OsmandRenderer {
|
|||
public static final int TILE_SIZE = 256;
|
||||
|
||||
private Map<String, PathEffect> dashEffect = new LinkedHashMap<String, PathEffect>();
|
||||
private Map<Integer, Shader> shaders = new LinkedHashMap<Integer, Shader>();
|
||||
private Map<Integer, Bitmap> cachedIcons = new LinkedHashMap<Integer, Bitmap>();
|
||||
private Map<String, Shader> shaders = new LinkedHashMap<String, Shader>();
|
||||
|
||||
private final Context context;
|
||||
|
||||
|
@ -91,7 +86,7 @@ public class OsmandRenderer {
|
|||
int textShadow = 0;
|
||||
int textWrap = 0;
|
||||
boolean bold = false;
|
||||
int shieldRes = 0;
|
||||
String shieldRes = null;
|
||||
int textOrder = 20;
|
||||
|
||||
public void fillProperties(RenderingRuleSearchRequest render, float centerX, float centerY){
|
||||
|
@ -107,7 +102,7 @@ public class OsmandRenderer {
|
|||
bold = render.getIntPropertyValue(render.ALL.R_TEXT_BOLD, 0) > 0;
|
||||
minDistance = render.getIntPropertyValue(render.ALL.R_TEXT_MIN_DISTANCE,0);
|
||||
if(render.isSpecified(render.ALL.R_TEXT_SHIELD)) {
|
||||
shieldRes = RenderingIcons.getIcons().get(render.getStringPropertyValue(render.ALL.R_TEXT_SHIELD));
|
||||
shieldRes = render.getStringPropertyValue(render.ALL.R_TEXT_SHIELD);
|
||||
}
|
||||
textOrder = render.getIntPropertyValue(render.ALL.R_TEXT_ORDER, 20);
|
||||
}
|
||||
|
@ -116,7 +111,7 @@ public class OsmandRenderer {
|
|||
private static class IconDrawInfo {
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
int resId;
|
||||
String resId;
|
||||
}
|
||||
|
||||
/*package*/ static class RenderingContext {
|
||||
|
@ -198,11 +193,16 @@ public class OsmandRenderer {
|
|||
return dashEffect.get(dashes);
|
||||
}
|
||||
|
||||
public Shader getShader(int resId){
|
||||
public Shader getShader(String resId){
|
||||
|
||||
if(shaders.get(resId) == null){
|
||||
Shader sh = new BitmapShader(
|
||||
BitmapFactory.decodeResource(context.getResources(), resId), TileMode.REPEAT, TileMode.REPEAT);
|
||||
shaders.put(resId, sh);
|
||||
Bitmap bmp = RenderingIcons.getIcon(context, resId);
|
||||
if(bmp != null){
|
||||
Shader sh = new BitmapShader(bmp, TileMode.REPEAT, TileMode.REPEAT);
|
||||
shaders.put(resId, sh);
|
||||
} else {
|
||||
shaders.put(resId, null);
|
||||
}
|
||||
}
|
||||
return shaders.get(resId);
|
||||
}
|
||||
|
@ -325,11 +325,8 @@ public class OsmandRenderer {
|
|||
int iconsH = rc.height / skewConstant;
|
||||
int[] alreadyDrawnIcons = new int[iconsW * iconsH / 32];
|
||||
for (IconDrawInfo icon : rc.iconsToDraw) {
|
||||
if (icon.resId != 0) {
|
||||
if (cachedIcons.get(icon.resId) == null) {
|
||||
cachedIcons.put(icon.resId, UnscaledBitmapLoader.loadFromResource(context.getResources(), icon.resId, null, dm));
|
||||
}
|
||||
Bitmap ico = cachedIcons.get(icon.resId);
|
||||
if (icon.resId != null) {
|
||||
Bitmap ico = RenderingIcons.getIcon(context, icon.resId);
|
||||
if (ico != null) {
|
||||
if (icon.y >= 0 && icon.y < rc.height && icon.x >= 0 && icon.x < rc.width) {
|
||||
int z = (((int) icon.x / skewConstant) + ((int) icon.y / skewConstant) * iconsW);
|
||||
|
@ -494,11 +491,8 @@ public class OsmandRenderer {
|
|||
}
|
||||
cv.drawTextOnPath(text.text, text.drawOnPath, 0, text.vOffset, paintText);
|
||||
} else {
|
||||
if (text.shieldRes != 0) {
|
||||
if (cachedIcons.get(text.shieldRes) == null) {
|
||||
cachedIcons.put(text.shieldRes, BitmapFactory.decodeResource(context.getResources(), text.shieldRes));
|
||||
}
|
||||
Bitmap ico = cachedIcons.get(text.shieldRes);
|
||||
if (text.shieldRes != null) {
|
||||
Bitmap ico = RenderingIcons.getIcon(context, text.shieldRes);
|
||||
if (ico != null) {
|
||||
cv.drawBitmap(ico, text.centerX - ico.getWidth() / 2 - 0.5f, text.centerY
|
||||
- ico.getHeight() / 2 - getDensityValue(rc, 4.5f)
|
||||
|
@ -713,7 +707,6 @@ public class OsmandRenderer {
|
|||
}
|
||||
|
||||
public void clearCachedResources(){
|
||||
cachedIcons.clear();
|
||||
shaders.clear();
|
||||
}
|
||||
|
||||
|
@ -851,7 +844,7 @@ public class OsmandRenderer {
|
|||
p.setColor(req.getIntPropertyValue(rColor));
|
||||
|
||||
if(ind == 0){
|
||||
Integer resId = RenderingIcons.getIcons().get(req.getStringPropertyValue(req.ALL.R_SHADER));
|
||||
String resId = req.getStringPropertyValue(req.ALL.R_SHADER);
|
||||
if(resId != null){
|
||||
p.setColor(Color.BLACK);
|
||||
p.setShader(getShader(resId));
|
||||
|
@ -927,12 +920,12 @@ public class OsmandRenderer {
|
|||
render.setInitialTagValueZoom(pair.tag, pair.value, rc.zoom);
|
||||
render.search(RenderingRulesStorage.POINT_RULES);
|
||||
|
||||
Integer resId = RenderingIcons.getIcons().get(render.getStringPropertyValue(render.ALL.R_ICON));
|
||||
String resId = render.getStringPropertyValue(render.ALL.R_ICON);
|
||||
String name = null;
|
||||
if (renderText) {
|
||||
name = obj.getName();
|
||||
}
|
||||
if((resId == null || resId == 0) && name == null){
|
||||
if(resId == null && name == null){
|
||||
return;
|
||||
}
|
||||
int len = obj.getPointsLength();
|
||||
|
@ -948,7 +941,7 @@ public class OsmandRenderer {
|
|||
ps.y /= len;
|
||||
}
|
||||
|
||||
if(resId != null && resId != 0){
|
||||
if(resId != null){
|
||||
IconDrawInfo ico = new IconDrawInfo();
|
||||
ico.x = ps.x;
|
||||
ico.y = ps.y;
|
||||
|
|
|
@ -4,22 +4,48 @@ import java.lang.reflect.Field;
|
|||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.R.drawable;
|
||||
|
||||
public class RenderingIcons {
|
||||
|
||||
private static Map<String, Integer> icons = new LinkedHashMap<String, Integer>();
|
||||
private static Map<String, Bitmap> iconsBmp = new LinkedHashMap<String, Bitmap>();
|
||||
private static DisplayMetrics dm;
|
||||
|
||||
public static Map<String, Integer> getIcons(){
|
||||
if(icons.isEmpty()){
|
||||
initIcons();
|
||||
public static boolean containsIcon(String s){
|
||||
return icons.containsKey(s);
|
||||
}
|
||||
|
||||
public static Bitmap getIcon(Context ctx, String s){
|
||||
if(!iconsBmp.containsKey(s)){
|
||||
Integer resId = icons.get(s);
|
||||
if(resId != null){
|
||||
if(dm == null) {
|
||||
dm = new DisplayMetrics();
|
||||
WindowManager wmgr = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
|
||||
wmgr.getDefaultDisplay().getMetrics(dm);
|
||||
}
|
||||
Bitmap bmp = UnscaledBitmapLoader.loadFromResource(ctx.getResources(), resId.intValue(), null, dm);
|
||||
iconsBmp.put(s, bmp);
|
||||
} else {
|
||||
iconsBmp.put(s, null);
|
||||
}
|
||||
}
|
||||
return icons;
|
||||
return iconsBmp.get(s);
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
initIcons();
|
||||
}
|
||||
|
||||
public static void initIcons() {
|
||||
|
||||
Class<? extends drawable> cl = R.drawable.class;
|
||||
for (Field f : cl.getDeclaredFields()) {
|
||||
if (f.getName().startsWith("h_") || f.getName().startsWith("g_")) {
|
||||
|
@ -33,4 +59,5 @@ public class RenderingIcons {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,22 +3,18 @@ package net.osmand.plus.views;
|
|||
import gnu.trove.set.hash.TIntHashSet;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.osmand.LogUtil;
|
||||
import net.osmand.OsmAndFormatter;
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.osm.LatLon;
|
||||
import net.osmand.osm.MapUtils;
|
||||
import net.osmand.plus.PoiFilter;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.ResourceManager;
|
||||
import net.osmand.plus.activities.EditingPOIActivity;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.render.RenderingIcons;
|
||||
import net.osmand.plus.render.UnscaledBitmapLoader;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
|
@ -53,7 +49,6 @@ public class POIMapLayer implements OsmandMapLayer, ContextMenuLayer.IContextMen
|
|||
private ResourceManager resourceManager;
|
||||
private PoiFilter filter;
|
||||
private DisplayMetrics dm;
|
||||
private Map<Integer, Bitmap> cachedIcons = new LinkedHashMap<Integer, Bitmap>();
|
||||
private final MapActivity activity;
|
||||
|
||||
public POIMapLayer(MapActivity activity) {
|
||||
|
@ -160,20 +155,11 @@ public class POIMapLayer implements OsmandMapLayer, ContextMenuLayer.IContextMen
|
|||
return (int) (r * dm.density);
|
||||
}
|
||||
|
||||
public Bitmap getCachedImg(int resId) {
|
||||
if (cachedIcons.containsKey(resId)) {
|
||||
return cachedIcons.get(resId);
|
||||
}
|
||||
Bitmap bmp = UnscaledBitmapLoader.loadFromResource(view.getResources(), resId, null, dm);
|
||||
cachedIcons.put(resId, bmp);
|
||||
return bmp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas canvas, RectF latLonBounds, RectF tilesRect, boolean nightMode) {
|
||||
|
||||
if (view.getZoom() >= startZoom) {
|
||||
Map<String, Integer> icons = RenderingIcons.getIcons();
|
||||
objects.clear();
|
||||
resourceManager.searchAmenitiesAsync(latLonBounds.top, latLonBounds.left, latLonBounds.bottom, latLonBounds.right, view.getZoom(), filter, objects);
|
||||
int r = getRadiusPoi(view.getZoom());
|
||||
|
@ -183,14 +169,13 @@ public class POIMapLayer implements OsmandMapLayer, ContextMenuLayer.IContextMen
|
|||
canvas.drawCircle(x, y, r, pointAltUI);
|
||||
canvas.drawCircle(x, y, r, point);
|
||||
String id = null;
|
||||
if(icons.containsKey(o.getSubType())){
|
||||
if(RenderingIcons.containsIcon(o.getSubType())){
|
||||
id = o.getSubType();
|
||||
} else if (icons.containsKey(o.getType().getDefaultTag() + "_" + o.getSubType())) {
|
||||
} else if (RenderingIcons.containsIcon(o.getType().getDefaultTag() + "_" + o.getSubType())) {
|
||||
id = o.getType().getDefaultTag() + "_" + o.getSubType();
|
||||
}
|
||||
if(id != null){
|
||||
int resId = icons.get(id);
|
||||
Bitmap bmp = getCachedImg(resId);
|
||||
Bitmap bmp = RenderingIcons.getIcon(view.getContext(), id);
|
||||
if(bmp != null){
|
||||
canvas.drawBitmap(bmp, x - bmp.getWidth() / 2, y - bmp.getHeight() / 2, paintIcon);
|
||||
}
|
||||
|
@ -294,7 +279,6 @@ public class POIMapLayer implements OsmandMapLayer, ContextMenuLayer.IContextMen
|
|||
|
||||
@Override
|
||||
public void destroyLayer() {
|
||||
cachedIcons.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue