Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

32 lines (22 sloc) 1.057 kb
#ifndef _SDLWRAPPERS_H
#define _SDLWRAPPERS_H
#include "SmartPtr.h"
namespace FileSystem { class FileSource; }
struct SDL_Surface;
class SDLSurfacePtr : public SmartPtrBase<SDLSurfacePtr, SDL_Surface> {
typedef SmartPtrBase<SDLSurfacePtr, SDL_Surface> base_type;
private:
explicit SDLSurfacePtr(SDL_Surface *p): base_type(p) {}
public:
static SDLSurfacePtr WrapNew(SDL_Surface *p) { return SDLSurfacePtr(p); }
static SDLSurfacePtr WrapCopy(SDL_Surface *p) { if (p) { p->refcount += 1; } return SDLSurfacePtr(p); }
SDLSurfacePtr() {}
SDLSurfacePtr(const SDLSurfacePtr& b): base_type(b.Get())
{ if (this->m_ptr) this->m_ptr->refcount += 1; }
~SDLSurfacePtr() { SDL_FreeSurface(this->Release()); }
SDLSurfacePtr &operator=(const SDLSurfacePtr &b) { SDLSurfacePtr(b).Swap(*this); return *this; }
bool Unique() const { assert(this->m_ptr); return (this->m_ptr->refcount == 1); }
};
SDLSurfacePtr LoadSurfaceFromFile(const std::string &fname, FileSystem::FileSource &source);
SDLSurfacePtr LoadSurfaceFromFile(const std::string &fname);
#endif
Jump to Line
Something went wrong with that request. Please try again.