[gtk: 2/3] gl: implement clipping for legacy contexts
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk: 2/3] gl: implement clipping for legacy contexts
- Date: Tue, 17 Jul 2018 11:11:37 +0000 (UTC)
commit 19873e549aa3eac61f36c1af2ba6cc5ac8aaebad
Author: Elias Aebi <eyelash users noreply github com>
Date: Sat Jul 14 14:31:50 2018 +0200
gl: implement clipping for legacy contexts
gsk/resources/glsl/gl_common.fs.glsl | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
---
diff --git a/gsk/resources/glsl/gl_common.fs.glsl b/gsk/resources/glsl/gl_common.fs.glsl
index a0b32d11ef..cdac39a353 100644
--- a/gsk/resources/glsl/gl_common.fs.glsl
+++ b/gsk/resources/glsl/gl_common.fs.glsl
@@ -6,6 +6,11 @@ uniform float u_alpha;
uniform int uBlendMode;
uniform vec4 u_viewport;
+// In GtkSnapshot coordinates
+uniform vec4 u_clip;
+uniform vec4 u_clip_corner_widths;
+uniform vec4 u_clip_corner_heights;
+
varying vec2 vUv;
@@ -82,5 +87,16 @@ vec4 Texture(sampler2D sampler, vec2 texCoords) {
}
void setOutputColor(vec4 color) {
- gl_FragColor = color;
+ vec4 clipBounds = u_clip;
+ vec4 f = gl_FragCoord;
+
+ f.x += u_viewport.x;
+ f.y = (u_viewport.y + u_viewport.w) - f.y;
+
+ clipBounds.z = clipBounds.x + clipBounds.z;
+ clipBounds.w = clipBounds.y + clipBounds.w;
+
+ RoundedRect r = RoundedRect(clipBounds, u_clip_corner_widths, u_clip_corner_heights);
+
+ gl_FragColor = color * rounded_rect_coverage(r, f.xy);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]