From 16461f7c53f3bd88ec20458edfc247df14cde721 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 6 Feb 2001 17:22:16 +0000 Subject: added _mesa_adjust_image_for_convolution() --- src/mesa/main/convolve.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'src/mesa/main/convolve.c') diff --git a/src/mesa/main/convolve.c b/src/mesa/main/convolve.c index 1a32acb41e..891e0aa5a6 100644 --- a/src/mesa/main/convolve.c +++ b/src/mesa/main/convolve.c @@ -1,10 +1,10 @@ -/* $Id: convolve.c,v 1.18 2001/01/05 02:26:48 keithw Exp $ */ +/* $Id: convolve.c,v 1.19 2001/02/06 17:22:16 brianp Exp $ */ /* * Mesa 3-D graphics library * Version: 3.5 * - * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2001 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"), @@ -1420,3 +1420,34 @@ _mesa_convolve_sep_image(const GLcontext *ctx, ; } } + + + +/* + * This function computes an image's size after convolution. + * If the convolution border mode is GL_REDUCE, the post-convolution + * image will be smaller than the original. + */ +void +_mesa_adjust_image_for_convolution(const GLcontext *ctx, GLuint dimensions, + GLsizei *width, GLsizei *height) +{ + if (ctx->Pixel.Convolution1DEnabled + && dimensions == 1 + && ctx->Pixel.ConvolutionBorderMode[0] == GL_REDUCE) { + *width = *width - (MAX2(ctx->Convolution1D.Width, 1) - 1); + } + else if (ctx->Pixel.Convolution2DEnabled + && dimensions > 1 + && ctx->Pixel.ConvolutionBorderMode[1] == GL_REDUCE) { + *width = *width - (MAX2(ctx->Convolution2D.Width, 1) - 1); + *height = *height - (MAX2(ctx->Convolution2D.Height, 1) - 1); + } + else if (ctx->Pixel.Separable2DEnabled + && dimensions > 1 + && ctx->Pixel.ConvolutionBorderMode[2] == GL_REDUCE) { + *width = *width - (MAX2(ctx->Separable2D.Width, 1) - 1); + *height = *height - (MAX2(ctx->Separable2D.Height, 1) - 1); + } +} + -- cgit v1.2.3