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.bugs Subject: bug#35468: [PATCH] Refactor draw_glyph_string on X and w32 Date: Sat, 04 May 2019 13:29:34 -0600 Message-ID: <87pnoyj9wh.fsf@gmail.com> References: <877ebeor2d.fsf@gmail.com> <83tveit5ph.fsf@gnu.org> <87pnp5oqu1.fsf@gmail.com> <877ebcogg4.fsf@gmail.com> <83sgu0rsue.fsf@gnu.org> <8736lznzjf.fsf@gmail.com> <83zho6ox5u.fsf@gnu.org> <878svomynv.fsf@gmail.com> <838svmmy5q.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="173992"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) Cc: 35468@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat May 04 21:30:12 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1hN0MN-000j8a-0P for geb-bug-gnu-emacs@m.gmane.org; Sat, 04 May 2019 21:30:11 +0200 Original-Received: from localhost ([127.0.0.1]:60275 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hN0MM-0006QC-1G for geb-bug-gnu-emacs@m.gmane.org; Sat, 04 May 2019 15:30:10 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:55265) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hN0MG-0006Py-3m for bug-gnu-emacs@gnu.org; Sat, 04 May 2019 15:30:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hN0ME-0003FC-TI for bug-gnu-emacs@gnu.org; Sat, 04 May 2019 15:30:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:38792) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hN0ME-0003F7-Q9 for bug-gnu-emacs@gnu.org; Sat, 04 May 2019 15:30:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hN0ME-0000O9-Lb for bug-gnu-emacs@gnu.org; Sat, 04 May 2019 15:30:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alex Gramiak Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 04 May 2019 19:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35468 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 35468-submit@debbugs.gnu.org id=B35468.15569981791434 (code B ref 35468); Sat, 04 May 2019 19:30:02 +0000 Original-Received: (at 35468) by debbugs.gnu.org; 4 May 2019 19:29:39 +0000 Original-Received: from localhost ([127.0.0.1]:52335 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hN0Lq-0000N2-LN for submit@debbugs.gnu.org; Sat, 04 May 2019 15:29:38 -0400 Original-Received: from mail-pl1-f171.google.com ([209.85.214.171]:34817) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hN0Lo-0000Mn-Eh for 35468@debbugs.gnu.org; Sat, 04 May 2019 15:29:37 -0400 Original-Received: by mail-pl1-f171.google.com with SMTP id w24so4338983plp.2 for <35468@debbugs.gnu.org>; Sat, 04 May 2019 12:29:36 -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=uVedNMzkaqvDfpne94mv9lsTdhO7W2Qnk8IeGsD5qQo=; b=ct4H3BDkKwH3qBb/KIKtgk21Uaw6ejME6mmhnzdYqgTJU1GF0Iy/GFi53if8j/FmUC +J67diCKa0XUFgVNJOEFrpfi+h8nfaUiOk07npoh+boHsw2RUE6X0/vppCLsHI+b9Y3E 70qpM2LbUNGnUxP6GrIa1LSNswtnBUPQx2Ut+uvldqADq4xBml3nMiZ1Qbhkx3YObAa7 DTIeNrdT825y+mbw65V2wcHAuuMQIktqyqt699N6uuLNKDQQRp1o8gdV+VxNNcHXFZZZ L39H/OtvNB7OTbDnzU/nsM4nMAQRZRjdZvpgAFvI0juItJn6vs1fUWA8wYfRZYiS4IYW RkEQ== 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=uVedNMzkaqvDfpne94mv9lsTdhO7W2Qnk8IeGsD5qQo=; b=mv1R8sApkgkhInAcPps7EACWsycaUqAh1mou3A1woH3BLpXwOvC3SOoM4GpA+C8PL3 RJXSlYkAqzd1Yc8Ib1KmdIbma1YulpONYPZutjGfZnVKCVuCVuJq5euXJ+v5N4KBUhnr yQVelLVSb7bU37yaSmTgX91P543Vn2xHSSzxIu1VqiaV6yGgPRPBqTiVHqFIM2X9NWD7 O9Bplt6hLWwVQe3L1gp2J/keVkmzeyUUctWwab9DD7lTB+TjP9mEaGhXOZmDY1IZxyol 4SWZEf1mx//cZWLpYA3n62aKjSdTc7jdP8KuNZFcauJle9ORsaZGNg7zWsTt0A7S32ny LaNg== X-Gm-Message-State: APjAAAWIKspLlKBckJG8WhsBZHVj0Cgl6c7KW1R4UmjM7gPTWapJ/enk ZwbQaR0iH3g5luEwLZ+DJtk= X-Google-Smtp-Source: APXvYqwDvgJp3o3vWglHzoHph8KCaQ8ntPtOFdPfHf/8bkhIysx4drtXkUruwVkh8i1ysb6yESPtWg== X-Received: by 2002:a17:902:6b47:: with SMTP id g7mr20499624plt.227.1556998170447; Sat, 04 May 2019 12:29:30 -0700 (PDT) Original-Received: from lylat ([2604:3d09:e37f:1500:1a72:4878:e793:7302]) by smtp.gmail.com with ESMTPSA id k9sm6077416pga.22.2019.05.04.12.29.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 04 May 2019 12:29:29 -0700 (PDT) In-Reply-To: <838svmmy5q.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 04 May 2019 11:17:21 +0300") 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:158758 Archived-At: Eli Zaretskii writes: >> Where do the X 'draw' methods accept the font as an argument? Looking >> at, e.g., *_draw_glyph_string_foreground, font->driver->draw takes the >> same arguments. > > The way I wrote it was confusing: by the 'draw' method I actually > meant the external APIs called by the 'draw' method, like > XftDrawGlyphs. Compare that with w32's ExtTextOutW in w32font_draw. Ah, I see. I'll keep the setter and rename it to, say, set_device_context_font. >> I'm having trouble with *_draw_image_foreground -- they just seem too >> different to nicely abstract. Would it be okay if some generic >> constructs leak into it (namely: s->img->mask)? Otherwise the common >> setup that w32 does would be problematic. > > I don't think I understand the difficulties, sorry. Why is > s->img->mask a problem? I meant problem as in that it's "leaking" the internals a bit. > In any case, it's not 100% "verboten" for platform-specific code to > look at the internals of 'struct glyph_string', if the interface needs > many different members of that struct. Avoiding this is just a > general rule, which makes it easier to implement generic interfaces > that will fit future uses. However draw_image (which, btw, I'd call > draw_image_foreground) looks specialized enough to be exempt of that > rule. That's good; it will be easier to work with the image procedures in that case. >> For reference, this is what I have right now for >> gui_draw_image_foreground: >> >> static void >> gui_draw_image_foreground (struct glyph_string *s) >> { >> struct graphical_drawing_interface *gdif = FRAME_GDIF (s->f); >> int x = s->x; >> int y = s->ybase - image_ascent (s->img, s->face, &s->slice); >> >> /* If first glyph of S has a left box line, start drawing it to the >> right of that line. */ >> if (s->face->box != FACE_NO_BOX >> && s->first_glyph->left_box_line_p >> && s->slice.x == 0) >> x += eabs (s->face->box_line_width); >> >> /* If there is a margin around the image, adjust x- and y-position >> by that margin. */ >> if (s->slice.x == 0) >> x += s->img->hmargin; >> if (s->slice.y == 0) >> y += s->img->vmargin; >> >> if (gdif->save_secondary_context) >> gdif->save_secondary_context (s, CON_ALL); // SaveDC (s->hdc); >> >> if (gdif->glyph_has_image (s)) > > What details does glyph_has_image hide? Is that just to test > s->img->pixmap? On most platforms, yes, but the Cairo drawing uses s->img->cr_data instead. >> { >> gdif->draw_image (s, s->img->width, s->img->height, >> s->slice.x, s->slice.y, s->slice.width, s->slice.height, >> x, y, true); >> if (!gdif->glyph_image_uses_mask (s)) > > And what does glyph_image_uses_mask hide? AFAIU, the current code > simply looks at s->img->mask, and if so, why do we need an interface > for that? I was thinking that since AFAIU the Cairo drawing doesn't set s->img->mask it wouldn't make sense, from an interface POV, to check it directly. I suppose it doesn't really matter in that case, and it would be faster to just check s->img->mask even if the backend doesn't use it.