--- gui-cocoa/screen.m +++ gui-cocoa/screen.m @@ -22,6 +22,8 @@ #endif #define LOG(fmt, ...) if(DEBUG)NSLog((@"%s:%d %s " fmt), __FILE__, __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__) +#define SCALE 2.0 + Memimage *gscreen; @interface DrawLayer : CAMetalLayer @@ -73,8 +75,8 @@ { memimageinit(); NSSize s = [myview convertSizeToBacking:myview.frame.size]; - screensize(Rect(0, 0, s.width, s.height), ARGB32); - gscreen->clipr = Rect(0, 0, s.width, s.height); + screensize(Rect(0, 0, s.width / SCALE, s.height / SCALE), ARGB32); + gscreen->clipr = Rect(0, 0, s.width / SCALE, s.height / SCALE); LOG(@"%g %g", s.width, s.height); terminit(); readybit = 1; @@ -105,6 +107,9 @@ CGFloat scale = myview.window.backingScaleFactor; [layer setDrawableSize:NSMakeSize(Dx(r), Dy(r))]; [layer setContentsScale:scale]; + [layer setShouldRasterize:YES]; + [layer setRasterizationScale:scale]; + [layer setMagnificationFilter:kCAFilterNearest]; } gscreen = i; gscreen->clipr = ZR; @@ -283,7 +288,7 @@ NSPoint s; if([[myview window] isKeyWindow]){ - s = NSMakePoint(p.x, p.y); + s = NSMakePoint(p.x * SCALE, p.y * SCALE); LOG(@"-> pixel %g %g", s.x, s.y); s = [[myview window] convertPointFromBacking:s]; LOG(@"-> point %g %g", s.x, s.y); @@ -378,7 +383,7 @@ { NSPoint p; p = [_window convertPointToBacking:[_window mouseLocationOutsideOfEventStream]]; - absmousetrack(p.x, [myview convertSizeToBacking:myview.frame.size].height - p.y, 0, ticks()); + absmousetrack(p.x / SCALE, ([myview convertSizeToBacking:myview.frame.size].height - p.y) / SCALE, 0, ticks()); } - (void) windowDidResignKey:(id)arg @@ -597,8 +602,8 @@ p = [self.window convertPointToBacking:[self.window mouseLocationOutsideOfEventStream]]; u = [NSEvent pressedMouseButtons]; - q.x = p.x; - q.y = p.y; + q.x = p.x / SCALE; + q.y = p.y / SCALE; if(!ptinrect(q, gscreen->clipr)) return; u = (u&~6) | (u&4)>>1 | (u&2)<<1; if(u == 1){ @@ -609,7 +614,7 @@ }else if(m & NSEventModifierFlagCommand) u = 4; } - absmousetrack(p.x, [self convertSizeToBacking:self.frame.size].height - p.y, u, ticks()); + absmousetrack(p.x / SCALE, ([self convertSizeToBacking:self.frame.size].height - p.y) / SCALE, u, ticks()); if(u && _lastInputRect.size.width && _lastInputRect.size.height) [self resetLastInputRect]; } @@ -700,7 +705,7 @@ NSSize s = [self convertSizeToBacking:self.frame.size]; LOG(@"%g %g", s.width, s.height); if(gscreen != nil){ - screenresize(Rect(0, 0, s.width, s.height)); + screenresize(Rect(0, 0, s.width / SCALE, s.height / SCALE)); } }