Exemplo n.º 1
0
                public layer(viewwindow owner)
                    : base()
                {
                    this.owner = owner;
                    base.NeedsDisplayOnBoundsChange = true;
                    base.Asynchronous = true;

                    lastupdate = -1;
                    timebase   = 0;

#if (false)
                    this.thread = new Thread(() =>
                    {
                        /*   var wBackend = Xwt.Toolkit.CurrentEngine.GetSafeBackend(owner.window.ParentWindow) as Xwt.Backends.IWindowFrameBackend;
                         * var win = wBackend.Window as NSWindow;
                         *
                         * while (win.ParentWindow != null)
                         * {
                         *     win = win.ParentWindow;
                         * }*/

                        long lu = 0, t = 0;

                        while (!stop.WaitOne(0, false))
                        {
                            while (!stop.WaitOne(20, false))
                            {
                                t = Interlocked.Add(ref this.lastupdate, 0);

                                if (t == -1)
                                {
                                    continue;
                                }

                                if (DateTime.Now.Ticks - t > 500000)
                                {
                                    break;
                                }
                            }
                            Thread.Sleep(30);
                            long t2 = Interlocked.Add(ref this.lastupdate, 0);

                            if (t == t2)
                            {
                                var tt = Math.Max(lu, t);
                                //       this.owner.renderer.SkipRender(DateTime.Now.Ticks - tt);
                                lu = tt;
                            }
                        }
                        this.stopped.Set();
                    })
                    {
                        Name = "wincheck"
                    };

                    this.thread.Start();
#endif
                }
Exemplo n.º 2
0
        void IXwtRender.CreateForWidgetContext(IRenderer renderer, IRenderOwner rendererimpl, Canvas widget)
        {
            var o        = Xwt.Toolkit.CurrentEngine.GetSafeBackend(widget);
            var wBackend = Xwt.Toolkit.CurrentEngine.GetSafeBackend(widget) as Xwt.Backends.IWidgetBackend;
            //  var nsWindow = wBackend.NativeHandle;l;
            var nsView = (wBackend.NativeWidget as NSView);

            var ctx = new NSOpenGLContext(GetOpenGLPixelFormat(0), null);

            var error = viewwindow.layer.CGLEnable(ctx.CGLContext.Handle, 313); // enable multithread

            viewwindow view = null;

            //    ctx.CGLContext.Lock();
            //   ctx.MakeCurrentContext();

            Application.InvokeAsync(() =>
            {
                view = new viewwindow(renderer, rendererimpl, widget, ViewPostion(widget, wBackend), ctx);

                nsView.AddSubview(view);

                Debug.Assert(!views.ContainsKey(widget));

                views[widget] = new viewinfo()
                {
                    orgview = nsView, /* backend = wBackend,*/ myview = view, widget = widget
                };

                widget.BoundsChanged += sizechanged;
            }).Wait();

            /*    (this as IXwtRender).StartRender(renderer, widget);
             *  view._ctx = new _GraphicsContext();
             *  (this as IXwtRender).EndRender(renderer, widget);*/

            this.QueueOnUI(() => view.initdone.Set());
        }