Commit cc0dcb69 authored by RazrFalcon's avatar RazrFalcon

(c-api) Qt wrapper refactoring.

parent 8e1a14f5
......@@ -39,7 +39,7 @@ pangocairo = { version = "0.5", optional = true }
# qt backend
#resvg-qt = { version = "0.3", optional = true }
#resvg-qt = { path = "../resvg-qt", optional = true }
resvg-qt = { git = "https://github.com/RazrFalcon/resvg-qt", rev = "716fe9e", optional = true }
resvg-qt = { git = "https://github.com/RazrFalcon/resvg-qt", rev = "fd0ed4f", optional = true }
unicode-segmentation = "1.2.1"
[features]
......
[package]
name = "resvg-capi"
version = "0.2.0"
version = "0.3.0"
authors = ["Evgeniy Reizner <razrfalcon@gmail.com>"]
keywords = ["svg", "render", "raster", "capi"]
license = "MPL-2.0"
......
......@@ -18,6 +18,17 @@ extern "C" {
#include <QDebug>
static void initOptions(resvg_options &opt)
{
resvg_init_options(&opt);
const auto screens = qApp->screens();
if (!screens.isEmpty()) {
const auto screen = screens.at(0);
opt.dpi = screen->logicalDotsPerInch() * screen->devicePixelRatio();
}
}
class ResvgRendererPrivate
{
public:
......@@ -38,6 +49,7 @@ public:
opt.path = NULL;
}
initOptions(opt);
viewBox = QRectF();
errMsg = QString();
}
......@@ -48,18 +60,6 @@ public:
QString errMsg;
};
static void initOptions(resvg_options &opt)
{
resvg_init_options(&opt);
const auto screens = qApp->screens();
if (!screens.isEmpty()) {
const auto screen = screens.at(0);
opt.dpi = screen->logicalDotsPerInch() * screen->devicePixelRatio();
}
}
static QString errorToString(const int err)
{
switch (err) {
......@@ -116,7 +116,6 @@ bool ResvgRenderer::load(const QString &filePath)
}
d->reset();
initOptions(d->opt);
const auto utf8Str = filePath.toUtf8();
const auto rawFilePath = utf8Str.constData();
......@@ -137,7 +136,6 @@ bool ResvgRenderer::load(const QString &filePath)
bool ResvgRenderer::load(const QByteArray &data)
{
d->reset();
initOptions(d->opt);
const auto err = resvg_parse_tree_from_data(data.constData(), data.size(), &d->opt, &d->tree);
if (err != RESVG_OK) {
......
......@@ -8,7 +8,6 @@
#include <QMimeData>
#include <QTimer>
#include <QThread>
#include <QSvgRenderer>
#include <QDebug>
#include "svgview.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment