C

Improving performance using hardware layers

Qt Quick Ultralite by default uses a single hardware layer for all the pixels that end up on the display. This may not be an optimal solution on hardware platforms that support layers. You could improve performance on such platforms using multiple framebuffers, letting the hardware blend them together to produce the final image.

Mutiple layers can be used to represent dynamic UI content rendered into framebuffers in CPU or GPU memory, or by static image data that never changes.

Hardware layers can be used by the Qt Quick Ultralite application to reduce memory footprint and CPU or GPU utilization, or to prevent skipped frames caused by expensive rendering operations.

Reducing memory footprint

Instead of using two full screen framebuffers to show a dynamically updated UI with a single background image covering the entire screen, an image layer could be used instead:

Screen {
    width: 800
    height: 480

    ImageLayer {
        anchors.fill: parent
        source: "background.png"
    }

    ItemLayer {
        anchors.fill: parent
        depth: ItemLayer.Bpp32Alpha

        // UI items here
    }
}

If the background image resides in flash, additional framebuffer memory is not required, reducing the CPU or GPU memory usage.

Using several item layers can also reduce memory usage by lowering bit depths or using smaller item layers instead of a single item layer. The later is used when there are significant gaps in the UI without any content.

Reducing rendering time

Some graphics might be expensive to render, such as images with perspective transform or effects applied. If possible, they could be placed in a separate item layer, with the refreshInterval property set to 2. This causes the contents of the layer to only be redrawn every second frame, saving CPU and GPU utilization and reducing the risk of the main UI not animating smoothly.

Screen {
    width: 800
    height: 480

    ItemLayer {
        anchors.fill: parent

        // Main UI items here
    }

    ItemLayer {
        anchors.centerIn: parent
        width: 400
        height: 240

        refreshInterval: 2

        // Expensive to render graphics here
    }
}

Using sprite layers

A lot of platforms only support a relatively small amount of root layers, possibly only up to four. If sprite hardware layer support is available, it's possible to use a sprite layer as a container for multiple smaller item or image layers.

There are however some limitations to using sprite layers which are mentioned in the SpriteLayer documentation.

See also Framebuffer Requirements.

Available under certain Qt licenses.
Find out more.