Skip to content

WIP: Switch to QtWebEngine for rendering SVGs

Madhav Kanbur requested to merge abcdjdj/gwenview:svg-webengine2 into master

Switch to Qt WebEngine (based on Chromium) for better SVG support.

Implementation - Qt WebEngine has a ready-to-use widget called QWebEngineView for displaying dynamic web content. However, resizing/zooming/scrolling is extremely laggy at present. Secondly, it crashes when Gwenview's OpenGL renderer is enabled. So instead, we do this -

  1. Create a "hidden" QWebEngineView widget
  2. Load SVG and resize (upscale) the qwebengineview widget if it's too tiny
  3. Wait for loading to finish. NOTE : Loading != Rendering. See comment in SvgDocumentLoadedImpl::onLoadFinished() for more info
  4. Render the web page onto a QPixmap
  5. Display the QPixmap via a QGraphicsPixmapItem with Qt::SmoothTransformation enabled to avoid pixelation when zooming in

Future Improvements -

  1. Find a reliable way to wait for QWebEngineView's rendering to finish before painting it on the pixmap
  2. Set the background for transparent SVGs as per the user's config.

BUG: 336436

Signed-off-by: Madhav Kanbur abcdjdj@gmail.com

Merge request reports