GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with VOMP; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ along with VOMP. If not, see <https://www.gnu.org/licenses/>.
*/
#include "colour.h"
-void InitDefaultSkin()
+void SkinFactory::InitDefaultSkin()
{
/*
Real colours
*/
}
-void InitEnhancedSkin()
+void SkinFactory::InitEnhancedSkin()
{
/*
Real colours
*/
}
-void InitNoopacityInspiredSkin()
+void SkinFactory::InitNoopacityInspiredSkin()
{
/*
Real colours
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with VOMP; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ along with VOMP. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef COLOUR_H
static int getNumberofSkins();
static const char* *getSkinNames();
static bool InitSkin(int n);
+private:
+ static void InitDefaultSkin();
+ static void InitEnhancedSkin();
+ static void InitNoopacityInspiredSkin();
};
#endif
/*
- Copyright 2004-2005 Chris Tallon
+ Copyright 2004-2020 Chris Tallon
This file is part of VOMP.
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with VOMP; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ along with VOMP. If not, see <https://www.gnu.org/licenses/>.
*/
-#include "vscreensaver.h"
+#include <stdlib.h>
+#include <time.h>
+#include <math.h>
#include "defines.h"
#include "log.h"
#include "video.h"
#include "surface.h"
+#include "vscreensaver.h"
+
VScreensaver::VScreensaver()
{
setPosition(0, 0);
VScreensaver::~VScreensaver()
{
+ stopThread();
surface = NULL; // it's the screen. stop view base from killing it.
- threadCancel();
}
void VScreensaver::draw()
{
fillColour(DrawStyle::BLACK);
- threadStart();
+
+ ssThreadStartProtect.lock();
+ ssThread = std::thread([this]
+ {
+ ssThreadStartProtect.lock();
+ ssThreadStartProtect.unlock();
+ threadMethod();
+ });
+ ssThreadStartProtect.unlock();
}
int VScreensaver::handleCommand(int /*command*/)
{
- threadCancel();
+ stopThread();
return 4;
}
+void VScreensaver::stopThread()
+{
+ threadReqStop = true;
+ if (ssThread.joinable()) ssThread.join();
+}
+
void VScreensaver::threadMethod()
{
srand(time(NULL));
- threadSetKillable();
-
// Config
const int h = 50; // length of line
- float deviation = 0.2; // how quickly can it change direction
-
+ double deviation = 0.2; // how quickly can it change direction
int x[h];
int i;
int head = -1;
int tail;
- float direction = 0;
- float fx, fy, dd;
- const float pi2 = 6.28318;
- float halfdeviation = deviation / 2;
+ double direction = 0;
+ double fx, fy, dd;
+ const double pi2 = 6.28318;
+ double halfdeviation = deviation / 2;
for(i = 0; i < h; i++) x[i] = -1;
- fx = x[0] = 50;
- fy = y[0] = 50;
+ fx = x[0] = 50.0;
+ fy = y[0] = 50.0;
DrawStyle &black=DrawStyle::BLACK;
DrawStyle &light=DrawStyle::SELECTHIGHLIGHT;
if (fy < 0) fy += screenHeight;
if (fy >= screenHeight) fy -= screenHeight;
- x[head] = (int)fx;
- y[head] = (int)fy;
+ x[head] = static_cast<int>(fx);
+ y[head] = static_cast<int>(fy);
surface->drawPoint(x[head], y[head], light); // was rgba
+
+ if (threadReqStop) return;
MILLISLEEP(10);
}
}
/*
- Copyright 2007 Chris Tallon
+ Copyright 2007-2020 Chris Tallon
This file is part of VOMP.
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with VOMP; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ along with VOMP. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef VSCREENSAVER_H
#define VSCREENSAVER_H
-#include <stdlib.h>
-#include <time.h>
-#include <math.h>
+#include <thread>
+#include <mutex>
#include "boxx.h"
-#include "threadsystem.h"
-
-
-class VScreensaver : public Boxx, public Thread_TYPE
+class VScreensaver : public Boxx
{
public:
VScreensaver();
void draw();
private:
-
- virtual void threadMethod();
+ void threadMethod();
+ void stopThread();
int screenHeight;
int screenWidth;
+
+ std::thread ssThread;
+ std::mutex ssThreadStartProtect;
+ bool threadReqStop{};
};
#endif