32 lines
773 B
C++
32 lines
773 B
C++
#include "scenes/surface_handle.hpp"
|
|
|
|
namespace scenes {
|
|
|
|
SurfaceHandle::SurfaceHandle(const char* file)
|
|
: surface_(JD8_LoadSurface(file)) {}
|
|
|
|
SurfaceHandle::~SurfaceHandle() {
|
|
if (surface_) JD8_FreeSurface(surface_);
|
|
}
|
|
|
|
SurfaceHandle::SurfaceHandle(SurfaceHandle&& other) noexcept
|
|
: surface_(other.surface_) {
|
|
other.surface_ = nullptr;
|
|
}
|
|
|
|
SurfaceHandle& SurfaceHandle::operator=(SurfaceHandle&& other) noexcept {
|
|
if (this != &other) {
|
|
if (surface_) JD8_FreeSurface(surface_);
|
|
surface_ = other.surface_;
|
|
other.surface_ = nullptr;
|
|
}
|
|
return *this;
|
|
}
|
|
|
|
void SurfaceHandle::reset(const char* file) {
|
|
if (surface_) JD8_FreeSurface(surface_);
|
|
surface_ = file ? JD8_LoadSurface(file) : nullptr;
|
|
}
|
|
|
|
} // namespace scenes
|