Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
 public override void Stop()
 {
     if (link == null)
     {
         return;
     }
     link?.Stop();
     link?.Dispose();
     link = null;
 }
Ejemplo n.º 3
0
        void DeAllocate()
        {
            if (_displayLink == null)
            {
                return;
            }

            _displayLink.Stop();
            _displayLink.Dispose();
            _displayLink = null;
        }
Ejemplo n.º 4
0
        protected override void Dispose(bool disposing)
        {
            // stop the render loop
            if (displayLink != null)
            {
                displayLink.Stop();
                displayLink.Dispose();
                displayLink = null;
            }

            base.Dispose(disposing);
        }
Ejemplo n.º 5
0
        protected override void Dispose(bool disposing)
        {
            if (_displayLink != null)
            {
                _displayLink.Dispose();
                _displayLink = null;

                if (Element != null)
                {
                    Element.DisplayRequested -= Display;
                }
            }

            base.Dispose(disposing);
        }
Ejemplo n.º 6
0
        protected override void Dispose(bool disposing)
        {
            if (_displayLink != null)
            {
                _displayLink.Dispose();
                _displayLink = null;

                if (Element != null)
                {
                    ((IOpenGlViewController)Element).DisplayRequested -= Display;
                }
            }

            base.Dispose(disposing);
        }
Ejemplo n.º 7
0
        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();
        }
Ejemplo n.º 8
0
        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();
        }
Ejemplo n.º 9
0
 protected override void DisableTimer()
 {
     _link?.Stop();
     _link?.Dispose();
     _link = null;
 }