mirror of https://github.com/stella-emu/stella.git
Converted FrameBuffer surface storage to unique_ptr. In the process,
I realized that they didn't need to be stored in a map, since the integer ID was never actually being used. This must have been part of a proposed API that I've since deleted?? git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@3062 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
5d927915ab
commit
db139bef1a
|
@ -342,10 +342,10 @@ void FrameBufferSDL2::setWindowIcon()
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
FBSurface* FrameBufferSDL2::createSurface(uInt32 w, uInt32 h,
|
||||
unique_ptr<FBSurface> FrameBufferSDL2::createSurface(uInt32 w, uInt32 h,
|
||||
const uInt32* data) const
|
||||
{
|
||||
return new FBSurfaceSDL2((FrameBufferSDL2&)*this, w, h, data);
|
||||
return make_ptr<FBSurfaceSDL2>((FrameBufferSDL2&)*this, w, h, data);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -151,7 +151,7 @@ class FrameBufferSDL2 : public FrameBuffer
|
|||
@param h The requested height of the new surface.
|
||||
@param data If non-null, use the given data values as a static surface
|
||||
*/
|
||||
FBSurface* createSurface(uInt32 w, uInt32 h, const uInt32* data) const;
|
||||
unique_ptr<FBSurface> createSurface(uInt32 w, uInt32 h, const uInt32* data) const;
|
||||
|
||||
/**
|
||||
Grabs or ungrabs the mouse based on the given boolean value.
|
||||
|
|
|
@ -58,12 +58,6 @@ FrameBuffer::FrameBuffer(OSystem& osystem)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
FrameBuffer::~FrameBuffer()
|
||||
{
|
||||
// Free all allocated surfaces
|
||||
while(!mySurfaceList.empty())
|
||||
{
|
||||
delete (*mySurfaceList.begin()).second;
|
||||
mySurfaceList.erase(mySurfaceList.begin());
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -234,19 +228,14 @@ FBInitStatus FrameBuffer::createDisplay(const string& title,
|
|||
myStatsMsg.w = infoFont().getMaxCharWidth() * 24 + 2;
|
||||
myStatsMsg.h = (infoFont().getFontHeight() + 2) * 2;
|
||||
|
||||
if(myStatsMsg.surface == nullptr)
|
||||
{
|
||||
uInt32 surfaceID = allocateSurface(myStatsMsg.w, myStatsMsg.h);
|
||||
myStatsMsg.surface = surface(surfaceID);
|
||||
}
|
||||
if(myMsg.surface == nullptr)
|
||||
{
|
||||
uInt32 surfaceID = allocateSurface((uInt32)kFBMinW, font().getFontHeight()+10);
|
||||
myMsg.surface = surface(surfaceID);
|
||||
}
|
||||
if(!myStatsMsg.surface)
|
||||
myStatsMsg.surface = allocateSurface(myStatsMsg.w, myStatsMsg.h);
|
||||
|
||||
if(!myMsg.surface)
|
||||
myMsg.surface = allocateSurface((uInt32)kFBMinW, font().getFontHeight()+10);
|
||||
|
||||
// Print initial usage message, but only print it later if the status has changed
|
||||
if (myInitializedCount == 1)
|
||||
if(myInitializedCount == 1)
|
||||
{
|
||||
myOSystem.logMessage(about(), 1);
|
||||
}
|
||||
|
@ -567,23 +556,13 @@ void FrameBuffer::refresh()
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt32 FrameBuffer::allocateSurface(int w, int h, const uInt32* data)
|
||||
FBSurface* FrameBuffer::allocateSurface(int w, int h, const uInt32* data)
|
||||
{
|
||||
// Create a new surface
|
||||
FBSurface* surface = createSurface(w, h, data);
|
||||
// Add new surface to the list
|
||||
mySurfaceList.push_back(createSurface(w, h, data));
|
||||
|
||||
// Add it to the list
|
||||
mySurfaceList.insert(make_pair((uInt32)mySurfaceList.size(), surface));
|
||||
|
||||
// Return a reference to it
|
||||
return (uInt32)mySurfaceList.size() - 1;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
FBSurface* FrameBuffer::surface(uInt32 id) const
|
||||
{
|
||||
const auto& iter = mySurfaceList.find(id);
|
||||
return iter != mySurfaceList.end() ? iter->second : nullptr;
|
||||
// And return a pointer to it (pointer should be treated read-only)
|
||||
return mySurfaceList.at(mySurfaceList.size() - 1).get();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -596,9 +575,9 @@ void FrameBuffer::resetSurfaces()
|
|||
// aware of these restrictions, and act accordingly
|
||||
|
||||
for(auto& s: mySurfaceList)
|
||||
s.second->free();
|
||||
s->free();
|
||||
for(auto& s: mySurfaceList)
|
||||
s.second->reload();
|
||||
s->reload();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -197,25 +197,16 @@ class FrameBuffer
|
|||
void enableMessages(bool enable);
|
||||
|
||||
/**
|
||||
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).
|
||||
Allocate a new surface. 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 h The requested height of the new surface.
|
||||
@param data If non-null, use the given data values as a static surface
|
||||
|
||||
@return A unique ID used to identify this surface
|
||||
@return A pointer to a valid surface object, or nullptr.
|
||||
*/
|
||||
uInt32 allocateSurface(int w, int h, const uInt32* data = 0);
|
||||
|
||||
/**
|
||||
Retrieve the surface associated with the given ID.
|
||||
|
||||
@param id The ID for the surface to retrieve.
|
||||
@return A pointer to a valid surface object, or nullptr.
|
||||
*/
|
||||
FBSurface* surface(uInt32 id) const;
|
||||
FBSurface* allocateSurface(int w, int h, const uInt32* data = 0);
|
||||
|
||||
/**
|
||||
Returns the current dimensions of the framebuffer image.
|
||||
|
@ -401,7 +392,8 @@ class FrameBuffer
|
|||
@param h The requested height of the new surface.
|
||||
@param data If non-null, use the given data values as a static surface
|
||||
*/
|
||||
virtual FBSurface* createSurface(uInt32 w, uInt32 h, const uInt32* data) const = 0;
|
||||
virtual unique_ptr<FBSurface> createSurface(uInt32 w, uInt32 h,
|
||||
const uInt32* data) const = 0;
|
||||
|
||||
/**
|
||||
Grabs or ungrabs the mouse based on the given boolean value.
|
||||
|
@ -569,7 +561,7 @@ class FrameBuffer
|
|||
VariantList myTIAZoomLevels;
|
||||
|
||||
// Holds a reference to all the surfaces that have been created
|
||||
map<uInt32,FBSurface*> mySurfaceList;
|
||||
vector<unique_ptr<FBSurface>> mySurfaceList;
|
||||
|
||||
// Holds UI palette data (standard and classic colours)
|
||||
static uInt32 ourGUIColors[2][kNumColors-256];
|
||||
|
|
|
@ -45,8 +45,7 @@ TIASurface::TIASurface(OSystem& system)
|
|||
myNTSCFilter.loadConfig(myOSystem.settings());
|
||||
|
||||
// Create a surface for the TIA image and scanlines; we'll need them eventually
|
||||
uInt32 tiaID = myFB.allocateSurface(ATARI_NTSC_OUT_WIDTH(kTIAW), kTIAH);
|
||||
myTiaSurface = myFB.surface(tiaID);
|
||||
myTiaSurface = myFB.allocateSurface(ATARI_NTSC_OUT_WIDTH(kTIAW), kTIAH);
|
||||
|
||||
// Generate scanline data, and a pre-defined scanline surface
|
||||
uInt32 scanData[kScanH];
|
||||
|
@ -55,12 +54,10 @@ TIASurface::TIASurface(OSystem& system)
|
|||
scanData[i] = 0x00000000;
|
||||
scanData[i+1] = 0xff000000;
|
||||
}
|
||||
uInt32 scanID = myFB.allocateSurface(1, kScanH, scanData);
|
||||
mySLineSurface = myFB.surface(scanID);
|
||||
mySLineSurface = myFB.allocateSurface(1, kScanH, scanData);
|
||||
|
||||
// Base TIA surface for use in taking snapshots in 1x mode
|
||||
uInt32 baseID = myFB.allocateSurface(kTIAW*2, kTIAH);
|
||||
myBaseTiaSurface = myFB.surface(baseID);
|
||||
myBaseTiaSurface = myFB.allocateSurface(kTIAW*2, kTIAH);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -40,14 +40,14 @@
|
|||
Dialog::Dialog(OSystem& instance, DialogContainer& parent,
|
||||
int x, int y, int w, int h)
|
||||
: GuiObject(instance, parent, *this, x, y, w, h),
|
||||
_mouseWidget(0),
|
||||
_focusedWidget(0),
|
||||
_dragWidget(0),
|
||||
_okWidget(0),
|
||||
_cancelWidget(0),
|
||||
_mouseWidget(nullptr),
|
||||
_focusedWidget(nullptr),
|
||||
_dragWidget(nullptr),
|
||||
_okWidget(nullptr),
|
||||
_cancelWidget(nullptr),
|
||||
_visible(false),
|
||||
_processCancel(false),
|
||||
_surface(0),
|
||||
_surface(nullptr),
|
||||
_tabID(0)
|
||||
{
|
||||
}
|
||||
|
@ -71,10 +71,7 @@ void Dialog::open(bool refresh)
|
|||
// Technically, this shouldn't be needed until drawDialog(), but some
|
||||
// dialogs cause drawing to occur within loadConfig()
|
||||
if(_surface == nullptr)
|
||||
{
|
||||
uInt32 surfaceID = instance().frameBuffer().allocateSurface(_w, _h);
|
||||
_surface = instance().frameBuffer().surface(surfaceID);
|
||||
}
|
||||
_surface = instance().frameBuffer().allocateSurface(_w, _h);
|
||||
parent().addDialog(this);
|
||||
|
||||
center();
|
||||
|
|
|
@ -92,8 +92,7 @@ void RomInfoWidget::parseProperties()
|
|||
// only draw certain parts of it
|
||||
if(mySurface == nullptr)
|
||||
{
|
||||
uInt32 ID = instance().frameBuffer().allocateSurface(320*2, 256*2);
|
||||
mySurface = instance().frameBuffer().surface(ID);
|
||||
mySurface = instance().frameBuffer().allocateSurface(320*2, 256*2);
|
||||
mySurface->attributes().smoothing = true;
|
||||
mySurface->applyAttributes();
|
||||
|
||||
|
|
Loading…
Reference in New Issue