From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Third Newsgroups: gmane.emacs.bugs Subject: bug#32932: 27.0.50; render bugs on macOS Mojave Date: Mon, 29 Oct 2018 16:09:43 +0000 Message-ID: <20181029160943.GA60662@breton.holly.idiocy.org> References: <7BCD942D-621D-4C91-AA8E-6C38908C03EE@d12frosted.io> <20181019184828.GA2041@breton.holly.idiocy.org> <20181020200444.GA2501@breton.holly.idiocy.org> <20181024104242.GA40431@breton.holly.idiocy.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="zYM0uCDKw75PZbzx" Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1540829378 12969 195.159.176.226 (29 Oct 2018 16:09:38 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 29 Oct 2018 16:09:38 +0000 (UTC) User-Agent: Mutt/1.10.1 (2018-07-13) Cc: Boris Buliga , 32932@debbugs.gnu.org To: Aaron Jensen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Oct 29 17:09:34 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gHA6e-0003Fp-5f for geb-bug-gnu-emacs@m.gmane.org; Mon, 29 Oct 2018 17:09:32 +0100 Original-Received: from localhost ([::1]:46548 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHA8k-00080m-Hx for geb-bug-gnu-emacs@m.gmane.org; Mon, 29 Oct 2018 12:11:42 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53167) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHA7E-0006om-DG for bug-gnu-emacs@gnu.org; Mon, 29 Oct 2018 12:10:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHA7B-0000fg-6b for bug-gnu-emacs@gnu.org; Mon, 29 Oct 2018 12:10:08 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:47804) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gHA79-0000cT-5Q for bug-gnu-emacs@gnu.org; Mon, 29 Oct 2018 12:10:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gHA78-0001W8-PJ for bug-gnu-emacs@gnu.org; Mon, 29 Oct 2018 12:10:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Third Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 29 Oct 2018 16:10:02 +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: Original-Received: via spool by 32932-submit@debbugs.gnu.org id=B32932.15408293985817 (code B ref 32932); Mon, 29 Oct 2018 16:10:02 +0000 Original-Received: (at 32932) by debbugs.gnu.org; 29 Oct 2018 16:09:58 +0000 Original-Received: from localhost ([127.0.0.1]:52062 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gHA73-0001Vl-O6 for submit@debbugs.gnu.org; Mon, 29 Oct 2018 12:09:58 -0400 Original-Received: from mail-wr1-f52.google.com ([209.85.221.52]:38623) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gHA6z-0001VT-FN for 32932@debbugs.gnu.org; Mon, 29 Oct 2018 12:09:54 -0400 Original-Received: by mail-wr1-f52.google.com with SMTP id d10-v6so9331280wrs.5 for <32932@debbugs.gnu.org>; Mon, 29 Oct 2018 09:09:53 -0700 (PDT) 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 :user-agent; bh=Q0ueUBUbAcYNWyBz9LFzisVUazB6KffvYaKtl9HTblQ=; b=Be/xMvhTCmwgH12bIh7m08GUiDS6huRzYAOYx/0X4lD9clV+PzrwICx1knDpcrhHOu VGh2hOsZK3IRKihzZB9oRa4n31YMsHxRa1bWS/zIGttSAL5I+SM44fDnBsx5kgD9mlIw JhZITh4xflpWOztVPIJi+2mM/pCoq+uXwRL+QP/m4JEMOqVRZJtD35NqBNnaNEH8K1YD XI88+gBlMu8nReBoatfIamAugSTizMoCDHfMmUxZhE0euDbsWG3eMNYU24/J23lOoSlO D7ay2BW+bF/TyTNfojqgaG1txfxKh/a72C6sAFEQpClgvdESqdJOyrIImebmxr3fA0+P jeXw== 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:user-agent; bh=Q0ueUBUbAcYNWyBz9LFzisVUazB6KffvYaKtl9HTblQ=; b=FLH/Von5cAomlDw5rooHUOD8yL8tFf5h7f28bwdq0K/ySZ40gmA3cTrxq4d+fyXKMA w2P2AfnTOL2Kx3BeqDDySZBBN9+ENxlsZtGLrWMxUScruv/lxIOMlL6YnFXqtnfgt/43 iYQ8rVamF5QOtdNuMV6YYh/wTDydj3WyyzG5w8Rq3Sxv/ds8Y2o/A50V3psFshJV273o rVn/JXRfqOV/+rQzejxqBTRlg16ItF1/NksuDDNeq7xXvp/MPHxraAwmlqRXsL5zpdsS CBSUWk+mb4UfBYF9bsDKFow3hz/85JrRp7OMU4gN773gdbpS+VLLMB3kweN0kZz+uWlY p5VA== X-Gm-Message-State: AGRZ1gJ2hH0Zd/zf0m6C3x/LAfCzlo/vlBEBmRsyYyGlnDZ0COgekLfH ZkcGA+S5uokQ1fbcaobJj0M= X-Google-Smtp-Source: AJdET5cThMd7NzXub3COIqxoN+yWUoPF8JxzmjMDIOtbnxTij76N8ip7BB93UJykxrFaWUATuXt52Q== X-Received: by 2002:a5d:434c:: with SMTP id u12-v6mr14408991wrr.306.1540829387527; Mon, 29 Oct 2018 09:09:47 -0700 (PDT) Original-Received: from breton.holly.idiocy.org (ip6-2001-08b0-03f8-8129-a9a7-73e3-89ce-d96b.holly.idiocy.org. [2001:8b0:3f8:8129:a9a7:73e3:89ce:d96b]) by smtp.gmail.com with ESMTPSA id q77-v6sm12279121wmd.33.2018.10.29.09.09.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Oct 2018 09:09:46 -0700 (PDT) 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: 208.118.235.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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:151778 Archived-At: --zYM0uCDKw75PZbzx Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Sun, Oct 28, 2018 at 07:18:04PM -0700, Aaron Jensen wrote: > On October 24, 2018 at 3:42:47 AM, Alan Third > (alan@idiocy.org(mailto:alan@idiocy.org)) wrote: > > > I’ve pushed a slight variant of this change to emacs-26. I’ve > > witnessed a very rare flicker of the modeline and the line containing > > the cursor in other windows while scrolling, but I can’t replicate it > > consistently. > > I am definitely seeing the flicker on the current line. It happens > occasionally when my emacs is idle (probably not truly idle). I see it > sometimes when I tell emacs to do something that is a thread blocking > operation (like loading some autoloaded lisp for the first time). It’s > as if it clears the current line and then immediately blocks the > rendering thread before it gets a chance to rerender the line. As soon > as Emacs is done doing whatever it was doing, the line rerenders. > > No clue if that helps, but if there’s anything you want to try, I’ll > be able to let you know if it fixes it :) One more go. I don’t think I’ve seen the cursor line flicker after installing this. Simply, all I’ve done is stop making it redraw the entire line the cursor is on. That should stop any flicker of the line text caused by redrawing the cursor, but won’t stop any flicker of the cursor itself, although I’ve not seen it flicker. There’s a bit more in here to do with drawing the fringe bitmaps, because that was the only other place ns_clip_to_row was being used, so I’ve removed it from there too. -- Alan Third --zYM0uCDKw75PZbzx Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-Fix-more-drawing-bugs-in-NS-port-bug-32932.patch" >From 95160c34b4f41e867761f29239db02e8e7232bbe Mon Sep 17 00:00:00 2001 From: Alan Third Date: Mon, 29 Oct 2018 15:37:35 +0000 Subject: [PATCH] Fix more drawing bugs in NS port (bug#32932) * src/nsterm.m (ns_row_rect): New function. (ns_clip_to_row): Remove function. (ns_copy_bits): Fix mistake. (ns_draw_fringe_bitmap): Stop using ns_clip_to_row. (ns_draw_window_cursor): Stop using ns_clip_to_row and move ns_reset_clipping to try and force cursor drawing to be atomic. --- src/nsterm.m | 105 +++++++++++++++++++++++++++++---------------------- 1 file changed, 59 insertions(+), 46 deletions(-) diff --git a/src/nsterm.m b/src/nsterm.m index 4b5d025ee3..39a7b25f60 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -796,6 +796,27 @@ Free a pool and temporary objects it refers to (callable from C) } +static NSRect +ns_row_rect (struct window *w, struct glyph_row *row, + enum glyph_row_area area) +/* Get the row as an NSRect. */ +{ + struct frame *f = XFRAME (WINDOW_FRAME (w)); + NSRect rect; + int window_x, window_y, window_width; + + window_box (w, area, &window_x, &window_y, &window_width, 0); + + rect.origin.x = window_x; + rect.origin.y = WINDOW_TO_FRAME_PIXEL_Y (w, max (0, row->y)); + rect.origin.y = max (rect.origin.y, window_y); + rect.size.width = window_width; + rect.size.height = row->visible_height; + + return rect; +} + + /* ========================================================================== Focus (clipping) and screen update @@ -1206,28 +1227,6 @@ static NSRect constrain_frame_rect(NSRect frameRect, bool isFullscreen) } -static BOOL -ns_clip_to_row (struct window *w, struct glyph_row *row, - enum glyph_row_area area, BOOL gc) -/* -------------------------------------------------------------------------- - Internal (but parallels other terms): Focus drawing on given row - -------------------------------------------------------------------------- */ -{ - struct frame *f = XFRAME (WINDOW_FRAME (w)); - NSRect clip_rect; - int window_x, window_y, window_width; - - window_box (w, area, &window_x, &window_y, &window_width, 0); - - clip_rect.origin.x = window_x; - clip_rect.origin.y = WINDOW_TO_FRAME_PIXEL_Y (w, max (0, row->y)); - clip_rect.origin.y = max (clip_rect.origin.y, window_y); - clip_rect.size.width = window_width; - clip_rect.size.height = row->visible_height; - - return ns_clip_to_rect (f, &clip_rect, 1); -} - /* ========================================================================== Visible bell and beep. @@ -2692,7 +2691,7 @@ so some key presses (TAB) are swallowed by the system. */ ns_copy_bits (struct frame *f, NSRect src, NSRect dest) { NSSize delta = NSMakeSize (dest.origin.x - src.origin.x, - dest.origin.y - src.origin.y) + dest.origin.y - src.origin.y); NSTRACE ("ns_copy_bits"); if (FRAME_NS_VIEW (f)) @@ -2911,6 +2910,9 @@ so some key presses (TAB) are swallowed by the system. */ struct face *face = p->face; static EmacsImage **bimgs = NULL; static int nBimgs = 0; + NSRect clearRect = NSZeroRect; + NSRect imageRect = NSZeroRect; + NSRect rowRect = ns_row_rect (w, row, ANY_AREA); NSTRACE_WHEN (NSTRACE_GROUP_FRINGE, "ns_draw_fringe_bitmap"); NSTRACE_MSG ("which:%d cursor:%d overlay:%d width:%d height:%d period:%d", @@ -2925,25 +2927,40 @@ so some key presses (TAB) are swallowed by the system. */ nBimgs = max_used_fringe_bitmap; } - /* Must clip because of partially visible lines. */ - if (ns_clip_to_row (w, row, ANY_AREA, YES)) + /* Work out the rectangle we will composite into. */ + if (p->which) + imageRect = NSMakeRect (p->x, p->y, p->wd, p->h); + + /* Work out the rectangle we will need to clear. Because we're + compositing rather than blitting, we need to clear the area under + the image regardless of anything else. */ + if (!p->overlay_p) + { + clearRect = NSMakeRect (p->bx, p->by, p->nx, p->ny); + clearRect = NSUnionRect (clearRect, imageRect); + } + else { - if (!p->overlay_p) + clearRect = imageRect; + } + + /* Handle partially visible rows. */ + clearRect = NSIntersectionRect (clearRect, rowRect); + + /* The visible portion of imageRect will always be contained within + clearRect. */ + if (ns_clip_to_rect (f, &clearRect, 1)) + { + if (! NSIsEmptyRect (clearRect)) { - int bx = p->bx, by = p->by, nx = p->nx, ny = p->ny; + NSTRACE_RECT ("clearRect", clearRect); - if (bx >= 0 && nx > 0) - { - NSRect r = NSMakeRect (bx, by, nx, ny); - NSRectClip (r); - [ns_lookup_indexed_color (face->background, f) set]; - NSRectFill (r); - } + [ns_lookup_indexed_color(face->background, f) set]; + NSRectFill (clearRect); } if (p->which) { - NSRect r = NSMakeRect (p->x, p->y, p->wd, p->h); EmacsImage *img = bimgs[p->which - 1]; if (!img) @@ -2964,13 +2981,6 @@ so some key presses (TAB) are swallowed by the system. */ xfree (cbits); } - NSTRACE_RECT ("r", r); - - NSRectClip (r); - /* Since we composite the bitmap instead of just blitting it, we need - to erase the whole background. */ - [ns_lookup_indexed_color(face->background, f) set]; - NSRectFill (r); { NSColor *bm_color; @@ -2990,7 +3000,7 @@ so some key presses (TAB) are swallowed by the system. */ NSTRACE_RECT ("fromRect", fromRect); - [img drawInRect: r + [img drawInRect: imageRect fromRect: fromRect operation: NSCompositingOperationSourceOver fraction: 1.0 @@ -2998,7 +3008,7 @@ so some key presses (TAB) are swallowed by the system. */ hints: nil]; #else { - NSPoint pt = r.origin; + NSPoint pt = imageRect.origin; pt.y += p->h; [img compositeToPoint: pt operation: NSCompositingOperationSourceOver]; } @@ -3088,7 +3098,9 @@ Note that CURSOR_WIDTH is meaningful only for (h)bar cursors. r.size.width = w->phys_cursor_width; /* Prevent the cursor from being drawn outside the text area. */ - if (ns_clip_to_row (w, glyph_row, TEXT_AREA, NO)) + r = NSIntersectionRect (r, ns_row_rect (w, glyph_row, TEXT_AREA)); + + if (ns_clip_to_rect (f, &r, 1)) { face = FACE_FROM_ID_OR_NULL (f, phys_cursor_glyph->face_id); if (face && NS_FACE_BACKGROUND (face) @@ -3128,11 +3140,12 @@ Note that CURSOR_WIDTH is meaningful only for (h)bar cursors. NSRectFill (s); break; } - ns_reset_clipping (f); /* draw the character under the cursor */ if (cursor_type != NO_CURSOR) draw_phys_cursor_glyph (w, glyph_row, DRAW_CURSOR); + + ns_reset_clipping (f); } } -- 2.18.0 --zYM0uCDKw75PZbzx--