示例#1
0
        private static void RenderVisual(SKSurface surface, SKImageInfo info, Visual visual)
        {
            if (visual.Opacity != 0)
            {
                surface.Canvas.Save();

                var visualMatrix = surface.Canvas.TotalMatrix;

                visualMatrix = visualMatrix.PreConcat(SKMatrix.CreateTranslation(visual.Offset.X, visual.Offset.Y));

                if (visual.RotationAngleInDegrees != 0)
                {
                    visualMatrix = visualMatrix.PreConcat(SKMatrix.CreateRotationDegrees(visual.RotationAngleInDegrees, visual.CenterPoint.X, visual.CenterPoint.Y));
                }

                if (visual.TransformMatrix != Matrix4x4.Identity)
                {
                    visualMatrix = visualMatrix.PreConcat(visual.TransformMatrix.ToSKMatrix44().Matrix);
                }

                surface.Canvas.SetMatrix(visualMatrix);

                if (visual.Clip is InsetClip insetClip)
                {
                    surface.Canvas.ClipRect(new SKRect {
                        Top    = insetClip.TopInset,
                        Bottom = insetClip.BottomInset,
                        Left   = insetClip.LeftInset,
                        Right  = insetClip.RightInset
                    });
                }

                visual.Render(surface, info);

                switch (visual)
                {
                case SpriteVisual spriteVisual:
                    foreach (var inner in spriteVisual.Children)
                    {
                        RenderVisual(surface, info, inner);
                    }
                    break;

                case ContainerVisual containerVisual:
                    foreach (var inner in containerVisual.Children)
                    {
                        RenderVisual(surface, info, inner);
                    }
                    break;
                }

                surface.Canvas.Restore();
            }
        }
示例#2
0
        private void RenderVisual(SKSurface surface, SKImageInfo info, Visual visual)
        {
            if (visual.Opacity != 0 && visual.IsVisible)
            {
                surface.Canvas.Save();

                var visualMatrix = surface.Canvas.TotalMatrix;

                visualMatrix = visualMatrix.PreConcat(SKMatrix.CreateTranslation(visual.Offset.X, visual.Offset.Y));
                visualMatrix = visualMatrix.PreConcat(SKMatrix.CreateTranslation(visual.AnchorPoint.X, visual.AnchorPoint.Y));

                if (visual.RotationAngleInDegrees != 0)
                {
                    visualMatrix = visualMatrix.PreConcat(SKMatrix.CreateRotationDegrees(visual.RotationAngleInDegrees, visual.CenterPoint.X, visual.CenterPoint.Y));
                }

                if (visual.TransformMatrix != Matrix4x4.Identity)
                {
                    visualMatrix = visualMatrix.PreConcat(visual.TransformMatrix.ToSKMatrix44().Matrix);
                }

                surface.Canvas.SetMatrix(visualMatrix);

                ApplyClip(surface, visual);

                using var opacityDisposable = PushOpacity(visual.Opacity);

                visual.Render(surface, info);

                switch (visual)
                {
                case SpriteVisual spriteVisual:
                    foreach (var inner in spriteVisual.Children)
                    {
                        RenderVisual(surface, info, inner);
                    }
                    break;

                case ContainerVisual containerVisual:
                    foreach (var inner in containerVisual.Children)
                    {
                        RenderVisual(surface, info, inner);
                    }
                    break;
                }

                surface.Canvas.Restore();
            }
        }
示例#3
0
        internal void RenderVisual(SKSurface surface, Visual visual)
        {
            if (visual.Opacity != 0 && visual.IsVisible)
            {
                if (visual.ShadowState is { } shadow)
                {
                    surface.Canvas.SaveLayer(shadow.Paint);
                }
                else
                {
                    surface.Canvas.Save();
                }

                var visualMatrix = surface.Canvas.TotalMatrix;

                visualMatrix = visualMatrix.PreConcat(SKMatrix.CreateTranslation(visual.Offset.X, visual.Offset.Y));
                visualMatrix = visualMatrix.PreConcat(SKMatrix.CreateTranslation(visual.AnchorPoint.X, visual.AnchorPoint.Y));

                if (visual.RotationAngleInDegrees != 0)
                {
                    visualMatrix = visualMatrix.PreConcat(SKMatrix.CreateRotationDegrees(visual.RotationAngleInDegrees, visual.CenterPoint.X, visual.CenterPoint.Y));
                }

                if (visual.TransformMatrix != Matrix4x4.Identity)
                {
                    visualMatrix = visualMatrix.PreConcat(visual.TransformMatrix.ToSKMatrix44().Matrix);
                }

                surface.Canvas.SetMatrix(visualMatrix);

                ApplyClip(surface, visual);

                using var opacityDisposable = PushOpacity(visual.Opacity);

                visual.Render(surface);

                if (visual is ContainerVisual containerVisual)
                {
                    var children = containerVisual.GetChildrenInRenderOrder();
                    for (var i = 0; i < children.Count; i++)
                    {
                        RenderVisual(surface, children[i]);
                    }
                }

                surface.Canvas.Restore();
            }