From b96792157e8a4ca207ceb3fffab6165ed8b25192 Mon Sep 17 00:00:00 2001 From: Svjatoslav Agejenko Date: Tue, 13 Jun 2017 12:55:53 +0300 Subject: [PATCH] Enable glowing point texture caching. --- .../renderer/raster/shapes/basic/GlowingPoint.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/renderer/raster/shapes/basic/GlowingPoint.java b/src/main/java/eu/svjatoslav/sixth/e3d/renderer/raster/shapes/basic/GlowingPoint.java index 4dd454f..339d6bb 100644 --- a/src/main/java/eu/svjatoslav/sixth/e3d/renderer/raster/shapes/basic/GlowingPoint.java +++ b/src/main/java/eu/svjatoslav/sixth/e3d/renderer/raster/shapes/basic/GlowingPoint.java @@ -28,12 +28,19 @@ public class GlowingPoint extends ForwardOrientedTexture { final Color color) { super(point, pointSize, getTexture(color)); this.color = color; + + synchronized (glowingPoints){ + glowingPoints.add(this); + } } private static Texture getTexture(final Color color) { // attempt to reuse texture from existing glowing point of the same color - for (GlowingPoint glowingPoint : glowingPoints) - if (color.equals(glowingPoint.color)) return glowingPoint.texture; + synchronized (glowingPoints) { + for (GlowingPoint glowingPoint : glowingPoints) + if (color.equals(glowingPoint.color)) + return glowingPoint.texture; + } // existing texture not found, creating new one return createTexture(color); -- 2.20.1