clang-format and uncomment debug

This commit is contained in:
Sergiusz Bazanski 2018-07-20 13:19:45 +01:00
parent b4b111a053
commit 19f4b68f07
4 changed files with 39 additions and 45 deletions

View File

@ -250,10 +250,11 @@ struct CellInfo : ArchCellInfo
class IdStringDB class IdStringDB
{ {
friend class IdString; friend class IdString;
private: private:
mutable std::unordered_map<std::string, int> *idstring_str_to_idx; mutable std::unordered_map<std::string, int> *idstring_str_to_idx;
mutable std::vector<const std::string *> *idstring_idx_to_str; mutable std::vector<const std::string *> *idstring_idx_to_str;
public: public:
IdString id(const std::string &s) const { return IdString(this, s); } IdString id(const std::string &s) const { return IdString(this, s); }
IdString id(const char *s) const { return IdString(this, s); } IdString id(const char *s) const { return IdString(this, s); }
@ -279,9 +280,7 @@ class DeterministicRNG
uint64_t rngstate; uint64_t rngstate;
public: public:
DeterministicRNG() : rngstate(0x3141592653589793) DeterministicRNG() : rngstate(0x3141592653589793) {}
{
}
uint64_t rng64() uint64_t rng64()
{ {
@ -340,7 +339,6 @@ class DeterministicRNG
std::sort(a.begin(), a.end()); std::sort(a.begin(), a.end());
shuffle(a); shuffle(a);
} }
}; };
class BaseCtx : public IdStringDB class BaseCtx : public IdStringDB
@ -348,7 +346,7 @@ class BaseCtx : public IdStringDB
private: private:
std::mutex mutex; std::mutex mutex;
pthread_t mutex_owner; pthread_t mutex_owner;
std::mutex generation_mutex; std::mutex generation_mutex;
public: public:
@ -362,7 +360,6 @@ class BaseCtx : public IdStringDB
{ {
mutex.lock(); mutex.lock();
mutex_owner = pthread_self(); mutex_owner = pthread_self();
} }
void unlock(void) void unlock(void)

View File

@ -37,17 +37,17 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
bool Application::notify(QObject *receiver, QEvent *event) bool Application::notify(QObject *receiver, QEvent *event)
{ {
bool retVal = true; bool retVal = true;
//try { try {
retVal = QApplication::notify(receiver, event); retVal = QApplication::notify(receiver, event);
//} catch (assertion_failure ex) { } catch (assertion_failure ex) {
// QString msg; QString msg;
// QTextStream out(&msg); QTextStream out(&msg);
// out << ex.filename.c_str() << " at " << ex.line << "\n"; out << ex.filename.c_str() << " at " << ex.line << "\n";
// out << ex.msg.c_str(); out << ex.msg.c_str();
// QMessageBox::critical(0, "Error", msg); QMessageBox::critical(0, "Error", msg);
//} catch (...) { } catch (...) {
// QMessageBox::critical(0, "Error", "Fatal error !!!"); QMessageBox::critical(0, "Error", "Fatal error !!!");
//} }
return retVal; return retVal;
} }

View File

@ -241,9 +241,10 @@ void LineShader::draw(const LineShaderData &line, const QColor &color, float thi
} }
FPGAViewWidget::FPGAViewWidget(QWidget *parent) FPGAViewWidget::FPGAViewWidget(QWidget *parent)
: QOpenGLWidget(parent), lineShader_(this), zoom_(500.f), ctx_(nullptr), paintTimer_(this), rendererData_(new FPGAViewWidget::RendererData), rendererArgs_(new FPGAViewWidget::RendererArgs) : QOpenGLWidget(parent), lineShader_(this), zoom_(500.f), ctx_(nullptr), paintTimer_(this),
rendererData_(new FPGAViewWidget::RendererData), rendererArgs_(new FPGAViewWidget::RendererArgs)
{ {
colors_.background = QColor("#000000"); colors_.background = QColor("#000000");
colors_.grid = QColor("#333"); colors_.grid = QColor("#333");
colors_.frame = QColor("#d0d0d0"); colors_.frame = QColor("#d0d0d0");
colors_.hidden = QColor("#606060"); colors_.hidden = QColor("#606060");
@ -275,12 +276,12 @@ FPGAViewWidget::FPGAViewWidget(QWidget *parent)
printf("Could not get OpenGL 3.1 context - trying anyway...\n "); printf("Could not get OpenGL 3.1 context - trying anyway...\n ");
} }
connect(&paintTimer_, SIGNAL(timeout()), this, SLOT(update())); connect(&paintTimer_, SIGNAL(timeout()), this, SLOT(update()));
paintTimer_.start(std::chrono::duration<int, std::milli>(1000/20)); // paint GL 20 times per second paintTimer_.start(std::chrono::duration<int, std::milli>(1000 / 20)); // paint GL 20 times per second
renderRunner_ = std::unique_ptr<PeriodicRunner>(new PeriodicRunner(this, [this] { renderLines(); })); renderRunner_ = std::unique_ptr<PeriodicRunner>(new PeriodicRunner(this, [this] { renderLines(); }));
renderRunner_->start(); renderRunner_->start();
renderRunner_->startTimer(std::chrono::duration<int, std::milli>(1000/2)); // render line 2 times per second renderRunner_->startTimer(std::chrono::duration<int, std::milli>(1000 / 2)); // render line 2 times per second
} }
FPGAViewWidget::~FPGAViewWidget() {} FPGAViewWidget::~FPGAViewWidget() {}
@ -301,7 +302,8 @@ void FPGAViewWidget::initializeGL()
log_error("Could not compile shader.\n"); log_error("Could not compile shader.\n");
} }
initializeOpenGLFunctions(); initializeOpenGLFunctions();
glClearColor(colors_.background.red() / 255, colors_.background.green() / 255, colors_.background.blue() / 255, 0.0); glClearColor(colors_.background.red() / 255, colors_.background.green() / 255, colors_.background.blue() / 255,
0.0);
} }
void FPGAViewWidget::drawDecal(LineShaderData &out, const DecalXY &decal) void FPGAViewWidget::drawDecal(LineShaderData &out, const DecalXY &decal)
@ -417,9 +419,7 @@ void FPGAViewWidget::paintGL()
rendererDataLock_.unlock(); rendererDataLock_.unlock();
} }
void FPGAViewWidget::pokeRenderer(void) { void FPGAViewWidget::pokeRenderer(void) { renderRunner_->poke(); }
renderRunner_->poke();
}
void FPGAViewWidget::renderLines(void) void FPGAViewWidget::renderLines(void)
{ {
@ -439,7 +439,7 @@ void FPGAViewWidget::renderLines(void)
ctx_->frameUiReload = false; ctx_->frameUiReload = false;
decalsChanged = true; decalsChanged = true;
} }
if (ctx_->belUiReload.size() > 0){ if (ctx_->belUiReload.size() > 0) {
ctx_->belUiReload.clear(); ctx_->belUiReload.clear();
decalsChanged = true; decalsChanged = true;
} }
@ -525,7 +525,6 @@ void FPGAViewWidget::renderLines(void)
rendererDataLock_.unlock(); rendererDataLock_.unlock();
} }
void FPGAViewWidget::onSelectedArchItem(std::vector<DecalXY> decals) void FPGAViewWidget::onSelectedArchItem(std::vector<DecalXY> decals)
{ {
rendererArgsLock_.lock(); rendererArgsLock_.lock();

View File

@ -28,8 +28,8 @@
#include <QOpenGLVertexArrayObject> #include <QOpenGLVertexArrayObject>
#include <QOpenGLWidget> #include <QOpenGLWidget>
#include <QPainter> #include <QPainter>
#include <QTimer>
#include <QThread> #include <QThread>
#include <QTimer>
#include <QWaitCondition> #include <QWaitCondition>
#include "nextpnr.h" #include "nextpnr.h"
@ -213,15 +213,16 @@ class LineShader
class PeriodicRunner : public QThread class PeriodicRunner : public QThread
{ {
Q_OBJECT Q_OBJECT
private: private:
QMutex mutex_; QMutex mutex_;
QWaitCondition condition_; QWaitCondition condition_;
bool abort_; bool abort_;
std::function<void()> target_; std::function<void()> target_;
QTimer timer_; QTimer timer_;
public:
explicit PeriodicRunner(QObject *parent, std::function<void()> target) : public:
QThread(parent), abort_(false), target_(target), timer_(this) explicit PeriodicRunner(QObject *parent, std::function<void()> target)
: QThread(parent), abort_(false), target_(target), timer_(this)
{ {
connect(&timer_, &QTimer::timeout, this, &PeriodicRunner::poke); connect(&timer_, &QTimer::timeout, this, &PeriodicRunner::poke);
} }
@ -243,10 +244,7 @@ public:
} }
} }
void startTimer(std::chrono::milliseconds value) void startTimer(std::chrono::milliseconds value) { timer_.start(value); }
{
timer_.start(value);
}
~PeriodicRunner() ~PeriodicRunner()
{ {
@ -258,10 +256,7 @@ public:
wait(); wait();
} }
void poke(void) void poke(void) { condition_.wakeOne(); }
{
condition_.wakeOne();
}
}; };
class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions
@ -319,7 +314,8 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions
std::unique_ptr<PeriodicRunner> renderRunner_; std::unique_ptr<PeriodicRunner> renderRunner_;
struct { struct
{
QColor background; QColor background;
QColor grid; QColor grid;
QColor frame; QColor frame;
@ -330,13 +326,15 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions
QColor highlight[8]; QColor highlight[8];
} colors_; } colors_;
struct RendererData { struct RendererData
{
LineShaderData decals[4]; LineShaderData decals[4];
LineShaderData selected; LineShaderData selected;
LineShaderData highlighted[8]; LineShaderData highlighted[8];
}; };
struct RendererArgs { struct RendererArgs
{
std::vector<DecalXY> selectedItems; std::vector<DecalXY> selectedItems;
std::vector<DecalXY> highlightedItems[8]; std::vector<DecalXY> highlightedItems[8];
bool highlightedOrSelectedChanged; bool highlightedOrSelectedChanged;