Hello. While working to increase rendering efficiency of I noticed via valgrind’s callgrind tool that vtkWindow::GetSize() was taking up more time than expected. Caching the TileSize on change of Size/TileScale improved the rendering speed by a small amount.
However, there is currently no way to force the re-computation on change of Size/TileScale because of two reasons:
- The Size/TileScale members are protected, so all derived classes (which there are many) would have to do the re-computation after every change of Size/TileScale. My opinion is this is not feasible or reasonable.
- The GetSize/GetTileScale functions expose a non-const pointer to the Size/TileScale members, which makes them equivalent to public members. Any code is then free to update these variables at will (which does happen in current VTK code).
The standard way in C++ to fix this, is to make Size/TileSize and TileScale all private and have set/get functions that can properly enforce the invariant. I have merge request that does this, but am unsure as to the impact to the greater VTK community and how to properly make a breaking change to the interface of such a fundamental class. (Note: new functions cannot merely be added, because the current GetSize method allows unfettered access to the internals).
Is it worth pursuing this change, or are the costs too high for benefit?
Link to merge request: https://gitlab.kitware.com/vtk/vtk/-/merge_requests/8401