GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
Data Structures | Enumerations | Functions
gp_backend.h File Reference

An abstraction for display, keyboard and mouse. More...

#include <core/gp_types.h>
#include <utils/gp_timer.h>
#include <utils/gp_list.h>
#include <utils/gp_poll.h>
#include <input/gp_ev_queue.h>
#include <input/gp_task.h>
#include <backends/gp_types.h>

Go to the source code of this file.

Data Structures

struct  gp_backend
 A backend. More...
 

Enumerations

enum  gp_backend_cursors {
  GP_BACKEND_CURSOR_ARROW , GP_BACKEND_CURSOR_TEXT_EDIT , GP_BACKEND_CURSOR_CROSSHAIR , GP_BACKEND_CURSOR_HAND ,
  GP_BACKEND_CURSOR_MAX , GP_BACKEND_CURSOR_SHOW = 0xc000 , GP_BACKEND_CURSOR_HIDE = 0x8000
}
 Cursor types. More...
 

Functions

static void gp_backend_flip (gp_backend *self)
 Copies whole backend pixmap to a display.
 
void gp_backend_update_rect_xyxy (gp_backend *self, gp_coord x0, gp_coord y0, gp_coord x1, gp_coord y1)
 Copies a rectangle from backend pixmap to a display.
 
static void gp_backend_update_rect (gp_backend *self, gp_coord x0, gp_coord y0, gp_coord x1, gp_coord y1)
 Copies a rectangle from backend pixmap to a display.
 
static void gp_backend_update_rect_xywh (gp_backend *self, gp_coord x, gp_coord y, gp_size w, gp_size h)
 Copies a rectangle from backend pixmap to a display.
 
void gp_backend_exit (gp_backend *self)
 Exits the backend.
 
int gp_backend_resize_ack (gp_backend *self)
 Resize acknowledge.
 
void gp_backend_task_ins (gp_backend *self, gp_task *task)
 Inserts a task into the task queue.
 
void gp_backend_task_rem (gp_backend *self, gp_task *task)
 Removes a task from the task queue.
 
void gp_backend_task_queue_set (gp_backend *self, gp_task_queue *task_queue)
 Sets the backend task_queue and starts task processing.
 

Detailed Description

An abstraction for display, keyboard and mouse.

The gp_backend is unified API for managing xserver, framebuffer, waylaynd, drm, e-ink display, etc. along with support for input devices, e.g. mouse, keyboard and keymaps.

In contrast to other graphics libraries we do not try to create unified initalization interface that would match specialities for every possible backend. Rather than that we are trying to create API that is the same for all backends, once initalization is done.

Definition in file gp_backend.h.

Enumeration Type Documentation

◆ gp_backend_cursors

Cursor types.

Enumerator
GP_BACKEND_CURSOR_ARROW 

Arrow default cursor type.

GP_BACKEND_CURSOR_TEXT_EDIT 

Text edit cursor.

GP_BACKEND_CURSOR_CROSSHAIR 

Crosshair.

GP_BACKEND_CURSOR_HAND 

Used typicaly while howering over links.

GP_BACKEND_CURSOR_MAX 

Last cursor + 1.

GP_BACKEND_CURSOR_SHOW 

Shows cursor.

GP_BACKEND_CURSOR_HIDE 

Hides cursor.

Definition at line 49 of file gp_backend.h.

Function Documentation

◆ gp_backend_exit()

void gp_backend_exit ( gp_backend self)

Exits the backend.

This functions deinitializes the backend. E.g. closes all file descriptors, frees memory, etc. It's important to call this before the application exits since some backends, e.g. framebuffer, cannot be recovered unless we return the underlying facility to the original state.

Parameters
selfA backend.

◆ gp_backend_flip()

static void gp_backend_flip ( gp_backend self)
inlinestatic

Copies whole backend pixmap to a display.

Majority of the backends are double buffered, that means that changes done to gp_backend::pixmap are not propagated to the display memory buffer unless they are copied explicitly. This call copies the complete backend pixmap to the display.

Parameters
selfA backend.

Definition at line 208 of file gp_backend.h.

References gp_backend::flip.

◆ gp_backend_resize_ack()

int gp_backend_resize_ack ( gp_backend self)

Resize acknowledge.

You must call this right after you application has received resize event. For a multithreaded application all threads that operate on the backend pixmap must be stopped first.

After this call returns the backend pixmap has been resized, that means that at least the width, height, and pixels of gp_backend::pixmap are different and the content of the gp_pixmap::pixels is undefined.

This call also resizes the windo/display/screen size in the gp_ev_queue.

If the function fails the best action to take is to save application data and exit as the backend may be in undefined state.

Parameters
selfA backend.
Returns
Zero on success, non-zero otherwise.

◆ gp_backend_task_ins()

void gp_backend_task_ins ( gp_backend self,
gp_task task 
)

Inserts a task into the task queue.

Tasks are executed sequentionally and input processing is blocked during task execution.

Parameters
selfA backend.
taskA task to be inserted into the task queue.

◆ gp_backend_task_queue_set()

void gp_backend_task_queue_set ( gp_backend self,
gp_task_queue task_queue 
)

Sets the backend task_queue and starts task processing.

By default backends does not have a task queue populated. Applications that require a task queue have to allocate and initialize the queue then pass it to the backend with this function.

Parameters
selfA backend.
task_queueA pointer to initialized task_queue.

◆ gp_backend_task_rem()

void gp_backend_task_rem ( gp_backend self,
gp_task task 
)

Removes a task from the task queue.

Parameters
selfA backend.
taskA task to be removed from the task queue.

◆ gp_backend_update_rect()

static void gp_backend_update_rect ( gp_backend self,
gp_coord  x0,
gp_coord  y0,
gp_coord  x1,
gp_coord  y1 
)
inlinestatic

Copies a rectangle from backend pixmap to a display.

This is an alias for gp_backend_update_rect_xyxy().

Parameters
selfA backend.
x0First x coordinate of the rectangle.
y0First y coordinate of the rectangle.
x1Last x coordinate of the rectangle.
y1Last y coordinate of the rectangle.

Definition at line 243 of file gp_backend.h.

References gp_backend_update_rect_xyxy().

◆ gp_backend_update_rect_xywh()

static void gp_backend_update_rect_xywh ( gp_backend self,
gp_coord  x,
gp_coord  y,
gp_size  w,
gp_size  h 
)
inlinestatic

Copies a rectangle from backend pixmap to a display.

This is a version of gp_backend_update_rect_xyxy() with width and height.

Parameters
selfA backend.
xLeft x coordinate of the rectangle.
yTop y coordinate of the rectangle.
wRectangle width.
hRectangle height.

Definition at line 261 of file gp_backend.h.

References gp_backend_update_rect_xyxy().

◆ gp_backend_update_rect_xyxy()

void gp_backend_update_rect_xyxy ( gp_backend self,
gp_coord  x0,
gp_coord  y0,
gp_coord  x1,
gp_coord  y1 
)

Copies a rectangle from backend pixmap to a display.

Majority of the backends are double buffered, that means that changes done to gp_backend::pixmap are not propagated to the display memory buffer unless they are copied explicitly. This call copies a rectanlge from backend pixmap to the display.

Parameters
selfA backend.
x0First x coordinate of the rectangle.
y0First y coordinate of the rectangle.
x1Last x coordinate of the rectangle.
y1Last y coordinate of the rectangle.

Referenced by gp_backend_update_rect(), and gp_backend_update_rect_xywh().