示例#1
0
        public override void Draw(CGRect rect)
        {
            base.Draw(rect);

            if (designMode || drawable == null)
            {
                return;
            }

            using (var ctx = UIGraphics.GetCurrentContext())
            {
                // create the skia context
                SKImageInfo info;
                using (var surface = drawable.CreateSurface(Bounds, IgnorePixelScaling ? 1 : ContentScaleFactor, out info))
                {
                    // draw on the image using SKiaSharp
                    OnPaintSurface(new SKPaintSurfaceEventArgs(surface, info));
#pragma warning disable CS0618 // Type or member is obsolete
                    DrawInSurface(surface, info);
#pragma warning restore CS0618 // Type or member is obsolete

                    // draw the surface to the context
                    drawable.DrawSurface(ctx, Bounds, info, surface);
                }
            }
        }
示例#2
0
        public override void DrawInContext(CGContext ctx)
        {
            base.DrawInContext(ctx);

            // create the skia context
            using (var surface = drawable.CreateSurface(Bounds, IgnorePixelScaling ? 1 : ContentsScale, out var info))
            {
                // draw on the image using SKiaSharp
                OnPaintSurface(new SKPaintSurfaceEventArgs(surface, info));
#pragma warning disable CS0618 // Type or member is obsolete
                DrawInSurface(surface, info);
                SKDelegate?.DrawInSurface(surface, info);
#pragma warning restore CS0618 // Type or member is obsolete

                // draw the surface to the context
                drawable.DrawSurface(ctx, Bounds, info, surface);
            }
        }
示例#3
0
        public override void DrawRect(CGRect dirtyRect)
        {
            base.DrawRect(dirtyRect);

            if (designMode || !isVisible || drawable == null)
            {
                return;
            }

            // create the skia context
            using var surface = drawable.CreateSurface(Bounds, Window.BackingScaleFactor, out var info);
            if (info.Width == 0 || info.Height == 0)
            {
                CanvasSize = SKSize.Empty;
                return;
            }

            var userVisibleSize = IgnorePixelScaling
                                ? new SKSizeI((int)Bounds.Width, (int)Bounds.Height)
                                : info.Size;

            CanvasSize = userVisibleSize;

            if (IgnorePixelScaling)
            {
                var skiaCanvas = surface.Canvas;
                skiaCanvas.Scale((float)Window.BackingScaleFactor);
                skiaCanvas.Save();
            }

            using var ctx = NSGraphicsContext.CurrentContext.CGContext;

            // draw on the image using SKiaSharp
            OnPaintSurface(new SKPaintSurfaceEventArgs(surface, info.WithSize(userVisibleSize), info));

            // draw the surface to the context
            drawable.DrawSurface(ctx, Bounds, info, surface);
        }
示例#4
0
        public override void Draw(CGRect dirtyRect)
        {
            base.Draw(dirtyRect);

            if (designMode || !isVisible || drawable == null)
            {
                return;
            }

            // create the skia context
            using var surface = drawable.CreateSurface(Bounds, IgnorePixelScaling ? 1 : ContentScaleFactor, out var info);
            if (info.Width == 0 || info.Height == 0)
            {
                return;
            }

            using var ctx = UIGraphics.GetCurrentContext();

            // draw on the image using SKiaSharp
            OnPaintSurface(new SKPaintSurfaceEventArgs(surface, info));

            // draw the surface to the context
            drawable.DrawSurface(ctx, Bounds, info, surface);
        }