float max_w = 0;
float max_h = 0;
for(int i = 0; static_cast<unsigned int>(i) < act_tmp->surfaces.size(); i++) {
- SurfacePtr surface(new Surface(*act_tmp->surfaces[i]));
+ SurfacePtr surface = act_tmp->surfaces[i]->clone();
surface->hflip();
max_w = std::max(max_w, (float) surface->get_width());
max_h = std::max(max_h, (float) surface->get_height());
surface_data = VideoSystem::new_surface_data(*this);
}
-const Surface&
-Surface::operator=(const Surface& rhs)
+Surface::~Surface()
{
- rhs.texture->ref();
+ VideoSystem::free_surface_data(surface_data);
texture->unref();
- texture = rhs.texture;
- rect = rhs.rect;
- return *this;
}
-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 */
Rect rect;
bool flipx;
-public:
+private:
Surface(const std::string& file);
Surface(const std::string& file, const Rect& rect);
- Surface(const Surface& other);
+ Surface(const Surface&);
+
+public:
~Surface();
- const Surface& operator= (const Surface& other);
+ SurfacePtr clone() const;
/** flip the surface horizontally */
void hflip();
/** returns a vector containing width and height */
Vector get_size() const;
+
+private:
+ Surface& operator=(const Surface&);
};
#endif