<div dir="ltr">You can store in 8 bits and still convert to/from linear values when computing compositing. Squaring the number is likely close enough and can simplify the math. Also GPUs have built-in instructions to convert between 8 bits and floating point as sRGB.<div><br><div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Dec 25, 2023 at 11:25 PM Bandi-T <<a href="mailto:bandit@surfnonstop.com">bandit@surfnonstop.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Greetings,<br>
<br>
Is Cairo antialiasing/compositing in linear light?<br>
<br>
I am drawing graphs into onto on-screen areas using Cairo/GTK4 <br>
(Gtk::DrawingArea)/Win10, and the edges of my slanted <br>
(non-vertical/horizontal) lines (straight line segments) look jagged... <br>
like they might not have been antialiased in linear light, but in <br>
gamma-space.<br>
<br>
If my observation is correct, I am proposing enhancing Cairo to be able <br>
to perform anti-aliasing/compositing in linear light.<br>
<br>
This would switch internal pixel representation to linear light (float <br>
or at least 12-13 bits/component – so practically uint16), and then only <br>
upon a snapshotting (outputting the result) would it generate a 8 bit <br>
sRGB representation for legacy environments that still expect sRGB, or <br>
pass through the 16 bit linear representation for more modern <br>
environments (e.g. GPU textures).<br>
<br>
Please see this article with visual demonstrations and discussion about <br>
the potential improvements: <br>
<a href="https://pixls.us/articles/users-guide-to-high-bit-depth-gimp-2-9-2-part-2/" rel="noreferrer" target="_blank">https://pixls.us/articles/users-guide-to-high-bit-depth-gimp-2-9-2-part-2/</a><br>
<br>
Conceptually, this would<br>
<br>
* convert all incoming legacy color (= color specified in gamma-encoded <br>
spaces, e.g. sRGB – be it from image pixels, or user-speficied pen/fill <br>
colors, etc.) into linear light<br>
<br>
* internally, always work (draw/paint/antialias/composite) in linear light<br>
<br>
* when a gamma-encoded output is needed, render a gamma-encoded snapshot <br>
of the result<br>
<br>
For sRGB (which I assume is going to be the most common case) the needed <br>
maths is elaborated in the Wikipedia article of sRGB.<br>
<br>
Because this needs extra buffering, plus implies non-zero computational <br>
cost, it would be behind a higher quality antialias flag, so that users <br>
who don't care would not pay the extra computational costs. (However my <br>
hope is that the cost on modern hardware versus the quality improvement <br>
would eventually make this the default mode.)<br>
<br>
This is orthogonal to whole-pixel versus sub-pixel antialiasing, so both <br>
of those modes could/would/should benefit from it.<br>
<br>
How viable is this proposal? (For example I am only considering the case <br>
where Cairo is rendering into a pixel-based memory buffer that <br>
eventually gets copied on-screen, and am unaware of what this might mean <br>
for other scenarios.)<br>
<br>
Thank you in advance.<br>
<br>
</blockquote></div>