Ejemplo n.º 1
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
	{
Ejemplo n.º 2
0
Archivo: video.c Proyecto: zmike/compiz
static void
videoDrawWindowTexture(CompWindow *w,
                       CompTexture *texture,
                       const FragmentAttrib *attrib,
                       unsigned int mask)
{
   CompScreen *s = w->screen;

   VIDEO_SCREEN(s);
   VIDEO_WINDOW(w);

   if (vw->context)
     {
        VideoSource *src = vw->context->source;

        if (src->format == IMAGE_FORMAT_YV12 &&
            &src->texture->texture == texture)
          {
             FragmentAttrib fa = *attrib;
             int param, function;

             param = allocFragmentParameters(&fa, 2);

             function = getYV12FragmentFunction(s, texture, param);
             if (function)
               {
                  float minX, minY, maxX, maxY, y1, y2;

                  addFragmentFunction(&fa, function);

                  minX = COMP_TEX_COORD_X(&texture->matrix, 1.0f);
                  maxX = COMP_TEX_COORD_X(&texture->matrix, src->width - 1.0f);

                  y1 = COMP_TEX_COORD_Y(&texture->matrix, 1.0f);
                  y2 = COMP_TEX_COORD_Y(&texture->matrix, src->height - 1.0f);

                  minY = MIN(y1, y2);
                  maxY = MAX(y1, y2);

                  (*s->programEnvParameter4f)(GL_FRAGMENT_PROGRAM_ARB, param,
                                              minX, minY, maxX, maxY);

                  /* need to provide plane offsets when texture coordinates
                     are not normalized */
                  if (texture->target != GL_TEXTURE_2D)
                    {
                       float offsetX, offsetY;

                       offsetX = COMP_TEX_COORD_X(&texture->matrix,
                                                  src->width / 2);

                       if (s->glxPixmapFBConfigs[8].yInverted)
                         offsetY = COMP_TEX_COORD_Y(&texture->matrix,
                                                    src->height);
                       else
                         offsetY = COMP_TEX_COORD_Y(&texture->matrix,
                                                    -src->height / 2);

                       (*s->programEnvParameter4f)(GL_FRAGMENT_PROGRAM_ARB,
                                                   param + 1,
                                                   0.0f, offsetY, offsetX, 0.0f);
                    }
               }

             UNWRAP(vs, s, drawWindowTexture);
             (*s->drawWindowTexture)(w, texture, &fa, mask);
             WRAP(vs, s, drawWindowTexture, videoDrawWindowTexture);
          }
        else
          {
             if (!(mask & PAINT_WINDOW_BLEND_MASK))
               {
                  /* we don't have to draw client window texture when
                     video cover the full window and blending isn't used */
                  if (vw->context->full && texture == w->texture)
                    return;
               }

             UNWRAP(vs, s, drawWindowTexture);
             (*s->drawWindowTexture)(w, texture, attrib, mask);
             WRAP(vs, s, drawWindowTexture, videoDrawWindowTexture);
          }
     }
   else
     {
        UNWRAP(vs, s, drawWindowTexture);
        (*s->drawWindowTexture)(w, texture, attrib, mask);
        WRAP(vs, s, drawWindowTexture, videoDrawWindowTexture);
     }
}
Ejemplo n.º 3
0
static void
waterDrawWindowTexture(CompWindow * w,
		       CompTexture * texture,
		       const FragmentAttrib * attrib, unsigned int mask)
{
	WATER_SCREEN(w->screen);

	if (ws->count) {
		FragmentAttrib fa = *attrib;
		Bool lighting = w->screen->lighting;
		int param, function, unit;
		GLfloat plane[4];

		WATER_DISPLAY(w->screen->display);

		param = allocFragmentParameters(&fa, 1);
		unit = allocFragmentTextureUnits(&fa, 1);

		function =
		    getBumpMapFragmentFunction(w->screen, texture, unit, param);
		if (function) {
			addFragmentFunction(&fa, function);

			screenLighting(w->screen, TRUE);

			(*w->screen->activeTexture) (GL_TEXTURE0_ARB + unit);

			glBindTexture(ws->target, ws->texture[TINDEX(ws, 0)]);

			plane[1] = plane[2] = 0.0f;
			plane[0] = ws->tx / (GLfloat) w->screen->width;
			plane[3] = 0.0f;

			glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
			glTexGenfv(GL_S, GL_EYE_PLANE, plane);
			glEnable(GL_TEXTURE_GEN_S);

			plane[0] = plane[2] = 0.0f;
			plane[1] = ws->ty / (GLfloat) w->screen->height;
			plane[3] = 0.0f;

			glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
			glTexGenfv(GL_T, GL_EYE_PLANE, plane);
			glEnable(GL_TEXTURE_GEN_T);

			(*w->screen->activeTexture) (GL_TEXTURE0_ARB);

			(*w->screen->
			 programEnvParameter4f) (GL_FRAGMENT_PROGRAM_ARB, param,
						 texture->matrix.yy *
						 wd->offsetScale,
						 -texture->matrix.xx *
						 wd->offsetScale, 0.0f, 0.0f);
		}

		/* to get appropriate filtering of texture */
		mask |= PAINT_WINDOW_ON_TRANSFORMED_SCREEN_MASK;

		UNWRAP(ws, w->screen, drawWindowTexture);
		(*w->screen->drawWindowTexture) (w, texture, &fa, mask);
		WRAP(ws, w->screen, drawWindowTexture, waterDrawWindowTexture);

		if (function) {
			(*w->screen->activeTexture) (GL_TEXTURE0_ARB + unit);
			glDisable(GL_TEXTURE_GEN_T);
			glDisable(GL_TEXTURE_GEN_S);
			glBindTexture(ws->target, 0);
			(*w->screen->activeTexture) (GL_TEXTURE0_ARB);

			screenLighting(w->screen, lighting);
		}
	} else {
		UNWRAP(ws, w->screen, drawWindowTexture);
		(*w->screen->drawWindowTexture) (w, texture, attrib, mask);
		WRAP(ws, w->screen, drawWindowTexture, waterDrawWindowTexture);
	}
}