From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Alan Third Newsgroups: gmane.emacs.bugs Subject: bug#32932: 27.0.50; render bugs on macOS Mojave Date: Sat, 1 Feb 2020 21:20:34 +0000 Message-ID: <20200201212034.GA30983@breton.holly.idiocy.org> References: <20200129200414.GA60190@breton.holly.idiocy.org> <20200130191154.GA62970@breton.holly.idiocy.org> <20200131202335.GA63701@breton.holly.idiocy.org> <20200201142242.GA25666@breton.holly.idiocy.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="k1lZvvs/B4yU6o8G" Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="119341"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Robert Pluim , 32932@debbugs.gnu.org To: Aaron Jensen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Feb 01 22:21:14 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iy0CX-000UrD-8O for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 01 Feb 2020 22:21:13 +0100 Original-Received: from localhost ([::1]:50800 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iy0CW-0007Rq-AD for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 01 Feb 2020 16:21:12 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55498) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iy0CP-0007Rk-3H for bug-gnu-emacs@gnu.org; Sat, 01 Feb 2020 16:21:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iy0CN-0001o0-KN for bug-gnu-emacs@gnu.org; Sat, 01 Feb 2020 16:21:05 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33414) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iy0CL-0001l8-Rc for bug-gnu-emacs@gnu.org; Sat, 01 Feb 2020 16:21:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iy0CL-0000bi-Na for bug-gnu-emacs@gnu.org; Sat, 01 Feb 2020 16:21:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Third Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 01 Feb 2020 21:21:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 32932 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed Original-Received: via spool by 32932-submit@debbugs.gnu.org id=B32932.15805920472290 (code B ref 32932); Sat, 01 Feb 2020 21:21:01 +0000 Original-Received: (at 32932) by debbugs.gnu.org; 1 Feb 2020 21:20:47 +0000 Original-Received: from localhost ([127.0.0.1]:39387 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iy0C6-0000ar-6V for submit@debbugs.gnu.org; Sat, 01 Feb 2020 16:20:47 -0500 Original-Received: from mail-wm1-f43.google.com ([209.85.128.43]:55230) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iy0C3-0000ae-Rj for 32932@debbugs.gnu.org; Sat, 01 Feb 2020 16:20:44 -0500 Original-Received: by mail-wm1-f43.google.com with SMTP id g1so11739630wmh.4 for <32932@debbugs.gnu.org>; Sat, 01 Feb 2020 13:20:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=m2PU74E6awGN2eIz7AXh/44BHlwRYYQbTkhxCx0qvKQ=; b=TOAKKdQLQZhadmuvXKZtpWOgP9VBLnk90fm6pH/OCSCraTswKQL4sz+AbraD5J0eiO vBmMJO5USGrx5vh93ZSuCU9nTp2cJ1s6w5AhxMCrm+oWBRaxj8qQplTuEk2lg5S/hU1z 7aLNDOgTZV8uMkiwtCxi4/C+8lfYMr+UFjSUyz5XBCSLK5l5MWfl4UtZz+JLSsqyfbsU Z/nWpzI9C/38evbwUCL+fY/ZOg1/2Tk3S4ij84OVuFf5jawnxRSQL0D5QBfC/1BfyBAC IkR4q5OwsNNCMSqkSJVxTM8HmjKHfkyP0pNpBNhbL5IaUASjEyk8+NEMdH60qojrvBCN WvSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to; bh=m2PU74E6awGN2eIz7AXh/44BHlwRYYQbTkhxCx0qvKQ=; b=ojihf7KmwkBF8lLP0xG1SWLfSFiP5qLJThPTlwM1Da7meGV88Vftl4Zwm7qJ2OajHt aM5C+/bJHWyJ8ITF/9ozTljKLIGtu8EO4vBTgoiZZXYzo5M26/+vY0Id/cW4DaXZi6RI q8eYDWI8nSDLSIPv9mnZdzFc5PQS7FHgMg0efyG9COL46gdzo8OKgdfbst5oDhCKAyMn PMw1OqGBtoGBx47VJ9M5HmFnxMl6TkJSUfzW9AKMxpTVdXQjKodtO3bHGZuWk+P/OQmK JfZJay1lh4pQMz0MJAsI2LC0Vd4iNXoKYZMWBIgiJz9bECnPJIJZBb6l3s16Rbte509e hXYg== X-Gm-Message-State: APjAAAWoJKohY4M26LZ/6yiAL8mRVUI5yWBsS/YwiPQBIm3FxsE82+MG Iy5kTh0OovQdJ6eptitXu3w= X-Google-Smtp-Source: APXvYqzyLjj9udYVCdh10idnLRmceL+HR8jSJemNR175gKzpogZPx7MdOSkU1F9tmYyZdR4B0vRrsw== X-Received: by 2002:a05:600c:2c50:: with SMTP id r16mr19236560wmg.74.1580592037906; Sat, 01 Feb 2020 13:20:37 -0800 (PST) Original-Received: from breton.holly.idiocy.org (ip6-2001-08b0-03f8-8129-a08b-b269-65be-dd6a.holly.idiocy.org. [2001:8b0:3f8:8129:a08b:b269:65be:dd6a]) by smtp.gmail.com with ESMTPSA id j12sm17500002wrt.55.2020.02.01.13.20.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Feb 2020 13:20:36 -0800 (PST) Content-Disposition: inline In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:175571 Archived-At: --k1lZvvs/B4yU6o8G Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Sat, Feb 01, 2020 at 08:29:10AM -0800, Aaron Jensen wrote: > On Sat, Feb 1, 2020 at 6:22 AM Alan Third wrote: > > > > I’m now stumped because I can’t actually find any image type in the > > documentation that isn’t immutable. I’m sure there must be something. > > The Mac port appears to be using IOSurfaces, but as far as I can tell > > they can be changed underneath you so aren’t much use for just > > updating little bits of the Emacs frame at a time. I must be > > misunderstanding something. > > I know nothing, but have you looked into > https://developer.apple.com/library/archive/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_layers/dq_layers.html > ? Can you try the attached patch? It looks like it’s faster here, but I can’t really tell. -- Alan Third --k1lZvvs/B4yU6o8G Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-Use-CGLayer-instead-of-NSBitmapImageRep-bug-32932.patch" >From ad2feeba4284ce7ef7518781c26bd2a98389372a Mon Sep 17 00:00:00 2001 From: Alan Third Date: Sat, 1 Feb 2020 21:17:29 +0000 Subject: [PATCH] Use CGLayer instead of NSBitmapImageRep (bug#32932) --- src/nsterm.h | 2 +- src/nsterm.m | 67 ++++++++++++++++++++++------------------------------ 2 files changed, 29 insertions(+), 40 deletions(-) diff --git a/src/nsterm.h b/src/nsterm.h index 980ca534cf..fbcd29be12 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -418,7 +418,7 @@ #define NSTRACE_UNSILENCE() NSWindow *nonfs_window; BOOL fs_is_native; #ifdef NS_IMPL_COCOA - NSBitmapImageRep *drawingBuffer; + CGLayerRef drawingBuffer; #endif @public struct frame *emacsframe; diff --git a/src/nsterm.m b/src/nsterm.m index 9d427b9b38..94662a24fe 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -1141,7 +1141,6 @@ static NSRect constrain_frame_rect(NSRect frameRect, bool isFullscreen) #ifdef NS_IMPL_COCOA [NSGraphicsContext setCurrentContext:nil]; - [view display]; #else block_input (); @@ -2853,7 +2852,9 @@ so some key presses (TAB) are swallowed by the system. */ ns_unfocus (f); /* as of 2006/11 or so this is now needed */ - ns_redraw_scroll_bars (f); + /* FIXME: I don't see any reason for this and removing it makes no + difference here. Do we need it for GNUstep? */ + //ns_redraw_scroll_bars (f); unblock_input (); } @@ -3169,18 +3170,6 @@ so some key presses (TAB) are swallowed by the system. */ NSTRACE_RECT ("fromRect", fromRect); - /* Because we're drawing into an offscreen buffer which isn't - flipped, the images come out upside down. To work around it - we need to do some fancy transforms. */ - { - NSAffineTransform *transform = [NSAffineTransform transform]; - [transform translateXBy:0 yBy:NSMaxY(imageRect)]; - [transform scaleXBy:1 yBy:-1]; - [transform concat]; - - imageRect.origin.y = 0; - } - [img drawInRect: imageRect fromRect: fromRect operation: NSCompositingOperationSourceOver @@ -3938,11 +3927,6 @@ Function modeled after x_draw_glyph_string_box (). NSAffineTransform *doTransform = [NSAffineTransform transform]; - /* We have to flip the image around the X axis as the offscreen - bitmap we're drawing to is flipped. */ - [doTransform scaleXBy:1 yBy:-1]; - [doTransform translateXBy:0 yBy:-[img size].height]; - /* ImageMagick images don't have transforms. */ if (img->transform) [doTransform appendTransform:img->transform]; @@ -4838,7 +4822,7 @@ in certain situations (rapid incoming events). if (NILP (window->vertical_scroll_bar)) { if (width > 0 && height > 0) - ns_clear_frame_area (f, left, top, width, height); + ns_clear_frame_area (f, left, top, width, height); bar = [[EmacsScroller alloc] initFrame: r window: win]; wset_vertical_scroll_bar (window, make_mint_ptr (bar)); @@ -8239,10 +8223,15 @@ - (void)createDrawingBufferWithRect:(NSRect)rect retain the old method of drawing direct to the EmacsView. */ { #ifdef NS_IMPL_COCOA + NSGraphicsContext *screen; + if (drawingBuffer != nil) - [drawingBuffer release]; + CGLayerRelease (drawingBuffer); - drawingBuffer = [[self bitmapImageRepForCachingDisplayInRect:rect] retain]; + screen = [NSGraphicsContext graphicsContextWithBitmapImageRep: + [self bitmapImageRepForCachingDisplayInRect:rect]]; + + drawingBuffer = CGLayerCreateWithContext ([screen CGContext], rect.size, nil); #endif } @@ -8250,11 +8239,12 @@ - (void)createDrawingBufferWithRect:(NSRect)rect #ifdef NS_IMPL_COCOA - (void)focusOnDrawingBuffer { - /* Creating the graphics context each time is very slow, but it - doesn't seem possible to cache and reuse it. */ - [NSGraphicsContext - setCurrentContext: - [NSGraphicsContext graphicsContextWithBitmapImageRep:drawingBuffer]]; + NSGraphicsContext *buf = + [NSGraphicsContext + graphicsContextWithCGContext:CGLayerGetContext (drawingBuffer) + flipped:YES]; + + [NSGraphicsContext setCurrentContext:buf]; } @@ -8284,13 +8274,16 @@ - (void)copyRect:(NSRect)srcRect to:(NSRect)dstRect NSTRACE_RECT ("Destination", dstRect); #ifdef NS_IMPL_COCOA - [drawingBuffer drawInRect:dstRect - fromRect:srcRect - operation:NSCompositingOperationCopy - fraction:1.0 - respectFlipped:NO - hints:nil]; + CGPoint offset = CGPointMake (NSMinX (dstRect) - NSMinX (srcRect), + NSMinY (dstRect) - NSMinY (srcRect)); + [[NSGraphicsContext currentContext] saveGraphicsState]; + NSRectClip (dstRect); + + CGContextDrawLayerAtPoint ([[NSGraphicsContext currentContext] CGContext], + offset, drawingBuffer); + + [[NSGraphicsContext currentContext] restoreGraphicsState]; [self setNeedsDisplayInRect:dstRect]; #else hide_bell(); // Ensure the bell image isn't scrolled. @@ -8313,12 +8306,8 @@ - (void)drawRect: (NSRect)rect return; #ifdef NS_IMPL_COCOA - [drawingBuffer drawInRect:rect - fromRect:rect - operation:NSCompositingOperationSourceOver - fraction:1 - respectFlipped:NO - hints:nil]; + CGContextRef ctx = [[NSGraphicsContext currentContext] CGContext]; + CGContextDrawLayerAtPoint (ctx, CGPointZero, drawingBuffer); #else int x = NSMinX (rect), y = NSMinY (rect); int width = NSWidth (rect), height = NSHeight (rect); -- 2.24.0 --k1lZvvs/B4yU6o8G--