Implemented window scaling in SDLRenderer, mouse input however breaks when scaling
[supertux.git] / src / video / surface.cpp
index 926342e..f9eb560 100644 (file)
 #include "video/texture.hpp"
 #include "video/video_systems.hpp"
 
-std::auto_ptr<Surface>
+SurfacePtr
 Surface::create(const std::string& file)
 {
-  return std::auto_ptr<Surface>(new Surface(file));
+  return SurfacePtr(new Surface(file));
 }
 
-std::auto_ptr<Surface> 
+SurfacePtr
 Surface::create(const std::string& file, const Rect& rect)
 {
-  return std::auto_ptr<Surface>(new Surface(file, rect));
+  return SurfacePtr(new Surface(file, rect));
 }
 
 Surface::Surface(const std::string& file) :
@@ -43,18 +43,16 @@ Surface::Surface(const std::string& file) :
            texture->get_image_height())),
   flipx(false)
 {
-  texture->ref();
-  surface_data = new_surface_data(*this);
+  surface_data = VideoSystem::new_surface_data(*this);
 }
 
 Surface::Surface(const std::string& file, const Rect& rect_) :
-  texture(texture_manager->get(file)),
+  texture(texture_manager->get(file, rect_)),
   surface_data(),
-  rect(rect_),
+  rect(0, 0, Size(rect_.get_width(), rect_.get_height())),
   flipx(false)
 {
-  texture->ref();
-  surface_data = new_surface_data(*this);
+  surface_data = VideoSystem::new_surface_data(*this);
 }
 
 Surface::Surface(const Surface& rhs) :
@@ -63,24 +61,19 @@ Surface::Surface(const Surface& rhs) :
   rect(rhs.rect),
   flipx(false)
 {
-  texture->ref();
-  surface_data = new_surface_data(*this);
+  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
 {
-  free_surface_data(surface_data);
-  texture->unref();
+  SurfacePtr surface(new Surface(*this));
+  return surface;
 }
 
 /** flip the surface horizontally */
@@ -94,13 +87,13 @@ bool Surface::get_flipx() const
   return flipx;
 }
 
-Texture
+TexturePtr
 Surface::get_texture() const
 {
   return texture;
 }
 
-void
+SurfaceData
 Surface::get_surface_data() const
 {
   return surface_data;