2D graphics accelerator class.
More...
2D graphics accelerator class.
A GPU is a struct pbl_gpu device that draws into pixel buffers owned by the caller: it fills rectangles and blits one buffer onto another, converting between formats, blending and, where the hardware can, rotating and scaling. What a GPU can do is in its pbl_gpu_caps. A job it cannot take is refused with -ENOTSUP before anything is drawn, for the caller to draw it in software, so the class can be used without knowing the hardware behind it.
.
data = pixels, .pitch = 390 * 2, .width = 390, .height = 450,
};
struct pbl_gpu_rect bar = {.
x = 0, .y = 400, .width = 390, .height = 50};
void * data
First pixel.
Definition gpu.h:86
int16_t x
Left column.
Definition gpu.h:100
const struct pbl_gpu_buffer * src
Source.
Definition gpu.h:126
A blit: a source drawn over what the target holds.
Definition gpu.h:124
A rectangle of a buffer.
Definition gpu.h:98
A pixel buffer.
Definition gpu.h:84
const struct pbl_gpu *const GPU
The GPU, defined by the board.
int pbl_gpu_fill(const struct pbl_gpu *gpu, const struct pbl_gpu_buffer *dst, const struct pbl_gpu_rect *rect, uint32_t argb)
Fill a rectangle with a color.
@ PBL_GPU_FORMAT_RGB565
16 bits per pixel: 5 of red, 6 of green and 5 of blue, from the most significant bit.
Definition gpu.h:48
Calls are made from task context, one job at a time, and return once the job is done, with the target ready to be read by the CPU: buffers may be cached. They return 0 or a negative errno: -ENOTSUP for a job the GPU cannot take, -EINVAL for an invalid one, -ENODEV if the GPU is not ready and -EIO or -ETIMEDOUT if the hardware failed.
◆ pbl_gpu_caps
| Data Fields |
|
uint32_t |
dst_formats |
Formats it draws into, a bit per pbl_gpu_format. |
|
uint32_t |
flags |
Capability flags. |
|
uint32_t |
src_formats |
Formats it blits from, a bit per pbl_gpu_format. |
◆ pbl_gpu_buffer
| Data Fields |
|
void * |
data |
First pixel. |
|
enum pbl_gpu_format |
format |
Format. |
|
uint16_t |
height |
Height, in pixels. |
|
uint32_t |
pitch |
Bytes from one row to the next. |
|
uint16_t |
width |
Width, in pixels. |
◆ pbl_gpu_rect
| Data Fields |
|
uint16_t |
height |
Height, in pixels. |
|
uint16_t |
width |
Width, in pixels. |
|
int16_t |
x |
Left column. |
|
int16_t |
y |
Top row. |
◆ pbl_gpu_transform
Rotation and scaling of a blit around a pivot, which stays where it is.
| Data Fields |
|
int16_t |
angle |
Clockwise rotation, in tenths of a degree. |
|
int16_t |
pivot_x |
Pivot column, from the first pixel of the source. |
|
int16_t |
pivot_y |
Pivot row, from the first pixel of the source. |
|
uint16_t |
scale_x |
Horizontal scale, PBL_GPU_SCALE_NONE for 1:1. |
|
uint16_t |
scale_y |
Vertical scale, PBL_GPU_SCALE_NONE for 1:1. |
◆ pbl_gpu_blit
A blit: a source drawn over what the target holds.
| Data Fields |
|
uint8_t |
alpha |
Alpha of the whole source, on top of its own: PBL_GPU_ALPHA_OPAQUE to leave it. |
|
uint32_t |
color |
Color of a PBL_GPU_FORMAT_A8 source, as 0x00RRGGBB. |
|
const struct pbl_gpu_buffer * |
src |
Source. |
|
const struct pbl_gpu_transform * |
transform |
Transform, or NULL. |
|
int16_t |
x |
Column of the target the first pixel of the source goes to, before any transform. |
|
int16_t |
y |
Row of the target the first pixel of the source goes to, before any transform. |
◆ pbl_gpu
| Data Fields |
|
struct pbl_gpu_caps |
caps |
Capabilities. |
|
struct pbl_device |
dev |
Device. |
|
const struct pbl_gpu_ops * |
ops |
Driver operations. |
|
struct pbl_gpu_state * |
state |
Runtime state. |
◆ PBL_GPU_ALPHA_OPAQUE
| #define PBL_GPU_ALPHA_OPAQUE 255U |
◆ PBL_GPU_INIT
| #define PBL_GPU_INIT |
( |
|
sym, |
|
|
|
_name, |
|
|
|
_ops, |
|
|
|
_deps, |
|
|
|
... |
|
) |
| |
Value: { \
.ops = (_ops), .state = &sym##_gpu_state, .caps = { \
__VA_ARGS__ \
} \
}
#define PBL_DEVICE_INIT_CLASS(sym, _name, _init, _parent, _deps, _cls)
Initializer for the struct pbl_device of device instance sym, in class _cls.
Definition device.h:145
const struct pbl_device_class pbl_gpu_class
Class of the GPUs.
int pbl_gpu_init(const struct pbl_device *dev)
Device init of every GPU: calls the driver's init.
Initializer for the struct pbl_gpu of GPU sym.
- Parameters
-
◆ PBL_GPU_SCALE_NONE
| #define PBL_GPU_SCALE_NONE 256U |
◆ PBL_GPU_STATE_DEFINE
| #define PBL_GPU_STATE_DEFINE |
( |
|
sym | ) |
|
Value:
#define PBL_DEVICE_STATE_DEFINE(sym)
Define the runtime state of device instance sym.
Definition device.h:131
#define PBL_MUTEX_INITIALIZER
Static initializer for an unlocked mutex.
Definition mutex.h:50
Define the class state of GPU sym, for the PBL_*_DEFINE() macro of a driver.
- Parameters
-
| sym | Symbol of the GPU instance. |
◆ anonymous enum
| anonymous enum : uint32_t |
Capability flags.
| Enumerator |
|---|
| PBL_GPU_CAP_ROTATE | Blits rotate by any angle.
|
| PBL_GPU_CAP_SCALE | Blits scale.
|
◆ pbl_gpu_format
Pixel formats.
Pixels wider than a byte are little-endian.
| Enumerator |
|---|
| PBL_GPU_FORMAT_RGB565 | 16 bits per pixel: 5 of red, 6 of green and 5 of blue, from the most significant bit.
|
| PBL_GPU_FORMAT_RGB888 | 24 bits per pixel: 8 of red, green and blue, from the most significant bit.
|
| PBL_GPU_FORMAT_ARGB8888 | 32 bits per pixel: 8 of alpha, red, green and blue, from the most significant bit.
|
| PBL_GPU_FORMAT_A8 | 8 bits per pixel, alpha only: the color comes from the blit.
|
| PBL_GPU_FORMAT_COUNT | Number of formats.
|
◆ pbl_gpu_blit()
Draw a buffer over another.
- Parameters
-
| gpu | GPU. |
| dst | Target. |
| clip | Rectangle of the target that may change, clipped to it, or NULL for all of it. |
| blit | Source, where it goes and how. |
- Returns
- 0 or a negative errno.
◆ pbl_gpu_fill()
Fill a rectangle with a color.
- Parameters
-
| gpu | GPU. |
| dst | Target. |
| rect | Rectangle, clipped to the target, or NULL for all of it. |
| argb | Color, as 0xAARRGGBB: blended over what the rectangle holds unless its alpha is PBL_GPU_ALPHA_OPAQUE. |
- Returns
- 0 or a negative errno.
◆ pbl_gpu_get_caps()
Get what a GPU can do.
- Parameters
-
- Returns
- Capabilities.
References pbl_gpu::caps.
◆ pbl_gpu_init()
Device init of every GPU: calls the driver's init.
- Parameters
-
- Returns
- 0 or a negative errno.
◆ GPU
The GPU, defined by the board.
◆ pbl_gpu_class