Пример #1
0
static Bool
shotPaintOutput (CompScreen              *s,
                 const ScreenPaintAttrib *sAttrib,
                 const CompTransform     *transform,
                 Region                  region,
                 CompOutput              *output,
                 unsigned int            mask)
{
	Bool status;

	SHOT_SCREEN (s);

	UNWRAP (ss, s, paintOutput);
	status = (*s->paintOutput) (s, sAttrib, transform, region, output, mask);
	WRAP (ss, s, paintOutput, shotPaintOutput);

	if (status && ss->grab)
	{
		int x1, x2, y1, y2;

		x1 = MIN (ss->x1, ss->x2);
		y1 = MIN (ss->y1, ss->y2);
		x2 = MAX (ss->x1, ss->x2);
		y2 = MAX (ss->y1, ss->y2);

		if (ss->grabIndex)
		{
			glPushMatrix ();

			prepareXCoords (s, output, -DEFAULT_Z_CAMERA);

			glDisableClientState (GL_TEXTURE_COORD_ARRAY);
			glEnable (GL_BLEND);
			glColor4us (0x2fff, 0x2fff, 0x4fff, 0x4fff);
			glRecti (x1, y2, x2, y1);
			glColor4us (0x2fff, 0x2fff, 0x4fff, 0x9fff);
			glBegin (GL_LINE_LOOP);
			glVertex2i (x1, y1);
			glVertex2i (x2, y1);
			glVertex2i (x2, y2);
			glVertex2i (x1, y2);
			glEnd ();
			glColor4usv (defaultColor);
			glDisable (GL_BLEND);
			glEnableClientState (GL_TEXTURE_COORD_ARRAY);
			glPopMatrix ();
		}
	}

	return status;
}
Пример #2
0
static Bool
enableFragmentProgramAndDrawGeometry (CompWindow	   *w,
				      CompTexture	   *texture,
				      const FragmentAttrib *attrib,
				      int		   filter,
				      unsigned int	   mask)
{
    FragmentAttrib fa = *attrib;
    CompScreen     *s = w->screen;
    Bool	   blending;

    if (s->canDoSaturated && attrib->saturation != COLOR)
    {
	int param, function;

	param    = allocFragmentParameters (&fa, 1);
	function = getSaturateFragmentFunction (s, texture, param);

	addFragmentFunction (&fa, function);

	(*s->programEnvParameter4f) (GL_FRAGMENT_PROGRAM_ARB, param,
				     RED_SATURATION_WEIGHT,
				     GREEN_SATURATION_WEIGHT,
				     BLUE_SATURATION_WEIGHT,
				     attrib->saturation / 65535.0f);
    }

    if (!enableFragmentAttrib (s, &fa, &blending))
	return FALSE;

    enableTexture (s, texture, filter);

    if (mask & PAINT_WINDOW_BLEND_MASK)
    {
	if (blending)
	    glEnable (GL_BLEND);

	if (attrib->opacity != OPAQUE || attrib->brightness != BRIGHT)
	{
	    GLushort color;

	    color = (attrib->opacity * attrib->brightness) >> 16;

	    screenTexEnvMode (s, GL_MODULATE);
	    glColor4us (color, color, color, attrib->opacity);

	    (*w->drawWindowGeometry) (w);

	    glColor4usv (defaultColor);
	    screenTexEnvMode (s, GL_REPLACE);
	}
	else
	{
static void
scaleaddonDrawWindowHighlight (CompWindow *w)
{
    GLboolean  wasBlend;
    GLint      oldBlendSrc, oldBlendDst;
    float      x, y, width, height;
    CompScreen *s = w->screen;

    SCALE_WINDOW (w);
    ADDON_WINDOW (w);

    if (aw->rescaled)
        return;

    x      = sw->tx + w->attrib.x - (w->input.left * sw->scale);
    y      = sw->ty + w->attrib.y - (w->input.top * sw->scale);
    width  = WIN_W (w) * sw->scale;
    height = WIN_H (w) * sw->scale;

    /* we use a poor replacement for roundf()
     * (available in C99 only) here */
    x = floor (x + 0.5f);
    y = floor (y + 0.5f);

    wasBlend = glIsEnabled (GL_BLEND);
    glGetIntegerv (GL_BLEND_SRC, &oldBlendSrc);
    glGetIntegerv (GL_BLEND_DST, &oldBlendDst);

    if (!wasBlend)
        glEnable (GL_BLEND);

    glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    glColor4us (scaleaddonGetHighlightColorRed (s),
                scaleaddonGetHighlightColorGreen (s),
                scaleaddonGetHighlightColorBlue (s),
                scaleaddonGetHighlightColorAlpha (s));

    glRectf (x, y + height, x + width, y);

    glColor4usv (defaultColor);

    if (!wasBlend)
        glDisable (GL_BLEND);
    glBlendFunc (oldBlendSrc, oldBlendDst);
}
static Bool
tdPaintWindowWithDepth (CompWindow              *w,
		     	const WindowPaintAttrib *attrib,
			const CompTransform     *transform,
			Region                  region,
			unsigned int            mask)
{
    Bool           wasCulled;
    Bool           status;
    int            wx, wy, ww, wh;
    int            bevel, cull, cullInv, temp;
    CompScreen     *s = w->screen;
    CompVector     point, tPoint;
    unsigned short *c;

    TD_SCREEN (s);
    TD_WINDOW (w);
    CUBE_SCREEN (s);

    wasCulled = glIsEnabled (GL_CULL_FACE);

    wx = w->attrib.x - w->input.left;
    wy = w->attrib.y - w->input.top;

    ww = w->width + w->input.left + w->input.right;
    wh = w->height + w->input.top + w->input.bottom;

    bevel = tdGetBevel (s);

    glGetIntegerv (GL_CULL_FACE_MODE, &cull);
    cullInv = (cull == GL_BACK)? GL_FRONT : GL_BACK;

    if (ww && wh && !(mask & PAINT_WINDOW_OCCLUSION_DETECTION_MASK) &&
	((cs->paintOrder == FTB && tdw->ftb) ||
	(cs->paintOrder == BTF && !tdw->ftb)))
    {
	/* Paint window depth. */
	glPushMatrix ();
	glLoadIdentity ();

	if (cs->paintOrder == BTF)
	    glCullFace (cullInv);
	
	glEnable (GL_BLEND);
	glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	
	if (w->id == s->display->activeWindow)
	    c = tdGetWidthColor (s);
	else
	    c = tdGetWidthColorInactive (s);

	temp = c[3] * w->paint.opacity;
	temp /= 0xffff;
	glColor4us (c[0], c[1], c[2], temp);

	point.z = 0.0f;
	point.w = 1.0f;

	glBegin (GL_QUADS);

	/* Top */
	ADDQUAD (wx + ww - DOBEVEL (Topleft), wy + 0.01,
		 wx + DOBEVEL (Topright), wy + 0.01);

	/* Bottom */
	ADDQUAD (wx + DOBEVEL (Bottomleft), wy + wh - 0.01,
		 wx + ww - DOBEVEL (Bottomright), wy + wh - 0.01);

	/* Left */
	ADDQUAD (wx + 0.01, wy + DOBEVEL (Topleft),
		 wx + 0.01, wy + wh - DOBEVEL (Bottomleft));

	/* Right */
	ADDQUAD (wx + ww - 0.01, wy + wh - DOBEVEL (Topright),
		 wx + ww - 0.01, wy + DOBEVEL (Bottomright));

	/* Top left bevel */
	if (tdGetBevelTopleft (s))
	{
	    ADDBEVELQUAD (wx + bevel / 2.0f,
			  wy + bevel - bevel / 1.2f,
			  wx, wy + bevel,
			  &tds->bTransform, transform);

	    ADDBEVELQUAD (wx + bevel / 2.0f,
			  wy + bevel - bevel / 1.2f,
			  wx + bevel, wy,
			  transform, &tds->bTransform);

	}

	/* Bottom left bevel */
	if (tdGetBevelBottomleft (s))
	{
	    ADDBEVELQUAD (wx + bevel / 2.0f,
			  wy + wh - bevel + bevel / 1.2f,
			  wx, wy + wh - bevel,
			  transform, &tds->bTransform);

	    ADDBEVELQUAD (wx + bevel / 2.0f,
			  wy + wh - bevel + bevel / 1.2f,
			  wx + bevel, wy + wh,
			  &tds->bTransform, transform);
	}

	/* Bottom right bevel */
	if (tdGetBevelBottomright (s))
	{
	    ADDBEVELQUAD (wx + ww - bevel / 2.0f,
			  wy + wh - bevel + bevel / 1.2f,
			  wx + ww - bevel, wy + wh,
			  transform, &tds->bTransform);

	    ADDBEVELQUAD (wx + ww - bevel / 2.0f,
			  wy + wh - bevel + bevel / 1.2f,
			  wx + ww, wy + wh - bevel,
			  &tds->bTransform, transform);

	}

	/* Top right bevel */
	if (tdGetBevelTopright (s))
	{
	    ADDBEVELQUAD (wx + ww - bevel, wy,
			  wx + ww - bevel / 2.0f,
			  wy + bevel - bevel / 1.2f,
			  transform, &tds->bTransform);

	    ADDBEVELQUAD (wx + ww, wy + bevel,
			  wx + ww - bevel / 2.0f,
			  wy + bevel - bevel / 1.2f,
			  &tds->bTransform, transform);
	}
	glEnd ();

	glColor4usv (defaultColor);
	glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
	glPopMatrix ();

	if (cs->paintOrder == BTF)
	    glCullFace (cull);
    }

    UNWRAP(tds, s, paintWindow);
    if (cs->paintOrder == BTF)
	status = (*s->paintWindow) (w, attrib, transform, region, mask);
    else
	status = (*s->paintWindow) (w, attrib, &tds->bTransform, region,
				    mask | PAINT_WINDOW_TRANSFORMED_MASK);
    WRAP (tds, s, paintWindow, tdPaintWindow);

    return status;
}
Пример #5
0
static void
scalefilterDrawFilterText (CompScreen *s,
			   CompOutput *output)
{
    FILTER_SCREEN (s);

    GLboolean wasBlend;
    GLint     oldBlendSrc, oldBlendDst;
    int       ox1, ox2, oy1, oy2;

    float width = fs->filterInfo->textWidth;
    float height = fs->filterInfo->textHeight;
    float border = scalefilterGetBorderSize (s);

    ox1 = output->region.extents.x1;
    ox2 = output->region.extents.x2;
    oy1 = output->region.extents.y1;
    oy2 = output->region.extents.y2;
    float x = ox1 + ((ox2 - ox1) / 2) - (width / 2);
    float y = oy1 + ((oy2 - oy1) / 2) + (height / 2);

    x = floor (x);
    y = floor (y);

    wasBlend = glIsEnabled (GL_BLEND);
    glGetIntegerv (GL_BLEND_SRC, &oldBlendSrc);
    glGetIntegerv (GL_BLEND_DST, &oldBlendDst);

    if (!wasBlend)
	glEnable (GL_BLEND);

    glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);

    glColor4us (scalefilterGetBackColorRed (s),
		scalefilterGetBackColorGreen (s),
		scalefilterGetBackColorBlue (s),
		scalefilterGetBackColorAlpha (s));

    glPushMatrix ();

    glTranslatef (x, y - height, 0.0f);
    glRectf (0.0f, height, width, 0.0f);
    glRectf (0.0f, 0.0f, width, -border);
    glRectf (0.0f, height + border, width, height);
    glRectf (-border, height, 0.0f, 0.0f);
    glRectf (width, height, width + border, 0.0f);
    glTranslatef (-border, -border, 0.0f);

#define CORNER(a,b) \
    for (k = a; k < b; k++) \
    {\
	float rad = k* (3.14159 / 180.0f);\
	glVertex2f (0.0f, 0.0f);\
	glVertex2f (cos (rad) * border, sin (rad) * border);\
	glVertex2f (cos ((k - 1) * (3.14159 / 180.0f)) * border, \
		    sin ((k - 1) * (3.14159 / 180.0f)) * border);\
    }

    /* Rounded corners */
    int k;

    glTranslatef (border, border, 0.0f);
    glBegin (GL_TRIANGLES);
    CORNER (180, 270) glEnd();
    glTranslatef (-border, -border, 0.0f);

    glTranslatef (width + border, border, 0.0f);
    glBegin (GL_TRIANGLES);
    CORNER (270, 360) glEnd();
    glTranslatef (-(width + border), -border, 0.0f);

    glTranslatef (border, height + border, 0.0f);
    glBegin (GL_TRIANGLES);
    CORNER (90, 180) glEnd();
    glTranslatef (-border, -(height + border), 0.0f);

    glTranslatef (width + border, height + border, 0.0f);
    glBegin (GL_TRIANGLES);
    CORNER (0, 90) glEnd();
    glTranslatef (-(width + border), -(height + border), 0.0f);

    glPopMatrix ();

#undef CORNER

    glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    glColor4f (1.0, 1.0, 1.0, 1.0);

    enableTexture (s, &fs->filterInfo->textTexture, COMP_TEXTURE_FILTER_GOOD);

    CompMatrix *m = &fs->filterInfo->textTexture.matrix;

    glBegin (GL_QUADS);

    glTexCoord2f (COMP_TEX_COORD_X(m, 0),COMP_TEX_COORD_Y(m ,0));
    glVertex2f (x, y - height);
    glTexCoord2f (COMP_TEX_COORD_X(m, 0),COMP_TEX_COORD_Y(m, height));
    glVertex2f (x, y);
    glTexCoord2f (COMP_TEX_COORD_X(m, width),COMP_TEX_COORD_Y(m, height));
    glVertex2f (x + width, y);
    glTexCoord2f (COMP_TEX_COORD_X(m, width),COMP_TEX_COORD_Y(m, 0));
    glVertex2f (x + width, y - height);

    glEnd ();

    disableTexture (s, &fs->filterInfo->textTexture);
    glColor4usv (defaultColor);

    if (!wasBlend)
	glDisable (GL_BLEND);
    glBlendFunc (oldBlendSrc, oldBlendDst);
}
Пример #6
0
static Bool
zoomPaintOutput(CompScreen *s,
                const ScreenPaintAttrib *sAttrib,
                const CompTransform *transform,
                Region region,
                CompOutput *output,
                unsigned int mask)
{
   CompTransform zTransform = *transform;
   Bool status;

   ZOOM_SCREEN(s);

   if (output->id != ~0 && (zs->zoomed & (1 << output->id)))
     {
        int saveFilter;
        ZoomBox box;
        float scale, x, y, x1, y1;
        float oWidth = output->width;
        float oHeight = output->height;

        mask &= ~PAINT_SCREEN_REGION_MASK;

        zoomGetCurrentZoom(s, output->id, &box);

        x1 = box.x1 - output->region.extents.x1;
        y1 = box.y1 - output->region.extents.y1;

        scale = oWidth / (box.x2 - box.x1);

        x = ((oWidth / 2.0f) - x1) / oWidth;
        y = ((oHeight / 2.0f) - y1) / oHeight;

        x = 0.5f - x * scale;
        y = 0.5f - y * scale;

        matrixTranslate(&zTransform, -x, y, 0.0f);
        matrixScale(&zTransform, scale, scale, 1.0f);

        mask |= PAINT_SCREEN_TRANSFORMED_MASK;

        saveFilter = s->filter[SCREEN_TRANS_FILTER];

        if ((zs->zoomOutput != output->id || !zs->adjust) && scale > 3.9f &&
            !zs->opt[ZOOM_SCREEN_OPTION_FILTER_LINEAR].value.b)
          s->filter[SCREEN_TRANS_FILTER] = COMP_TEXTURE_FILTER_FAST;

        UNWRAP(zs, s, paintOutput);
        status = (*s->paintOutput)(s, sAttrib, &zTransform, region, output,
                                   mask);
        WRAP(zs, s, paintOutput, zoomPaintOutput);

        s->filter[SCREEN_TRANS_FILTER] = saveFilter;
     }
   else
     {
        UNWRAP(zs, s, paintOutput);
        status = (*s->paintOutput)(s, sAttrib, transform, region, output,
                                   mask);
        WRAP(zs, s, paintOutput, zoomPaintOutput);
     }

   if (status && zs->grab)
     {
        int x1, x2, y1, y2;

        x1 = MIN(zs->x1, zs->x2);
        y1 = MIN(zs->y1, zs->y2);
        x2 = MAX(zs->x1, zs->x2);
        y2 = MAX(zs->y1, zs->y2);

        if (zs->grabIndex)
          {
             transformToScreenSpace(s, output, -DEFAULT_Z_CAMERA, &zTransform);

             glPushMatrix();
             glLoadMatrixf(zTransform.m);
             glDisableClientState(GL_TEXTURE_COORD_ARRAY);
             glEnable(GL_BLEND);
             glColor4us(0x2fff, 0x2fff, 0x4fff, 0x4fff);
             glRecti(x1, y2, x2, y1);
             glColor4us(0x2fff, 0x2fff, 0x4fff, 0x9fff);
             glBegin(GL_LINE_LOOP);
             glVertex2i(x1, y1);
             glVertex2i(x2, y1);
             glVertex2i(x2, y2);
             glVertex2i(x1, y2);
             glEnd();
             glColor4usv(defaultColor);
             glDisable(GL_BLEND);
             glEnableClientState(GL_TEXTURE_COORD_ARRAY);
             glPopMatrix();
          }
     }

   return status;
}
Пример #7
0
/*
 * groupDrawWindow
 *
 */
Bool
groupDrawWindow (CompWindow           *w,
                 const CompTransform  *transform,
                 const FragmentAttrib *attrib,
                 Region               region,
                 unsigned int         mask)
{
	Bool status;
	CompScreen *s = w->screen;

	GROUP_WINDOW (w);
	GROUP_SCREEN (s);

	if (gw->group && (gw->group->nWins > 1) && gw->glowQuads)
	{
		if (mask & PAINT_WINDOW_TRANSFORMED_MASK)
			region = &infiniteRegion;

		if (region->numRects)
		{
			REGION box;
			int i;

			box.rects = &box.extents;
			box.numRects = 1;

			w->vCount = w->indexCount = 0;

			for (i = 0; i < NUM_GLOWQUADS; i++)
			{
				box.extents = gw->glowQuads[i].box;

				if (box.extents.x1 < box.extents.x2 &&
				    box.extents.y1 < box.extents.y2)
				{
					(*s->addWindowGeometry)(w, &gw->glowQuads[i].matrix,
					                        1, &box, region);
				}
			}

			if (w->vCount)
			{
				FragmentAttrib fAttrib = *attrib;
				GLushort average;
				GLushort color[3] = {gw->group->color[0],
					             gw->group->color[1],
					             gw->group->color[2]};

				/* Apply brightness to color. */
				color[0] *= (float)attrib->brightness / BRIGHT;
				color[1] *= (float)attrib->brightness / BRIGHT;
				color[2] *= (float)attrib->brightness / BRIGHT;

				/* Apply saturation to color. */
				average = (color[0] + color[1] + color[2]) / 3;
				color[0] = average + (color[0] - average) *
				           attrib->saturation / COLOR;
				color[1] = average + (color[1] - average) *
				           attrib->saturation / COLOR;
				color[2] = average + (color[2] - average) *
				           attrib->saturation / COLOR;

				fAttrib.opacity = OPAQUE;
				fAttrib.saturation = COLOR;
				fAttrib.brightness = BRIGHT;

				screenTexEnvMode (s, GL_MODULATE);
				glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
				glColor4us (color[0], color[1], color[2], attrib->opacity);

				/* we use PAINT_WINDOW_TRANSFORMED_MASK here to force
				   the usage of a good texture filter */
				(*s->drawWindowTexture)(w, &gs->glowTexture, &fAttrib,
				                        mask | PAINT_WINDOW_BLEND_MASK |
				                        PAINT_WINDOW_TRANSLUCENT_MASK |
				                        PAINT_WINDOW_TRANSFORMED_MASK);

				glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
				screenTexEnvMode (s, GL_REPLACE);
				glColor4usv (defaultColor);
			}
		}
	}

	UNWRAP (gs, s, drawWindow);
	status = (*s->drawWindow)(w, transform, attrib, region, mask);
	WRAP (gs, s, drawWindow, groupDrawWindow);

	return status;
}
Пример #8
0
static void
_vte_gl_clear(struct _vte_draw *draw, gint x, gint y, gint width, gint height)
{
	struct _vte_gl_data *data = draw->impl_data;
	long xstop, ystop, i, j;
	int pixbufw, pixbufh, w, h, channels, stride;
	GLenum format = 0;
	guchar *pixels;

	glXMakeCurrent(data->display, data->glwindow, data->context);

	if (data->bgpixbuf != NULL) {
		pixbufw = gdk_pixbuf_get_width(data->bgpixbuf);
		pixbufh = gdk_pixbuf_get_height(data->bgpixbuf);
	} else {
		pixbufw = pixbufh = 0;
	}

	if ((pixbufw == 0) || (pixbufh == 0)) {
		glColor4us(draw->bg_color.red,
			   draw->bg_color.green,
			   draw->bg_color.blue,
			   0xFFFF);
		glBegin(GL_POLYGON);
		glVertex2d(x, y);
		glVertex2d(x + width, y);
		glVertex2d(x + width, y + height - 1);
		glVertex2d(x, y + height - 1);
		glEnd();
		return;
	}

	/* Flood fill. */
	xstop = x + width;
	ystop = y + height;

	pixels = gdk_pixbuf_get_pixels(data->bgpixbuf);
	channels = gdk_pixbuf_get_n_channels(data->bgpixbuf);
	stride = gdk_pixbuf_get_rowstride(data->bgpixbuf);

	switch (channels) {
	case 3:
		format = GL_RGB;
		break;
	case 4:
		format = GL_RGBA;
		break;
	default:
		g_assert_not_reached();
		break;
	}

	y = ystop - height;
	j = (draw->scrolly + y) % pixbufh;
	while (y < ystop) {
		x = xstop - width;
		i = (draw->scrollx + x) % pixbufw;

		/* h = MIN(pixbufh - (j % pixbufh), ystop - y); */
		h = 1;
		while (x < xstop) {
			w = MIN(pixbufw - (i % pixbufw), xstop - x);

			glRasterPos2i(x, y);
			glDrawPixels(w, h,
				     format, GL_UNSIGNED_BYTE,
				     pixels + stride * j + channels * i);
			x += w;
			i = 0;
		}
		y += h;
		j = (draw->scrolly + y) % pixbufh;
	}
	glFlush();
}
Пример #9
0
static void
paintBackground (CompScreen   *s,
		 Region	      region,
		 Bool	      transformed)
{
    CompTexture *bg = &s->backgroundTexture;
    BoxPtr      pBox = region->rects;
    int	        n, nBox = region->numRects;
    GLfloat     *d, *data;

    if (!nBox)
	return;

    if (s->desktopWindowCount)
    {
	if (bg->name)
	{
	    finiTexture (s, bg);
	    initTexture (s, bg);
	}

	s->backgroundLoaded = FALSE;

	return;
    }
    else
    {
	if (!s->backgroundLoaded)
	    updateScreenBackground (s, bg);

	s->backgroundLoaded = TRUE;
    }

    data = malloc (sizeof (GLfloat) * nBox * 16);
    if (!data)
	return;

    d = data;
    n = nBox;
    while (n--)
    {
	*d++ = COMP_TEX_COORD_X (&bg->matrix, pBox->x1);
	*d++ = COMP_TEX_COORD_Y (&bg->matrix, pBox->y2);

	*d++ = pBox->x1;
	*d++ = pBox->y2;

	*d++ = COMP_TEX_COORD_X (&bg->matrix, pBox->x2);
	*d++ = COMP_TEX_COORD_Y (&bg->matrix, pBox->y2);

	*d++ = pBox->x2;
	*d++ = pBox->y2;

	*d++ = COMP_TEX_COORD_X (&bg->matrix, pBox->x2);
	*d++ = COMP_TEX_COORD_Y (&bg->matrix, pBox->y1);

	*d++ = pBox->x2;
	*d++ = pBox->y1;

	*d++ = COMP_TEX_COORD_X (&bg->matrix, pBox->x1);
	*d++ = COMP_TEX_COORD_Y (&bg->matrix, pBox->y1);

	*d++ = pBox->x1;
	*d++ = pBox->y1;

	pBox++;
    }

    glTexCoordPointer (2, GL_FLOAT, sizeof (GLfloat) * 4, data);
    glVertexPointer (2, GL_FLOAT, sizeof (GLfloat) * 4, data + 2);

    if (bg->name)
    {
	if (transformed)
	    enableTexture (s, bg, COMP_TEXTURE_FILTER_GOOD);
	else
	    enableTexture (s, bg, COMP_TEXTURE_FILTER_FAST);

	glDrawArrays (GL_QUADS, 0, nBox * 4);

	disableTexture (s, bg);
    }
    else
    {
	glColor4us (0, 0, 0, 0);
	glDrawArrays (GL_QUADS, 0, nBox * 4);
	glColor4usv (defaultColor);
    }

    free (data);
}
Пример #10
0
static void
thumbPaintThumb (CompScreen          *s,
                 Thumbnail           *t,
                 const CompTransform *transform)
{
	AddWindowGeometryProc oldAddWindowGeometry;
	CompWindow            *w = t->win;
	int wx = t->x;
	int wy = t->y;
	float width  = t->width;
	float height = t->height;
	WindowPaintAttrib sAttrib;
	unsigned int mask = PAINT_WINDOW_TRANSFORMED_MASK |
	                    PAINT_WINDOW_TRANSLUCENT_MASK;

	THUMB_SCREEN (s);

	if (!w)
		return;

	sAttrib = w->paint;

	if (t->textData)
		height += t->textData->height + TEXT_DISTANCE;

	/* Wrap drawWindowGeometry to make sure the general
	   drawWindowGeometry function is used */
	oldAddWindowGeometry = s->addWindowGeometry;
	s->addWindowGeometry = addWindowGeometry;

	if (w->texture->pixmap)
	{
		int off = t->offset;
		GLenum filter = display.textureFilter;
		FragmentAttrib fragment;
		CompTransform wTransform = *transform;

		glEnable (GL_BLEND);
		glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
		glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
		glDisableClientState (GL_TEXTURE_COORD_ARRAY);

		const BananaValue *
		option_window_like = bananaGetOption (bananaIndex,
		                                      "window_like",
		                                      s->screenNum);

		if (option_window_like->b)
		{
			glColor4f (1.0, 1.0, 1.0, t->opacity);
			enableTexture (s, &ts->windowTexture, COMP_TEXTURE_FILTER_GOOD);
		}
		else
		{
			unsigned short color[] = { 0, 0, 0, 0 };

			const BananaValue *
			option_thumb_color = bananaGetOption (bananaIndex,
			                                      "thumb_color",
			                                      s->screenNum);

			stringToColor (option_thumb_color->s, color);

			glColor4us (color[0],
			            color[1],
			            color[2],
			            color[3] * t->opacity);

			enableTexture (s, &ts->glowTexture, COMP_TEXTURE_FILTER_GOOD);
		}

		glBegin (GL_QUADS);

		glTexCoord2f (1, 0);
		glVertex2f (wx, wy);
		glVertex2f (wx, wy + height);
		glVertex2f (wx + width, wy + height);
		glVertex2f (wx + width, wy);

		glTexCoord2f (0, 1);
		glVertex2f (wx - off, wy - off);
		glTexCoord2f (0, 0);
		glVertex2f (wx - off, wy);
		glTexCoord2f (1, 0);
		glVertex2f (wx, wy);
		glTexCoord2f (1, 1);
		glVertex2f (wx, wy - off);

		glTexCoord2f (1, 1);
		glVertex2f (wx + width, wy - off);
		glTexCoord2f (1, 0);
		glVertex2f (wx + width, wy);
		glTexCoord2f (0, 0);
		glVertex2f (wx + width + off, wy);
		glTexCoord2f (0, 1);
		glVertex2f (wx + width + off, wy - off);

		glTexCoord2f (0, 0);
		glVertex2f (wx - off, wy + height);
		glTexCoord2f (0, 1);
		glVertex2f (wx - off, wy + height + off);
		glTexCoord2f (1, 1);
		glVertex2f (wx, wy + height + off);
		glTexCoord2f (1, 0);
		glVertex2f (wx, wy + height);

		glTexCoord2f (1, 0);
		glVertex2f (wx + width, wy + height);
		glTexCoord2f (1, 1);
		glVertex2f (wx + width, wy + height + off);
		glTexCoord2f (0, 1);
		glVertex2f (wx + width + off, wy + height + off);
		glTexCoord2f (0, 0);
		glVertex2f (wx + width + off, wy + height);

		glTexCoord2f (1, 1);
		glVertex2f (wx, wy - off);
		glTexCoord2f (1, 0);
		glVertex2f (wx, wy);
		glTexCoord2f (1, 0);
		glVertex2f (wx + width, wy);
		glTexCoord2f (1, 1);
		glVertex2f (wx + width, wy - off);

		glTexCoord2f (1, 0);
		glVertex2f (wx, wy + height);
		glTexCoord2f (1, 1);
		glVertex2f (wx, wy + height + off);
		glTexCoord2f (1, 1);
		glVertex2f (wx + width, wy + height + off);
		glTexCoord2f (1, 0);
		glVertex2f (wx + width, wy + height);

		glTexCoord2f (0, 0);
		glVertex2f (wx - off, wy);
		glTexCoord2f (0, 0);
		glVertex2f (wx - off, wy + height);
		glTexCoord2f (1, 0);
		glVertex2f (wx, wy + height);
		glTexCoord2f (1, 0);
		glVertex2f (wx, wy);

		glTexCoord2f (1, 0);
		glVertex2f (wx + width, wy);
		glTexCoord2f (1, 0);
		glVertex2f (wx + width, wy + height);
		glTexCoord2f (0, 0);
		glVertex2f (wx + width + off, wy + height);
		glTexCoord2f (0, 0);
		glVertex2f (wx + width + off, wy);

		glEnd ();

		if (option_window_like->b)
		{
			disableTexture (s, &ts->windowTexture);
		}
		else
		{
			disableTexture (s, &ts->glowTexture);
		}

		glColor4usv (defaultColor);

		glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);

		if (t->textData)
		{
			float ox = 0.0;

			if (t->textData->width < width)
				ox = (width - (int)t->textData->width) / 2.0;

			textDrawText (s, t->textData, wx + ox, wy + height, t->opacity);
		}

		glEnableClientState (GL_TEXTURE_COORD_ARRAY);
		glDisable (GL_BLEND);

		screenTexEnvMode (s, GL_REPLACE);

		glColor4usv (defaultColor);

		sAttrib.opacity *= t->opacity;
		sAttrib.yScale = t->scale;
		sAttrib.xScale = t->scale;

		sAttrib.xTranslate = wx - w->attrib.x + w->input.left * sAttrib.xScale;
		sAttrib.yTranslate = wy - w->attrib.y + w->input.top * sAttrib.yScale;

		const BananaValue *
		option_mipmap = bananaGetOption (bananaIndex,
		                                 "mipmap",
		                                 s->screenNum);

		if (option_mipmap->b)
			display.textureFilter = GL_LINEAR_MIPMAP_LINEAR;

		initFragmentAttrib (&fragment, &sAttrib);

		matrixTranslate (&wTransform, w->attrib.x, w->attrib.y, 0.0f);
		matrixScale (&wTransform, sAttrib.xScale, sAttrib.yScale, 1.0f);
		matrixTranslate (&wTransform,
		                 sAttrib.xTranslate / sAttrib.xScale - w->attrib.x,
		                 sAttrib.yTranslate / sAttrib.yScale - w->attrib.y,
		                 0.0f);

		glPushMatrix ();
		glLoadMatrixf (wTransform.m);
		(*s->drawWindow) (w, &wTransform, &fragment, &infiniteRegion, mask);
		glPopMatrix ();

		display.textureFilter = filter;
	}

	s->addWindowGeometry = oldAddWindowGeometry;
}
Пример #11
0
inline void glColor( const GLushort & red, const GLushort & green, const GLushort & blue, const GLushort & alpha )	{ glColor4us( red, green, blue, alpha ); }
Пример #12
0
static Bool
tdPaintWindowWithDepth (CompWindow              *w,
                        const WindowPaintAttrib *attrib,
                        const CompTransform     *transform,
                        Region                  region,
                        unsigned int            mask)
{
	//Bool           wasCulled;
	Bool           status;
	int            wx, wy, ww, wh;
	int            bevel, cull, cullInv, temp;
	CompScreen     *s = w->screen;
	CompVector     point, tPoint;
	unsigned short c[4];

	TD_SCREEN (s);
	TD_WINDOW (w);
	CUBE_SCREEN (s);

	//wasCulled = glIsEnabled (GL_CULL_FACE);

	wx = w->attrib.x - w->input.left;
	wy = w->attrib.y - w->input.top;

	ww = w->width + w->input.left + w->input.right;
	wh = w->height + w->input.top + w->input.bottom;

	const BananaValue *
	option_bevel = bananaGetOption (bananaIndex,
	                                "bevel",
	                                s->screenNum);

	bevel = option_bevel->i;

	glGetIntegerv (GL_CULL_FACE_MODE, &cull);
	cullInv = (cull == GL_BACK)? GL_FRONT : GL_BACK;

	if (ww && wh && !(mask & PAINT_WINDOW_OCCLUSION_DETECTION_MASK) &&
	                        ((cs->paintOrder == FTB && tdw->ftb) ||
	                         (cs->paintOrder == BTF && !tdw->ftb)))
	{
		/* Paint window depth. */
		glPushMatrix ();
		glLoadIdentity ();

		if (cs->paintOrder == BTF)
			glCullFace (cullInv);

		glEnable (GL_BLEND);
		glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

		if (w->id == display.activeWindow)
		{
			const BananaValue *
			option_width_color = bananaGetOption (bananaIndex,
			                                      "width_color",
			                                      s->screenNum);

			stringToColor (option_width_color->s, c);
		}
		else
		{
			const BananaValue *
			option_width_color_inactive = bananaGetOption (bananaIndex,
			                                            "width_color_inactive",
			                                            s->screenNum);

			stringToColor (option_width_color_inactive->s, c);
		}

		temp = c[3] * w->paint.opacity;
		temp /= 0xffff;
		glColor4us (c[0], c[1], c[2], temp);

		point.z = 0.0f;
		point.w = 1.0f;

		glBegin (GL_QUADS);

		/* Top */
		ADDQUAD (wx + ww - dobevel ("bevel_topleft", bevel), wy + 0.01,
		         wx + dobevel ("bevel_topright", bevel), wy + 0.01);

		/* Bottom */
		ADDQUAD (
		    wx + dobevel ("bevel_bottomleft", bevel), wy + wh - 0.01,
		    wx + ww - dobevel ("bevel_bottomright", bevel), wy + wh - 0.01);

		/* Left */
		ADDQUAD (wx + 0.01, wy + dobevel ("bevel_topleft", bevel),
		         wx + 0.01, wy + wh - dobevel ("bevel_bottomleft", bevel));

		/* Right */
		ADDQUAD (wx + ww - 0.01, wy + wh - dobevel ("bevel_topright", bevel),
		         wx + ww - 0.01, wy + dobevel ("bevel_bottomright", bevel));

		const BananaValue *
		option_bevel_topleft = bananaGetOption (bananaIndex,
		                                        "bevel_topleft",
		                                        s->screenNum);

		/* Top left bevel */
		if (option_bevel_topleft->b)
		{
			ADDBEVELQUAD (wx + bevel / 2.0f,
			      wy + bevel - bevel / 1.2f,
			      wx, wy + bevel,
			      &tds->bTransform, transform);

			ADDBEVELQUAD (wx + bevel / 2.0f,
			      wy + bevel - bevel / 1.2f,
			      wx + bevel, wy,
			      transform, &tds->bTransform);
		}

		const BananaValue *
		option_bevel_bottomleft = bananaGetOption (bananaIndex,
		                                           "bevel_bottomleft",
		                                           s->screenNum);

		/* Bottom left bevel */
		if (option_bevel_bottomleft->b)
		{
			ADDBEVELQUAD (wx + bevel / 2.0f,
			      wy + wh - bevel + bevel / 1.2f,
			      wx, wy + wh - bevel,
			      transform, &tds->bTransform);

			ADDBEVELQUAD (wx + bevel / 2.0f,
			      wy + wh - bevel + bevel / 1.2f,
			      wx + bevel, wy + wh,
			      &tds->bTransform, transform);
		}

		const BananaValue *
		option_bevel_bottomright = bananaGetOption (bananaIndex,
		                                          "bevel_bottomright",
		                                          s->screenNum);

		/* Bottom right bevel */
		if (option_bevel_bottomright->b)
		{
			ADDBEVELQUAD (wx + ww - bevel / 2.0f,
			      wy + wh - bevel + bevel / 1.2f,
			      wx + ww - bevel, wy + wh,
			      transform, &tds->bTransform);

			ADDBEVELQUAD (wx + ww - bevel / 2.0f,
			      wy + wh - bevel + bevel / 1.2f,
			      wx + ww, wy + wh - bevel,
			      &tds->bTransform, transform);
		}

		const BananaValue *
		option_bevel_topright = bananaGetOption (bananaIndex,
		                                         "bevel_topright",
		                                         s->screenNum);

		/* Top right bevel */
		if (option_bevel_topright->b)
		{
			ADDBEVELQUAD (wx + ww - bevel, wy,
			      wx + ww - bevel / 2.0f,
			      wy + bevel - bevel / 1.2f,
			      transform, &tds->bTransform);

			ADDBEVELQUAD (wx + ww, wy + bevel,
			      wx + ww - bevel / 2.0f,
			      wy + bevel - bevel / 1.2f,
			      &tds->bTransform, transform);
		}

		glEnd ();

		glColor4usv (defaultColor);
		glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
		glPopMatrix ();

		if (cs->paintOrder == BTF)
			glCullFace (cull);
	}

	UNWRAP(tds, s, paintWindow);
	if (cs->paintOrder == BTF)
		status = (*s->paintWindow) (w, attrib, transform, region, mask);
	else
		status = (*s->paintWindow) (w, attrib, &tds->bTransform, region,
		                        mask | PAINT_WINDOW_TRANSFORMED_MASK);
	WRAP (tds, s, paintWindow, tdPaintWindow);

	return status;
}
Пример #13
0
M(void, glColor4us, jshort red, jshort green, jshort blue, jshort alpha) {
	glColor4us(red, green, blue, alpha);
}
static void
magPaintSimple (CompScreen *s)
{
    float          pw, ph, bw, bh;
    int            x1, x2, y1, y2;
    float          vc[4];
    float          tc[4];
    int            w, h, cw, ch, cx, cy;
    Bool           kScreen;
    unsigned short *color;
    float          tmp;

    MAG_SCREEN (s);

    w = magGetBoxWidth (s);
    h = magGetBoxHeight (s);

    kScreen = magGetKeepScreen (s);

    x1 = ms->posX - (w / 2);
    if (kScreen)
	x1 = MAX (0, MIN (x1, s->width - w));
    x2 = x1 + w;
    y1 = ms->posY - (h / 2);
    if (kScreen)
	y1 = MAX (0, MIN (y1, s->height - h));
    y2 = y1 + h;
 
    cw = ceil ((float)w / (ms->zoom * 2.0)) * 2.0;
    ch = ceil ((float)h / (ms->zoom * 2.0)) * 2.0;
    cw = MIN (w, cw + 2);
    ch = MIN (h, ch + 2);
    cx = (w - cw) / 2;
    cy = (h - ch) / 2;

    cx = MAX (0, MIN (w - cw, cx));
    cy = MAX (0, MIN (h - ch, cy));

    if (x1 != (ms->posX - (w / 2)))
    {
	cx = 0;
	cw = w;
    }
    if (y1 != (ms->posY - (h / 2)))
    {
	cy = 0;
	ch = h;
    }

    glEnable (ms->target);

    glBindTexture (ms->target, ms->texture);

    if (ms->width != w || ms->height != h)
    {
	glCopyTexImage2D(ms->target, 0, GL_RGB, x1, s->height - y2,
			 w, h, 0);
	ms->width = w;
	ms->height = h;
    }
    else
	glCopyTexSubImage2D (ms->target, 0, cx, cy,
			     x1 + cx, s->height - y2 + cy, cw, ch);

    if (ms->target == GL_TEXTURE_2D)
    {
	pw = 1.0 / ms->width;
	ph = 1.0 / ms->height;
    }
    else
    {
	pw = 1.0;
	ph = 1.0;
    }

    glMatrixMode (GL_PROJECTION);
    glPushMatrix ();
    glLoadIdentity ();
    glMatrixMode (GL_MODELVIEW);
    glPushMatrix ();
    glLoadIdentity ();

    vc[0] = ((x1 * 2.0) / s->width) - 1.0;
    vc[1] = ((x2 * 2.0) / s->width) - 1.0;
    vc[2] = ((y1 * -2.0) / s->height) + 1.0;
    vc[3] = ((y2 * -2.0) / s->height) + 1.0;

    tc[0] = 0.0;
    tc[1] = w * pw;
    tc[2] = h * ph;
    tc[3] = 0.0;

    glColor4usv (defaultColor);

    glPushMatrix ();

    glTranslatef ((float)(ms->posX - (s->width / 2)) * 2 / s->width,
		  (float)(ms->posY - (s->height / 2)) * 2 / -s->height, 0.0);

    glScalef (ms->zoom, ms->zoom, 1.0);

    glTranslatef ((float)((s->width / 2) - ms->posX) * 2 / s->width,
		  (float)((s->height / 2) - ms->posY) * 2 / -s->height, 0.0);

    glScissor (x1, s->height - y2, w, h);

    glEnable (GL_SCISSOR_TEST);

    glBegin (GL_QUADS);
    glTexCoord2f (tc[0], tc[2]);
    glVertex2f (vc[0], vc[2]);
    glTexCoord2f (tc[0], tc[3]);
    glVertex2f (vc[0], vc[3]);
    glTexCoord2f (tc[1], tc[3]);
    glVertex2f (vc[1], vc[3]);
    glTexCoord2f (tc[1], tc[2]);
    glVertex2f (vc[1], vc[2]);
    glEnd ();

    glDisable (GL_SCISSOR_TEST);

    glPopMatrix ();

    glBindTexture (ms->target, 0);

    glDisable (ms->target);

    glEnable (GL_BLEND);
    glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    tmp = MIN (1.0, (ms->zoom - 1) * 3.0);

    bw = bh = magGetBorder (s);

    bw = bw * 2.0 / s->width;
    bh = bh * 2.0 / s->height;

    bw = bh = magGetBorder (s);

    bw *= 2.0 / (float)s->width;
    bh *= 2.0 / (float)s->height;

    color = magGetBoxColor (s);

    glColor4us (color[0], color[1], color[2], color[3] * tmp);

    glBegin (GL_QUADS);
    glVertex2f (vc[0] - bw, vc[2] + bh);
    glVertex2f (vc[0] - bw, vc[2]);
    glVertex2f (vc[1] + bw, vc[2]);
    glVertex2f (vc[1] + bw, vc[2] + bh);
    glVertex2f (vc[0] - bw, vc[3]);
    glVertex2f (vc[0] - bw, vc[3] - bh);
    glVertex2f (vc[1] + bw, vc[3] - bh);
    glVertex2f (vc[1] + bw, vc[3]);
    glVertex2f (vc[0] - bw, vc[2]);
    glVertex2f (vc[0] - bw, vc[3]);
    glVertex2f (vc[0], vc[3]);
    glVertex2f (vc[0], vc[2]);
    glVertex2f (vc[1], vc[2]);
    glVertex2f (vc[1], vc[3]);
    glVertex2f (vc[1] + bw, vc[3]);
    glVertex2f (vc[1] + bw, vc[2]);
    glEnd();

    glColor4usv (defaultColor);
    glDisable (GL_BLEND);
    glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);

    glPopMatrix();
    glMatrixMode (GL_PROJECTION);
    glPopMatrix ();
    glMatrixMode (GL_MODELVIEW);
}