If a PDF viewer must display an Image that represents a whole page, the user can still zoom and pan the page in such a way that it needs to be rendered at high resolution, but only part of it is visible. It should be possible for an Image to "look upwards" to the window within which it's rendered, and perhaps also take into account any overlapping Items that obscure part of the Image, and come up with a rectangular area that is visible. Only this area really needs to be rendered. So perhaps the Image can populate a smaller texture into the scene graph, thus saving on memory and rendering time.
But it will also need to be updated when the user pans to a different position. This should not be done synchronously. Various solutions are possible:
1) leave it up to QML code to give the Image a viewport rect, and update that only when the user is done panning (so, add a new QRectF property to Image, and bind it to some other property that only changes when panning is done?)
2) add a new flag to mark the viewport "dirty" and update periodically, as CPU time permits (because rendering a PDF page is non-trivial): the advantage would be that it would re-render (slowly) even while the user is still dragging
3) treat it as a tiling problem: break up the Image into tiles, and populate separate textures into the scene graph for each tile that is currently rendered. Thus small panning movements may not require any more rendering, but only when the user moves it so far that it goes past the edge of the existing tiles, and needs to render more of them. An advantage might be working around the texture size limit that afflicts some GPUs (if there is not already some solution for that).
The tiling solution is the most generic, but also would tend to overlap with functionality that has already been created in QtLocation (the world map always needs to be tiled, because almost nobody can afford to render the whole world at high resolution to one big image), and in TableView. In fact a TiledImage component could probably be created as a TableView where each delegate is an Image that asks the QImageIOHandler for just a part of the image, by calling setOption(ScaledClipRect, QRect(...)) . But then we have to figure out how to apply PinchHandler to an entire TableView to be able to pinch-zoom the whole thing as if it was one image. So maybe it's easier to make a TiledImage class instead.
|For Gerrit Dashboard: QTBUG-77521|
|282970,31||Allow any Item to act as a viewport for any of its children||dev||qt/qtdeclarative||Status: NEW||+2||0|
|366286,1||WIP Add TiledImage to optimize rendering of large images||dev||qt/qtdeclarative||Status: NEW||-2||0|
|284381,6||WIP Add TiledImage to optimize rendering of large images||5.15||qt/qtdeclarative||Status: ABANDONED||-2||0|