Example #1
0
        public override void RenderFrame(FrameBitmapBuffer buffer, IPlatformWindow owner)
        {
            var layoutResult = layoutEngine.ProcessLayout(owner.ClientSize, owner.ComponentTree);

            var info = new SKImageInfo(buffer.Width, buffer.Height, SKImageInfo.PlatformColorType, SKAlphaType.Premul);

            using (var surface = SKSurface.Create(info, buffer.Pixels, buffer.RowBytes))
            {
                foreach (var component in owner.ComponentTree.GetAllElements())
                {
                    if (component is ILayoutBox layoutBox && component is IVisualComponent element)
                    {
                        var frameRenderer = new FrameRenderer(owner.ClientSize, surface);
                        var renderContext = new RenderContext()
                        {
                            FrameRenderer = frameRenderer,
                            ClientSize    = owner.ClientSize,
                            LayoutInfo    = layoutResult.GetLayoutBoxInformation(layoutBox)
                        };

                        element.Render(renderContext);
                    }
                }
            }
        }
Example #2
0
        private void formPaint(object sender, PaintEventArgs e)
        {
            var bitmap = new Bitmap(form.Width, form.Height, PixelFormat.Format32bppPArgb);
            var data   = bitmap.LockBits(new System.Drawing.Rectangle(0, 0, form.Width, form.Height), ImageLockMode.WriteOnly, bitmap.PixelFormat);

            var buffer = new FrameBitmapBuffer()
            {
                Width    = form.Width,
                Height   = form.Height,
                RowBytes = data.Stride,
                Pixels   = data.Scan0
            };

            app.GetService <IRenderEngine>().RenderFrame(buffer, this);

            bitmap.UnlockBits(data);
            e.Graphics.DrawImage(bitmap, 0, 0);
        }