public ComposedLut(LutCollection luts, BufferCache<int> cache) { //luts.Validate(); int lutCount; IComposableLut firstLut, lastLut; GetFirstAndLastLut(luts, out firstLut, out lastLut, out lutCount); _minInputValue = (int) Math.Round(firstLut.MinInputValue); _maxInputValue = (int) Math.Round(firstLut.MaxInputValue); _length = _maxInputValue - _minInputValue + 1; _data = cache != null ? cache.Allocate(_length) : MemoryManager.Allocate<int>(_length); //copy to array because accessing ObservableList's indexer in a tight loop is very expensive IComposableLut[] lutArray = new IComposableLut[lutCount]; luts.CopyTo(lutArray, 0); unsafe { fixed (int* composedLutData = _data) { int* pLutData = composedLutData; int min = _minInputValue; int max = _maxInputValue + 1; for (int i = min; i < max; ++i) { double val = i; for (int j = 0; j < lutCount; ++j) val = lutArray[j][val]; *pLutData = (int) Math.Round(val); ++pLutData; } } } }
internal CachedLutProxy(LutCollection sourceLuts) { _sourceLuts = sourceLuts; }
public static ICachedLut GetLut(LutCollection sourceLuts) { Platform.CheckForNullReference(sourceLuts, "sourceLuts"); return new CachedLutProxy(sourceLuts); }
public IComposedLut GetLut(LutCollection sourceLuts) { IComposedLut lut = _realComposedLut; if (lut != null) return lut; lock (_syncLock) { if (_realComposedLut != null) return _realComposedLut; //Trace.WriteLine(String.Format("Creating Composed Lut '{0}'", Key), "LUT"); _realComposedLut = new ComposedLut(sourceLuts, _bufferCache); //just use the creation time as the "last access time", otherwise it can get expensive when called in a tight loop. _largeObjectData.UpdateLastAccessTime(); _largeObjectData.BytesHeldCount = _realComposedLut.Data.Length * sizeof(int); _largeObjectData.LargeObjectCount = 1; MemoryManager.Add(this); Diagnostics.OnLargeObjectAllocated(_largeObjectData.BytesHeldCount); return _realComposedLut; } }
public IComposedLut GetLut(LutCollection sourceLuts) { return _cacheItem.GetLut(sourceLuts); }
public ComposedLut(LutCollection luts): this(luts, null) { }