/** * @param glContext * the object representing the OpenGL context a texture belongs to. See * {@link RenderContext#getGlContextRep()} * @return the texture id of a texture in the given context. If the texture is not found in the given context, 0 is * returned. */ public Integer getTextureIdForContext(final Object glContext) { final Integer id = _idCache.getValue(glContext); if (id != null) { return id; } return ZERO; }
/** * @param glContext * the object representing the OpenGL context a vbo belongs to. See * {@link RenderContext#getGlContextRep()} * @return the vbo id of a vbo in the given context. If the vbo is not found in the given context, 0 is returned. */ public int getVBOID(final Object glContext) { if (_vboIdCache != null) { final Integer id = _vboIdCache.getValue(glContext); if (id != null) { return id.intValue(); } } return 0; }
@SuppressWarnings("unchecked") private static Multimap<Object, Integer> gatherGCdIds() { Multimap<Object, Integer> idMap = null; // Pull all expired textures from ref queue and add to an id multimap. ContextIdReference<TextureKey> ref; Integer id; while ((ref = (ContextIdReference<TextureKey>) _textureRefQueue.poll()) != null) { // lazy init if (idMap == null) { idMap = ArrayListMultimap.create(); } if (Constants.useMultipleContexts) { final Set<Object> contextObjects = ref.getContextObjects(); for (final Object o : contextObjects) { id = ref.getValue(o); if (id != null && id.intValue() != 0) { // Add id to map idMap.put(o, id); } } } else { id = ref.getValue(null); if (id != null && id.intValue() != 0) { idMap.put(ContextManager.getCurrentContext().getGlContextRep(), id); } } ref.clear(); } return idMap; }
@SuppressWarnings("unchecked") private static final Multimap<Object, Integer> gatherGCdIds(Multimap<Object, Integer> store) { // Pull all expired vbos from ref queue and add to an id multimap. ContextIdReference<AbstractBufferData<?>> ref; while ((ref = (ContextIdReference<AbstractBufferData<?>>) _vboRefQueue.poll()) != null) { if (Constants.useMultipleContexts) { final Set<Object> contextObjects = ref.getContextObjects(); for (final Object o : contextObjects) { // Add id to map final Integer id = ref.getValue(o); if (id != null) { if (store == null) { // lazy init store = ArrayListMultimap.create(); } store.put(o, id); } } } else { final Integer id = ref.getValue(null); if (id != null) { if (store == null) { // lazy init store = ArrayListMultimap.create(); } store.put(ContextManager.getCurrentContext().getGlContextRep(), id); } } ref.clear(); } return store; }