From 234825fbbbd8d83ac8ee099228819750003d2793 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Tue, 14 Aug 2012 00:13:13 +0200 Subject: [PATCH] Speedup rendering --- .../osmand/binary/BinaryMapDataObject.java | 5 -- .../osmand/plus/render/OsmandRenderer.java | 33 ++++++++++ Osmand-kernel/osmand/src/rendering.cpp | 60 +++++++++++++++++++ 3 files changed, 93 insertions(+), 5 deletions(-) diff --git a/DataExtractionOSM/src/net/osmand/binary/BinaryMapDataObject.java b/DataExtractionOSM/src/net/osmand/binary/BinaryMapDataObject.java index c177a7603d..d9c773e9d9 100644 --- a/DataExtractionOSM/src/net/osmand/binary/BinaryMapDataObject.java +++ b/DataExtractionOSM/src/net/osmand/binary/BinaryMapDataObject.java @@ -2,7 +2,6 @@ package net.osmand.binary; import gnu.trove.map.hash.TIntObjectHashMap; import net.osmand.binary.BinaryMapIndexReader.MapIndex; -import net.osmand.binary.BinaryMapIndexReader.TagValuePair; import net.osmand.osm.MapRenderingTypes; public class BinaryMapDataObject { @@ -114,10 +113,6 @@ public class BinaryMapDataObject { this.area = area; } - public TagValuePair getTagValue(int indType){ - throw new UnsupportedOperationException("This functions is deprecated and should be deleted"); - } - public long getId() { return id; } diff --git a/OsmAnd/src/net/osmand/plus/render/OsmandRenderer.java b/OsmAnd/src/net/osmand/plus/render/OsmandRenderer.java index 701864e598..0154dde7af 100644 --- a/OsmAnd/src/net/osmand/plus/render/OsmandRenderer.java +++ b/OsmAnd/src/net/osmand/plus/render/OsmandRenderer.java @@ -440,6 +440,14 @@ public class OsmandRenderer { } rc.visible++; int len = obj.getPointsLength(); +// if(len > 150) { +// int[] ts = obj.getTypes(); +// System.err.println("Polygon " + len); +// for(int i=0; i= 0 && p.y >= 0 && p.x < rc.width && p.y < rc.height) { + intersect = true; + } + if (!intersect && prev != null) { + if ((p.x < 0 && prev.x < 0) || (p.y < 0 && prev.y < 0) || (p.x > rc.width && prev.x > rc.width) + || (p.y > rc.height && prev.y > rc.height)) { + intersect = false; + } else { + intersect = true; + } + + } + } if (path == null) { path = new Path(); path.moveTo(p.x, p.y); @@ -674,6 +698,15 @@ public class OsmandRenderer { } path.lineTo(p.x, p.y); } + prev = p; + } + if (!intersect) { +// System.err.println("Not intersect "); +// int[] ts = obj.getTypes(); +// for(int i=0; ipoints.at(i), rc); if (i == 0) { @@ -383,6 +386,27 @@ void drawPolyline(MapDataObject* mObj, RenderingRuleSearchRequest* req, SkCanvas } path.lineTo(rc->calcX, rc->calcY); } + if (!intersect) { + if (rc->calcX >= 0 && rc->calcY >= 0 && rc->calcX < rc->getWidth()&& rc->calcY < rc->getHeight()) { + intersect = true; + } + if (!intersect && i > 0) { + if ((rc->calcX < 0 && prevx < 0) || (rc->calcY < 0 && prevy < 0) || + (rc->calcX> rc->getWidth() && prevx > rc->getWidth()) + || (rc->calcY > rc->getHeight() && prevy > rc->getHeight())) { + intersect = false; + } else { + intersect = true; + } + + } + } + prevx = rc->calcX; + prevy = rc->calcY; + } + + if (!intersect) { + return; } if (i > 0) { @@ -442,6 +466,10 @@ void drawPolygon(MapDataObject* mObj, RenderingRuleSearchRequest* req, SkCanvas* rc->visible++; SkPath path; int i = 0; + float prevx; + float prevy; + bool intersect = false; + int bounds = 0; for (; i < length; i++) { calcPoint(mObj->points.at(i), rc); if (i == 0) { @@ -451,6 +479,38 @@ void drawPolygon(MapDataObject* mObj, RenderingRuleSearchRequest* req, SkCanvas* } xText += rc->calcX; yText += rc->calcY; + if (!intersect) { + if (rc->calcX >= 0 && rc->calcY >= 0 && rc->calcX < rc->getWidth() && rc->calcY < rc->getHeight()) { + intersect = true; + } + bounds |= (rc->calcX < 0 ? 1 : 0); + bounds |= (rc->calcX >= rc->getWidth() ? 2 : 0); + bounds |= (rc->calcY < 0 ? 4 : 0); + bounds |= (rc->calcY >= rc->getHeight() ? 8 : 0); + if (!intersect && i > 0) { + if ((rc->calcX < 0 && prevx < 0) || (rc->calcY < 0 && prevy < 0) + || (rc->calcX > rc->getWidth() && prevx > rc->getWidth()) + || (rc->calcY > rc->getHeight() && prevy > rc->getHeight())) { + intersect = false; + } else { + intersect = true; + } + } + } + } + if(!intersect){ + if(bounds == 15) { + path.reset(); + path.moveTo(0, 0); + path.lineTo(0, rc->getWidth()); + path.lineTo(rc->getHeight(), rc->getWidth()); + path.lineTo(rc->getHeight(), 0); + path.close(); + xText = rc->getWidth() / 2; + yText = rc->getHeight() / 2; + } else { + return; + } } std::vector polygonInnerCoordinates = mObj->polygonInnerCoordinates; if (polygonInnerCoordinates.size() > 0) {