Reduce clearRect calls to improve framerate

This change improves the framerate in resizable mode by 10-15 fps by
reducing the amount of screen clearing done while drawing overlays.
This commit is contained in:
SomeoneWithAnInternetConnection
2018-01-04 21:46:16 -05:00
parent 04772b8f02
commit 03bfb535f3

View File

@@ -241,8 +241,6 @@ public class OverlayRenderer
}
else
{
surfaceGraphics.clearRect(0, 0, surface.getWidth(), surface.getHeight());
final Dimension dimension = MoreObjects.firstNonNull(safeRender(overlay, surfaceGraphics, subPosition), new Dimension());
if (dimension.width == 0 && dimension.height == 0)
{
@@ -272,6 +270,7 @@ public class OverlayRenderer
final Point transformed = OverlayUtil.transformPosition(overlayPosition, dimension);
graphics.drawImage(clippedImage, subPosition.x + transformed.x, subPosition.y + transformed.y, null);
surfaceGraphics.clearRect(0, 0, (int) dimension.getWidth(), (int) dimension.getHeight());
}
});
}