summaryrefslogtreecommitdiff
path: root/beryl-plugins/src/neg.c
diff options
context:
space:
mode:
authoronestone <onestone@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2007-02-12 17:07:37 +0000
committeronestone <onestone@d7aaf104-2d23-0410-ae22-9d23157bf5a3>2007-02-12 17:07:37 +0000
commitb8b22c765d21af3f1ea707b0d210c03549b759f4 (patch)
treeb3a4a5349c6ea0981210b3e5091ee81ff6f4d142 /beryl-plugins/src/neg.c
parent35ea22ddb468d9ee728d5bbb7e028f7e12efe945 (diff)
downloadmarex-dev-b8b22c765d21af3f1ea707b0d210c03549b759f4.tar.gz
marex-dev-b8b22c765d21af3f1ea707b0d210c03549b759f4.tar.bz2
beryl-plugins: neg: use fragment system if available (=correct negation of argb windows)
git-svn-id: file:///beryl/trunk@3997 d7aaf104-2d23-0410-ae22-9d23157bf5a3
Diffstat (limited to 'beryl-plugins/src/neg.c')
-rw-r--r--beryl-plugins/src/neg.c523
1 files changed, 310 insertions, 213 deletions
diff --git a/beryl-plugins/src/neg.c b/beryl-plugins/src/neg.c
index 2756abc..f0f4a50 100644
--- a/beryl-plugins/src/neg.c
+++ b/beryl-plugins/src/neg.c
@@ -79,6 +79,8 @@ typedef struct _NEGSCreen
DrawWindowTextureProc drawWindowTexture; /* function pointer */
DamageWindowRectProc damageWindowRect; /* function pointer */
Bool isNeg; /* negative screen flag */
+ int negFunction;
+ int negAlphaFunction;
unsigned int excludeWMask;
} NEGScreen;
@@ -176,10 +178,83 @@ negToggleAll(CompDisplay * d, CompAction * action, CompActionState state,
return TRUE;
}
+
+static int
+getNegFragmentFunction (CompScreen *s, CompTexture *texture, Bool alpha)
+{
+ CompFunctionData *data;
+
+ NEG_SCREEN (s);
+
+ int target;
+
+ if (texture->target == GL_TEXTURE_2D)
+ target = COMP_FETCH_TARGET_2D;
+ else
+ target = COMP_FETCH_TARGET_RECT;
+
+ if (alpha)
+ {
+ if (ns->negAlphaFunction)
+ return ns->negAlphaFunction;
+ }
+ else
+ {
+ if (ns->negFunction)
+ return ns->negFunction;
+ }
+
+
+ data = createFunctionData ();
+ if (data)
+ {
+ Bool ok = TRUE;
+ int handle = 0;
+ printf("Using Data\n");
+
+ if (alpha)
+ {
+ ok &= addTempHeaderOpToFunctionData (data, "neg" );
+ }
+
+ ok &= addFetchOpToFunctionData (data, "output", NULL, target);
+ if (alpha)
+ {
+ ok &= addDataOpToFunctionData (data, "RCP neg.a, output.a;");
+ ok &= addDataOpToFunctionData (data, "MUL output.rgb, neg.a, output;");
+ }
+ ok &= addDataOpToFunctionData (data, "SUB output.rgb, 1.0, output;");
+ if (alpha)
+ {
+ ok &= addDataOpToFunctionData (data, "MUL output.rgb, output.a, output;");
+ }
+ ok &= addColorOpToFunctionData (data, "output", "output");
+
+ if (!ok)
+ {
+ destroyFunctionData (data);
+ return 0;
+ }
+
+ handle = createFragmentFunction (s, "neg", data);
+
+ if (alpha)
+ ns->negAlphaFunction = handle;
+ else
+ ns->negFunction = handle;
+
+ destroyFunctionData (data);
+
+ return handle;
+ }
+
+ return 0;
+}
+
static void
NEGDrawWindowTexture(CompWindow * w,
CompTexture * texture,
- const WindowPaintAttrib * attrib,
+ const WindowPaintAttrib * attrib,
const FragmentAttrib *fAttrib,
unsigned int mask)
{
@@ -193,166 +268,217 @@ NEGDrawWindowTexture(CompWindow * w,
*/
if (nw->isNeg && !(mask & PAINT_WINDOW_DECORATION_MASK))
{
-
- /* this is for the most part taken from paint.c */
-
- /* push the current matrix */
- glPushMatrix();
-
- /* we need this to handle windows that are not regular, like during scale */
- if (mask & PAINT_WINDOW_TRANSFORMED_MASK)
+ if (w->screen->fragmentProgram)
{
- glTranslatef(w->attrib.x, w->attrib.y, 0.0f);
- glScalef(attrib->xScale, attrib->yScale, 0.0f);
- glTranslatef(attrib->xTranslate / attrib->xScale -
- w->attrib.x,
- attrib->yTranslate / attrib->yScale -
- w->attrib.y, 0.0f);
-
- filter = w->screen->filter[WINDOW_TRANS_FILTER];
- }
- else if (mask & PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK)
- {
- filter = w->screen->filter[SCREEN_TRANS_FILTER];
+ FragmentAttrib fa = *fAttrib;
+ int function;
+ function = getNegFragmentFunction (w->screen, texture, w->alpha);
+ if (function)
+ {
+ addFragmentFunction (&fa, function);
+ }
+ UNWRAP(ns, w->screen, drawWindowTexture);
+ (*w->screen->drawWindowTexture) (w, texture, attrib, &fa, mask);
+ WRAP(ns, w->screen, drawWindowTexture, NEGDrawWindowTexture);
}
else
{
- filter = w->screen->filter[NOTHING_TRANS_FILTER];
- }
-
- /* if we can addjust saturation, even if it's just on and off */
- if (w->screen->canDoSaturated && attrib->saturation != COLOR)
- {
- GLfloat constant[4];
-
- /* if the paint mask has this set we want to blend */
- if (mask & PAINT_WINDOW_TRANSLUCENT_MASK)
- glEnable(GL_BLEND);
+ /* this is for the most part taken from paint.c */
- /* enable the texture */
- enableTexture(w->screen, texture, filter);
+ /* push the current matrix */
+ glPushMatrix();
- /* texture combiner */
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
-
- glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE);
- glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE);
- glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR);
- glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE2_RGB, GL_PRIMARY_COLOR);
- glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_ONE_MINUS_SRC_COLOR); /* negate */
- glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
- glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_ALPHA);
-
- glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
- glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE);
- glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
+ /* we need this to handle windows that are not regular, like during scale */
+ if (mask & PAINT_WINDOW_TRANSFORMED_MASK)
+ {
+ glTranslatef(w->attrib.x, w->attrib.y, 0.0f);
+ glScalef(attrib->xScale, attrib->yScale, 0.0f);
+ glTranslatef(attrib->xTranslate / attrib->xScale -
+ w->attrib.x,
+ attrib->yTranslate / attrib->yScale -
+ w->attrib.y, 0.0f);
+
+ filter = w->screen->filter[WINDOW_TRANS_FILTER];
+ }
+ else if (mask & PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK)
+ {
+ filter = w->screen->filter[SCREEN_TRANS_FILTER];
+ }
+ else
+ {
+ filter = w->screen->filter[NOTHING_TRANS_FILTER];
+ }
- glColor4f(1.0f, 1.0f, 1.0f, 0.5f);
+ /* if we can addjust saturation, even if it's just on and off */
+ if (w->screen->canDoSaturated && attrib->saturation != COLOR)
+ {
+ GLfloat constant[4];
- /* make another texture active */
- w->screen->activeTexture(GL_TEXTURE1_ARB);
+ /* if the paint mask has this set we want to blend */
+ if (mask & PAINT_WINDOW_TRANSLUCENT_MASK)
+ glEnable(GL_BLEND);
- /* enable that texture */
- enableTexture(w->screen, texture, filter);
+ /* enable the texture */
+ enableTexture(w->screen, texture, filter);
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
+ /* texture combiner */
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
- glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_DOT3_RGB);
- glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PREVIOUS);
- glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_CONSTANT);
- glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
- glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
+ glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE);
+ glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE);
+ glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR);
+ glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE2_RGB, GL_PRIMARY_COLOR);
+ glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_ONE_MINUS_SRC_COLOR); /* negate */
+ glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
+ glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_ALPHA);
- /* if we can do saturation that is in between min and max */
- if (w->screen->canDoSlightlySaturated && attrib->saturation > 0)
- {
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
- glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS);
+ glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE);
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
- constant[0] = 0.5f + 0.5f * RED_SATURATION_WEIGHT;
- constant[1] = 0.5f + 0.5f * GREEN_SATURATION_WEIGHT;
- constant[2] = 0.5f + 0.5f * BLUE_SATURATION_WEIGHT;
- constant[3] = 1.0;
-
- glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constant);
+ glColor4f(1.0f, 1.0f, 1.0f, 0.5f);
- /* mack another texture active */
- w->screen->activeTexture(GL_TEXTURE2_ARB);
+ /* make another texture active */
+ w->screen->activeTexture(GL_TEXTURE1_ARB);
/* enable that texture */
enableTexture(w->screen, texture, filter);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
- glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE);
- glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0);
- glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PREVIOUS);
- glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE2_RGB, GL_CONSTANT);
- glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_ONE_MINUS_SRC_COLOR); /* negate */
+ glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_DOT3_RGB);
+ glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PREVIOUS);
+ glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_CONSTANT);
+ glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
- glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_ALPHA);
- glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
- glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS);
- glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
+ /* if we can do saturation that is in between min and max */
+ if (w->screen->canDoSlightlySaturated && attrib->saturation > 0)
+ {
+ glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
+ glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS);
+ glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
- /* color constant */
- constant[3] = attrib->saturation / 65535.0f;
+ constant[0] = 0.5f + 0.5f * RED_SATURATION_WEIGHT;
+ constant[1] = 0.5f + 0.5f * GREEN_SATURATION_WEIGHT;
+ constant[2] = 0.5f + 0.5f * BLUE_SATURATION_WEIGHT;
+ constant[3] = 1.0;
- glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constant);
+ glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constant);
- /* if we are not opaque or not fully bright */
- if (attrib->opacity < OPAQUE || attrib->brightness != BRIGHT)
- {
- /* activate a new texture */
- w->screen->activeTexture(GL_TEXTURE3_ARB);
+ /* mack another texture active */
+ w->screen->activeTexture(GL_TEXTURE2_ARB);
/* enable that texture */
enableTexture(w->screen, texture, filter);
- /* color constant */
- constant[3] = attrib->opacity / 65535.0f;
- constant[0] = constant[1] =
- constant[2] =
- constant[3] * attrib->brightness / 65535.0f;
-
- glTexEnvfv(GL_TEXTURE_ENV,
- GL_TEXTURE_ENV_COLOR, constant);
-
- glTexEnvf(GL_TEXTURE_ENV,
- GL_TEXTURE_ENV_MODE, GL_COMBINE);
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
- glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
- glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PREVIOUS);
- glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_CONSTANT);
- glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
+ glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE);
+ glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0);
+ glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PREVIOUS);
+ glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE2_RGB, GL_CONSTANT);
+ glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_ONE_MINUS_SRC_COLOR); /* negate */
glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
+ glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_ALPHA);
- glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
+ glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS);
- glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_CONSTANT);
- glTexEnvf(GL_TEXTURE_ENV,
- GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
- glTexEnvf(GL_TEXTURE_ENV,
- GL_OPERAND1_ALPHA, GL_SRC_ALPHA);
+ glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
- /* draw the window geometry */
- (*w->screen->drawWindowGeometry) (w);
+ /* color constant */
+ constant[3] = attrib->saturation / 65535.0f;
+
+ glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constant);
+
+ /* if we are not opaque or not fully bright */
+ if (attrib->opacity < OPAQUE || attrib->brightness != BRIGHT)
+ {
+ /* activate a new texture */
+ w->screen->activeTexture(GL_TEXTURE3_ARB);
+
+ /* enable that texture */
+ enableTexture(w->screen, texture, filter);
+
+ /* color constant */
+ constant[3] = attrib->opacity / 65535.0f;
+ constant[0] = constant[1] =
+ constant[2] =
+ constant[3] * attrib->brightness / 65535.0f;
+
+ glTexEnvfv(GL_TEXTURE_ENV,
+ GL_TEXTURE_ENV_COLOR, constant);
+
+ glTexEnvf(GL_TEXTURE_ENV,
+ GL_TEXTURE_ENV_MODE, GL_COMBINE);
+
+ glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
+ glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PREVIOUS);
+ glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_CONSTANT);
+ glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
+ glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
+
+ glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
+ glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS);
+ glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_CONSTANT);
+ glTexEnvf(GL_TEXTURE_ENV,
+ GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
+ glTexEnvf(GL_TEXTURE_ENV,
+ GL_OPERAND1_ALPHA, GL_SRC_ALPHA);
+
+ /* draw the window geometry */
+ (*w->screen->drawWindowGeometry) (w);
+
+ /* disable the current texture */
+ disableTexture(w->screen, texture);
+
+ /* set texture mode back to replace */
+ glTexEnvi(GL_TEXTURE_ENV,
+ GL_TEXTURE_ENV_MODE, GL_REPLACE);
+
+ /* re-activate last texture */
+ w->screen->activeTexture(GL_TEXTURE2_ARB);
+ }
+ else
+ {
+ /* fully opaque and bright */
+
+ /* draw the window geometry */
+ (*w->screen->drawWindowGeometry) (w);
+ }
/* disable the current texture */
disableTexture(w->screen, texture);
- /* set texture mode back to replace */
- glTexEnvi(GL_TEXTURE_ENV,
- GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ /* set the texture mode back to replace */
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
/* re-activate last texture */
- w->screen->activeTexture(GL_TEXTURE2_ARB);
+ w->screen->activeTexture(GL_TEXTURE1_ARB);
}
else
{
- /* fully opaque and bright */
+ /* fully saturated or fully unsaturated */
+
+ glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
+ glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS);
+ glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_CONSTANT);
+ glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
+ glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);
+
+ /* color constant */
+ constant[3] = attrib->opacity / 65535.0f;
+ constant[0] = constant[1] = constant[2] =
+ constant[3] * attrib->brightness / 65535.0f;
+
+ constant[0] =
+ 0.5f + 0.5f * RED_SATURATION_WEIGHT * constant[0];
+ constant[1] =
+ 0.5f + 0.5f * GREEN_SATURATION_WEIGHT * constant[1];
+ constant[2] =
+ 0.5f + 0.5f * BLUE_SATURATION_WEIGHT * constant[2];
+
+ glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constant);
/* draw the window geometry */
(*w->screen->drawWindowGeometry) (w);
@@ -365,124 +491,88 @@ NEGDrawWindowTexture(CompWindow * w,
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
/* re-activate last texture */
- w->screen->activeTexture(GL_TEXTURE1_ARB);
- }
- else
- {
- /* fully saturated or fully unsaturated */
-
- glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
- glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS);
- glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_CONSTANT);
- glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
- glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);
+ w->screen->activeTexture(GL_TEXTURE0_ARB);
- /* color constant */
- constant[3] = attrib->opacity / 65535.0f;
- constant[0] = constant[1] = constant[2] =
- constant[3] * attrib->brightness / 65535.0f;
+ /* disable that texture */
+ disableTexture(w->screen, texture);
- constant[0] =
- 0.5f + 0.5f * RED_SATURATION_WEIGHT * constant[0];
- constant[1] =
- 0.5f + 0.5f * GREEN_SATURATION_WEIGHT * constant[1];
- constant[2] =
- 0.5f + 0.5f * BLUE_SATURATION_WEIGHT * constant[2];
+ /* set the default color */
+ glColor4usv(defaultColor);
- glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constant);
+ /* set screens texture mode back to replace */
+ screenTexEnvMode(w->screen, GL_REPLACE);
- /* draw the window geometry */
- (*w->screen->drawWindowGeometry) (w);
+ /* if it's a translucent window, disable blending */
+ if (mask & PAINT_WINDOW_TRANSLUCENT_MASK)
+ glDisable(GL_BLEND);
}
+ else
+ {
+ /* no saturation adjustments */
- /* disable the current texture */
- disableTexture(w->screen, texture);
-
- /* set the texture mode back to replace */
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-
- /* re-activate last texture */
- w->screen->activeTexture(GL_TEXTURE0_ARB);
-
- /* disable that texture */
- disableTexture(w->screen, texture);
-
- /* set the default color */
- glColor4usv(defaultColor);
-
- /* set screens texture mode back to replace */
- screenTexEnvMode(w->screen, GL_REPLACE);
+ /* enable the current texture */
+ enableTexture(w->screen, texture, filter);
- /* if it's a translucent window, disable blending */
- if (mask & PAINT_WINDOW_TRANSLUCENT_MASK)
- glDisable(GL_BLEND);
- }
- else
- {
- /* no saturation adjustments */
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
+ glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE);
+ glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE);
+ glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_ONE_MINUS_SRC_COLOR); /* negate */
- /* enable the current texture */
- enableTexture(w->screen, texture, filter);
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
- glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE);
- glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE);
- glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_ONE_MINUS_SRC_COLOR); /* negate */
+ /* we are not opaque or fully bright */
+ if ((mask & PAINT_WINDOW_TRANSLUCENT_MASK)
+ || attrib->brightness != BRIGHT)
+ {
+ GLfloat constant[4];
+ /* enable blending */
+ glEnable(GL_BLEND);
- /* we are not opaque or fully bright */
- if ((mask & PAINT_WINDOW_TRANSLUCENT_MASK)
- || attrib->brightness != BRIGHT)
- {
- GLfloat constant[4];
+ /* color constant */
+ constant[3] = attrib->opacity / 65535.0f;
+ constant[0] = constant[3] * attrib->brightness / 65535.0f;
+ constant[1] = constant[3] * attrib->brightness / 65535.0f;
+ constant[2] = constant[3] * attrib->brightness / 65535.0f;
+ glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constant);
- /* enable blending */
- glEnable(GL_BLEND);
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
+ glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
+ glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE);
+ glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_CONSTANT);
+ glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_ONE_MINUS_SRC_COLOR); /* negate */
+ glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
- /* color constant */
- constant[3] = attrib->opacity / 65535.0f;
- constant[0] = constant[3] * attrib->brightness / 65535.0f;
- constant[1] = constant[3] * attrib->brightness / 65535.0f;
- constant[2] = constant[3] * attrib->brightness / 65535.0f;
- glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, constant);
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
+ glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
+ glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE);
+ glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_CONSTANT);
+ glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
+ glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
- glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
- glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE);
- glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_CONSTANT);
- glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_ONE_MINUS_SRC_COLOR); /* negate */
- glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
+ /* draw the window geometry */
+ (*w->screen->drawWindowGeometry) (w);
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
- glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE);
- glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE);
- glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_CONSTANT);
- glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
- glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);
+ /* disable blending */
+ glDisable(GL_BLEND);
- /* draw the window geometry */
- (*w->screen->drawWindowGeometry) (w);
+ }
+ else
+ {
+ /* no adjustments to saturation, brightness or opacity */
- /* disable blending */
- glDisable(GL_BLEND);
+ /* draw the window geometry */
+ (*w->screen->drawWindowGeometry) (w);
+ }
- }
- else
- {
- /* no adjustments to saturation, brightness or opacity */
+ /* disable the current texture */
+ disableTexture(w->screen, texture);
- /* draw the window geometry */
- (*w->screen->drawWindowGeometry) (w);
+ /* set the screens texture mode back to replace */
+ screenTexEnvMode(w->screen, GL_REPLACE);
}
-
- /* disable the current texture */
- disableTexture(w->screen, texture);
-
- /* set the screens texture mode back to replace */
- screenTexEnvMode(w->screen, GL_REPLACE);
+ /* pop previous matrix */
+ glPopMatrix();
}
- /* pop previous matrix */
- glPopMatrix();
}
else
{
@@ -780,6 +870,9 @@ static Bool NEGInitScreen(CompPlugin * p, CompScreen * s)
s->privates[nd->screenPrivateIndex].ptr = ns;
+ ns->negFunction = 0;
+ ns->negAlphaFunction = 0;
+
return TRUE;
}
@@ -797,6 +890,10 @@ static void NEGFiniScreen(CompPlugin * p, CompScreen * s)
removeScreenAction(s,
&nd->opt[NEG_DISPLAY_OPTION_SCREEN_TOGGLE].
value.action);
+ if (ns->negFunction)
+ destroyFragmentFunction (s, ns->negFunction);
+ if (ns->negAlphaFunction)
+ destroyFragmentFunction (s, ns->negAlphaFunction);
free(ns);
}