// Clean up the notifications public void DeAllocate() { displayLink.Stop(); displayLink.SetOutputCallback(null); NSNotificationCenter.DefaultCenter.RemoveObserver(notificationProxy); }
protected override void SetupRenderLoop(bool oneShot) { // only start if we haven't already if (displayLink != null) { return; } // bail out if we are requesting something that the view doesn't want to if (!oneShot && !Element.HasRenderLoop) { return; } // if this is a one shot request, don't bother with the display link if (oneShot) { var nativeView = Control; nativeView?.BeginInvokeOnMainThread(() => { if (nativeView.Handle != IntPtr.Zero) { nativeView.NeedsDisplay = true; } }); return; } // create the loop displayLink = new CVDisplayLink(); displayLink.SetOutputCallback(delegate { var nativeView = Control; var formsView = Element; // stop the render loop if this was a one-shot, or the views are disposed if (nativeView == null || formsView == null || nativeView.Handle == IntPtr.Zero || !formsView.HasRenderLoop) { displayLink.Stop(); displayLink.Dispose(); displayLink = null; return(CVReturn.Success); } // redraw the view nativeView?.BeginInvokeOnMainThread(() => { if (nativeView != null) { nativeView.NeedsDisplay = true; } }); return(CVReturn.Success); }); displayLink.Start(); }
public override void Start() { if (link != null) { return; } link = new CVDisplayLink(); link.SetOutputCallback(DisplayLinkOutputCallback); link.Start(); }
public void Startup() { DisplayTitle(); displayLink = new CVDisplayLink(); displayLink.SetOutputCallback(DisplayLinkOutputCallback); tickStopWatch = new Stopwatch(); tickStopWatch.Start(); displayLink.Start(); }
private void SetupDisplayLink() { // Create a display link capable of being used with all active displays displayLink = new CVDisplayLink(); // Set the renderer output callback function displayLink.SetOutputCallback(MyDisplayLinkOutputCallback); // Set the display link for the current renderer CGLContext cglContext = openGLContext.CGLContext; CGLPixelFormat cglPixelFormat = PixelFormat.CGLPixelFormat; displayLink.SetCurrentDisplay(cglContext, cglPixelFormat); }
private void Control_Draw(object sender, EventArgs e) { Callback.OnInitializeBackend(Widget, new InitializeEventArgs(RenderSize)); if (Widget.Backend == GraphicsBackend.Metal) { _displayLink = new CVDisplayLink(); _displayLink.SetOutputCallback(HandleDisplayLinkOutputCallback); _displayLink.Start(); } Control.Draw -= Control_Draw; Widget.SizeChanged += Widget_SizeChanged; }
partial void DoEnableRenderLoop(bool enable) { // stop the render loop if (!enable) { if (displayLink != null) { displayLink.Stop(); displayLink.Dispose(); displayLink = null; } return; } // only start if we haven't already if (displayLink != null) { return; } // create the loop displayLink = new CVDisplayLink(); displayLink.SetOutputCallback(delegate { // redraw the view glView?.BeginInvokeOnMainThread(() => { if (glView != null) { glView.NeedsDisplay = true; } }); // stop the render loop if it has been disabled or the views are disposed if (glView == null || !EnableRenderLoop) { DoEnableRenderLoop(false); } return(CVReturn.Success); }); displayLink.Start(); }
public override void ViewDidMoveToWindow() { base.ViewDidMoveToWindow(); var swapchainSource = SwapchainSource.CreateNSView(Handle); var swapchainDescription = new SwapchainDescription(swapchainSource, (uint)Frame.Width, (uint)Frame.Height, null, true, true); if (_backend == GraphicsBackend.Metal) { GraphicsDevice = GraphicsDevice.CreateMetal(_deviceOptions); } MainSwapchain = GraphicsDevice.ResourceFactory.CreateSwapchain(swapchainDescription); DeviceReady?.Invoke(); _displayLink = new CVDisplayLink(); _displayLink.SetOutputCallback(HandleDisplayLinkOutputCallback); _displayLink.Start(); }
protected override void SetupRenderLoop(bool oneShot) { // only start if we haven't already if (displayLink != null) { return; } // bail out if we are requesting something that the view doesn't want to if (!oneShot && !Element.HasRenderLoop) { return; } // create the loop displayLink = new CVDisplayLink(); displayLink.SetOutputCallback(delegate { var formsView = Control; var nativeView = Element; // redraw the view formsView?.Display(); // stop the render loop if this was a one-shot, or the views are disposed if (formsView == null || nativeView == null || !nativeView.HasRenderLoop) { displayLink.Stop(); displayLink.Dispose(); displayLink = null; } return(CVReturn.Success); }); displayLink.Start(); }
private void SetupDisplayLink () { // Create a display link capable of being used with all active displays displayLink = new CVDisplayLink (); // Set the renderer output callback function displayLink.SetOutputCallback (MyDisplayLinkOutputCallback); // Set the display link for the current renderer CGLContext cglContext = openGLContext.CGLContext; CGLPixelFormat cglPixelFormat = PixelFormat.CGLPixelFormat; displayLink.SetCurrentDisplay (cglContext, cglPixelFormat); }
protected override void EnableTimer() { _link = new CVDisplayLink(); _link.SetOutputCallback(DisplayLinkOutputCallback); _link.Start(); }