From 807f3577bcea52a2f4d0bed394d3f430b9a80967 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 27 Apr 2025 15:19:06 +0200 Subject: Add move constructor/operator to Texture. --- src/wx/gl_util.cc | 28 ++++++++++++++++++++++++++++ src/wx/gl_util.h | 3 +++ 2 files changed, 31 insertions(+) diff --git a/src/wx/gl_util.cc b/src/wx/gl_util.cc index 87a75f749..8b66e4c05 100644 --- a/src/wx/gl_util.cc +++ b/src/wx/gl_util.cc @@ -81,6 +81,34 @@ Texture::Texture(GLint unpack_alignment, int unit) } +Texture::Texture(Texture&& other) + : _name(other._name) + , _unpack_alignment(other._unpack_alignment) + , _unit(other._unit) + , _size(std::move(other._size)) +{ + other._name = 0; +} + + +Texture& +Texture::operator=(Texture&& other) +{ + if (this == &other) { + return *this; + } + + _name = other._name; + _unpack_alignment = other._unpack_alignment; + _unit = other._unit; + _size = std::move(other._size); + + other._name = 0; + + return *this; +} + + Texture::~Texture() { glDeleteTextures(1, &_name); diff --git a/src/wx/gl_util.h b/src/wx/gl_util.h index 3c8ba6dc5..20ea2883e 100644 --- a/src/wx/gl_util.h +++ b/src/wx/gl_util.h @@ -137,6 +137,9 @@ public: Texture(Texture const&) = delete; Texture& operator=(Texture const&) = delete; + Texture(Texture&&); + Texture& operator=(Texture&&); + void bind(); void set(std::shared_ptr image, int component = 0); -- cgit v1.2.3