In our most recent release of JPedal we have added several enhancements. One of these called off screen rendering was added to improve performance of interactive features in the Viewer. Using this option you can improve the responsiveness of the viewer in large and complex files.
What is off screen rendering
The idea here is that we can improve performance beyond the use of double buffering and volatile images. Rendering this image can take varying amounts of time depending on what is currently being drawn. A single image is relatively quick, a series of complex shapes, image, text and shadings will take longer.
Off screen rendering allows us to move the slower rendering off the screen and EDT and onto an image. Obviously this will increase memory usage but it also allows for a more responsive UI which is worth the cost. The cost works out at 32 bit per pixel, a display area sized to 1920 by 1080 would work out to around 8Mb.
Whenever the Viewers display requires an update we check a set of tracking variables, if they have changed we render the image as we usually would but rendering it to the off screen image. This image is then rendered to the screen. In this first case the rendering takes a tiny amount longer than usual. Then when we need to render the display again without any changes the image is reused, taking only a minuscule amount to time.
What practical use does this have?
PDFs can contain a large variety of different content, some are fast to render, others are slow. We have pages that have a large amount of complex content requiring 500ms or more to render. For viewing this is fine but for interactive functionality this will cause delays.
When highlighting text or drawing annotations the mouse that is controlling these features requires the EDT, as does rendering. On these files the highlighting and annotation creation only updates once every 500ms because we make the change then wait for the page to render the change again.
With off screen rendering the page is rendered when it is first displayed taking the full time (such as 500ms as in the example above). As you then use one of the features the display update takes considerably less time as it is only rendering a single image which is much simpler to handle. This allows these features to be more responsive. Of course this rendering also then takes advantage of any back buffer that has been set up to allow rendering to be performed even faster.
Below you can see the difference this has made.
Off Screen Rendering
How can I use this feature?
This feature is controlled by a flag that can be activated in 2 different ways.
Via Properties file
The properties file used by the Viewer contains the following entry, setting the value to true will turn this feature on.
You can activate this feature with PdfDecoder by passing in the correct value to modifyNonstaticJPedalParameters.
HashMap<Integer, Object> values = new HashMap<Integer, Object>(); values.put(JPedalSettings.OFF_SCREEN_RENDERING, true); pdfDecoder.modifyNonstaticJPedalParameters(values);
Latest posts by Kieran France (see all)
- How Java 10 will improve performance - April 17, 2018
- Pros and Cons of Bitbucket Pipelines - March 15, 2018
- Off Screen Rendering Improvements to JPedal Viewer - February 2, 2018
- How to use Cipher streams in Java - January 10, 2018
- Improved Shape Rendering with Soft Clipping - August 24, 2017