diff options
author | David Robillard <d@drobilla.net> | 2020-04-08 13:41:35 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-04-08 13:41:35 +0200 |
commit | 29ba1095370abcdc341086b258bfe046f50100fc (patch) | |
tree | ecd130c3d3f5755cdd083c66e01c483238cd5404 /pugl/detail/mac_cairo.m | |
parent | 53d8fe0c19408a54165f6422319be8139758a5b2 (diff) | |
download | pugl-29ba1095370abcdc341086b258bfe046f50100fc.tar.gz pugl-29ba1095370abcdc341086b258bfe046f50100fc.tar.bz2 pugl-29ba1095370abcdc341086b258bfe046f50100fc.zip |
Mac: Use high-resolution backing surfaces
Diffstat (limited to 'pugl/detail/mac_cairo.m')
-rw-r--r-- | pugl/detail/mac_cairo.m | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/pugl/detail/mac_cairo.m b/pugl/detail/mac_cairo.m index 51c1c13..ccce14e 100644 --- a/pugl/detail/mac_cairo.m +++ b/pugl/detail/mac_cairo.m @@ -43,7 +43,9 @@ - (id) initWithFrame:(NSRect)frame { - return (self = [super initWithFrame:frame]); + self = [super initWithFrame:frame]; + + return self; } - (void) resizeWithOldSuperviewSize:(NSSize)oldSize @@ -69,7 +71,7 @@ puglMacCairoCreate(PuglView* view) PuglCairoView* drawView = [PuglCairoView alloc]; drawView->puglview = view; - [drawView initWithFrame:NSMakeRect(0, 0, view->frame.width, view->frame.height)]; + [drawView initWithFrame:[impl->wrapperView bounds]]; if (view->hints[PUGL_RESIZABLE]) { [drawView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; } else { @@ -103,10 +105,17 @@ puglMacCairoEnter(PuglView* view, const PuglEventExpose* expose) assert(!drawView->surface); assert(!drawView->cr); + const double scale = 1.0 / [[NSScreen mainScreen] backingScaleFactor]; CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort]; + const CGSize sizePx = {view->frame.width, view->frame.height}; + const CGSize sizePt = CGContextConvertSizeToUserSpace(context, sizePx); + + // Convert coordinates to standard Cairo space + CGContextTranslateCTM(context, 0.0, -sizePt.height); + CGContextScaleCTM(context, scale, -scale); drawView->surface = cairo_quartz_surface_create_for_cg_context( - context, view->frame.width, view->frame.height); + context, sizePx.width, sizePx.height); drawView->cr = cairo_create(drawView->surface); |