[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 06/12] ui/cocoa: Scale with NSView instead of Core Graphics
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 06/12] ui/cocoa: Scale with NSView instead of Core Graphics |
Date: |
Tue, 5 Mar 2024 12:06:01 +0100 |
From: Akihiko Odaki <akihiko.odaki@daynix.com>
Core Graphics is not accelerated and slow.
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Tested-by: Rene Engel <ReneEngel80@emailn.de>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-ID: <20240224-cocoa-v12-4-e89f70bdda71@daynix.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
ui/cocoa.m | 24 ++++++++++--------------
1 file changed, 10 insertions(+), 14 deletions(-)
diff --git a/ui/cocoa.m b/ui/cocoa.m
index e156527082..6e8cd24e88 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -504,10 +504,8 @@ - (void) drawRect:(NSRect) rect
[self getRectsBeingDrawn:&rectList count:&rectCount];
for (i = 0; i < rectCount; i++) {
- clipRect.origin.x = rectList[i].origin.x / cdx;
- clipRect.origin.y = (float)h - (rectList[i].origin.y +
rectList[i].size.height) / cdy;
- clipRect.size.width = rectList[i].size.width / cdx;
- clipRect.size.height = rectList[i].size.height / cdy;
+ clipRect = rectList[i];
+ clipRect.origin.y = (float)h - (clipRect.origin.y +
clipRect.size.height);
clipImageRef = CGImageCreateWithImageInRect(
imageRef,
clipRect
@@ -553,6 +551,11 @@ - (void) setContentDimensions
}
}
+- (void) updateBounds
+{
+ [self setBoundsSize:NSMakeSize(screen.width, screen.height)];
+}
+
- (void) updateUIInfoLocked
{
/* Must be called with the BQL, i.e. via updateUIInfo */
@@ -642,6 +645,7 @@ - (void) switchSurface:(pixman_image_t *)image
screen.height = h;
[self setContentDimensions];
[self setFrame:NSMakeRect(cx, cy, cw, ch)];
+ [self updateBounds];
}
// update screenBuffer
@@ -1305,6 +1309,7 @@ - (void)windowDidChangeScreen:(NSNotification
*)notification
- (void)windowDidResize:(NSNotification *)notification
{
+ [cocoaView updateBounds];
[cocoaView updateUIInfo];
}
@@ -1967,16 +1972,7 @@ static void cocoa_update(DisplayChangeListener *dcl,
COCOA_DEBUG("qemu_cocoa: cocoa_update\n");
dispatch_async(dispatch_get_main_queue(), ^{
- NSRect rect;
- if ([cocoaView cdx] == 1.0) {
- rect = NSMakeRect(x, [cocoaView gscreen].height - y - h, w, h);
- } else {
- rect = NSMakeRect(
- x * [cocoaView cdx],
- ([cocoaView gscreen].height - y - h) * [cocoaView cdy],
- w * [cocoaView cdx],
- h * [cocoaView cdy]);
- }
+ NSRect rect = NSMakeRect(x, [cocoaView gscreen].height - y - h, w, h);
[cocoaView setNeedsDisplayInRect:rect];
});
}
--
2.41.0
- [PULL 00/12] Cocoa patches for 2024-03-05, Philippe Mathieu-Daudé, 2024/03/05
- [PULL 02/12] ui/cocoa: Fix window clipping on macOS 14, Philippe Mathieu-Daudé, 2024/03/05
- [PULL 03/12] ui/cocoa: Split [-QemuCocoaView handleEventLocked:], Philippe Mathieu-Daudé, 2024/03/05
- [PULL 06/12] ui/cocoa: Scale with NSView instead of Core Graphics,
Philippe Mathieu-Daudé <=
- [PULL 04/12] ui/cocoa: Immediately call [-QemuCocoaView handleMouseEvent:buttons:], Philippe Mathieu-Daudé, 2024/03/05
- [PULL 01/12] ui/cocoa: add zoom-interpolation display option, Philippe Mathieu-Daudé, 2024/03/05
- [PULL 07/12] ui/cocoa: Fix pause label coordinates, Philippe Mathieu-Daudé, 2024/03/05
- [PULL 05/12] ui/cocoa: Release specific mouse buttons, Philippe Mathieu-Daudé, 2024/03/05
- [PULL 08/12] ui/cocoa: Let the platform toggle fullscreen, Philippe Mathieu-Daudé, 2024/03/05
- [PULL 09/12] ui/cocoa: Remove normalWindow, Philippe Mathieu-Daudé, 2024/03/05
- [PULL 10/12] ui/cocoa: Make window resizable, Philippe Mathieu-Daudé, 2024/03/05
- [PULL 11/12] ui/cocoa: Call console_select() with the BQL, Philippe Mathieu-Daudé, 2024/03/05
- [PULL 12/12] ui/cocoa: Remove stretch_video flag, Philippe Mathieu-Daudé, 2024/03/05
- Re: [PULL 00/12] Cocoa patches for 2024-03-05, Peter Maydell, 2024/03/05