If you are already running an application with a GXY view, LuciadLightspeed offers the possibility to selectively adapt an application based on your current view implementation. Lightspeed views are able to show their contents in both 2D and 3D.

Depending on your needs, you can choose to:

  • Move specific GXY layers to Lightspeed technology but keep your GXY view implementation. This is the topic of this article.

  • Gradually make the switch from a GXY view to a Lightspeed view implementation, by moving the view component and performance-critical layers first, and keeping other layers until later. See Moving from a GXY view to an ILspView for more information.

Regardless of the choice you make, LuciadLightspeed 's Model-View-Controller paradigm ensures that you do not have to change anything on the model side.

Using Lightspeed technology within an ILcdGXYView

LuciadLightspeed provides an easy transition path to convert selected parts of your application to use Lightspeed technology, while keeping your existing ILcdGXYView and all code that interacts with it. This allows you to speed up rendering in situations where you are painting many objects, or displaying complex visualizations such as hypsometry data and density plots.

GXY views already offered a facility to paint heavy data sets asynchronously, on a separate thread. This mechanism has been extended with a special layer wrapper implementation that delegates rendering to a Lightspeed layer. This allows for perfect GXY view compatibility, combined with Lightspeed view rendering.

This article requires prior knowledge of asynchronous layer wrappers. Please refer to Asynchronous painting in a GXY view for more information.

When would you use Lightspeed view technology?

Even though the Lightspeed view technology accelerates many rendering operations, there are some typical use cases where Lightspeed technology can noticeably speed up rendering in an ILcdGXYView. Lightspeed view technology can accelerate the display of:

  • Complex icons

  • Anti-aliased vector shapes

  • Density plots

  • Hypsometry visualizations

For large resolutions (beyond Full HD), it is recommended to use a native Lightspeed view to reduce the 2D compositing overhead that is typically required for ILcdGXYView implementations.

Including a Lightspeed layer in a ILcdGXYView

To include a Lightspeed layer in a ILcdGXYView, wrap the Lightspeed layer in an asynchronous layer wrapper. Program: Using an asynchronous layer wrapper to include a Lightspeed layer in a GXY view. shows how to include a Lightspeed layer in an ILcdGXYView.

Program: Using an asynchronous layer wrapper to include a Lightspeed layer in an ILcdGXYView. (from samples/gxy/concurrent/painting/lightspeed/MainPanel)
ILcdGXYLayer dmedGXYLayer = GXYDataUtil.instance()
                                       .label("Alps [Lightspeed]")
ILspLayer dmedLspLayer = LspDataUtil.instance().model(dmedGXYLayer.getModel()).layer().getLayer();
TLcdGXYLspAsynchronousLayerWrapper asynchronousDmedLayer =
    new TLcdGXYLspAsynchronousLayerWrapper(dmedGXYLayer, dmedLspLayer);
GXYLayerUtil.addGXYLayer(getView(), asynchronousDmedLayer);

The TLcdGXYLspAsynchronousLayerWrapper's constructor takes both an ILspLayer, as well as an ILcdGXYLayer. Just as any other ILcdGXYAsynchronousLayerWrapper, the Lightspeed layer wrapper uses a paint queue to delegate its paint requests to. In order to make use of the Lightspeed layer, a special Lightspeed paint queue must be used: TLcdGXYLspAsynchronousPaintQueue.

This paint queue delegates rendering as follows:

  • Regular paint representations (the ILcdGXYLayer.ALL + ILcdGXYLayer.BODIES paint mode) use the Lightspeed layer.

  • Edited and selected objects (the ILcdGXYLayer.SELECTION paint modes) use the ILcdGXYLayer.

  • Labels (the ILcdGXYLayer.LABELS and ILcdGXYEditableLabelsLayer.PLACED_LABELS paint modes) use the ILcdGXYLayer.

Hence, the Lightspeed layer should at least have a painter configured for painting the regular representations (TLspPaintRepresentationState.REGULAR_BODY). The ILcdGXYLayer should at least have a painter provider configured. If needed, you can prevent selection by overriding the ILcdGXYLayer's isSelectableSupported method. It is good practice to let the layer wrapper create the paint queue as is done in the snippet.

Just as with regular asynchronous layer wrappers, you can use a paint queue manager with the Lightspeed layer wrapper. The paint queue manager automatically creates and assigns the correct paint queue to each layer wrapper. Program: Creating a paint queue manager for a view shows how to set up a paint queue manager capable of dealing with both TLcdGXYLspAsynchronousLayerWrapper instances, as well as other ILcdGXYAsynchronousLayerWrapper implementations.

Program: Creating a paint queue manager for a view (from samples/gxy/concurrent/painting/lightspeed/MainPanel)
TLcdGXYLspAsynchronousPaintQueueManager manager = new TLcdGXYLspAsynchronousPaintQueueManager();

TLcdGXYLspAsynchronousPaintQueueManager extends from TLcdGXYAsynchronousPaintQueueManager and hence also takes its decisions based on paint hints. By default the manager uses a pre-configured paint hint provider. Please refer to Asynchronous painting in a GXY view for more information on customizing paint queue assignments.

Safely accessing asynchronously painted Lightspeed layers

The Lightspeed layer is rendered in a separate background thread. Hence, unless it is explicitly mentioned that this layer is thread-safe, precautions must be taken to safely access it. In general, the rules for accessing the wrapped ILspLayer are the same as for accessing a wrapped ILcdGXYLayer. In particular, it is recommended to access the Lightspeed layer only through one of the invocation methods in the TLcdGXYLspAsynchronousLayerWrapper: invokeAndWaitOnGXYAndLspLayer, invokeLaterOnGXYAndLspLayer, invokeLaterOnGXYAndLspLayerInEDT and invokeNowOnGXYAndLspLayer. See Asynchronous painting in a GXY view on asynchronous painting for more information on safely accessing the wrapped layer.

Deploying on a mix of hardware configurations

The hardware requirements for Lightspeed view technology are higher than those for GXY views, because Lightspeed technology takes advantage of modern GPU hardware. Nevertheless, even when your application is deployed on a mixed range of hardware configurations, which do not all support Lightspeed technology, you can still take advantage of Lightspeed layers.

TLcdGXYLspAsynchronousPaintQueue checks the OpenGL requirements of its Lightspeed layers. If the OpenGL requirements for a Lightspeed layer do not match those of the target platform, LuciadLightspeed will use the wrapped ILcdGXYLayer for all visualization, providing a convenient fallback. A warning message will be logged if this is the case.

For more information on hardware and software requirements, see the LuciadLightspeed technical notes.

Performance tips for wrapped Lightspeed layers

Just as with regular asynchronous layer wrappers, you can reduce the compositing overhead for multiple layers if you make them share the same paint queue. TLcdGXYLspAsynchronousPaintQueueManager, is configured to do exactly this, provided that the Lightspeed layer wrappers are adjacent. They have to be directly on top of one another without any non-adapter layer inserted between the two.

If you suspect that the Lightspeed layer is not being used at all, make sure that you are using the appropriate paint queue or paint queue manager, either TLcdGXYLspAsynchronousPaintQueue or TLcdGXYLspAsynchronousPaintQueueManager). Other implementations may ignore the Lightspeed layer.