summaryrefslogtreecommitdiffstats
path: root/compton.c
diff options
context:
space:
mode:
authorRichard Grenville <[email protected]>2013-04-29 22:42:46 +0800
committerRichard Grenville <[email protected]>2013-04-29 22:42:46 +0800
commite94746bbbb104fd11dec9c0a218b0d8f9f5c9252 (patch)
treea365361e8997728e5127c88c7a6c4a43a3ff07fe /compton.c
parent7f97bf939620124f8f3157e5bf72378bae9cb931 (diff)
downloadtdebase-e94746bbbb104fd11dec9c0a218b0d8f9f5c9252.tar.gz
tdebase-e94746bbbb104fd11dec9c0a218b0d8f9f5c9252.zip
Improvement: Add predefined blur kernels
- Add a few predefined blur kernels, requested by jerri in #104. - Add compton-convgen.py to generate blur kernels.
Diffstat (limited to 'compton.c')
-rw-r--r--compton.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/compton.c b/compton.c
index a97ca17c9..82ee6c714 100644
--- a/compton.c
+++ b/compton.c
@@ -4237,6 +4237,9 @@ usage(void) {
" --blur-background-fixed.\n"
" A 7x7 Guassian blur kernel looks like:\n"
" --blur-kern '7,7,0.000003,0.000102,0.000849,0.001723,0.000849,0.000102,0.000003,0.000102,0.003494,0.029143,0.059106,0.029143,0.003494,0.000102,0.000849,0.029143,0.243117,0.493069,0.243117,0.029143,0.000849,0.001723,0.059106,0.493069,0.493069,0.059106,0.001723,0.000849,0.029143,0.243117,0.493069,0.243117,0.029143,0.000849,0.000102,0.003494,0.029143,0.059106,0.029143,0.003494,0.000102,0.000003,0.000102,0.000849,0.001723,0.000849,0.000102,0.000003'\n"
+ " May also be one the predefined kernels: 3x3box (default), 5x5box,\n"
+ " 7x7box, 3x3gaussian, 5x5gaussian, 7x7gaussian, 9x9gaussian,\n"
+ " 11x11gaussian.\n"
"--blur-background-exclude condition\n"
" Exclude conditions for background blur.\n"
"--resize-damage integer\n"
@@ -4590,6 +4593,31 @@ parse_matrix_err:
}
/**
+ * Parse a convolution kernel.
+ */
+static inline XFixed *
+parse_conv_kern(session_t *ps, const char *src) {
+ static const struct {
+ const char *name;
+ const char *kern_str;
+ } CONV_KERN_PREDEF[] = {
+ { "3x3box", "3,3,1,1,1,1,1,1,1,1," },
+ { "5x5box", "5,5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1," },
+ { "7x7box", "7,7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1," },
+ { "3x3gaussian", "3,3,0.243117,0.493069,0.243117,0.493069,0.493069,0.243117,0.493069,0.243117," },
+ { "5x5gaussian", "5,5,0.003493,0.029143,0.059106,0.029143,0.003493,0.029143,0.243117,0.493069,0.243117,0.029143,0.059106,0.493069,0.493069,0.059106,0.029143,0.243117,0.493069,0.243117,0.029143,0.003493,0.029143,0.059106,0.029143,0.003493," },
+ { "7x7gaussian", "7,7,0.000003,0.000102,0.000849,0.001723,0.000849,0.000102,0.000003,0.000102,0.003493,0.029143,0.059106,0.029143,0.003493,0.000102,0.000849,0.029143,0.243117,0.493069,0.243117,0.029143,0.000849,0.001723,0.059106,0.493069,0.493069,0.059106,0.001723,0.000849,0.029143,0.243117,0.493069,0.243117,0.029143,0.000849,0.000102,0.003493,0.029143,0.059106,0.029143,0.003493,0.000102,0.000003,0.000102,0.000849,0.001723,0.000849,0.000102,0.000003," },
+ { "9x9gaussian", "9,9,0.000000,0.000000,0.000001,0.000006,0.000012,0.000006,0.000001,0.000000,0.000000,0.000000,0.000003,0.000102,0.000849,0.001723,0.000849,0.000102,0.000003,0.000000,0.000001,0.000102,0.003493,0.029143,0.059106,0.029143,0.003493,0.000102,0.000001,0.000006,0.000849,0.029143,0.243117,0.493069,0.243117,0.029143,0.000849,0.000006,0.000012,0.001723,0.059106,0.493069,0.493069,0.059106,0.001723,0.000012,0.000006,0.000849,0.029143,0.243117,0.493069,0.243117,0.029143,0.000849,0.000006,0.000001,0.000102,0.003493,0.029143,0.059106,0.029143,0.003493,0.000102,0.000001,0.000000,0.000003,0.000102,0.000849,0.001723,0.000849,0.000102,0.000003,0.000000,0.000000,0.000000,0.000001,0.000006,0.000012,0.000006,0.000001,0.000000,0.000000," },
+ { "11x11gaussian", "11,11,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000001,0.000006,0.000012,0.000006,0.000001,0.000000,0.000000,0.000000,0.000000,0.000000,0.000003,0.000102,0.000849,0.001723,0.000849,0.000102,0.000003,0.000000,0.000000,0.000000,0.000001,0.000102,0.003493,0.029143,0.059106,0.029143,0.003493,0.000102,0.000001,0.000000,0.000000,0.000006,0.000849,0.029143,0.243117,0.493069,0.243117,0.029143,0.000849,0.000006,0.000000,0.000000,0.000012,0.001723,0.059106,0.493069,0.493069,0.059106,0.001723,0.000012,0.000000,0.000000,0.000006,0.000849,0.029143,0.243117,0.493069,0.243117,0.029143,0.000849,0.000006,0.000000,0.000000,0.000001,0.000102,0.003493,0.029143,0.059106,0.029143,0.003493,0.000102,0.000001,0.000000,0.000000,0.000000,0.000003,0.000102,0.000849,0.001723,0.000849,0.000102,0.000003,0.000000,0.000000,0.000000,0.000000,0.000000,0.000001,0.000006,0.000012,0.000006,0.000001,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000," },
+ };
+ for (int i = 0;
+ i < sizeof(CONV_KERN_PREDEF) / sizeof(CONV_KERN_PREDEF[0]); ++i)
+ if (!strcmp(CONV_KERN_PREDEF[i].name, src))
+ return parse_matrix(ps, CONV_KERN_PREDEF[i].kern_str);
+ return parse_matrix(ps, src);
+}
+
+/**
* Parse a condition list in configuration file.
*/
static inline void
@@ -5097,7 +5125,7 @@ get_cfg(session_t *ps, int argc, char *const *argv, bool first_pass) {
case 301:
// --blur-kern
free(ps->o.blur_kern);
- if (!(ps->o.blur_kern = parse_matrix(ps, optarg)))
+ if (!(ps->o.blur_kern = parse_conv_kern(ps, optarg)))
exit(1);
case 302:
// --resize-damage