summaryrefslogtreecommitdiff
path: root/src/video/video_driver.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/video/video_driver.hpp')
-rw-r--r--src/video/video_driver.hpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/video/video_driver.hpp b/src/video/video_driver.hpp
index c52b36029..cc74df202 100644
--- a/src/video/video_driver.hpp
+++ b/src/video/video_driver.hpp
@@ -127,6 +127,25 @@ public:
return static_cast<VideoDriver*>(*DriverFactoryBase::GetActiveDriver(Driver::DT_VIDEO));
}
+ /**
+ * Helper struct to ensure the video buffer is locked and ready for drawing. The destructor
+ * will make sure the buffer is unlocked no matter how the scope is exited.
+ */
+ struct VideoBufferLocker {
+ VideoBufferLocker()
+ {
+ this->unlock = VideoDriver::GetInstance()->LockVideoBuffer();
+ }
+
+ ~VideoBufferLocker()
+ {
+ if (this->unlock) VideoDriver::GetInstance()->UnlockVideoBuffer();
+ }
+
+ private:
+ bool unlock; ///< Stores if the lock did anything that has to be undone.
+ };
+
protected:
const uint ALLOWED_DRIFT = 5; ///< How many times videodriver can miss deadlines without it being overly compensated.