Off Screen Rendering Improvements to JPedal Viewer

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.

Animated image demonstrating text highlighting in default rendering

Animated image demonstrating text highlighting in default rendering

Default Rendering

Animated image demonstrating text highlighting in off screen rendering

Animated image demonstrating text highlighting in off screen rendering

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.
<useOffScreenRendering value=”false”/>

Via PdfDecoder
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);

If you’re a first-time reader, or simply want to be notified when we post new articles and updates, you can keep up to date by social media (Twitter, Facebook and Google+) or the Blog RSS.

Related Posts:

The following two tabs change content below.
Kieran France is a programmer for IDRSolutions. He enjoys tinkering with most things including gadgets, code and electronics. He spends his time working on the the JPedal library and our internal test suite..
KieranF

About Kieran France

Kieran France is a programmer for IDRSolutions. He enjoys tinkering with most things including gadgets, code and electronics. He spends his time working on the the JPedal library and our internal test suite..

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>