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.
This commit is contained in:
parent
b8a42ff53b
commit
499951cb65
@ -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);
|
||||
|
||||
|
@ -286,24 +286,30 @@ 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;
|
||||
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(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.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)
|
||||
PolyLine(offsetX + scale * el.x1, offsetY + scale * el.y1, offsetX + scale * el.x2, offsetY + scale * el.y2)
|
||||
.build(out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QMatrix4x4 FPGAViewWidget::getProjection(void)
|
||||
{
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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\"";
|
||||
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 * el.x1) << "\" y=\"" << (offset + scale * el.y1) << "\" height=\""
|
||||
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";
|
||||
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";
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user