Example #1
0
        public static void ConvertSparseTileRegions(this IMTLDevice This, MTLRegion [] tileRegions, MTLRegion [] pixelRegions, MTLSize tileSize, nuint numRegions)
        {
            if (tileRegions == null)
            {
                ObjCRuntime.ThrowHelper.ThrowArgumentNullException(nameof(tileRegions));
            }
            if (pixelRegions == null)
            {
                ObjCRuntime.ThrowHelper.ThrowArgumentNullException(nameof(pixelRegions));
            }

            var tileRegionsHandle  = GCHandle.Alloc(tileRegions, GCHandleType.Pinned);
            var pixelRegionsHandle = GCHandle.Alloc(pixelRegions, GCHandleType.Pinned);

            try {
                IntPtr tilePtr  = tileRegionsHandle.AddrOfPinnedObject();
                IntPtr pixelPtr = pixelRegionsHandle.AddrOfPinnedObject();
                This.ConvertSparseTileRegions(tilePtr, pixelPtr, tileSize, numRegions);
            } finally {
                tileRegionsHandle.Free();
                pixelRegionsHandle.Free();
            }
        }