コード例 #1
0
        public void Close()
        {
            //1. clear all subForms
            if (_rootgfx != null)
            {
                _rootgfx.CloseWinRoot();
                _rootgfx = null;
            }

            if (_winBridge != null)
            {
                _winBridge.Close();
                _winBridge = null;
            }

#if DEBUG
            System.GC.Collect();
#endif
        }
コード例 #2
0
        public static void CreateCanvasControlOnExistingControl(
            Control landingControl,
            int xpos, int ypos,
            int w, int h,
            InnerViewportKind internalViewportKind,
            out GraphicsViewRoot view_root)
        {
            //1. init
            InitWinform();
            IInstalledTypefaceProvider fontLoader = YourImplementation.CommonTextServiceSetup.FontLoader;

            //2.


            switch (internalViewportKind)
            {
            default:
                //gdi, gdi on gles


                break;

            case InnerViewportKind.PureAgg:
            case InnerViewportKind.AggOnGLES:
            case InnerViewportKind.GLES:
            {
                var openFontTextService = new Typography.Text.OpenFontTextService();
                openFontTextService.SvgBmpBuilder = PaintLab.SvgBuilderHelper.ParseAndRenderSvg;

                PixelFarm.Drawing.GLES2.GLES2Platform.TextService = openFontTextService;

                Typography.Text.GlobalTextService.TxtClient = openFontTextService.CreateNewServiceClient();
            }
            break;
            }

            PixelFarm.Drawing.WinGdi.WinGdiPlusPlatform.SetInstalledTypefaceProvider(fontLoader);
            //---------------------------------------------------------------------------
            //3. root graphics

            PixelFarm.Drawing.Rectangle screenClientAreaRect = Conv.ToRect(Screen.PrimaryScreen.WorkingArea);
            w = screenClientAreaRect.Width;
            h = screenClientAreaRect.Height;



            MyRootGraphic myRootGfx = new MyRootGraphic(w, h);

            //4. create event bridge that will bridge from native window event to root graphics
            AbstractTopWindowBridge bridge = GetTopWindowBridge(internalViewportKind, myRootGfx, myRootGfx.TopWinEventPortal);

            //5. actualWinUI is platform specific
            var actualWinUI = new LayoutFarm.UI.MyWinFormsControl();

            actualWinUI.Size = new System.Drawing.Size(w, h);
            landingControl.Controls.Add(actualWinUI);


            //so we create abstraction of actual UI
            IGpuOpenGLSurfaceView viewAbstraction = actualWinUI.CreateWindowWrapper(bridge);

            var viewRoot = view_root = new GraphicsViewRoot(
                screenClientAreaRect.Width,
                screenClientAreaRect.Height);

            view_root.InitRootGraphics(
                myRootGfx,
                myRootGfx.TopWinEventPortal,
                internalViewportKind,
                viewAbstraction,
                bridge);

            //TODO: review here again
            myRootGfx.SetDrawboardReqDelegate(view_root.GetDrawBoard);
            //------
            //TODO: review here
            view_root.SetBounds(xpos, ypos,
                                screenClientAreaRect.Width,
                                screenClientAreaRect.Height);

            //
            Form ownerForm = landingControl.FindForm();

            if (ownerForm != null)
            {
                ownerForm.FormClosing += (s, e) =>
                {
                    //TODO: review here
                    viewRoot.Close();
                };
            }
        }
コード例 #3
0
        public void InitRootGraphics(RootGraphic rootgfx,
                                     ITopWindowEventRoot topWinEventRoot,
                                     InnerViewportKind innerViewportKind,
                                     IGpuOpenGLSurfaceView nativeWindow,
                                     AbstractTopWindowBridge bridge)
        {
            //create a proper bridge****
            _rootgfx           = rootgfx;
            _topWinEventRoot   = topWinEventRoot;
            _innerViewportKind = innerViewportKind;
            _viewport          = nativeWindow;
            _winBridge         = bridge;

            nativeWindow.SetSize(rootgfx.Width, rootgfx.Height);

            switch (innerViewportKind)
            {
            case InnerViewportKind.GdiPlusOnGLES:
            case InnerViewportKind.AggOnGLES:
            case InnerViewportKind.GLES:
            {
                _winBridge.OnHostControlLoaded();
                try
                {
                    nativeWindow.MakeCurrent();
                }
                catch (Exception ex)
                {
                }
                int w = nativeWindow.Width;
                int h = nativeWindow.Height;

                int max = Math.Max(w, h);

                _pcx       = PixelFarm.DrawingGL.GLPainterCore.Create(max, max, w, h, true);
                _glPainter = new GLPainter();
                _glPainter.BindToPainterCore(_pcx);


                if (PixelFarm.Drawing.GLES2.GLES2Platform.TextService != null)
                {
                    var printer = new GLBitmapGlyphTextPrinter(_glPainter, PixelFarm.Drawing.GLES2.GLES2Platform.TextService);

                    _glPainter.TextPrinter = printer;
                }
                else
                {
                    //warn....!
                }

                //canvasPainter.SmoothingMode = PixelFarm.Drawing.SmoothingMode.HighQuality;
                //----------------------
                //1. win gdi based
                //var printer = new WinGdiFontPrinter(canvas2d, view.Width, view.Height);
                //canvasPainter.TextPrinter = printer;
                //----------------------
                //2. raw vxs
                //var printer = new PixelFarm.Drawing.Fonts.VxsTextPrinter(canvasPainter);
                //canvasPainter.TextPrinter = printer;
                //----------------------
                //3. agg texture based font texture
                //_glPainter.TextPrinter = new CpuBlitTextSpanPrinter2(_glPainter, 400, 50, PixelFarm.Drawing.GLES2.GLES2Platform.TextService);

                //TODO: review this again!
                //3
                var drawboard = new PixelFarm.Drawing.GLES2.MyGLDrawBoard(_glPainter);
                _glPainter.SetDrawboard(drawboard);
                _drawboard = drawboard;

                //{
                //in mixed mode
                //GDI+ on GLES, Agg on GLES we provide a software rendering layer too
                PixelFarm.Drawing.DrawBoard cpuDrawBoard = null;        // CreateSoftwareDrawBoard(view.Width, view.Height, innerViewportKind);
                drawboard.SetCpuBlitDrawBoardCreator(() => cpuDrawBoard ?? (cpuDrawBoard = CreateSoftwareDrawBoard(w, h, innerViewportKind)));
                //}
                ((OpenGL.MyTopWindowBridgeOpenGL)_winBridge).SetCanvas(drawboard);
            }
            break;
            }
        }