iPXE
pixbuf.h
Go to the documentation of this file.
1#ifndef _IPXE_PIXBUF_H
2#define _IPXE_PIXBUF_H
3
4/** @file
5 *
6 * Pixel buffer
7 *
8 */
9
10FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11FILE_SECBOOT ( PERMITTED );
12
13#include <stddef.h>
14#include <ipxe/refcnt.h>
15
16/** A pixel buffer */
18 /** Reference count */
19 struct refcnt refcnt;
20 /** Width */
21 unsigned int width;
22 /** Height */
23 unsigned int height;
24 /** 32-bit (8:8:8:8) xRGB pixel data, in host-endian order */
26 /** Total number of pixels */
27 unsigned int pixels;
28 /** Total length */
29 size_t len;
30};
31
32/**
33 * Get reference to pixel buffer
34 *
35 * @v pixbuf Pixel buffer
36 * @ret pixbuf Pixel buffer
37 */
38static inline __attribute__ (( always_inline )) struct pixel_buffer *
39pixbuf_get ( struct pixel_buffer *pixbuf ) {
40 ref_get ( &pixbuf->refcnt );
41 return pixbuf;
42}
43
44/**
45 * Drop reference to pixel buffer
46 *
47 * @v pixbuf Pixel buffer
48 */
49static inline __attribute__ (( always_inline )) void
50pixbuf_put ( struct pixel_buffer *pixbuf ) {
51 ref_put ( &pixbuf->refcnt );
52}
53
54/**
55 * Get pixel
56 *
57 * @v pixbuf Pixel buffer
58 * @v x X position
59 * @v y Y position
60 * @ret pixel Pixel
61 */
62static inline __attribute__ (( always_inline )) uint32_t *
63pixbuf_pixel ( struct pixel_buffer *pixbuf, unsigned int x, unsigned int y ) {
64 unsigned int index;
65
66 index = ( ( y * pixbuf->width ) + x );
67 return &pixbuf->data[index];
68}
69
70extern struct pixel_buffer * alloc_pixbuf ( unsigned int width,
71 unsigned int height );
72
73#endif /* _IPXE_PIXBUF_H */
unsigned int uint32_t
Definition stdint.h:12
long index
Definition bigint.h:65
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
#define __attribute__(x)
Definition compiler.h:10
static unsigned int unsigned int y
Definition pixbuf.h:63
static unsigned int x
Definition pixbuf.h:63
struct pixel_buffer * alloc_pixbuf(unsigned int width, unsigned int height)
Allocate pixel buffer.
Definition pixbuf.c:60
Reference counting.
#define ref_get(refcnt)
Get additional reference to object.
Definition refcnt.h:93
#define ref_put(refcnt)
Drop reference to object.
Definition refcnt.h:107
A pixel buffer.
Definition pixbuf.h:17
unsigned int height
Height.
Definition pixbuf.h:23
unsigned int pixels
Total number of pixels.
Definition pixbuf.h:27
struct refcnt refcnt
Reference count.
Definition pixbuf.h:19
size_t len
Total length.
Definition pixbuf.h:29
unsigned int width
Width.
Definition pixbuf.h:21
uint32_t * data
32-bit (8:8:8:8) xRGB pixel data, in host-endian order
Definition pixbuf.h:25