Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,360 changes: 1,680 additions & 1,680 deletions results.csv

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions tools/vdiff/src/exportdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ ExportDialog::ExportDialog(const QList<Backend> &backends, QWidget *parent)
ui->chBoxBInkscape->setEnabled(backends.contains(Backend::Inkscape));
ui->chBoxBLibrsvg->setEnabled(backends.contains(Backend::Librsvg));
ui->chBoxBQtSvg->setEnabled(backends.contains(Backend::QtSvg));
ui->chBoxBLadybird->setEnabled(backends.contains(Backend::Ladybird));

ui->chBoxBResvg->setChecked(backends.contains(Backend::Resvg));
ui->chBoxBChrome->setChecked(backends.contains(Backend::Chrome));
Expand All @@ -27,6 +28,7 @@ ExportDialog::ExportDialog(const QList<Backend> &backends, QWidget *parent)
ui->chBoxBInkscape->setChecked(backends.contains(Backend::Inkscape));
ui->chBoxBLibrsvg->setChecked(backends.contains(Backend::Librsvg));
ui->chBoxBQtSvg->setChecked(backends.contains(Backend::QtSvg));
ui->chBoxBLadybird->setChecked(backends.contains(Backend::Ladybird));

ui->buttonBox->button(QDialogButtonBox::Ok)->setText("Export");

Expand Down Expand Up @@ -54,6 +56,8 @@ ExportDialog::Options ExportDialog::options() const
if (ui->chBoxBInkscape->isChecked()) { opt.backends << Backend::Inkscape; }
if (ui->chBoxBLibrsvg->isChecked()) { opt.backends << Backend::Librsvg; }
if (ui->chBoxBQtSvg->isChecked()) { opt.backends << Backend::QtSvg; }
if (ui->chBoxBLadybird->isChecked()) { opt.backends << Backend::Ladybird; }


return opt;
}
15 changes: 11 additions & 4 deletions tools/vdiff/src/exportdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,17 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chBoxBLadybird">
<property name="text">
<string>Ladybird</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down Expand Up @@ -135,7 +142,7 @@
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand All @@ -152,10 +159,10 @@
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
</property>
</widget>
</item>
Expand Down
4 changes: 4 additions & 0 deletions tools/vdiff/src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ void MainWindow::prepareBackends()
backends << Backend::QtSvg;
}

if (m_settings.useLadybird) {
backends << Backend::Ladybird;
}


for (const Backend backend : backends) {
auto w = new BackendWidget(backend);
Expand Down
41 changes: 38 additions & 3 deletions tools/vdiff/src/render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <QXmlStreamReader>
#include <QtConcurrent/QtConcurrentMap>
#include <QtConcurrent/QtConcurrentRun>
#include <QDir>

#include <cmath>

Expand Down Expand Up @@ -307,6 +308,34 @@ QImage Render::renderViaQtSvg(const RenderData &data)
return loadImage(outImg);
}

QImage Render::renderViaLadybird(const RenderData& data)
{
// Define the default output image path
const auto defaultOutImg = Paths::workDir() + "/output.png"; // Ladybird default output file

QStringList arguments = {
"--screenshot=1", // Take screenshot after 1 second
"--width=500", // Set viewport width to 500 pixels
"--height=500", // Set viewport height to 500 pixels
data.imgPath // Path to the SVG file to render
};

// Change working directory to ensure the output goes where expected
QDir::setCurrent(Paths::workDir());

// Execute the command
const QString out = Process::run(data.convPath, arguments, true);

// Check if the default output file was created
QFile file(defaultOutImg);
if (!file.exists()) {
throw QString("Failed to generate output image: %1").arg(defaultOutImg);
}

return loadImage(defaultOutImg);
}


void Render::renderImages()
{
const auto ts = m_settings->testSuite;
Expand Down Expand Up @@ -372,6 +401,10 @@ void Render::renderImages()
list.append({ Backend::QtSvg, m_viewSize, imageSize, m_imgPath, QString(), ts });
}

if (m_settings->useLadybird) {
renderCached(Backend::Ladybird, m_settings->ladybirdPath);
}

const auto future = QtConcurrent::mapped(list, &Render::renderImage);
m_watcher1.setFuture(future);
}
Expand Down Expand Up @@ -402,6 +435,7 @@ RenderResult Render::renderImage(const RenderData &data)
case Backend::Inkscape : img = renderViaInkscape(data); break;
case Backend::Librsvg : img = renderViaRsvg(data); break;
case Backend::QtSvg : img = renderViaQtSvg(data); break;
case Backend::Ladybird : img = renderViaLadybird(data); break;
}

return { data.type, img };
Expand Down Expand Up @@ -505,7 +539,8 @@ void Render::onImageRendered(const int idx)
case Backend::Firefox :
case Backend::Safari :
case Backend::Batik :
case Backend::Inkscape : m_imgCache.setImage(res.type, m_imgPath, res.img); break;
case Backend::Inkscape :
case Backend::Ladybird : m_imgCache.setImage(res.type, m_imgPath, res.img); break;
default : break;
}
}
Expand All @@ -525,7 +560,7 @@ void Render::onImagesRendered()
}
};

for (int t = (int)Backend::Firefox; t <= (int)Backend::QtSvg; ++t) {
for (int t = (int)Backend::Firefox; t <= (int)Backend::Ladybird; ++t) {
append((Backend)t);
}

Expand All @@ -541,7 +576,7 @@ void Render::onImagesRendered()
}
};

for (int t = (int)Backend::Chrome; t <= (int)Backend::QtSvg; ++t) {
for (int t = (int)Backend::Chrome; t <= (int)Backend::Ladybird; ++t) {
append((Backend)t);
}

Expand Down
1 change: 1 addition & 0 deletions tools/vdiff/src/render.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class Render : public QObject
static QImage renderViaInkscape(const RenderData &data);
static QImage renderViaRsvg(const RenderData &data);
static QImage renderViaQtSvg(const RenderData &data);
static QImage renderViaLadybird(const RenderData &data);
static RenderResult renderImage(const RenderData &data);
static DiffOutput diffImage(const DiffData &data);

Expand Down
6 changes: 6 additions & 0 deletions tools/vdiff/src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace Key {
static const QString BatikPath = "BatikPath";
static const QString InkscapePath = "InkscapePath";
static const QString RsvgPath = "RsvgPath";
static const QString LadybirdPath = "LadybirdPath";
static const QString UseChrome = "UseChrome";
static const QString UseFirefox = "UseFirefox";
static const QString UseSafari = "UseSafari";
Expand All @@ -20,6 +21,7 @@ namespace Key {
static const QString UseSvgNet = "UseSvgNet";
static const QString UseLibrsvg = "UseLibrsvg";
static const QString UseQtSvg = "UseQtSvg";
static const QString UseLadybird = "UseLadybird";
static const QString ViewSize = "ViewSize";
}

Expand Down Expand Up @@ -72,12 +74,14 @@ void Settings::load() noexcept
this->useLibrsvg = appSettings.value(Key::UseLibrsvg).toBool();
this->useSvgNet = appSettings.value(Key::UseSvgNet).toBool();
this->useQtSvg = appSettings.value(Key::UseQtSvg).toBool();
this->useLadybird = appSettings.value(Key::UseLadybird).toBool();

this->resvgDir = appSettings.value(Key::ResvgDir).toString();
this->firefoxPath = appSettings.value(Key::FirefoxPath).toString();
this->batikPath = appSettings.value(Key::BatikPath).toString();
this->inkscapePath = appSettings.value(Key::InkscapePath).toString();
this->librsvgPath = appSettings.value(Key::RsvgPath).toString();
this->ladybirdPath = appSettings.value(Key::LadybirdPath).toString();
}

void Settings::save() const noexcept
Expand All @@ -95,11 +99,13 @@ void Settings::save() const noexcept
appSettings.setValue(Key::UseLibrsvg, this->useLibrsvg);
appSettings.setValue(Key::UseSvgNet, this->useSvgNet);
appSettings.setValue(Key::UseQtSvg, this->useQtSvg);
appSettings.setValue(Key::UseLadybird, this->useLadybird);
appSettings.setValue(Key::ResvgDir, this->resvgDir);
appSettings.setValue(Key::FirefoxPath, this->firefoxPath);
appSettings.setValue(Key::BatikPath, this->batikPath);
appSettings.setValue(Key::InkscapePath, this->inkscapePath);
appSettings.setValue(Key::RsvgPath, this->librsvgPath);
appSettings.setValue(Key::LadybirdPath, this->ladybirdPath);
}

QString Settings::resvgPath() const noexcept
Expand Down
2 changes: 2 additions & 0 deletions tools/vdiff/src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ class Settings
bool useLibrsvg = true;
bool useSvgNet = true;
bool useQtSvg = true;
bool useLadybird = true;
QString resvgDir; // it's a dir, not a path
QString firefoxPath;
QString batikPath;
QString inkscapePath;
QString librsvgPath;
QString ladybirdPath;
};
14 changes: 14 additions & 0 deletions tools/vdiff/src/settingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ void SettingsDialog::loadSettings()

ui->chBoxUseQtSvg->setChecked(m_settings->useQtSvg);

ui->chBoxUseLadybird->setChecked(m_settings->useLadybird);
ui->lineEditLadybird->setText(m_settings->ladybirdPath);

prepareTestsPathWidgets();
}

Expand Down Expand Up @@ -95,12 +98,14 @@ void SettingsDialog::on_buttonBox_accepted()
m_settings->useLibrsvg = ui->chBoxUseLibrsvg->isChecked();
m_settings->useSvgNet = ui->chBoxUseSvgNet->isChecked();
m_settings->useQtSvg = ui->chBoxUseQtSvg->isChecked();
m_settings->useLadybird = ui->chBoxUseLadybird->isChecked();

m_settings->resvgDir = ui->lineEditResvg->text();
m_settings->firefoxPath = ui->lineEditFirefox->text();
m_settings->batikPath = ui->lineEditBatik->text();
m_settings->inkscapePath = ui->lineEditInkscape->text();
m_settings->librsvgPath = ui->lineEditRsvg->text();
m_settings->ladybirdPath = ui->lineEditLadybird->text();

m_settings->save();
}
Expand Down Expand Up @@ -153,3 +158,12 @@ void SettingsDialog::on_btnSelectRsvg_clicked()
ui->lineEditRsvg->setText(path);
}
}

void SettingsDialog::on_btnSelectLadybird_clicked()
{
const auto path = QFileDialog::getOpenFileName(this, "headless-browser exe path");
if (!path.isEmpty()) {
ui->lineEditLadybird->setText(path);
}
}

1 change: 1 addition & 0 deletions tools/vdiff/src/settingsdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ private slots:
void on_btnSelectFirefox_clicked();
void on_btnSelectBatik_clicked();
void on_btnSelectTest_clicked();
void on_btnSelectLadybird_clicked();
void prepareTestsPathWidgets();

private:
Expand Down
Loading