summaryrefslogtreecommitdiffstats
path: root/gfx/wr/webrender/res/ps_quad.glsl
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
commitd8bbc7858622b6d9c278469aab701ca0b609cddf (patch)
treeeff41dc61d9f714852212739e6b3738b82a2af87 /gfx/wr/webrender/res/ps_quad.glsl
parentReleasing progress-linux version 125.0.3-1~progress7.99u1. (diff)
downloadfirefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz
firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'gfx/wr/webrender/res/ps_quad.glsl')
-rw-r--r--gfx/wr/webrender/res/ps_quad.glsl69
1 files changed, 66 insertions, 3 deletions
diff --git a/gfx/wr/webrender/res/ps_quad.glsl b/gfx/wr/webrender/res/ps_quad.glsl
index 94c80a93f7..3565c28afc 100644
--- a/gfx/wr/webrender/res/ps_quad.glsl
+++ b/gfx/wr/webrender/res/ps_quad.glsl
@@ -25,6 +25,11 @@
/// +-----------------------------+ | device pixel scale | +-----------+--------------+-+-+
/// | content origin |
/// +--------------------+
+///
+/// To use the quad infrastructure, a shader must define the following entry
+/// points in the corresponding shader stages:
+/// - void pattern_vertex(PrimitiveInfo prim)
+/// - vec4 pattern_fragment(vec4 base_color)
///```
#define WR_FEATURE_TEXTURE_2D
@@ -39,6 +44,10 @@ flat varying mediump vec4 v_uv_sample_bounds;
flat varying lowp ivec4 v_flags;
varying highp vec2 v_uv;
+#ifndef SWGL_ANTIALIAS
+varying highp vec2 vLocalPos;
+#endif
+
#ifdef WR_VERTEX_SHADER
#define EDGE_AA_LEFT 1
@@ -73,6 +82,7 @@ struct PrimitiveInfo {
int edge_flags;
int quad_flags;
+ ivec2 pattern_input;
};
struct QuadSegment {
@@ -112,6 +122,7 @@ QuadPrimitive fetch_primitive(int index) {
struct QuadHeader {
int transform_id;
int z_id;
+ ivec2 pattern_input;
};
QuadHeader fetch_header(int address) {
@@ -119,7 +130,8 @@ QuadHeader fetch_header(int address) {
QuadHeader qh = QuadHeader(
header.x,
- header.y
+ header.y,
+ header.zw
);
return qh;
@@ -204,7 +216,11 @@ float edge_aa_offset(int edge, int flags) {
return ((flags & edge) != 0) ? AA_PIXEL_RADIUS : 0.0;
}
-PrimitiveInfo ps_quad_main(void) {
+#ifdef WR_VERTEX_SHADER
+void pattern_vertex(PrimitiveInfo prim);
+#endif
+
+PrimitiveInfo quad_primive_info(void) {
QuadInstance qi = decode_instance();
QuadHeader qh = fetch_header(qi.prim_address_i);
@@ -339,7 +355,54 @@ PrimitiveInfo ps_quad_main(void) {
prim.bounds,
prim.clip,
qi.edge_flags,
- qi.quad_flags
+ qi.quad_flags,
+ qh.pattern_input
);
}
+
+void antialiasing_vertex(PrimitiveInfo prim) {
+#ifndef SWGL_ANTIALIAS
+ // This does the setup that is required for init_tranform_vs.
+ RectWithEndpoint xf_bounds = RectWithEndpoint(
+ max(prim.local_prim_rect.p0, prim.local_clip_rect.p0),
+ min(prim.local_prim_rect.p1, prim.local_clip_rect.p1)
+ );
+ vTransformBounds = vec4(xf_bounds.p0, xf_bounds.p1);
+
+ vLocalPos = prim.local_pos;
+
+ if (prim.edge_flags == 0) {
+ v_flags.x = 0;
+ } else {
+ v_flags.x = 1;
+ }
+#endif
+}
+
+void main() {
+ PrimitiveInfo prim = quad_primive_info();
+ antialiasing_vertex(prim);
+ pattern_vertex(prim);
+}
+#endif
+
+#ifdef WR_FRAGMENT_SHADER
+vec4 pattern_fragment(vec4 base_color);
+
+float antialiasing_fragment() {
+ float alpha = 1.0;
+#ifndef SWGL_ANTIALIAS
+ if (v_flags.x != 0) {
+ alpha = init_transform_fs(vLocalPos);
+ }
+#endif
+ return alpha;
+}
+
+void main() {
+ vec4 base_color = v_color;
+ base_color *= antialiasing_fragment();
+ oFragColor = pattern_fragment(base_color);
+}
+
#endif