[gtk/matthiasc/glshader-demo: 3/9] gl: Add some namespacing to the preamble symbols
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/glshader-demo: 3/9] gl: Add some namespacing to the preamble symbols
- Date: Tue, 22 Sep 2020 02:17:57 +0000 (UTC)
commit a70addb8a5dab8be40a854ca1b5f94b523e4af7b
Author: Alexander Larsson <alexl redhat com>
Date: Fri Sep 18 11:35:29 2020 +0200
gl: Add some namespacing to the preamble symbols
This adds a gsk prefix to the stuff in the preamble, as we want to
avoid it conflicting with things in the main shader. Especially once
we start allow some customization of shaders.
gsk/resources/glsl/blend.glsl | 6 ++---
gsk/resources/glsl/blit.glsl | 4 ++--
gsk/resources/glsl/blur.glsl | 8 +++----
gsk/resources/glsl/border.glsl | 30 +++++++++++------------
gsk/resources/glsl/color.glsl | 4 ++--
gsk/resources/glsl/color_matrix.glsl | 4 ++--
gsk/resources/glsl/coloring.glsl | 6 ++---
gsk/resources/glsl/cross_fade.glsl | 6 ++---
gsk/resources/glsl/inset_shadow.glsl | 30 +++++++++++------------
gsk/resources/glsl/linear_gradient.glsl | 12 +++++-----
gsk/resources/glsl/outset_shadow.glsl | 20 ++++++++--------
gsk/resources/glsl/preamble.fs.glsl | 32 ++++++++++++-------------
gsk/resources/glsl/preamble.glsl | 16 ++++++-------
gsk/resources/glsl/preamble.vs.glsl | 14 +++++------
gsk/resources/glsl/radial_gradient.glsl | 16 ++++++-------
gsk/resources/glsl/repeat.glsl | 4 ++--
gsk/resources/glsl/unblurred_outset_shadow.glsl | 30 +++++++++++------------
17 files changed, 121 insertions(+), 121 deletions(-)
---
diff --git a/gsk/resources/glsl/blend.glsl b/gsk/resources/glsl/blend.glsl
index f1e0c49b5e..22323402ac 100644
--- a/gsk/resources/glsl/blend.glsl
+++ b/gsk/resources/glsl/blend.glsl
@@ -267,8 +267,8 @@ luminosity (vec4 Cs, vec4 Cb)
}
void main() {
- vec4 bottom_color = Texture(u_source, vUv);
- vec4 top_color = Texture(u_source2, vUv);
+ vec4 bottom_color = GskTexture(u_source, vUv);
+ vec4 top_color = GskTexture(u_source2, vUv);
vec4 result;
if (u_mode == 0)
@@ -306,5 +306,5 @@ void main() {
else
discard;
- setOutputColor(result * u_alpha);
+ gskSetOutputColor(result * u_alpha);
}
diff --git a/gsk/resources/glsl/blit.glsl b/gsk/resources/glsl/blit.glsl
index 0f9fe10067..f01cd238ec 100644
--- a/gsk/resources/glsl/blit.glsl
+++ b/gsk/resources/glsl/blit.glsl
@@ -7,7 +7,7 @@ void main() {
// FRAGMENT_SHADER:
void main() {
- vec4 diffuse = Texture(u_source, vUv);
+ vec4 diffuse = GskTexture(u_source, vUv);
- setOutputColor(diffuse * u_alpha);
+ gskSetOutputColor(diffuse * u_alpha);
}
diff --git a/gsk/resources/glsl/blur.glsl b/gsk/resources/glsl/blur.glsl
index 13bf588b0e..7cccad2af1 100644
--- a/gsk/resources/glsl/blur.glsl
+++ b/gsk/resources/glsl/blur.glsl
@@ -39,14 +39,14 @@ void main() {
vec3 incrementalGaussian = initial_gaussian;
float coefficientSum = 0.0;
- vec4 sum = Texture(u_source, vUv) * incrementalGaussian.x;
+ vec4 sum = GskTexture(u_source, vUv) * incrementalGaussian.x;
coefficientSum += incrementalGaussian.x;
incrementalGaussian.xy *= incrementalGaussian.yz;
vec2 p = pixel_step;
for (int i = 1; i <= int(pixels_per_side); i++) {
- sum += Texture(u_source, vUv - p) * incrementalGaussian.x;
- sum += Texture(u_source, vUv + p) * incrementalGaussian.x;
+ sum += GskTexture(u_source, vUv - p) * incrementalGaussian.x;
+ sum += GskTexture(u_source, vUv + p) * incrementalGaussian.x;
coefficientSum += 2.0 * incrementalGaussian.x;
incrementalGaussian.xy *= incrementalGaussian.yz;
@@ -54,5 +54,5 @@ void main() {
p += pixel_step;
}
- setOutputColor(sum / coefficientSum);
+ gskSetOutputColor(sum / coefficientSum);
}
diff --git a/gsk/resources/glsl/border.glsl b/gsk/resources/glsl/border.glsl
index d35c60954c..677a0df7cd 100644
--- a/gsk/resources/glsl/border.glsl
+++ b/gsk/resources/glsl/border.glsl
@@ -4,37 +4,37 @@ uniform vec4 u_widths;
uniform vec4[3] u_outline_rect;
_OUT_ vec4 final_color;
-_OUT_ _ROUNDED_RECT_UNIFORM_ transformed_outside_outline;
-_OUT_ _ROUNDED_RECT_UNIFORM_ transformed_inside_outline;
+_OUT_ _GSK_ROUNDED_RECT_UNIFORM_ transformed_outside_outline;
+_OUT_ _GSK_ROUNDED_RECT_UNIFORM_ transformed_inside_outline;
void main() {
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
- final_color = premultiply(u_color) * u_alpha;
+ final_color = gsk_premultiply(u_color) * u_alpha;
- RoundedRect outside = create_rect(u_outline_rect);
- RoundedRect inside = rounded_rect_shrink (outside, u_widths);
+ GskRoundedRect outside = gsk_create_rect(u_outline_rect);
+ GskRoundedRect inside = gsk_rounded_rect_shrink (outside, u_widths);
- rounded_rect_transform(outside, u_modelview);
- rounded_rect_transform(inside, u_modelview);
+ gsk_rounded_rect_transform(outside, u_modelview);
+ gsk_rounded_rect_transform(inside, u_modelview);
- rounded_rect_encode(outside, transformed_outside_outline);
- rounded_rect_encode(inside, transformed_inside_outline);
+ gsk_rounded_rect_encode(outside, transformed_outside_outline);
+ gsk_rounded_rect_encode(inside, transformed_inside_outline);
}
// FRAGMENT_SHADER:
uniform vec4[3] u_outline_rect;
_IN_ vec4 final_color;
-_IN_ _ROUNDED_RECT_UNIFORM_ transformed_outside_outline;
-_IN_ _ROUNDED_RECT_UNIFORM_ transformed_inside_outline;
+_IN_ _GSK_ROUNDED_RECT_UNIFORM_ transformed_outside_outline;
+_IN_ _GSK_ROUNDED_RECT_UNIFORM_ transformed_inside_outline;
void main() {
- vec2 frag = get_frag_coord();
+ vec2 frag = gsk_get_frag_coord();
- float alpha = clamp(rounded_rect_coverage(decode_rect(transformed_outside_outline), frag) -
- rounded_rect_coverage(decode_rect(transformed_inside_outline), frag),
+ float alpha = clamp(gsk_rounded_rect_coverage(gsk_decode_rect(transformed_outside_outline), frag) -
+ gsk_rounded_rect_coverage(gsk_decode_rect(transformed_inside_outline), frag),
0.0, 1.0);
- setOutputColor(final_color * alpha);
+ gskSetOutputColor(final_color * alpha);
}
diff --git a/gsk/resources/glsl/color.glsl b/gsk/resources/glsl/color.glsl
index 3dc2f1dcb7..636456ce0d 100644
--- a/gsk/resources/glsl/color.glsl
+++ b/gsk/resources/glsl/color.glsl
@@ -6,13 +6,13 @@ _OUT_ vec4 final_color;
void main() {
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
- final_color = premultiply(u_color) * u_alpha;
+ final_color = gsk_premultiply(u_color) * u_alpha;
}
// FRAGMENT_SHADER:
_IN_ vec4 final_color;
void main() {
- setOutputColor(final_color);
+ gskSetOutputColor(final_color);
}
diff --git a/gsk/resources/glsl/color_matrix.glsl b/gsk/resources/glsl/color_matrix.glsl
index adaee80abc..79cb36434e 100644
--- a/gsk/resources/glsl/color_matrix.glsl
+++ b/gsk/resources/glsl/color_matrix.glsl
@@ -10,7 +10,7 @@ uniform mat4 u_color_matrix;
uniform vec4 u_color_offset;
void main() {
- vec4 color = Texture(u_source, vUv);
+ vec4 color = GskTexture(u_source, vUv);
// Un-premultilpy
if (color.a != 0.0)
@@ -21,5 +21,5 @@ void main() {
color.rgb *= color.a;
- setOutputColor(color * u_alpha);
+ gskSetOutputColor(color * u_alpha);
}
diff --git a/gsk/resources/glsl/coloring.glsl b/gsk/resources/glsl/coloring.glsl
index 6342ccb890..a675493030 100644
--- a/gsk/resources/glsl/coloring.glsl
+++ b/gsk/resources/glsl/coloring.glsl
@@ -8,7 +8,7 @@ void main() {
vUv = vec2(aUv.x, aUv.y);
- final_color = premultiply(u_color) * u_alpha;
+ final_color = gsk_premultiply(u_color) * u_alpha;
}
// FRAGMENT_SHADER:
@@ -16,7 +16,7 @@ void main() {
_IN_ vec4 final_color;
void main() {
- vec4 diffuse = Texture(u_source, vUv);
+ vec4 diffuse = GskTexture(u_source, vUv);
- setOutputColor(final_color * diffuse.a);
+ gskSetOutputColor(final_color * diffuse.a);
}
diff --git a/gsk/resources/glsl/cross_fade.glsl b/gsk/resources/glsl/cross_fade.glsl
index d3840423fa..f824430f9d 100644
--- a/gsk/resources/glsl/cross_fade.glsl
+++ b/gsk/resources/glsl/cross_fade.glsl
@@ -10,11 +10,11 @@ uniform float u_progress;
uniform sampler2D u_source2;
void main() {
- vec4 source1 = Texture(u_source, vUv); // start child
- vec4 source2 = Texture(u_source2, vUv); // end child
+ vec4 source1 = GskTexture(u_source, vUv); // start child
+ vec4 source2 = GskTexture(u_source2, vUv); // end child
float p_start = (1.0 - u_progress) * u_alpha;
float p_end = u_progress * u_alpha;
vec4 color = (p_start * source1) + (p_end * source2);
- setOutputColor(color);
+ gskSetOutputColor(color);
}
diff --git a/gsk/resources/glsl/inset_shadow.glsl b/gsk/resources/glsl/inset_shadow.glsl
index 5b43779fe8..6047946784 100644
--- a/gsk/resources/glsl/inset_shadow.glsl
+++ b/gsk/resources/glsl/inset_shadow.glsl
@@ -5,8 +5,8 @@ uniform vec2 u_offset;
uniform vec4[3] u_outline_rect;
_OUT_ vec4 final_color;
-_OUT_ _ROUNDED_RECT_UNIFORM_ transformed_outside_outline;
-_OUT_ _ROUNDED_RECT_UNIFORM_ transformed_inside_outline;
+_OUT_ _GSK_ROUNDED_RECT_UNIFORM_ transformed_outside_outline;
+_OUT_ _GSK_ROUNDED_RECT_UNIFORM_ transformed_inside_outline;
void main() {
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
@@ -15,29 +15,29 @@ void main() {
final_color.rgb *= final_color.a;
final_color *= u_alpha;
- RoundedRect outside = create_rect(u_outline_rect);
- RoundedRect inside = rounded_rect_shrink(outside, vec4(u_spread));
+ GskRoundedRect outside = gsk_create_rect(u_outline_rect);
+ GskRoundedRect inside = gsk_rounded_rect_shrink(outside, vec4(u_spread));
- rounded_rect_offset(inside, u_offset);
+ gsk_rounded_rect_offset(inside, u_offset);
- rounded_rect_transform(outside, u_modelview);
- rounded_rect_transform(inside, u_modelview);
+ gsk_rounded_rect_transform(outside, u_modelview);
+ gsk_rounded_rect_transform(inside, u_modelview);
- rounded_rect_encode(outside, transformed_outside_outline);
- rounded_rect_encode(inside, transformed_inside_outline);
+ gsk_rounded_rect_encode(outside, transformed_outside_outline);
+ gsk_rounded_rect_encode(inside, transformed_inside_outline);
}
// FRAGMENT_SHADER:
_IN_ vec4 final_color;
-_IN_ _ROUNDED_RECT_UNIFORM_ transformed_outside_outline;
-_IN_ _ROUNDED_RECT_UNIFORM_ transformed_inside_outline;
+_IN_ _GSK_ROUNDED_RECT_UNIFORM_ transformed_outside_outline;
+_IN_ _GSK_ROUNDED_RECT_UNIFORM_ transformed_inside_outline;
void main() {
- vec2 frag = get_frag_coord();
+ vec2 frag = gsk_get_frag_coord();
- float alpha = clamp(rounded_rect_coverage(decode_rect(transformed_outside_outline), frag) -
- rounded_rect_coverage(decode_rect(transformed_inside_outline), frag),
+ float alpha = clamp(gsk_rounded_rect_coverage(gsk_decode_rect(transformed_outside_outline), frag) -
+ gsk_rounded_rect_coverage(gsk_decode_rect(transformed_inside_outline), frag),
0.0, 1.0);
- setOutputColor(final_color * alpha);
+ gskSetOutputColor(final_color * alpha);
}
diff --git a/gsk/resources/glsl/linear_gradient.glsl b/gsk/resources/glsl/linear_gradient.glsl
index dea01344f0..023475957e 100644
--- a/gsk/resources/glsl/linear_gradient.glsl
+++ b/gsk/resources/glsl/linear_gradient.glsl
@@ -25,10 +25,10 @@ void main() {
for (int i = 0; i < u_num_color_stops; i ++) {
color_offsets[i] = u_color_stops[(i * 5) + 0];
- color_stops[i] = premultiply(vec4(u_color_stops[(i * 5) + 1],
- u_color_stops[(i * 5) + 2],
- u_color_stops[(i * 5) + 3],
- u_color_stops[(i * 5) + 4]));
+ color_stops[i] = gsk_premultiply(vec4(u_color_stops[(i * 5) + 1],
+ u_color_stops[(i * 5) + 2],
+ u_color_stops[(i * 5) + 3],
+ u_color_stops[(i * 5) + 4]));
}
}
@@ -49,7 +49,7 @@ _IN_ float color_offsets[8];
void main() {
// Position relative to startPoint
- vec2 pos = get_frag_coord() - startPoint;
+ vec2 pos = gsk_get_frag_coord() - startPoint;
// Current pixel, projected onto the line between the start point and the end point
// The projection will be relative to the start point!
@@ -66,5 +66,5 @@ void main() {
}
}
- setOutputColor(color * u_alpha);
+ gskSetOutputColor(color * u_alpha);
}
diff --git a/gsk/resources/glsl/outset_shadow.glsl b/gsk/resources/glsl/outset_shadow.glsl
index 2a2a54ec6b..373c650179 100644
--- a/gsk/resources/glsl/outset_shadow.glsl
+++ b/gsk/resources/glsl/outset_shadow.glsl
@@ -3,31 +3,31 @@ uniform vec4 u_color;
uniform vec4[3] u_outline_rect;
_OUT_ vec4 final_color;
-_OUT_ _ROUNDED_RECT_UNIFORM_ transformed_outline;
+_OUT_ _GSK_ROUNDED_RECT_UNIFORM_ transformed_outline;
void main() {
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
vUv = vec2(aUv.x, aUv.y);
- final_color = premultiply(u_color) * u_alpha;
+ final_color = gsk_premultiply(u_color) * u_alpha;
- RoundedRect outline = create_rect(u_outline_rect);
- rounded_rect_transform(outline, u_modelview);
- rounded_rect_encode(outline, transformed_outline);
+ GskRoundedRect outline = gsk_create_rect(u_outline_rect);
+ gsk_rounded_rect_transform(outline, u_modelview);
+ gsk_rounded_rect_encode(outline, transformed_outline);
}
// FRAGMENT_SHADER:
_IN_ vec4 final_color;
-_IN_ _ROUNDED_RECT_UNIFORM_ transformed_outline;
+_IN_ _GSK_ROUNDED_RECT_UNIFORM_ transformed_outline;
void main() {
- vec2 frag = get_frag_coord();
+ vec2 frag = gsk_get_frag_coord();
- float alpha = Texture(u_source, vUv).a;
- alpha *= (1.0 - clamp(rounded_rect_coverage(decode_rect(transformed_outline), frag), 0.0, 1.0));
+ float alpha = GskTexture(u_source, vUv).a;
+ alpha *= (1.0 - clamp(gsk_rounded_rect_coverage(gsk_decode_rect(transformed_outline), frag), 0.0, 1.0));
vec4 color = final_color * alpha;
- setOutputColor(color);
+ gskSetOutputColor(color);
}
diff --git a/gsk/resources/glsl/preamble.fs.glsl b/gsk/resources/glsl/preamble.fs.glsl
index cadbaf1331..85b11c013e 100644
--- a/gsk/resources/glsl/preamble.fs.glsl
+++ b/gsk/resources/glsl/preamble.fs.glsl
@@ -16,17 +16,17 @@ _IN_ vec2 vUv;
-RoundedRect decode_rect(_ROUNDED_RECT_UNIFORM_ r)
+GskRoundedRect gsk_decode_rect(_GSK_ROUNDED_RECT_UNIFORM_ r)
{
#if defined(GSK_GLES) || defined(GSK_LEGACY)
- return RoundedRect(r[0], r[1], r[2]);
+ return GskRoundedRect(r[0], r[1], r[2]);
#else
return r;
#endif
}
float
-ellipsis_dist (vec2 p, vec2 radius)
+gsk_ellipsis_dist (vec2 p, vec2 radius)
{
if (radius == vec2(0, 0))
return 0.0;
@@ -38,14 +38,14 @@ ellipsis_dist (vec2 p, vec2 radius)
}
float
-ellipsis_coverage (vec2 point, vec2 center, vec2 radius)
+gsk_ellipsis_coverage (vec2 point, vec2 center, vec2 radius)
{
- float d = ellipsis_dist (point - center, radius);
+ float d = gsk_ellipsis_dist (point - center, radius);
return clamp (0.5 - d, 0.0, 1.0);
}
float
-rounded_rect_coverage (RoundedRect r, vec2 p)
+gsk_rounded_rect_coverage (GskRoundedRect r, vec2 p)
{
if (p.x < r.bounds.x || p.y < r.bounds.y ||
p.x >= r.bounds.z || p.y >= r.bounds.w)
@@ -61,10 +61,10 @@ rounded_rect_coverage (RoundedRect r, vec2 p)
vec2 ref_br = r.corner_points2.xy;
vec2 ref_bl = r.corner_points2.zw;
- float d_tl = ellipsis_coverage(p, ref_tl, rad_tl);
- float d_tr = ellipsis_coverage(p, ref_tr, rad_tr);
- float d_br = ellipsis_coverage(p, ref_br, rad_br);
- float d_bl = ellipsis_coverage(p, ref_bl, rad_bl);
+ float d_tl = gsk_ellipsis_coverage(p, ref_tl, rad_tl);
+ float d_tr = gsk_ellipsis_coverage(p, ref_tr, rad_tr);
+ float d_br = gsk_ellipsis_coverage(p, ref_br, rad_br);
+ float d_bl = gsk_ellipsis_coverage(p, ref_bl, rad_bl);
vec4 corner_coverages = 1.0 - vec4(d_tl, d_tr, d_br, d_bl);
@@ -76,7 +76,7 @@ rounded_rect_coverage (RoundedRect r, vec2 p)
return 1.0 - dot(vec4(is_out), corner_coverages);
}
-vec4 Texture(sampler2D sampler, vec2 texCoords) {
+vec4 GskTexture(sampler2D sampler, vec2 texCoords) {
#if defined(GSK_GLES) || defined(GSK_LEGACY)
return texture2D(sampler, texCoords);
#else
@@ -88,7 +88,7 @@ vec4 Texture(sampler2D sampler, vec2 texCoords) {
layout(origin_upper_left) in vec4 gl_FragCoord;
#endif
-vec2 get_frag_coord() {
+vec2 gsk_get_frag_coord() {
vec2 fc = gl_FragCoord.xy;
#ifdef GSK_GL3
@@ -101,15 +101,15 @@ vec2 get_frag_coord() {
return fc;
}
-void setOutputColor(vec4 color) {
- vec2 f = get_frag_coord();
+void gskSetOutputColor(vec4 color) {
+ vec2 f = gsk_get_frag_coord();
// We do *NOT* transform the clip rect here since we already
// need to do that on the CPU.
#if defined(GSK_GLES) || defined(GSK_LEGACY)
- gl_FragColor = color * rounded_rect_coverage(create_rect(u_clip_rect), f);
+ gl_FragColor = color * gsk_rounded_rect_coverage(gsk_create_rect(u_clip_rect), f);
#else
- outputColor = color * rounded_rect_coverage(create_rect(u_clip_rect), f);
+ outputColor = color * gsk_rounded_rect_coverage(gsk_create_rect(u_clip_rect), f);
#endif
/*outputColor = color;*/
}
diff --git a/gsk/resources/glsl/preamble.glsl b/gsk/resources/glsl/preamble.glsl
index 013938899a..091438b3b4 100644
--- a/gsk/resources/glsl/preamble.glsl
+++ b/gsk/resources/glsl/preamble.glsl
@@ -5,15 +5,15 @@ precision highp float;
#if defined(GSK_GLES) || defined(GSK_LEGACY)
#define _OUT_ varying
#define _IN_ varying
-#define _ROUNDED_RECT_UNIFORM_ vec4[3]
+#define _GSK_ROUNDED_RECT_UNIFORM_ vec4[3]
#else
#define _OUT_ out
#define _IN_ in
-#define _ROUNDED_RECT_UNIFORM_ RoundedRect
+#define _GSK_ROUNDED_RECT_UNIFORM_ GskRoundedRect
#endif
-struct RoundedRect
+struct GskRoundedRect
{
vec4 bounds;
// Look, arrays can't be in structs if you want to return the struct
@@ -22,9 +22,9 @@ struct RoundedRect
vec4 corner_points2; // xy = bottom right, zw = bottom left
};
-// Transform from a GskRoundedRect to a RoundedRect as we need it.
-RoundedRect
-create_rect(vec4[3] data)
+// Transform from a C GskRoundedRect to what we need.
+GskRoundedRect
+gsk_create_rect(vec4[3] data)
{
vec4 bounds = vec4(data[0].xy, data[0].xy + data[0].zw);
@@ -33,9 +33,9 @@ create_rect(vec4[3] data)
vec4 corner_points2 = vec4(bounds.zw + (data[2].xy * vec2(-1, -1)),
bounds.xw + vec2(data[2].zw * vec2(1, -1)));
- return RoundedRect(bounds, corner_points1, corner_points2);
+ return GskRoundedRect(bounds, corner_points1, corner_points2);
}
-vec4 premultiply(vec4 c) {
+vec4 gsk_premultiply(vec4 c) {
return vec4(c.rgb * c.a, c.a);
}
diff --git a/gsk/resources/glsl/preamble.vs.glsl b/gsk/resources/glsl/preamble.vs.glsl
index 76de2d6561..89ee6f74e0 100644
--- a/gsk/resources/glsl/preamble.vs.glsl
+++ b/gsk/resources/glsl/preamble.vs.glsl
@@ -13,8 +13,8 @@ _OUT_ vec2 vUv;
#endif
// amount is: top, right, bottom, left
-RoundedRect
-rounded_rect_shrink (RoundedRect r, vec4 amount)
+GskRoundedRect
+gsk_rounded_rect_shrink (GskRoundedRect r, vec4 amount)
{
vec4 new_bounds = r.bounds + vec4(1.0,1.0,-1.0,-1.0) * amount.wxyz;
vec4 new_corner_points1 = r.corner_points1;
@@ -25,11 +25,11 @@ rounded_rect_shrink (RoundedRect r, vec4 amount)
if (r.corner_points2.xy == r.bounds.zw) new_corner_points2.xy = new_bounds.zw;
if (r.corner_points2.zw == r.bounds.xw) new_corner_points2.zw = new_bounds.xw;
- return RoundedRect (new_bounds, new_corner_points1, new_corner_points2);
+ return GskRoundedRect (new_bounds, new_corner_points1, new_corner_points2);
}
void
-rounded_rect_offset(inout RoundedRect r, vec2 offset)
+gsk_rounded_rect_offset(inout GskRoundedRect r, vec2 offset)
{
r.bounds.xy += offset;
r.bounds.zw += offset;
@@ -39,7 +39,7 @@ rounded_rect_offset(inout RoundedRect r, vec2 offset)
r.corner_points2.zw += offset;
}
-void rounded_rect_transform(inout RoundedRect r, mat4 mat)
+void gsk_rounded_rect_transform(inout GskRoundedRect r, mat4 mat)
{
r.bounds.xy = (mat * vec4(r.bounds.xy, 0.0, 1.0)).xy;
r.bounds.zw = (mat * vec4(r.bounds.zw, 0.0, 1.0)).xy;
@@ -53,9 +53,9 @@ void rounded_rect_transform(inout RoundedRect r, mat4 mat)
#if defined(GSK_LEGACY)
// Can't have out or inout array parameters...
-#define rounded_rect_encode(r, uni) uni[0] = r.bounds; uni[1] = r.corner_points1; uni[2] = r.corner_points2;
+#define gsk_rounded_rect_encode(r, uni) uni[0] = r.bounds; uni[1] = r.corner_points1; uni[2] =
r.corner_points2;
#else
-void rounded_rect_encode(RoundedRect r, out _ROUNDED_RECT_UNIFORM_ out_r)
+void gsk_rounded_rect_encode(GskRoundedRect r, out _GSK_ROUNDED_RECT_UNIFORM_ out_r)
{
#if defined(GSK_GLES)
out_r[0] = r.bounds;
diff --git a/gsk/resources/glsl/radial_gradient.glsl b/gsk/resources/glsl/radial_gradient.glsl
index 9d8be275b3..abd307508d 100644
--- a/gsk/resources/glsl/radial_gradient.glsl
+++ b/gsk/resources/glsl/radial_gradient.glsl
@@ -21,10 +21,10 @@ void main() {
for (int i = 0; i < u_num_color_stops; i ++) {
color_offsets[i] = u_color_stops[(i * 5) + 0];
- color_stops[i] = premultiply(vec4(u_color_stops[(i * 5) + 1],
- u_color_stops[(i * 5) + 2],
- u_color_stops[(i * 5) + 3],
- u_color_stops[(i * 5) + 4]));
+ color_stops[i] = gsk_premultiply(vec4(u_color_stops[(i * 5) + 1],
+ u_color_stops[(i * 5) + 2],
+ u_color_stops[(i * 5) + 3],
+ u_color_stops[(i * 5) + 4]));
}
}
@@ -51,17 +51,17 @@ float abs_offset(float offset) {
}
void main() {
- vec2 pixel = get_frag_coord();
+ vec2 pixel = gsk_get_frag_coord();
vec2 rel = (center - pixel) / (u_radius);
float d = sqrt(dot(rel, rel));
if (d < abs_offset (color_offsets[0])) {
- setOutputColor(color_stops[0] * u_alpha);
+ gskSetOutputColor(color_stops[0] * u_alpha);
return;
}
if (d > end) {
- setOutputColor(color_stops[u_num_color_stops - 1] * u_alpha);
+ gskSetOutputColor(color_stops[u_num_color_stops - 1] * u_alpha);
return;
}
@@ -80,5 +80,5 @@ void main() {
}
}
- setOutputColor(color * u_alpha);
+ gskSetOutputColor(color * u_alpha);
}
diff --git a/gsk/resources/glsl/repeat.glsl b/gsk/resources/glsl/repeat.glsl
index 4f94ee3506..a9ebcc5e10 100644
--- a/gsk/resources/glsl/repeat.glsl
+++ b/gsk/resources/glsl/repeat.glsl
@@ -35,7 +35,7 @@ void main() {
tp.x = u_texture_rect.x + (wrapped_x * tw);
tp.y = u_texture_rect.y + (wrapped_y * th);
- vec4 diffuse = Texture(u_source, tp);
+ vec4 diffuse = GskTexture(u_source, tp);
- setOutputColor(diffuse * u_alpha);
+ gskSetOutputColor(diffuse * u_alpha);
}
diff --git a/gsk/resources/glsl/unblurred_outset_shadow.glsl b/gsk/resources/glsl/unblurred_outset_shadow.glsl
index a789155b64..fe7ad742d3 100644
--- a/gsk/resources/glsl/unblurred_outset_shadow.glsl
+++ b/gsk/resources/glsl/unblurred_outset_shadow.glsl
@@ -5,8 +5,8 @@ uniform vec2 u_offset;
uniform vec4[3] u_outline_rect;
_OUT_ vec4 final_color;
-_OUT_ _ROUNDED_RECT_UNIFORM_ transformed_outside_outline;
-_OUT_ _ROUNDED_RECT_UNIFORM_ transformed_inside_outline;
+_OUT_ _GSK_ROUNDED_RECT_UNIFORM_ transformed_outside_outline;
+_OUT_ _GSK_ROUNDED_RECT_UNIFORM_ transformed_inside_outline;
void main() {
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
@@ -15,30 +15,30 @@ void main() {
final_color.rgb *= final_color.a;
final_color *= u_alpha;
- RoundedRect inside = create_rect(u_outline_rect);
- RoundedRect outside = rounded_rect_shrink(inside, vec4(- u_spread));
+ GskRoundedRect inside = gsk_create_rect(u_outline_rect);
+ GskRoundedRect outside = gsk_rounded_rect_shrink(inside, vec4(- u_spread));
- rounded_rect_offset(outside, u_offset);
+ gsk_rounded_rect_offset(outside, u_offset);
- rounded_rect_transform(outside, u_modelview);
- rounded_rect_transform(inside, u_modelview);
+ gsk_rounded_rect_transform(outside, u_modelview);
+ gsk_rounded_rect_transform(inside, u_modelview);
- rounded_rect_encode(outside, transformed_outside_outline);
- rounded_rect_encode(inside, transformed_inside_outline);
+ gsk_rounded_rect_encode(outside, transformed_outside_outline);
+ gsk_rounded_rect_encode(inside, transformed_inside_outline);
}
// FRAGMENT_SHADER:
_IN_ vec4 final_color;
-_IN_ _ROUNDED_RECT_UNIFORM_ transformed_outside_outline;
-_IN_ _ROUNDED_RECT_UNIFORM_ transformed_inside_outline;
+_IN_ _GSK_ROUNDED_RECT_UNIFORM_ transformed_outside_outline;
+_IN_ _GSK_ROUNDED_RECT_UNIFORM_ transformed_inside_outline;
void main() {
- vec2 frag = get_frag_coord();
+ vec2 frag = gsk_get_frag_coord();
- float alpha = clamp(rounded_rect_coverage(decode_rect(transformed_outside_outline), frag) -
- rounded_rect_coverage(decode_rect(transformed_inside_outline), frag),
+ float alpha = clamp(gsk_rounded_rect_coverage(gsk_decode_rect(transformed_outside_outline), frag) -
+ gsk_rounded_rect_coverage(gsk_decode_rect(transformed_inside_outline), frag),
0.0, 1.0);
- setOutputColor(final_color * alpha);
+ gskSetOutputColor(final_color * alpha);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]