Ejemplo n.º 1
0
Archivo: s_imaging.c Proyecto: aosm/X11
void
_swrast_CopyConvolutionFilter1D(GLcontext *ctx, GLenum target, 
				GLenum internalFormat, 
				GLint x, GLint y, GLsizei width)
{
   SWcontext *swrast = SWRAST_CONTEXT(ctx);
   GLchan rgba[MAX_CONVOLUTION_WIDTH][4];

   /* Select buffer to read from */
   _swrast_use_read_buffer(ctx);

   RENDER_START( swrast, ctx );

   /* read the data from framebuffer */
   _mesa_read_rgba_span( ctx, ctx->ReadBuffer, width, x, y,
				(GLchan (*)[4]) rgba );
   
   RENDER_FINISH( swrast, ctx );

   /* Restore reading from draw buffer (the default) */
   _swrast_use_draw_buffer(ctx);

   /* store as convolution filter */
   glConvolutionFilter1D(target, internalFormat, width,
			 GL_RGBA, CHAN_TYPE, rgba);
}
Ejemplo n.º 2
0
Archivo: s_imaging.c Proyecto: aosm/X11
void
_swrast_CopyConvolutionFilter2D(GLcontext *ctx, GLenum target, 
				GLenum internalFormat, 
				GLint x, GLint y, GLsizei width, GLsizei height)
{
   SWcontext *swrast = SWRAST_CONTEXT(ctx);
   struct gl_pixelstore_attrib packSave;
   GLchan rgba[MAX_CONVOLUTION_HEIGHT][MAX_CONVOLUTION_WIDTH][4];
   GLint i;

   /* Select buffer to read from */
   _swrast_use_read_buffer(ctx);

   RENDER_START(swrast,ctx);
   
   /* read pixels from framebuffer */
   for (i = 0; i < height; i++) {
      _mesa_read_rgba_span( ctx, ctx->ReadBuffer, width, x, y + i,
				(GLchan (*)[4]) rgba[i] );
   }

   RENDER_FINISH(swrast,ctx);

   /* Restore reading from draw buffer (the default) */
   _swrast_use_draw_buffer(ctx);

   /*
    * HACK: save & restore context state so we can store this as a
    * convolution filter via the GL api.  Doesn't call any callbacks
    * hanging off ctx->Unpack statechanges.
    */

   packSave = ctx->Unpack;  /* save pixel packing params */

   ctx->Unpack.Alignment = 1;
   ctx->Unpack.RowLength = MAX_CONVOLUTION_WIDTH;
   ctx->Unpack.SkipPixels = 0;
   ctx->Unpack.SkipRows = 0;
   ctx->Unpack.ImageHeight = 0;
   ctx->Unpack.SkipImages = 0;
   ctx->Unpack.SwapBytes = GL_FALSE;
   ctx->Unpack.LsbFirst = GL_FALSE;
   ctx->NewState |= _NEW_PACKUNPACK;

   glConvolutionFilter2D(target, internalFormat, width, height,
			 GL_RGBA, CHAN_TYPE, rgba);

   ctx->Unpack = packSave;  /* restore pixel packing params */
   ctx->NewState |= _NEW_PACKUNPACK; 
}
Ejemplo n.º 3
0
Archivo: s_imaging.c Proyecto: aosm/X11
void
_swrast_CopyColorSubTable( GLcontext *ctx,GLenum target, GLsizei start,
			   GLint x, GLint y, GLsizei width)
{
   GLchan data[MAX_WIDTH][4];

   /* Select buffer to read from */
   _swrast_use_read_buffer(ctx);

   if (width > MAX_WIDTH)
      width = MAX_WIDTH;

   /* read the data from framebuffer */
   _mesa_read_rgba_span( ctx, ctx->ReadBuffer, width, x, y, data );

   /* Restore reading from draw buffer (the default) */
   _swrast_use_draw_buffer(ctx);

   glColorSubTable(target, start, width, GL_RGBA, CHAN_TYPE, data);
}
Ejemplo n.º 4
0
/*
 * Clear the front/back/left/right color buffers.
 * This function is usually only called if we need to clear the
 * buffers with masking.
 */
static void
clear_color_buffers(GLcontext *ctx)
{
   SWcontext *swrast = SWRAST_CONTEXT(ctx);
   const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
   GLuint bufferBit;

   /* loop over four possible dest color buffers */
   for (bufferBit = 1; bufferBit <= 8; bufferBit = bufferBit << 1) {
      if (bufferBit & ctx->Color._DrawDestMask) {
         (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, bufferBit);

         if (colorMask != 0xffffffff) {
            clear_color_buffer_with_masking(ctx);
         }
         else {
            clear_color_buffer(ctx);
         }
      }
   }

   /* restore default read/draw buffer */
   _swrast_use_draw_buffer(ctx);
}
Ejemplo n.º 5
0
/*
 * Fallback for ctx->Driver.DrawBuffer()
 */
void
_swrast_DrawBuffer( GLcontext *ctx, GLenum mode )
{
   _swrast_use_draw_buffer(ctx);
}