A few more fixes for some OpenGL crashes. The allocation/deallocation

of FBSurfaces should belong solely to FrameBuffer, so that different
parts of the code don't try to delete what they don't own.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1561 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2008-12-12 18:32:53 +00:00
parent 203cdaf323
commit 9aa6eb820c
5 changed files with 30 additions and 60 deletions

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: FrameBufferGL.cxx,v 1.113 2008-12-12 15:51:06 stephena Exp $ // $Id: FrameBufferGL.cxx,v 1.114 2008-12-12 18:32:53 stephena Exp $
//============================================================================ //============================================================================
#ifdef DISPLAY_OPENGL #ifdef DISPLAY_OPENGL
@ -352,9 +352,14 @@ cerr << "dimensions: " << endl
<< " imageh = " << mode.image_h << endl << " imageh = " << mode.image_h << endl
<< endl; << endl;
delete myBaseSurface; if(1)//!inUIMode)
myBaseSurface = new FBSurfaceGL(*this, baseWidth, baseHeight, {
mode.image_w, mode.image_h); delete myBaseSurface;
myBaseSurface = new FBSurfaceGL(*this, baseWidth, baseHeight,
mode.image_w, mode.image_h);
}
// myOSystem->setUIPalette();
// Old textures currently in use by various UI items need to be // Old textures currently in use by various UI items need to be
// refreshed as well (only seems to be required for OSX) // refreshed as well (only seems to be required for OSX)
@ -539,7 +544,7 @@ FBSurfaceGL::FBSurfaceGL(FrameBufferGL& buffer,
myWidth(scaleWidth), myWidth(scaleWidth),
myHeight(scaleHeight) myHeight(scaleHeight)
{ {
cerr << " FBSurfaceGL::FBSurfaceGL: w = " << baseWidth << ", h = " << baseHeight << endl; cerr << " FBSurfaceGL::FBSurfaceGL: w = " << baseWidth << ", h = " << baseHeight << " : " << this << endl;
// Fill buffer struct with valid data // Fill buffer struct with valid data
// This changes depending on the texturing used // This changes depending on the texturing used

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: FrameBuffer.cxx,v 1.143 2008-12-12 15:51:07 stephena Exp $ // $Id: FrameBuffer.cxx,v 1.144 2008-12-12 18:32:53 stephena Exp $
//============================================================================ //============================================================================
#include <algorithm> #include <algorithm>
@ -57,8 +57,13 @@ FrameBuffer::FrameBuffer(OSystem* osystem)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FrameBuffer::~FrameBuffer(void) FrameBuffer::~FrameBuffer(void)
{ {
freeSurface(myMsg.surfaceID); // Free all allocated surfaces
freeSurface(myStatsMsg.surfaceID); while(!mySurfaceList.empty())
{
cerr << " delete id = " << (*mySurfaceList.begin()).first << ", " << (*mySurfaceList.begin()).second << endl;
delete (*mySurfaceList.begin()).second;
mySurfaceList.erase(mySurfaceList.begin());
}
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -395,22 +400,6 @@ int FrameBuffer::allocateSurface(int w, int h, bool useBase)
return mySurfaceCount - 1; return mySurfaceCount - 1;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int FrameBuffer::freeSurface(int id)
{
// Really delete the surface this time
// That means actually deleting the FBSurface object, and removing it
// from the list
map<int,FBSurface*>::iterator iter = mySurfaceList.find(id);
if(iter != mySurfaceList.end())
{
cerr << " delete id = " << iter->first << ", " << iter->second << endl;
delete iter->second;
mySurfaceList.erase(iter);
}
return -1;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FBSurface* FrameBuffer::surface(int id) const FBSurface* FrameBuffer::surface(int id) const
{ {

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: FrameBuffer.hxx,v 1.105 2008-12-12 15:51:07 stephena Exp $ // $Id: FrameBuffer.hxx,v 1.106 2008-12-12 18:32:53 stephena Exp $
//============================================================================ //============================================================================
#ifndef FRAMEBUFFER_HXX #ifndef FRAMEBUFFER_HXX
@ -91,7 +91,7 @@ enum {
turn drawn here as well. turn drawn here as well.
@author Stephen Anthony @author Stephen Anthony
@version $Id: FrameBuffer.hxx,v 1.105 2008-12-12 15:51:07 stephena Exp $ @version $Id: FrameBuffer.hxx,v 1.106 2008-12-12 18:32:53 stephena Exp $
*/ */
class FrameBuffer class FrameBuffer
{ {
@ -152,7 +152,9 @@ class FrameBuffer
void enableMessages(bool enable); void enableMessages(bool enable);
/** /**
Allocate a new surface with a unique ID. Allocate a new surface with a unique ID. The FrameBuffer class takes
all responsibility for freeing this surface (ie, other classes must not
delete it directly).
@param w The requested width of the new surface. @param w The requested width of the new surface.
@param h The requested height of the new surface. @param h The requested height of the new surface.
@ -162,16 +164,6 @@ class FrameBuffer
*/ */
int allocateSurface(int w, int h, bool useBase = false); int allocateSurface(int w, int h, bool useBase = false);
/**
De-allocate a previously allocated surface. Other classes should
call this method when a surface is no longer needed; it shouldn't
try to manually delete the surface object.
@param id The ID for the surface to de-allocate.
@return The ID indicating a non-existent surface (-1).
*/
int freeSurface(int id);
/** /**
Retrieve the surface associated with the given ID. Retrieve the surface associated with the given ID.
@ -557,7 +549,7 @@ class FrameBuffer
FrameBuffer type. FrameBuffer type.
@author Stephen Anthony @author Stephen Anthony
@version $Id: FrameBuffer.hxx,v 1.105 2008-12-12 15:51:07 stephena Exp $ @version $Id: FrameBuffer.hxx,v 1.106 2008-12-12 18:32:53 stephena Exp $
*/ */
// Text alignment modes for drawString() // Text alignment modes for drawString()
enum TextAlignment { enum TextAlignment {

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: OSystem.cxx,v 1.131 2008-05-30 19:07:55 stephena Exp $ // $Id: OSystem.cxx,v 1.132 2008-12-12 18:32:53 stephena Exp $
//============================================================================ //============================================================================
#include <cassert> #include <cassert>
@ -347,9 +347,6 @@ bool OSystem::createFrameBuffer(bool showmessage)
// Let the system know that we've possibly resized the display // Let the system know that we've possibly resized the display
if(changeBuffer) myEventHandler->handleResizeEvent(); if(changeBuffer) myEventHandler->handleResizeEvent();
// Update the UI palette
setUIPalette();
if(showmessage) if(showmessage)
{ {
switch(myFrameBuffer->type()) switch(myFrameBuffer->type())

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Dialog.cxx,v 1.65 2008-12-12 15:51:07 stephena Exp $ // $Id: Dialog.cxx,v 1.66 2008-12-12 18:32:53 stephena Exp $
// //
// Based on code from ScummVM - Scumm Interpreter // Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project // Copyright (C) 2002-2004 The ScummVM project
@ -62,9 +62,6 @@ Dialog::~Dialog()
_firstWidget = NULL; _firstWidget = NULL;
_ourButtonGroup.clear(); _ourButtonGroup.clear();
_surfaceID = instance().frameBuffer().freeSurface(_surfaceID);
_surface = NULL;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -89,25 +86,14 @@ void Dialog::open()
} }
else if((uInt32)_w > _surface->getWidth() || (uInt32)_h > _surface->getHeight()) else if((uInt32)_w > _surface->getWidth() || (uInt32)_h > _surface->getHeight())
{ {
cerr << "!!!! surface is too small !!!!" << endl;
/*
_surfaceID = instance().frameBuffer().freeSurface(_surfaceID); _surfaceID = instance().frameBuffer().freeSurface(_surfaceID);
_surfaceID = instance().frameBuffer().allocateSurface(_w, _h, _isBase); _surfaceID = instance().frameBuffer().allocateSurface(_w, _h, _isBase);
_surface = instance().frameBuffer().surface(_surfaceID); _surface = instance().frameBuffer().surface(_surfaceID);
*/
} }
else
{
_surface->setWidth(_w);
_surface->setHeight(_h);
}
/* /*
if(_surface == NULL)
_surface = instance().frameBuffer().createSurface(_w, _h, _isBase);
else if((uInt32)_w > _surface->getWidth() || (uInt32)_h > _surface->getHeight())
{
delete _surface;
_surface = instance().frameBuffer().createSurface(_w, _h, _isBase);
}
else else
{ {
_surface->setWidth(_w); _surface->setWidth(_w);
@ -115,6 +101,7 @@ void Dialog::open()
} }
*/ */
instance().setUIPalette();
center(); center();