Convert FrameBuffer/FBSurface to use shared_ptr instead of raw pointers.

git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@3072 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2014-11-15 18:29:13 +00:00
parent 4544f59b53
commit 690b681fe7
10 changed files with 16 additions and 39 deletions

View File

@ -16,7 +16,7 @@
* The conversion to C++11 has begun :) From this point on, to build
Stella you will need a C++11 compatible compiler (Visual Studio 2013,
Clang 3.5, gcc 4.9, Xcode 5, etc). Eventually, this will bring more
Clang 3.3, gcc 4.7, Xcode 5, etc). Eventually, this will bring more
bug-free and (hopefully) faster code.
* The minimum supported version for the OSX port is now OSX 10.7.

View File

@ -36,7 +36,7 @@
*/
// This comes directly from SDL_scancode.h
typedef enum
enum StellaKey
{
KBDK_UNKNOWN = 0,
@ -390,10 +390,10 @@ typedef enum
KBDK_LAST = 512 /**< not a key, just marks the number of scancodes
for array bounds */
} StellaKey;
};
// This comes directly from SDL_keycode.h
typedef enum
enum StellaMod
{
KBDM_NONE = 0x0000,
KBDM_LSHIFT = 0x0001,
@ -412,6 +412,6 @@ typedef enum
KBDM_SHIFT = (KBDM_LSHIFT|KBDM_RSHIFT),
KBDM_ALT = (KBDM_LALT|KBDM_RALT),
KBDM_GUI = (KBDM_LGUI|KBDM_RGUI)
} StellaMod;
};
#endif /* StellaKeys */

View File

@ -556,13 +556,13 @@ void FrameBuffer::refresh()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FBSurface* FrameBuffer::allocateSurface(int w, int h, const uInt32* data)
shared_ptr<FBSurface> FrameBuffer::allocateSurface(int w, int h, const uInt32* data)
{
// Add new surface to the list
mySurfaceList.push_back(createSurface(w, h, data));
// And return a pointer to it (pointer should be treated read-only)
return mySurfaceList.at(mySurfaceList.size() - 1).get();
return mySurfaceList.at(mySurfaceList.size() - 1);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -206,7 +206,7 @@ class FrameBuffer
@return A pointer to a valid surface object, or nullptr.
*/
FBSurface* allocateSurface(int w, int h, const uInt32* data = 0);
shared_ptr<FBSurface> allocateSurface(int w, int h, const uInt32* data = 0);
/**
Returns the current dimensions of the framebuffer image.
@ -546,7 +546,7 @@ class FrameBuffer
int x, y, w, h;
MessagePosition position;
uInt32 color;
FBSurface* surface;
shared_ptr<FBSurface> surface;
bool enabled;
};
Message myMsg;
@ -561,7 +561,7 @@ class FrameBuffer
VariantList myTIAZoomLevels;
// Holds a reference to all the surfaces that have been created
vector<unique_ptr<FBSurface>> mySurfaceList;
vector<shared_ptr<FBSurface>> mySurfaceList;
// Holds UI palette data (standard and classic colours)
static uInt32 ourGUIColors[2][kNumColors-256];

View File

@ -32,9 +32,6 @@ TIASurface::TIASurface(OSystem& system)
: myOSystem(system),
myFB(system.frameBuffer()),
myTIA(nullptr),
myTiaSurface(nullptr),
mySLineSurface(nullptr),
myBaseTiaSurface(nullptr),
myFilterType(kNormal),
myUsePhosphor(false),
myPhosphorBlend(77),

View File

@ -139,7 +139,7 @@ class TIASurface
FrameBuffer& myFB;
TIA* myTIA;
FBSurface *myTiaSurface, *mySLineSurface, *myBaseTiaSurface;
shared_ptr<FBSurface> myTiaSurface, mySLineSurface, myBaseTiaSurface;
// Enumeration created such that phosphor off/on is in LSB,
// and Blargg off/on is in MSB

View File

@ -267,7 +267,7 @@ void Dialog::redrawFocus()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Dialog::addSurface(FBSurface* surface)
void Dialog::addSurface(shared_ptr<FBSurface> surface)
{
mySurfaceStack.push(surface);
}

View File

@ -81,7 +81,7 @@ class Dialog : public GuiObject
the surface render() call will always occur in such a case, the
surface should call setVisible() to enable/disable its output.
*/
void addSurface(FBSurface* surface);
void addSurface(shared_ptr<FBSurface> surface);
protected:
virtual void draw();
@ -124,7 +124,7 @@ class Dialog : public GuiObject
bool _visible;
bool _processCancel;
Common::FixedStack<FBSurface*> mySurfaceStack;
Common::FixedStack<shared_ptr<FBSurface>> mySurfaceStack;
private:
struct Focus {
@ -154,7 +154,7 @@ class Dialog : public GuiObject
TabFocusList _myTabList; // focus for each tab (if any)
WidgetArray _buttonGroup;
FBSurface* _surface;
shared_ptr<FBSurface> _surface;
int _tabID;
};

View File

@ -28,7 +28,6 @@
RomInfoWidget::RomInfoWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int w, int h)
: Widget(boss, font, x, y, w, h),
mySurface(nullptr),
mySurfaceIsValid(false),
myHaveProperties(false),
myAvail(w > 400 ? GUI::Size(640, 512) : GUI::Size(320, 256))
@ -174,22 +173,3 @@ void RomInfoWidget::drawWidget(bool hilite)
ypos += _font.getLineHeight();
}
}
/*
cerr << "surface:" << endl
<< " w = " << sw << endl
<< " h = " << sh << endl
<< " szoom = " << myZoomLevel << endl
<< " spitch = " << spitch << endl
<< endl;
cerr << "image:" << endl
<< " width = " << width << endl
<< " height = " << height << endl
<< " izoom = " << izoom << endl
<< " ipitch = " << ipitch << endl
<< " bufsize = " << bufsize << endl
<< " buf_offset = " << buf_offset << endl
<< " i_offset = " << i_offset << endl
<< endl;
*/

View File

@ -48,7 +48,7 @@ class RomInfoWidget : public Widget
private:
// Surface pointer holding the PNG image
FBSurface* mySurface;
shared_ptr<FBSurface> mySurface;
// Whether the surface should be redrawn by drawWidget()
bool mySurfaceIsValid;