Browse Source

TexLock should be movable and not copyable

opengl-renderer-broken
Martin Dørum 4 years ago
parent
commit
19ca65b3de
2 changed files with 10 additions and 1 deletions
  1. 2
    0
      libswan/include/swan/gfxutil.h
  2. 8
    1
      libswan/src/gfxutil.cc

+ 2
- 0
libswan/include/swan/gfxutil.h View File

@@ -15,6 +15,8 @@ inline std::ostream &operator<<(std::ostream &os, const SDL_Rect &rect) {
class TexLock {
public:
TexLock(SDL_Texture *tex, SDL_Rect *rect = nullptr);
TexLock(const TexLock &) = delete;
TexLock(TexLock &&lock) noexcept;
~TexLock();

int blit(SDL_Rect *destrect, SDL_Surface *srcsurf, SDL_Rect *srcrect = nullptr) {

+ 8
- 1
libswan/src/gfxutil.cc View File

@@ -42,8 +42,15 @@ TexLock::TexLock(SDL_Texture *tex, SDL_Rect *rect): tex_(tex) {
32, pitch, rmask, gmask, bmask, amask));
}

TexLock::TexLock(TexLock &&lock) noexcept {
tex_ = lock.tex_;
surf_ = std::move(lock.surf_);
lock.tex_ = nullptr;
}

TexLock::~TexLock() {
SDL_UnlockTexture(tex_);
if (tex_ != nullptr)
SDL_UnlockTexture(tex_);
}

}

Loading…
Cancel
Save