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 FILE_SECBOOT ( PERMITTED );
12 
13 #include <stddef.h>
14 #include <ipxe/refcnt.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 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  */
38 static inline __attribute__ (( always_inline )) struct pixel_buffer *
39 pixbuf_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  */
49 static inline __attribute__ (( always_inline )) void
50 pixbuf_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  */
62 static inline __attribute__ (( always_inline )) uint32_t *
63 pixbuf_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 
70 extern struct pixel_buffer * alloc_pixbuf ( unsigned int width,
71  unsigned int height );
72 
73 #endif /* _IPXE_PIXBUF_H */
index
Definition: pixbuf.h:66
unsigned int height
Height.
Definition: pixbuf.h:23
static unsigned int x
Definition: pixbuf.h:63
unsigned int pixels
Total number of pixels.
Definition: pixbuf.h:27
struct pixel_buffer * alloc_pixbuf(unsigned int width, unsigned int height)
Allocate pixel buffer.
Definition: pixbuf.c:60
A reference counter.
Definition: refcnt.h:27
size_t len
Total length.
Definition: pixbuf.h:29
uint32_t * data
32-bit (8:8:8:8) xRGB pixel data, in host-endian order
Definition: pixbuf.h:25
#define ref_get(refcnt)
Get additional reference to object.
Definition: refcnt.h:93
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:38
struct refcnt refcnt
Reference count.
Definition: pixbuf.h:19
unsigned int uint32_t
Definition: stdint.h:12
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
static unsigned int unsigned int y
Definition: pixbuf.h:63
Reference counting.
FILE_SECBOOT(PERMITTED)
unsigned int width
Width.
Definition: pixbuf.h:21
#define ref_put(refcnt)
Drop reference to object.
Definition: refcnt.h:107