From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Alex Gramiak Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] Remove display member of glyph_string Date: Thu, 09 May 2019 10:07:25 -0600 Message-ID: <871s17ehmq.fsf@gmail.com> References: <87a7fwe12f.fsf@gmail.com> <83ef58goru.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="235145"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu May 09 18:08:05 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hOlaW-000yyi-AH for ged-emacs-devel@m.gmane.org; Thu, 09 May 2019 18:08:04 +0200 Original-Received: from localhost ([127.0.0.1]:57312 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOlaU-0005ca-SE for ged-emacs-devel@m.gmane.org; Thu, 09 May 2019 12:08:02 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:59402) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOlZy-0005JP-BS for emacs-devel@gnu.org; Thu, 09 May 2019 12:07:31 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hOlZu-0002D7-Us for emacs-devel@gnu.org; Thu, 09 May 2019 12:07:29 -0400 Original-Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:46989) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hOlZs-0002Ba-PV; Thu, 09 May 2019 12:07:25 -0400 Original-Received: by mail-pl1-x643.google.com with SMTP id bi2so1351734plb.13; Thu, 09 May 2019 09:07:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=6Du8JvXtNnzd9xzEyCKV9pE+L+B68T8FCnicT2FUKTs=; b=JzNlELplhvfqDui2BbShaSNmDUlPqqfDTk88Sg4jdLkC2DpCAeU11i6jc+eF+tTBSY MmeHIlnT0cqMQZeFJ6G/h+Ec1amd/yPZglVrzI10dARqpHmhHCafVctLBNMSyOv5kmPp lYKJE+o/D/PzWWuNxlqa5eMiPvgTwCjA0vGJYUT0gFZ10/1YKZ1eb27cXjttZpGkjyZT sVwgfN4Q8SZOSyThCtPnVIwRL3ZNHnR/bX4exi16xg2DJFBYEgi3YTF/tupGWKAgusM/ KbJiap6vz3suGdaOH93cvAAQ+ZPDOQvAdex2/vZQg63smkHcr9C3MLTF8Y9NYlnIg0DI W4ug== 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:references:date:in-reply-to :message-id:user-agent:mime-version; bh=6Du8JvXtNnzd9xzEyCKV9pE+L+B68T8FCnicT2FUKTs=; b=HlFwM8aLxm+6cXHMZr03J0GqkLqNYPvgf0A1jsopXDUN+7wnjmrPQ4+evXZQ7Q8iXX oBnkAZNI/8S9HCX+EvlIbGNl0Gxtb8Rp6lUexSyJg8AyaNTB93iHg5L15jKflsT3wj2x Njf5Z3bAcmRcxEsFpRfXyY4mhOsRbx5Ce6u46tBHOatGQhZUTQnKuMEjHadwN3LAMRrV Pnu7kgQbwV+lE3cyi2kdwq/ZfgqCL1lm6yarzhvvu1vw9xDsp5qBWazZ9wvjA9C87Tda PHvxeXIxBJhszSczow4WdrcnCRwS9EAW6Jym/ut4767OWloWu3OWyVO/qPqyad8AP3ZV A0Sw== X-Gm-Message-State: APjAAAVGZl2KF2ZrVKlnYCn1WajZPMNGSZNgDsNnZo719F6/UkEGkkKF eUMdmqPaCu8OPfwFJ8M0uzZ/j4T3 X-Google-Smtp-Source: APXvYqyKGRy6r4Bm8udDgnE56nVfQCut/gIldFfGc4AYOnr6YrnnBkA8EUm8o0UB2sS+EgpIT4Rcgw== X-Received: by 2002:a17:902:968b:: with SMTP id n11mr6273505plp.118.1557418042024; Thu, 09 May 2019 09:07:22 -0700 (PDT) Original-Received: from lylat ([2604:3d09:e37f:1500:1a72:4878:e793:7302]) by smtp.gmail.com with ESMTPSA id l15sm2788353pgb.71.2019.05.09.09.07.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 09 May 2019 09:07:20 -0700 (PDT) In-Reply-To: <83ef58goru.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 09 May 2019 08:50:13 +0300") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::643 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:236337 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> From: Alex Gramiak >> Date: Wed, 08 May 2019 21:52:56 -0600 > > Each FRAME_X_DISPLAY call expands into applying a struct offset 4 > times. Do we care about the (small) additional inefficiency? AFAIU, > that was the cause for maintaining the result inside the glyph_string > structure in the first place. I doubt that it's much of a difference. However, it should be noted that in cases where the member is used several times in a single procedure, the FRAME_X_DISPLAY method is comparable or better: x_clear_glyph_string_rect, x_draw_stretch_glyph_string: Before: 3 offsets After: 4 offsets x_draw_image_foreground_1: Before: 4 offsets After: 4 offsets x_draw_image_glyph_string: Before: up to 9 offsets After: 4 offsets x_draw_underwave: Before 3 + 2 * ceiling ((xmax - x1)/dx) offsets After: 4 offsets >> The only other location that FRAME_X_DISPLAY appears in non-X code is in >> the argument to Free_Pixmap in image.c, which can hopefully be >> refactored out in a later patch; at that point the other terms can >> remove their trivial FRAME_X_DISPLAY definitions. > > So should we do both in one go, perhaps? Sure, here's a patch that does it: --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Convert-Free_Pixmap-macro-into-terminal-hook.patch Content-Description: Free_Pixmap >From 749a61a0bda6a3023e6f4b19528c6a6be940c929 Mon Sep 17 00:00:00 2001 From: Alexander Gramiak Date: Thu, 9 May 2019 09:37:50 -0600 Subject: [PATCH] Convert Free_Pixmap macro into terminal hook * src/termhooks.h (terminal): New terminal hook free_pixmap. * src/image.c: Replace Free_Pixmap with free_pixmap. * src/msdos.h: * src/nsgui.h: * src/nsterm.h: * src/w32term.h: Remove unused X-compatibility macros and typedefs. * src/nsterm.m: * src/w32term.c: * src/xterm.c: Implement and set free_pixmap hook. --- src/image.c | 24 ++---------------------- src/msdos.h | 1 - src/nsgui.h | 1 - src/nsterm.h | 6 ------ src/nsterm.m | 16 ++++++++++++++-- src/termhooks.h | 8 ++++++++ src/w32term.c | 14 ++++++++++++++ src/w32term.h | 3 --- src/xterm.c | 12 ++++++++++++ 9 files changed, 50 insertions(+), 35 deletions(-) diff --git a/src/image.c b/src/image.c index e8cb434177..0779594989 100644 --- a/src/image.c +++ b/src/image.c @@ -1221,26 +1221,6 @@ four_corners_best (XImagePtr_or_DC ximg, int *corners, return best; } -/* Portability macros */ - -#ifdef HAVE_NTGUI - -#define Free_Pixmap(display, pixmap) \ - DeleteObject (pixmap) - -#elif defined (HAVE_NS) - -#define Free_Pixmap(display, pixmap) \ - ns_release_object (pixmap) - -#else - -#define Free_Pixmap(display, pixmap) \ - XFreePixmap (display, pixmap) - -#endif /* !HAVE_NTGUI && !HAVE_NS */ - - /* Return the `background' field of IMG. If IMG doesn't have one yet, it is guessed heuristically. If non-zero, XIMG is an existing XImage object (or device context with the image selected on W32) to @@ -1328,7 +1308,7 @@ image_clear_image_1 (struct frame *f, struct image *img, int flags) { if (img->pixmap) { - Free_Pixmap (FRAME_X_DISPLAY (f), img->pixmap); + FRAME_TERMINAL (f)->free_pixmap (f, img->pixmap); img->pixmap = NO_PIXMAP; /* NOTE (HAVE_NS): background color is NOT an indexed color! */ img->background_valid = 0; @@ -1347,7 +1327,7 @@ image_clear_image_1 (struct frame *f, struct image *img, int flags) { if (img->mask) { - Free_Pixmap (FRAME_X_DISPLAY (f), img->mask); + FRAME_TERMINAL (f)->free_pixmap (f, img->mask); img->mask = NO_PIXMAP; img->background_transparent_valid = 0; } diff --git a/src/msdos.h b/src/msdos.h index 0d15df7a33..90ceea8e3d 100644 --- a/src/msdos.h +++ b/src/msdos.h @@ -95,7 +95,6 @@ typedef struct tty_display_info Display_Info; extern struct tty_display_info the_only_display_info; extern struct tty_output the_only_tty_output; -#define FRAME_X_DISPLAY(f) ((Display *) 0) #define FRAME_FONT(f) ((f)->output_data.tty->font) #define FRAME_DISPLAY_INFO(f) (&the_only_display_info) diff --git a/src/nsgui.h b/src/nsgui.h index c147f4dec4..ab6cdff1e5 100644 --- a/src/nsgui.h +++ b/src/nsgui.h @@ -115,7 +115,6 @@ typedef NSColor * Color; typedef void * Color; #endif typedef int Window; -typedef int Display; /* Some sort of attempt to normalize rectangle handling. Seems a bit diff --git a/src/nsterm.h b/src/nsterm.h index 683f2dd934..ffaf809785 100644 --- a/src/nsterm.h +++ b/src/nsterm.h @@ -997,12 +997,6 @@ struct x_output #define FRAME_NS_WINDOW(f) ((f)->output_data.ns->window_desc) #define FRAME_NATIVE_WINDOW(f) FRAME_NS_WINDOW (f) -/* This is the `Display *' which frame F is on. */ -#define FRAME_NS_DISPLAY(f) (0) -#define FRAME_X_DISPLAY(f) (0) -#define FRAME_X_SCREEN(f) (0) -#define FRAME_X_VISUAL(f) FRAME_DISPLAY_INFO(f)->visual - #define FRAME_FOREGROUND_COLOR(f) ((f)->output_data.ns->foreground_color) #define FRAME_BACKGROUND_COLOR(f) ((f)->output_data.ns->background_color) diff --git a/src/nsterm.m b/src/nsterm.m index ffb7b7692b..d688aceca5 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -2515,8 +2515,7 @@ so some key presses (TAB) are swallowed by the system. */ /* Clear the mouse-moved flag for every frame on this display. */ FOR_EACH_FRAME (tail, frame) - if (FRAME_NS_P (XFRAME (frame)) - && FRAME_NS_DISPLAY (XFRAME (frame)) == FRAME_NS_DISPLAY (*fp)) + if (FRAME_NS_P (XFRAME (frame))) XFRAME (frame)->mouse_moved = 0; dpyinfo->last_mouse_scroll_bar = nil; @@ -4966,6 +4965,18 @@ in certain situations (rapid incoming events). [eview updateFrameSize: NO]; } +/* ========================================================================== + + Image Hooks + + ========================================================================== */ + +static void +ns_free_pixmap (struct frame *_f, Pixmap pixmap) +{ + ns_release_object (pixmap); +} + /* ========================================================================== Initialization @@ -5196,6 +5207,7 @@ static Lisp_Object ns_new_font (struct frame *f, Lisp_Object font_object, terminal->redeem_scroll_bar_hook = ns_redeem_scroll_bar; terminal->judge_scroll_bars_hook = ns_judge_scroll_bars; terminal->get_string_resource_hook = ns_get_string_resource; + terminal->free_pixmap = ns_free_pixmap; terminal->delete_frame_hook = ns_destroy_window; terminal->delete_terminal_hook = ns_delete_terminal; /* Other hooks are NULL by default. */ diff --git a/src/termhooks.h b/src/termhooks.h index 54f09e0303..617df86c5c 100644 --- a/src/termhooks.h +++ b/src/termhooks.h @@ -741,6 +741,14 @@ struct terminal const char *name, const char *class); + /* Image hooks */ + + /* Free the pixmap PIXMAP on F. */ + void (*free_pixmap) (struct frame *f, Pixmap pixmap); + + + /* Deletion hooks */ + /* Called to delete the device-specific portions of a frame that is on this terminal device. */ void (*delete_frame_hook) (struct frame *); diff --git a/src/w32term.c b/src/w32term.c index 0abec3d92a..435455e1a6 100644 --- a/src/w32term.c +++ b/src/w32term.c @@ -6869,6 +6869,7 @@ w32_wm_set_size_hint (struct frame *f, long flags, bool user_position) leave_crit (); } + /*********************************************************************** Fonts ***********************************************************************/ @@ -6940,6 +6941,18 @@ w32_toggle_invisible_pointer (struct frame *f, bool invisible) unblock_input (); } + +/*********************************************************************** + Image Hooks + ***********************************************************************/ + +static void +w32_free_pixmap (struct frame *_f, Pixmap pixmap) +{ + DeleteObject (pixmap); +} + + /*********************************************************************** Initialization ***********************************************************************/ @@ -7119,6 +7132,7 @@ w32_create_terminal (struct w32_display_info *dpyinfo) terminal->redeem_scroll_bar_hook = w32_redeem_scroll_bar; terminal->judge_scroll_bars_hook = w32_judge_scroll_bars; terminal->get_string_resource_hook = w32_get_string_resource; + terminal->free_pixmap = w32_free_pixmap; terminal->delete_frame_hook = w32_destroy_window; terminal->delete_terminal_hook = w32_delete_terminal; /* Other hooks are NULL by default. */ diff --git a/src/w32term.h b/src/w32term.h index de372d7e5d..a03b9fd331 100644 --- a/src/w32term.h +++ b/src/w32term.h @@ -420,9 +420,6 @@ extern struct w32_output w32term_display; /* This gives the w32_display_info structure for the display F is on. */ #define FRAME_DISPLAY_INFO(f) ((void) (f), (&one_w32_display_info)) -/* This is the `Display *' which frame F is on. */ -#define FRAME_X_DISPLAY(f) (0) - #define FRAME_NORMAL_PLACEMENT(F) ((F)->output_data.w32->normal_placement) #define FRAME_PREV_FSMODE(F) ((F)->output_data.w32->prev_fsmode) diff --git a/src/xterm.c b/src/xterm.c index 7bedcabe98..a7b84f46cf 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -12181,6 +12181,17 @@ x_check_font (struct frame *f, struct font *font) #endif /* GLYPH_DEBUG */ +/*********************************************************************** + Image Hooks + ***********************************************************************/ + +static void +x_free_pixmap (struct frame *f, Pixmap pixmap) +{ + XFreePixmap (FRAME_X_DISPLAY (f), pixmap); +} + + /*********************************************************************** Initialization ***********************************************************************/ @@ -13257,6 +13268,7 @@ x_create_terminal (struct x_display_info *dpyinfo) terminal->redeem_scroll_bar_hook = XTredeem_scroll_bar; terminal->judge_scroll_bars_hook = XTjudge_scroll_bars; terminal->get_string_resource_hook = x_get_string_resource; + terminal->free_pixmap = x_free_pixmap; terminal->delete_frame_hook = x_destroy_window; terminal->delete_terminal_hook = x_delete_terminal; /* Other hooks are NULL by default. */ -- 2.21.0 --=-=-=--