Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Fixed bug 3369 - RaspberryPI ability to specify a Dispmanx layer
Albert Casals
On a RaspberryPI, it might become convenient to specify the Dispmanx layer SDL uses.
Currently, it is hardcoded to be 10000 to sit above most applications.
This can be specially useful when integrating other graphical apps and frameworks like OMXplayer, QT5 etc.. in order to have more flexibility on their Z-order.
Loading branch information
@@ -699,6 +699,14 @@ extern "C" {
*/
#define SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING " SDL_WINDOWS_DISABLE_THREAD_NAMING"
/* *
* \brief Tell SDL which Dispmanx layer to use on a Raspberry PI
*
* Also known as Z-order. The variable can take a negative or positive value.
* The default is 10000.
*/
#define SDL_HINT_RPI_VIDEO_LAYER " SDL_RPI_VIDEO_LAYER"
/* *
* \brief An enumeration of hint priorities
*/
@@ -24,6 +24,7 @@
#include " SDL_assert.h"
#include " SDL_surface.h"
#include " SDL_hints.h"
#include " SDL_rpivideo.h"
#include " SDL_rpimouse.h"
@@ -117,7 +118,9 @@ RPI_ShowCursor(SDL_Cursor * cursor)
SDL_VideoDisplay *display;
SDL_DisplayData *data;
VC_DISPMANX_ALPHA_T alpha = { DISPMANX_FLAGS_ALPHA_FROM_SOURCE /* flags */ , 255 /* opacity 0->255*/ , 0 /* mask */ };
uint32_t layer = SDL_RPI_MOUSELAYER;
const char *env;
mouse = SDL_GetMouse ();
if (mouse == NULL ) {
return -1 ;
@@ -167,9 +170,14 @@ RPI_ShowCursor(SDL_Cursor * cursor)
update = vc_dispmanx_update_start (10 );
SDL_assert (update);
env = SDL_GetHint (SDL_HINT_RPI_VIDEO_LAYER);
if (env) {
layer = SDL_atoi (env) + 1 ;
}
curdata->element = vc_dispmanx_element_add (update,
data->dispman_display ,
SDL_RPI_MOUSELAYER, // layer
layer,
&dst_rect,
curdata->resource ,
&src_rect,
@@ -38,6 +38,7 @@
#include " SDL_events.h"
#include " ../../events/SDL_mouse_c.h"
#include " ../../events/SDL_keyboard_c.h"
#include " SDL_hints.h"
#ifdef SDL_INPUT_LINUXEV
#include " ../../core/linux/SDL_evdev.h"
@@ -221,6 +222,8 @@ RPI_CreateWindow(_THIS, SDL_Window * window)
VC_RECT_T src_rect;
VC_DISPMANX_ALPHA_T dispman_alpha;
DISPMANX_UPDATE_HANDLE_T dispman_update;
uint32_t layer = SDL_RPI_VIDEOLAYER;
const char *env;
/* Disable alpha, otherwise the app looks composed with whatever dispman is showing (X11, console,etc) */
dispman_alpha.flags = DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS;
@@ -253,11 +256,25 @@ RPI_CreateWindow(_THIS, SDL_Window * window)
src_rect.width = window->w << 16 ;
src_rect.height = window->h << 16 ;
env = SDL_GetHint (SDL_HINT_RPI_VIDEO_LAYER);
if (env) {
layer = SDL_atoi (env);
}
dispman_update = vc_dispmanx_update_start ( 0 );
wdata->dispman_window .element = vc_dispmanx_element_add ( dispman_update, displaydata->dispman_display , SDL_RPI_VIDEOLAYER /* layer */ , &dst_rect, 0 /* src*/ , &src_rect, DISPMANX_PROTECTION_NONE, &dispman_alpha /* alpha*/ , 0 /* clamp*/ , 0 /* transform*/ );
wdata->dispman_window .element = vc_dispmanx_element_add (dispman_update,
displaydata->dispman_display ,
layer /* layer */ ,
&dst_rect,
0 /* src*/ ,
&src_rect,
DISPMANX_PROTECTION_NONE,
&dispman_alpha /* alpha*/ ,
0 /* clamp*/ ,
0 /* transform*/ );
wdata->dispman_window .width = window->w ;
wdata->dispman_window .height = window->h ;
vc_dispmanx_update_submit_sync ( dispman_update );
vc_dispmanx_update_submit_sync (dispman_update);
if (!_this->egl_data ) {
if (SDL_GL_LoadLibrary (NULL ) < 0 ) {
Toggle all file notes
Toggle all file annotations