From 499951cb65ff31fe15aa360a6b44371b13815d66 Mon Sep 17 00:00:00 2001 From: Sergiusz Bazanski Date: Thu, 12 Jul 2018 21:30:36 +0100 Subject: 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. --- common/nextpnr.h | 72 --------------------------------------------------- gui/fpgaviewwidget.cc | 52 ++++++++++++++++++------------------- gui/fpgaviewwidget.h | 2 +- ice40/main.cc | 32 +++++++++++------------ 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 getFrameGraphics() const - { - std::vector 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 getBelGraphics(BelId bel) const - { - std::vector 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 getWireGraphics(WireId wire) const - { - std::vector 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 getPipGraphics(PipId pip) const - { - std::vector 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 getGroupGraphics(GroupId group) const - { - std::vector 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 << "\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 << "\n"; + } - if (el.type == GraphicElement::G_LINE) { - std::cout << "\n"; + if (el.type == GraphicElement::G_LINE) { + std::cout << "\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 << "\n"; - for (auto &el : ctx.getBelGraphics(bel)) - svg_dump_el(el); + svg_dump_decal(ctx, ctx.getBelDecal(bel)); } std::cout << "\n"; - for (auto &el : ctx.getFrameGraphics()) - svg_dump_el(el); + svg_dump_decal(ctx, ctx.getFrameDecal()); std::cout << "\n"; } -- cgit v1.2.3