Slow text rendering with vtkCornerAnnotation and big windows
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
Hi, I'm the developer of a medical viewer that uses vtkCornerAnnotation to display image-related information in the corners of the window. I have found that updating the text for each frame is slow when the window is very big, like for example in a 5 MPixel medical display.
With the default vtkTextRenderer implementation in the vtkRenderingFreeType module, when the window is very big, vtkCornerAnnotation updates take a considerable amount of time, to the point of making the application very laggy when scrolling through images. I have tried to limit the text size to a small number, but even then with a big window text rendering is slow and with a small window it's fast, so it's not directly related to text size. In comparison, the old ftgl approach in the vtkRenderingFreeTypeOpenGL module is instantaneous no matter the window size.
A profiler points to vtkFreeTypeTools::RenderCharacter() as the hotspot, but according to David Lonie's answer in the mailing list, the real issue may be in vtkCornerAnnotation::RenderOpaqueGeometry(), which has two loops that resize the text repeatedly to decide the best size.
Possible improvements: "At the very least the initial fontsize should be able to be set, and at best this class should be refactored to use newer text renderering APIs like vtkTextRenderer::GetBoundingBox, which won't actually generate a texture but just compute the dimensions of the resulting image."