Swap video layer(Rockchip Linux)
date_range 04/06/2017 infosortEmbedded and Linux
By default, Video layer is on top of GUI layer, which means you can’t put GUI items on top of video.
To allow video work with GUI, there are two ways.
Use Wayland dma-buf api
If there is something cover the video layer, wayland compositor will use GPU to composite. The advantage is that it’s a standard and the api is clean. The disadvantage is that wayland have many compatibility problem(e.g QT) and the using of GPU will reduce performance.
Change video layer to the bottom
In this way, we could make the place we want to show video transparent, so the bottom layer would show up. The advantage is that it has the best performance. The disadvantage is that it’s kind of hacky.
In below, i will introduce how to enable the second way on different display server.
First, you need apply the below kernel patches.
The Kernel Patch for swap layer:
kernel patch 1
The Kernel Patch for dsiable double vsync with drm api:
kernel patch 2
“we could make the place we want to show video transparent”
To make qt background transparent, we need this patches to change the default color format to ARGB.
qt patch 1
Then set the alpha value of the window you want to show video to zero, VOP will skip them when do alpha blending.
Before starting application, please set below env value to force qt use kmssink to show video on bottom.
Please use qmlvideo
On X11 and Wayland backend, we can’t make GUI layer transparent by alpha becuase of the exists of desktop background. If you set window backgournd color to transparent, it would show background rather than video lyaer, so we can only use color key.
To set color key, it need some changes in kernel driver.
it will make black color a transparency color key.
Before starting application, please set below env value to force qt use rkximagesink to show video on bottom.
Somtimes we need a 1080P UI with the video layer in 4K resolution for smooth, then we might need this patch.
The Kernel Patch for 1080P UI + 4K video layer :
kernel patch 3
The Qt patch for 1080 UI:
kernel patch 4