From 99796464c5f0fdb463c31a0e99b0896089b8bd80 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 27 Sep 2005 01:25:24 +0000 Subject: Lift all the format/type error checking out of the _swrast_Draw/Read/CopyPixels functions into the _mesa_Draw/Read/CopyPixels functions. --- src/mesa/swrast/s_copypix.c | 45 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 25 deletions(-) (limited to 'src/mesa/swrast/s_copypix.c') diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c index 2b4e845..ed6a02e 100644 --- a/src/mesa/swrast/s_copypix.c +++ b/src/mesa/swrast/s_copypix.c @@ -517,11 +517,6 @@ copy_depth_pixels( GLcontext *ctx, GLint srcx, GLint srcy, INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_Z); - if (fb->Visual.depthBits == 0) { - _mesa_error( ctx, GL_INVALID_OPERATION, "glCopyPixels" ); - return; - } - /* Determine if copy should be bottom-to-top or top-to-bottom */ if (srcyPixel.IndexShift || ctx->Pixel.IndexOffset; GLint overlapping; - if (fb->Visual.stencilBits == 0) { - _mesa_error( ctx, GL_INVALID_OPERATION, "glCopyPixels" ); - return; - } - if (!rb) { /* no readbuffer - OK */ return; @@ -709,12 +699,14 @@ copy_stencil_pixels( GLcontext *ctx, GLint srcx, GLint srcy, } - +/** + * Do software-based glCopyPixels. + * By time we get here, all parameters will have been error-checked. + */ void _swrast_CopyPixels( GLcontext *ctx, GLint srcx, GLint srcy, GLsizei width, GLsizei height, - GLint destx, GLint desty, - GLenum type ) + GLint destx, GLint desty, GLenum type ) { SWcontext *swrast = SWRAST_CONTEXT(ctx); RENDER_START(swrast,ctx); @@ -722,20 +714,23 @@ _swrast_CopyPixels( GLcontext *ctx, if (swrast->NewState) _swrast_validate_derived( ctx ); - if (type == GL_COLOR && ctx->Visual.rgbMode) { - copy_rgba_pixels( ctx, srcx, srcy, width, height, destx, desty ); - } - else if (type == GL_COLOR && !ctx->Visual.rgbMode) { - copy_ci_pixels( ctx, srcx, srcy, width, height, destx, desty ); - } - else if (type == GL_DEPTH) { + switch (type) { + case GL_COLOR: + if (ctx->Visual.rgbMode) { + copy_rgba_pixels( ctx, srcx, srcy, width, height, destx, desty ); + } + else { + copy_ci_pixels( ctx, srcx, srcy, width, height, destx, desty ); + } + break; + case GL_DEPTH: copy_depth_pixels( ctx, srcx, srcy, width, height, destx, desty ); - } - else if (type == GL_STENCIL) { + break; + case GL_STENCIL: copy_stencil_pixels( ctx, srcx, srcy, width, height, destx, desty ); - } - else { - _mesa_error( ctx, GL_INVALID_ENUM, "glCopyPixels" ); + break; + default: + _mesa_problem(ctx, "unexpected type in _swrast_CopyPixels"); } RENDER_FINISH(swrast,ctx); -- cgit v1.1