gfx/gfx.h header reference
[Lightweight 2d graphic module]

The source code of this header can be browsed online.

Members  

Types  

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  

Members detail  

_GFX_BPP_EXPAND(_GFX_BPP_L2PPW )  

Alternate declarations with same identifier: [1], [2], [3], [4], [5], [6], [7].

#define GFX_ASSERT(...)  

This macro is declared in gfx/gfx.h source file, line 75.

#define _GFX_BPP0(...)  

This macro is declared in gfx/gfx.h source file, line 338.

Preprocessor condition: defined( CONFIG_GFX_BPP0 )

#define _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 )

#define _GFX_BPP1(...)  

This macro is declared in gfx/gfx.h source file, line 346.

Preprocessor condition: defined( CONFIG_GFX_BPP1 )

#define _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 )

#define _GFX_BPP2(...)  

This macro is declared in gfx/gfx.h source file, line 354.

Preprocessor condition: defined( CONFIG_GFX_BPP2 )

#define _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 )

#define _GFX_BPP3(...)  

This macro is declared in gfx/gfx.h source file, line 362.

Preprocessor condition: defined( CONFIG_GFX_BPP3 )

#define _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 )

#define _GFX_BPP4(...)  

This macro is declared in gfx/gfx.h source file, line 370.

Preprocessor condition: defined( CONFIG_GFX_BPP4 )

#define _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 )

#define _GFX_BPP5(...)  

This macro is declared in gfx/gfx.h source file, line 378.

Preprocessor condition: defined( CONFIG_GFX_BPP5 )

#define _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 )

#define _GFX_BPP_L2PPW(bpp, ppw, l2bpp, l2ppw, pm, ps, word_t)  

This macro is declared in gfx/gfx.h source file, line 496.

#define _GFX_CPP1(a)  

This macro is declared in gfx/gfx.h source file, line 331.

#define _GFX_CPP3(a, b, c)  

This macro is declared in gfx/gfx.h source file, line 332.

#define _GFX_FMT_SWITCH(name, args)  

This macro is declared in gfx/gfx.h source file, line 386.

#define _GFX_H_  

This macro is declared in gfx/gfx.h source file, line 37.

#define _GFX_SWAP(a, b)  

This macro is declared in gfx/gfx.h source file, line 335.

#define __GFX_CPP3(a, b, c)  

This macro is declared in gfx/gfx.h source file, line 333.

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.

enum gfx_direction_e  

This enum is declared in gfx/gfx.h source file, line 114.

This enum specifies directions.

IdentifierDescription
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.

enum gfx_surface_compress  

This enum is declared in gfx/gfx.h source file, line 106.

This enum specifies the various implemented surface compression formats

IdentifierDescription
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.

enum gfx_surface_format  

This enum is declared in gfx/gfx.h source file, line 93.

This enum specifies the various implemented pixel formats

IdentifierDescription
GFX_FMT_DEFAULTsee 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.

struct gfx_surface_s  

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.

FieldDescription
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.

struct gfx_tilemap_s  

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.

FieldDescription
struct gfx_surface_s s;
uint8_t l2tpr;
uint8_t tw;
uint8_t th;
uint8_t offset;

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.

struct gfx_fmt_desc_s  

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.

FieldDescription
uint8_t l2bpp;
uint8_t l2ppw;
gfx_pixel_t pm;

gfx_addr_t gfx_xymod(const struct gfx_surface_s *s, gfx_addr_t a)  

This function is declared in gfx/gfx.h source file, line 291.

This function clamps the pixel address so that it always fall in the surface.

This function is for internal use only.

Valid XHTML 1.0 StrictGenerated by diaxen on Wed Oct 17 21:18:38 2018 using MkDoc