Skip to content

Commit 46ca1e2

Browse files
committed
Removed _pixelDensity local variable
1 parent a6873f2 commit 46ca1e2

2 files changed

Lines changed: 6 additions & 15 deletions

File tree

Mapsui.UI.Android/MapControl.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ public partial class MapControl : ViewGroup, IMapControl
2424
private double _previousRadius = 1f;
2525
private TouchMode _mode = TouchMode.None;
2626
/// <summary>
27-
/// The number of pixels per device independent unit
28-
/// </summary>
29-
private float _pixelDensity;
30-
/// <summary>
3127
/// Saver for center before last pinch movement
3228
/// </summary>
3329
private Point _previousCenter = new Point();
@@ -47,7 +43,6 @@ public MapControl(Context context, IAttributeSet attrs, int defStyle) :
4743
public void Initialize()
4844
{
4945
SetBackgroundColor(Color.Transparent);
50-
_pixelDensity = PixelDensity;
5146
_canvas = new SKCanvasView(Context) { IgnorePixelScaling = true };
5247
_canvas.PaintSurface += CanvasOnPaintSurface;
5348
AddView(_canvas);
@@ -316,7 +311,7 @@ private void WidgetTouched(IWidget widget, Point screenPosition)
316311
/// <returns>The device pixels given as input translated to device pixels.</returns>
317312
private float ToDeviceIndependentUnits(float pixelCoordinate)
318313
{
319-
return pixelCoordinate / _pixelDensity;
314+
return pixelCoordinate / PixelDensity;
320315
}
321316

322317
public new void Dispose()

Mapsui.UI.iOS/MapControl.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@ public partial class MapControl : UIView, IMapControl
1818
{
1919
private readonly SKGLView _canvas = new SKGLView();
2020
private double _innerRotation;
21-
/// <summary>
22-
/// The number of pixels per device independent unit
23-
/// </summary>
24-
private float _pixelDensity;
25-
21+
2622
public MapControl(CGRect frame)
2723
: base(frame)
2824
{
@@ -52,9 +48,6 @@ public void Initialize()
5248
NSLayoutConstraint.Create(this, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, _canvas, NSLayoutAttribute.Bottom, 1.0f, 0.0f)
5349
});
5450

55-
// Unfortunately the SKGLView does not have a IgnorePixelScaling property. We have to adjust for density with SKGLView.Scale.
56-
_pixelDensity = PixelDensity;
57-
5851
TryInitializeViewport(ScreenWidth, ScreenHeight);
5952

6053
ClipsToBounds = true;
@@ -102,8 +95,11 @@ void OnPaintSurface(object sender, SKPaintGLSurfaceEventArgs args)
10295
TryInitializeViewport(ScreenWidth, ScreenHeight);
10396
if (!_map.Viewport.Initialized) return;
10497

105-
args.Surface.Canvas.Scale(_pixelDensity, _pixelDensity); // we can only set the scale in the render loop
98+
// Unfortunately the SKGLView does not have a IgnorePixelScaling property,
99+
// so have to adjust for density with SKGLView.Scale.
100+
// The Scale can only be set in the render loop
106101

102+
args.Surface.Canvas.Scale(PixelDensity, PixelDensity);
107103
Renderer.Render(args.Surface.Canvas, _map.Viewport, _map.Layers, _map.Widgets, _map.BackColor);
108104
}
109105

0 commit comments

Comments
 (0)