Fix highres rendering

This commit is contained in:
Victor Shcherb 2012-03-22 23:50:43 +01:00
parent 3281476d2f
commit 2a2c5567a0
5 changed files with 73 additions and 41 deletions

View file

@ -738,7 +738,7 @@
<filter minzoom="15" icon="sport_ski" tag="sport" value="skiing"/>
<filter minzoom="16" icon="sport_diving" tag="sport" value="diving"/>
<filter minzoom="15" icon="theme_park" tag="tourism" value="theme_park"/>
<filter minzoom="16" icon="amenity_bench" tag="amenity" value="bench"/>
<filter minzoom="17" icon="amenity_bench" tag="amenity" value="bench"/>
<filter minzoom="15" icon="leisure_sports_centre" tag="leisure" value="sports_centre"/>
<filter minzoom="16" icon="bird_hide" tag="leisure" value="bird_hide"/>

View file

@ -585,9 +585,16 @@ void drawIconsOverCanvas(RenderingContext* rc, SkCanvas* canvas)
if (((ind >> b) & 1) == 0) {
alreadyDrawnIcons[i] = ind | (1 << b);
SkBitmap* ico = icon.bmp;
if(rc->highResMode) {
float left = icon.x - getDensityValue(rc, ico->width() / 2);
float top = icon.y - getDensityValue(rc, ico->height() / 2);
SkRect r = SkRect::MakeXYWH(left, top, getDensityValue(rc, ico->width()), getDensityValue(rc, ico->height()));
PROFILE_NATIVE_OPERATION(rc, canvas->drawBitmapRect(*ico, (SkIRect*) NULL, r, &p));
} else {
PROFILE_NATIVE_OPERATION(rc, canvas->drawBitmap(*ico, icon.x - ico->width() / 2, icon.y - ico->height() / 2, &p));
}
}
}
if(rc->interrupted()){
return;
}

View file

@ -534,10 +534,15 @@ void drawTextOverCanvas(RenderingContext* rc, SkCanvas* cv) {
if (text->shieldRes.length() > 0) {
SkBitmap* ico = getCachedBitmap(rc, text->shieldRes);
if (ico != NULL) {
rc->nativeOperations.pause();
cv->drawBitmap(*ico, text->centerX - ico->width() / 2 - 0.5f,
text->centerY - ico->height() / 2 - getDensityValue(rc, 4.5f), &paintIcon);
rc->nativeOperations.start();
if(rc->highResMode) {
float left = text->centerX - getDensityValue(rc, ico->width() / 2) - 0.5f;
float top =text->centerY - getDensityValue(rc, ico->height() / 2) - getDensityValue(rc, 4.5f);
SkRect r = SkRect::MakeXYWH(left, top, getDensityValue(rc, ico->width()), getDensityValue(rc, ico->height()));
PROFILE_NATIVE_OPERATION(rc, cv->drawBitmapRect(*ico, (SkIRect*) NULL, r, &paintIcon));
} else {
PROFILE_NATIVE_OPERATION(rc, cv->drawBitmap(*ico, text->centerX - ico->width() / 2 - 0.5f,
text->centerY - ico->height() / 2 - getDensityValue(rc, 4.5f), &paintIcon));
}
}
}
drawWrappedText(rc, cv, text, textSize, paintText);

View file

@ -36,6 +36,8 @@ import android.graphics.Paint.Style;
import android.graphics.Path;
import android.graphics.PathEffect;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffColorFilter;
import android.graphics.Shader;
@ -358,11 +360,18 @@ public class OsmandRenderer {
// check bit b if it is set
if (((ind >> b) & 1) == 0) {
alreadyDrawnIcons[i] = ind | (1 << b);
if(rc.highResMode) {
float left = icon.x - rc.getDensityValue(ico.getWidth() / 2);
float top = icon.y - rc.getDensityValue(ico.getHeight() / 2);
cv.drawBitmap(ico, null, new RectF(left, top, left + rc.getDensityValue(ico.getWidth()), top
+ rc.getDensityValue(ico.getHeight())), paintIcon);
} else {
cv.drawBitmap(ico, icon.x - ico.getWidth() / 2, icon.y - ico.getHeight() / 2, paintIcon);
}
}
}
}
}
if (rc.interrupted) {
return;
}

View file

@ -237,8 +237,19 @@ public class TextRenderer {
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 - rc.getDensityValue(4.5f), paintIcon);
if (rc.highResMode) {
float left = text.centerX - rc.getDensityValue(ico.getWidth() / 2) - 0.5f;
float top = text.centerY - rc.getDensityValue(ico.getHeight() / 2) - rc.getDensityValue(4.5f);
Rect rec = new Rect(0, 0, ico.getWidth(), ico.getHeight());
cv.drawBitmap(ico, rec,
new RectF(left, top, left + rc.getDensityValue(ico.getWidth()), top
+ rc.getDensityValue(ico.getHeight())), paintIcon);
} else {
float left = text.centerX - ico.getWidth() / 2 - 0.5f;
float top = text.centerY - ico.getHeight() / 2 - rc.getDensityValue(4.5f);
cv.drawBitmap(ico, left, top, paintIcon);
}
}
}
@ -298,7 +309,7 @@ public class TextRenderer {
if(render.getIntPropertyValue(render.ALL.R_TEXT_SIZE) > 0){
TextDrawInfo text = new TextDrawInfo(name);
text.fillProperties(render, xMid, yMid);
paintText.setTextSize(text.textSize);
paintText.setTextSize(rc.getDensityValue(text.textSize));
Rect bs = new Rect();
paintText.getTextBounds(name, 0, name.length(), bs);
text.bounds = new RectF(bs);