Commit 8245a683 authored by RazrFalcon's avatar RazrFalcon

Update ResvgQt.h

parent ca4bdcfb
......@@ -9,9 +9,11 @@ This changelog also contains important changes in dependencies.
## [Unreleased]
### Added
- Nested `baseline-shift` support.
- (qt-api) `renderToImage`.
### Changed
- `baseline-shift` with `sub`, `super` and percent values calculation.
- (qt-api) `render` methods are `const` now.
### Fixed
- (cairo-backend) `font-family` parsing.
......
......@@ -88,7 +88,7 @@ Also, we do not test against Chrome, Firefox, Inkscape and Batik because they ha
![Chart3](./.github/perf-elementary.svg)
- Elementary Icon Theme contains 3417 files.
- resvg-qt is slow for unknown reasons.
- Qt backend is slow because `QRasterPaintEngine` is slow.
![Chart4](./.github/perf-oxygen.svg)
......
......@@ -231,7 +231,7 @@ public:
/**
* @brief Renders the SVG data to canvas.
*/
void render(QPainter *p);
void render(QPainter *p) const;
/**
* @brief Renders the SVG data to canvas with the specified \b bounds.
......@@ -239,7 +239,7 @@ public:
* If the bounding rectangle is not specified
* the SVG file is mapped to the whole paint device.
*/
void render(QPainter *p, const QRectF &bounds);
void render(QPainter *p, const QRectF &bounds) const;
/**
* @brief Renders the given element with \b elementId on the specified \b bounds.
......@@ -247,8 +247,14 @@ public:
* If the bounding rectangle is not specified
* the SVG element is mapped to the whole paint device.
*/
void render(QPainter *p, const QString &elementId,
const QRectF &bounds = QRectF());
void render(QPainter *p, const QString &elementId, const QRectF &bounds = QRectF()) const;
/**
* @brief Renders the SVG data to \b QImage with a specified \b size.
*
* If \b size is not set, the \b defaultSize() will be used.
*/
QImage renderToImage(const QSize &size = QSize()) const;
/**
* @brief Initializes the library log.
......@@ -419,12 +425,12 @@ inline void ResvgRenderer::setDevicePixelRatio(qreal scaleFactor)
d->scaleFactor = scaleFactor;
}
inline void ResvgRenderer::render(QPainter *p)
inline void ResvgRenderer::render(QPainter *p) const
{
render(p, QRectF());
}
inline void ResvgRenderer::render(QPainter *p, const QRectF &bounds)
inline void ResvgRenderer::render(QPainter *p, const QRectF &bounds) const
{
if (!d->tree)
return;
......@@ -444,12 +450,25 @@ inline void ResvgRenderer::render(QPainter *p, const QRectF &bounds)
p->restore();
}
inline void ResvgRenderer::render(QPainter *p, const QString &elementId, const QRectF &bounds)
inline void ResvgRenderer::render(QPainter *p, const QString &elementId, const QRectF &bounds) const
{
Q_UNUSED(p) Q_UNUSED(elementId) Q_UNUSED(bounds)
Q_UNIMPLEMENTED();
}
inline QImage ResvgRenderer::renderToImage(const QSize &size) const
{
const auto s = size.isValid() ? size : defaultSize();
QImage img(s, QImage::Format_ARGB32_Premultiplied);
img.fill(Qt::transparent);
QPainter p(&img);
render(&p);
p.end();
return img;
}
inline void ResvgRenderer::initLog()
{
resvg_init_log();
......
......@@ -58,9 +58,7 @@ void SvgViewWorker::render(const QSize &viewSize)
QImage img(s * m_dpiRatio, QImage::Format_ARGB32_Premultiplied);
img.fill(Qt::transparent);
QPainter p;
p.begin(&img);
p.setRenderHint(QPainter::Antialiasing);
QPainter p(&img);
m_renderer.render(&p);
p.end();
......
......@@ -176,6 +176,7 @@ e-symbol-006,58
e-text-016,1551,chrome uses different coefficients
e-text-032,552,unsupported #4
e-text-033,361,unsupported #4
e-text-038,1959,chrome bug
e-tref-001,2005,chrome bug
e-tref-002,1180,chrome bug
e-tref-005,2005,chrome bug
......
......@@ -968,3 +968,4 @@ e-tspan-019,8d51455e
e-tspan-020,ddab51fd
e-tspan-021,ddab51fd
e-tspan-022,ddab51fd
e-text-038,4f7d7b56
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