summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2007-10-23 21:58:57 +0200
committerDanny Baumann <dannybaumann@web.de>2007-10-23 21:58:57 +0200
commitfd64011404a2c9c39b9ea2664e7750619b691423 (patch)
treebccb79e40689d9da5a0b83465d9dd9661ccd284e
parentd0b9afd8f3fdc94afafc640a701621bf76468311 (diff)
downloadfakeargb-fd64011404a2c9c39b9ea2664e7750619b691423.tar.gz
fakeargb-fd64011404a2c9c39b9ea2664e7750619b691423.tar.bz2
Compiz indention style.
-rw-r--r--fakeargb.c403
1 files changed, 213 insertions, 190 deletions
diff --git a/fakeargb.c b/fakeargb.c
index 372abaf..8b69e85 100644
--- a/fakeargb.c
+++ b/fakeargb.c
@@ -26,287 +26,309 @@ static int displayPrivateIndex;
typedef struct _FakeDisplay
{
- int screenPrivateIndex;
+ int screenPrivateIndex;
} FakeDisplay;
typedef struct _FakeScreen
{
- int windowPrivateIndex;
- DrawWindowTextureProc drawWindowTexture;
- int handle;
- Bool black;
+ int windowPrivateIndex;
+
+ DrawWindowTextureProc drawWindowTexture;
+
+ int handle;
+ Bool black;
} FakeScreen;
typedef struct _FakeWindow
{
- Bool isFaked;
+ Bool isFaked;
} FakeWindow;
-#define GET_FAKE_DISPLAY(d) ((FakeDisplay *) (d)->base.privates[displayPrivateIndex].ptr)
-#define FAKE_DISPLAY(d) FakeDisplay *fd = GET_FAKE_DISPLAY (d)
-#define GET_FAKE_SCREEN(s, nd) ((FakeScreen *) (s)->base.privates[(nd)->screenPrivateIndex].ptr)
-#define FAKE_SCREEN(s) FakeScreen *fs = GET_FAKE_SCREEN (s, GET_FAKE_DISPLAY (s->display))
-#define GET_FAKE_WINDOW(w, ns) ((FakeWindow *) (w)->base.privates[(ns)->windowPrivateIndex].ptr)
-#define FAKE_WINDOW(w) FakeWindow *fw = GET_FAKE_WINDOW (w, GET_FAKE_SCREEN (w->screen, GET_FAKE_DISPLAY (w->screen->display)))
+#define GET_FAKE_DISPLAY(d) \
+ ((FakeDisplay *) (d)->base.privates[displayPrivateIndex].ptr)
+#define FAKE_DISPLAY(d) \
+ FakeDisplay *fd = GET_FAKE_DISPLAY (d)
+
+#define GET_FAKE_SCREEN(s, nd) \
+ ((FakeScreen *) (s)->base.privates[(nd)->screenPrivateIndex].ptr)
+#define FAKE_SCREEN(s) \
+ FakeScreen *fs = GET_FAKE_SCREEN (s, GET_FAKE_DISPLAY (s->display))
+
+#define GET_FAKE_WINDOW(w, ns) \
+ ((FakeWindow *) (w)->base.privates[(ns)->windowPrivateIndex].ptr)
+#define FAKE_WINDOW(w) \
+ FakeWindow *fw = GET_FAKE_WINDOW (w, \
+ GET_FAKE_SCREEN (w->screen, \
+ GET_FAKE_DISPLAY (w->screen->display)))
#define NUM_OPTIONS(s) (sizeof ((s)->opt) / sizeof (CompOption))
-static void fakeToggleWindow(CompWindow *w)
+static void
+fakeToggleWindow (CompWindow *w)
{
- FAKE_WINDOW(w);
- FAKE_SCREEN(w->screen);
- if (fs->black)
- fw->isFaked = !fw->isFaked;
- if (fw->isFaked)
- {
- fs->handle = 0;
- fs->black = !fs->black;
- }
- addWindowDamage(w);
+ FAKE_WINDOW (w);
+ FAKE_SCREEN (w->screen);
+
+ if (fs->black)
+ fw->isFaked = !fw->isFaked;
+ if (fw->isFaked)
+ {
+ fs->handle = 0;
+ fs->black = !fs->black;
+ }
+
+ addWindowDamage(w);
}
static Bool
-fakeToggle(CompDisplay * d, CompAction * action, CompActionState state,
- CompOption * option, int nOption)
+fakeToggle (CompDisplay *d,
+ CompAction *action,
+ CompActionState state,
+ CompOption *option,
+ int nOption)
{
- CompWindow *w;
- Window xid;
-
- xid = getIntOptionNamed(option, nOption, "window", 0);
+ CompWindow *w;
+ Window xid;
- w = findWindowAtDisplay(d, xid);
+ xid = getIntOptionNamed (option, nOption, "window", 0);
+ w = findWindowAtDisplay (d, xid);
- if (w)
- fakeToggleWindow(w);
+ if (w)
+ fakeToggleWindow (w);
- return TRUE;
+ return TRUE;
}
static int
-getFakeFragmentFunction (CompScreen *s, CompTexture *texture)
+getFakeFragmentFunction (CompScreen *s,
+ CompTexture *texture)
{
CompFunctionData *data;
+ int target;
FAKE_SCREEN (s);
- int target;
-
- if (texture->target == GL_TEXTURE_2D)
- target = COMP_FETCH_TARGET_2D;
+ if (texture->target == GL_TEXTURE_2D)
+ target = COMP_FETCH_TARGET_2D;
else
- target = COMP_FETCH_TARGET_RECT;
-
+ target = COMP_FETCH_TARGET_RECT;
- if (fs->handle)
- return fs->handle;
+ if (fs->handle)
+ return fs->handle;
data = createFunctionData ();
if (data)
{
- Bool ok = TRUE;
- int handle = 0;
+ Bool ok = TRUE;
+ int handle = 0;
-
- printf("Building shader");
-
- ok &= addTempHeaderOpToFunctionData (data, "neg" );
- ok &= addTempHeaderOpToFunctionData(data, "temp");
+ ok &= addTempHeaderOpToFunctionData (data, "neg" );
+ ok &= addTempHeaderOpToFunctionData(data, "temp");
- ok &= addFetchOpToFunctionData (data, "output", NULL, target);
+ ok &= addFetchOpToFunctionData (data, "output", NULL, target);
+ ok &= addDataOpToFunctionData (data, "RCP neg.a, output.a;");
- ok &= addDataOpToFunctionData (data, "RCP neg.a, output.a;");
-
-
-
- ok &= addDataOpToFunctionData (data, "MUL output.rgb, output.a, output;");
+ ok &= addDataOpToFunctionData (data,
+ "MUL output.rgb, output.a, output;");
- ok &= addDataOpToFunctionData(data, "MOV temp, output;");
+ ok &= addDataOpToFunctionData(data, "MOV temp, output;");
- if (!fs->black)
- ok &= addDataOpToFunctionData(data, "SUB temp.rgb, 1.0, temp;");
+ if (!fs->black)
+ ok &= addDataOpToFunctionData(data, "SUB temp.rgb, 1.0, temp;");
- ok &= addDataOpToFunctionData(data, "ADD output.a, 0, temp.r;");
-
- ok &= addDataOpToFunctionData(data, "ADD output.a, output.a, temp.g;");
- ok &= addDataOpToFunctionData(data, "ADD output.a, output.a, temp.b;");
- ok &= addDataOpToFunctionData(data, "MUL output.a, output.a, 0.33;");
- ok &= addDataOpToFunctionData (data, "MUL output.rgb, output.a, output;");
+ ok &= addDataOpToFunctionData(data, "ADD output.a, 0, temp.r;");
+ ok &= addDataOpToFunctionData(data, "ADD output.a, output.a, temp.g;");
+ ok &= addDataOpToFunctionData(data, "ADD output.a, output.a, temp.b;");
+ ok &= addDataOpToFunctionData(data, "MUL output.a, output.a, 0.33;");
+ ok &= addDataOpToFunctionData (data,
+ "MUL output.rgb, output.a, output;");
- ok &= addColorOpToFunctionData (data, "output", "output");
+ ok &= addColorOpToFunctionData (data, "output", "output");
- if (!ok)
- {
- destroyFunctionData (data);
- return 0;
- }
-
- handle = createFragmentFunction (s, "fake", data);
- fs->handle = handle;
-
-
+ if (!ok)
+ {
+ destroyFunctionData (data);
+ return 0;
+ }
- destroyFunctionData (data);
+ handle = createFragmentFunction (s, "fake", data);
+ fs->handle = handle;
+ destroyFunctionData (data);
- return handle;
+ return handle;
}
return 0;
}
-static void fakeDrawWindowTexture(CompWindow * w,
- CompTexture * texture,
- const FragmentAttrib *attrib,
- unsigned int mask)
+static void
+fakeDrawWindowTexture (CompWindow *w,
+ CompTexture *texture,
+ const FragmentAttrib *attrib,
+ unsigned int mask)
{
- FAKE_SCREEN(w->screen);
- FAKE_WINDOW(w);
- FragmentAttrib fa = *attrib;
+ CompScreen *s = w->screen;
+ FAKE_SCREEN (s);
+ FAKE_WINDOW (w);
- if (fw->isFaked && (texture->name == w->texture->name))
- {
+ if (fw->isFaked && (texture->name == w->texture->name) &&
+ s->fragmentProgram)
+ {
+ FragmentAttrib fa = *attrib;
+ int function;
- if (w->screen->fragmentProgram)
- {
- int function;
- function = getFakeFragmentFunction (w->screen, texture);
- if (function)
- {
- addFragmentFunction (&fa, function);
- }
- UNWRAP(fs, w->screen, drawWindowTexture);
- (*w->screen->drawWindowTexture) (w, texture, &fa, mask);
- WRAP(fs, w->screen, drawWindowTexture, fakeDrawWindowTexture);
- }
- }
-
- else
- {
- UNWRAP(fs, w->screen, drawWindowTexture);
- (*w->screen->drawWindowTexture) (w, texture, &fa, mask);
- WRAP(fs, w->screen, drawWindowTexture, fakeDrawWindowTexture);
- }
+ function = getFakeFragmentFunction (s, texture);
+ if (function)
+ addFragmentFunction (&fa, function);
+
+ UNWRAP (fs, s, drawWindowTexture);
+ (*s->drawWindowTexture) (w, texture, &fa, mask);
+ WRAP (fs, s, drawWindowTexture, fakeDrawWindowTexture);
+ }
+ else
+ {
+ UNWRAP (fs, s, drawWindowTexture);
+ (*s->drawWindowTexture) (w, texture, attrib, mask);
+ WRAP(fs, s, drawWindowTexture, fakeDrawWindowTexture);
+ }
}
-static Bool fakeInitDisplay(CompPlugin * p, CompDisplay * d)
+static Bool
+fakeInitDisplay (CompPlugin *p,
+ CompDisplay *d)
{
- FakeDisplay *fd;
+ FakeDisplay *fd;
- if (!checkPluginABI ("core", CORE_ABIVERSION))
- return FALSE;
+ if (!checkPluginABI ("core", CORE_ABIVERSION))
+ return FALSE;
- fd = malloc(sizeof(FakeDisplay));
- if (!fd)
- return FALSE;
+ fd = malloc (sizeof (FakeDisplay));
+ if (!fd)
+ return FALSE;
- fd->screenPrivateIndex = allocateScreenPrivateIndex(d);
- if (fd->screenPrivateIndex < 0)
- {
- free(fd);
- return FALSE;
- }
+ fd->screenPrivateIndex = allocateScreenPrivateIndex (d);
+ if (fd->screenPrivateIndex < 0)
+ {
+ free (fd);
+ return FALSE;
+ }
- fakeargbSetWindowToggleKeyInitiate(d, fakeToggle);
- fakeargbSetWindowToggleButtonInitiate(d, fakeToggle);
+ fakeargbSetWindowToggleKeyInitiate (d, fakeToggle);
+ fakeargbSetWindowToggleButtonInitiate (d, fakeToggle);
- d->base.privates[displayPrivateIndex].ptr = fd;
+ d->base.privates[displayPrivateIndex].ptr = fd;
- return TRUE;
+ return TRUE;
}
-static void fakeFiniDisplay(CompPlugin * p, CompDisplay * d)
+static void
+fakeFiniDisplay (CompPlugin *p,
+ CompDisplay *d)
{
- FAKE_DISPLAY(d);
- freeScreenPrivateIndex(d, fd->screenPrivateIndex);
- free(fd);
+ FAKE_DISPLAY (d);
+
+ freeScreenPrivateIndex (d, fd->screenPrivateIndex);
+ free (fd);
}
-static Bool fakeInitScreen(CompPlugin * p, CompScreen * s)
+static Bool
+fakeInitScreen (CompPlugin *p,
+ CompScreen *s)
{
- FakeScreen *fs;
+ FakeScreen *fs;
- FAKE_DISPLAY(s->display);
+ FAKE_DISPLAY (s->display);
- fs = malloc(sizeof(FakeScreen));
- if (!fs)
- return FALSE;
+ fs = malloc (sizeof (FakeScreen));
+ if (!fs)
+ return FALSE;
- fs->windowPrivateIndex = allocateWindowPrivateIndex(s);
- if (fs->windowPrivateIndex < 0)
- {
- free(fs);
- return FALSE;
- }
+ fs->windowPrivateIndex = allocateWindowPrivateIndex (s);
+ if (fs->windowPrivateIndex < 0)
+ {
+ free (fs);
+ return FALSE;
+ }
- fs->handle = 0;
+ fs->handle = 0;
- WRAP(fs, s, drawWindowTexture, fakeDrawWindowTexture);
+ WRAP (fs, s, drawWindowTexture, fakeDrawWindowTexture);
- s->base.privates[fd->screenPrivateIndex].ptr = fs;
-
- fs->black = TRUE;
+ s->base.privates[fd->screenPrivateIndex].ptr = fs;
+ fs->black = TRUE;
- return TRUE;
+ return TRUE;
}
-static void fakeFiniScreen(CompPlugin * p, CompScreen * s)
+static void
+fakeFiniScreen (CompPlugin *p,
+ CompScreen *s)
{
- FAKE_SCREEN(s);
- freeWindowPrivateIndex(s, fs->windowPrivateIndex);
- UNWRAP(fs, s, drawWindowTexture);
+ FAKE_SCREEN (s);
+
+ freeWindowPrivateIndex (s, fs->windowPrivateIndex);
+
+ UNWRAP (fs, s, drawWindowTexture);
- free(fs);
+ free (fs);
}
-static Bool fakeInitWindow(CompPlugin * p, CompWindow * w)
+static Bool
+fakeInitWindow (CompPlugin *p,
+ CompWindow *w)
{
- FakeWindow *fw;
+ FakeWindow *fw;
- FAKE_SCREEN(w->screen);
+ FAKE_SCREEN (w->screen);
- fw = malloc(sizeof(FakeWindow));
- if (!fw)
- return FALSE;
+ fw = malloc (sizeof (FakeWindow));
+ if (!fw)
+ return FALSE;
- fw->isFaked = FALSE;
+ fw->isFaked = FALSE;
- w->base.privates[fs->windowPrivateIndex].ptr = fw;
+ w->base.privates[fs->windowPrivateIndex].ptr = fw;
- return TRUE;
+ return TRUE;
}
-static void fakeFiniWindow(CompPlugin * p, CompWindow * w)
+static void
+fakeFiniWindow (CompPlugin *p,
+ CompWindow *w)
{
- FAKE_WINDOW(w);
- free(fw);
+ FAKE_WINDOW (w);
+
+ free (fw);
}
-static Bool fakeInit(CompPlugin * p)
+static Bool
+fakeInit (CompPlugin *p)
{
- displayPrivateIndex = allocateDisplayPrivateIndex();
- if (displayPrivateIndex < 0)
- return FALSE;
+ displayPrivateIndex = allocateDisplayPrivateIndex ();
+ if (displayPrivateIndex < 0)
+ return FALSE;
- return TRUE;
+ return TRUE;
}
-static void fakeFini(CompPlugin * p)
+static void
+fakeFini (CompPlugin *p)
{
- if (displayPrivateIndex >= 0)
- freeDisplayPrivateIndex(displayPrivateIndex);
+ freeDisplayPrivateIndex (displayPrivateIndex);
}
static CompBool
fakeInitObject (CompPlugin *p,
- CompObject *o)
+ CompObject *o)
{
static InitPluginObjectProc dispTab[] = {
- (InitPluginObjectProc) 0, /* InitCore */
- (InitPluginObjectProc) fakeInitDisplay,
- (InitPluginObjectProc) fakeInitScreen,
- (InitPluginObjectProc) fakeInitWindow
+ (InitPluginObjectProc) 0, /* InitCore */
+ (InitPluginObjectProc) fakeInitDisplay,
+ (InitPluginObjectProc) fakeInitScreen,
+ (InitPluginObjectProc) fakeInitWindow
};
RETURN_DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), TRUE, (p, o));
@@ -314,31 +336,32 @@ fakeInitObject (CompPlugin *p,
static void
fakeFiniObject (CompPlugin *p,
- CompObject *o)
+ CompObject *o)
{
static FiniPluginObjectProc dispTab[] = {
- (FiniPluginObjectProc) 0, /* FiniCore */
- (FiniPluginObjectProc) fakeFiniDisplay,
- (FiniPluginObjectProc) fakeFiniScreen,
- (FiniPluginObjectProc) fakeFiniWindow
+ (FiniPluginObjectProc) 0, /* FiniCore */
+ (FiniPluginObjectProc) fakeFiniDisplay,
+ (FiniPluginObjectProc) fakeFiniScreen,
+ (FiniPluginObjectProc) fakeFiniWindow
};
DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), (p, o));
}
CompPluginVTable fakeVTable = {
- "fakeargb",
- 0,
- fakeInit,
- fakeFini,
- fakeInitObject,
- fakeFiniObject,
- 0,
- 0
+ "fakeargb",
+ 0,
+ fakeInit,
+ fakeFini,
+ fakeInitObject,
+ fakeFiniObject,
+ 0,
+ 0
};
-CompPluginVTable *getCompPluginInfo(void)
+CompPluginVTable*
+getCompPluginInfo (void)
{
- return &fakeVTable;
+ return &fakeVTable;
}