[gtk/ngl-vertex-attributes: 3/3] Undo the vertex attribute for alpha
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/ngl-vertex-attributes: 3/3] Undo the vertex attribute for alpha
- Date: Fri, 12 Mar 2021 06:01:07 +0000 (UTC)
commit 8bc556b3f10824e5ddf0d1f77be62fc7309667a7
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Mar 12 00:51:04 2021 -0500
Undo the vertex attribute for alpha
Doesn't seem such a great fit for our alpha, which
really changes rarely, and for a whole subtree.
gsk/ngl/gsknglcommandqueue.c | 6 ---
gsk/ngl/gskngldriver.c | 12 ++++-
gsk/ngl/gskngldriverprivate.h | 1 +
gsk/ngl/gsknglrenderjob.c | 69 ++++++++++++--------------
gsk/ngl/gskngltypesprivate.h | 1 -
gsk/ngl/resources/blend.glsl | 6 +--
gsk/ngl/resources/blit.glsl | 6 +--
gsk/ngl/resources/border.glsl | 2 +-
gsk/ngl/resources/color.glsl | 2 +-
gsk/ngl/resources/color_matrix.glsl | 6 +--
gsk/ngl/resources/coloring.glsl | 2 +-
gsk/ngl/resources/conic_gradient.glsl | 9 ++--
gsk/ngl/resources/cross_fade.glsl | 8 +--
gsk/ngl/resources/inset_shadow.glsl | 2 +-
gsk/ngl/resources/linear_gradient.glsl | 10 ++--
gsk/ngl/resources/outset_shadow.glsl | 2 +-
gsk/ngl/resources/preamble.fs.glsl | 3 +-
gsk/ngl/resources/preamble.vs.glsl | 3 +-
gsk/ngl/resources/radial_gradient.glsl | 9 ++--
gsk/ngl/resources/repeat.glsl | 6 +--
gsk/ngl/resources/unblurred_outset_shadow.glsl | 2 +-
21 files changed, 66 insertions(+), 101 deletions(-)
---
diff --git a/gsk/ngl/gsknglcommandqueue.c b/gsk/ngl/gsknglcommandqueue.c
index 5d8ed2e0f8..7d5a8b30be 100644
--- a/gsk/ngl/gsknglcommandqueue.c
+++ b/gsk/ngl/gsknglcommandqueue.c
@@ -1102,12 +1102,6 @@ gsk_ngl_command_queue_execute (GskNglCommandQueue *self,
sizeof (GskNglDrawVertex),
(void *) G_STRUCT_OFFSET (GskNglDrawVertex, color));
- /* 3 = alpha location */
- glEnableVertexAttribArray (3);
- glVertexAttribPointer (3, 1, GL_FLOAT, GL_FALSE,
- sizeof (GskNglDrawVertex),
- (void *) G_STRUCT_OFFSET (GskNglDrawVertex, alpha));
-
/* Setup initial scissor clip */
if (scissor != NULL)
{
diff --git a/gsk/ngl/gskngldriver.c b/gsk/ngl/gskngldriver.c
index 4c3b4567c9..3d910e5d51 100644
--- a/gsk/ngl/gskngldriver.c
+++ b/gsk/ngl/gskngldriver.c
@@ -348,7 +348,6 @@ gsk_ngl_driver_load_programs (GskNglDriver *self,
gsk_ngl_compiler_bind_attribute (compiler, "aPosition", 0);
gsk_ngl_compiler_bind_attribute (compiler, "aUv", 1);
gsk_ngl_compiler_bind_attribute (compiler, "aColor", 2);
- gsk_ngl_compiler_bind_attribute (compiler, "aAlpha", 3);
/* Use XMacros to register all of our programs and their uniforms */
#define GSK_NGL_NO_UNIFORMS
@@ -362,11 +361,13 @@ gsk_ngl_driver_load_programs (GskNglDriver *self,
#define GSK_NGL_COMPILE_PROGRAM(name, uniforms, clip) \
G_STMT_START { \
GskNglProgram *program; \
+ gboolean have_alpha; \
gboolean have_source; \
\
if (!(program = gsk_ngl_compiler_compile (compiler, #name, clip, error))) \
goto failure; \
\
+ have_alpha = gsk_ngl_program_add_uniform (program, "u_alpha", UNIFORM_SHARED_ALPHA); \
have_source = gsk_ngl_program_add_uniform (program, "u_source", UNIFORM_SHARED_SOURCE); \
gsk_ngl_program_add_uniform (program, "u_clip_rect", UNIFORM_SHARED_CLIP_RECT); \
gsk_ngl_program_add_uniform (program, "u_viewport", UNIFORM_SHARED_VIEWPORT); \
@@ -376,6 +377,8 @@ gsk_ngl_driver_load_programs (GskNglDriver *self,
uniforms \
\
gsk_ngl_program_uniforms_added (program, have_source); \
+ if (have_alpha) \
+ gsk_ngl_program_set_uniform1f (program, UNIFORM_SHARED_ALPHA, 0, 1.0f); \
\
*(GskNglProgram **)(((guint8 *)self) + G_STRUCT_OFFSET (GskNglDriver, name)) = \
g_steal_pointer (&program); \
@@ -1043,15 +1046,17 @@ gsk_ngl_driver_lookup_shader (GskNglDriver *self,
gsk_ngl_compiler_bind_attribute (compiler, "aPosition", 0);
gsk_ngl_compiler_bind_attribute (compiler, "aUv", 1);
gsk_ngl_compiler_bind_attribute (compiler, "aColor", 2);
- gsk_ngl_compiler_bind_attribute (compiler, "aAlpha", 3);
if ((program = gsk_ngl_compiler_compile (compiler, NULL, "", error)))
{
+ gboolean have_alpha;
+
gsk_ngl_program_add_uniform (program, "u_source", UNIFORM_SHARED_SOURCE);
gsk_ngl_program_add_uniform (program, "u_clip_rect", UNIFORM_SHARED_CLIP_RECT);
gsk_ngl_program_add_uniform (program, "u_viewport", UNIFORM_SHARED_VIEWPORT);
gsk_ngl_program_add_uniform (program, "u_projection", UNIFORM_SHARED_PROJECTION);
gsk_ngl_program_add_uniform (program, "u_modelview", UNIFORM_SHARED_MODELVIEW);
+ have_alpha = gsk_ngl_program_add_uniform (program, "u_alpha", UNIFORM_SHARED_ALPHA);
gsk_ngl_program_add_uniform (program, "u_size", UNIFORM_CUSTOM_SIZE);
gsk_ngl_program_add_uniform (program, "u_texture1", UNIFORM_CUSTOM_TEXTURE1);
@@ -1073,6 +1078,9 @@ gsk_ngl_driver_lookup_shader (GskNglDriver *self,
gsk_ngl_program_uniforms_added (program, TRUE);
+ if (have_alpha)
+ gsk_ngl_program_set_uniform1f (program, UNIFORM_SHARED_ALPHA, 0, 1.0f);
+
g_hash_table_insert (self->shader_cache, shader, program);
g_object_weak_ref (G_OBJECT (shader),
gsk_ngl_driver_shader_weak_cb,
diff --git a/gsk/ngl/gskngldriverprivate.h b/gsk/ngl/gskngldriverprivate.h
index 87c567d205..c50e112e86 100644
--- a/gsk/ngl/gskngldriverprivate.h
+++ b/gsk/ngl/gskngldriverprivate.h
@@ -29,6 +29,7 @@
G_BEGIN_DECLS
enum {
+ UNIFORM_SHARED_ALPHA,
UNIFORM_SHARED_SOURCE,
UNIFORM_SHARED_CLIP_RECT,
UNIFORM_SHARED_VIEWPORT,
diff --git a/gsk/ngl/gsknglrenderjob.c b/gsk/ngl/gsknglrenderjob.c
index a02319262f..14e3b3e42b 100644
--- a/gsk/ngl/gsknglrenderjob.c
+++ b/gsk/ngl/gsknglrenderjob.c
@@ -391,6 +391,7 @@ gsk_ngl_render_job_set_alpha (GskNglRenderJob *job,
{
float ret = job->alpha;
job->alpha = alpha;
+ job->driver->stamps[UNIFORM_SHARED_ALPHA]++;
return ret;
}
@@ -905,7 +906,6 @@ gsk_ngl_render_job_draw_coords (GskNglRenderJob *job,
vertices[0].color[1] = job->color.green;
vertices[0].color[2] = job->color.blue;
vertices[0].color[3] = job->color.alpha;
- vertices[0].alpha = job->alpha;
vertices[1].position[0] = min_x;
vertices[1].position[1] = max_y;
@@ -915,7 +915,6 @@ gsk_ngl_render_job_draw_coords (GskNglRenderJob *job,
vertices[1].color[1] = job->color.green;
vertices[1].color[2] = job->color.blue;
vertices[1].color[3] = job->color.alpha;
- vertices[1].alpha = job->alpha;
vertices[2].position[0] = max_x;
vertices[2].position[1] = min_y;
@@ -925,7 +924,6 @@ gsk_ngl_render_job_draw_coords (GskNglRenderJob *job,
vertices[2].color[1] = job->color.green;
vertices[2].color[2] = job->color.blue;
vertices[2].color[3] = job->color.alpha;
- vertices[2].alpha = job->alpha;
vertices[3].position[0] = max_x;
vertices[3].position[1] = max_y;
@@ -935,7 +933,6 @@ gsk_ngl_render_job_draw_coords (GskNglRenderJob *job,
vertices[3].color[1] = job->color.green;
vertices[3].color[2] = job->color.blue;
vertices[3].color[3] = job->color.alpha;
- vertices[3].alpha = job->alpha;
vertices[4].position[0] = min_x;
vertices[4].position[1] = max_y;
@@ -945,7 +942,6 @@ gsk_ngl_render_job_draw_coords (GskNglRenderJob *job,
vertices[4].color[1] = job->color.green;
vertices[4].color[2] = job->color.blue;
vertices[4].color[3] = job->color.alpha;
- vertices[4].alpha = job->alpha;
vertices[5].position[0] = max_x;
vertices[5].position[1] = min_y;
@@ -955,7 +951,6 @@ gsk_ngl_render_job_draw_coords (GskNglRenderJob *job,
vertices[5].color[1] = job->color.green;
vertices[5].color[2] = job->color.blue;
vertices[5].color[3] = job->color.alpha;
- vertices[5].alpha = job->alpha;
}
/* load_vertex_data_with_region */
@@ -1056,6 +1051,13 @@ gsk_ngl_render_job_begin_draw (GskNglRenderJob *job,
program->uniform_locations[UNIFORM_SHARED_CLIP_RECT],
job->driver->stamps[UNIFORM_SHARED_CLIP_RECT],
&job->current_clip->rect);
+
+ if (program->uniform_locations[UNIFORM_SHARED_ALPHA] > -1)
+ gsk_ngl_uniform_state_set1f (program->uniforms,
+ program->program_info,
+ program->uniform_locations[UNIFORM_SHARED_ALPHA],
+ job->driver->stamps[UNIFORM_SHARED_ALPHA],
+ job->alpha);
}
#define CHOOSE_PROGRAM(job,name) \
@@ -1738,7 +1740,6 @@ gsk_ngl_render_job_visit_border_node (GskNglRenderJob *job,
float w;
float h;
} sizes[4];
- float a = job->alpha;
/* Top left */
if (widths[3] > 0)
@@ -1793,43 +1794,43 @@ gsk_ngl_render_job_visit_border_node (GskNglRenderJob *job,
const GskNglDrawVertex side_data[4][6] = {
/* Top */
{
- { { min_x, min_y }, { 0, 1 }, { c[0].red, c[0].green, c[0].blue,
c[0].alpha }, a }, /* Upper left */
- { { min_x + sizes[0].w, min_y + sizes[0].h }, { 0, 0 }, { c[0].red, c[0].green, c[0].blue,
c[0].alpha }, a }, /* Lower left */
- { { max_x, min_y }, { 1, 1 }, { c[0].red, c[0].green, c[0].blue,
c[0].alpha }, a }, /* Upper right */
+ { { min_x, min_y }, { 0, 1 }, { c[0].red, c[0].green, c[0].blue,
c[0].alpha } }, /* Upper left */
+ { { min_x + sizes[0].w, min_y + sizes[0].h }, { 0, 0 }, { c[0].red, c[0].green, c[0].blue,
c[0].alpha } }, /* Lower left */
+ { { max_x, min_y }, { 1, 1 }, { c[0].red, c[0].green, c[0].blue,
c[0].alpha } }, /* Upper right */
- { { max_x - sizes[1].w, min_y + sizes[1].h }, { 1, 0 }, { c[0].red, c[0].green, c[0].blue,
c[0].alpha }, a }, /* Lower right */
- { { min_x + sizes[0].w, min_y + sizes[0].h }, { 0, 0 }, { c[0].red, c[0].green, c[0].blue,
c[0].alpha }, a }, /* Lower left */
- { { max_x, min_y }, { 1, 1 }, { c[0].red, c[0].green, c[0].blue,
c[0].alpha }, a }, /* Upper right */
+ { { max_x - sizes[1].w, min_y + sizes[1].h }, { 1, 0 }, { c[0].red, c[0].green, c[0].blue,
c[0].alpha } }, /* Lower right */
+ { { min_x + sizes[0].w, min_y + sizes[0].h }, { 0, 0 }, { c[0].red, c[0].green, c[0].blue,
c[0].alpha } }, /* Lower left */
+ { { max_x, min_y }, { 1, 1 }, { c[0].red, c[0].green, c[0].blue,
c[0].alpha } }, /* Upper right */
},
/* Right */
{
- { { max_x - sizes[1].w, min_y + sizes[1].h }, { 0, 1 }, { c[1].red, c[1].green, c[1].blue,
c[1].alpha }, a }, /* Upper left */
- { { max_x - sizes[2].w, max_y - sizes[2].h }, { 0, 0 }, { c[1].red, c[1].green, c[1].blue,
c[1].alpha }, a }, /* Lower left */
- { { max_x, min_y }, { 1, 1 }, { c[1].red, c[1].green, c[1].blue,
c[1].alpha }, a }, /* Upper right */
+ { { max_x - sizes[1].w, min_y + sizes[1].h }, { 0, 1 }, { c[1].red, c[1].green, c[1].blue,
c[1].alpha } }, /* Upper left */
+ { { max_x - sizes[2].w, max_y - sizes[2].h }, { 0, 0 }, { c[1].red, c[1].green, c[1].blue,
c[1].alpha } }, /* Lower left */
+ { { max_x, min_y }, { 1, 1 }, { c[1].red, c[1].green, c[1].blue,
c[1].alpha } }, /* Upper right */
- { { max_x, max_y }, { 1, 0 }, { c[1].red, c[1].green, c[1].blue,
c[1].alpha }, a }, /* Lower right */
- { { max_x - sizes[2].w, max_y - sizes[2].h }, { 0, 0 }, { c[1].red, c[1].green, c[1].blue,
c[1].alpha }, a }, /* Lower left */
- { { max_x, min_y }, { 1, 1 }, { c[1].red, c[1].green, c[1].blue,
c[1].alpha }, a }, /* Upper right */
+ { { max_x, max_y }, { 1, 0 }, { c[1].red, c[1].green, c[1].blue,
c[1].alpha } }, /* Lower right */
+ { { max_x - sizes[2].w, max_y - sizes[2].h }, { 0, 0 }, { c[1].red, c[1].green, c[1].blue,
c[1].alpha } }, /* Lower left */
+ { { max_x, min_y }, { 1, 1 }, { c[1].red, c[1].green, c[1].blue,
c[1].alpha } }, /* Upper right */
},
/* Bottom */
{
- { { min_x + sizes[3].w, max_y - sizes[3].h }, { 0, 1 }, { c[2].red, c[2].green, c[2].blue,
c[2].alpha }, a }, /* Upper left */
- { { min_x, max_y }, { 0, 0 }, { c[2].red, c[2].green, c[2].blue,
c[2].alpha }, a }, /* Lower left */
- { { max_x - sizes[2].w, max_y - sizes[2].h }, { 1, 1 }, { c[2].red, c[2].green, c[2].blue,
c[2].alpha }, a }, /* Upper right */
+ { { min_x + sizes[3].w, max_y - sizes[3].h }, { 0, 1 }, { c[2].red, c[2].green, c[2].blue,
c[2].alpha } }, /* Upper left */
+ { { min_x, max_y }, { 0, 0 }, { c[2].red, c[2].green, c[2].blue,
c[2].alpha } }, /* Lower left */
+ { { max_x - sizes[2].w, max_y - sizes[2].h }, { 1, 1 }, { c[2].red, c[2].green, c[2].blue,
c[2].alpha } }, /* Upper right */
- { { max_x, max_y }, { 1, 0 }, { c[2].red, c[2].green, c[2].blue,
c[2].alpha }, a }, /* Lower right */
- { { min_x , max_y }, { 0, 0 }, { c[2].red, c[2].green, c[2].blue,
c[2].alpha }, a }, /* Lower left */
- { { max_x - sizes[2].w, max_y - sizes[2].h }, { 1, 1 }, { c[2].red, c[2].green, c[2].blue,
c[2].alpha }, a }, /* Upper right */
+ { { max_x, max_y }, { 1, 0 }, { c[2].red, c[2].green, c[2].blue,
c[2].alpha } }, /* Lower right */
+ { { min_x , max_y }, { 0, 0 }, { c[2].red, c[2].green, c[2].blue,
c[2].alpha } }, /* Lower left */
+ { { max_x - sizes[2].w, max_y - sizes[2].h }, { 1, 1 }, { c[2].red, c[2].green, c[2].blue,
c[2].alpha } }, /* Upper right */
},
/* Left */
{
- { { min_x, min_y }, { 0, 1 }, { c[3].red, c[3].green, c[3].blue,
c[3].alpha }, a }, /* Upper left */
- { { min_x, max_y }, { 0, 0 }, { c[3].red, c[3].green, c[3].blue,
c[3].alpha }, a }, /* Lower left */
- { { min_x + sizes[0].w, min_y + sizes[0].h }, { 1, 1 }, { c[3].red, c[3].green, c[3].blue,
c[3].alpha }, a }, /* Upper right */
+ { { min_x, min_y }, { 0, 1 }, { c[3].red, c[3].green, c[3].blue,
c[3].alpha } }, /* Upper left */
+ { { min_x, max_y }, { 0, 0 }, { c[3].red, c[3].green, c[3].blue,
c[3].alpha } }, /* Lower left */
+ { { min_x + sizes[0].w, min_y + sizes[0].h }, { 1, 1 }, { c[3].red, c[3].green, c[3].blue,
c[3].alpha } }, /* Upper right */
- { { min_x + sizes[3].w, max_y - sizes[3].h }, { 1, 0 }, { c[3].red, c[3].green, c[3].blue,
c[3].alpha }, a }, /* Lower right */
- { { min_x, max_y }, { 0, 0 }, { c[3].red, c[3].green, c[3].blue,
c[3].alpha }, a }, /* Lower left */
- { { min_x + sizes[0].w, min_y + sizes[0].h }, { 1, 1 }, { c[3].red, c[3].green, c[3].blue,
c[3].alpha }, a }, /* Upper right */
+ { { min_x + sizes[3].w, max_y - sizes[3].h }, { 1, 0 }, { c[3].red, c[3].green, c[3].blue,
c[3].alpha } }, /* Lower right */
+ { { min_x, max_y }, { 0, 0 }, { c[3].red, c[3].green, c[3].blue,
c[3].alpha } }, /* Lower left */
+ { { min_x + sizes[0].w, min_y + sizes[0].h }, { 1, 1 }, { c[3].red, c[3].green, c[3].blue,
c[3].alpha } }, /* Upper right */
}
};
GskRoundedRect outline;
@@ -2789,7 +2790,6 @@ gsk_ngl_render_job_visit_text_node (GskNglRenderJob *job,
vertices[base+0].color[1] = color->green;
vertices[base+0].color[2] = color->blue;
vertices[base+0].color[3] = color->alpha;
- vertices[base+0].alpha = job->alpha;
vertices[base+1].position[0] = glyph_x;
vertices[base+1].position[1] = glyph_y2;
@@ -2799,7 +2799,6 @@ gsk_ngl_render_job_visit_text_node (GskNglRenderJob *job,
vertices[base+1].color[1] = color->green;
vertices[base+1].color[2] = color->blue;
vertices[base+1].color[3] = color->alpha;
- vertices[base+1].alpha = job->alpha;
vertices[base+2].position[0] = glyph_x2;
vertices[base+2].position[1] = glyph_y;
@@ -2809,7 +2808,6 @@ gsk_ngl_render_job_visit_text_node (GskNglRenderJob *job,
vertices[base+2].color[1] = color->green;
vertices[base+2].color[2] = color->blue;
vertices[base+2].color[3] = color->alpha;
- vertices[base+2].alpha = job->alpha;
vertices[base+3].position[0] = glyph_x2;
vertices[base+3].position[1] = glyph_y2;
@@ -2819,7 +2817,6 @@ gsk_ngl_render_job_visit_text_node (GskNglRenderJob *job,
vertices[base+3].color[1] = color->green;
vertices[base+3].color[2] = color->blue;
vertices[base+3].color[3] = color->alpha;
- vertices[base+3].alpha = job->alpha;
vertices[base+4].position[0] = glyph_x;
vertices[base+4].position[1] = glyph_y2;
@@ -2829,7 +2826,6 @@ gsk_ngl_render_job_visit_text_node (GskNglRenderJob *job,
vertices[base+4].color[1] = color->green;
vertices[base+4].color[2] = color->blue;
vertices[base+4].color[3] = color->alpha;
- vertices[base+4].alpha = job->alpha;
vertices[base+5].position[0] = glyph_x2;
vertices[base+5].position[1] = glyph_y;
@@ -2839,7 +2835,6 @@ gsk_ngl_render_job_visit_text_node (GskNglRenderJob *job,
vertices[base+5].color[1] = color->green;
vertices[base+5].color[2] = color->blue;
vertices[base+5].color[3] = color->alpha;
- vertices[base+5].alpha = job->alpha;
batch->draw.vbo_count += GSK_NGL_N_VERTICES;
used++;
diff --git a/gsk/ngl/gskngltypesprivate.h b/gsk/ngl/gskngltypesprivate.h
index 39cdbb03c5..dc76fb41f4 100644
--- a/gsk/ngl/gskngltypesprivate.h
+++ b/gsk/ngl/gskngltypesprivate.h
@@ -56,7 +56,6 @@ struct _GskNglDrawVertex
float position[2];
float uv[2];
float color[4];
- float alpha;
};
G_END_DECLS
diff --git a/gsk/ngl/resources/blend.glsl b/gsk/ngl/resources/blend.glsl
index f09fd848d9..51670f8b78 100644
--- a/gsk/ngl/resources/blend.glsl
+++ b/gsk/ngl/resources/blend.glsl
@@ -1,19 +1,15 @@
// VERTEX_SHADER:
-_OUT_ float alpha;
void main() {
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
vUv = vec2(aUv.x, aUv.y);
- alpha = aAlpha;
}
// FRAGMENT_SHADER:
uniform int u_mode;
uniform sampler2D u_source2;
-_IN_ float alpha;
-
float
combine (float source, float backdrop)
{
@@ -311,5 +307,5 @@ void main() {
else
discard;
- gskSetOutputColor(result * alpha);
+ gskSetOutputColor(result * u_alpha);
}
diff --git a/gsk/ngl/resources/blit.glsl b/gsk/ngl/resources/blit.glsl
index 69c4fb1f8f..93416bc6a4 100644
--- a/gsk/ngl/resources/blit.glsl
+++ b/gsk/ngl/resources/blit.glsl
@@ -1,18 +1,14 @@
// VERTEX_SHADER:
-_OUT_ float alpha;
void main() {
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
vUv = vec2(aUv.x, aUv.y);
- alpha = aAlpha;
}
// FRAGMENT_SHADER:
-_IN_ float alpha;
-
void main() {
vec4 diffuse = GskTexture(u_source, vUv);
- gskSetOutputColor(diffuse * alpha);
+ gskSetOutputColor(diffuse * u_alpha);
}
diff --git a/gsk/ngl/resources/border.glsl b/gsk/ngl/resources/border.glsl
index 8f1d09496f..997aeab3da 100644
--- a/gsk/ngl/resources/border.glsl
+++ b/gsk/ngl/resources/border.glsl
@@ -9,7 +9,7 @@ _OUT_ _GSK_ROUNDED_RECT_UNIFORM_ transformed_inside_outline;
void main() {
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
- final_color = gsk_premultiply(aColor) * aAlpha;
+ final_color = gsk_premultiply(aColor) * u_alpha;
GskRoundedRect outside = gsk_create_rect(u_outline_rect);
GskRoundedRect inside = gsk_rounded_rect_shrink (outside, u_widths);
diff --git a/gsk/ngl/resources/color.glsl b/gsk/ngl/resources/color.glsl
index c2c81acef6..5d2370bdf5 100644
--- a/gsk/ngl/resources/color.glsl
+++ b/gsk/ngl/resources/color.glsl
@@ -4,7 +4,7 @@ _OUT_ vec4 final_color;
void main() {
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
- final_color = gsk_premultiply(aColor) * aAlpha;
+ final_color = gsk_premultiply(aColor) * u_alpha;
}
// FRAGMENT_SHADER:
diff --git a/gsk/ngl/resources/color_matrix.glsl b/gsk/ngl/resources/color_matrix.glsl
index 0fa93297e4..06e645b605 100644
--- a/gsk/ngl/resources/color_matrix.glsl
+++ b/gsk/ngl/resources/color_matrix.glsl
@@ -1,19 +1,15 @@
// VERTEX_SHADER:
-_OUT_ float alpha;
void main() {
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
vUv = vec2(aUv.x, aUv.y);
- alpha = aAlpha;
}
// FRAGMENT_SHADER:
uniform mat4 u_color_matrix;
uniform vec4 u_color_offset;
-_IN_ float alpha;
-
void main() {
vec4 color = GskTexture(u_source, vUv);
@@ -26,5 +22,5 @@ void main() {
color.rgb *= color.a;
- gskSetOutputColor(color * alpha);
+ gskSetOutputColor(color * u_alpha);
}
diff --git a/gsk/ngl/resources/coloring.glsl b/gsk/ngl/resources/coloring.glsl
index ed000f3cec..b6af0c1766 100644
--- a/gsk/ngl/resources/coloring.glsl
+++ b/gsk/ngl/resources/coloring.glsl
@@ -6,7 +6,7 @@ void main() {
vUv = vec2(aUv.x, aUv.y);
- final_color = gsk_premultiply(aColor) * aAlpha;
+ final_color = gsk_premultiply(aColor) * u_alpha;
}
// FRAGMENT_SHADER:
diff --git a/gsk/ngl/resources/conic_gradient.glsl b/gsk/ngl/resources/conic_gradient.glsl
index ae1b2a9c18..48a1cf7149 100644
--- a/gsk/ngl/resources/conic_gradient.glsl
+++ b/gsk/ngl/resources/conic_gradient.glsl
@@ -2,7 +2,6 @@
uniform vec4 u_geometry;
_NOPERSPECTIVE_ _OUT_ vec2 coord;
-_OUT_ float alpha;
void main() {
gl_Position = u_projection * (u_modelview * vec4(aPosition, 0.0, 1.0));
@@ -12,7 +11,6 @@ void main() {
vec2 offset = aPosition - u_geometry.xy;
coord = vec2(dot(mv0, offset), dot(mv1, offset));
- alpha = aAlpha;
}
// FRAGMENT_SHADER:
@@ -26,7 +24,6 @@ uniform vec4 u_geometry;
uniform float u_color_stops[6 * 5];
_NOPERSPECTIVE_ _IN_ vec2 coord;
-_IN_ float alpha;
float get_offset(int index) {
return u_color_stops[5 * index];
@@ -51,7 +48,7 @@ void main() {
float offset = fract(angle * u_geometry.z + u_geometry.w);
if (offset < get_offset(0)) {
- gskSetOutputColor(gsk_scaled_premultiply(get_color(0), alpha));
+ gskSetOutputColor(gsk_scaled_premultiply(get_color(0), u_alpha));
return;
}
@@ -66,10 +63,10 @@ void main() {
vec4 next_color = gsk_premultiply(get_color(i + 1));
vec4 color = mix(curr_color, next_color, f);
- gskSetOutputColor(color * alpha);
+ gskSetOutputColor(color * u_alpha);
return;
}
}
- gskSetOutputColor(gsk_scaled_premultiply(get_color(n), alpha));
+ gskSetOutputColor(gsk_scaled_premultiply(get_color(n), u_alpha));
}
diff --git a/gsk/ngl/resources/cross_fade.glsl b/gsk/ngl/resources/cross_fade.glsl
index 6a4544d0e0..dddc44fdd0 100644
--- a/gsk/ngl/resources/cross_fade.glsl
+++ b/gsk/ngl/resources/cross_fade.glsl
@@ -1,25 +1,21 @@
// VERTEX_SHADER:
-_OUT_ float alpha;
void main() {
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
vUv = vec2(aUv.x, aUv.y);
- alpha = aAlpha;
}
// FRAGMENT_SHADER:
uniform float u_progress;
uniform sampler2D u_source2;
-_IN_ float alpha;
-
void main() {
vec4 source1 = GskTexture(u_source, vUv); // start child
vec4 source2 = GskTexture(u_source2, vUv); // end child
- float p_start = (1.0 - u_progress) * alpha;
- float p_end = u_progress * alpha;
+ float p_start = (1.0 - u_progress) * u_alpha;
+ float p_end = u_progress * u_alpha;
vec4 color = (p_start * source1) + (p_end * source2);
gskSetOutputColor(color);
}
diff --git a/gsk/ngl/resources/inset_shadow.glsl b/gsk/ngl/resources/inset_shadow.glsl
index 18e9fce9c7..aae2f2ebef 100644
--- a/gsk/ngl/resources/inset_shadow.glsl
+++ b/gsk/ngl/resources/inset_shadow.glsl
@@ -10,7 +10,7 @@ _OUT_ _GSK_ROUNDED_RECT_UNIFORM_ transformed_inside_outline;
void main() {
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
- final_color = gsk_premultiply(aColor) * aAlpha;
+ final_color = gsk_premultiply(aColor) * u_alpha;
GskRoundedRect outside = gsk_create_rect(u_outline_rect);
GskRoundedRect inside = gsk_rounded_rect_shrink(outside, vec4(u_spread));
diff --git a/gsk/ngl/resources/linear_gradient.glsl b/gsk/ngl/resources/linear_gradient.glsl
index bebd18dfee..cc90392c06 100644
--- a/gsk/ngl/resources/linear_gradient.glsl
+++ b/gsk/ngl/resources/linear_gradient.glsl
@@ -2,7 +2,6 @@
uniform vec4 u_points;
_NOPERSPECTIVE_ _OUT_ vec4 info;
-_OUT_ float alpha;
void main() {
gl_Position = u_projection * (u_modelview * vec4(aPosition, 0.0, 1.0));
@@ -37,8 +36,6 @@ void main() {
float rcp_gradient_length = inversesqrt(dot(gradient, gradient));
info = rcp_gradient_length * vec4(coord, gradient);
-
- alpha = aAlpha;
}
// FRAGMENT_SHADER:
@@ -52,7 +49,6 @@ uniform float u_color_stops[6 * 5];
uniform bool u_repeat;
_NOPERSPECTIVE_ _IN_ vec4 info;
-_IN_ float alpha;
float get_offset(int index) {
return u_color_stops[5 * index];
@@ -75,7 +71,7 @@ void main() {
}
if (offset < get_offset(0)) {
- gskSetOutputColor(gsk_scaled_premultiply(get_color(0), alpha));
+ gskSetOutputColor(gsk_scaled_premultiply(get_color(0), u_alpha));
return;
}
@@ -90,10 +86,10 @@ void main() {
vec4 next_color = gsk_premultiply(get_color(i + 1));
vec4 color = mix(curr_color, next_color, f);
- gskSetOutputColor(color * alpha);
+ gskSetOutputColor(color * u_alpha);
return;
}
}
- gskSetOutputColor(gsk_scaled_premultiply(get_color(n), alpha));
+ gskSetOutputColor(gsk_scaled_premultiply(get_color(n), u_alpha));
}
diff --git a/gsk/ngl/resources/outset_shadow.glsl b/gsk/ngl/resources/outset_shadow.glsl
index bdb62a446f..e8a802e494 100644
--- a/gsk/ngl/resources/outset_shadow.glsl
+++ b/gsk/ngl/resources/outset_shadow.glsl
@@ -9,7 +9,7 @@ void main() {
vUv = vec2(aUv.x, aUv.y);
- final_color = gsk_premultiply(aColor) * aAlpha;
+ final_color = gsk_premultiply(aColor) * u_alpha;
GskRoundedRect outline = gsk_create_rect(u_outline_rect);
gsk_rounded_rect_transform(outline, u_modelview);
diff --git a/gsk/ngl/resources/preamble.fs.glsl b/gsk/ngl/resources/preamble.fs.glsl
index b22fb815ed..e715d2526d 100644
--- a/gsk/ngl/resources/preamble.fs.glsl
+++ b/gsk/ngl/resources/preamble.fs.glsl
@@ -1,6 +1,7 @@
uniform sampler2D u_source;
uniform mat4 u_projection;
uniform mat4 u_modelview;
+uniform float u_alpha;
uniform vec4 u_viewport;
uniform vec4[3] u_clip_rect;
@@ -11,8 +12,6 @@ _OUT_ vec4 outputColor;
#endif
_IN_ vec2 vUv;
-_IN_ float vAlpha;
-
GskRoundedRect gsk_decode_rect(_GSK_ROUNDED_RECT_UNIFORM_ r)
diff --git a/gsk/ngl/resources/preamble.vs.glsl b/gsk/ngl/resources/preamble.vs.glsl
index 5b5d17f249..a549ff6ded 100644
--- a/gsk/ngl/resources/preamble.vs.glsl
+++ b/gsk/ngl/resources/preamble.vs.glsl
@@ -1,17 +1,16 @@
uniform mat4 u_projection;
uniform mat4 u_modelview;
+uniform float u_alpha;
#if defined(GSK_GLES) || defined(GSK_LEGACY)
attribute vec2 aPosition;
attribute vec2 aUv;
attribute vec4 aColor;
-attribute float aAlpha;
_OUT_ vec2 vUv;
#else
_IN_ vec2 aPosition;
_IN_ vec2 aUv;
_IN_ vec4 aColor;
-_IN_ float aAlpha;
_OUT_ vec2 vUv;
#endif
diff --git a/gsk/ngl/resources/radial_gradient.glsl b/gsk/ngl/resources/radial_gradient.glsl
index 4d4a73b01e..0ab3fdf07a 100644
--- a/gsk/ngl/resources/radial_gradient.glsl
+++ b/gsk/ngl/resources/radial_gradient.glsl
@@ -2,7 +2,6 @@
uniform vec4 u_geometry;
_NOPERSPECTIVE_ _OUT_ vec2 coord;
-_OUT_ float alpha;
void main() {
gl_Position = u_projection * (u_modelview * vec4(aPosition, 0.0, 1.0));
@@ -14,7 +13,6 @@ void main() {
dot(mv1, offset));
coord = dir * u_geometry.zw;
- alpha = aAlpha;
}
// FRAGMENT_SHADER:
@@ -29,7 +27,6 @@ uniform vec2 u_range;
uniform float u_color_stops[6 * 5];
_NOPERSPECTIVE_ _IN_ vec2 coord;
-_IN_ float alpha;
float get_offset(int index) {
return u_color_stops[5 * index];
@@ -53,7 +50,7 @@ void main() {
}
if (offset < get_offset(0)) {
- gskSetOutputColor(gsk_scaled_premultiply(get_color(0), alpha));
+ gskSetOutputColor(gsk_scaled_premultiply(get_color(0), u_alpha));
return;
}
@@ -68,10 +65,10 @@ void main() {
vec4 next_color = gsk_premultiply(get_color(i + 1));
vec4 color = mix(curr_color, next_color, f);
- gskSetOutputColor(color * alpha);
+ gskSetOutputColor(color * u_alpha);
return;
}
}
- gskSetOutputColor(gsk_scaled_premultiply(get_color(n), alpha));
+ gskSetOutputColor(gsk_scaled_premultiply(get_color(n), u_alpha));
}
diff --git a/gsk/ngl/resources/repeat.glsl b/gsk/ngl/resources/repeat.glsl
index b226e03a80..654446c70f 100644
--- a/gsk/ngl/resources/repeat.glsl
+++ b/gsk/ngl/resources/repeat.glsl
@@ -1,19 +1,15 @@
// VERTEX_SHADER:
-_OUT_ float alpha;
void main() {
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
vUv = vec2(aUv.x, aUv.y);
- alpha = aAlpha;
}
// FRAGMENT_SHADER:
uniform vec4 u_child_bounds;
uniform vec4 u_texture_rect;
-_IN_ float alpha;
-
float wrap(float f, float wrap_for) {
return mod(f, wrap_for);
}
@@ -41,5 +37,5 @@ void main() {
vec4 diffuse = GskTexture(u_source, tp);
- gskSetOutputColor(diffuse * alpha);
+ gskSetOutputColor(diffuse * u_alpha);
}
diff --git a/gsk/ngl/resources/unblurred_outset_shadow.glsl b/gsk/ngl/resources/unblurred_outset_shadow.glsl
index a59a9381a6..56f0750e6d 100644
--- a/gsk/ngl/resources/unblurred_outset_shadow.glsl
+++ b/gsk/ngl/resources/unblurred_outset_shadow.glsl
@@ -10,7 +10,7 @@ _OUT_ _GSK_ROUNDED_RECT_UNIFORM_ transformed_inside_outline;
void main() {
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
- final_color = gsk_premultiply(aColor) * aAlpha;
+ final_color = gsk_premultiply(aColor) * u_alpha;
GskRoundedRect inside = gsk_create_rect(u_outline_rect);
GskRoundedRect outside = gsk_rounded_rect_shrink(inside, vec4(- u_spread));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]