iPXE
pixbuf.h
Go to the documentation of this file.
00001 #ifndef _IPXE_PIXBUF_H
00002 #define _IPXE_PIXBUF_H
00003 
00004 /** @file
00005  *
00006  * Pixel buffer
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00011 
00012 #include <stddef.h>
00013 #include <ipxe/refcnt.h>
00014 #include <ipxe/uaccess.h>
00015 
00016 /** A pixel buffer */
00017 struct pixel_buffer {
00018         /** Reference count */
00019         struct refcnt refcnt;
00020         /** Width */
00021         unsigned int width;
00022         /** Height */
00023         unsigned int height;
00024         /** 32-bit (8:8:8:8) xRGB pixel data, in host-endian order */
00025         userptr_t data;
00026         /** Total length */
00027         size_t len;
00028 };
00029 
00030 /**
00031  * Get reference to pixel buffer
00032  *
00033  * @v pixbuf            Pixel buffer
00034  * @ret pixbuf          Pixel buffer
00035  */
00036 static inline __attribute__ (( always_inline )) struct pixel_buffer *
00037 pixbuf_get ( struct pixel_buffer *pixbuf ) {
00038         ref_get ( &pixbuf->refcnt );
00039         return pixbuf;
00040 }
00041 
00042 /**
00043  * Drop reference to pixel buffer
00044  *
00045  * @v pixbuf            Pixel buffer
00046  */
00047 static inline __attribute__ (( always_inline )) void
00048 pixbuf_put ( struct pixel_buffer *pixbuf ) {
00049         ref_put ( &pixbuf->refcnt );
00050 }
00051 
00052 extern struct pixel_buffer * alloc_pixbuf ( unsigned int width,
00053                                             unsigned int height );
00054 
00055 #endif /* _IPXE_PIXBUF_H */