extern static unsafe VTStatus VTCompressionSessionEncodeFrameWithOutputHandler( /* VTCompressionSessionRef */ IntPtr session, /* CVImageBufferRef */ IntPtr imageBuffer, /* CMTime */ CMTime presentation, /* CMTime */ CMTime duration, // can ve CMTime.Invalid /* CFDictionaryRef */ IntPtr dict, // can be null, undocumented options /* VTEncodeInfoFlags */ out VTEncodeInfoFlags flags, /* VTCompressionOutputHandler */ BlockLiteral *outputHandler);
static unsafe void TrampolineHandler(BlockLiteral *block, IntPtr completionHandlerPtr) { var callback = (ScheduleCallback)(block->Target); if (callback != null) { callback(completionHandlerPtr); } }
static unsafe void VTCompressionOutputHandlerTrampoline(BlockLiteral *block, VTStatus status, VTEncodeInfoFlags infoFlags, IntPtr sampleBuffer) { var del = (VTCompressionOutputHandler)(block->Target); if (del != null) { del(status, infoFlags, new CMSampleBuffer(sampleBuffer)); } }
static unsafe void VTDecompressionOutputHandlerTrampoline(BlockLiteral *block, VTStatus status, VTDecodeInfoFlags infoFlags, IntPtr imageBuffer, CMTime presentationTimeStamp, CMTime presentationDuration) { var del = (VTDecompressionOutputHandler)(block->Target); if (del != null) { del(status, infoFlags, new CVImageBuffer(imageBuffer), presentationTimeStamp, presentationDuration); } }
public static bool IsManagedBlock(IntPtr block) { if (block == IntPtr.Zero) { throw new ArgumentNullException("block"); } BlockLiteral * literal = (BlockLiteral *)block; BlockDescriptor *descriptor = (BlockDescriptor *)xamarin_get_block_descriptor(); return(descriptor->copy_helper == ((BlockDescriptor *)literal->block_descriptor)->copy_helper); }
// // Simple method that we can use to wrap methods that need to call a block // // usage: // void MyCallBack () {} // BlockLiteral.SimpleCall (MyCallBack, (x) => my_PINvokeThatTakesaBlock (x)); // The above will call the unmanaged my_PINvokeThatTakesaBlock method with a block // that when invoked will call MyCallback // internal unsafe static void SimpleCall(Action callbackToInvoke, Action <IntPtr> pinvoke) { unsafe { BlockLiteral block_handler = new BlockLiteral(); BlockLiteral *block_ptr_handler = &block_handler; block_handler.SetupBlockUnsafe(BlockStaticDispatchClass.static_dispatch_block, callbackToInvoke); try { pinvoke((IntPtr)block_ptr_handler); } finally { block_handler.CleanupBlock(); } } }
public void ScheduleAsync (Action handler) { unsafe { if (handler == null) { nw_framer_async (GetCheckedHandle (), null); return; } BlockLiteral block_handler = new BlockLiteral (); BlockLiteral *block_ptr_handler = &block_handler; block_handler.SetupBlockUnsafe (static_ScheduleHandler, handler); try { nw_framer_async (GetCheckedHandle (), (void*) block_ptr_handler); } finally { block_handler.CleanupBlock (); } } }
public void SetAdvertisedEndpointChangedHandler(AdvertisedEndpointChanged callback) { unsafe { if (callback == null) { nw_listener_set_advertised_endpoint_changed_handler(GetCheckedHandle(), null); return; } BlockLiteral block_handler = new BlockLiteral(); BlockLiteral *block_ptr_handler = &block_handler; block_handler.SetupBlockUnsafe(static_AdvertisedEndpointChangedHandler, callback); try { nw_listener_set_advertised_endpoint_changed_handler(GetCheckedHandle(), (void *)block_ptr_handler); } finally { block_handler.CleanupBlock(); } } }
public void SetNewConnectionHandler(Action <NWConnection> callback) { unsafe { if (callback == null) { nw_listener_set_new_connection_handler(GetCheckedHandle(), null); return; } BlockLiteral block_handler = new BlockLiteral(); BlockLiteral *block_ptr_handler = &block_handler; block_handler.SetupBlockUnsafe(static_NewConnection, callback); try { nw_listener_set_new_connection_handler(GetCheckedHandle(), (void *)block_ptr_handler); } finally { block_handler.CleanupBlock(); } } }
public void SetStateChangedHandler(Action <NWListenerState, NWError> callback) { unsafe { if (callback == null) { nw_listener_set_state_changed_handler(GetCheckedHandle(), null); return; } BlockLiteral block_handler = new BlockLiteral(); BlockLiteral *block_ptr_handler = &block_handler; block_handler.SetupBlockUnsafe(static_ListenerStateChanged, callback); try { nw_listener_set_state_changed_handler(GetCheckedHandle(), (void *)block_ptr_handler); } finally { block_handler.CleanupBlock(); } } }
public void SetMonitorCanceledHandler(Action callback) { unsafe { if (callback == null) { nw_path_monitor_set_cancel_handler(GetCheckedHandle(), null); return; } BlockLiteral block_handler = new BlockLiteral(); BlockLiteral *block_ptr_handler = &block_handler; block_handler.SetupBlockUnsafe(static_MonitorCanceled, callback); try { nw_path_monitor_set_cancel_handler(GetCheckedHandle(), (void *)block_ptr_handler); } finally { block_handler.CleanupBlock(); } } }
void _SetUpdatedSnapshotHandler(Action <NWPath> callback) { unsafe { if (callback == null) { nw_path_monitor_set_update_handler(GetCheckedHandle(), null); return; } BlockLiteral block_handler = new BlockLiteral(); BlockLiteral *block_ptr_handler = &block_handler; block_handler.SetupBlockUnsafe(static_UpdateSnapshot, callback); try { nw_path_monitor_set_update_handler(GetCheckedHandle(), (void *)block_ptr_handler); } finally { block_handler.CleanupBlock(); } } }
public unsafe void SetStateChangeHandler(Action <NWConnectionState, NWError> stateHandler) { if (stateHandler == null) { nw_connection_set_state_changed_handler(GetCheckedHandle(), null); return; } unsafe { BlockLiteral block_handler = new BlockLiteral(); BlockLiteral *block_ptr_handler = &block_handler; block_handler.SetupBlockUnsafe(static_stateChangeHandler, stateHandler); try { nw_connection_set_state_changed_handler(GetCheckedHandle(), (void *)block_ptr_handler); } finally { block_handler.CleanupBlock(); } } }
public unsafe void SetBetterPathAvailableHandler(Action <bool> callback) { if (callback == null) { nw_connection_set_better_path_available_handler(GetCheckedHandle(), null); return; } unsafe { BlockLiteral block_handler = new BlockLiteral(); BlockLiteral *block_ptr_handler = &block_handler; block_handler.SetupBlockUnsafe(static_BooleanChangeHandler, callback); try { nw_connection_set_better_path_available_handler(GetCheckedHandle(), (void *)block_ptr_handler); } finally { block_handler.CleanupBlock(); } } }
public unsafe static NWParameters CreateSecureUdp(Action <NWProtocolOptions>?configureTls = null, Action <NWProtocolOptions>?configureUdp = null) { var tlsHandler = new BlockLiteral(); var udpHandler = new BlockLiteral(); BlockLiteral *tlsPtr = &tlsHandler; BlockLiteral *udpPtr = &udpHandler; if (configureTls == null) { tlsPtr = DEFAULT_CONFIGURATION(); } else { tlsHandler.SetupBlockUnsafe(static_ConfigureHandler, configureTls); } if (configureUdp == null) { udpPtr = DEFAULT_CONFIGURATION(); } else { udpHandler.SetupBlockUnsafe(static_ConfigureHandler, configureUdp); } var ptr = nw_parameters_create_secure_udp(tlsPtr, udpPtr); if (configureTls != null) { tlsPtr->CleanupBlock(); } if (configureUdp != null) { udpPtr->CleanupBlock(); } return(new NWParameters(ptr, owns: true)); }
public void Send(DispatchData buffer, NWContentContext context, bool isComplete, Action <NWError> callback) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (callback == null) { throw new ArgumentNullException(nameof(callback)); } unsafe { BlockLiteral block_handler = new BlockLiteral(); BlockLiteral *block_ptr_handler = &block_handler; block_handler.SetupBlockUnsafe(static_SendCompletion, callback); try { LowLevelSend(GetCheckedHandle(), buffer, context.Handle, isComplete, block_ptr_handler); } finally { block_handler.CleanupBlock(); } } }
unsafe static extern void nw_ethernet_channel_set_state_changed_handler(OS_nw_ethernet_channel ethernet_channel, /* [NullAllowed] */ BlockLiteral *handler);
public unsafe NIDUIConfigurationColorTransformerHandler(BlockLiteral *block) : base(block) { invoker = block->GetDelegateForBlock <DUIConfigurationColorTransformerHandler> (); }
public unsafe NIDMBProgressHUDCompletionBlock(BlockLiteral *block) { blockPtr = _Block_copy((IntPtr)block); invoker = block->GetDelegateForBlock <DMBProgressHUDCompletionBlock> (); }
public unsafe NIDAction(BlockLiteral *block) { blockPtr = _Block_copy((IntPtr)block); invoker = block->GetDelegateForBlock <DAction> (); }
extern static unsafe VTStatus VTDecompressionSessionDecodeFrameWithOutputHandler( /* VTDecompressionSessionRef */ IntPtr session, /* CMSampleBufferRef */ IntPtr sampleBuffer, /* VTDecodeFrameFlags */ VTDecodeFrameFlags decodeFlags, /* VTDecodeInfoFlags */ out VTDecodeInfoFlags infoFlagsOut, /* VTDecompressionOutputHandler */ BlockLiteral *outputHandler);
static unsafe void CopyHelper(BlockLiteral *dest, BlockLiteral *source) { dest->global_handle = (IntPtr)GCHandle.Alloc(GCHandle.FromIntPtr(dest->local_handle).Target); }
protected unsafe TrampolineBlockBase(BlockLiteral *block) { blockPtr = _Block_copy((IntPtr)block); }
unsafe static extern IntPtr nw_parameters_create_custom_ip(byte custom_ip_protocol_number, BlockLiteral *configure_ip);
public unsafe NIDCompletionCallback(BlockLiteral *block) { blockPtr = _Block_copy((IntPtr)block); invoker = block->GetDelegateForBlock <DCompletionCallback> (); }
public unsafe NIDCSVoidBlock(BlockLiteral *block) { blockPtr = _Block_copy((IntPtr)block); invoker = block->GetDelegateForBlock <DCSVoidBlock> (); }
public MTLGraphicsDevice( GraphicsDeviceOptions options, SwapchainDescription?swapchainDesc) { _device = MTLDevice.MTLCreateSystemDefaultDevice(); MetalFeatures = new MTLFeatureSupport(_device); Features = new GraphicsDeviceFeatures( computeShader: true, geometryShader: false, tessellationShaders: false, multipleViewports: MetalFeatures.IsSupported(MTLFeatureSet.macOS_GPUFamily1_v3), samplerLodBias: false, drawBaseVertex: true, drawBaseInstance: true, drawIndirect: true, drawIndirectBaseInstance: true, fillModeWireframe: true, samplerAnisotropy: true, depthClipDisable: true, texture1D: true, // TODO: Should be macOS 10.11+ and iOS 11.0+. independentBlend: true, structuredBuffer: true, subsetTextureView: true, commandListDebugMarkers: true, bufferRangeBinding: true); ResourceBindingModel = options.ResourceBindingModel; _libSystem = new NativeLibrary("libSystem.dylib"); _concreteGlobalBlock = _libSystem.LoadFunction <IntPtr>("_NSConcreteGlobalBlock"); if (MetalFeatures.IsMacOS) { _completionHandler = OnCommandBufferCompleted; } else { _completionHandler = OnCommandBufferCompleted_Static; } _completionHandlerFuncPtr = Marshal.GetFunctionPointerForDelegate <MTLCommandBufferHandler>(_completionHandler); _completionBlockDescriptor = Marshal.AllocHGlobal(Unsafe.SizeOf <BlockDescriptor>()); BlockDescriptor *descriptorPtr = (BlockDescriptor *)_completionBlockDescriptor; descriptorPtr->reserved = 0; descriptorPtr->Block_size = (ulong)Unsafe.SizeOf <BlockDescriptor>(); _completionBlockLiteral = Marshal.AllocHGlobal(Unsafe.SizeOf <BlockLiteral>()); BlockLiteral *blockPtr = (BlockLiteral *)_completionBlockLiteral; blockPtr->isa = _concreteGlobalBlock; blockPtr->flags = 1 << 28 | 1 << 29; blockPtr->invoke = _completionHandlerFuncPtr; blockPtr->descriptor = descriptorPtr; if (!MetalFeatures.IsMacOS) { lock (s_aotRegisteredBlocks) { s_aotRegisteredBlocks.Add(_completionBlockLiteral, this); } } ResourceFactory = new MTLResourceFactory(this); _commandQueue = _device.newCommandQueue(); TextureSampleCount[] allSampleCounts = (TextureSampleCount[])Enum.GetValues(typeof(TextureSampleCount)); _supportedSampleCounts = new bool[allSampleCounts.Length]; for (int i = 0; i < allSampleCounts.Length; i++) { TextureSampleCount count = allSampleCounts[i]; uint uintValue = FormatHelpers.GetSampleCountUInt32(count); if (_device.supportsTextureSampleCount((UIntPtr)uintValue)) { _supportedSampleCounts[i] = true; } } if (swapchainDesc != null) { SwapchainDescription desc = swapchainDesc.Value; _mainSwapchain = new MTLSwapchain(this, ref desc); } PostDeviceCreated(); }
static unsafe void DisposeHelper(BlockLiteral *block) { GCHandle.FromIntPtr(block->global_handle).Free(); }
static unsafe extern void CTLineEnumerateCaretOffsets(IntPtr line, BlockLiteral *blockEnumerator);
public unsafe NIDPrinterScanPrintersCallback(BlockLiteral *block) { blockPtr = _Block_copy((IntPtr)block); invoker = block->GetDelegateForBlock <DPrinterScanPrintersCallback> (); }