فهرست منبع

device: cleanup

Daniele Bartolini 10 ماه پیش
والد
کامیت
389363cc0c
2فایلهای تغییر یافته به همراه10 افزوده شده و 8 حذف شده
  1. 7 6
      src/device/device.cpp
  2. 3 2
      src/device/device.h

+ 7 - 6
src/device/device.cpp

@@ -352,8 +352,8 @@ Device::Device(const DeviceOptions &opts, ConsoleServer &cs)
 	, _timestep_policy(TimestepPolicy::VARIABLE)
 	, _width(CROWN_DEFAULT_WINDOW_WIDTH)
 	, _height(CROWN_DEFAULT_WINDOW_HEIGHT)
-	, _quit(false)
-	, _paused(false)
+	, _quit(0)
+	, _paused(0)
 	, _needs_draw(1)
 {
 	list::init_head(_worlds);
@@ -416,7 +416,7 @@ void Device::set_timestep_smoothing(u32 num_samples, u32 num_outliers, f32 avera
 
 bool Device::frame()
 {
-	if (CE_UNLIKELY(process_events() || _quit))
+	if (CE_UNLIKELY(process_events() || _quit != 0))
 		return true;
 
 	const s64 time = time::now();
@@ -461,7 +461,7 @@ bool Device::frame()
 	if (CE_UNLIKELY(!_needs_draw))
 		return false;
 
-	if (CE_LIKELY(!_paused)) {
+	if (CE_LIKELY(_paused == 0)) {
 		_resource_manager->complete_requests();
 
 		{
@@ -751,6 +751,7 @@ void Device::run()
 void Device::quit()
 {
 	_quit = true;
+	_quit = 1;
 }
 
 int Device::argc() const
@@ -765,13 +766,13 @@ const char **Device::argv() const
 
 void Device::pause()
 {
-	_paused = true;
+	_paused = 1;
 	logi(DEVICE, "Paused");
 }
 
 void Device::unpause()
 {
-	_paused = false;
+	_paused = 0;
 	logi(DEVICE, "Unpaused");
 }
 

+ 3 - 2
src/device/device.h

@@ -66,8 +66,9 @@ struct Device
 	u16 _prev_height;
 	s64 _last_time;
 
-	bool _quit;
-	bool _paused;
+	s16 _quit   : 1;
+	s16 _paused : 1;
+
 	std::atomic_int _needs_draw;
 
 	///