In trying to squeeze performance for #109 I stumbled upon many resources for toying with avoidance of graphics re-drawing/rendering and have now a slew of place to get started if we decide to dig further on this optimization front in the Qt types and apis.
This also pertains to ongoing work discussed in #109 which has since moved to rendering OHLC bars using QPainterPath much like pyqtgraph's internal usage for line plots which are very performant even for moderately sized data sets.
As some preface please note the following:
pyqtgraph uses the Graphics View framework internally for which it overrides and extends many types, in particular the GraphicsItem and QGraphicsWidget types which serve as the base for almost everything drawn to screen
we've adopted this as the implementation for our internal BarsItems graphics and it seems to be scaling well (at least way better then any other easily testable platform) with renders of 15-20k bars with ~ 3 - 10ms latency depending on how far zoomed out the view is.
we've numba-ized the binary format array generation which can likely be extended if arrayToQPath() can be split up into it's numpy only and Qt only parts.
appends are supported out of the box using .addPath() (which we're also using) which avoids having to regenerate path segments previously drawn to screen
use of QPicture and QPainter.drawPicture() seems to slow this down oddly
pyqtgraph has internal support for the old API which needs to be updated and tested with QtGui.QOpenGLWidget in the graphics scene code here (which I've tested but haven't had a GPU rich machine to see if it's better yet)
In trying to squeeze performance for #109 I stumbled upon many resources for toying with avoidance of graphics re-drawing/rendering and have now a slew of place to get started if we decide to dig further on this optimization front in the
Qt
types and apis.This also pertains to ongoing work discussed in #109 which has since moved to rendering OHLC bars using
QPainterPath
much likepyqtgraph
's internal usage for line plots which are very performant even for moderately sized data sets.As some preface please note the following:
pyqtgraph
uses the Graphics View framework internally for which it overrides and extends many types, in particular theGraphicsItem
andQGraphicsWidget
types which serve as the base for almost everything drawn to screenQGraphicsView
(make sure to read follow up comments)QPainter
api is a mustQt
and the 2d painting exampleQt
QPainterPath
(what we're using)pyqtgraph
uses this internally with a fancy binary-format array generation routine,pg.functions.arrayToQPath()
, which streams to the path magically and is quite fastBarsItems
graphics and it seems to be scaling well (at least way better then any other easily testable platform) with renders of 15-20k bars with ~ 3 - 10ms latency depending on how far zoomed out the view is.numba
-ized the binary format array generation which can likely be extended ifarrayToQPath()
can be split up into it'snumpy
only andQt
only parts..addPath()
(which we're also using) which avoids having to regenerate path segments previously drawn to screenQPicture
andQPainter.drawPicture()
seems to slow this down oddlyQBackingStore
(what we should probably look into for further speedups)QBackingStore
api docsQWindow
and the raster surface none of which has been tested inside thepyqtgraph
ecosystempyqtgraph
that offers aQObject
based canvas api.OpenGL options in
Qt
(the distant goals of 3d UX)pyqtgraph
has internal support for the old API which needs to be updated and tested withQtGui.QOpenGLWidget
in the graphics scene code here (which I've tested but haven't had a GPU rich machine to see if it's better yet)QPixMap
for painting images to screen (likely not what we want at all)QPainter.drawPixmap()
and redraws withQPainter.play()
QPicture
draws:QPicture.play()
seems to be slowing everything downQPainter
"keeping" previous drawings to avoid re-drawsQPainterPath
overQLineF
(this is actually the eventual solution we came to for bars drawing)QPixMap
apiQPixmap
inside aQGraphicsScene
QPainter
and bitmap graphicsQPixmap
for rendering a magnifying glass thinger