iPXE
pixbuf.h File Reference

Pixel buffer. More...

#include <stddef.h>
#include <ipxe/refcnt.h>

Go to the source code of this file.

Data Structures

struct  pixel_buffer
 A pixel buffer. More...

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 FILE_SECBOOT (PERMITTED)
static __attribute__ ((always_inline)) struct pixel_buffer *pixbuf_get(struct pixel_buffer *pixbuf)
 Get reference to pixel buffer.
struct pixel_bufferalloc_pixbuf (unsigned int width, unsigned int height)
 Allocate pixel buffer.

Variables

static unsigned int x
static unsigned int unsigned int y
 index = ( ( y * pixbuf->width ) + x )
return &pixbuf data [index]

Detailed Description

Pixel buffer.

Definition in file pixbuf.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ __attribute__()

__attribute__ ( (always_inline) )
inlinestatic

Get reference to pixel buffer.

Get pixel.

Drop reference to pixel buffer.

Parameters
pixbufPixel buffer
Return values
pixbufPixel buffer
Parameters
pixbufPixel buffer
pixbufPixel buffer
xX position
yY position
Return values
pixelPixel

Definition at line 38 of file pixbuf.h.

39 {
40 ref_get ( &pixbuf->refcnt );
41 return pixbuf;
42}
#define ref_get(refcnt)
Get additional reference to object.
Definition refcnt.h:93

References ref_get, and pixel_buffer::refcnt.

◆ alloc_pixbuf()

struct pixel_buffer * alloc_pixbuf ( unsigned int width,
unsigned int height )
extern

Allocate pixel buffer.

Parameters
widthWidth @h height Height
Return values
pixbufPixel buffer, or NULL on failure

Definition at line 60 of file pixbuf.c.

60 {
61 struct pixel_buffer *pixbuf;
62
63 /* Allocate and initialise structure */
64 pixbuf = zalloc ( sizeof ( *pixbuf ) );
65 if ( ! pixbuf )
66 goto err_alloc_pixbuf;
67 ref_init ( &pixbuf->refcnt, free_pixbuf );
68 pixbuf->width = width;
69 pixbuf->height = height;
70 pixbuf->pixels = ( width * height );
71 pixbuf->len = ( pixbuf->pixels * sizeof ( uint32_t ) );
72
73 /* Check for multiplication overflow */
74 if ( ( width != 0 ) &&
75 ( ( pixbuf->len / sizeof ( uint32_t ) ) / width ) != height ) {
76 goto err_overflow;
77 }
78
79 /* Allocate pixel data buffer */
80 pixbuf->data = umalloc ( pixbuf->len );
81 if ( ! pixbuf->data )
82 goto err_alloc_data;
83
84 return pixbuf;
85
86 err_alloc_data:
87 err_overflow:
88 pixbuf_put ( pixbuf );
89 err_alloc_pixbuf:
90 return NULL;
91}
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
unsigned int uint32_t
Definition stdint.h:12
static __always_inline void * umalloc(size_t size)
Allocate external memory.
Definition umalloc.h:57
void * zalloc(size_t size)
Allocate cleared memory.
Definition malloc.c:662
static void free_pixbuf(struct refcnt *refcnt)
Free pixel buffer.
Definition pixbuf.c:45
#define ref_init(refcnt, free)
Initialise a reference counter.
Definition refcnt.h:65
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

References pixel_buffer::data, free_pixbuf(), pixel_buffer::height, pixel_buffer::len, NULL, pixel_buffer::pixels, ref_init, pixel_buffer::refcnt, umalloc(), pixel_buffer::width, and zalloc().

Referenced by png_image_header().

Variable Documentation

◆ x

◆ y

◆ index

index = ( ( y * pixbuf->width ) + x )

Definition at line 66 of file pixbuf.h.

◆ data

return& pixbuf data[index]

Definition at line 67 of file pixbuf.h.