diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 6f83c8f9bb..aed3454584 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,7 +9,7 @@ 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy --> - + FPS info Select Driving Region : US, Europe, UK, Asia and Others Driving Region Japan diff --git a/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java b/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java index a48b6a4d70..1971099072 100644 --- a/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java +++ b/OsmAnd/src/net/osmand/plus/development/OsmandDevelopmentPlugin.java @@ -1,10 +1,18 @@ package net.osmand.plus.development; +import java.util.EnumSet; + +import net.osmand.plus.ApplicationMode; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.SettingsActivity; +import net.osmand.plus.audionotes.AudioNotesLayer; +import net.osmand.plus.views.MapInfoLayer; +import net.osmand.plus.views.OsmandMapLayer.DrawSettings; +import net.osmand.plus.views.OsmandMapTileView; +import net.osmand.plus.views.mapwidgets.TextInfoWidget; import android.content.Intent; import android.preference.Preference; import android.preference.Preference.OnPreferenceClickListener; @@ -13,6 +21,7 @@ import android.preference.PreferenceScreen; public class OsmandDevelopmentPlugin extends OsmandPlugin { private static final String ID = "osmand.development"; private OsmandApplication app; + private TextInfoWidget fps; public OsmandDevelopmentPlugin(OsmandApplication app) { this.app = app; @@ -35,6 +44,33 @@ public class OsmandDevelopmentPlugin extends OsmandPlugin { public String getName() { return app.getString(R.string.debugging_and_development); } + + @Override + public void registerLayers(MapActivity activity) { + registerWidget(activity); + } + + + private void registerWidget(MapActivity activity) { + MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer(); + final OsmandMapTileView mv = activity.getMapView(); + if (mapInfoLayer != null) { + fps = new TextInfoWidget(activity, 0, mapInfoLayer.getPaintText(), mapInfoLayer.getPaintSubText()) { + @Override + public boolean updateInfo(DrawSettings drawSettings) { + if(!mv.isMeasureFPS()) { + mv.setMeasureFPS(true); + } + setText(Float.toString(mv.getFPS()), "FPS"); + return true; + } + }; + mapInfoLayer.getMapInfoControls().registerSideWidget(fps, 0, + R.string.map_widget_fps_info, "fps", false, EnumSet.allOf(ApplicationMode.class), + EnumSet.noneOf(ApplicationMode.class), 30); + mapInfoLayer.recreateControls(); + } + } @Override public void settingsActivityCreate(final SettingsActivity activity, PreferenceScreen screen) { @@ -51,7 +87,4 @@ public class OsmandDevelopmentPlugin extends OsmandPlugin { screen.addPreference(grp); } - @Override - public void registerLayers(MapActivity activity) { - } } diff --git a/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java b/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java index 1a0cc9202c..f716822829 100644 --- a/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java +++ b/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java @@ -52,9 +52,11 @@ import android.widget.Toast; public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCallback, Callback { protected final static int LOWEST_ZOOM_TO_ROTATE = 10; - private static boolean MEASURE_FPS = true; + private boolean MEASURE_FPS = false; private int fpsMeasureCount = 0; private int fpsMeasureMs = 0; + private long fpsFirstMeasurement = 0; + private float fps; protected static final int emptyTileDivisor = 16; @@ -494,8 +496,6 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall private void refreshMapInternal(boolean updateVectorRendering) { handler.removeMessages(1); long ms = SystemClock.elapsedRealtime(); - // long time = System.currentTimeMillis(); - boolean useInternet = getSettings().USE_INTERNET_TO_DOWNLOAD_TILES.get(); if (useInternet) { if(application != null) { @@ -521,29 +521,41 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall latlonRect.left = (float) MapUtils.getLongitudeFromTile(nzoom, tilesRect.left); latlonRect.bottom = (float) MapUtils.getLatitudeFromTile(nzoom, tilesRect.bottom); latlonRect.right = (float) MapUtils.getLongitudeFromTile(nzoom, tilesRect.right); - if(nightMode){ + if (nightMode) { canvas.drawARGB(255, 100, 100, 100); } else { canvas.drawARGB(255, 225, 225, 225); } drawOverMap(canvas, latlonRect, tilesRect, new DrawSettings(nightMode, updateVectorRendering)); -// log.info("Draw with layers " + (System.currentTimeMillis() - time)); } finally { holder.unlockCanvasAndPost(canvas); } } - } - if(MEASURE_FPS) { - fpsMeasureMs += SystemClock.elapsedRealtime() - ms; - fpsMeasureCount ++; - if(fpsMeasureCount > 4) { - log.debug("FPS speed " + (1000*fpsMeasureCount/fpsMeasureMs)); - fpsMeasureCount = 0; - fpsMeasureMs = 0; + if (MEASURE_FPS) { + fpsMeasureMs += SystemClock.elapsedRealtime() - ms; + fpsMeasureCount++; + if (fpsMeasureCount > 10 || (ms - fpsFirstMeasurement) > 400) { + fpsFirstMeasurement = ms; + fps = (1000f * fpsMeasureCount / fpsMeasureMs); + fpsMeasureCount = 0; + fpsMeasureMs = 0; + } } } } + public boolean isMeasureFPS() { + return MEASURE_FPS; + } + + public void setMeasureFPS(boolean measureFPS) { + MEASURE_FPS = measureFPS; + } + + public float getFPS(){ + return fps; + } + private void drawOverMap(Canvas canvas, RectF latlonRect, RectF tilesRect, DrawSettings drawSettings) { int w = getCenterPointX(); int h = getCenterPointY();