Rename _mesa_update_buffers() to _mesa_update_draw_buffer_bounds() and do

additional checks.
Replace _mesa_init_buffers() with _mesa_init_scissor() and _mesa_init_multisample().
This commit is contained in:
Brian Paul
2005-02-26 17:16:12 +00:00
parent 4932ba28ad
commit 67742383e8
4 changed files with 67 additions and 43 deletions

View File

@@ -5,9 +5,9 @@
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
* Version: 6.1 * Version: 6.3
* *
* Copyright (C) 1999-2004 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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -645,51 +645,62 @@ _mesa_Scissor( GLint x, GLint y, GLsizei width, GLsizei height )
/** \name State management */ /** \name State management */
/*@{*/ /*@{*/
/** /**
* Update screen bounds. * Update the context's current drawing buffer's Xmin, Xmax, Ymin, Ymax fields.
* * These values are computed from the buffer's width and height and
* \param ctx GL context. * the scissor box, if it's enabled.
* * \param ctx the GL context.
* Update gl_frame_buffer::_Xmin, and etc.
*/ */
void _mesa_update_buffers( GLcontext *ctx ) void
_mesa_update_draw_buffer_bounds(GLcontext *ctx)
{ {
ctx->DrawBuffer->_Xmin = 0; GLframebuffer *buffer = ctx->DrawBuffer;
ctx->DrawBuffer->_Ymin = 0;
ctx->DrawBuffer->_Xmax = ctx->DrawBuffer->Width; buffer->_Xmin = 0;
ctx->DrawBuffer->_Ymax = ctx->DrawBuffer->Height; buffer->_Ymin = 0;
buffer->_Xmax = buffer->Width;
buffer->_Ymax = buffer->Height;
if (ctx->Scissor.Enabled) { if (ctx->Scissor.Enabled) {
if (ctx->Scissor.X > ctx->DrawBuffer->_Xmin) { if (ctx->Scissor.X > buffer->_Xmin) {
ctx->DrawBuffer->_Xmin = ctx->Scissor.X; buffer->_Xmin = ctx->Scissor.X;
} }
if (ctx->Scissor.Y > ctx->DrawBuffer->_Ymin) { if (ctx->Scissor.Y > buffer->_Ymin) {
ctx->DrawBuffer->_Ymin = ctx->Scissor.Y; buffer->_Ymin = ctx->Scissor.Y;
} }
if (ctx->Scissor.X + ctx->Scissor.Width < ctx->DrawBuffer->_Xmax) { if (ctx->Scissor.X + ctx->Scissor.Width < buffer->_Xmax) {
ctx->DrawBuffer->_Xmax = ctx->Scissor.X + ctx->Scissor.Width; buffer->_Xmax = ctx->Scissor.X + ctx->Scissor.Width;
} }
if (ctx->Scissor.Y + ctx->Scissor.Height < ctx->DrawBuffer->_Ymax) { if (ctx->Scissor.Y + ctx->Scissor.Height < buffer->_Ymax) {
ctx->DrawBuffer->_Ymax = ctx->Scissor.Y + ctx->Scissor.Height; buffer->_Ymax = ctx->Scissor.Y + ctx->Scissor.Height;
}
/* finally, check for empty region */
if (buffer->_Xmin > buffer->_Xmax) {
buffer->_Xmin = buffer->_Xmax;
}
if (buffer->_Ymin > buffer->_Ymax) {
buffer->_Ymin = buffer->_Ymax;
} }
} }
ASSERT(buffer->_Xmin <= buffer->_Xmax);
ASSERT(buffer->_Ymin <= buffer->_Ymax);
} }
/*@}*/ /*@}*/
/**********************************************************************/ /**********************************************************************/
/** \name Initialization */ /** \name Initialization */
/*@{*/ /*@{*/
/** /**
* Initialize the context scissor data. * Initialize the context's scissor state.
* * \param ctx the GL context.
* \param ctx GL context.
*
* Initializes the __GLcontextRec::Scissor and __GLcontextRec::Multisample
* attribute groups, and related constants in __GLcontextRec::Const.
*/ */
void _mesa_init_buffers( GLcontext * ctx ) void
_mesa_init_scissor(GLcontext *ctx)
{ {
/* Scissor group */ /* Scissor group */
ctx->Scissor.Enabled = GL_FALSE; ctx->Scissor.Enabled = GL_FALSE;
@@ -697,15 +708,22 @@ void _mesa_init_buffers( GLcontext * ctx )
ctx->Scissor.Y = 0; ctx->Scissor.Y = 0;
ctx->Scissor.Width = 0; ctx->Scissor.Width = 0;
ctx->Scissor.Height = 0; ctx->Scissor.Height = 0;
}
/* Multisample */
/**
* Initialize the context's multisample state.
* \param ctx the GL context.
*/
void
_mesa_init_multisample(GLcontext *ctx)
{
ctx->Multisample.Enabled = GL_FALSE; ctx->Multisample.Enabled = GL_FALSE;
ctx->Multisample.SampleAlphaToCoverage = GL_FALSE; ctx->Multisample.SampleAlphaToCoverage = GL_FALSE;
ctx->Multisample.SampleAlphaToOne = GL_FALSE; ctx->Multisample.SampleAlphaToOne = GL_FALSE;
ctx->Multisample.SampleCoverage = GL_FALSE; ctx->Multisample.SampleCoverage = GL_FALSE;
ctx->Multisample.SampleCoverageValue = 1.0; ctx->Multisample.SampleCoverageValue = 1.0;
ctx->Multisample.SampleCoverageInvert = GL_FALSE; ctx->Multisample.SampleCoverageInvert = GL_FALSE;
} }
/*@}*/ /*@}*/

View File

@@ -5,9 +5,9 @@
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
* Version: 3.5 * Version: 6.3
* *
* 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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -65,9 +65,13 @@ extern void GLAPIENTRY
_mesa_SampleCoverageARB(GLclampf value, GLboolean invert); _mesa_SampleCoverageARB(GLclampf value, GLboolean invert);
extern void extern void
_mesa_init_buffers( GLcontext * ctx ); _mesa_update_draw_buffer_bounds(GLcontext *ctx);
extern void extern void
_mesa_update_buffers( GLcontext *ctx ); _mesa_init_scissor(GLcontext *ctx);
extern void
_mesa_init_multisample(GLcontext *ctx);
#endif #endif

View File

@@ -1194,7 +1194,6 @@ init_attrib_groups( GLcontext *ctx )
/* Attribute Groups */ /* Attribute Groups */
_mesa_init_accum( ctx ); _mesa_init_accum( ctx );
_mesa_init_attrib( ctx ); _mesa_init_attrib( ctx );
_mesa_init_buffers( ctx );
_mesa_init_buffer_objects( ctx ); _mesa_init_buffer_objects( ctx );
_mesa_init_color( ctx ); _mesa_init_color( ctx );
_mesa_init_colortables( ctx ); _mesa_init_colortables( ctx );
@@ -1210,12 +1209,14 @@ init_attrib_groups( GLcontext *ctx )
_mesa_init_line( ctx ); _mesa_init_line( ctx );
_mesa_init_lighting( ctx ); _mesa_init_lighting( ctx );
_mesa_init_matrix( ctx ); _mesa_init_matrix( ctx );
_mesa_init_multisample( ctx );
_mesa_init_occlude( ctx ); _mesa_init_occlude( ctx );
_mesa_init_pixel( ctx ); _mesa_init_pixel( ctx );
_mesa_init_point( ctx ); _mesa_init_point( ctx );
_mesa_init_polygon( ctx ); _mesa_init_polygon( ctx );
_mesa_init_program( ctx ); _mesa_init_program( ctx );
_mesa_init_rastpos( ctx ); _mesa_init_rastpos( ctx );
_mesa_init_scissor( ctx );
_mesa_init_shaderobjects (ctx); _mesa_init_shaderobjects (ctx);
_mesa_init_stencil( ctx ); _mesa_init_stencil( ctx );
_mesa_init_transform( ctx ); _mesa_init_transform( ctx );

View File

@@ -2,7 +2,7 @@
* Mesa 3-D graphics library * Mesa 3-D graphics library
* Version: 6.3 * Version: 6.3
* *
* Copyright (C) 1999-2004 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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -935,20 +935,21 @@ update_program(GLcontext *ctx)
} }
/* /**
* If __GLcontextRec::NewState is non-zero then this function \b must be called * If __GLcontextRec::NewState is non-zero then this function \b must be called
* before rendering any primitive. Basically, function pointers and * before rendering any primitive. Basically, function pointers and
* miscellaneous flags are updated to reflect the current state of the state * miscellaneous flags are updated to reflect the current state of the state
* machine. * machine.
* *
* Calls dd_function_table::UpdateState to perform any internal state management * Calls dd_function_table::UpdateState to perform any internal state
* necessary. * management necessary.
* *
* \sa _mesa_update_modelview_project(), _mesa_update_texture(), * \sa _mesa_update_modelview_project(), _mesa_update_texture(),
* _mesa_update_buffers(), _mesa_update_polygon(), _mesa_update_lighting() and * _mesa_update_buffer_bounds(), _mesa_update_polygon(),
* _mesa_update_tnl_spaces(). * _mesa_update_lighting() and _mesa_update_tnl_spaces().
*/ */
void _mesa_update_state( GLcontext *ctx ) void
_mesa_update_state( GLcontext *ctx )
{ {
GLuint new_state = ctx->NewState; GLuint new_state = ctx->NewState;
@@ -965,7 +966,7 @@ void _mesa_update_state( GLcontext *ctx )
_mesa_update_texture( ctx, new_state ); _mesa_update_texture( ctx, new_state );
if (new_state & (_NEW_SCISSOR|_NEW_BUFFERS)) if (new_state & (_NEW_SCISSOR|_NEW_BUFFERS))
_mesa_update_buffers( ctx ); _mesa_update_draw_buffer_bounds( ctx );
if (new_state & _NEW_POLYGON) if (new_state & _NEW_POLYGON)
_mesa_update_polygon( ctx ); _mesa_update_polygon( ctx );