Remove _mesa_ResizeBuffersMESA() call from _mesa_set_viewport().

Now, the driver's Viewport routine should call _mesa_ResizeBuffersMESA()
if necessary.
Cleaned up code related to GLframebuffer width/height initialization.
Set initial viewport/scissor params in _mesa_make_current2(), instead of
in the drivers' MakeCurrent functions.
This commit is contained in:
Brian Paul 2004-11-27 22:47:59 +00:00
parent 118a8bad73
commit 65a66f5bc3
41 changed files with 175 additions and 151 deletions

View file

@ -21,6 +21,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <allegro.h>
#include "buffers.h"
#include "context.h"
#include "imports.h"
#include "matrix.h"
@ -144,6 +145,13 @@ static void get_buffer_size(GLcontext *ctx, GLuint *width, GLuint *height)
}
static void viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
{
/* poll for window size change and realloc software Z/stencil/etc if needed */
_mesa_ResizeBuffersMESA();
}
/**********************************************************************/
/**********************************************************************/
@ -155,8 +163,9 @@ static void setup_dd_pointers(GLcontext *ctx)
/* a new context is made current or we change buffers via set_buffer! */
ctx->Driver.UpdateState = setup_dd_pointers;
ctx->Driver.SetBuffer = set_buffer;
ctx->Driver.GetBufferSize = get_buffer_size;
ctx->Driver.SetBuffer = set_buffer;
ctx->Driver.GetBufferSize = get_buffer_size;
ctx->Driver.Viewport = viewport;
ctx->Driver.Color = set_color_generic;
ctx->Driver.ClearColor = clear_color_generic;
@ -371,9 +380,9 @@ GLboolean AMesaMakeCurrent(AMesaContext context, AMesaBuffer buffer)
setup_dd_pointers(context->GLContext);
_mesa_make_current(context->GLContext, buffer->GLBuffer);
_mesa_set_viewport(context->GLContext, 0, 0, buffer->Width, buffer->Height);
}
else {
/* XXX I don't think you want to destroy anything here! */
destroy_bitmap(context->Buffer->Screen);
context->Buffer->Screen = NULL;
context->Buffer->Active = NULL;

View file

@ -153,6 +153,7 @@ private:
GLuint *height);
static void Error(GLcontext *ctx);
static const GLubyte * GetString(GLcontext *ctx, GLenum name);
static void Viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h);
// Front-buffer functions
static void WriteRGBASpanFront(const GLcontext *ctx, GLuint n,
@ -317,6 +318,7 @@ BGLView::BGLView(BRect rect, char *name,
functions.ClearIndex = md->ClearIndex;
functions.ClearColor = md->ClearColor;
functions.Error = md->Error;
functions.Viewport = md->Viewport;
// create core context
GLcontext *ctx = _mesa_create_context(visual, NULL, &functions, md);
@ -1028,6 +1030,13 @@ void MesaDriver::GetBufferSize(GLframebuffer * framebuffer, GLuint *width,
}
void MesaDriver::Viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
{
/* poll for window size change and realloc software Z/stencil/etc if needed */
_mesa_ResizeBuffersMESA();
}
const GLubyte *MesaDriver::GetString(GLcontext *ctx, GLenum name)
{
switch (name) {

View file

@ -36,6 +36,7 @@
#include "imports.h"
#ifndef FX
#include "bufferobj.h"
#include "buffers.h"
#include "extensions.h"
#include "macros.h"
#include "matrix.h"
@ -812,6 +813,14 @@ get_buffer_size (GLframebuffer *buffer, GLuint *width, GLuint *height)
}
static void
viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
{
/* poll for window size change and realloc software Z/stencil/etc if needed */
_mesa_ResizeBuffersMESA();
}
static const GLubyte *
get_string (GLcontext *ctx, GLenum name)
{
@ -898,6 +907,7 @@ dmesa_init_driver_functions (DMesaVisual visual,
driver->UpdateState = dmesa_update_state;
driver->GetString = get_string;
driver->GetBufferSize = get_buffer_size;
driver->Viewport = viewport;
driver->Flush = flush;
driver->Finish = finish;
driver->Clear = clear;
@ -1271,11 +1281,8 @@ DMesaMakeCurrent (DMesaContext c, DMesaBuffer b)
c->buffer = b;
_mesa_make_current((GLcontext *)c, (GLframebuffer *)b);
if (((GLcontext *)c)->Viewport.Width == 0) {
/* initialize viewport to window size */
_mesa_Viewport(0, 0, b->width, b->height);
}
} else {
}
else {
/* Detach */
_mesa_make_current(NULL, NULL);
}

View file

@ -63,6 +63,7 @@
#include "miniglxP.h" /* window-system-specific */
#include "dri_util.h" /* window-system-specific-ish */
#include "buffers.h"
#include "context.h"
#include "extensions.h"
#include "imports.h"
@ -133,6 +134,13 @@ get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
}
static void
viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
{
_mesa_ResizeBuffersMESA();
}
/* specifies the buffer for swrast span rendering/reading */
static void
set_buffer( GLcontext *ctx, GLframebuffer *buffer, GLuint bufferBit )
@ -166,6 +174,7 @@ init_core_functions( struct dd_function_table *functions )
functions->UpdateState = update_state;
functions->ResizeBuffers = _swrast_alloc_buffers;
functions->GetBufferSize = get_buffer_size;
functions->Viewport = viewport;
functions->Clear = _swrast_Clear; /* could accelerate with blits */
}
@ -536,11 +545,6 @@ fbMakeCurrent( __DRIcontextPrivate *driContextPriv,
_mesa_make_current2( newFbCtx->glCtx,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate );
if ( !newFbCtx->glCtx->Viewport.Width ) {
_mesa_set_viewport( newFbCtx->glCtx, 0, 0,
driDrawPriv->w, driDrawPriv->h );
}
} else {
_mesa_make_current( 0, 0 );
}

View file

@ -26,6 +26,7 @@
*/
#include "mtypes.h"
#include "buffers.h"
#include "colormac.h"
#include "mm.h"
#include "ffb_dd.h"
@ -444,6 +445,8 @@ void ffbCalcViewport(GLcontext *ctx)
static void ffbDDViewport(GLcontext *ctx, GLint x, GLint y,
GLsizei width, GLsizei height)
{
/* update size of Mesa/software ancillary buffers */
_mesa_ResizeBuffersMESA();
ffbCalcViewport(ctx);
}

View file

@ -494,12 +494,6 @@ ffbMakeCurrent(__DRIcontextPrivate *driContextPriv,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate);
if (!fmesa->glCtx->Viewport.Width)
_mesa_set_viewport(fmesa->glCtx,
0, 0,
driDrawPriv->w,
driDrawPriv->h);
first_time = 0;
if (fmesa->wid == ~0) {
first_time = 1;

View file

@ -27,6 +27,7 @@
#include "gamma_context.h"
#include "gamma_macros.h"
#include "buffers.h"
#include "macros.h"
#include "glint_dri.h"
#include "colormac.h"
@ -1098,6 +1099,8 @@ void gammaUpdateWindow( GLcontext *ctx )
static void gammaDDViewport( GLcontext *ctx, GLint x, GLint y,
GLsizei width, GLsizei height )
{
/* update size of Mesa/software ancillary buffers */
_mesa_ResizeBuffersMESA();
gammaUpdateWindow( ctx );
}

View file

@ -225,11 +225,6 @@ newGammaCtx->new_state |= GAMMA_NEW_WINDOW; /* FIXME */
_mesa_make_current2( newGammaCtx->glCtx,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate );
if (!newGammaCtx->glCtx->Viewport.Width) {
_mesa_set_viewport(newGammaCtx->glCtx, 0, 0,
driDrawPriv->w, driDrawPriv->h);
}
} else {
_mesa_make_current( 0, 0 );
}

View file

@ -431,9 +431,6 @@ i810MakeCurrent(__DRIcontextPrivate *driContextPriv,
/* Are these necessary?
*/
i810XMesaWindowMoved( imesa );
if (!imesa->glCtx->Viewport.Width)
_mesa_set_viewport(imesa->glCtx, 0, 0,
driDrawPriv->w, driDrawPriv->h);
}
else {
_mesa_make_current(0,0);

View file

@ -3,6 +3,7 @@
#include <stdio.h>
#include "glheader.h"
#include "buffers.h"
#include "context.h"
#include "macros.h"
#include "enums.h"
@ -682,6 +683,8 @@ static void i810Viewport( GLcontext *ctx,
GLint x, GLint y,
GLsizei width, GLsizei height )
{
/* update size of Mesa/software ancillary buffers */
_mesa_ResizeBuffersMESA();
i810CalcViewport( ctx );
}

View file

@ -530,10 +530,6 @@ GLboolean i830MakeCurrent(__DRIcontextPrivate *driContextPriv,
_mesa_make_current2(imesa->glCtx,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate);
if (!imesa->glCtx->Viewport.Width)
_mesa_set_viewport(imesa->glCtx, 0, 0,
driDrawPriv->w, driDrawPriv->h);
} else {
_mesa_make_current(0,0);
}

View file

@ -36,6 +36,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "glheader.h"
#include "buffers.h"
#include "context.h"
#include "macros.h"
#include "enums.h"
@ -1228,6 +1229,8 @@ static void i830Viewport( GLcontext *ctx,
GLint x, GLint y,
GLsizei width, GLsizei height )
{
/* update size of Mesa/software ancillary buffers */
_mesa_ResizeBuffersMESA();
i830CalcViewport( ctx );
}

View file

@ -534,9 +534,6 @@ GLboolean intelMakeCurrent(__DRIcontextPrivate *driContextPriv,
_mesa_make_current2(&intel->ctx,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate);
if (!intel->ctx.Viewport.Width)
_mesa_set_viewport(&intel->ctx, 0, 0, driDrawPriv->w, driDrawPriv->h);
} else {
_mesa_make_current(0,0);
}

View file

@ -312,11 +312,6 @@ mach64MakeCurrent( __DRIcontextPrivate *driContextPriv,
newMach64Ctx->new_state |= MACH64_NEW_CLIP;
if ( !newMach64Ctx->glCtx->Viewport.Width ) {
_mesa_set_viewport(newMach64Ctx->glCtx, 0, 0,
driDrawPriv->w, driDrawPriv->h);
}
} else {
_mesa_make_current( 0, 0 );
}

View file

@ -37,6 +37,7 @@
#include "mach64_tex.h"
#include "context.h"
#include "buffers.h"
#include "enums.h"
#include "colormac.h"
#include "swrast/swrast.h"
@ -646,6 +647,8 @@ static void mach64Viewport( GLcontext *ctx,
GLint x, GLint y,
GLsizei width, GLsizei height )
{
/* update size of Mesa/software ancillary buffers */
_mesa_ResizeBuffersMESA();
mach64CalcViewport( ctx );
}

View file

@ -802,11 +802,6 @@ mgaMakeCurrent(__DRIcontextPrivate *driContextPriv,
_mesa_make_current2(mmesa->glCtx,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate);
if (!mmesa->glCtx->Viewport.Width)
_mesa_set_viewport(mmesa->glCtx, 0, 0,
driDrawPriv->w, driDrawPriv->h);
}
else {
_mesa_make_current(NULL, NULL);

View file

@ -28,6 +28,7 @@
#include "mtypes.h"
#include "buffers.h"
#include "colormac.h"
#include "dd.h"
@ -695,6 +696,8 @@ static void mgaViewport( GLcontext *ctx,
GLint x, GLint y,
GLsizei width, GLsizei height )
{
/* update size of Mesa/software ancillary buffers */
_mesa_ResizeBuffersMESA();
mgaCalcViewport( ctx );
}

View file

@ -341,13 +341,7 @@ r128MakeCurrent( __DRIcontextPrivate *driContextPriv,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate );
newR128Ctx->new_state |= R128_NEW_WINDOW | R128_NEW_CLIP;
if ( !newR128Ctx->glCtx->Viewport.Width ) {
_mesa_set_viewport(newR128Ctx->glCtx, 0, 0,
driDrawPriv->w, driDrawPriv->h);
}
} else {
_mesa_make_current( 0, 0 );
}

View file

@ -41,6 +41,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "r128_tex.h"
#include "context.h"
#include "buffers.h"
#include "enums.h"
#include "colormac.h"
#include "swrast/swrast.h"
@ -664,6 +665,8 @@ static void r128Viewport( GLcontext *ctx,
GLint x, GLint y,
GLsizei width, GLsizei height )
{
/* update size of Mesa/software ancillary buffers */
_mesa_ResizeBuffersMESA();
r128CalcViewport( ctx );
}

View file

@ -624,11 +624,6 @@ r200MakeCurrent( __DRIcontextPrivate *driContextPriv,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate );
if ( !newCtx->glCtx->Viewport.Width ) {
_mesa_set_viewport( newCtx->glCtx, 0, 0,
driDrawPriv->w, driDrawPriv->h );
}
if (newCtx->vb.enabled)
r200VtxfmtMakeCurrent( newCtx->glCtx );

View file

@ -593,11 +593,6 @@ radeonMakeCurrent( __DRIcontextPrivate *driContextPriv,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate );
if ( !newCtx->glCtx->Viewport.Width ) {
_mesa_set_viewport( newCtx->glCtx, 0, 0,
driDrawPriv->w, driDrawPriv->h );
}
if (newCtx->vb.enabled)
radeonVtxfmtMakeCurrent( newCtx->glCtx );

View file

@ -39,6 +39,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "enums.h"
#include "colormac.h"
#include "state.h"
#include "buffers.h"
#include "context.h"
#include "swrast/swrast.h"
@ -1451,6 +1452,8 @@ void radeonUpdateWindow( GLcontext *ctx )
static void radeonViewport( GLcontext *ctx, GLint x, GLint y,
GLsizei width, GLsizei height )
{
/* update size of Mesa/software ancillary buffers */
_mesa_ResizeBuffersMESA();
/* Don't pipeline viewport changes, conflict with window offset
* setting below. Could apply deltas to rescue pipelined viewport
* values, or keep the originals hanging around.

View file

@ -676,10 +676,6 @@ savageMakeCurrent(__DRIcontextPrivate *driContextPriv,
(GLframebuffer *) driReadPriv->driverPrivate);
savageXMesaWindowMoved( imesa );
if (!imesa->glCtx->Viewport.Width)
_mesa_set_viewport(imesa->glCtx, 0, 0,
driDrawPriv->w, driDrawPriv->h);
}
else
{

View file

@ -26,6 +26,7 @@
#include <stdio.h>
#include "mtypes.h"
#include "buffers.h"
#include "enums.h"
#include "macros.h"
#include "dd.h"
@ -704,6 +705,8 @@ static void savageViewport( GLcontext *ctx,
GLint x, GLint y,
GLsizei width, GLsizei height )
{
/* update size of Mesa/software ancillary buffers */
_mesa_ResizeBuffersMESA();
savageCalcViewport( ctx );
}

View file

@ -312,11 +312,6 @@ sisMakeCurrent( __DRIcontextPrivate *driContextPriv,
sisUpdateBufferSize( newSisCtx );
sisUpdateClipping( newSisCtx->glCtx );
if ( newSisCtx->glCtx->Viewport.Width == 0 ) {
_mesa_set_viewport(newSisCtx->glCtx, 0, 0,
driDrawPriv->w, driDrawPriv->h);
}
} else {
_mesa_make_current( 0, 0 );
}

View file

@ -39,6 +39,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "sis_tex.h"
#include "context.h"
#include "buffers.h"
#include "enums.h"
#include "colormac.h"
#include "swrast/swrast.h"
@ -436,6 +437,8 @@ static void sisDDViewport( GLcontext *ctx,
GLint x, GLint y,
GLsizei width, GLsizei height )
{
/* update size of Mesa/software ancillary buffers */
_mesa_ResizeBuffersMESA();
sisCalcViewport( ctx );
}

View file

@ -666,10 +666,6 @@ tdfxMakeCurrent( __DRIcontextPrivate *driContextPriv,
_mesa_make_current2( newCtx,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate );
if ( !newCtx->Viewport.Width ) {
_mesa_set_viewport( newCtx, 0, 0, driDrawPriv->w, driDrawPriv->h );
}
} else {
_mesa_make_current( 0, 0 );
}

View file

@ -40,6 +40,7 @@
*/
#include "mtypes.h"
#include "buffers.h"
#include "colormac.h"
#include "texformat.h"
#include "texstore.h"
@ -902,6 +903,8 @@ static void tdfxDDViewport( GLcontext *ctx, GLint x, GLint y,
GLsizei w, GLsizei h )
{
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
/* update size of Mesa/software ancillary buffers */
_mesa_ResizeBuffersMESA();
FLUSH_BATCH( fxMesa );
fxMesa->new_state |= TDFX_NEW_VIEWPORT;
}

View file

@ -959,9 +959,6 @@ viaMakeCurrent(__DRIcontextPrivate *driContextPriv,
if (VIA_DEBUG) fprintf(stderr, "Context %d MakeCurrent\n", vmesa->hHWContext);
#endif
viaXMesaWindowMoved(vmesa);
if (!vmesa->glCtx->Viewport.Width)
_mesa_set_viewport(vmesa->glCtx, 0, 0,
driDrawPriv->w, driDrawPriv->h);
}
else {
_mesa_make_current(0,0);

View file

@ -25,6 +25,7 @@
#include <stdio.h>
#include "glheader.h"
#include "buffers.h"
#include "context.h"
#include "macros.h"
#include "colormac.h"
@ -464,6 +465,8 @@ static void viaViewport(GLcontext *ctx,
GLint x, GLint y,
GLsizei width, GLsizei height)
{
/* update size of Mesa/software ancillary buffers */
_mesa_ResizeBuffersMESA();
viaCalcViewport(ctx);
}

View file

@ -409,11 +409,6 @@ x11MakeCurrent(__DRIcontextPrivate *driContextPriv,
_mesa_make_current2(newFbCtx->glCtx,
(GLframebuffer *) driDrawPriv->driverPrivate,
(GLframebuffer *) driReadPriv->driverPrivate);
if (!newFbCtx->glCtx->Viewport.Width) {
_mesa_set_viewport(newFbCtx->glCtx, 0, 0,
driDrawPriv->w, driDrawPriv->h);
}
} else {
_mesa_make_current(0, 0);
}

View file

@ -45,6 +45,7 @@
#include "glheader.h"
#include <linux/fb.h>
#include "GL/glfbdev.h"
#include "buffers.h"
#include "context.h"
#include "extensions.h"
#include "imports.h"
@ -151,6 +152,14 @@ get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
}
static void
viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
{
/* poll for window size change and realloc software Z/stencil/etc if needed */
_mesa_ResizeBuffersMESA();
}
/* specifies the buffer for swrast span rendering/reading */
static void
set_buffer( GLcontext *ctx, GLframebuffer *buffer, GLuint bufferBit )
@ -639,6 +648,7 @@ glFBDevCreateContext( const GLFBDevVisualPtr visual, GLFBDevContextPtr share )
functions.GetString = get_string;
functions.UpdateState = update_state;
functions.GetBufferSize = get_buffer_size;
functions.Viewport = viewport;
if (!_mesa_initialize_context(&ctx->glcontext, &visual->glvisual,
share ? &share->glcontext : NULL,

View file

@ -30,6 +30,7 @@
#include <ggi/mesa/ggimesa_int.h>
#include <ggi/mesa/debug.h>
#include "extensions.h"
#include "buffers.h"
#include "colormac.h"
#include "imports.h"
#include "matrix.h"
@ -256,6 +257,13 @@ static void gl_ggiGetSize(GLframebuffer *fb, GLuint *width, GLuint *height)
printf("returning %d, %d\n", *width, *height);
}
static void gl_ggiViewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
{
/* poll for window size change and realloc software Z/stencil/etc if needed */
_mesa_ResizeBuffersMESA();
}
static void gl_ggiSetIndex(GLcontext *ctx, GLuint ci)
{
ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
@ -400,6 +408,7 @@ static void gl_ggiSetupPointers(GLcontext *ctx)
/* General information */
ctx->Driver.GetString = gl_ggiGetString;
ctx->Driver.GetBufferSize = gl_ggiGetSize;
ctx->Driver.Viewport = gl_ggiViewport;
ctx->Driver.Finish = gl_ggiFlush;
ctx->Driver.Flush = gl_ggiFlush;
@ -632,15 +641,6 @@ void ggiMesaMakeCurrent(ggi_mesa_context_t ctx, ggi_visual_t vis)
}
_mesa_make_current(ctx->gl_ctx, &LIBGGI_MESAEXT(vis)->mesa_buffer);
if (ctx->gl_ctx->Viewport.Width == 0)
{
_mesa_Viewport(0, 0,
LIBGGI_VIRTX(vis),
LIBGGI_VIRTY(vis));
ctx->gl_ctx->Scissor.Width = LIBGGI_VIRTX(vis);
ctx->gl_ctx->Scissor.Height = LIBGGI_VIRTY(vis);
}
}

View file

@ -873,10 +873,6 @@ fxMesaMakeCurrent(fxMesaContext fxMesa)
_mesa_make_current(fxMesa->glCtx, fxMesa->glBuffer);
fxSetupDDPointers(fxMesa->glCtx);
/* The first time we call MakeCurrent we set the initial viewport size */
if (fxMesa->glCtx->Viewport.Width == 0)
_mesa_set_viewport(fxMesa->glCtx, 0, 0, fxMesa->width, fxMesa->height);
}

View file

@ -43,6 +43,7 @@
#include "image.h"
#include "mtypes.h"
#include "fxdrv.h"
#include "buffers.h"
#include "enums.h"
#include "extensions.h"
#include "macros.h"
@ -106,7 +107,7 @@ static void fxDisableColor (fxMesaContext fxMesa)
/* Return buffer size information */
static void
fxDDBufferSize(GLframebuffer *buffer, GLuint *width, GLuint *height)
fxDDGetBufferSize(GLframebuffer *buffer, GLuint *width, GLuint *height)
{
GET_CURRENT_CONTEXT(ctx);
if (ctx && FX_CONTEXT(ctx)) {
@ -121,6 +122,12 @@ fxDDBufferSize(GLframebuffer *buffer, GLuint *width, GLuint *height)
}
}
static void
fxDDViewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
{
/* poll for window size change and realloc software Z/stencil/etc if needed */
_mesa_ResizeBuffersMESA();
}
/* Implements glClearColor() */
static void
@ -2106,7 +2113,8 @@ fxSetupDDPointers(GLcontext * ctx)
ctx->Driver.ClearColor = fxDDClearColor;
ctx->Driver.Clear = fxDDClear;
ctx->Driver.DrawBuffer = fxDDSetDrawBuffer;
ctx->Driver.GetBufferSize = fxDDBufferSize;
ctx->Driver.GetBufferSize = fxDDGetBufferSize;
ctx->Driver.Viewport = fxDDViewport;
switch (fxMesa->colDepth) {
case 15:
ctx->Driver.DrawPixels = fxDDDrawPixels555;

View file

@ -1,4 +1,4 @@
/* $Id: svgamesa.c,v 1.23 2002/11/11 18:42:38 brianp Exp $ */
/* $Id: svgamesa.c,v 1.24 2004/11/27 22:48:00 brianp Exp $ */
/*
* Mesa 3-D graphics library
@ -39,6 +39,7 @@
#include <string.h>
#include <vga.h>
#include "GL/svgamesa.h"
#include "buffers.h"
#include "context.h"
#include "extensions.h"
#include "imports.h"
@ -212,6 +213,11 @@ static void get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *heigh
*height = SVGAMesa->height = vga_getydim();
}
static void viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
{
/* poll for window size change and realloc software Z/stencil/etc if needed */
_mesa_ResizeBuffersMESA();
}
static void set_buffer( GLcontext *ctx, GLframebuffer *colorBuffer,
GLenum buffer )
@ -258,6 +264,7 @@ static void svgamesa_update_state( GLcontext *ctx, GLuint new_state )
ctx->Driver.GetBufferSize = get_buffer_size;
ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
ctx->Driver.Viewport = viewport;
/* Software rasterizer pixel paths:
*/
@ -446,10 +453,8 @@ void SVGAMesaMakeCurrent( SVGAMesaContext ctx )
_mesa_make_current( ctx->gl_ctx, ctx->gl_buffer );
if (ctx->width==0 || ctx->height==0) {
/* setup initial viewport */
ctx->width = vga_getxdim();
ctx->height = vga_getydim();
_mesa_set_viewport( ctx->gl_ctx, 0, 0, ctx->width, ctx->height );
}
#endif
}

View file

@ -29,6 +29,7 @@
//#include "mesa_extend.h"
#include "glheader.h"
#include "buffers.h"
#include "colors.h"
#include "context.h"
#include "colormac.h"
@ -614,7 +615,7 @@ static void set_buffer(GLcontext *ctx, GLframebuffer *colorBuffer,
/* Return characteristics of the output buffer. */
static void buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
static void get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
{
/*GET_CURRENT_CONTEXT(ctx);*/
int New_Size;
@ -658,6 +659,12 @@ static void buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
}
static void viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
{
/* poll for window size change and realloc software Z/stencil/etc if needed */
_mesa_ResizeBuffersMESA();
}
/**********************************************************************/
/***** Accelerated point, line, polygon rendering *****/
@ -1094,7 +1101,8 @@ static void SetFunctionPointers( struct dd_function_table *functions )
functions->GetString = get_string;
functions->UpdateState = wmesa_update_state;
functions->ResizeBuffers = _swrast_alloc_buffers;
functions->GetBufferSize = buffer_size;
functions->GetBufferSize = get_buffer_size;
functions->Viewport = viewport;
functions->Clear = clear;
@ -1491,12 +1499,6 @@ void WMesaMakeCurrent( WMesaContext c )
Current = c;
wmesa_update_state(c->gl_ctx, 0);
_mesa_make_current(c->gl_ctx, c->gl_buffer);
if (Current->gl_ctx->Viewport.Width==0) {
/* initialize viewport to window size */
_mesa_Viewport( 0, 0, Current->width, Current->height );
Current->gl_ctx->Scissor.Width = Current->width;
Current->gl_ctx->Scissor.Height = Current->height;
}
if ((c->cColorBits <= 8 ) && (c->rgb_flag == GL_TRUE)){
WMesaPaletteChange(c->hPalHalfTone);
}

View file

@ -25,6 +25,7 @@
#include "glxheader.h"
#include "bufferobj.h"
#include "buffers.h"
#include "context.h"
#include "colormac.h"
#include "depth.h"
@ -1202,6 +1203,23 @@ choose_tex_format( GLcontext *ctx, GLint internalFormat,
}
/**
* Called by glViewport.
* This is a good time for us to poll the current X window size and adjust
* our ancillary (back color, depth, stencil, etc) buffers to match the
* current window size. Remember, we have no opportunity to respond to
* conventional X Resize/StructureNotify events since the X driver has no
* event loop. Thus, we poll.
* Note that this trick isn't fool-proof. If the application never calls
* glViewport, our notion of the current window size may be incorrect.
*/
static void
xmesa_viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
{
_mesa_ResizeBuffersMESA();
}
/**
* Initialize the device driver function table with the functions
* we implement in this driver.
@ -1222,6 +1240,7 @@ xmesa_init_driver_functions( XMesaVisual xmvisual,
driver->Enable = enable;
driver->Clear = clear_buffers;
driver->ResizeBuffers = xmesa_resize_buffers;
driver->Viewport = xmesa_viewport;
#ifndef XFree86Server
driver->CopyPixels = xmesa_CopyPixels;
if (xmvisual->undithered_pf == PF_8R8G8B &&

View file

@ -1606,6 +1606,10 @@ _mesa_free_context_data( GLcontext *ctx )
_mesa_delete_buffer_object(ctx, ctx->Array.NullBufferObj);
#endif
/* free dispatch tables */
_mesa_free(ctx->Exec);
_mesa_free(ctx->Save);
/* Shared context state (display lists, textures, etc) */
_glthread_LOCK_MUTEX(ctx->Shared->Mutex);
ctx->Shared->RefCount--;
@ -1618,9 +1622,6 @@ _mesa_free_context_data( GLcontext *ctx )
if (ctx->Extensions.String)
FREE((void *) ctx->Extensions.String);
FREE(ctx->Exec);
FREE(ctx->Save);
}
@ -1877,41 +1878,36 @@ _mesa_make_current2( GLcontext *newCtx, GLframebuffer *drawBuffer,
newCtx->NewState |= _NEW_BUFFERS;
#if _HAVE_FULL_GL
if (drawBuffer->Width == 0 && drawBuffer->Height == 0) {
if (!drawBuffer->Initialized) {
/* get initial window size */
GLuint bufWidth, bufHeight;
/* ask device driver for size of output buffer */
(*newCtx->Driver.GetBufferSize)( drawBuffer, &bufWidth, &bufHeight );
if (drawBuffer->Width != bufWidth ||
drawBuffer->Height != bufHeight) {
drawBuffer->Width = bufWidth;
drawBuffer->Height = bufHeight;
newCtx->Driver.ResizeBuffers( drawBuffer );
}
/* ask device driver for size of the buffer */
(*newCtx->Driver.GetBufferSize)(drawBuffer, &bufWidth, &bufHeight);
/* set initial buffer size */
drawBuffer->Width = bufWidth;
drawBuffer->Height = bufHeight;
newCtx->Driver.ResizeBuffers( drawBuffer );
drawBuffer->Initialized = GL_TRUE;
}
if (readBuffer != drawBuffer &&
readBuffer->Width == 0 && readBuffer->Height == 0) {
if (readBuffer != drawBuffer && !readBuffer->Initialized) {
/* get initial window size */
GLuint bufWidth, bufHeight;
/* ask device driver for size of output buffer */
(*newCtx->Driver.GetBufferSize)( readBuffer, &bufWidth, &bufHeight );
if (readBuffer->Width != bufWidth ||
readBuffer->Height != bufHeight) {
readBuffer->Width = bufWidth;
readBuffer->Height = bufHeight;
newCtx->Driver.ResizeBuffers( readBuffer );
}
/* ask device driver for size of the buffer */
(*newCtx->Driver.GetBufferSize)(readBuffer, &bufWidth, &bufHeight);
/* set initial buffer size */
readBuffer->Width = bufWidth;
readBuffer->Height = bufHeight;
newCtx->Driver.ResizeBuffers( readBuffer );
readBuffer->Initialized = GL_TRUE;
}
#endif
if (newCtx->FirstTimeCurrent) {
/* set initial viewport and scissor size now */
_mesa_set_viewport(newCtx, 0, 0, drawBuffer->Width, drawBuffer->Height);
newCtx->Scissor.Width = drawBuffer->Width;
newCtx->Scissor.Height = drawBuffer->Height;
}
}
/* Alert the driver - usually passed on to the sw t&l module,

View file

@ -35,7 +35,6 @@
#include "glheader.h"
#include "imports.h"
#include "buffers.h"
#include "context.h"
#include "enums.h"
#include "macros.h"
@ -556,11 +555,6 @@ _mesa_Viewport( GLint x, GLint y, GLsizei width, GLsizei height )
* Set new viewport parameters and update derived state (the _WindowMap
* matrix). Usually called from _mesa_Viewport().
*
* \note We also call _mesa_ResizeBuffersMESA() because this is a good
* time to check if the window has been resized. Many device drivers
* can't get direct notification from the window system of size changes
* so this is an ad-hoc solution to that problem.
*
* \param ctx GL context.
* \param x, y coordinates of the lower left corner of the viewport rectangle.
* \param width width of the viewport rectangle.
@ -618,15 +612,10 @@ _mesa_set_viewport( GLcontext *ctx, GLint x, GLint y,
ctx->Viewport._WindowMap.type = MATRIX_3D_NO_ROT;
ctx->NewState |= _NEW_VIEWPORT;
/* Check if window/buffer has been resized and if so, reallocate the
* ancillary buffers. This is an ad-hoc solution to detecting window
* size changes. 99% of all GL apps call glViewport when a window is
* resized so this is a good time to check for new window dims and
* reallocate color buffers and ancilliary buffers.
*/
_mesa_ResizeBuffersMESA();
if (ctx->Driver.Viewport) {
/* Many drivers will use this call to check for window size changes
* and reallocate the z/stencil/accum/etc buffers if needed.
*/
(*ctx->Driver.Viewport)( ctx, x, y, width, height );
}
}

View file

@ -1869,6 +1869,8 @@ struct gl_frame_buffer
GLuint Width, Height; /**< size of frame buffer in pixels */
GLboolean Initialized;
GLboolean UseSoftwareDepthBuffer;
GLboolean UseSoftwareAccumBuffer;
GLboolean UseSoftwareStencilBuffer;