From: carwynellis@gmail.com
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, philmd@linaro.org,
akihiko.odaki@daynix.com, kraxel@redhat.com,
marcandre.lureau@redhat.com, Carwyn Ellis <carwynellis@gmail.com>
Subject: [PATCH 1/1] ui/cocoa: add zoom-interpolation display option
Date: Fri, 10 Nov 2023 16:17:29 +0000 [thread overview]
Message-ID: <20231110161729.36822-2-carwynellis@gmail.com> (raw)
In-Reply-To: <20231110161729.36822-1-carwynellis@gmail.com>
From: Carwyn Ellis <carwynellis@gmail.com>
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>
---
qapi/ui.json | 6 +++++-
ui/cocoa.m | 21 ++++++++++++++++++++-
2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/qapi/ui.json b/qapi/ui.json
index a0158baf23..e27e57f69c 100644
--- a/qapi/ui.json
+++ b/qapi/ui.json
@@ -1414,6 +1414,9 @@
# turned off the host window will be resized instead. Defaults to
# "off". (Since 8.2)
#
+# @zoom-interpolation: Apply interpolation to smooth output when
+# zoom-to-fit is enabled. Defaults to "off". (Since 8.2)
+#
# Since: 7.0
##
{ 'struct': 'DisplayCocoa',
@@ -1421,7 +1424,8 @@
'*left-command-key': 'bool',
'*full-grab': 'bool',
'*swap-opt-cmd': 'bool',
- '*zoom-to-fit': 'bool'
+ '*zoom-to-fit': 'bool',
+ '*zoom-interpolation': 'bool'
} }
##
diff --git a/ui/cocoa.m b/ui/cocoa.m
index cd069da696..35df8d6ce2 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -105,6 +105,7 @@ static void cocoa_switch(DisplayChangeListener *dcl,
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 @@ - (void) drawRect:(NSRect) rect
// 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 @@ - (void)zoomToFit:(id) sender
}
}
+- (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
--
2.42.1
next prev parent reply other threads:[~2023-11-10 16:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-10 16:17 [PATCH 0/1] ui/cocoa: add zoom-interpolation display option carwynellis
2023-11-10 16:17 ` carwynellis [this message]
2023-11-11 14:45 ` [PATCH 1/1] " Akihiko Odaki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231110161729.36822-2-carwynellis@gmail.com \
--to=carwynellis@gmail.com \
--cc=akihiko.odaki@daynix.com \
--cc=kraxel@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).