From 3e35fa33fae0742fad3cb22a0cb26f5546c3c16b Mon Sep 17 00:00:00 2001 From: trimbe Date: Mon, 19 Nov 2018 22:38:08 -0500 Subject: [PATCH] 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. --- .../ui/overlay/worldmap/WorldMapOverlay.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/ui/overlay/worldmap/WorldMapOverlay.java b/runelite-client/src/main/java/net/runelite/client/ui/overlay/worldmap/WorldMapOverlay.java index b436b19b94..83b40bae2d 100644 --- a/runelite-client/src/main/java/net/runelite/client/ui/overlay/worldmap/WorldMapOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/ui/overlay/worldmap/WorldMapOverlay.java @@ -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();