From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: patches@linaro.org, John Arbuckle <programmingkidx@gmail.com>,
Berkus Decker <berkus@gmail.com>,
Gerd Hoffmann <kraxel@redhat.com>,
Roman Bolshakov <r.bolshakov@yadro.com>
Subject: [Qemu-devel] [RFC 2/5] ui/cocoa: Use the pixman image directly in switchSurface
Date: Sat, 1 Dec 2018 12:30:53 +0000 [thread overview]
Message-ID: <20181201123056.432-3-peter.maydell@linaro.org> (raw)
In-Reply-To: <20181201123056.432-1-peter.maydell@linaro.org>
Currently the switchSurface method takes a DisplaySurface. We want
to change our DisplayChangeListener's dpy_gfx_switch callback
to do this work asynchronously on a different thread. The caller
of the switch callback will free the old DisplaySurface
immediately the callback returns, so to ensure that the
other thread doesn't access freed data we need to switch
to using the underlying pixman image instead. The pixman
image is reference counted, so we will be able to take
a reference to it to avoid it vanishing too early.
In this commit we only change the switchSurface method
to take a pixman image, and keep the flow of control
synchronous for now.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
ui/cocoa.m | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/ui/cocoa.m b/ui/cocoa.m
index 9148ecdeb4c..997b0199c6c 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -303,7 +303,7 @@ static void handleAnyDeviceErrors(Error * err)
BOOL isAbsoluteEnabled;
BOOL isMouseDeassociated;
}
-- (void) switchSurface:(DisplaySurface *)surface;
+- (void) switchSurface:(pixman_image_t *)image;
- (void) grabMouse;
- (void) ungrabMouse;
- (void) toggleFullScreen:(id)sender;
@@ -478,12 +478,13 @@ QemuCocoaView *cocoaView;
}
}
-- (void) switchSurface:(DisplaySurface *)surface
+- (void) switchSurface:(pixman_image_t *)image
{
COCOA_DEBUG("QemuCocoaView: switchSurface\n");
- int w = surface_width(surface);
- int h = surface_height(surface);
+ int w = pixman_image_get_width(image);
+ int h = pixman_image_get_height(image);
+ pixman_format_code_t image_format = pixman_image_get_format(image);
/* cdx == 0 means this is our very first surface, in which case we need
* to recalculate the content dimensions even if it happens to be the size
* of the initial empty window.
@@ -505,10 +506,10 @@ QemuCocoaView *cocoaView;
CGDataProviderRelease(dataProviderRef);
//sync host window color space with guests
- screen.bitsPerPixel = surface_bits_per_pixel(surface);
- screen.bitsPerComponent = surface_bytes_per_pixel(surface) * 2;
+ screen.bitsPerPixel = PIXMAN_FORMAT_BPP(image_format);
+ screen.bitsPerComponent = DIV_ROUND_UP(screen.bitsPerPixel, 8) * 2;
- dataProviderRef = CGDataProviderCreateWithData(NULL, surface_data(surface), w * 4 * h, NULL);
+ dataProviderRef = CGDataProviderCreateWithData(NULL, pixman_image_get_data(image), w * 4 * h, NULL);
// update windows
if (isFullscreen) {
@@ -1608,7 +1609,7 @@ static void cocoa_switch(DisplayChangeListener *dcl,
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
COCOA_DEBUG("qemu_cocoa: cocoa_switch\n");
- [cocoaView switchSurface:surface];
+ [cocoaView switchSurface:surface->image];
[pool release];
}
--
2.19.2
next prev parent reply other threads:[~2018-12-01 12:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-01 12:30 [Qemu-devel] [RFC 0/5] ui/cocoa: Use OSX's main loop Peter Maydell
2018-12-01 12:30 ` [Qemu-devel] [RFC 1/5] ui/cocoa: Ensure we have the iothread lock when calling into QEMU Peter Maydell
2018-12-01 12:30 ` Peter Maydell [this message]
2018-12-01 12:30 ` [Qemu-devel] [RFC 3/5] ui/cocoa: Factor out initial menu creation Peter Maydell
2018-12-01 12:30 ` [Qemu-devel] [RFC 4/5] ui/cocoa: Move console/device menu creation code up in file Peter Maydell
2018-12-01 12:30 ` [Qemu-devel] [RFC 5/5] ui/cocoa: Perform UI operations only on the main thread Peter Maydell
2018-12-03 15:47 ` [Qemu-devel] [RFC 0/5] ui/cocoa: Use OSX's main loop Richard Henderson
2018-12-05 6:51 ` Gerd Hoffmann
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=20181201123056.432-3-peter.maydell@linaro.org \
--to=peter.maydell@linaro.org \
--cc=berkus@gmail.com \
--cc=kraxel@redhat.com \
--cc=patches@linaro.org \
--cc=programmingkidx@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=r.bolshakov@yadro.com \
/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).