#include "main/context.h"
#include "main/colormac.h"
#include "main/condrender.h"
-#include "main/convolve.h"
-#include "main/image.h"
#include "main/macros.h"
+#include "main/pixeltransfer.h"
#include "main/imports.h"
#include "s_context.h"
}
-/**
- * RGBA copypixels with convolution.
- */
-static void
-copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
- GLint width, GLint height, GLint destx, GLint desty)
-{
- GLint row;
- const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F;
- const GLbitfield transferOps = ctx->_ImageTransferState;
- const GLboolean sink = (ctx->Pixel.MinMaxEnabled && ctx->MinMax.Sink)
- || (ctx->Pixel.HistogramEnabled && ctx->Histogram.Sink);
- GLfloat *dest, *tmpImage, *convImage;
- SWspan span;
-
- INIT_SPAN(span, GL_BITMAP);
- _swrast_span_default_attribs(ctx, &span);
- span.arrayMask = SPAN_RGBA;
- span.arrayAttribs = FRAG_BIT_COL0;
-
- /* allocate space for GLfloat image */
- tmpImage = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
- if (!tmpImage) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels");
- return;
- }
- convImage = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
- if (!convImage) {
- free(tmpImage);
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels");
- return;
- }
-
- /* read source image as float/RGBA */
- dest = tmpImage;
- for (row = 0; row < height; row++) {
- _swrast_read_rgba_span(ctx, ctx->ReadBuffer->_ColorReadBuffer,
- width, srcx, srcy + row, GL_FLOAT, dest);
- dest += 4 * width;
- }
-
- /* do the image transfer ops which preceed convolution */
- for (row = 0; row < height; row++) {
- GLfloat (*rgba)[4] = (GLfloat (*)[4]) (tmpImage + row * width * 4);
- _mesa_apply_rgba_transfer_ops(ctx,
- transferOps & IMAGE_PRE_CONVOLUTION_BITS,
- width, rgba);
- }
-
- /* do convolution */
- if (ctx->Pixel.Convolution2DEnabled) {
- _mesa_convolve_2d_image(ctx, &width, &height, tmpImage, convImage);
- }
- else {
- ASSERT(ctx->Pixel.Separable2DEnabled);
- _mesa_convolve_sep_image(ctx, &width, &height, tmpImage, convImage);
- }
- free(tmpImage);
-
- /* do remaining post-convolution image transfer ops */
- for (row = 0; row < height; row++) {
- GLfloat (*rgba)[4] = (GLfloat (*)[4]) (convImage + row * width * 4);
- _mesa_apply_rgba_transfer_ops(ctx,
- transferOps & IMAGE_POST_CONVOLUTION_BITS,
- width, rgba);
- }
-
- if (!sink) {
- /* write the new image */
- for (row = 0; row < height; row++) {
- const GLfloat *src = convImage + row * width * 4;
- GLfloat *rgba = (GLfloat *) span.array->attribs[FRAG_ATTRIB_COL0];
-
- /* copy convolved colors into span array */
- memcpy(rgba, src, width * 4 * sizeof(GLfloat));
-
- /* write span */
- span.x = destx;
- span.y = desty + row;
- span.end = width;
- span.array->ChanType = GL_FLOAT;
- if (zoom) {
- _swrast_write_zoomed_rgba_span(ctx, destx, desty, &span, rgba);
- }
- else {
- _swrast_write_rgba_span(ctx, &span);
- }
- }
- /* restore this */
- span.array->ChanType = CHAN_TYPE;
- }
-
- free(convImage);
-}
-
-
/**
* RGBA copypixels
*/
static void
-copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
+copy_rgba_pixels(struct gl_context *ctx, GLint srcx, GLint srcy,
GLint width, GLint height, GLint destx, GLint desty)
{
GLfloat *tmpImage, *p;
return;
}
- if (ctx->Pixel.Convolution2DEnabled || ctx->Pixel.Separable2DEnabled) {
- copy_conv_rgba_pixels(ctx, srcx, srcy, width, height, destx, desty);
- return;
- }
- else if (ctx->Pixel.Convolution1DEnabled) {
- /* make sure we don't apply 1D convolution */
- transferOps &= ~(IMAGE_CONVOLUTION_BIT |
- IMAGE_POST_CONVOLUTION_SCALE_BIAS);
- }
-
if (ctx->DrawBuffer == ctx->ReadBuffer) {
overlapping = regions_overlap(srcx, srcy, destx, desty, width, height,
ctx->Pixel.ZoomX, ctx->Pixel.ZoomY);
* Z scale and bias.
*/
static void
-scale_and_bias_z(GLcontext *ctx, GLuint width,
+scale_and_bias_z(struct gl_context *ctx, GLuint width,
const GLfloat depth[], GLuint z[])
{
const GLuint depthMax = ctx->DrawBuffer->_DepthMax;
* TODO: Optimize!!!!
*/
static void
-copy_depth_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
+copy_depth_pixels( struct gl_context *ctx, GLint srcx, GLint srcy,
GLint width, GLint height,
GLint destx, GLint desty )
{
static void
-copy_stencil_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
+copy_stencil_pixels( struct gl_context *ctx, GLint srcx, GLint srcy,
GLint width, GLint height,
GLint destx, GLint desty )
{
struct gl_renderbuffer *rb = fb->_StencilBuffer;
GLint sy, dy, stepy;
GLint j;
- GLstencil *p, *tmpImage;
+ GLubyte *p, *tmpImage;
const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F;
GLint overlapping;
if (overlapping) {
GLint ssy = sy;
- tmpImage = (GLstencil *) malloc(width * height * sizeof(GLstencil));
+ tmpImage = (GLubyte *) malloc(width * height * sizeof(GLubyte));
if (!tmpImage) {
_mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyPixels" );
return;
}
for (j = 0; j < height; j++, sy += stepy, dy += stepy) {
- GLstencil stencil[MAX_WIDTH];
+ GLubyte stencil[MAX_WIDTH];
/* Get stencil values */
if (overlapping) {
- memcpy(stencil, p, width * sizeof(GLstencil));
+ memcpy(stencil, p, width * sizeof(GLubyte));
p += width;
}
else {
* CopyPixels function.
*/
static void
-copy_depth_stencil_pixels(GLcontext *ctx,
+copy_depth_stencil_pixels(struct gl_context *ctx,
const GLint srcX, const GLint srcY,
const GLint width, const GLint height,
const GLint destX, const GLint destY)
struct gl_renderbuffer *stencilReadRb, *depthReadRb, *depthDrawRb;
GLint sy, dy, stepy;
GLint j;
- GLstencil *tempStencilImage = NULL, *stencilPtr = NULL;
+ GLubyte *tempStencilImage = NULL, *stencilPtr = NULL;
GLfloat *tempDepthImage = NULL, *depthPtr = NULL;
const GLfloat depthScale = ctx->DrawBuffer->_DepthMaxF;
const GLuint stencilMask = ctx->Stencil.WriteMask[0];
if (stencilMask != 0x0) {
tempStencilImage
- = (GLstencil *) malloc(width * height * sizeof(GLstencil));
+ = (GLubyte *) malloc(width * height * sizeof(GLubyte));
if (!tempStencilImage) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels");
return;
for (j = 0; j < height; j++, sy += stepy, dy += stepy) {
if (stencilMask != 0x0) {
- GLstencil stencil[MAX_WIDTH];
+ GLubyte stencil[MAX_WIDTH];
/* Get stencil values */
if (overlapping) {
- memcpy(stencil, stencilPtr, width * sizeof(GLstencil));
+ memcpy(stencil, stencilPtr, width * sizeof(GLubyte));
stencilPtr += width;
}
else {
* Try to do a fast copy pixels.
*/
static GLboolean
-fast_copy_pixels(GLcontext *ctx,
+fast_copy_pixels(struct gl_context *ctx,
GLint srcX, GLint srcY, GLsizei width, GLsizei height,
GLint dstX, GLint dstY, GLenum type)
{
* By time we get here, all parameters will have been error-checked.
*/
void
-_swrast_CopyPixels( GLcontext *ctx,
+_swrast_CopyPixels( struct gl_context *ctx,
GLint srcx, GLint srcy, GLsizei width, GLsizei height,
GLint destx, GLint desty, GLenum type )
{