Understanding Composition

This chapter discusses the technical details of composition. It covers:

There are two types of composition: composition at the hardware level using a display controller's layers and composition into a frame-buffer. Hardware-level composition can composite one buffer per layer, where a buffer is a window's buffer or a composited frame-buffer. Composited frame-buffers on the other hand, consist of multiple elements that are combined into a single frame-buffer that is then displayed.

A buffer belonging to a window that is displayed directly on a layer is said to be autonomous, since Composition Manager does not need to composite the window's buffers into a composited frame-buffer. For a window to run autonomously on a layer, the window's buffer format must be supported by the layer it's trying to be displayed on.

Hardware-level composition capabilities are controlled by a layer's capabilities, which tend to vary from platform to platform. The Composition Manager uses three forms of transparency for layers. Each form determines how buffers on layers can be composited.

The three forms of transparency are:

destination view port
Destination view ports have an implicit transparency in that anything outside the view-port is transparent, allowing any content on layers below to be displayed.
source chroma
Source chroma allows for pixels of a particular color to be interpreted as transparent. Unlike a destination view-port, chroma allows for transparent pixels within the buffer.
source alpha blending
Source alpha allows for pixel blending based on the alpha channel of the pixel. Source alpha is the most powerful form of transparency, since it allows for both semi-transparent or completely transparent pixels like chroma.

Many of these capabilities can be achieved when compositing windows into a frame-buffer. Using the same set of window properties, Composition Manager can provide the same capabilities for windows regardless of whether they are composited or running autonomously. However, when a window is composited, the contents of a window's buffer must be copied to the frame-buffer, which can negatively impact performance. If a platform does not have enough layers to composite the number of elements desired, or a layer does not support a particular behavior, it can still be done with composition regardless of the hardware's capabilities.

Composition can also provide additional flexibility. When using composition it's possible to create windows with a buffer format which is not supported by a layer, since composition can convert the format when it copies the window buffer. It's also possible to display a software cursor, or draw a background. Most importantly, it can combine multiple windows in a single buffer which means a platform only requires one layer.

Both solutions have multiple advantages and disadvantages, some of which are very subtle, sometimes depending on the rate at which window's contents are updated. In general, using hardware-level composition provides the best performance. However, depending on the frequency and size of updates to windows, composition can sometime display the same as layer, while using less bandwidth.

Here's a quick list of advantages and disadvantages for both hardware-level composition compared to composited frame-buffers:

Hardware level composition

Advantages:
Disadvantages:

Composited frame-buffer

Advantages:
Disadvantages:

Layers, WFD pipelines and EGL levels

Now that you have an understanding of how composition works, it's important to know how the OpenKODE/EGL APIs map to layers. Composition Manager implements a subset of the OpenWFD specification which is another Khronos Group API for communicating with display controllers. Composition Manager uses WFD to interact with display controllers. Layers are exposed as wfd-pipelines, the only difference is that layers are indexed starting at 0, where as wfd-pipelines begin at 1 (e.g. layer 0 is wfd-pipelines 1). Some WFD-related functionality is configurable via configuration files such winmgr.conf or graphics.conf. Layer/Pipeline properties such as chroma and source alpha blending are examples of configurable properties. For applications, the layer on which the window will be displayed on, is determined by the EGL level attribute of a window's egl configuration. The EGL level is an index to the layer, which is also indexed starting at 0 (e.g. layer 0 is egl level 0 which is wfd-pipelines level 1).

Composition Modules

Composition Manager currently has three composition modules. The first, is the WFD module, which allows for hardware level composition as described in the previous section. The second, is a GF composition module which takes advantage of any GF acceleration on a platform. The third module is a GLES2 composition module, which can take advantage of any GPU that supports open GL ES 2.0 to do composition.

Cursors

In the current version of Composition Manager, there are various ways to configure a cursor. For example, you can configure a software cursor which must be on a plane which is then composited. Another possible way to get a cursor is by placing a hardware cursor on a plane which has access to a wfd-pipeline. Keep in mind however, that access to the pipeline cannot be shared. Lastly, you can configure WFD to use the GF hardware cursor on the platform. This is done by configuring WFD to use the GF cursor as an additional pipeline. This gives Composition Manager access to an additional pipeline for use as a cursor.