public static void disposeAll() { if (screenCache != null) { for (ScreenCache sc : screenCache.values()) { sc.dispose(); sc = null; } screenCache.clear(); } }
/** * 获得当前游戏屏幕截图 * * @param x * @param y * @param width * @param height * @return */ public static synchronized LImage toScreenCaptureImage(int x, int y, int width, int height) { if (GLEx.gl10 == null) { return null; } if (width < 0) { width = 1; } if (height < 0) { height = 1; } if (x < 0 || x > width) { x = 0; } if (y < 0 || y > height) { y = 0; } int hashCode = 1; hashCode = LSystem.unite(hashCode, x); hashCode = LSystem.unite(hashCode, y); hashCode = LSystem.unite(hashCode, width); hashCode = LSystem.unite(hashCode, height); if (screenCache.size() > LSystem.DEFAULT_MAX_CACHE_SIZE / 10) { for (ScreenCache sc : screenCache.values()) { sc.dispose(); sc = null; } screenCache.clear(); } ScreenCache cache = screenCache.get(hashCode); if (cache == null) { cache = new ScreenCache(x, y, width, height); } else { cache.reset(); } screenCache.put(hashCode, cache); cache.commit(); for (; cache.commit == null; ) { try { Thread.yield(); } catch (Exception e) { } } return cache.commit; }