[Interest] Accellerated WebGL in Qt/WebKit?

Allan Sandfeld Jensen kde at carewolf.com
Fri Mar 7 20:20:00 CET 2014


On Friday 07 March 2014, you wrote:
> Hi Allan,
> 
> > On Saturday 01 March 2014, Jori Liesenborgs wrote:
> >> Hi everyone,
> >> 
> >> I was wondering if someone knows how to avoid copying the view from a
> >> WebGL component to the CPU each time. On [1] it says to use a
> >> QGraphicsWebView with a QGLWidget viewport, but if I try this the result
> >> seems to be even slower than the more naive version.
> > 
> > It should work. What version of Qt are you using?  There was a regression
> > in Qt 5.1 that could trigger if you build against EGL instead of OpenGL.
> > This would cause CPU copying on every frame. In Qt 5.2 though,
> > QGraphicsWebView should always render directly to the QGLWidget, if
> > using accelerated compositing is enable and a Qt GL context was found.
> 
> This is with Qt 5.2.1. When I run it in the 'normal' mode, I get a
> framerate of 35 fps, while using the QGLWidget I get 20 fps (1/3 vsync).
> 
> Is there a working example somewhere that shows how this should be done?
> 
Yes, but the working examples are exactly what you have done. You can try to 
build or look at the the QtTestBrowser in QtWebKit (Tool/qttestbrowser). To 
build it you must edit Tools/qmake/mkspecs/features/configure.prf and add 
build_qttestsupport and build_testbrowser to the config (they are removed for 
'production_build' which is set whenever building with qmake). In the 
QtTestBrowser you can at runtime switch between QWidget based, QGraphicsView 
based and QGraphicsView based with QGLWidget at runtime. You can also build 
using the build_webkit script (look on webkit.org for instructions). When you 
use build_webkit we assume you are developer and makes a developer build of 
qtwebkit with much faster incremental linking and all test tools.

You can also try to adjust the repaint throttle, by default we repaint as fast 
as possible which for accelerated content with a backing store can be faster 
than the application is painting it (slowing things down by doing unnecessary 
work). Look at the dynamic properties on QWebPage (implemented in 
QWebPageAdapter). There are more fine grained control, but could always start 
by try by setting the "_q_RepaintThrottlingPreset" property to "Minimal". If 
that helps you can try to set it to something more optimal (minimal throttles 
repaints to 100fps). 

`Allan



More information about the Interest mailing list