From eaf899061aa2bf0222328ece0b3ee28bd941ed04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Thu, 15 Mar 2018 18:07:35 +0100 Subject: [PATCH] gl renderer: Remove shadow program Drawing shadows is the same task as drawing text in our case and these two shaders have been the same thing for quite a while. --- gsk/gl/gskglrenderer.c | 7 +------ gsk/gl/gskglrenderopsprivate.h | 5 +---- gsk/meson.build | 1 - gsk/resources/glsl/coloring.fs.glsl | 3 ++- gsk/resources/glsl/shadow.fs.glsl | 13 ------------- 5 files changed, 4 insertions(+), 25 deletions(-) delete mode 100644 gsk/resources/glsl/shadow.fs.glsl diff --git a/gsk/gl/gskglrenderer.c b/gsk/gl/gskglrenderer.c index b82c2e53c3..f6137b7636 100644 --- a/gsk/gl/gskglrenderer.c +++ b/gsk/gl/gskglrenderer.c @@ -209,7 +209,6 @@ struct _GskGLRenderer Program inset_shadow_program; Program outset_shadow_program; Program unblurred_outset_shadow_program; - Program shadow_program; Program border_program; Program cross_fade_program; }; @@ -1371,7 +1370,7 @@ render_shadow_node (GskGLRenderer *self, shadow_child, &texture_id, &is_offscreen, FALSE, TRUE); ops_offset (builder, dx, dy); - ops_set_program (builder, &self->shadow_program); + ops_set_program (builder, &self->coloring_program); ops_set_color (builder, &shadow->color); ops_set_texture (builder, texture_id); if (is_offscreen) @@ -1755,7 +1754,6 @@ gsk_gl_renderer_create_programs (GskGLRenderer *self, { "inset shadow", "blit.vs.glsl", "inset_shadow.fs.glsl" }, { "outset shadow", "blit.vs.glsl", "outset_shadow.fs.glsl" }, { "unblurred outset shadow", "blit.vs.glsl", "unblurred_outset_shadow.fs.glsl" }, - { "shadow", "blit.vs.glsl", "shadow.fs.glsl" }, { "border", "blit.vs.glsl", "border.fs.glsl" }, { "cross fade", "blit.vs.glsl", "cross_fade.fs.glsl" }, }; @@ -1874,9 +1872,6 @@ gsk_gl_renderer_create_programs (GskGLRenderer *self, INIT_PROGRAM_UNIFORM_LOCATION (unblurred_outset_shadow, corner_widths); INIT_PROGRAM_UNIFORM_LOCATION (unblurred_outset_shadow, corner_heights); - /* shadow */ - INIT_PROGRAM_UNIFORM_LOCATION (shadow, color); - /* border */ INIT_PROGRAM_UNIFORM_LOCATION (border, color); INIT_PROGRAM_UNIFORM_LOCATION (border, widths); diff --git a/gsk/gl/gskglrenderopsprivate.h b/gsk/gl/gskglrenderopsprivate.h index 7d6fe8a821..ddf6b5e311 100644 --- a/gsk/gl/gskglrenderopsprivate.h +++ b/gsk/gl/gskglrenderopsprivate.h @@ -10,7 +10,7 @@ #include "gskglrendererprivate.h" #define GL_N_VERTICES 6 -#define GL_N_PROGRAMS 13 +#define GL_N_PROGRAMS 12 enum { OP_NONE, @@ -63,9 +63,6 @@ typedef struct struct { int color_location; } coloring; - struct { - int color_location; - } shadow; struct { int color_matrix_location; int color_offset_location; diff --git a/gsk/meson.build b/gsk/meson.build index e5a66313d3..0c8b6400ec 100644 --- a/gsk/meson.build +++ b/gsk/meson.build @@ -11,7 +11,6 @@ gsk_private_gl_shaders = [ 'resources/glsl/inset_shadow.fs.glsl', 'resources/glsl/outset_shadow.fs.glsl', 'resources/glsl/unblurred_outset_shadow.fs.glsl', - 'resources/glsl/shadow.fs.glsl', 'resources/glsl/border.fs.glsl', 'resources/glsl/cross_fade.fs.glsl', 'resources/glsl/es2_common.fs.glsl', diff --git a/gsk/resources/glsl/coloring.fs.glsl b/gsk/resources/glsl/coloring.fs.glsl index 7b2e68b4c0..b8aa382eab 100644 --- a/gsk/resources/glsl/coloring.fs.glsl +++ b/gsk/resources/glsl/coloring.fs.glsl @@ -8,6 +8,7 @@ void main() { color.rgb *= color.a; // u_source is drawn using cairo, so already pre-multiplied. + color = vec4(u_color.rgb * diffuse.a * u_alpha, diffuse.a * color.a * u_alpha); - setOutputColor(color * diffuse * u_alpha); + setOutputColor(color); } diff --git a/gsk/resources/glsl/shadow.fs.glsl b/gsk/resources/glsl/shadow.fs.glsl deleted file mode 100644 index 9faab8c45b..0000000000 --- a/gsk/resources/glsl/shadow.fs.glsl +++ /dev/null @@ -1,13 +0,0 @@ -uniform vec4 u_color; - -void main() { - vec4 diffuse = Texture(u_source, vUv); - vec4 color = u_color; - - // pre-multiply - color.rgb *= color.a; - - color = vec4(u_color.rgb * diffuse.a * u_alpha, diffuse.a * color.a * u_alpha); - - setOutputColor(color); -}