[gtk/wip/chergert/glproto] gskglrenderer: First class support of repeating-radial-gradient
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/chergert/glproto] gskglrenderer: First class support of repeating-radial-gradient
- Date: Thu, 28 Jan 2021 01:24:21 +0000 (UTC)
commit 51ed811e4c63121586103f1fa31528672ac8f87b
Author: Fabio Lagalla <lagfabio amazon com>
Date: Tue Jan 26 12:49:16 2021 +0100
gskglrenderer: First class support of repeating-radial-gradient
gsk/gl/gskglrenderer.c | 7 ++++++-
gsk/gl/gskglrenderops.c | 2 ++
gsk/gl/gskglrenderopsprivate.h | 2 ++
gsk/gl/opbuffer.h | 1 +
gsk/resources/glsl/radial_gradient.glsl | 5 +++++
5 files changed, 16 insertions(+), 1 deletion(-)
---
diff --git a/gsk/gl/gskglrenderer.c b/gsk/gl/gskglrenderer.c
index ecd1028a69..b18f8e9efc 100644
--- a/gsk/gl/gskglrenderer.c
+++ b/gsk/gl/gskglrenderer.c
@@ -1486,6 +1486,7 @@ render_radial_gradient_node (GskGLRenderer *self,
ops_set_radial_gradient (builder,
n_color_stops,
stops,
+ gsk_render_node_get_node_type (node) == GSK_REPEATING_RADIAL_GRADIENT_NODE,
builder->dx + center->x,
builder->dy + center->y,
start, end,
@@ -3078,6 +3079,8 @@ apply_radial_gradient_op (const Program *program,
scale = 1.0f / (op->end - op->start);
bias = -op->start * scale;
+
+ glUniform1i (program->radial_gradient.repeat_location, op->repeat);
glUniform2f (program->radial_gradient.range_location, scale, bias);
glUniform4f (program->radial_gradient.geometry_location,
op->center[0], op->center[1],
@@ -3405,6 +3408,7 @@ gsk_gl_renderer_create_programs (GskGLRenderer *self,
/* radial gradient */
INIT_PROGRAM_UNIFORM_LOCATION (radial_gradient, color_stops);
INIT_PROGRAM_UNIFORM_LOCATION (radial_gradient, num_color_stops);
+ INIT_PROGRAM_UNIFORM_LOCATION (radial_gradient, repeat);
INIT_PROGRAM_UNIFORM_LOCATION (radial_gradient, geometry);
INIT_PROGRAM_UNIFORM_LOCATION (radial_gradient, range);
@@ -3763,6 +3767,8 @@ gsk_gl_renderer_add_render_ops (GskGLRenderer *self,
break;
case GSK_RADIAL_GRADIENT_NODE:
+ /* Intentional fall-through */
+ case GSK_REPEATING_RADIAL_GRADIENT_NODE:
render_radial_gradient_node (self, node, builder);
break;
@@ -3829,7 +3835,6 @@ gsk_gl_renderer_add_render_ops (GskGLRenderer *self,
render_gl_shader_node (self, node, builder);
break;
- case GSK_REPEATING_RADIAL_GRADIENT_NODE:
case GSK_CAIRO_NODE:
default:
{
diff --git a/gsk/gl/gskglrenderops.c b/gsk/gl/gskglrenderops.c
index ec14be1e13..ad9518b228 100644
--- a/gsk/gl/gskglrenderops.c
+++ b/gsk/gl/gskglrenderops.c
@@ -924,6 +924,7 @@ void
ops_set_radial_gradient (RenderOpBuilder *self,
guint n_color_stops,
const GskColorStop *color_stops,
+ bool repeat,
float center_x,
float center_y,
float start,
@@ -947,6 +948,7 @@ ops_set_radial_gradient (RenderOpBuilder *self,
op->radius[1] = vradius;
op->start = start;
op->end = end;
+ op->repeat = repeat;
}
void
diff --git a/gsk/gl/gskglrenderopsprivate.h b/gsk/gl/gskglrenderopsprivate.h
index ccc63ab074..d556009d06 100644
--- a/gsk/gl/gskglrenderopsprivate.h
+++ b/gsk/gl/gskglrenderopsprivate.h
@@ -126,6 +126,7 @@ struct _Program
int color_stops_location;
int geometry_location;
int range_location;
+ int repeat_location;
} radial_gradient;
struct {
int num_color_stops_location;
@@ -324,6 +325,7 @@ void ops_set_linear_gradient (RenderOpBuilder *self,
void ops_set_radial_gradient (RenderOpBuilder *self,
guint n_color_stops,
const GskColorStop *color_stops,
+ bool repeat,
float center_x,
float center_y,
float start,
diff --git a/gsk/gl/opbuffer.h b/gsk/gl/opbuffer.h
index 4241214a37..a5c1af9189 100644
--- a/gsk/gl/opbuffer.h
+++ b/gsk/gl/opbuffer.h
@@ -157,6 +157,7 @@ typedef struct
float end;
float radius[2];
float center[2];
+ bool repeat;
} OpRadialGradient;
typedef struct
diff --git a/gsk/resources/glsl/radial_gradient.glsl b/gsk/resources/glsl/radial_gradient.glsl
index 9834a69ba4..0ab3fdf07a 100644
--- a/gsk/resources/glsl/radial_gradient.glsl
+++ b/gsk/resources/glsl/radial_gradient.glsl
@@ -22,6 +22,7 @@ uniform int u_num_color_stops;
uniform highp int u_num_color_stops;
#endif
+uniform bool u_repeat;
uniform vec2 u_range;
uniform float u_color_stops[6 * 5];
@@ -44,6 +45,10 @@ void main() {
// Reverse scale
float offset = length(coord) * u_range.x + u_range.y;
+ if (u_repeat) {
+ offset = fract(offset);
+ }
+
if (offset < get_offset(0)) {
gskSetOutputColor(gsk_scaled_premultiply(get_color(0), u_alpha));
return;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]