GFXprim
2D bitmap graphics library with emphasis on speed and correctness
|
Generated macros and function to access pixels. More...
Go to the source code of this file.
Macros | |
#define | GP_PIXEL_ADDR_1BPP_DB(pixmap, x, y) |
A macro to get address of a starting byte for a pixel in a 1BPP_DB pixmap. | |
#define | GP_PIXEL_ADDR_SHIFT_1BPP_DB(pixmap, x) (((x + (pixmap)->offset) % 8) * 1) |
A macro to get bit-shift of pixel in 1BPP_DB pixmap. | |
#define | GP_PIXEL_ADDR_OFFSET_1BPP_DB(pixmap, x) (((pixmap)->offset + x) % 8) |
A macro to get pixel offset in pixels. | |
#define | GP_PIXEL_ADDR_1BPP_UB(pixmap, x, y) |
A macro to get address of a starting byte for a pixel in a 1BPP_UB pixmap. | |
#define | GP_PIXEL_ADDR_SHIFT_1BPP_UB(pixmap, x) (7 - ((x + (pixmap)->offset) % 8) * 1) |
A macro to get bit-shift of pixel in 1BPP_UB pixmap. | |
#define | GP_PIXEL_ADDR_OFFSET_1BPP_UB(pixmap, x) (((pixmap)->offset + x) % 8) |
A macro to get pixel offset in pixels. | |
#define | GP_PIXEL_ADDR_2BPP_DB(pixmap, x, y) |
A macro to get address of a starting byte for a pixel in a 2BPP_DB pixmap. | |
#define | GP_PIXEL_ADDR_SHIFT_2BPP_DB(pixmap, x) (((x + (pixmap)->offset) % 4) * 2) |
A macro to get bit-shift of pixel in 2BPP_DB pixmap. | |
#define | GP_PIXEL_ADDR_OFFSET_2BPP_DB(pixmap, x) (((pixmap)->offset + x) % 4) |
A macro to get pixel offset in pixels. | |
#define | GP_PIXEL_ADDR_2BPP_UB(pixmap, x, y) |
A macro to get address of a starting byte for a pixel in a 2BPP_UB pixmap. | |
#define | GP_PIXEL_ADDR_SHIFT_2BPP_UB(pixmap, x) (6 - ((x + (pixmap)->offset) % 4) * 2) |
A macro to get bit-shift of pixel in 2BPP_UB pixmap. | |
#define | GP_PIXEL_ADDR_OFFSET_2BPP_UB(pixmap, x) (((pixmap)->offset + x) % 4) |
A macro to get pixel offset in pixels. | |
#define | GP_PIXEL_ADDR_4BPP_DB(pixmap, x, y) |
A macro to get address of a starting byte for a pixel in a 4BPP_DB pixmap. | |
#define | GP_PIXEL_ADDR_SHIFT_4BPP_DB(pixmap, x) (((x + (pixmap)->offset) % 2) * 4) |
A macro to get bit-shift of pixel in 4BPP_DB pixmap. | |
#define | GP_PIXEL_ADDR_OFFSET_4BPP_DB(pixmap, x) (((pixmap)->offset + x) % 2) |
A macro to get pixel offset in pixels. | |
#define | GP_PIXEL_ADDR_4BPP_UB(pixmap, x, y) |
A macro to get address of a starting byte for a pixel in a 4BPP_UB pixmap. | |
#define | GP_PIXEL_ADDR_SHIFT_4BPP_UB(pixmap, x) (4 - ((x + (pixmap)->offset) % 2) * 4) |
A macro to get bit-shift of pixel in 4BPP_UB pixmap. | |
#define | GP_PIXEL_ADDR_OFFSET_4BPP_UB(pixmap, x) (((pixmap)->offset + x) % 2) |
A macro to get pixel offset in pixels. | |
#define | GP_PIXEL_ADDR_8BPP(pixmap, x, y) |
A macro to get address of a starting byte for a pixel in a 8BPP pixmap. | |
#define | GP_PIXEL_ADDR_SHIFT_8BPP(pixmap, x) (0) |
A macro to get bit-shift of pixel in 8BPP pixmap. | |
#define | GP_PIXEL_ADDR_OFFSET_8BPP(pixmap, x) (0) |
A macro to get pixel offset in pixels. | |
#define | GP_PIXEL_ADDR_16BPP(pixmap, x, y) |
A macro to get address of a starting byte for a pixel in a 16BPP pixmap. | |
#define | GP_PIXEL_ADDR_SHIFT_16BPP(pixmap, x) (0) |
A macro to get bit-shift of pixel in 16BPP pixmap. | |
#define | GP_PIXEL_ADDR_OFFSET_16BPP(pixmap, x) (0) |
A macro to get pixel offset in pixels. | |
#define | GP_PIXEL_ADDR_24BPP(pixmap, x, y) |
A macro to get address of a starting byte for a pixel in a 24BPP pixmap. | |
#define | GP_PIXEL_ADDR_SHIFT_24BPP(pixmap, x) (0) |
A macro to get bit-shift of pixel in 24BPP pixmap. | |
#define | GP_PIXEL_ADDR_OFFSET_24BPP(pixmap, x) (0) |
A macro to get pixel offset in pixels. | |
#define | GP_PIXEL_ADDR_32BPP(pixmap, x, y) |
A macro to get address of a starting byte for a pixel in a 32BPP pixmap. | |
#define | GP_PIXEL_ADDR_SHIFT_32BPP(pixmap, x) (0) |
A macro to get bit-shift of pixel in 32BPP pixmap. | |
#define | GP_PIXEL_ADDR_OFFSET_32BPP(pixmap, x) (0) |
A macro to get pixel offset in pixels. | |
#define | GP_PIXEL_ADDR_18BPP_DB(pixmap, x, y) |
A macro to get address of a starting byte for a pixel in a 18BPP_DB pixmap. | |
#define | GP_PIXEL_ADDR_SHIFT_18BPP_DB(pixmap, x) ((18 * (x + (pixmap)->offset)) % 8) |
A macro to get bit-shift of pixel in 18BPP_DB pixmap. | |
#define | GP_PIXEL_ADDR_OFFSET_18BPP_DB(pixmap, x) (0) |
A macro to get pixel offset in pixels. | |
Generated macros and function to access pixels.
These function and macros are generated based on the pixel defintions in gfxprim_config.py. The get and put pixel functions are build on the top of macros to manipulate bytes and bits.
The GP_PIXEL_ADDR macros return a pointer to the first byte of the pixel in the gp_pixmap buffer. If the pixel is aligned to whole bytes, we just need to fetch/write a few bytes. Otherwise we need to compute the shift, fetch a few bytes and then mask and bit shift it.
Unaligned access happens when instruction that works with multiple byte value gets an address that is not divideable by the size of the value. Eg. if 32 bit integer instruction gets an address that is not a multiple of 4. On intel cpus this type of access works and is supported however the C standard defines this as undefined behavior. This fails to work older ARM and most of the non intel cpus. So some more trickery must be done in order to write unaligned multibyte values. First of all we must compute offset and number of bytes to be accessed (which is cruicial for speed as we are going to read the pixel value byte by byte).
The offsets (starting with the first one e.g. pixel_size mod 8) forms subgroup in the mod 8 cyclic group. The maximal count of bits, from the start of the byte, then will be max from this subgroup + pixel_size. If this number is less or equal to 8 * N, we could write such pixel by writing N bytes.
For example the offsets of 16 BPP forms subgroup only with {0} so we only need 2 bytes to write it. As a matter of fact the 16 and 32 BPP are special cases that are always aligned together with the 8 BPP (which is aligned trivially). These three are coded as special cases which yields to faster operations in case of 16 and 32 BPP. The 24 BPP is not aligned as there are no instruction to operate 3 byte long numbers.
For second example take offsets of 20 BPP that forms subgroup {4, 0} so the max + pixel_size = 24 and indeed we fit into 3 bytes.
If pixel_size is coprime to 8, the offsets generates whole group and so the max + pixel_size = 7 + pixel_size. The 17 BPP fits into 24 bits and so 3 bytes are needed. The 19 BPP fits into 26 bits and because of that 4 bytes are needed.
Once we figure maximal number of bytes and the offset all that is to be done is to fetch first and last byte to combine it together with given pixel value and write the result back to the bitmap.
Definition in file gp_get_put_pixel.gen.h.
#define GP_PIXEL_ADDR_16BPP | ( | pixmap, | |
x, | |||
y | |||
) |
A macro to get address of a starting byte for a pixel in a 16BPP pixmap.
pixmap | A pixmap. |
x | An x coordinate within the pixmap. |
y | An y coordinate within the pixmap. |
Definition at line 626 of file gp_get_put_pixel.gen.h.
#define GP_PIXEL_ADDR_18BPP_DB | ( | pixmap, | |
x, | |||
y | |||
) |
A macro to get address of a starting byte for a pixel in a 18BPP_DB pixmap.
pixmap | A pixmap. |
x | An x coordinate within the pixmap. |
y | An y coordinate within the pixmap. |
Definition at line 860 of file gp_get_put_pixel.gen.h.
#define GP_PIXEL_ADDR_1BPP_DB | ( | pixmap, | |
x, | |||
y | |||
) |
A macro to get address of a starting byte for a pixel in a 1BPP_DB pixmap.
pixmap | A pixmap. |
x | An x coordinate within the pixmap. |
y | An y coordinate within the pixmap. |
Definition at line 86 of file gp_get_put_pixel.gen.h.
#define GP_PIXEL_ADDR_1BPP_UB | ( | pixmap, | |
x, | |||
y | |||
) |
A macro to get address of a starting byte for a pixel in a 1BPP_UB pixmap.
pixmap | A pixmap. |
x | An x coordinate within the pixmap. |
y | An y coordinate within the pixmap. |
Definition at line 164 of file gp_get_put_pixel.gen.h.
#define GP_PIXEL_ADDR_24BPP | ( | pixmap, | |
x, | |||
y | |||
) |
A macro to get address of a starting byte for a pixel in a 24BPP pixmap.
pixmap | A pixmap. |
x | An x coordinate within the pixmap. |
y | An y coordinate within the pixmap. |
Definition at line 698 of file gp_get_put_pixel.gen.h.
#define GP_PIXEL_ADDR_2BPP_DB | ( | pixmap, | |
x, | |||
y | |||
) |
A macro to get address of a starting byte for a pixel in a 2BPP_DB pixmap.
pixmap | A pixmap. |
x | An x coordinate within the pixmap. |
y | An y coordinate within the pixmap. |
Definition at line 242 of file gp_get_put_pixel.gen.h.
#define GP_PIXEL_ADDR_2BPP_UB | ( | pixmap, | |
x, | |||
y | |||
) |
A macro to get address of a starting byte for a pixel in a 2BPP_UB pixmap.
pixmap | A pixmap. |
x | An x coordinate within the pixmap. |
y | An y coordinate within the pixmap. |
Definition at line 320 of file gp_get_put_pixel.gen.h.
#define GP_PIXEL_ADDR_32BPP | ( | pixmap, | |
x, | |||
y | |||
) |
A macro to get address of a starting byte for a pixel in a 32BPP pixmap.
pixmap | A pixmap. |
x | An x coordinate within the pixmap. |
y | An y coordinate within the pixmap. |
Definition at line 788 of file gp_get_put_pixel.gen.h.
#define GP_PIXEL_ADDR_4BPP_DB | ( | pixmap, | |
x, | |||
y | |||
) |
A macro to get address of a starting byte for a pixel in a 4BPP_DB pixmap.
pixmap | A pixmap. |
x | An x coordinate within the pixmap. |
y | An y coordinate within the pixmap. |
Definition at line 398 of file gp_get_put_pixel.gen.h.
#define GP_PIXEL_ADDR_4BPP_UB | ( | pixmap, | |
x, | |||
y | |||
) |
A macro to get address of a starting byte for a pixel in a 4BPP_UB pixmap.
pixmap | A pixmap. |
x | An x coordinate within the pixmap. |
y | An y coordinate within the pixmap. |
Definition at line 476 of file gp_get_put_pixel.gen.h.
#define GP_PIXEL_ADDR_8BPP | ( | pixmap, | |
x, | |||
y | |||
) |
A macro to get address of a starting byte for a pixel in a 8BPP pixmap.
pixmap | A pixmap. |
x | An x coordinate within the pixmap. |
y | An y coordinate within the pixmap. |
Definition at line 554 of file gp_get_put_pixel.gen.h.
#define GP_PIXEL_ADDR_SHIFT_16BPP | ( | pixmap, | |
x | |||
) | (0) |
A macro to get bit-shift of pixel in 16BPP pixmap.
pixmap | A pixmap. |
x | An x coordinate in the pixmap. |
Definition at line 636 of file gp_get_put_pixel.gen.h.
#define GP_PIXEL_ADDR_SHIFT_18BPP_DB | ( | pixmap, | |
x | |||
) | ((18 * (x + (pixmap)->offset)) % 8) |
A macro to get bit-shift of pixel in 18BPP_DB pixmap.
pixmap | A pixmap. |
x | An x coordinate in the pixmap. |
Definition at line 870 of file gp_get_put_pixel.gen.h.
#define GP_PIXEL_ADDR_SHIFT_1BPP_DB | ( | pixmap, | |
x | |||
) | (((x + (pixmap)->offset) % 8) * 1) |
A macro to get bit-shift of pixel in 1BPP_DB pixmap.
pixmap | A pixmap. |
x | An x coordinate in the pixmap. |
Definition at line 96 of file gp_get_put_pixel.gen.h.
#define GP_PIXEL_ADDR_SHIFT_1BPP_UB | ( | pixmap, | |
x | |||
) | (7 - ((x + (pixmap)->offset) % 8) * 1) |
A macro to get bit-shift of pixel in 1BPP_UB pixmap.
pixmap | A pixmap. |
x | An x coordinate in the pixmap. |
Definition at line 174 of file gp_get_put_pixel.gen.h.
#define GP_PIXEL_ADDR_SHIFT_24BPP | ( | pixmap, | |
x | |||
) | (0) |
A macro to get bit-shift of pixel in 24BPP pixmap.
pixmap | A pixmap. |
x | An x coordinate in the pixmap. |
Definition at line 708 of file gp_get_put_pixel.gen.h.
#define GP_PIXEL_ADDR_SHIFT_2BPP_DB | ( | pixmap, | |
x | |||
) | (((x + (pixmap)->offset) % 4) * 2) |
A macro to get bit-shift of pixel in 2BPP_DB pixmap.
pixmap | A pixmap. |
x | An x coordinate in the pixmap. |
Definition at line 252 of file gp_get_put_pixel.gen.h.
#define GP_PIXEL_ADDR_SHIFT_2BPP_UB | ( | pixmap, | |
x | |||
) | (6 - ((x + (pixmap)->offset) % 4) * 2) |
A macro to get bit-shift of pixel in 2BPP_UB pixmap.
pixmap | A pixmap. |
x | An x coordinate in the pixmap. |
Definition at line 330 of file gp_get_put_pixel.gen.h.
#define GP_PIXEL_ADDR_SHIFT_32BPP | ( | pixmap, | |
x | |||
) | (0) |
A macro to get bit-shift of pixel in 32BPP pixmap.
pixmap | A pixmap. |
x | An x coordinate in the pixmap. |
Definition at line 798 of file gp_get_put_pixel.gen.h.
#define GP_PIXEL_ADDR_SHIFT_4BPP_DB | ( | pixmap, | |
x | |||
) | (((x + (pixmap)->offset) % 2) * 4) |
A macro to get bit-shift of pixel in 4BPP_DB pixmap.
pixmap | A pixmap. |
x | An x coordinate in the pixmap. |
Definition at line 408 of file gp_get_put_pixel.gen.h.
#define GP_PIXEL_ADDR_SHIFT_4BPP_UB | ( | pixmap, | |
x | |||
) | (4 - ((x + (pixmap)->offset) % 2) * 4) |
A macro to get bit-shift of pixel in 4BPP_UB pixmap.
pixmap | A pixmap. |
x | An x coordinate in the pixmap. |
Definition at line 486 of file gp_get_put_pixel.gen.h.
#define GP_PIXEL_ADDR_SHIFT_8BPP | ( | pixmap, | |
x | |||
) | (0) |
A macro to get bit-shift of pixel in 8BPP pixmap.
pixmap | A pixmap. |
x | An x coordinate in the pixmap. |
Definition at line 564 of file gp_get_put_pixel.gen.h.
gp_getpixel for 16BPP
c | A pixmap. |
x | A x coordinate. |
y | A y coordinate. |
Definition at line 656 of file gp_get_put_pixel.gen.h.
References GP_PIXEL_ADDR_16BPP.
|
inlinestatic |
gp_getpixel for 18BPP_DB
c | A pixmap. |
x | A x coordinate. |
y | A y coordinate. |
Definition at line 890 of file gp_get_put_pixel.gen.h.
References GP_GET_BITS3_ALIGNED, GP_PIXEL_ADDR_18BPP_DB, and GP_PIXEL_ADDR_SHIFT_18BPP_DB.
|
inlinestatic |
gp_getpixel for 1BPP_DB
c | A pixmap. |
x | A x coordinate. |
y | A y coordinate. |
Definition at line 116 of file gp_get_put_pixel.gen.h.
References GP_GET_BITS1_ALIGNED, GP_PIXEL_ADDR_1BPP_DB, and GP_PIXEL_ADDR_SHIFT_1BPP_DB.
|
inlinestatic |
gp_getpixel for 1BPP_UB
c | A pixmap. |
x | A x coordinate. |
y | A y coordinate. |
Definition at line 194 of file gp_get_put_pixel.gen.h.
References GP_GET_BITS1_ALIGNED, GP_PIXEL_ADDR_1BPP_UB, and GP_PIXEL_ADDR_SHIFT_1BPP_UB.
gp_getpixel for 24BPP
c | A pixmap. |
x | A x coordinate. |
y | A y coordinate. |
Definition at line 728 of file gp_get_put_pixel.gen.h.
References GP_GET_BITS3_ALIGNED, GP_PIXEL_ADDR_24BPP, and GP_PIXEL_ADDR_SHIFT_24BPP.
|
inlinestatic |
gp_getpixel for 2BPP_DB
c | A pixmap. |
x | A x coordinate. |
y | A y coordinate. |
Definition at line 272 of file gp_get_put_pixel.gen.h.
References GP_GET_BITS1_ALIGNED, GP_PIXEL_ADDR_2BPP_DB, and GP_PIXEL_ADDR_SHIFT_2BPP_DB.
|
inlinestatic |
gp_getpixel for 2BPP_UB
c | A pixmap. |
x | A x coordinate. |
y | A y coordinate. |
Definition at line 350 of file gp_get_put_pixel.gen.h.
References GP_GET_BITS1_ALIGNED, GP_PIXEL_ADDR_2BPP_UB, and GP_PIXEL_ADDR_SHIFT_2BPP_UB.
gp_getpixel for 32BPP
c | A pixmap. |
x | A x coordinate. |
y | A y coordinate. |
Definition at line 818 of file gp_get_put_pixel.gen.h.
References GP_PIXEL_ADDR_32BPP.
|
inlinestatic |
gp_getpixel for 4BPP_DB
c | A pixmap. |
x | A x coordinate. |
y | A y coordinate. |
Definition at line 428 of file gp_get_put_pixel.gen.h.
References GP_GET_BITS1_ALIGNED, GP_PIXEL_ADDR_4BPP_DB, and GP_PIXEL_ADDR_SHIFT_4BPP_DB.
|
inlinestatic |
gp_getpixel for 4BPP_UB
c | A pixmap. |
x | A x coordinate. |
y | A y coordinate. |
Definition at line 506 of file gp_get_put_pixel.gen.h.
References GP_GET_BITS1_ALIGNED, GP_PIXEL_ADDR_4BPP_UB, and GP_PIXEL_ADDR_SHIFT_4BPP_UB.
gp_getpixel for 8BPP
c | A pixmap. |
x | A x coordinate. |
y | A y coordinate. |
Definition at line 584 of file gp_get_put_pixel.gen.h.
References GP_PIXEL_ADDR_8BPP.
|
inlinestatic |
gp_putpixel for 16BPP
c | A pixmap. |
x | A x coordinate. |
y | A y coordinate. |
p | A pixel value to be written into the buffer. |
Definition at line 674 of file gp_get_put_pixel.gen.h.
References GP_PIXEL_ADDR_16BPP.
|
inlinestatic |
gp_putpixel for 18BPP_DB
c | A pixmap. |
x | A x coordinate. |
y | A y coordinate. |
p | A pixel value to be written into the buffer. |
Definition at line 917 of file gp_get_put_pixel.gen.h.
References GP_PIXEL_ADDR_18BPP_DB, GP_PIXEL_ADDR_SHIFT_18BPP_DB, and GP_SET_BITS3_ALIGNED.
|
inlinestatic |
gp_putpixel for 1BPP_DB
c | A pixmap. |
x | A x coordinate. |
y | A y coordinate. |
p | A pixel value to be written into the buffer. |
Definition at line 137 of file gp_get_put_pixel.gen.h.
References GP_PIXEL_ADDR_1BPP_DB, GP_PIXEL_ADDR_SHIFT_1BPP_DB, and GP_SET_BITS1_ALIGNED.
|
inlinestatic |
gp_putpixel for 1BPP_UB
c | A pixmap. |
x | A x coordinate. |
y | A y coordinate. |
p | A pixel value to be written into the buffer. |
Definition at line 215 of file gp_get_put_pixel.gen.h.
References GP_PIXEL_ADDR_1BPP_UB, GP_PIXEL_ADDR_SHIFT_1BPP_UB, and GP_SET_BITS1_ALIGNED.
|
inlinestatic |
gp_putpixel for 24BPP
c | A pixmap. |
x | A x coordinate. |
y | A y coordinate. |
p | A pixel value to be written into the buffer. |
Definition at line 755 of file gp_get_put_pixel.gen.h.
References GP_PIXEL_ADDR_24BPP, GP_PIXEL_ADDR_SHIFT_24BPP, and GP_SET_BITS3_ALIGNED.
|
inlinestatic |
gp_putpixel for 2BPP_DB
c | A pixmap. |
x | A x coordinate. |
y | A y coordinate. |
p | A pixel value to be written into the buffer. |
Definition at line 293 of file gp_get_put_pixel.gen.h.
References GP_PIXEL_ADDR_2BPP_DB, GP_PIXEL_ADDR_SHIFT_2BPP_DB, and GP_SET_BITS1_ALIGNED.
|
inlinestatic |
gp_putpixel for 2BPP_UB
c | A pixmap. |
x | A x coordinate. |
y | A y coordinate. |
p | A pixel value to be written into the buffer. |
Definition at line 371 of file gp_get_put_pixel.gen.h.
References GP_PIXEL_ADDR_2BPP_UB, GP_PIXEL_ADDR_SHIFT_2BPP_UB, and GP_SET_BITS1_ALIGNED.
|
inlinestatic |
gp_putpixel for 32BPP
c | A pixmap. |
x | A x coordinate. |
y | A y coordinate. |
p | A pixel value to be written into the buffer. |
Definition at line 836 of file gp_get_put_pixel.gen.h.
References GP_PIXEL_ADDR_32BPP.
|
inlinestatic |
gp_putpixel for 4BPP_DB
c | A pixmap. |
x | A x coordinate. |
y | A y coordinate. |
p | A pixel value to be written into the buffer. |
Definition at line 449 of file gp_get_put_pixel.gen.h.
References GP_PIXEL_ADDR_4BPP_DB, GP_PIXEL_ADDR_SHIFT_4BPP_DB, and GP_SET_BITS1_ALIGNED.
|
inlinestatic |
gp_putpixel for 4BPP_UB
c | A pixmap. |
x | A x coordinate. |
y | A y coordinate. |
p | A pixel value to be written into the buffer. |
Definition at line 527 of file gp_get_put_pixel.gen.h.
References GP_PIXEL_ADDR_4BPP_UB, GP_PIXEL_ADDR_SHIFT_4BPP_UB, and GP_SET_BITS1_ALIGNED.
gp_putpixel for 8BPP
c | A pixmap. |
x | A x coordinate. |
y | A y coordinate. |
p | A pixel value to be written into the buffer. |
Definition at line 602 of file gp_get_put_pixel.gen.h.
References GP_PIXEL_ADDR_8BPP.