aboutsummaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
authorSergiusz Bazanski <q3k@q3k.org>2018-07-12 21:30:36 +0100
committerSergiusz Bazanski <q3k@q3k.org>2018-07-12 21:30:36 +0100
commit499951cb65ff31fe15aa360a6b44371b13815d66 (patch)
tree8a13613876b17e61b1717288d3cf97a862e270eb /gui
parentb8a42ff53b1fbb6e03d169d14e58180a750f4cad (diff)
downloadnextpnr-499951cb65ff31fe15aa360a6b44371b13815d66.tar.gz
nextpnr-499951cb65ff31fe15aa360a6b44371b13815d66.tar.bz2
nextpnr-499951cb65ff31fe15aa360a6b44371b13815d66.zip
Remove legacy graphics API
For now we do not optimize the OpenGL renderer against the new decal API, but this can be done in the future.
Diffstat (limited to 'gui')
-rw-r--r--gui/fpgaviewwidget.cc52
-rw-r--r--gui/fpgaviewwidget.h2
2 files changed, 27 insertions, 27 deletions
diff --git a/gui/fpgaviewwidget.cc b/gui/fpgaviewwidget.cc
index 1b105b98..84b8f8d2 100644
--- a/gui/fpgaviewwidget.cc
+++ b/gui/fpgaviewwidget.cc
@@ -286,22 +286,28 @@ void FPGAViewWidget::initializeGL()
glClearColor(backgroundColor.red() / 255, backgroundColor.green() / 255, backgroundColor.blue() / 255, 0.0);
}
-void FPGAViewWidget::drawElement(LineShaderData &out, const GraphicElement &el)
+void FPGAViewWidget::drawDecal(LineShaderData &out, const DecalXY &decal)
{
- const float scale = 1.0, offset = 0.0;
-
- if (el.type == GraphicElement::G_BOX) {
- auto line = PolyLine(true);
- line.point(offset + scale * el.x1, offset + scale * el.y1);
- line.point(offset + scale * el.x2, offset + scale * el.y1);
- line.point(offset + scale * el.x2, offset + scale * el.y2);
- line.point(offset + scale * el.x1, offset + scale * el.y2);
- line.build(out);
- }
+ const float scale = 1.0;
+ float offsetX = 0.0, offsetY = 0.0;
+
+ for (auto &el : ctx_->getDecalGraphics(decal.decal)) {
+ offsetX = decal.x;
+ offsetY = decal.y;
+
+ if (el.type == GraphicElement::G_BOX) {
+ auto line = PolyLine(true);
+ line.point(offsetX + scale * el.x1, offsetY + scale * el.y1);
+ line.point(offsetX + scale * el.x2, offsetY + scale * el.y1);
+ line.point(offsetX + scale * el.x2, offsetY + scale * el.y2);
+ line.point(offsetX + scale * el.x1, offsetY + scale * el.y2);
+ line.build(out);
+ }
- if (el.type == GraphicElement::G_LINE) {
- PolyLine(offset + scale * el.x1, offset + scale * el.y1, offset + scale * el.x2, offset + scale * el.y2)
- .build(out);
+ if (el.type == GraphicElement::G_LINE) {
+ PolyLine(offsetX + scale * el.x1, offsetY + scale * el.y1, offsetX + scale * el.x2, offsetY + scale * el.y2)
+ .build(out);
+ }
}
}
@@ -342,8 +348,7 @@ void FPGAViewWidget::paintGL()
auto bels = LineShaderData(thick11Px, belColor);
if (ctx_) {
for (auto bel : ctx_->getBels()) {
- for (auto &el : ctx_->getBelGraphics(bel))
- drawElement(bels, el);
+ drawDecal(bels, ctx_->getBelDecal(bel));
}
lineShader_.draw(bels, matrix);
}
@@ -352,8 +357,7 @@ void FPGAViewWidget::paintGL()
auto wires = LineShaderData(thick11Px, wireColor);
if (ctx_) {
for (auto wire : ctx_->getWires()) {
- for (auto &el : ctx_->getWireGraphics(wire))
- drawElement(wires, el);
+ drawDecal(wires, ctx_->getWireDecal(wire));
}
lineShader_.draw(wires, matrix);
}
@@ -361,9 +365,8 @@ void FPGAViewWidget::paintGL()
// Draw Pips.
auto pips = LineShaderData(thick11Px, pipColor);
if (ctx_) {
- for (auto wire : ctx_->getPips()) {
- for (auto &el : ctx_->getPipGraphics(wire))
- drawElement(pips, el);
+ for (auto pip : ctx_->getPips()) {
+ drawDecal(pips, ctx_->getPipDecal(pip));
}
lineShader_.draw(pips, matrix);
}
@@ -372,8 +375,7 @@ void FPGAViewWidget::paintGL()
auto groups = LineShaderData(thick11Px, groupColor);
if (ctx_) {
for (auto group : ctx_->getGroups()) {
- for (auto &el : ctx_->getGroupGraphics(group))
- drawElement(groups, el);
+ drawDecal(groups, ctx_->getGroupDecal(group));
}
lineShader_.draw(groups, matrix);
}
@@ -381,9 +383,7 @@ void FPGAViewWidget::paintGL()
// Draw Frame Graphics.
auto frames = LineShaderData(thick11Px, frameColor);
if (ctx_) {
- for (auto &el : ctx_->getFrameGraphics()) {
- drawElement(frames, el);
- }
+ drawDecal(frames, ctx_->getFrameDecal());
lineShader_.draw(frames, matrix);
}
}
diff --git a/gui/fpgaviewwidget.h b/gui/fpgaviewwidget.h
index a2495f4e..90e12bbf 100644
--- a/gui/fpgaviewwidget.h
+++ b/gui/fpgaviewwidget.h
@@ -246,7 +246,7 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
- void drawElement(LineShaderData &data, const GraphicElement &el);
+ void drawDecal(LineShaderData &data, const DecalXY &decal);
public Q_SLOTS:
void newContext(Context *ctx);