all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alex Gramiak <agrambot@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: Removing assumption of unsigned long pixel values for colours
Date: Sun, 05 May 2019 13:35:01 -0600	[thread overview]
Message-ID: <87h8a8k84a.fsf@gmail.com> (raw)
In-Reply-To: <83zho0khdu.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 05 May 2019 19:14:53 +0300")

Eli Zaretskii <eliz@gnu.org> writes:

>> It's not as much of an issue with the X+Cairo backend since the colour
>> is calculated from XQueryColors which returns an XColor, but the backend
>> I'm working on uses gdk_rgba_parse to query colors, which returns a
>> GdkRGBA (which is compatible with Cairo's). This means that a conversion
>> from the quadruple into unsigned long has to be done for every colour
>> queried.
>
> Such conversion needs about 2 to 3 machine instructions on modern
> hardware, so why is it a problem?  If you are annoyed by seeing it in
> the sources all the time, then a macro or an inline function should
> take care of that.

It's certainly possible that I'm overestimating the cost of the
conversions. It just doesn't seem good to have to do this conversion for
every draw operation.

Perhaps I should follow the old adage and just use unsigned long with
conversions first and benchmark after.

> Are there other issues that caused you to propose this change?

Not directly, but to avoid the conversions I did add additional
complexity by using a local tagged union that I feel is too much
trouble. I figured that I'd float this option by before changing
strategies.

> I see a couple of disadvantages with your proposal:
>
>   . it leaks to platform-independent parts of the code representation
>     that is specific to one platform, something that goes against
>     everything you've been doing lately in your other work

I'm not sure what leaks you're referring to here. The cases that use
.pixel directly should only be in the TTY-specific or X-specific code.

>   . the union you propose has no indication which of its
>     interpretations is being used, which will lead to bugs

I considered that, but as it looks like faces are tied to frames (which
are tied to terminals), then the type shouldn't need to be checked as
long as the terminal-independent code doesn't alter it.

> (larger structures slow down Emacs)

More so than other programs?

>> Also, AFAIU a GdkRGBA wouldn't necessarily convert into an unsigned long
>> without losing precision.
>
> If we want to increase the number of bits per pixel we support in
> Emacs, we need to do that for all the platforms.  Currently, they all
> are aligned on 32 bpp, AFAIK.  If indeed there will be loss of
> information (and I'd like to see some evidence to that first), then we
> need to move all the platforms to higher precision, not just one.

Wouldn't it only need to be done for platforms that support a higher
pixel depth?

gdk_rgba_parse uses pango_color_parse, which returns a PangoColor (48
bpp RGB), and normalizes each component over 2^16. If using either
CAIRO_FORMAT_RGB30 (30 bpp RGB) with image surfaces or using the OpenGL
backend (which I believe the GTK Wayland backend uses), then storing
ARGB values into an unsigned long would mean lost precision that could
have been used.



  reply	other threads:[~2019-05-05 19:35 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-04 18:08 Removing assumption of unsigned long pixel values for colours Alex Gramiak
2019-05-04 18:39 ` Eli Zaretskii
2019-05-04 23:04   ` Alex Gramiak
2019-05-05 16:14     ` Eli Zaretskii
2019-05-05 19:35       ` Alex Gramiak [this message]
2019-05-06  2:45         ` Eli Zaretskii
2019-05-06 14:13           ` Daniel Pittman
2019-05-06 16:11             ` Alex Gramiak
2019-05-06 16:51               ` Stefan Monnier
2019-05-06 20:03                 ` Alex Gramiak
2019-05-06 15:11           ` Alex Gramiak
2019-05-06 15:45             ` Eli Zaretskii
2019-05-06 16:29               ` Alex Gramiak
2019-05-06 16:54                 ` Eli Zaretskii
2019-05-06 17:14                   ` Alex Gramiak
2019-05-06 17:39                     ` Eli Zaretskii
2019-05-06 18:00                       ` Eli Zaretskii
2019-05-06 19:49                         ` Alex Gramiak
2019-05-07  2:29                           ` Eli Zaretskii
2019-05-06  8:12     ` Alan Third
2019-05-06  9:18       ` mituharu
2019-05-06 15:06       ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87h8a8k84a.fsf@gmail.com \
    --to=agrambot@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.