Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
Use appropriate scale properties for darwin platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
friedbunny committed Oct 18, 2017
1 parent f77a20d commit 23bd12e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions platform/darwin/src/MGLGeometry.mm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

#import <mbgl/util/projection.hpp>

#if !TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR
#import <Cocoa/Cocoa.h>
#endif

/** Vertical field of view, measured in degrees, for determining the altitude
of the viewpoint.
Expand Down Expand Up @@ -59,6 +63,10 @@ CLLocationDistance MGLAltitudeForZoomLevel(double zoomLevel, CGFloat pitch, CLLo
}

CGPoint MGLPointRounded(CGPoint point) {
CGFloat scale = [UIScreen mainScreen].scale;
return CGPointMake(round(point.x * scale) / scale, round(point.y * scale) / scale);
#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
CGFloat scaleFactor = [UIScreen instancesRespondToSelector:@selector(nativeScale)] ? [UIScreen mainScreen].nativeScale : [UIScreen mainScreen].scale;
#elif TARGET_OS_MAC
CGFloat scaleFactor = [NSScreen mainScreen].backingScaleFactor;
#endif
return CGPointMake(round(point.x * scaleFactor) / scaleFactor, round(point.y * scaleFactor) / scaleFactor);
}

0 comments on commit 23bd12e

Please sign in to comment.