added ImageLock RAII class for SDL Surface locking
This commit is contained in:
parent
582de4df22
commit
ec465820e8
20
ImageLock.cpp
Normal file
20
ImageLock.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
//
|
||||
// ImageLock.cpp
|
||||
// libscgui
|
||||
//
|
||||
// Created by Bob Polis at 2020-10-24
|
||||
// Copyright (c) 2020 SwiftCoder. All rights reserved.
|
||||
//
|
||||
|
||||
#include "ImageLock.hpp"
|
||||
#include "Image.hpp"
|
||||
|
||||
using namespace sc::gui;
|
||||
|
||||
ImageLock::ImageLock(const Image& image) : _image {image} {
|
||||
SDL_LockSurface(image.surface());
|
||||
}
|
||||
|
||||
ImageLock::~ImageLock() {
|
||||
SDL_UnlockSurface(_image.surface());
|
||||
}
|
32
ImageLock.hpp
Normal file
32
ImageLock.hpp
Normal file
@ -0,0 +1,32 @@
|
||||
//
|
||||
// ImageLock.hpp
|
||||
// libscgui
|
||||
//
|
||||
// Created by Bob Polis at 2020-10-24
|
||||
// Copyright (c) 2020 SwiftCoder. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef _ImageLock_H_
|
||||
#define _ImageLock_H_
|
||||
|
||||
namespace sc {
|
||||
namespace gui {
|
||||
class Image;
|
||||
|
||||
class ImageLock {
|
||||
public:
|
||||
ImageLock(const Image& image);
|
||||
~ImageLock();
|
||||
|
||||
ImageLock(const ImageLock&) = delete;
|
||||
ImageLock& operator=(const ImageLock&) = delete;
|
||||
ImageLock(ImageLock&&) = delete;
|
||||
ImageLock& operator=(ImageLock&&) = delete;
|
||||
|
||||
private:
|
||||
const Image& _image;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // _ImageLock_H_
|
Loading…
x
Reference in New Issue
Block a user