diff options
author | Carwyn Ellis <carwynellis@gmail.com> | 2023-11-10 16:17:29 +0000 |
---|---|---|
committer | Philippe Mathieu-Daudé <philmd@linaro.org> | 2024-03-05 12:04:41 +0100 |
commit | e28a909a191f00645d101511e5e9e132662aa290 (patch) | |
tree | db28cd33a9628fe58ca29c1278b7ecd4366af2f0 /ui/cocoa.m | |
parent | 52e7db443bd8d233acc3977bd150bdadb62db86c (diff) |
ui/cocoa: add zoom-interpolation display option
Provides a new display option, zoom-interpolation, that enables
interpolation of the scaled display when zoom-to-fit is enabled.
Also provides a corresponding view menu item to allow this to be toggled
as required.
Signed-off-by: Carwyn Ellis <carwynellis@gmail.com>
Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Message-ID: <20231110161729.36822-2-carwynellis@gmail.com>
[PMD: QAPI @zoom-interpolation since 9.0]
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Diffstat (limited to 'ui/cocoa.m')
-rw-r--r-- | ui/cocoa.m | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/ui/cocoa.m b/ui/cocoa.m index eb99064bee..b7ca0ed94b 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -105,6 +105,7 @@ static int left_command_key_enabled = 1; static bool swap_opt_cmd; static bool stretch_video; +static CGInterpolationQuality zoom_interpolation = kCGInterpolationNone; static NSTextField *pauseLabel; static bool allow_events; @@ -455,7 +456,7 @@ static CGEventRef handleTapEvent(CGEventTapProxy proxy, CGEventType type, CGEven // get CoreGraphic context CGContextRef viewContextRef = [[NSGraphicsContext currentContext] CGContext]; - CGContextSetInterpolationQuality (viewContextRef, kCGInterpolationNone); + CGContextSetInterpolationQuality (viewContextRef, zoom_interpolation); CGContextSetShouldAntialias (viewContextRef, NO); // draw screen bitmap directly to Core Graphics context @@ -1411,6 +1412,17 @@ static CGEventRef handleTapEvent(CGEventTapProxy proxy, CGEventType type, CGEven } } +- (void)toggleZoomInterpolation:(id) sender +{ + if (zoom_interpolation == kCGInterpolationNone) { + zoom_interpolation = kCGInterpolationLow; + [sender setState: NSControlStateValueOn]; + } else { + zoom_interpolation = kCGInterpolationNone; + [sender setState: NSControlStateValueOff]; + } +} + /* Displays the console on the screen */ - (void)displayConsole:(id)sender { @@ -1673,6 +1685,9 @@ static void create_initial_menus(void) menuItem = [[[NSMenuItem alloc] initWithTitle:@"Zoom To Fit" action:@selector(zoomToFit:) keyEquivalent:@""] autorelease]; [menuItem setState: stretch_video ? NSControlStateValueOn : NSControlStateValueOff]; [menu addItem: menuItem]; + menuItem = [[[NSMenuItem alloc] initWithTitle:@"Zoom Interpolation" action:@selector(toggleZoomInterpolation:) keyEquivalent:@""] autorelease]; + [menuItem setState: zoom_interpolation == kCGInterpolationLow ? NSControlStateValueOn : NSControlStateValueOff]; + [menu addItem: menuItem]; menuItem = [[[NSMenuItem alloc] initWithTitle:@"View" action:nil keyEquivalent:@""] autorelease]; [menuItem setSubmenu:menu]; [[NSApp mainMenu] addItem:menuItem]; @@ -2070,6 +2085,10 @@ static void cocoa_display_init(DisplayState *ds, DisplayOptions *opts) stretch_video = true; } + if (opts->u.cocoa.has_zoom_interpolation && opts->u.cocoa.zoom_interpolation) { + zoom_interpolation = kCGInterpolationLow; + } + create_initial_menus(); /* * Create the menu entries which depend on QEMU state (for consoles |