|
|
|
@ -287,17 +287,22 @@ namespace Avalonia.Web.Blazor |
|
|
|
|
|
|
|
_topLevelImpl.SetSurface(_context, _jsGlInfo, ColorType, |
|
|
|
new PixelSize((int)_canvasSize.Width, (int)_canvasSize.Height), _dpi); |
|
|
|
|
|
|
|
_interop.SetCanvasSize((int)(_canvasSize.Width * _dpi), (int)(_canvasSize.Height * _dpi)); |
|
|
|
|
|
|
|
_initialised = true; |
|
|
|
|
|
|
|
_topLevel.Prepare(); |
|
|
|
|
|
|
|
_topLevel.Renderer.Start(); |
|
|
|
|
|
|
|
Invalidate(); |
|
|
|
|
|
|
|
_sizeWatcher = await SizeWatcherInterop.ImportAsync(Js, _htmlCanvas, OnSizeChanged); |
|
|
|
_dpiWatcher = await DpiWatcherInterop.ImportAsync(Js, OnDpiChanged); |
|
|
|
Threading.Dispatcher.UIThread.Post(async () => |
|
|
|
{ |
|
|
|
_interop.RequestAnimationFrame(true); |
|
|
|
|
|
|
|
_sizeWatcher = await SizeWatcherInterop.ImportAsync(Js, _htmlCanvas, OnSizeChanged); |
|
|
|
_dpiWatcher = await DpiWatcherInterop.ImportAsync(Js, OnDpiChanged); |
|
|
|
|
|
|
|
_topLevel.Prepare(); |
|
|
|
|
|
|
|
_topLevel.Renderer.Start(); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -336,37 +341,30 @@ namespace Avalonia.Web.Blazor |
|
|
|
|
|
|
|
private void OnDpiChanged(double newDpi) |
|
|
|
{ |
|
|
|
_dpi = newDpi; |
|
|
|
if (Math.Abs(_dpi - newDpi) > 0.0001) |
|
|
|
{ |
|
|
|
_dpi = newDpi; |
|
|
|
|
|
|
|
_interop.SetCanvasSize((int)(_canvasSize.Width * _dpi), (int)(_canvasSize.Height * _dpi)); |
|
|
|
|
|
|
|
_topLevelImpl.SetClientSize(_canvasSize, _dpi); |
|
|
|
|
|
|
|
ForceBlit(); |
|
|
|
_topLevelImpl.SetClientSize(_canvasSize, _dpi); |
|
|
|
|
|
|
|
Invalidate(); |
|
|
|
ForceBlit(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void OnSizeChanged(SKSize newSize) |
|
|
|
{ |
|
|
|
_canvasSize = newSize; |
|
|
|
|
|
|
|
_interop.SetCanvasSize((int)(_canvasSize.Width * _dpi), (int)(_canvasSize.Height * _dpi)); |
|
|
|
|
|
|
|
_topLevelImpl.SetClientSize(_canvasSize, _dpi); |
|
|
|
if (_canvasSize != newSize) |
|
|
|
{ |
|
|
|
_canvasSize = newSize; |
|
|
|
|
|
|
|
ForceBlit(); |
|
|
|
_interop.SetCanvasSize((int)(_canvasSize.Width * _dpi), (int)(_canvasSize.Height * _dpi)); |
|
|
|
|
|
|
|
Invalidate(); |
|
|
|
} |
|
|
|
_topLevelImpl.SetClientSize(_canvasSize, _dpi); |
|
|
|
|
|
|
|
public void Invalidate() |
|
|
|
{ |
|
|
|
if (!_initialised || _jsGlInfo == null) |
|
|
|
{ |
|
|
|
Console.WriteLine("invalidate ignored"); |
|
|
|
return; |
|
|
|
ForceBlit(); |
|
|
|
} |
|
|
|
|
|
|
|
_interop.RequestAnimationFrame(true); |
|
|
|
} |
|
|
|
|
|
|
|
public void SetActive(bool active) |
|
|
|
|