From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ben Simms Newsgroups: gmane.emacs.bugs Subject: bug#73384: [PATCH] Draw coloured stipples on NS Date: Mon, 14 Oct 2024 19:35:51 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000d7279f0624741bad" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17643"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Rudolf =?UTF-8?Q?Adamkovi=C4=8D?= , Arash Esbati , Stefan Kangas To: 73384@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Oct 15 02:08:05 2024 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 1t0V6a-0004Pr-A9 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 15 Oct 2024 02:08:04 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0V6J-0005U8-M3; Mon, 14 Oct 2024 20:07:48 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t0V6H-0005Tk-0D for bug-gnu-emacs@gnu.org; Mon, 14 Oct 2024 20:07:45 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t0V6G-0002uA-NB for bug-gnu-emacs@gnu.org; Mon, 14 Oct 2024 20:07:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=Date:From:In-Reply-To:References:MIME-Version:To:Subject; bh=K5poi6Er9Mi5WiJt24EzFtmcC1tudsNgiGIZgC72zIw=; b=eDGBiUbNUiJ2fFEMxOhgBqf8Q7GcLOeNYuo7s84g1S+J9iOyhPF63ehuM89SMX4svNm65LAlkUnxN5CIgFI8W0bvbq0nco5W1h2ijxR4wtbQ3TGix+/2tKERhRdI5rL14KmLd2C/0ztktgHSzU069obEzhX+FD5XsoHBtpSOe4i8CjCwDj6uWR5j+smRSblQNi+ggNsQ4UmejzE8XnAetmEN8dvB3MdDbPzaDs4sXDKTnKY3q6TU1nZg7Q9cmyr1e96lHdki0JKV0/JkeAMTwYh56iiF4i5IE8v077qbF6vksTtqOIPMFJ6WDggHEp/ryysbLWRdklA+zGx34Nmshg==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t0V6Y-0001BL-1q for bug-gnu-emacs@gnu.org; Mon, 14 Oct 2024 20:08:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ben Simms Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 15 Oct 2024 00:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73384 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 73384-submit@debbugs.gnu.org id=B73384.17289508324438 (code B ref 73384); Tue, 15 Oct 2024 00:08:02 +0000 Original-Received: (at 73384) by debbugs.gnu.org; 15 Oct 2024 00:07:12 +0000 Original-Received: from localhost ([127.0.0.1]:47464 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t0V5i-00019V-Ng for submit@debbugs.gnu.org; Mon, 14 Oct 2024 20:07:11 -0400 Original-Received: from mail-qt1-f170.google.com ([209.85.160.170]:56411) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t0Pwb-0007ca-Vj for 73384@debbugs.gnu.org; Mon, 14 Oct 2024 14:37:27 -0400 Original-Received: by mail-qt1-f170.google.com with SMTP id d75a77b69052e-4603b835a1cso46556061cf.0 for <73384@debbugs.gnu.org>; Mon, 14 Oct 2024 11:37:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728930962; x=1729535762; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=K5poi6Er9Mi5WiJt24EzFtmcC1tudsNgiGIZgC72zIw=; b=JkobzzQkAACEuM6d4DfjCaDHCj/14KlmSLGnC7x/2KtFIf5roaGtFxXIoemE4VxeCq ncPFSSmdx1XuoG6p7yMN5MLVb/ZOOhH3wVUlv31RATdYDAWXJ8mM2+7CO/06o9qntS1a QYM/Q5KXVYEMUqfhg3khdDz26/FgDHHRPo/mbjhjFn0/xApL6VBAv5eJYAi1CSpkq5GW iomJtYO0lZoZeutm2lfg88rBFsQelSfwB3Dkj+brbDx5DhZu9z3go2qIygtijuvayqTf msa095AcfWcqJKQCIRQ58fiAF7vyks5BoGgFa0yXS7OeBpUf4yxBo39TW89v5JyEvNra NlOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728930962; x=1729535762; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=K5poi6Er9Mi5WiJt24EzFtmcC1tudsNgiGIZgC72zIw=; b=vUuIASM1aatTvqjiLvUV9a8ZSqy6c3Wgqw3eCOZr+5hPX40++CRIZCWNQ46RSr7GbY AfWg/G183Fi4Ut6TOmU12ME0x4XYWj56yQa6WmP4cqxEfutrtuXV9Av5IarjSXkhn+qb 0UgSRpn9IfPdk2XB8wYwdJ+6/1ln1cYvLF0TQSiHJqkuzei88PhO93ok1wbkQatBicJu UUDqlLuuaxFq5M5ORfOk25OO3pndzuKqi0AEiZrmiSRrzqZQntF5skkG4F5KArntcz1S A4Wf2EQGWeGTW009sQuNIJ7KzadocUTckPYnq3rYLR6cPA3xcd9K9z4RfV6eGg7TCVOd WqAQ== X-Gm-Message-State: AOJu0YzKM6r3FM0I2HSHv1qbpjFQbJB3FdXx3VbbNloxt2ZcZjxi5jG4 qKeLUuE+RgOpgR2tqldMnhd8Sf00A9/ZmqMVKJPrKnOAzCo8W5IE8iXo2+OF71lOKQtQNtSIcr1 yZn8aUjVEB9JX1ZKvH0arr4n2Iy6b6XavN3g= X-Google-Smtp-Source: AGHT+IGktSkEzi8STZKgENL6OIOEh5RBnU2ap8fKJymvRdJchAzUIo1Ra3k+ZyxzKnEK7RuDtinrex4X4HvjC29xsfA= X-Received: by 2002:a05:622a:22a7:b0:458:4d54:2c35 with SMTP id d75a77b69052e-4604bc2e5c3mr230683971cf.46.1728930962152; Mon, 14 Oct 2024 11:36:02 -0700 (PDT) In-Reply-To: X-Mailman-Approved-At: Mon, 14 Oct 2024 20:07:10 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:293598 Archived-At: --000000000000d7279f0624741bad Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hey all, I've gone ahead and put my changes behind NS_IMPL_COCA ifdefs: >From fb1ceddc6385bcefc3fb31f2c96652448298df77 Mon Sep 17 00:00:00 2001 From: Ben Simms Date: Mon, 14 Oct 2024 19:32:53 +0100 Subject: [PATCH] Use masked coregraphics images on cocoa NS --- src/nsimage.m | 31 +++++++++++++++++++++++++++++++ src/nsterm.h | 8 ++++++++ src/nsterm.m | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 84 insertions(+), 2 deletions(-) diff --git a/src/nsimage.m b/src/nsimage.m index ee72d6e0ea1..e36cbe5dc87 100644 --- a/src/nsimage.m +++ b/src/nsimage.m @@ -35,6 +35,9 @@ Updated by Christian Limpach (chris@nice.ch) #include "frame.h" #include "coding.h" +#ifdef NS_IMPL_COCOA +#include +#endif #if defined (NS_IMPL_GNUSTEP) || MAC_OS_X_VERSION_MAX_ALLOWED < 1070 # define COLORSPACE_NAME NSCalibratedRGBColorSpace @@ -289,7 +292,11 @@ + (instancetype)allocInitFromFile: (Lisp_Object)file - (void)dealloc { +#ifdef NS_IMPL_COCOA + CGImageRelease(stippleMask); +#else [stippleMask release]; +#endif [bmRep release]; [transform release]; [super dealloc]; @@ -300,7 +307,11 @@ - (id)copyWithZone:(NSZone *)zone { EmacsImage *copy =3D [super copyWithZone:zone]; +#ifdef NS_IMPL_COCOA + copy->stippleMask =3D CGImageCreateCopy(stippleMask); +#else copy->stippleMask =3D [stippleMask copyWithZone:zone]; +#endif /* NS_IMPL_COCOA */ copy->bmRep =3D [bmRep copyWithZone:zone]; copy->transform =3D [transform copyWithZone:zone]; @@ -509,6 +520,25 @@ - (void) setAlphaAtX: (int) x Y: (int) y to: (unsigned char) a } } +#ifdef NS_IMPL_COCOA +/* Returns a cached CGImageMask of the stipple pattern */ +- (CGImageRef)stippleMask +{ + if (stippleMask =3D=3D nil) { + CGDataProviderRef provider =3D CGDataProviderCreateWithData (NULL, [bmRep bitmapData], + [self sizeInBytes], NULL); + CGImageRef mask =3D CGImageMaskCreate( + [self size].width, + [self size].height, + 8, 8, [self size].width, + provider, NULL, 0); + + CGDataProviderRelease(provider); + stippleMask =3D CGImageRetain(mask); + } + return stippleMask; +} +#else /* Returns a pattern color, which is cached here. */ - (NSColor *)stippleMask { @@ -516,6 +546,7 @@ - (NSColor *)stippleMask stippleMask =3D [[NSColor colorWithPatternImage: self] retain]; return stippleMask; } +#endif /* NS_IMPL_COCOA */ /* Find the first NSBitmapImageRep which has multiple frames. */ - (NSBitmapImageRep *)getAnimatedBitmapImageRep diff --git a/src/nsterm.h b/src/nsterm.h index 6c67653705e..2370f6ea3fb 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -671,7 +671,11 @@ #define NSTRACE_UNSILENCE() { NSBitmapImageRep *bmRep; /* used for accessing pixel data */ unsigned char *pixmapData[5]; /* shortcut to access pixel data */ +#ifdef NS_IMPL_COCOA + CGImageRef stippleMask; +#else NSColor *stippleMask; +#endif // NS_IMPL_COCOA @public NSAffineTransform *transform; BOOL smoothing; @@ -688,7 +692,11 @@ #define NSTRACE_UNSILENCE() green: (unsigned char)g blue: (unsigned char)b alpha:(unsigned char)a; - (void)setAlphaAtX: (int)x Y: (int)y to: (unsigned char)a; +#ifdef NS_IMPL_COCOA +- (CGImageRef)stippleMask; +#else - (NSColor *)stippleMask; +#endif // NS_IMPL_COCOA - (Lisp_Object)getMetadata; - (BOOL)setFrame: (unsigned int) index; - (void)setTransform: (double[3][3]) m; diff --git a/src/nsterm.m b/src/nsterm.m index f68a22d9fbc..a617669cb4d 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -3823,8 +3823,31 @@ Function modeled after x_draw_glyph_string_box (). if (s->stippled_p) { struct ns_display_info *dpyinfo =3D FRAME_DISPLAY_INFO (s->f); +#ifdef NS_IMPL_COCOA + [[NSColor colorWithUnsignedLong:face->background] set]; + r =3D NSMakeRect (s->x, s->y + box_line_width, + s->background_width, + s->height - 2 * box_line_width); + NSRectFill (r); + s->background_filled_p =3D 1; + CGImageRef mask =3D [dpyinfo->bitmaps[face->stipple - 1].img stippleMask]; + CGRect bounds =3D CGRectMake (s->x, s->y + box_line_width, + s->background_width, + s->height - 2 * box_line_width); + NSGraphicsContext *ctx =3D [NSGraphicsContext currentContext]; + [ctx saveGraphicsState]; + CGContextRef context =3D [ctx CGContext]; + CGContextClipToRect (context, bounds); + CGContextScaleCTM (context, 1, -1); + [[NSColor colorWithUnsignedLong:face->foreground] set]; + CGRect imageSize =3D CGRectMake (0, 0, CGImageGetWidth (mask), CGImageGetHeight (mask)); + CGContextDrawTiledImage (context, imageSize, mask); + [[NSGraphicsContext currentContext] restoreGraphicsState]; +#else [[dpyinfo->bitmaps[face->stipple-1].img stippleMask] set]; goto fill; +#endif /* NS_IMPL_COCOA */ + } else if (FONT_HEIGHT (s->font) < s->height - 2 * box_line_width /* When xdisp.c ignores FONT_HEIGHT, we cannot trust font @@ -3847,7 +3870,9 @@ Function modeled after x_draw_glyph_string_box (). else [FRAME_CURSOR_COLOR (s->f) set]; +#ifndef NS_IMPL_COCOA fill: +#endif /* !NS_IMPL_COCOA */ r =3D NSMakeRect (s->x, s->y + box_line_width, s->background_width, s->height - 2 * box_line_width); @@ -4171,8 +4196,26 @@ Function modeled after x_draw_glyph_string_box (). dpyinfo =3D FRAME_DISPLAY_INFO (s->f); if (s->hl =3D=3D DRAW_CURSOR) [FRAME_CURSOR_COLOR (s->f) set]; - else if (s->stippled_p) - [[dpyinfo->bitmaps[s->face->stipple - 1].img stippleMask] set]; + else if (s->stippled_p) { +#ifdef NS_IMPL_COCOA + [[NSColor colorWithUnsignedLong:s->face->background] set]; + NSRectFill (NSMakeRect (x, s->y, background_width, s->height)); + CGImageRef mask =3D [dpyinfo->bitmaps[s->face->stipple - 1].img stippleMask]; + CGRect bounds =3D CGRectMake (s->x, s->y, s->background_width, s->height); + NSGraphicsContext *ctx =3D [NSGraphicsContext currentContext]; + [ctx saveGraphicsState]; + CGContextRef context =3D [ctx CGContext]; + CGContextClipToRect(context, bounds); + CGContextScaleCTM (context, 1, -1); + [[NSColor colorWithUnsignedLong:s->face->foreground] set]; + CGRect imageSize =3D CGRectMake (0, 0, CGImageGetWidth (mask), + CGImageGetHeight (mask)); + CGContextDrawTiledImage (context, imageSize, mask); + [[NSGraphicsContext currentContext] restoreGraphicsState]; +#else + [[dpyinfo->bitmaps[s->face->stipple - 1].img stippleMask] set]; +#endif /* NS_IMPL_COCOA */ + } else [[NSColor colorWithUnsignedLong: s->face->background] set]; --=20 2.46.0 On Mon, 14 Oct 2024 at 02:29, Rudolf Adamkovi=C4=8D = wrote: > Arash Esbati writes: > > > Here is how it currently looks: > > > > https://lists.gnu.org/archive/html/bug-gnu-emacs/2024-09/msg00304.htm= l > > OMG, this explains my recent troubles with Indent Bars on macOS. > > +1 for merging! > > Rudy > -- > "The whole science is nothing more than a refinement of everyday > thinking." --- Albert Einstein, 1879-1955 > > Rudolf Adamkovi=C4=8D [he/him] > http://adamkovic.org > --000000000000d7279f0624741bad Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hey all, I've gone ahead and put my changes behind NS_= IMPL_COCA ifdefs:

From fb1ceddc6385bcefc3fb31f2c96652448= 298df77 Mon Sep 17 00:00:00 2001
From: Ben Simms <ben@bensimms.moe>= ;
Date: Mon, 14 Oct 2024 19:32:53 +0100
Subject: [PATCH] Use masked c= oregraphics images on cocoa NS

---
=C2=A0src/nsimage.m | 31 +++++= ++++++++++++++++++++++++++
=C2=A0src/nsterm.h =C2=A0| =C2=A08 ++++++++=C2=A0src/nsterm.m =C2=A0| 47 +++++++++++++++++++++++++++++++++++++++++++= ++--
=C2=A03 files changed, 84 insertions(+), 2 deletions(-)

diff= --git a/src/nsimage.m b/src/nsimage.m
index ee72d6e0ea1..e36cbe5dc87 10= 0644
--- a/src/nsimage.m
+++ b/src/nsimage.m
@@ -35,6 +35,9 @@ Upd= ated by Christian Limpach (chris@nice.ch)
=C2=A0#include "frame.h"
=C2=A0#include "coding.h&= quot;
=C2=A0
+#ifdef NS_IMPL_COCOA
+#include <CoreGraphics/Core= Graphics.h>
+#endif
=C2=A0
=C2=A0#if defined (NS_IMPL_GNUSTEP) = || MAC_OS_X_VERSION_MAX_ALLOWED < 1070
=C2=A0# define COLORSPACE_NAME= NSCalibratedRGBColorSpace
@@ -289,7 +292,11 @@ + (instancetype)allocIni= tFromFile: (Lisp_Object)file
=C2=A0
=C2=A0- (void)dealloc
=C2=A0{<= br>+#ifdef NS_IMPL_COCOA
+ =C2=A0CGImageRelease(stippleMask);
+#else<= br>=C2=A0 =C2=A0[stippleMask release];
+#endif
=C2=A0 =C2=A0[bmRep re= lease];
=C2=A0 =C2=A0[transform release];
=C2=A0 =C2=A0[super dealloc= ];
@@ -300,7 +307,11 @@ - (id)copyWithZone:(NSZone *)zone
=C2=A0{
= =C2=A0 =C2=A0EmacsImage *copy =3D [super copyWithZone:zone];
=C2=A0
+= #ifdef NS_IMPL_COCOA
+ =C2=A0copy->stippleMask =3D CGImageCreateCopy(= stippleMask);
+#else
=C2=A0 =C2=A0copy->stippleMask =3D [stippleMa= sk copyWithZone:zone];
+#endif /* NS_IMPL_COCOA */
=C2=A0 =C2=A0copy-= >bmRep =3D [bmRep copyWithZone:zone];
=C2=A0 =C2=A0copy->transform= =3D [transform copyWithZone:zone];
=C2=A0
@@ -509,6 +520,25 @@ - (vo= id) setAlphaAtX: (int) x Y: (int) y to: (unsigned char) a
=C2=A0 =C2=A0 = =C2=A0}
=C2=A0}
=C2=A0
+#ifdef NS_IMPL_COCOA
+/* Returns a cach= ed CGImageMask of the stipple pattern */
+- (CGImageRef)stippleMask
+= {
+ =C2=A0if (stippleMask =3D=3D nil) {
+ =C2=A0 =C2=A0CGDataProvider= Ref provider =3D CGDataProviderCreateWithData (NULL, [bmRep bitmapData],+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 [self si= zeInBytes], NULL);
+ =C2=A0 =C2=A0CGImageRef mask =3D CGImageMaskCreate(=
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0[self= size].width,
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0[self size].height,
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A08, 8, [self size].width,
+ =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0provider, NULL, 0);
++ =C2=A0 =C2=A0CGDataProviderRelease(provider);
+ =C2=A0 =C2=A0stippleM= ask =3D CGImageRetain(mask);
+ =C2=A0}
+ =C2=A0return stippleMask;+}
+#else
=C2=A0/* Returns a pattern color, which is cached here. = =C2=A0*/
=C2=A0- (NSColor *)stippleMask
=C2=A0{
@@ -516,6 +546,7 @= @ - (NSColor *)stippleMask
=C2=A0 =C2=A0 =C2=A0 =C2=A0stippleMask =3D [[= NSColor colorWithPatternImage: self] retain];
=C2=A0 =C2=A0return stippl= eMask;
=C2=A0}
+#endif /* NS_IMPL_COCOA */
=C2=A0
=C2=A0/* Find= the first NSBitmapImageRep which has multiple frames. =C2=A0*/
=C2=A0- = (NSBitmapImageRep *)getAnimatedBitmapImageRep
diff --git a/src/nsterm.h = b/src/nsterm.h
index 6c67653705e..2370f6ea3fb 100644
--- a/src/nsterm= .h
+++ b/src/nsterm.h
@@ -671,7 +671,11 @@ #define NSTRACE_UNSILENCE(= )
=C2=A0{
=C2=A0 =C2=A0NSBitmapImageRep *bmRep; /* used for accessing= pixel data */
=C2=A0 =C2=A0unsigned char *pixmapData[5]; /* shortcut to= access pixel data */
+#ifdef NS_IMPL_COCOA
+ =C2=A0CGImageRef stippl= eMask;
+#else
=C2=A0 =C2=A0NSColor *stippleMask;
+#endif // NS_IMP= L_COCOA
=C2=A0@public
=C2=A0 =C2=A0NSAffineTransform *transform;
= =C2=A0 =C2=A0BOOL smoothing;
@@ -688,7 +692,11 @@ #define NSTRACE_UNSILE= NCE()
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 green: (un= signed char)g blue: (unsigned char)b
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0alpha:(unsigned char)a;
=C2=A0- (void)setAlphaAtX: (= int)x Y: (int)y to: (unsigned char)a;
+#ifdef NS_IMPL_COCOA
+- (CGIma= geRef)stippleMask;
+#else
=C2=A0- (NSColor *)stippleMask;
+#endif = // NS_IMPL_COCOA
=C2=A0- (Lisp_Object)getMetadata;
=C2=A0- (BOOL)setF= rame: (unsigned int) index;
=C2=A0- (void)setTransform: (double[3][3]) m= ;
diff --git a/src/nsterm.m b/src/nsterm.m
index f68a22d9fbc..a617669= cb4d 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -3823,8 +3823= ,31 @@ Function modeled after x_draw_glyph_string_box ().
=C2=A0 =C2=A0 = =C2=A0 =C2=A0if (s->stippled_p)
=C2=A0 {
=C2=A0 =C2=A0struct ns_d= isplay_info *dpyinfo =3D FRAME_DISPLAY_INFO (s->f);
+#ifdef NS_IMPL_C= OCOA
+ =C2=A0 =C2=A0[[NSColor colorWithUnsignedLong:face->background]= set];
+ =C2=A0 =C2=A0r =3D NSMakeRect (s->x, s->y + box_line_widt= h,
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0s->background_width,
+ =C2=A0 =C2= =A0 =C2=A0 =C2=A0s->height - 2 * box_line_width);
+ =C2=A0 =C2=A0NSRe= ctFill (r);
+ =C2=A0 =C2=A0s->background_filled_p =3D 1;
+ =C2=A0 = =C2=A0CGImageRef mask =3D [dpyinfo->bitmaps[face->stipple - 1].img st= ippleMask];
+ =C2=A0 =C2=A0CGRect bounds =3D CGRectMake (s->x, s->= y + box_line_width,
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0s->background_width,=
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0s->height - 2 * box_line_width);
+ = =C2=A0 =C2=A0NSGraphicsContext *ctx =3D [NSGraphicsContext currentContext];=
+ =C2=A0 =C2=A0[ctx saveGraphicsState];
+ =C2=A0 =C2=A0CGContextRef = context =3D [ctx CGContext];
+ =C2=A0 =C2=A0CGContextClipToRect (context= , bounds);
+ =C2=A0 =C2=A0CGContextScaleCTM (context, 1, -1);
+ =C2= =A0 =C2=A0[[NSColor colorWithUnsignedLong:face->foreground] set];
+ = =C2=A0 =C2=A0CGRect imageSize =3D CGRectMake (0, 0, CGImageGetWidth (mask),= CGImageGetHeight (mask));
+ =C2=A0 =C2=A0CGContextDrawTiledImage (conte= xt, imageSize, mask);
+ =C2=A0 =C2=A0[[NSGraphicsContext currentContext]= restoreGraphicsState];
+#else
=C2=A0 =C2=A0[[dpyinfo->bitmaps[fa= ce->stipple-1].img stippleMask] set];
=C2=A0 =C2=A0goto fill;
+#e= ndif /* NS_IMPL_COCOA */
+
=C2=A0 }
=C2=A0 =C2=A0 =C2=A0 =C2=A0els= e if (FONT_HEIGHT (s->font) < s->height - 2 * box_line_width
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 /* When xdisp.c ignores FONT_HEIGHT, we cannot= trust font
@@ -3847,7 +3870,9 @@ Function modeled after x_draw_glyph_st= ring_box ().
=C2=A0 =C2=A0else
=C2=A0 =C2=A0 =C2=A0[FRAME_CURSOR_CO= LOR (s->f) set];
=C2=A0
+#ifndef NS_IMPL_COCOA
=C2=A0 fill:
= +#endif /* !NS_IMPL_COCOA */
=C2=A0 =C2=A0r =3D NSMakeRect (s->x, s-= >y + box_line_width,
=C2=A0 =C2=A0s->background_width,
=C2= =A0 =C2=A0s->height - 2 * box_line_width);
@@ -4171,8 +4196,26 @@ = Function modeled after x_draw_glyph_string_box ().
=C2=A0 =C2=A0dpyinfo= =3D FRAME_DISPLAY_INFO (s->f);
=C2=A0 =C2=A0if (s->hl =3D=3D DRA= W_CURSOR)
=C2=A0 =C2=A0 =C2=A0[FRAME_CURSOR_COLOR (s->f) set];
- = =C2=A0else if (s->stippled_p)
- =C2=A0 =C2=A0[[dpyinfo->bitmaps[= s->face->stipple - 1].img stippleMask] set];
+ =C2=A0else if (s-&= gt;stippled_p) {
+#ifdef NS_IMPL_COCOA
+ =C2=A0 =C2=A0 =C2=A0[[NSColo= r colorWithUnsignedLong:s->face->background] set];
+ =C2=A0 =C2=A0= =C2=A0NSRectFill (NSMakeRect (x, s->y, background_width, s->height))= ;
+ =C2=A0 =C2=A0 =C2=A0CGImageRef mask =3D [dpyinfo->bitmaps[s->f= ace->stipple - 1].img stippleMask];
+ =C2=A0 =C2=A0 =C2=A0CGRect boun= ds =3D CGRectMake (s->x, s->y, s->background_width, s->height);=
+ =C2=A0 =C2=A0 =C2=A0NSGraphicsContext *ctx =3D [NSGraphicsContext cur= rentContext];
+ =C2=A0 =C2=A0 =C2=A0[ctx saveGraphicsState];
+ =C2=A0= =C2=A0 =C2=A0CGContextRef context =3D [ctx CGContext];
+ =C2=A0 =C2=A0 = =C2=A0CGContextClipToRect(context, bounds);
+ =C2=A0 =C2=A0 =C2=A0CGCont= extScaleCTM (context, 1, -1);
+ =C2=A0 =C2=A0 =C2=A0[[NSColor colorWithU= nsignedLong:s->face->foreground] set];
+ =C2=A0 =C2=A0 =C2=A0CGRec= t imageSize =3D CGRectMake (0, 0, CGImageGetWidth (mask),
+ =C2=A0 =C2= =A0 =C2=A0CGImageGetHeight (mask));
+ =C2=A0 =C2=A0 =C2=A0CGContextDrawT= iledImage (context, imageSize, mask);
+ =C2=A0 =C2=A0 =C2=A0[[NSGraphics= Context currentContext] restoreGraphicsState];
+#else
+ =C2=A0 =C2= =A0 =C2=A0[[dpyinfo->bitmaps[s->face->stipple - 1].img stippleMask= ] set];
+#endif /* NS_IMPL_COCOA */
+ =C2=A0 =C2=A0}
=C2=A0 =C2= =A0else
=C2=A0 =C2=A0 =C2=A0[[NSColor colorWithUnsignedLong: s->face= ->background] set];
=C2=A0
--
2.46.0


Arash Esbati <arash@gnu.org> writes:

> Here is how it currently looks:
>
>=C2=A0 =C2=A0https://lists= .gnu.org/archive/html/bug-gnu-emacs/2024-09/msg00304.html

OMG, this explains my recent troubles with Indent Bars on macOS.

+1 for merging!

Rudy
--
"The whole science is nothing more than a refinement of everyday
thinking."=C2=A0 --- Albert Einstein, 1879-1955

Rudolf Adamkovi=C4=8D <rudolf@adamkovic.org> [he/him]
http:= //adamkovic.org
--000000000000d7279f0624741bad--