- Surface(const std::string& file);
- Surface(const std::string& file, int x, int y, int w, int h);
- Surface(const Surface& other);
- ~Surface();
+ Surface(const std::string& file) :
+ texture(texture_manager->get(file)),
+ x(0), y(0), w(0), h(0),
+ flipx(false)
+ {
+ texture->ref();
+ w = texture->get_image_width();
+ h = texture->get_image_height();
+ surface_data = new_surface_data(*this);
+ }
+
+ Surface(const std::string& file, int x, int y, int w, int h) :
+ texture(texture_manager->get(file)),
+ x(x), y(y), w(w), h(h),
+ flipx(false)
+ {
+ texture->ref();
+ surface_data = new_surface_data(*this);
+ }
+
+ Surface(const Surface& other) :
+ texture(other.texture),
+ x(other.x), y(other.y),
+ w(other.w), h(other.h),
+ flipx(false)
+ {
+ texture->ref();
+ surface_data = new_surface_data(*this);
+ }
+
+ ~Surface()
+ {
+ free_surface_data(surface_data);
+ texture->unref();
+ }