mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-04 09:40:19 +00:00
b0e8d8483d
This commit takes several steps towards rendering text like we want to. The creation of the cairo surface and texture is moved to the backend (in GskVulkanRenderer). We add a mask shader that is used in the next text pipeline to use the texture as a mask, like cairo_mask_surface does. There is a separate color text pipeline that uses the already existing blend shaders to use the texture as a source, like cairo_paint does. The text node api is simplified to have just a single offset, which determines the left end of the text baseline, like all our other text drawing APIs.
39 lines
1016 B
GLSL
39 lines
1016 B
GLSL
#version 420 core
|
|
|
|
#include "clip.vert.glsl"
|
|
|
|
layout(location = 0) in vec4 inRect;
|
|
layout(location = 1) in vec4 inTexRect;
|
|
layout(location = 2) in vec4 inColor;
|
|
|
|
layout(location = 0) out vec2 outPos;
|
|
layout(location = 1) out vec2 outTexCoord;
|
|
layout(location = 2) out flat vec4 outColor;
|
|
|
|
out gl_PerVertex {
|
|
vec4 gl_Position;
|
|
};
|
|
|
|
vec2 offsets[6] = { vec2(0.0, 0.0),
|
|
vec2(1.0, 0.0),
|
|
vec2(0.0, 1.0),
|
|
vec2(0.0, 1.0),
|
|
vec2(1.0, 0.0),
|
|
vec2(1.0, 1.0) };
|
|
|
|
void main() {
|
|
vec4 rect = clip (inRect);
|
|
vec2 pos = rect.xy + rect.zw * offsets[gl_VertexIndex];
|
|
gl_Position = push.mvp * vec4 (pos, 0.0, 1.0);
|
|
|
|
outPos = pos;
|
|
|
|
vec4 texrect = vec4((rect.xy - inRect.xy) / inRect.zw,
|
|
rect.zw / inRect.zw);
|
|
texrect = vec4(inTexRect.xy + inTexRect.zw * texrect.xy,
|
|
inTexRect.zw * texrect.zw);
|
|
outTexCoord = texrect.xy + texrect.zw * offsets[gl_VertexIndex];
|
|
|
|
outColor = inColor;
|
|
}
|