// only height and stride compared, other parameters do not affect native buffers and can be simple overwritten protected override bool infosMatch(ImageBufferInfo i0, ImageBufferInfo i1) { if (i0 == null) { return(i1 == null); } if (i1 == null) { return(i0 == null); } if (i0.Height != i1.Height) { return(false); } var s0 = i0.Stride; var s1 = i1.Stride; if (s0.Length != s1.Length) { return(false); } switch (i0.Stride.Length) { // most common case are 1 and 3 planes case 1: return(s0[0] == s1[0]); case 2: return(s0[0] == s1[0] && s0[1] == s1[1]); case 3: return(s0[0] == s1[0] && s0[1] == s1[1] && s0[2] == s1[2]); default: for (int i = 0; i < s0.Length; i++) { if (s0[i] != s1[i]) { return(false); } } return(true); } }
protected override T createObject(ImageBufferInfo info) { //UnityEngine.Debug.Log(LogPrefix + " Create " + pos); return(factory(this, info)); }
public ImageBufferNativePool(int capacity, Factory factory, string name, ImageBufferInfo info) : base(capacity, name, info) { this.factory = factory; }
public ImageBufferNativeGCHandleSinglePlane(ImageBufferNativePool <ImageBufferNativeGCHandleSinglePlane> pool, ImageBufferInfo info) : base(info) { if (info.Stride.Length != 1) { throw new Exception("ImageBufferNativeGCHandleSinglePlane wrong plane count " + info.Stride.Length); } this.pool = pool; Planes = new IntPtr[1]; }
public ImageBufferNativeAlloc(ImageBufferNativePool <ImageBufferNativeAlloc> pool, ImageBufferInfo info) : base(info) { this.pool = pool; Planes = new IntPtr[info.Stride.Length]; for (int i = 0; i < info.Stride.Length; i++) { Planes[i] = System.Runtime.InteropServices.Marshal.AllocHGlobal(info.Stride[i] * info.Height); } }
public ImageBufferNative(ImageBufferInfo info) { Info = info; }