mirror of
https://github.com/libSDL2pp/libSDL2pp.git
synced 2025-08-03 19:05:59 -04:00
Implement empty constructor for Texture::LockHandle
Useful if lock must be initialized after it was created While here, deinitialize all fields of an object which was moved-from
This commit is contained in:
parent
93a77542d8
commit
1118a9b166
@ -53,6 +53,7 @@ public:
|
||||
LockHandle(Texture* texture, const Rect& rect);
|
||||
|
||||
public:
|
||||
LockHandle();
|
||||
~LockHandle();
|
||||
|
||||
LockHandle(LockHandle&& other) noexcept;
|
||||
|
@ -28,6 +28,9 @@
|
||||
|
||||
namespace SDL2pp {
|
||||
|
||||
Texture::LockHandle::LockHandle() : texture_(nullptr) {
|
||||
}
|
||||
|
||||
Texture::LockHandle::LockHandle(Texture* texture, const Rect& rect) : texture_(texture) {
|
||||
if (SDL_LockTexture(texture_->Get(), rect.Get(), &pixels_, &pitch_) != 0)
|
||||
throw Exception("SDL_LockTexture failed");
|
||||
@ -35,6 +38,8 @@ Texture::LockHandle::LockHandle(Texture* texture, const Rect& rect) : texture_(t
|
||||
|
||||
Texture::LockHandle::LockHandle(Texture::LockHandle&& other) noexcept : texture_(other.texture_), pixels_(other.pixels_), pitch_(other.pitch_) {
|
||||
other.texture_ = nullptr;
|
||||
other.pixels_ = nullptr;
|
||||
other.pitch_ = 0;
|
||||
}
|
||||
|
||||
Texture::LockHandle& Texture::LockHandle::operator=(Texture::LockHandle&& other) noexcept {
|
||||
@ -49,6 +54,8 @@ Texture::LockHandle& Texture::LockHandle::operator=(Texture::LockHandle&& other)
|
||||
pitch_ = other.pitch_;
|
||||
|
||||
other.texture_ = nullptr;
|
||||
other.pixels_ = nullptr;
|
||||
other.pitch_ = 0;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user