Hallo,
Actually, I was just looking for some display problems and I have found a little bit performance.
But from the beginning!
I was looking for my problem with the tile
border and have noticed that here the default values are set in Area Builder
on black.
public AreaBuilder(GraphicFactory graphicFactory, String elementName, Attributes attributes, int level,
String relativePathPrefix) throws IOException, SAXException {
this.level = level;
this.fill = graphicFactory.createPaint();
this.fill.setColor(Color.TRANSPARENT); //Change from BLACK to TRANSPARENT
this.fill.setStyle(Style.FILL);
this.fill.setStrokeCap(Cap.ROUND);
this.stroke = graphicFactory.createPaint();
this.stroke.setColor(Color.TRANSPARENT); //Change from BLACK to TRANSPARENT
this.stroke.setStyle(Style.STROKE);
this.stroke.setStrokeCap(Cap.ROUND);
extractValues(graphicFactory, elementName, attributes, relativePathPrefix);
}
But if there is no value in the theme of this, of course, Black was then taken. So I put it to the test on transparent and my problem was solved. Also the reported problem of emux => https://groups.google.com/forum/?fromgroups#!topic/mapsforge-dev/8o7TmLvn2jY was solved.
Then I asked myself why a transparent color must be drawn at all and have Prevents this. The result is a performance improvement of ~20%
(
What I have noticed in several tests on Android and AWT
· Before changes tile generation at ~600ms, after changes ~500ms on Android
· Before changes tile generation at ~80ms, after changes ~70ms on Android
)
The changes that I have made here are not very serious.
So that can be queried
on a transparency in the canvas, I extended the Paint interface.
public interface Paint {
boolean isTransparent();
....
And of course the two derived classes for Android and AWT
AwtPaint:
@Override
public boolean isTransparent() {
return this.color.getAlpha()==0;
}AndroidPaint:
@Override
public boolean isTransparent() {
return this.paint. getAlpha()==0;
}
So then a transparent color is not drawn, I have in all canvas methods, in which is passed Paint, I use a query off transparency and I left the method.
@Override
public void drawLine(int x1, int y1, int x2, int y2, Paint paint) {
if(paint.isTransparent())return;
I hope that you still feed this changes and I have not overlooked anything.
I have committed this to my clone wwwlongride-cachebox
Greeting Andre
--
You received this message because you are subscribed to the Google Groups "mapsforge-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapsforge-de...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
I have also the TestFailer and I fixed with chk NPE on Paint.IsTransparent()
@Override
public boolean isTransparent() {
if(this.color==null)return true;
return this.color.getAlpha()==0;
}
I think this chk is safer!
Ok, now I understand and that’s ok for me.
Thanks!
I wondered why the areas are no longer filled with the bitmaps from the pattern here and have found that the Paint have a color and a texture.
So if a paint contains a texture, then this should also be drawn, even if the color is transparent.
I have reached this in the queried of isTransparent!
For AwtPaint
@Override
public boolean isTransparent() {
return this.texturePaint==null && this.color.getAlpha()==0;
}
For AndroidPaint
@Override
public boolean isTransparent() {
return this.paint.getShader()==null && this.paint.getAlpha()==0;
}
There is for Android, but still a problem when the android.graphics.Paint has a transparent color, but a
shader, it is
not drawn here.
This then helps
only put one
color in AndroidPaint.setBitmapShader ()
@Override
public void setBitmapShader(org.mapsforge.core.graphics.Bitmap bitmap) {
if (bitmap == null) {
return;
}
this.paint
.setShader(new BitmapShader(AndroidGraphicFactory.getBitmap(bitmap), TileMode.REPEAT, TileMode.REPEAT));
this.paint.setColor(android.graphics.Color.BLACK);
}
Thus, I longed for the performance gain is not as big though, but still 4%!
It was also no surprise that there is a performance increase if nothing is drawn.
Sorry again!
Greeting Andre
Greeting Andre
--