From patchwork Mon Feb 25 10:24:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 1047654 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="pRGpeWJz"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 447J4h54WQz9ryj for ; Mon, 25 Feb 2019 21:25:56 +1100 (AEDT) Received: from localhost ([127.0.0.1]:34740 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gyDSM-0006LD-Hh for incoming@patchwork.ozlabs.org; Mon, 25 Feb 2019 05:25:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33072) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gyDRV-0006JD-25 for qemu-devel@nongnu.org; Mon, 25 Feb 2019 05:25:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gyDRB-0002yk-ID for qemu-devel@nongnu.org; Mon, 25 Feb 2019 05:24:52 -0500 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:34085) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gyDRB-0002xK-70 for qemu-devel@nongnu.org; Mon, 25 Feb 2019 05:24:41 -0500 Received: by mail-wm1-x344.google.com with SMTP id o10so2590278wmc.1 for ; Mon, 25 Feb 2019 02:24:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bmDgQhAr7tyLraO8i1ouLXjQaT6+r93opd/eZp7ELdo=; b=pRGpeWJz5vrS4mnjdmlsnOSZZ6wB2kwACIQBn4lYKCRgpxn8yhruTrIf9WoDkneG+r Z8zw/0PCM3Lj9PYPXIU3q4dhK4dZwlv3QCS2UKftACza0xSpe9smXSDeZGMZClqtGDpS uhCGm5NzOgr1XlDJ9GiTWMGChBgXGMFkFdpKBDQQ1+NunvUQRsh0cUv5Ynf8UxjuPb4G ekGAq7lB42WSrdhE3H0OPgsYwbr2njzwBZRuCePg/YaLqepTLBoNNWgTuslqHOQ1BEHV IGNdVRZfPcSvjOWNWeDv0sFestBTlwV1yoSX7Qv6xKYkX/pSlXhxXfCYGYn+mqhQIje9 MzWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bmDgQhAr7tyLraO8i1ouLXjQaT6+r93opd/eZp7ELdo=; b=KtshmHDt0Jm7GAjBkJlAYBw8ZYUq1e93hYxzwfT76VZrmyF3syZF2F1lIU2pDUweZM vTIXwoUbYP16IB3pcVIIy6We0qs6Zwsyr1iQOC78aQqeHMMDmnLpZ4PqoR3+8CD7jBO8 q8dUQibx4umycJtttUILISmkCcfXPygKuBdTUnxqrfQd5LWJpNLL1rESBZn+X03XeNr+ M1iSNXzMZ/gSSdFdvRcD52FA2gSMZqPWOBlyMLpVaYrgfTUbbm8faSWsQBAzU1OW3404 DfdW8mm9paiMNzyggqNuppycslxD1KKKkZjApQg478PU4/GoPIyYWF68yC6IcT/J6+iV PPiw== X-Gm-Message-State: AHQUAub56aqYrJKUdxKa2wzSe0FANUXQe4nHZI3p1/EZaBFEOiefTLhk JLbb/HUOgml/rMGwcf1XhNdy71p7QBU= X-Google-Smtp-Source: AHgI3IZvbedHkfi40MWvk/xzKy6OhIYUce/G5Rwh8rdnR7RgOg3sdd4TniiutJqitQPKlRWN144lSQ== X-Received: by 2002:a1c:9692:: with SMTP id y140mr10469724wmd.67.1551090279517; Mon, 25 Feb 2019 02:24:39 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v10sm1764692wrn.26.2019.02.25.02.24.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Feb 2019 02:24:38 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 25 Feb 2019 10:24:28 +0000 Message-Id: <20190225102433.22401-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190225102433.22401-1-peter.maydell@linaro.org> References: <20190225102433.22401-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::344 Subject: [Qemu-devel] [PATCH v3 2/7] ui/cocoa: Use the pixman image directly in switchSurface X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roman Bolshakov , patches@linaro.org, John Arbuckle , Gerd Hoffmann , Ben Hekster , Berkus Decker Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 Reviewed-by: BALATON Zoltan Reviewed-by: Roman Bolshakov Tested-by: Roman Bolshakov Message-id: 20190214102816.3393-3-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 f1171c4865..a913a51a2d 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -315,7 +315,7 @@ @interface QemuCocoaView : NSView BOOL isAbsoluteEnabled; BOOL isMouseDeassociated; } -- (void) switchSurface:(DisplaySurface *)surface; +- (void) switchSurface:(pixman_image_t *)image; - (void) grabMouse; - (void) ungrabMouse; - (void) toggleFullScreen:(id)sender; @@ -495,12 +495,13 @@ - (void) setContentDimensions } } -- (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. @@ -522,10 +523,10 @@ - (void) switchSurface:(DisplaySurface *)surface 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) { @@ -1629,7 +1630,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]; }