gfx/gfx.h header reference
[Lightweight 2d graphic module]
The source code of this header can be browsed online.
Members
Types
- typedef [...] gfx_addr_t
- enum gfx_direction_e
- typedef [...] gfx_pixel_t
- typedef [...] gfx_pos_t
- enum gfx_surface_compress
- enum gfx_surface_format
- struct gfx_surface_s
- struct gfx_tilemap_s
- struct gfx_fmt_desc_s
Functions
- _GFX_BPP_EXPAND(_GFX_BPP_L2PPW )
- bool_t gfx_box_check(const struct gfx_surface_s *s, gfx_pos_t x0, gfx_pos_t y0, gfx_pos_t x1, gfx_pos_t y1)
- bool_t gfx_box_safe(const struct gfx_surface_s *s, gfx_pos_t *x0, gfx_pos_t *y0, gfx_pos_t *x1, gfx_pos_t *y1)
- bool_t gfx_draw_tile(const struct gfx_surface_s *s, const struct gfx_tilemap_s *t, uint_fast16_t tile, gfx_pos_t x, gfx_pos_t y, bool_t center)
- void gfx_draw_tile_string(const struct gfx_surface_s *s, const struct gfx_tilemap_s *t, const uint8_t *str, uint_fast16_t size, gfx_pos_t x, gfx_pos_t y, enum gfx_direction_e dir, bool_t center)
- gfx_pos_t gfx_height(const struct gfx_surface_s *s)
- gfx_word_t * gfx_surface_data(const struct gfx_surface_s *s)
- void gfx_surface_dummy(struct gfx_surface_s *s)
- error_t gfx_surface_init(struct gfx_surface_s *s, gfx_word_t *data, size_t bytes, gfx_pos_t w, gfx_pos_t h, enum gfx_surface_format fmt)
- error_t gfx_surface_storage(size_t *bytes, size_t *row_bytes, gfx_pos_t w, gfx_pos_t h, enum gfx_surface_format fmt)
- error_t gfx_tilemap_init(struct gfx_tilemap_s *t, const struct gfx_surface_s *s, gfx_pos_t tw, gfx_pos_t th, uint_fast8_t first)
- gfx_pos_t gfx_width(const struct gfx_surface_s *s)
- bool_t gfx_xcheck(const struct gfx_surface_s *s, gfx_pos_t x)
- gfx_pos_t gfx_xmod(const struct gfx_surface_s *s, gfx_pos_t x)
- gfx_addr_t gfx_yaddr(const struct gfx_surface_s *s, gfx_pos_t y)
- bool_t gfx_ycheck(const struct gfx_surface_s *s, gfx_pos_t y)
- gfx_pos_t gfx_ymod(const struct gfx_surface_s *s, gfx_pos_t y)
- gfx_addr_t gfx_xymod(const struct gfx_surface_s *s, gfx_addr_t a)
Constant
- const struct gfx_fmt_desc_s gfx_fmt_desc[16]
Members detail
This macro is declared in gfx/gfx.h source file, line 338.
Preprocessor condition: defined( CONFIG_GFX_BPP0 )
This macro is declared in gfx/gfx.h source file, line 342.
Preprocessor condition: not defined( CONFIG_GFX_BPP0 ) and not ( CONFIG_GFX_DEFAULT_L2BPP == 0 )
This macro is declared in gfx/gfx.h source file, line 346.
Preprocessor condition: defined( CONFIG_GFX_BPP1 )
This macro is declared in gfx/gfx.h source file, line 350.
Preprocessor condition: not defined( CONFIG_GFX_BPP1 ) and not ( CONFIG_GFX_DEFAULT_L2BPP == 1 )
This macro is declared in gfx/gfx.h source file, line 354.
Preprocessor condition: defined( CONFIG_GFX_BPP2 )
This macro is declared in gfx/gfx.h source file, line 358.
Preprocessor condition: not defined( CONFIG_GFX_BPP2 ) and not ( CONFIG_GFX_DEFAULT_L2BPP == 2 )
This macro is declared in gfx/gfx.h source file, line 362.
Preprocessor condition: defined( CONFIG_GFX_BPP3 )
This macro is declared in gfx/gfx.h source file, line 366.
Preprocessor condition: not defined( CONFIG_GFX_BPP3 ) and not ( CONFIG_GFX_DEFAULT_L2BPP == 3 )
This macro is declared in gfx/gfx.h source file, line 370.
Preprocessor condition: defined( CONFIG_GFX_BPP4 )
This macro is declared in gfx/gfx.h source file, line 374.
Preprocessor condition: not defined( CONFIG_GFX_BPP4 ) and not ( CONFIG_GFX_DEFAULT_L2BPP == 4 )
This macro is declared in gfx/gfx.h source file, line 378.
Preprocessor condition: defined( CONFIG_GFX_BPP5 )
This macro is declared in gfx/gfx.h source file, line 382.
Preprocessor condition: not defined( CONFIG_GFX_BPP5 ) and not ( CONFIG_GFX_DEFAULT_L2BPP == 5 )
typedef uint32_t gfx_addr_t
This typedef is declared in gfx/gfx.h source file, line 87.
An integer type large enough to address a word in the data storage of a surface.
bool_t gfx_box_check(const struct gfx_surface_s *s, gfx_pos_t x0, gfx_pos_t y0, gfx_pos_t x1, gfx_pos_t y1)
This function is declared in gfx/gfx.h source file, line 304.
This function returns false if the box falls outside the surface
bool_t gfx_box_safe(const struct gfx_surface_s *s, gfx_pos_t *x0, gfx_pos_t *y0, gfx_pos_t *x1, gfx_pos_t *y1)
This function is declared in gfx/gfx.h source file, line 318.
This function prevents coordinates from falling outside a surface either by mangling the values or returns an error.
This enum is declared in gfx/gfx.h source file, line 114.
This enum specifies directions.
Identifier | Description |
---|---|
GFX_DIR_LEFT | |
GFX_DIR_RIGHT | |
GFX_DIR_UP | |
GFX_DIR_DOWN |
bool_t gfx_draw_tile(const struct gfx_surface_s *s, const struct gfx_tilemap_s *t, uint_fast16_t tile, gfx_pos_t x, gfx_pos_t y, bool_t center)
This function draws a single tile from a tilemap on a surface.
void gfx_draw_tile_string(const struct gfx_surface_s *s, const struct gfx_tilemap_s *t, const uint8_t *str, uint_fast16_t size, gfx_pos_t x, gfx_pos_t y, enum gfx_direction_e dir, bool_t center)
This function draws multiple tiles from a tilemap on a surface. Tiles index are taken from a string.
gfx_pos_t gfx_height(const struct gfx_surface_s *s)
This function is declared in gfx/gfx.h source file, line 214.
This function returns the height of a surface in pixels.
typedef uint32_t gfx_pixel_t
This typedef is declared in gfx/gfx.h source file, line 83.
An integer type large enough to hold a pixel value in any format.
typedef int32_t gfx_pos_t
This typedef is declared in gfx/gfx.h source file, line 85.
An signed integer type large enough to hold a pixel coordinate.
This enum is declared in gfx/gfx.h source file, line 106.
This enum specifies the various implemented surface compression formats
Identifier | Description |
---|---|
GFX_CMP_NONE | |
GFX_CMP_RLE | |
GFX_CMP_LZO |
gfx_word_t * gfx_surface_data(const struct gfx_surface_s *s)
This function is declared in gfx/gfx.h source file, line 492.
This function returns a pointer to the surface storage.
void gfx_surface_dummy(struct gfx_surface_s *s)
This function initializes a surface with a dummy single pixel storage.
This enum is declared in gfx/gfx.h source file, line 93.
This enum specifies the various implemented pixel formats
Identifier | Description |
---|---|
GFX_FMT_DEFAULT | see CONFIG_GFX_DEFAULT_L2BPP |
GFX_FMT_1BIT | |
GFX_FMT_2BIT | |
GFX_FMT_4BIT | |
GFX_FMT_8BIT | |
GFX_FMT_16BIT | |
GFX_FMT_32BIT |
error_t gfx_surface_init(struct gfx_surface_s *s, gfx_word_t *data, size_t bytes, gfx_pos_t w, gfx_pos_t h, enum gfx_surface_format fmt)
This function initializes a surface with specified log2 width, log2 height and format. The surface data is located at data + offset and is checked to be within data + size.
This struct is declared in gfx/gfx.h source file, line 135.
This struct is a surface descriptor.
A surface object has an associated user provided buffer used to store the image data. The actual data format depends on the pixel format and library configuration.
The image data is stored as an array of gfx_word_t. Native endianess is used. The word width used is defined by the CONFIG_GFX_LOG2_WORD_WIDTH token.
See also gfx_surface_init.
Field | Description |
---|---|
void * ptr; | pointer to surface data |
gfx_addr_t mask; | ptr index mask |
uint8_t l2bw; | log2 of row size in words |
uint8_t l2w; | log2 of width in pixels |
uint8_t l2h; | log2 of height in pixels |
gfx_addr_t bsize; | size in words |
uint16_t bw; | row size in words |
uint16_t w; | width in pixels |
uint16_t h; | height in pixels |
enum gfx_surface_format fmt; | pixel format |
error_t gfx_surface_storage(size_t *bytes, size_t *row_bytes, gfx_pos_t w, gfx_pos_t h, enum gfx_surface_format fmt)
This function computes the size in bytes needed to store the surface data.
error_t gfx_tilemap_init(struct gfx_tilemap_s *t, const struct gfx_surface_s *s, gfx_pos_t tw, gfx_pos_t th, uint_fast8_t first)
This function initializes a tilemap object from a surface containing the tile set. You need to specifies the resolution of a single tile.
The number of tiles on a single row of the tile set image is the largest power of 2 that fits. They may be padding on the right if you have some surface resolution constraints.
Example: You have configured the library to only support surfaces with power of two resolution. You have a tile set image with a resolution of 256x128 pixels and the resolution of a single tile is 14x24. You then need to design your tile set image with 16 tiles per row and 32 pixels of padding at the end of each row.
This struct is declared in gfx/gfx.h source file, line 169.
This struct contains a struct gfx_surface_s object along with information about the set of tiles it contains. This allows extracting a single tile for drawing on an other surface.
This is typically used to implement bitmap fonts.
gfx_pos_t gfx_width(const struct gfx_surface_s *s)
This function is declared in gfx/gfx.h source file, line 240.
This function returns the width of a surface in pixels.
bool_t gfx_xcheck(const struct gfx_surface_s *s, gfx_pos_t x)
This function is declared in gfx/gfx.h source file, line 267.
This function returns false if the x coordinate falls outside the surface
gfx_pos_t gfx_xmod(const struct gfx_surface_s *s, gfx_pos_t x)
This function is declared in gfx/gfx.h source file, line 255.
This function performs a modulus on the x coordinate in a surface.
gfx_addr_t gfx_yaddr(const struct gfx_surface_s *s, gfx_pos_t y)
This function is declared in gfx/gfx.h source file, line 203.
This function returns the address of the row of pixels at position y in a surface.
bool_t gfx_ycheck(const struct gfx_surface_s *s, gfx_pos_t y)
This function is declared in gfx/gfx.h source file, line 279.
This function returns false if the y coordinate falls outside the surface
gfx_pos_t gfx_ymod(const struct gfx_surface_s *s, gfx_pos_t y)
This function is declared in gfx/gfx.h source file, line 229.
This function performs a modulus on the y coordinate in a surface.
const struct gfx_fmt_desc_s gfx_fmt_desc[16]
This variable is declared in gfx/gfx.h source file, line 542.
This variable contains properties all supported pixel formats.
This variable is for internal use only.
This struct is declared in gfx/gfx.h source file, line 464.
This struct contains properties of a pixel format.
This struct is for internal use only.