diff options
| -rw-r--r-- | include/sway/desktop/fx_renderer.h | 3 | ||||
| -rw-r--r-- | include/sway/desktop/shaders.h | 24 | ||||
| -rw-r--r-- | sway/desktop/fx_renderer.c | 6 | 
3 files changed, 14 insertions, 19 deletions
diff --git a/include/sway/desktop/fx_renderer.h b/include/sway/desktop/fx_renderer.h index 39c1a25b..889d8a82 100644 --- a/include/sway/desktop/fx_renderer.h +++ b/include/sway/desktop/fx_renderer.h @@ -13,8 +13,7 @@ struct gles2_tex_shader {  	GLint alpha;  	GLint pos_attrib;  	GLint tex_attrib; -	GLint width; -	GLint height; +	GLint size;  	GLint position;  	GLint radius;  }; diff --git a/include/sway/desktop/shaders.h b/include/sway/desktop/shaders.h index 4ff9ca42..6a9f8863 100644 --- a/include/sway/desktop/shaders.h +++ b/include/sway/desktop/shaders.h @@ -45,16 +45,15 @@ const GLchar tex_fragment_src_rgba[] =  "uniform sampler2D tex;\n"  "uniform float alpha;\n"  "\n" -"uniform float width;\n" -"uniform float height;\n" +"uniform vec2 size;\n"  "uniform vec2 position;\n"  "uniform float radius;\n"  "\n"  "void main() {\n"  "   gl_FragColor = texture2D(tex, v_texcoord) * alpha;\n" -"   vec2 corner_distance = min(gl_FragCoord.xy - position, position + vec2(width, height) - gl_FragCoord.xy);\n" +"   vec2 corner_distance = min(gl_FragCoord.xy - position, size + position - gl_FragCoord.xy);\n"  "   if (max(corner_distance.x, corner_distance.y) < radius) {\n" -"		float d = radius - distance(corner_distance, vec2(radius, radius));\n" +"		float d = radius - distance(corner_distance, vec2(radius));\n"  "		float smooth = smoothstep(-1.0f, 0.5f, d);\n"  "		gl_FragColor = mix(vec4(0), gl_FragColor, smooth);\n"  "   }\n" @@ -66,38 +65,37 @@ const GLchar tex_fragment_src_rgbx[] =  "uniform sampler2D tex;\n"  "uniform float alpha;\n"  "\n" -"uniform float width;\n" -"uniform float height;\n" +"uniform vec2 size;\n"  "uniform vec2 position;\n"  "uniform float radius;\n"  "\n"  "void main() {\n"  "	gl_FragColor = vec4(texture2D(tex, v_texcoord).rgb, 1.0) * alpha;\n" -"   vec2 corner_distance = min(gl_FragCoord.xy - position, position + vec2(width, height) - gl_FragCoord.xy);\n" +"   vec2 corner_distance = min(gl_FragCoord.xy - position, position + size - gl_FragCoord.xy);\n"  "   if (max(corner_distance.x, corner_distance.y) < radius) {\n" -"		float d = radius - distance(corner_distance, vec2(radius, radius));\n" +"		float d = radius - distance(corner_distance, vec2(radius));\n"  "		float smooth = smoothstep(-1.0f, 0.5f, d);\n"  "		gl_FragColor = mix(vec4(0), gl_FragColor, smooth);\n"  "   }\n"  "}\n";  const GLchar tex_fragment_src_external[] = -"#extension GL_OES_EGL_image_external : require\n\n" +"#extension GL_OES_EGL_image_external : require\n" +"\n"  "precision mediump float;\n"  "varying vec2 v_texcoord;\n"  "uniform samplerExternalOES texture0;\n"  "uniform float alpha;\n"  "\n" -"uniform float width;\n" -"uniform float height;\n" +"uniform vec2 size;\n"  "uniform vec2 position;\n"  "uniform float radius;\n"  "\n"  "void main() {\n"  "	gl_FragColor = texture2D(texture0, v_texcoord) * alpha;\n" -"   vec2 corner_distance = min(gl_FragCoord.xy - position, position + vec2(width, height) - gl_FragCoord.xy);\n" +"   vec2 corner_distance = min(gl_FragCoord.xy - position, position + size - gl_FragCoord.xy);\n"  "   if (max(corner_distance.x, corner_distance.y) < radius) {\n" -"		float d = radius - distance(corner_distance, vec2(radius, radius));\n" +"		float d = radius - distance(corner_distance, vec2(radius));\n"  "		float smooth = smoothstep(-1.0f, 0.5f, d);\n"  "		gl_FragColor = mix(vec4(0), gl_FragColor, smooth);\n"  "   }\n" diff --git a/sway/desktop/fx_renderer.c b/sway/desktop/fx_renderer.c index 6810fa26..90ed8957 100644 --- a/sway/desktop/fx_renderer.c +++ b/sway/desktop/fx_renderer.c @@ -86,8 +86,7 @@ bool init_frag_shader(struct gles2_tex_shader *shader, GLuint prog) {  	shader->alpha = glGetUniformLocation(prog, "alpha");  	shader->pos_attrib = glGetAttribLocation(prog, "pos");  	shader->tex_attrib = glGetAttribLocation(prog, "texcoord"); -	shader->width = glGetUniformLocation(prog, "width"); -	shader->height = glGetUniformLocation(prog, "height"); +	shader->size = glGetUniformLocation(prog, "size");  	shader->position = glGetUniformLocation(prog, "position");  	shader->radius = glGetUniformLocation(prog, "radius");  	return true; @@ -277,8 +276,7 @@ bool fx_render_subtexture_with_matrix(struct fx_renderer *renderer, struct wlr_t  	glUniform1f(shader->alpha, alpha);  	// rounded corners -	glUniform1f(shader->width, dst_box->width); -	glUniform1f(shader->height, dst_box->height); +	glUniform2f(shader->size, dst_box->width, dst_box->height);  	glUniform2f(shader->position, dst_box->x, dst_box->y);  	glUniform1f(shader->radius, radius);  | 
