Commit 6d0ca58b authored by Stefan Haun's avatar Stefan Haun
Browse files

Adapt display driver and API for virtual fb handling

* epic_disp_overlay() function to select overlay
parent c16ed399
......@@ -55,6 +55,7 @@ typedef _Bool bool;
#define API_DISP_FRAMEBUFFER 0x29
#define API_DISP_BACKLIGHT 0x2a
#define API_DISP_PRINT_ADV 0x2b
#define API_DISP_OVERLAY 0x2c
/* API_BATTERY_VOLTAGE 0x30 */
#define API_BATTERY_CURRENT 0x31
......@@ -1306,6 +1307,15 @@ union disp_framebuffer {
*/
API(API_DISP_OPEN, int epic_disp_open());
/**
* Switch framebuffer to overlay.
*
* :return: ``0`` on success or a negative value in case of an error:
*
* - ``-EBUSY``: Display was already locked from another task.
*/
API(API_DISP_OVERLAY, int epic_disp_overlay());
/**
* Unlocks the display again.
*
......
......@@ -11,6 +11,8 @@
static TaskHandle_t lock = NULL;
static struct gfx_region *current_fb = &application_screen;
static int check_lock()
{
TaskHandle_t task = xTaskGetCurrentTaskHandle();
......@@ -71,7 +73,7 @@ int epic_disp_clear(uint16_t color)
if (cl < 0) {
return cl;
} else {
gfx_clear_to_color(&display_screen, color);
gfx_clear_to_color(current_fb, color);
return 0;
}
}
......@@ -82,7 +84,7 @@ int epic_disp_pixel(int16_t x, int16_t y, uint16_t color)
if (cl < 0) {
return cl;
} else {
gfx_setpixel(&display_screen, x, y, color);
gfx_setpixel(current_fb, x, y, color);
return 0;
}
}
......@@ -102,7 +104,7 @@ int epic_disp_line(
} else {
/* TODO add linestyle support to gfx code */
gfx_line(
&display_screen,
current_fb,
xstart,
ystart,
xend,
......@@ -130,7 +132,7 @@ int epic_disp_rect(
switch (fillstyle) {
case FILLSTYLE_EMPTY:
gfx_rectangle(
&display_screen,
current_fb,
xstart,
ystart,
xend - xstart,
......@@ -141,7 +143,7 @@ int epic_disp_rect(
break;
case FILLSTYLE_FILLED:
gfx_rectangle_fill(
&display_screen,
current_fb,
xstart,
ystart,
xend - xstart,
......@@ -167,16 +169,37 @@ int epic_disp_circ(
switch (fillstyle) {
case FILLSTYLE_EMPTY:
gfx_circle(&display_screen, x, y, rad, pixelsize, color);
gfx_circle(current_fb, x, y, rad, pixelsize, color);
break;
case FILLSTYLE_FILLED:
gfx_circle_fill(&display_screen, x, y, rad, color);
gfx_circle_fill(current_fb, x, y, rad, color);
break;
}
return 0;
}
void compositor()
{
for (int y = 0; y < display_screen.height; y++) {
for (int x = 0; x < display_screen.width; x++) {
uint8_t *overlay_pixel =
fb_pixel(overlay_screen.fb, x, y);
uint8_t *target = fb_pixel(display_screen.fb, x, y);
if ((overlay_pixel[0] == 0) && (overlay_pixel[1] == 0)) {
uint8_t *app_pixel =
fb_pixel(application_screen.fb, x, y);
target[0] = app_pixel[0];
target[1] = app_pixel[1];
} else {
target[0] = overlay_pixel[0];
target[1] = overlay_pixel[1];
}
}
}
}
int epic_disp_update()
{
int cl = check_lock();
......@@ -184,6 +207,7 @@ int epic_disp_update()
return cl;
}
compositor();
gfx_update(&display_screen);
return 0;
}
......@@ -210,15 +234,29 @@ int epic_disp_open()
{
TaskHandle_t task = xTaskGetCurrentTaskHandle();
if (lock == task) {
current_fb = &application_screen;
return 0;
} else if (lock == NULL) {
lock = task;
return 0;
lock = task;
current_fb = &application_screen;
return 0;
} else {
return -EBUSY;
}
}
int epic_disp_overlay()
{
int cl = check_lock();
if (cl < 0) {
return cl;
}
current_fb = &overlay_screen;
return 0;
}
int epic_disp_close()
{
if (check_lock() < 0 && lock != NULL) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment