X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fvideo%2Fsurface.hpp;h=d90494bfd4576de151cac46f28880a3eec39e1b2;hb=75acd4b141f45e851a492f089aa9ad24a9552409;hp=a9358fbbac92b3dea875fe6deef721bc2804bbba;hpb=99cf62c2d44b4555e9761f1c8f1b10cf880c33fb;p=supertux.git diff --git a/src/video/surface.hpp b/src/video/surface.hpp index a9358fbba..d90494bfd 100644 --- a/src/video/surface.hpp +++ b/src/video/surface.hpp @@ -25,19 +25,8 @@ #include #include #include "math/vector.hpp" -#include "file_system.hpp" -#include - -/// bitset for drawing effects -enum DrawingEffect { - /** Don't apply anything */ - NO_EFFECT, - /** Draw the Surface upside down */ - VERTICAL_FLIP, - /** Draw the Surface from left to down */ - HORIZONTAL_FLIP, - NUM_EFFECTS -}; +#include "texture.hpp" +#include "video_systems.hpp" /** * A rectangular image. @@ -47,30 +36,49 @@ enum DrawingEffect { class Surface { private: - Unison::Video::TextureSection texture; + Texture* texture; + void *surface_data; + int x; + int y; + int w; + int h; bool flipx; public: Surface(const std::string& file) : - texture(FileSystem::normalize(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(FileSystem::normalize(file), Unison::Video::Rect(x, y, w, 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(); } /** flip the surface horizontally */ @@ -86,33 +94,44 @@ public: const Surface& operator= (const Surface& other) { + other.texture->ref(); + texture->unref(); texture = other.texture; + x = other.x; + y = other.y; + w = other.w; + h = other.h; return *this; } - Unison::Video::TextureSection get_texture() const + Texture *get_texture() const { return texture; } + void *get_surface_data() const + { + return surface_data; + } + int get_x() const { - return texture.clip_rect.pos.x; + return x; } int get_y() const { - return texture.clip_rect.pos.y; + return y; } int get_width() const { - return texture.clip_rect.size.x ? texture.clip_rect.size.x : texture.image.get_size().x; + return w; } int get_height() const { - return texture.clip_rect.size.y ? texture.clip_rect.size.y : texture.image.get_size().y; + return h; } Vector get_position() const