private TextureWithRefCount createTextureWithRefCount([NotNull] string lookupKey, [CanBeNull] Texture baseTexture) { if (baseTexture == null) { return(null); } lock (referenceCountLock) { if (!referenceCounts.TryGetValue(lookupKey, out TextureWithRefCount.ReferenceCount count)) { referenceCounts[lookupKey] = count = new TextureWithRefCount.ReferenceCount(referenceCountLock, () => onAllReferencesLost(baseTexture)); } return(new TextureWithRefCount(baseTexture.TextureGL, count)); } }
protected override Texture CacheAndReturnTexture(string lookupKey, Texture texture) { lock (referenceCountLock) return(createTextureWithRefCount(lookupKey, base.CacheAndReturnTexture(lookupKey, texture))); }