rendered paste bodyPatch:
From 7b2704987e4cca85e56c41947c38a4bedd8bc0f9 Mon Sep 17 00:00:00 2001
From: Dennis Kasprzyk <onestone@opencompositing.org>
Date: Mon, 25 Jun 2007 14:14:32 +0200
Subject: [PATCH] Added string formating to fragment functions.
---
include/compiz.h | 8 +++++---
src/fragment.c | 43 +++++++++++++++++++++++++++++++++++++++----
2 files changed, 44 insertions(+), 7 deletions(-)
diff --git a/include/compiz.h b/include/compiz.h
index dd34f00..4c66c55 100644
--- a/include/compiz.h
+++ b/include/compiz.h
@@ -26,7 +26,7 @@
#ifndef _COMPIZ_H
#define _COMPIZ_H
-#define ABIVERSION 20070606
+#define ABIVERSION 20070625
#include <stdio.h>
#include <sys/time.h>
@@ -3008,11 +3008,13 @@ addColorOpToFunctionData (CompFunctionData *data,
Bool
addDataOpToFunctionData (CompFunctionData *data,
- char *str);
+ char *str,
+ ...);
Bool
addBlendOpToFunctionData (CompFunctionData *data,
- char *str);
+ char *str,
+ ...);
int
createFragmentFunction (CompScreen *s,
diff --git a/src/fragment.c b/src/fragment.c
index 1c35858..4090c90 100644
--- a/src/fragment.c
+++ b/src/fragment.c
@@ -34,6 +34,8 @@
#define COMP_FUNCTION_ARB_MASK (1 << 0)
#define COMP_FUNCTION_MASK (COMP_FUNCTION_ARB_MASK)
+#define BUFFER_SIZE 1024
+
struct _CompProgram {
struct _CompProgram *next;
@@ -1031,25 +1033,58 @@ addColorOpToFunctionData (CompFunctionData *data,
Bool
addDataOpToFunctionData (CompFunctionData *data,
- char *str)
+ char *str,
+ ...)
{
- int index = data->nBody;
+ int index = data->nBody;
+ int n;
+ char fStr[BUFFER_SIZE];
+ va_list ap;
+
+ va_start (ap, str);
+
+ n = snprintf (fStr, BUFFER_SIZE, str, ap);
+
+ va_end (ap);
+ if (n < 0 || n >= BUFFER_SIZE)
+ {
+ compLogMessage (NULL, "core", CompLogLevelError,
+ "failed to add fragment data operation.");
+ return FALSE;
+ }
if (!allocBodyOpInFunctionData (data))
return FALSE;
data->body[index].type = CompOpTypeData;
- data->body[index].data.data = strdup (str);
+ data->body[index].data.data = strdup (fStr);
return TRUE;
}
Bool
addBlendOpToFunctionData (CompFunctionData *data,
- char *str)
+ char *str,
+ ...)
{
int index = data->nBody;
+ int n;
+ char fStr[BUFFER_SIZE];
+ va_list ap;
+
+ va_start (ap, str);
+ n = snprintf (fStr, BUFFER_SIZE, str, ap);
+
+ va_end (ap);
+
+ if (n < 0 || n >= BUFFER_SIZE)
+ {
+ compLogMessage (NULL, "core", CompLogLevelError,
+ "failed to add fragment blend operation.");
+ return FALSE;
+ }
+
if (!allocBodyOpInFunctionData (data))
return FALSE;
--
1.5.0.5-dirty
Blur code:
Funktioniert:
ok &= addDataOpToFunctionData (data,
"MUL coord, fragment.position, program.env[%d];",
param);
Funktioniert nicht:
ok &= addDataOpToFunctionData (data,
"ADD t0, coord, program.env[%d];"
"TEX s0, t0, texture[%d], %s;"
"SUB t1, coord, program.env[%d];"
"TEX s1, t1, texture[%d], %s;"
"MAD t2, program.env[%d], { -1.0, 1.0, 0.0, 0.0 }, coord;"
"TEX s2, t2, texture[%d], %s;"
"MAD t3, program.env[%d], { 1.0, -1.0, 0.0, 0.0 }, coord;"
"TEX s3, t3, texture[%d], %s;"
"MUL_SAT mask, output.a, program.env[%d];"
"MUL sum, s0, 0.25;"
"MAD sum, s1, 0.25, sum;"
"MAD sum, s2, 0.25, sum;"
"MAD sum, s3, 0.25, sum;",
param + 2, unit, targetString,
param + 2, unit, targetString,
param + 2, unit, targetString,
param + 2, unit, targetString,
param + 1);
Crash:
#2 0x00002aaaab49d556 in crash_handler (sig=11) at crashhandler.c:50
#3 <signal handler called>
#4 0x00002b970d3e8d70 in strlen () from /lib64/libc.so.6
#5 0x00002b970d3ba34f in vfprintf () from /lib64/libc.so.6
#6 0x00002b970d3db74a in vsnprintf () from /lib64/libc.so.6
#7 0x00002b970d3bfc83 in snprintf () from /lib64/libc.so.6
#8 0x0000000000426eb9 in addDataOpToFunctionData (data=0x978330, str=0x7fffa06de2b8 "\002") at fragment.c:1046
#9 0x00002aaaad7ced31 in getDstBlurFragmentFunction (s=0x7c4ae0, texture=<value optimized out>, param=0, unit=1)
at blur.c:1125
#10 0x00002aaaad7cf8cb in blurDrawWindowTexture (w=0x8e5300, texture=0x8e4f40, attrib=<value optimized out>, mask=589824)
at blur.c:2059
#11 0x0000000000421104 in drawWindow (w=0x8e5300, transform=<value optimized out>, fragment=0x7fffa06dfc50,
region=0x8e4fe0, mask=589824) at paint.c:1014
...