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 
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 */
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 *
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
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 */
unsigned int height
Height.
Definition: pixbuf.h:23
struct pixel_buffer * alloc_pixbuf(unsigned int width, unsigned int height)
Allocate pixel buffer.
Definition: pixbuf.c:58
Access to external ("user") memory.
A reference counter.
Definition: refcnt.h:26
size_t len
Total length.
Definition: pixbuf.h:27
#define ref_get(refcnt)
Get additional reference to object.
Definition: refcnt.h:92
A pixel buffer.
Definition: pixbuf.h:17
static __attribute__((always_inline)) struct pixel_buffer *pixbuf_get(struct pixel_buffer *pixbuf)
Get reference to pixel buffer.
Definition: pixbuf.h:36
struct refcnt refcnt
Reference count.
Definition: pixbuf.h:19
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
Reference counting.
userptr_t data
32-bit (8:8:8:8) xRGB pixel data, in host-endian order
Definition: pixbuf.h:25
unsigned int width
Width.
Definition: pixbuf.h:21
#define ref_put(refcnt)
Drop reference to object.
Definition: refcnt.h:106
unsigned long userptr_t
A pointer to a user buffer.
Definition: uaccess.h:33