world map plugin: optimize clipping of world map points

Change the world map overlay to only clip the graphics if it's necessary.
setClip is fairly expensive and re-setting the clip for every map point
almost halves FPS when the world map is open.
This commit is contained in:
trimbe
2018-11-19 22:38:08 -05:00
committed by Adam
parent 57711cc9ff
commit 3e35fa33fa

View File

@@ -95,6 +95,7 @@ public class WorldMapOverlay extends Overlay
// in fixed, the bounds are offset by the size of the black borders outside the canvas
canvasBounds.setLocation(0, 0);
final Area canvasViewArea = getWorldMapClipArea(canvasBounds);
Area currentClip = null;
WorldMapPoint tooltipPoint = null;
@@ -113,10 +114,19 @@ public class WorldMapOverlay extends Overlay
continue;
}
if (worldPoint.isSnapToEdge())
if (worldPoint.isSnapToEdge() && canvasViewArea != currentClip)
{
graphics.setClip(canvasViewArea);
currentClip = canvasViewArea;
}
else if (!worldPoint.isSnapToEdge() && mapViewArea != currentClip)
{
graphics.setClip(mapViewArea);
currentClip = mapViewArea;
}
if (worldPoint.isSnapToEdge())
{
if (worldMapRectangle.contains(drawPoint.getX(), drawPoint.getY()))
{
if (worldPoint.isCurrentlyEdgeSnapped())
@@ -135,10 +145,6 @@ public class WorldMapOverlay extends Overlay
}
}
}
else
{
graphics.setClip(mapViewArea);
}
int drawX = drawPoint.getX();
int drawY = drawPoint.getY();