You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a weird behaviour when using SKSwapChainPanel on IOS every ManipulationDelta of the Scale is 1. If SKXamlCanvas is used everything works just fine on every platform.
Even though the event is not registered directly on SKSwapChainPanel the e.Delta.Scale is 1.
Code
Codesample is based on the SkiaSharptest sample of uno platform:
usingMicrosoft.UI.Xaml.Input;usingWindows.Foundation;usingSkiaSharp;usingSkiaSharp.Views.Windows;// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409namespaceSkiaSharpTest{/// <summary>/// An empty page that can be used on its own or navigated to within a Frame./// </summary>publicsealedpartialclassMainPage:Page{privatePoint_currentPosition;publicMainPage(){
#if !WINDOWSSKSwapChainPanel.RaiseOnUnsupported=false;
#endif
this.ManipulationDelta+=MainPage_ManipulationDelta;this.ManipulationMode=ManipulationModes.TranslateX|ManipulationModes.TranslateY|ManipulationModes.Scale;this.InitializeComponent();
#if HAS_UNO_SKIA||WINDOWSnotSupported.Visibility=Visibility.Visible;
#endif
}publicfloatZoom{get;set;}=1;privatevoidMainPage_ManipulationDelta(objectsender,ManipulationDeltaRoutedEventArgse){Zoom*=e.Delta.Scale;if(e.Delta.Scale!=1){if(hwAcceleration.IsChecked??false){
#if !WINDOWSswapChain.Invalidate();
#endif
}else{canvas.Invalidate();}}}privateVisibilityNot(bool?value)=>(!value??false)?Visibility.Visible:Visibility.Collapsed;privatevoidOnPaintSwapChain(objectsender,SKPaintGLSurfaceEventArgse){// the the canvas and propertiesvarcanvas=e.Surface.Canvas;varinfo=e.Info;Render(canvas,newSize(info.Width,info.Height),SKColors.Green,"SkiaSharp Hardware Rendering");//canvas.Scale(Zoom);}privatevoidOnPaintSurface(objectsender,SKPaintSurfaceEventArgse){// the the canvas and propertiesvarcanvas=e.Surface.Canvas;varinfo=e.Info;Render(canvas,newSize(info.Width,info.Height),SKColors.Yellow,"SkiaSharp Software Rendering");//canvas.Scale(Zoom);}privatevoidOnSurfacePointerMoved(objectsender,PointerRoutedEventArgse){_currentPosition=e.GetCurrentPoint(panelGrid).Position;currentPositionText.Text=_currentPosition.ToString();if(hwAcceleration.IsChecked??false){
#if !WINDOWSswapChain.Invalidate();
#endif
}else{canvas.Invalidate();}}privatevoidRender(SKCanvascanvas,Sizesize,SKColorcolor,stringtext){// get the screen density for scalingvarscale=(float)this.XamlRoot.RasterizationScale;varscaledSize=newSKSize((float)size.Width/scale,(float)size.Height/scale);// handle the device screen densitycanvas.Scale(scale*Zoom);// make sure the canvas is blankcanvas.Clear(color);// draw some textvarpaint=newSKPaint{Color=SKColors.Black,IsAntialias=true,Style=SKPaintStyle.Fill,TextAlign=SKTextAlign.Center,TextSize=24};varcoord=newSKPoint(scaledSize.Width/2,(scaledSize.Height+paint.TextSize)/2);canvas.DrawText(text,coord,paint);varcirclePaint=newSKPaint{Style=SKPaintStyle.Fill,Color=SKColors.Red};canvas.DrawCircle((float)_currentPosition.X,(float)_currentPosition.Y,5,circlePaint);}}}
Description
There is a weird behaviour when using SKSwapChainPanel on IOS every ManipulationDelta of the Scale is 1. If SKXamlCanvas is used everything works just fine on every platform.
Even though the event is not registered directly on SKSwapChainPanel the e.Delta.Scale is 1.
Code
Codesample is based on the SkiaSharptest sample of uno platform:
SKSwapChainPanelIOS.zip
You can also share some XAML:
Expected Behavior
No response
Actual Behavior
No response
Version of SkiaSharp
2.88.9 (Previous)
Last Known Good Version of SkiaSharp
Other (Please indicate in the description)
IDE / Editor
Visual Studio (Windows)
Platform / Operating System
iOS
Platform / Operating System Version
iOS 18.0 - 18.3
Devices
No response
Relevant Screenshots
No response
Relevant Log Output
Code of Conduct
The text was updated successfully, but these errors were encountered: