summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2011-01-19 12:07:17 -0800
committerEric Anholt <eric@anholt.net>2011-01-19 12:07:17 -0800
commit4556fdc69e5f3e59a96436ef10f10c35c9b67b0f (patch)
treef49af610bb9b1f09ec53e434654f26a13497b21f
parentae4fd3818fb9913c572ef7e89005cc3999abef81 (diff)
glsl-gnome-shell-dim-window: Add a shader from gnome-shell that 7.9 broke.g-s-dim-window
Looks like we fixed it in 7.9.1, though.
-rw-r--r--COPYING1
-rw-r--r--tests/all.tests1
-rw-r--r--tests/shaders/glsl-gnome-shell-dim-window.shader_test77
3 files changed, 79 insertions, 0 deletions
diff --git a/COPYING b/COPYING
index 102c97327..3001a809b 100644
--- a/COPYING
+++ b/COPYING
@@ -73,6 +73,7 @@ tests/glslparsertest/glsl2/norsetto-*
tests/glslparsertest/glsl2/xreal-*
tests/glslparsertest/glsl2/xonotic-*
+tests/shaders/glsl-gnome-shell-dim-window.shader_test
/* Full text of the GPL v2 is included in licenses/GPL-2 */
/*
===========================================================================
diff --git a/tests/all.tests b/tests/all.tests
index 4a509502f..9875c7e75 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -487,6 +487,7 @@ add_shader_generic(shaders, 'glsl-fs-vec4-indexing-temp-src-in-nested-loop-outer
add_shader_generic(shaders, 'glsl-fs-vec4-indexing-temp-src-in-nested-loop-combined')
add_shader_generic(shaders, 'glsl-fs-vec4-operator-equal')
add_shader_generic(shaders, 'glsl-fs-vec4-operator-notequal')
+add_shader_generic(shaders, 'glsl-gnome-shell-dim-window')
add_shader_generic(shaders, 'glsl-function-prototype')
add_shader_generic(shaders, 'glsl-if-assign-call')
add_shader_generic(shaders, 'glsl-inout-struct-01')
diff --git a/tests/shaders/glsl-gnome-shell-dim-window.shader_test b/tests/shaders/glsl-gnome-shell-dim-window.shader_test
new file mode 100644
index 000000000..ff1479cce
--- /dev/null
+++ b/tests/shaders/glsl-gnome-shell-dim-window.shader_test
@@ -0,0 +1,77 @@
+[require]
+GLSL >= 1.10
+
+[vertex shader]
+varying vec4 texcoords;
+
+void main()
+{
+ gl_Position = gl_Vertex;
+ texcoords = (gl_Vertex + 1.0) / 2.0;
+}
+
+[fragment shader]
+/* This shader came from gnome-shell, which is GPLv2+. This copyright
+ * notice was constructed from the git logs of that file plus the
+ * top-level COPYING file, as it did not explicitly include the
+ * notice.
+ */
+/*
+ Copyright (C) 2010 Maxim Ermilov <zaspire@rambler.ru>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#version 110
+uniform sampler2D sampler0;
+uniform float fraction;
+uniform float height;
+const float c = -0.5;
+const float border_max_height = 60.0;
+varying vec4 texcoords;
+
+mat4 contrast = mat4(1.0 + c, 0.0, 0.0, 0.0,
+ 0.0, 1.0 + c, 0.0, 0.0,
+ 0.0, 0.0, 1.0 + c, 0.0,
+ 0.0, 0.0, 0.0, 1.0);
+vec4 off = vec4(0.633, 0.633, 0.633, 0);
+
+void main()
+{
+ vec4 color = texture2D(sampler0, texcoords.xy);
+ float y = height * texcoords.y;
+
+ // To reduce contrast, blend with a mid gray
+ gl_FragColor = color * contrast - off * c;
+
+ // We only fully dim at a distance of BORDER_MAX_HEIGHT from the edge and
+ // when the fraction is 1.0. For other locations and fractions we linearly
+ // interpolate back to the original undimmed color.
+ gl_FragColor = color + (gl_FragColor - color) * min(y / border_max_height, 1.0);
+ gl_FragColor = color + (gl_FragColor - color) * fraction;
+}
+
+[test]
+uniform int sampler0 0
+uniform float fraction 1.0
+uniform float height 60.0
+texture rgbw 0 (8, 8)
+draw rect -1 -1 2 2
+relative probe rgb (0.0, 0.0) (1.0, 0.0, 0.0)
+relative probe rgb (1.0, 0.0) (0.0, 1.0, 0.0)
+relative probe rgb (0.0, 0.499) (0.90825, 0.15835, 0.15835)
+relative probe rgb (1.0, 0.499) (0.15835, 0.90825, 0.15835)
+relative probe rgb (0.0, 1.0) (0.3165, 0.3165, 0.8165)
+relative probe rgb (1.0, 1.0) (0.8165, 0.8165, 0.8165)