diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2016-06-02 21:00:37 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2016-06-02 21:00:37 +0200 |
commit | ab7ab9e52ab87963831f90ab25957d883878654d (patch) | |
tree | 2225a4382497889f43477429d2f6b696ce04bf8f /plugingui/image.cc | |
parent | 1d6833cfcb0b5bf4890fa15b5013d7490af48f69 (diff) |
New ImageCache class for reusing Image resources.
Diffstat (limited to 'plugingui/image.cc')
-rw-r--r-- | plugingui/image.cc | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/plugingui/image.cc b/plugingui/image.cc index 250dc60..63f708d 100644 --- a/plugingui/image.cc +++ b/plugingui/image.cc @@ -48,9 +48,39 @@ Image::Image(const std::string& filename) load(rc.data(), rc.size()); } +Image::Image(Image&& other) + : _width(other._width) + , _height(other._height) + , image_data(other.image_data) +{ + other.image_data = nullptr; + other._width = 0; + other._height = 0; +} + Image::~Image() { - std::free(image_data); + if(image_data) + { + std::free(image_data); + } +} + +Image& Image::operator=(Image&& other) +{ + if(image_data) + { + std::free(image_data); + } + image_data = other.image_data; + _width = other._width; + _height = other._height; + + other.image_data = nullptr; + other._width = 0; + other._height = 0; + + return *this; } void Image::setError() |