To finish my description of GTK4's "GSK" renderer, I'll new describe the (GLSL) code running on the GPU to do the actual rendering.

And this starts with a handful of common input variables & utilities to output a (clipped) colour, hittest a rounded rectangle, or lookup a point in a texture. That hittest first involves hittesting the unrounded rectangle, then each corner, then combines those latter tests. Different variants are implemented for ES2, GL3, & GL2.

The formula for hittesting an ellipsis is:

(dotproduct(p / r, p / r) - 1.0) / length(2 * (p / r) / r)

Where dotproduct(a, b) = a.x*b.x + a.y*b.y & length(a) = sqrt dotproduct(a, a).

Feel free to explain this formula to me, I haven't studied much geometry.

To color blend between two surfaces, lookup the appropriate colours in both textures & mixes them according to the specified (of numerous) formulas.

To copy ("blit") an image onto the output you simply look up that pixel & apply the opacity. That texture position from which to read is interpolated between this "fragment shader" and the "vertex shader".

(cont.)

Follow

@alcinnz Could you post any examples of what this might look like?

@Anarkat I'm sorry, I'll have to ask you to look up "GTK Scenegraph Kit" for that. All I see is code.

Sign in to participate in the conversation
Computer Fairies

Computer Fairies is a Mastodon instance that aims to be as queer, friendly and furry as possible. We welcome all kinds of computer fairies!