diff options
Diffstat (limited to 'cocoa/PlatCocoa.mm')
-rw-r--r-- | cocoa/PlatCocoa.mm | 17 |
1 files changed, 17 insertions, 0 deletions
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. */ |