Example #1
0
        // 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);
            }
        }
Example #2
0
 protected override T createObject(ImageBufferInfo info)
 {
     //UnityEngine.Debug.Log(LogPrefix + " Create " + pos);
     return(factory(this, info));
 }
Example #3
0
 public ImageBufferNativePool(int capacity, Factory factory, string name, ImageBufferInfo info) : base(capacity, name, info)
 {
     this.factory = factory;
 }
Example #4
0
 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];
 }
Example #5
0
 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);
     }
 }
Example #6
0
 public ImageBufferNative(ImageBufferInfo info)
 {
     Info = info;
 }