X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fvideo%2Fsurface.cpp;h=f9eb560e848d352900b3d63c0fe59832ae09387b;hb=c2624ec9162122f2e625b57eac798ee37912c3e0;hp=4d8582bafafd0ff0f1fa08e7b86f5fab4f97d94b;hpb=e479e1826cdc1eb2e3474e738b8e4313ac6a94c1;p=supertux.git diff --git a/src/video/surface.cpp b/src/video/surface.cpp index 4d8582baf..f9eb560e8 100644 --- a/src/video/surface.cpp +++ b/src/video/surface.cpp @@ -23,16 +23,16 @@ #include "video/texture.hpp" #include "video/video_systems.hpp" -std::auto_ptr +SurfacePtr Surface::create(const std::string& file) { - return std::auto_ptr(new Surface(file)); + return SurfacePtr(new Surface(file)); } -std::auto_ptr +SurfacePtr Surface::create(const std::string& file, const Rect& rect) { - return std::auto_ptr(new Surface(file, rect)); + return SurfacePtr(new Surface(file, rect)); } Surface::Surface(const std::string& file) : @@ -43,7 +43,6 @@ Surface::Surface(const std::string& file) : texture->get_image_height())), flipx(false) { - texture->ref(); surface_data = VideoSystem::new_surface_data(*this); } @@ -53,7 +52,6 @@ Surface::Surface(const std::string& file, const Rect& rect_) : rect(0, 0, Size(rect_.get_width(), rect_.get_height())), flipx(false) { - texture->ref(); surface_data = VideoSystem::new_surface_data(*this); } @@ -63,24 +61,19 @@ Surface::Surface(const Surface& rhs) : rect(rhs.rect), flipx(false) { - texture->ref(); surface_data = VideoSystem::new_surface_data(*this); } -const Surface& -Surface::operator=(const Surface& rhs) +Surface::~Surface() { - rhs.texture->ref(); - texture->unref(); - texture = rhs.texture; - rect = rhs.rect; - return *this; + VideoSystem::free_surface_data(surface_data); } -Surface::~Surface() +SurfacePtr +Surface::clone() const { - VideoSystem::free_surface_data(surface_data); - texture->unref(); + SurfacePtr surface(new Surface(*this)); + return surface; } /** flip the surface horizontally */ @@ -94,7 +87,7 @@ bool Surface::get_flipx() const return flipx; } -Texture* +TexturePtr Surface::get_texture() const { return texture;