rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
gfx_damage.c File Reference

Damage: the part of one frame buffer the rasteriser wrote, as 16-row bands. See include/gfx_damage.h. More...

#include "gfx_damage.h"
#include <stddef.h>

Functions

void gfx_damage_init (gfx_damage_t *d, const gfx_canvas_t *root)
 Bind d to the buffer under root, empty.
void gfx_damage_reset (gfx_damage_t *d)
 Forget what d holds: nothing written.
void gfx_damage_all (gfx_damage_t *d)
 Count the whole buffer as written.
static bool place (gfx_damage_t *d, const gfx_canvas_t *c, int *x, int *y)
 Where c's top-left pixel lies in d's buffer.
void gfx_damage_mark (gfx_damage_t *d, const gfx_canvas_t *c, int x, int y, int w, int h)
 Count a rectangle written through c as written.
bool gfx_damage_empty (const gfx_damage_t *d)
 Whether d holds no write.
static long area (gfx_rect_t r)
 A rectangle's area, pixels.
static gfx_rect_t bound (gfx_rect_t a, gfx_rect_t b)
 The smallest rectangle round a and b.
int gfx_damage_rects (const gfx_damage_t *d, gfx_rect_t *out, int max)
 The written area as at most max rectangles, top to bottom.
gfx_rect_t gfx_damage_turn (gfx_rect_t r, int width, int height)
 Where r lies in a width x height buffer turned by 180°.
void gfx_damage_attach (gfx_damage_t *d)
 Report the primitives' writes to d, or to nothing.

Variables

gfx_damage_t * gfx_damage_sink
 The record the primitives report to, or NULL; gfx_damage.c.

Detailed Description

Damage: the part of one frame buffer the rasteriser wrote, as 16-row bands. See include/gfx_damage.h.

SPDX-License-Identifier: MIT

Function Documentation

◆ gfx_damage_all()

void gfx_damage_all ( gfx_damage_t * d)

Count the whole buffer as written.

Parameters
dthe record

◆ gfx_damage_attach()

void gfx_damage_attach ( gfx_damage_t * d)

Report the primitives' writes to d, or to nothing.

Parameters
dthe record, or NULL to stop counting

◆ gfx_damage_empty()

bool gfx_damage_empty ( const gfx_damage_t * d)

Whether d holds no write.

Parameters
dthe record
Returns
true when nothing was written since the last reset

◆ gfx_damage_init()

void gfx_damage_init ( gfx_damage_t * d,
const gfx_canvas_t * root )

Bind d to the buffer under root, empty.

Parameters
dthe record
roota canvas whose pixels are the buffer's first pixel and whose width, height and stride are the buffer's

◆ gfx_damage_mark()

void gfx_damage_mark ( gfx_damage_t * d,
const gfx_canvas_t * c,
int x,
int y,
int w,
int h )

Count a rectangle written through c as written.

Nothing when c's pixels lie outside d's buffer. A canvas inside it with another stride counts the whole buffer.

Parameters
dthe record
cthe canvas written through
xthe rectangle's left edge, in c's coordinates
yits top edge
wits width, already clipped to c
hits height, already clipped

◆ gfx_damage_rects()

int gfx_damage_rects ( const gfx_damage_t * d,
gfx_rect_t * out,
int max )

The written area as at most max rectangles, top to bottom.

Each band's span is one rectangle; neighbouring bands then merge, the pair that adds the fewest unwritten pixels first, while a merge adds none or more than max are left. Every written pixel lies in one of the rectangles; a rectangle may hold unwritten pixels.

Parameters
dthe record
outthe rectangles, in buffer coordinates
maxroom in out, 1 or more
Returns
the rectangles written to out, 0 when nothing was written

◆ gfx_damage_reset()

void gfx_damage_reset ( gfx_damage_t * d)

Forget what d holds: nothing written.

Parameters
dthe record

◆ gfx_damage_turn()

gfx_rect_t gfx_damage_turn ( gfx_rect_t r,
int width,
int height )

Where r lies in a width x height buffer turned by 180°.

Parameters
ra rectangle inside the buffer
widththe buffer's width, pixels
heightits height, rows
Returns
the turned rectangle, of the same size

◆ place()

bool place ( gfx_damage_t * d,
const gfx_canvas_t * c,
int * x,
int * y )
static

Where c's top-left pixel lies in d's buffer.

Parameters
dthe record
cthe canvas
xits left edge in the buffer, set when it lies inside
yits top edge, set when it lies inside
Returns
true when c's pixels lie inside the buffer with its stride