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: Sat, 19 Oct 2024 10:34:02 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000d261fe0624d04827" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14750"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Rudolf =?UTF-8?Q?Adamkovi=C4=8D?= , 73384@debbugs.gnu.org, Stefan Kangas To: Arash Esbati Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Oct 19 16:26:35 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 1t2APb-0003fS-3E for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 19 Oct 2024 16:26:35 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2AOm-0006Yo-4m; Sat, 19 Oct 2024 10:25:44 -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 1t2AOk-0006Xh-4t for bug-gnu-emacs@gnu.org; Sat, 19 Oct 2024 10:25:42 -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 1t2AOj-0004yJ-Sm for bug-gnu-emacs@gnu.org; Sat, 19 Oct 2024 10:25:41 -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=PhlMivrUHXJqza/05chQ15K1dlw1CW3XTeprwmBQI4g=; b=hfMLhaBDQ8lUIDnk/xsWyEgZVBfHiIupADbeBZ0pyFngg/YOkGLgFrnpxt3l4Kx4/CxKoNlfG6pbOZ+4WCTTptNcxRbXc7CF8pnTrbn5GHAoudhbUTbeSKZD5HktKS41lhc/AM3+9x0JHyJHyfXTZToScD06lg2O6mUaew9vaIjdn43E1X5JMSfZQAeoVCY+O+HwCKIIp69PNgiFhF9f4DhdEfDXGXSctVEslU5S8KYR8ki/S52eK/csmikSHolEeLTitCger8Q+xeVAcHqsv/UoEaQeDHhEfAA+yoOQIgtIc38lAxH9Uc9EXBkdJ5j25BSKIr2WPM7kmG8hx9E1bQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t2AP7-00033f-K8 for bug-gnu-emacs@gnu.org; Sat, 19 Oct 2024 10:26:05 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ben Simms Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 19 Oct 2024 14:26:05 +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.172934794411634 (code B ref 73384); Sat, 19 Oct 2024 14:26:05 +0000 Original-Received: (at 73384) by debbugs.gnu.org; 19 Oct 2024 14:25:44 +0000 Original-Received: from localhost ([127.0.0.1]:44217 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t2AOk-00031Y-Q8 for submit@debbugs.gnu.org; Sat, 19 Oct 2024 10:25:44 -0400 Original-Received: from mail-qt1-f182.google.com ([209.85.160.182]:60453) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t24w3-00030h-0e for 73384@debbugs.gnu.org; Sat, 19 Oct 2024 04:35:44 -0400 Original-Received: by mail-qt1-f182.google.com with SMTP id d75a77b69052e-460b2e4c50fso8220351cf.0 for <73384@debbugs.gnu.org>; Sat, 19 Oct 2024 01:35:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729326854; x=1729931654; 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=PhlMivrUHXJqza/05chQ15K1dlw1CW3XTeprwmBQI4g=; b=PL+nHfuVbGpUIAa4ZzufqGnaGZlZcFkMNHOyeqkmo/0GOIFknNSoJ62F3W5Ew8Ilqu vz+u1bHuGJwOalf9c6TGs5JXnIORHXhV2HHAI1ACv2/VFr1SlC6PmBuiv8Uo4rYVTNxK HSeQlX5gpAhD1KJ0RmrkLoPZ9MumIBPArYGwHsxH9RQTlJeF8WM0Hl1tHUe+GXxc2U1T EeDAJtv+ahZTnNKw0ao/x3xECLiy8//FfmNbaC7arZWVb1sC5jAXNb60QigahLjaa4c0 TVyHIWup88hT+vEH1eclEDBytTgoZAxmqcbj1ZFa/mF/o57uYg4/T7r2rNc+0jX8PfF/ 0N2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729326854; x=1729931654; 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=PhlMivrUHXJqza/05chQ15K1dlw1CW3XTeprwmBQI4g=; b=mLhHq1JcYz8tnvEQwNJ2bRNeD/ByHnqw29tJHK3s1xJG2L+7VriGVnHgJKCDQqZfuO 7ytYN/HsWoVc7mxCop0jmo/R0Fptr56+lW8NIAcag9tu/1Fdwpa/qbKkVDMjFqUCSOmD H8W72oPLbKo+hHYMvVRUOTxhgnB9+I2Iwg3f5Wt4qsXjDpLStud2IhHvyqN0NqAv0JLL P0uIj/OgITDvY5yfEICoW86FveltODEiW2yH0L15RO6cBzRSOg1JIMbwJUpfAhot2t2r HckSIsw4Tad9y53Hpt9xG9cube6sVSe+4QD3562BEhkZ9FTvIaWewWrG3MkFJ76cecbe Ns0A== X-Gm-Message-State: AOJu0Yxs6tpMfalovZ+GshAQoQiKrmJF9T+LQ1oJkL7Xq9mSG/hLqAaX 9xcb6cPTnVIWz1Lfg0tYftsuIn2qt6689GQ+os1r8CXa6yUlsprJm7fJyHuNFo5bOFvLpTCXXwg RVxcHtIAy/rorxheIpz+tr7mUas0= X-Google-Smtp-Source: AGHT+IETHhNp9su0oYInE5p+yN54EU8gBJZNxusIYfdydUMfoO77k5cVJP70M1zTCh7SBbJfbj2EqTdjUwcfdRQjZQE= X-Received: by 2002:a05:622a:3d3:b0:460:8416:6fd8 with SMTP id d75a77b69052e-460aed48b1fmr84171791cf.14.1729326853806; Sat, 19 Oct 2024 01:34:13 -0700 (PDT) In-Reply-To: X-Mailman-Approved-At: Sat, 19 Oct 2024 10:25:42 -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:293885 Archived-At: --000000000000d261fe0624d04827 Content-Type: text/plain; charset="UTF-8" Sure, this is the patch from 6213ca44 >From 1c4b8efb82bd0e35c91d98f2759217702f3a7c65 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 = [super copyWithZone:zone]; +#ifdef NS_IMPL_COCOA + copy->stippleMask = CGImageCreateCopy(stippleMask); +#else copy->stippleMask = [stippleMask copyWithZone:zone]; +#endif /* NS_IMPL_COCOA */ copy->bmRep = [bmRep copyWithZone:zone]; copy->transform = [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 == nil) { + CGDataProviderRef provider = CGDataProviderCreateWithData (NULL, [bmRep bitmapData], + [self sizeInBytes], NULL); + CGImageRef mask = CGImageMaskCreate( + [self size].width, + [self size].height, + 8, 8, [self size].width, + provider, NULL, 0); + + CGDataProviderRelease(provider); + stippleMask = CGImageRetain(mask); + } + return stippleMask; +} +#else /* Returns a pattern color, which is cached here. */ - (NSColor *)stippleMask { @@ -516,6 +546,7 @@ - (NSColor *)stippleMask stippleMask = [[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 = FRAME_DISPLAY_INFO (s->f); +#ifdef NS_IMPL_COCOA + [[NSColor colorWithUnsignedLong:face->background] set]; + r = NSMakeRect (s->x, s->y + box_line_width, + s->background_width, + s->height - 2 * box_line_width); + NSRectFill (r); + s->background_filled_p = 1; + CGImageRef mask = [dpyinfo->bitmaps[face->stipple - 1].img stippleMask]; + CGRect bounds = CGRectMake (s->x, s->y + box_line_width, + s->background_width, + s->height - 2 * box_line_width); + NSGraphicsContext *ctx = [NSGraphicsContext currentContext]; + [ctx saveGraphicsState]; + CGContextRef context = [ctx CGContext]; + CGContextClipToRect (context, bounds); + CGContextScaleCTM (context, 1, -1); + [[NSColor colorWithUnsignedLong:face->foreground] set]; + CGRect imageSize = 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 = 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 = FRAME_DISPLAY_INFO (s->f); if (s->hl == 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 = [dpyinfo->bitmaps[s->face->stipple - 1].img stippleMask]; + CGRect bounds = CGRectMake (s->x, s->y, s->background_width, s->height); + NSGraphicsContext *ctx = [NSGraphicsContext currentContext]; + [ctx saveGraphicsState]; + CGContextRef context = [ctx CGContext]; + CGContextClipToRect(context, bounds); + CGContextScaleCTM (context, 1, -1); + [[NSColor colorWithUnsignedLong:s->face->foreground] set]; + CGRect imageSize = 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]; -- 2.46.0 On Thu, 17 Oct 2024 at 12:43, Arash Esbati wrote: > Ben Simms writes: > > > Hey all, I've gone ahead and put my changes behind NS_IMPL_COCA ifdefs: > > Thanks. I tried to test this but the patch doesn't apply: > > $ git apply --check 00stipple.patch > error: patch failed: src/nsterm.m:3823 > error: src/nsterm.m: patch does not apply > > This is with Emacs from master 6213ca44. Do you have the chance to > check and resend? > > Best, Arash > --000000000000d261fe0624d04827 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Sure, this is the patch from 6213ca44

F= rom 1c4b8efb82bd0e35c91d98f2759217702f3a7c65 Mon Sep 17 00:00:00 2001
Fr= om: Ben Simms <ben@bensimms.moe>
Date: Mon, 14 Oct 2024 19:32:53 += 0100
Subject: [PATCH] Use masked coregraphics images on cocoa NS

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

diff --git a/src/nsimage.m b/src/nsimage.m=
index ee72d6e0ea1..e36cbe5dc87 100644
--- a/src/nsimage.m
+++ b/s= rc/nsimage.m
@@ -35,6 +35,9 @@ Updated by Christian Limpach (chris@nice.ch)
=C2=A0#include "frame.h&qu= ot;
=C2=A0#include "coding.h"
=C2=A0
+#ifdef NS_IMPL_COC= OA
+#include <CoreGraphics/CoreGraphics.h>
+#endif
=C2=A0=C2=A0#if defined (NS_IMPL_GNUSTEP) || MAC_OS_X_VERSION_MAX_ALLOWED < 1= 070
=C2=A0# define COLORSPACE_NAME NSCalibratedRGBColorSpace
@@ -289,= 7 +292,11 @@ + (instancetype)allocInitFromFile: (Lisp_Object)file
=C2=A0=
=C2=A0- (void)dealloc
=C2=A0{
+#ifdef NS_IMPL_COCOA
+ =C2=A0CG= ImageRelease(stippleMask);
+#else
=C2=A0 =C2=A0[stippleMask release];=
+#endif
=C2=A0 =C2=A0[bmRep release];
=C2=A0 =C2=A0[transform rel= ease];
=C2=A0 =C2=A0[super dealloc];
@@ -300,7 +307,11 @@ - (id)copyW= ithZone:(NSZone *)zone
=C2=A0{
=C2=A0 =C2=A0EmacsImage *copy =3D [sup= er copyWithZone:zone];
=C2=A0
+#ifdef NS_IMPL_COCOA
+ =C2=A0copy-&= gt;stippleMask =3D CGImageCreateCopy(stippleMask);
+#else
=C2=A0 =C2= =A0copy->stippleMask =3D [stippleMask copyWithZone:zone];
+#endif /* = NS_IMPL_COCOA */
=C2=A0 =C2=A0copy->bmRep =3D [bmRep copyWithZone:zon= e];
=C2=A0 =C2=A0copy->transform =3D [transform copyWithZone:zone];=C2=A0
@@ -509,6 +520,25 @@ - (void) setAlphaAtX: (int) x Y: (int) y t= o: (unsigned char) a
=C2=A0 =C2=A0 =C2=A0}
=C2=A0}
=C2=A0
+#ifd= ef NS_IMPL_COCOA
+/* Returns a cached CGImageMask of the stipple pattern= */
+- (CGImageRef)stippleMask
+{
+ =C2=A0if (stippleMask =3D=3D n= il) {
+ =C2=A0 =C2=A0CGDataProviderRef provider =3D CGDataProviderCreate= WithData (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 sizeInBytes], NULL);
+ =C2=A0 =C2=A0CG= ImageRef 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, [se= lf 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=A0CGDataProviderRelea= se(provider);
+ =C2=A0 =C2=A0stippleMask =3D CGImageRetain(mask);
+ = =C2=A0}
+ =C2=A0return stippleMask;
+}
+#else
=C2=A0/* Returns = a pattern color, which is cached here. =C2=A0*/
=C2=A0- (NSColor *)stipp= leMask
=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 stippleMask;
=C2=A0}
+#endif /* NS_I= MPL_COCOA */
=C2=A0
=C2=A0/* Find the first NSBitmapImageRep which ha= s multiple frames. =C2=A0*/
=C2=A0- (NSBitmapImageRep *)getAnimatedBitma= pImageRep
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=A0NSBitma= pImageRep *bmRep; /* used for accessing pixel data */
=C2=A0 =C2=A0unsig= ned char *pixmapData[5]; /* shortcut to access pixel data */
+#ifdef NS_= IMPL_COCOA
+ =C2=A0CGImageRef stippleMask;
+#else
=C2=A0 =C2=A0NSC= olor *stippleMask;
+#endif // NS_IMPL_COCOA
=C2=A0@public
=C2=A0 = =C2=A0NSAffineTransform *transform;
=C2=A0 =C2=A0BOOL smoothing;
@@ -= 688,7 +692,11 @@ #define NSTRACE_UNSILENCE()
=C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 green: (unsigned 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
+- (CGImageRef)stippleMask;
+#else
=C2= =A0- (NSColor *)stippleMask;
+#endif // NS_IMPL_COCOA
=C2=A0- (Lisp_O= bject)getMetadata;
=C2=A0- (BOOL)setFrame: (unsigned int) index;
=C2= =A0- (void)setTransform: (double[3][3]) m;
diff --git a/src/nsterm.m b/s= rc/nsterm.m
index f68a22d9fbc..a617669cb4d 100644
--- a/src/nsterm.m<= br>+++ b/src/nsterm.m
@@ -3823,8 +3823,31 @@ Function modeled after x_dr= aw_glyph_string_box ().
=C2=A0 =C2=A0 =C2=A0 =C2=A0if (s->stippled_p)=
=C2=A0 {
=C2=A0 =C2=A0struct ns_display_info *dpyinfo =3D FRAME_DIS= PLAY_INFO (s->f);
+#ifdef NS_IMPL_COCOA
+ =C2=A0 =C2=A0[[NSColor c= olorWithUnsignedLong:face->background] set];
+ =C2=A0 =C2=A0r =3D NSM= akeRect (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=A0NSRectFill (r);
+ =C2=A0 =C2=A0s-&= gt;background_filled_p =3D 1;
+ =C2=A0 =C2=A0CGImageRef mask =3D [dpyinf= o->bitmaps[face->stipple - 1].img stippleMask];
+ =C2=A0 =C2=A0CGR= ect 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 saveGra= phicsState];
+ =C2=A0 =C2=A0CGContextRef context =3D [ctx CGContext];+ =C2=A0 =C2=A0CGContextClipToRect (context, bounds);
+ =C2=A0 =C2=A0CG= ContextScaleCTM (context, 1, -1);
+ =C2=A0 =C2=A0[[NSColor colorWithUnsi= gnedLong:face->foreground] set];
+ =C2=A0 =C2=A0CGRect imageSize =3D = CGRectMake (0, 0, CGImageGetWidth (mask), CGImageGetHeight (mask));
+ = =C2=A0 =C2=A0CGContextDrawTiledImage (context, imageSize, mask);
+ =C2= =A0 =C2=A0[[NSGraphicsContext currentContext] restoreGraphicsState];
+#e= lse
=C2=A0 =C2=A0[[dpyinfo->bitmaps[face->stipple-1].img stippleM= ask] set];
=C2=A0 =C2=A0goto fill;
+#endif /* NS_IMPL_COCOA */
+<= br>=C2=A0 }
=C2=A0 =C2=A0 =C2=A0 =C2=A0else 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_string_box ().
=C2=A0 =C2=A0el= se
=C2=A0 =C2=A0 =C2=A0[FRAME_CURSOR_COLOR (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_gl= yph_string_box ().
=C2=A0 =C2=A0dpyinfo =3D FRAME_DISPLAY_INFO (s->f= );
=C2=A0 =C2=A0if (s->hl =3D=3D DRAW_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->stippled_p) {
+#ifdef NS_= IMPL_COCOA
+ =C2=A0 =C2=A0 =C2=A0[[NSColor colorWithUnsignedLong:s->f= ace->background] set];
+ =C2=A0 =C2=A0 =C2=A0NSRectFill (NSMakeRect (= x, s->y, background_width, s->height));
+ =C2=A0 =C2=A0 =C2=A0CGIm= ageRef mask =3D [dpyinfo->bitmaps[s->face->stipple - 1].img stippl= eMask];
+ =C2=A0 =C2=A0 =C2=A0CGRect bounds =3D CGRectMake (s->x, s-&= gt;y, s->background_width, s->height);
+ =C2=A0 =C2=A0 =C2=A0NSGra= phicsContext *ctx =3D [NSGraphicsContext currentContext];
+ =C2=A0 =C2= =A0 =C2=A0[ctx saveGraphicsState];
+ =C2=A0 =C2=A0 =C2=A0CGContextRef co= ntext =3D [ctx CGContext];
+ =C2=A0 =C2=A0 =C2=A0CGContextClipToRect(con= text, bounds);
+ =C2=A0 =C2=A0 =C2=A0CGContextScaleCTM (context, 1, -1);=
+ =C2=A0 =C2=A0 =C2=A0[[NSColor colorWithUnsignedLong:s->face->fo= reground] set];
+ =C2=A0 =C2=A0 =C2=A0CGRect imageSize =3D CGRectMake (0= , 0, CGImageGetWidth (mask),
+ =C2=A0 =C2=A0 =C2=A0CGImageGetHeight (mas= k));
+ =C2=A0 =C2=A0 =C2=A0CGContextDrawTiledImage (context, imageSize, = mask);
+ =C2=A0 =C2=A0 =C2=A0[[NSGraphicsContext currentContext] restore= GraphicsState];
+#else
+ =C2=A0 =C2=A0 =C2=A0[[dpyinfo->bitmaps[s= ->face->stipple - 1].img stippleMask] set];
+#endif /* NS_IMPL_COC= OA */
+ =C2=A0 =C2=A0}
=C2=A0 =C2=A0else
=C2=A0 =C2=A0 =C2=A0[[N= SColor colorWithUnsignedLong: s->face->background] set];
=C2=A0--
2.46.0


On Thu, 17 Oct 2024 at 12:43, Arash Esbati &l= t;arash@gnu.org> wrote:
Ben Simms <bsimms.simms@gmail.com&g= t; writes:

> Hey all, I've gone ahead and put my changes behind NS_IMPL_COCA if= defs:

Thanks.=C2=A0 I tried to test this but the patch doesn't apply:

$ git apply --check 00stipple.patch
error: patch failed: src/nsterm.m:3823
error: src/nsterm.m: patch does not apply

This is with Emacs from master 6213ca44.=C2=A0 Do you have the chance to check and resend?

Best, Arash
--000000000000d261fe0624d04827--