Esempio n. 1
0
		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;
					}
				}
			}
		}
Esempio n. 2
0
			internal CachedLutProxy(LutCollection sourceLuts)
			{
				_sourceLuts = sourceLuts;
			}
Esempio n. 3
0
		public static ICachedLut GetLut(LutCollection sourceLuts)
		{
			Platform.CheckForNullReference(sourceLuts, "sourceLuts");
			return new CachedLutProxy(sourceLuts);
		}
Esempio n. 4
0
			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;
				}
			}
Esempio n. 5
0
			public IComposedLut GetLut(LutCollection sourceLuts)
			{
				return _cacheItem.GetLut(sourceLuts);
			}
Esempio n. 6
0
		public ComposedLut(LutCollection luts): this(luts, null)
		{
		}