1 #ifndef _IPXE_PIXBUF_H
2 #define _IPXE_PIXBUF_H
3 
4 /** @file
5  *
6  * Pixel buffer
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 
12 #include <stddef.h>
13 #include <ipxe/refcnt.h>
14 #include <ipxe/uaccess.h>
15 
16 /** A pixel buffer */
17 struct 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 */
25 	userptr_t data;
26 	/** Total length */
27 	size_t len;
28 };
29 
30 /**
31  * Get reference to pixel buffer
32  *
33  * @v pixbuf		Pixel buffer
34  * @ret pixbuf		Pixel buffer
35  */
36 static inline __attribute__ (( always_inline )) struct pixel_buffer *
pixbuf_get(struct pixel_buffer * pixbuf)37 pixbuf_get ( struct pixel_buffer *pixbuf ) {
38 	ref_get ( &pixbuf->refcnt );
39 	return pixbuf;
40 }
41 
42 /**
43  * Drop reference to pixel buffer
44  *
45  * @v pixbuf		Pixel buffer
46  */
47 static inline __attribute__ (( always_inline )) void
pixbuf_put(struct pixel_buffer * pixbuf)48 pixbuf_put ( struct pixel_buffer *pixbuf ) {
49 	ref_put ( &pixbuf->refcnt );
50 }
51 
52 extern struct pixel_buffer * alloc_pixbuf ( unsigned int width,
53 					    unsigned int height );
54 
55 #endif /* _IPXE_PIXBUF_H */
56