aboutsummaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--common/nextpnr.h72
-rw-r--r--gui/fpgaviewwidget.cc52
-rw-r--r--gui/fpgaviewwidget.h2
-rw-r--r--ice40/main.cc32
4 files changed, 43 insertions, 115 deletions
diff --git a/common/nextpnr.h b/common/nextpnr.h
index 5e8c2362..50465869 100644
--- a/common/nextpnr.h
+++ b/common/nextpnr.h
@@ -312,78 +312,6 @@ struct Context : Arch
// --------------------------------------------------------------
- NPNR_DEPRECATED std::vector<GraphicElement> getFrameGraphics() const
- {
- std::vector<GraphicElement> ret;
- DecalXY decalxy = getFrameDecal();
- ret = getDecalGraphics(decalxy.decal);
- for (auto &it : ret) {
- it.x1 += decalxy.x;
- it.x2 += decalxy.x;
- it.y1 += decalxy.y;
- it.y2 += decalxy.y;
- }
- return ret;
- }
-
- NPNR_DEPRECATED std::vector<GraphicElement> getBelGraphics(BelId bel) const
- {
- std::vector<GraphicElement> ret;
- DecalXY decalxy = getBelDecal(bel);
- ret = getDecalGraphics(decalxy.decal);
- for (auto &it : ret) {
- it.x1 += decalxy.x;
- it.x2 += decalxy.x;
- it.y1 += decalxy.y;
- it.y2 += decalxy.y;
- }
- return ret;
- }
-
- NPNR_DEPRECATED std::vector<GraphicElement> getWireGraphics(WireId wire) const
- {
- std::vector<GraphicElement> ret;
- DecalXY decalxy = getWireDecal(wire);
- ret = getDecalGraphics(decalxy.decal);
- for (auto &it : ret) {
- it.x1 += decalxy.x;
- it.x2 += decalxy.x;
- it.y1 += decalxy.y;
- it.y2 += decalxy.y;
- }
- return ret;
- }
-
- NPNR_DEPRECATED std::vector<GraphicElement> getPipGraphics(PipId pip) const
- {
- std::vector<GraphicElement> ret;
- DecalXY decalxy = getPipDecal(pip);
- ret = getDecalGraphics(decalxy.decal);
- for (auto &it : ret) {
- it.x1 += decalxy.x;
- it.x2 += decalxy.x;
- it.y1 += decalxy.y;
- it.y2 += decalxy.y;
- }
- return ret;
- }
-
- NPNR_DEPRECATED std::vector<GraphicElement> getGroupGraphics(GroupId group) const
- {
- std::vector<GraphicElement> ret;
- DecalXY decalxy = getGroupDecal(group);
- ret = getDecalGraphics(decalxy.decal);
- for (auto &it : ret) {
- it.x1 += decalxy.x;
- it.x2 += decalxy.x;
- it.y1 += decalxy.y;
- it.y2 += decalxy.y;
- }
- return ret;
- }
-
- // --------------------------------------------------------------
-
// provided by router1.cc
bool getActualRouteDelay(WireId src_wire, WireId dst_wire, delay_t &delay);
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);
diff --git a/ice40/main.cc b/ice40/main.cc
index 5fa58921..32864703 100644
--- a/ice40/main.cc
+++ b/ice40/main.cc
@@ -47,20 +47,22 @@
USING_NEXTPNR_NAMESPACE
-void svg_dump_el(const GraphicElement &el)
+void svg_dump_decal(const Context &ctx, const DecalXY &decal)
{
- float scale = 10.0, offset = 10.0;
- std::string style = "stroke=\"black\" stroke-width=\"0.1\" fill=\"none\"";
-
- if (el.type == GraphicElement::G_BOX) {
- std::cout << "<rect x=\"" << (offset + scale * el.x1) << "\" y=\"" << (offset + scale * el.y1) << "\" height=\""
- << (scale * (el.y2 - el.y1)) << "\" width=\"" << (scale * (el.x2 - el.x1)) << "\" " << style
- << "/>\n";
- }
+ const float scale = 10.0, offset = 10.0;
+ const std::string style = "stroke=\"black\" stroke-width=\"0.1\" fill=\"none\"";
+
+ for (auto &el : ctx.getDecalGraphics(decal.decal)) {
+ if (el.type == GraphicElement::G_BOX) {
+ std::cout << "<rect x=\"" << (offset + scale * (decal.x + el.x1)) << "\" y=\"" << (offset + scale * (decal.y + el.y1)) << "\" height=\""
+ << (scale * (el.y2 - el.y1)) << "\" width=\"" << (scale * (el.x2 - el.x1)) << "\" " << style
+ << "/>\n";
+ }
- if (el.type == GraphicElement::G_LINE) {
- std::cout << "<line x1=\"" << (offset + scale * el.x1) << "\" y1=\"" << (offset + scale * el.y1) << "\" x2=\""
- << (offset + scale * el.x2) << "\" y2=\"" << (offset + scale * el.y2) << "\" " << style << "/>\n";
+ if (el.type == GraphicElement::G_LINE) {
+ std::cout << "<line x1=\"" << (offset + scale * (decal.x + el.x1)) << "\" y1=\"" << (offset + scale * (decal.y + el.y1)) << "\" x2=\""
+ << (offset + scale * (decal.x + el.x2)) << "\" y2=\"" << (offset + scale * (decal.y + el.y2)) << "\" " << style << "/>\n";
+ }
}
}
@@ -291,12 +293,10 @@ int main(int argc, char *argv[])
"xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n";
for (auto bel : ctx.getBels()) {
std::cout << "<!-- " << ctx.getBelName(bel).str(&ctx) << " -->\n";
- for (auto &el : ctx.getBelGraphics(bel))
- svg_dump_el(el);
+ svg_dump_decal(ctx, ctx.getBelDecal(bel));
}
std::cout << "<!-- Frame -->\n";
- for (auto &el : ctx.getFrameGraphics())
- svg_dump_el(el);
+ svg_dump_decal(ctx, ctx.getFrameDecal());
std::cout << "</svg>\n";
}