26 : base(Math.Max(1, control.ClientSize.
Width), Math.Max(1, control.ClientSize.
Height), initialSizeAvailable: control.IsHandleCreated)
28 _control = control ??
throw new ArgumentNullException(nameof(control));
30 _control.PaintSurface += OnPaintSurface;
31 _control.HandleCreated += OnHandleCreated;
32 _control.ClientSizeChanged += OnSizeChanged;
35 if (_control.IsHandleCreated)
61 public override void Present(SKImage bufferImage, SKRectI bufferRect, SKRect destRect)
64 if (_control.IsDisposed || !_control.IsHandleCreated)
66 bufferImage.Dispose();
70 var sourceRect = SKRectI.Intersect(
72 new SKRectI(0, 0, bufferImage.Width, bufferImage.Height));
74 var dirty = global::System.Drawing.Rectangle.FromLTRB(sourceRect.Left, sourceRect.Top, sourceRect.Right, sourceRect.Bottom);
77 var invalidateRect = global::System.Drawing.Rectangle.Intersect(
78 Presentation.ScreenRectToAdapterRect(dirty), _control.ClientRectangle);
80 if (sourceRect ==
new SKRectI(0, 0, bufferImage.Width, bufferImage.Height))
81 invalidateRect = _control.ClientRectangle;
83 if (sourceRect.IsEmpty || invalidateRect.IsEmpty)
85 bufferImage.Dispose();
93 bufferImage.Dispose();
99 var old = _currentImage;
100 _currentImage = bufferImage;
101 if (!ReferenceEquals(old, _currentImage) && old is not
null)
102 _toDispose.Enqueue(old);
106 _control.Invalidate(invalidateRect);