diff options
Diffstat (limited to 'cocoa')
-rw-r--r-- | cocoa/PlatCocoa.h | 1 | ||||
-rw-r--r-- | cocoa/PlatCocoa.mm | 17 |
2 files changed, 18 insertions, 0 deletions
diff --git a/cocoa/PlatCocoa.h b/cocoa/PlatCocoa.h index 18d339536..870b61aa3 100644 --- a/cocoa/PlatCocoa.h +++ b/cocoa/PlatCocoa.h @@ -88,6 +88,7 @@ public: void CopyImageRectangle(Surface &surfaceSource, PRectangle srcRect, PRectangle dstRect); int LogPixelsY() override; + int PixelDivisions() override; int DeviceHeightFont(int points) override; void MoveTo(int x_, int y_) override; void LineTo(int x_, int y_) override; diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm index 33c24397f..b662c25e6 100644 --- a/cocoa/PlatCocoa.mm +++ b/cocoa/PlatCocoa.mm @@ -321,6 +321,7 @@ void GetPositions(CTLineRef line, std::vector<CGFloat> &positions) { const int SupportsCocoa[] = { SC_SUPPORTS_LINE_DRAWS_FINAL, + SC_SUPPORTS_PIXEL_DIVISIONS, }; } @@ -556,6 +557,22 @@ int SurfaceImpl::LogPixelsY() { //-------------------------------------------------------------------------------------------------- /** + * Returns the number of device pixels per logical pixel. + * 1 for older displays and 2 for retina displays. Potentially 3 for some phones. + */ +int SurfaceImpl::PixelDivisions() { + if (gc) { + const CGSize szDevice = CGContextConvertSizeToDeviceSpace(gc, CGSizeMake(1.0, 1.0)); + const int devicePixels = std::round(szDevice.width); + assert(devicePixels == 1 || devicePixels == 2); + return devicePixels; + } + return 1; +} + +//-------------------------------------------------------------------------------------------------- + +/** * Converts the logical font height in points into a device height. * For Cocoa, points are always used for the result even on retina displays. */ |