-/* $Id: s_imaging.c,v 1.4 2001/03/19 02:28:59 keithw Exp $ */
-
/*
* Mesa 3-D graphics library
- * Version: 3.5
+ * Version: 6.5
*
- * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
#include "s_context.h"
#include "s_span.h"
+#include "colortab.h"
+#include "convolve.h"
+
void
_swrast_CopyColorTable( GLcontext *ctx,
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLchan data[MAX_WIDTH][4];
+ struct gl_buffer_object *bufferSave;
- /* Select buffer to read from */
- (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
- ctx->Pixel.DriverReadBuffer );
+ if (!ctx->ReadBuffer->_ColorReadBuffer) {
+ /* no readbuffer - OK */
+ return;
+ }
if (width > MAX_WIDTH)
width = MAX_WIDTH;
+ RENDER_START( swrast, ctx );
+
/* read the data from framebuffer */
- _mesa_read_rgba_span( ctx, ctx->ReadBuffer, width, x, y, data );
+ _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer,
+ width, x, y, CHAN_TYPE, data );
+
+ RENDER_FINISH(swrast,ctx);
+
+ /* save PBO binding */
+ bufferSave = ctx->Unpack.BufferObj;
+ ctx->Unpack.BufferObj = ctx->Array.NullBufferObj;
- /* Restore reading from draw buffer (the default) */
- (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer,
- ctx->Color.DriverDrawBuffer );
+ _mesa_ColorTable(target, internalformat, width, GL_RGBA, CHAN_TYPE, data);
- glColorTable(target, internalformat, width, GL_RGBA, GL_UNSIGNED_BYTE, data);
+ /* restore PBO binding */
+ ctx->Unpack.BufferObj = bufferSave;
}
+
void
_swrast_CopyColorSubTable( GLcontext *ctx,GLenum target, GLsizei start,
GLint x, GLint y, GLsizei width)
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLchan data[MAX_WIDTH][4];
+ struct gl_buffer_object *bufferSave;
- /* Select buffer to read from */
- (*swrast->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer,
- ctx->Pixel.DriverReadBuffer );
+ if (!ctx->ReadBuffer->_ColorReadBuffer) {
+ /* no readbuffer - OK */
+ return;
+ }
if (width > MAX_WIDTH)
width = MAX_WIDTH;
+ RENDER_START( swrast, ctx );
+
/* read the data from framebuffer */
- _mesa_read_rgba_span( ctx, ctx->ReadBuffer, width, x, y, data );
+ _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer,
+ width, x, y, CHAN_TYPE, data );
- /* Restore reading from draw buffer (the default) */
- (*swrast->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer,
- ctx->Color.DriverDrawBuffer );
+ RENDER_FINISH(swrast,ctx);
+
+ /* save PBO binding */
+ bufferSave = ctx->Unpack.BufferObj;
+ ctx->Unpack.BufferObj = ctx->Array.NullBufferObj;
+
+ _mesa_ColorSubTable(target, start, width, GL_RGBA, CHAN_TYPE, data);
- glColorSubTable(target, start, width, GL_RGBA, GL_UNSIGNED_BYTE, data);
+ /* restore PBO binding */
+ ctx->Unpack.BufferObj = bufferSave;
}
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLchan rgba[MAX_CONVOLUTION_WIDTH][4];
+ struct gl_buffer_object *bufferSave;
+
+ if (!ctx->ReadBuffer->_ColorReadBuffer) {
+ /* no readbuffer - OK */
+ return;
+ }
RENDER_START( swrast, ctx );
/* read the data from framebuffer */
- _mesa_read_rgba_span( ctx, ctx->ReadBuffer, width, x, y,
- (GLchan (*)[4]) rgba );
+ _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer,
+ width, x, y, CHAN_TYPE, rgba );
RENDER_FINISH( swrast, ctx );
+ /* save PBO binding */
+ bufferSave = ctx->Unpack.BufferObj;
+ ctx->Unpack.BufferObj = ctx->Array.NullBufferObj;
+
/* store as convolution filter */
- glConvolutionFilter1D(target, internalFormat, width,
- GL_RGBA, CHAN_TYPE, rgba);
+ _mesa_ConvolutionFilter1D(target, internalFormat, width,
+ GL_RGBA, CHAN_TYPE, rgba);
+
+ /* restore PBO binding */
+ ctx->Unpack.BufferObj = bufferSave;
}
struct gl_pixelstore_attrib packSave;
GLchan rgba[MAX_CONVOLUTION_HEIGHT][MAX_CONVOLUTION_WIDTH][4];
GLint i;
+ struct gl_buffer_object *bufferSave;
+
+ if (!ctx->ReadBuffer->_ColorReadBuffer) {
+ /* no readbuffer - OK */
+ return;
+ }
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] );
+ _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer,
+ width, x, y + i, CHAN_TYPE, rgba[i] );
}
RENDER_FINISH(swrast,ctx);
ctx->Unpack.SkipImages = 0;
ctx->Unpack.SwapBytes = GL_FALSE;
ctx->Unpack.LsbFirst = GL_FALSE;
+ ctx->Unpack.BufferObj = ctx->Array.NullBufferObj;
ctx->NewState |= _NEW_PACKUNPACK;
- glConvolutionFilter2D(target, internalFormat, width, height,
- GL_RGBA, CHAN_TYPE, rgba);
+ /* save PBO binding */
+ bufferSave = ctx->Unpack.BufferObj;
+ ctx->Unpack.BufferObj = ctx->Array.NullBufferObj;
+
+ _mesa_ConvolutionFilter2D(target, internalFormat, width, height,
+ GL_RGBA, CHAN_TYPE, rgba);
+
+ /* restore PBO binding */
+ ctx->Unpack.BufferObj = bufferSave;
ctx->Unpack = packSave; /* restore pixel packing params */
ctx->NewState |= _NEW_PACKUNPACK;