1
#ifndef __NR_PIXBLOCK_H__
2
#define __NR_PIXBLOCK_H__
5
* \brief Pixel block structure. Used for low-level rendering.
8
* (C) 1999-2002 Lauris Kaplinski <lauris@kaplinski.com>
9
* (C) 2005 Ralf Stephan <ralf@ark.in-berlin.de> (some cleanup)
11
* This code is in the Public Domain.
14
#include <libnr/nr-rect-l.h>
15
#include <libnr/nr-forward.h>
17
/// Size indicator. Hardcoded to max. 3 bits.
19
NR_PIXBLOCK_SIZE_TINY, ///< Fits in (unsigned char *)
20
NR_PIXBLOCK_SIZE_4K, ///< Pixelstore
21
NR_PIXBLOCK_SIZE_16K, ///< Pixelstore
22
NR_PIXBLOCK_SIZE_64K, ///< Pixelstore
23
NR_PIXBLOCK_SIZE_256K, ///< Pixelstore
24
NR_PIXBLOCK_SIZE_1M, ///< Pixelstore
25
NR_PIXBLOCK_SIZE_BIG, ///< Normally allocated
26
NR_PIXBLOCK_SIZE_STATIC ///< Externally managed
29
/// Mode indicator. Hardcoded to max. 2 bits.
31
NR_PIXBLOCK_MODE_A8, ///< Grayscale
32
NR_PIXBLOCK_MODE_R8G8B8, ///< 8 bit RGB
33
NR_PIXBLOCK_MODE_R8G8B8A8N, ///< Normal 8 bit RGBA
34
NR_PIXBLOCK_MODE_R8G8B8A8P ///< Premultiplied 8 bit RGBA
37
/// The pixel block struct.
39
NR_PIXBLOCK_SIZE size : 3; ///< Size indicator
40
NR_PIXBLOCK_MODE mode : 2; ///< Mode indicator
41
bool empty : 1; ///< Empty flag
42
unsigned int rs; ///< Size of line in bytes
46
unsigned char *px; ///< Pointer to buffer
47
unsigned char p[sizeof (unsigned char *)]; ///< Tiny buffer
51
/// Returns number of bytes per pixel (1, 3, or 4).
53
NR_PIXBLOCK_BPP (NRPixBlock *pb)
55
return ((pb->mode == NR_PIXBLOCK_MODE_A8) ? 1 :
56
(pb->mode == NR_PIXBLOCK_MODE_R8G8B8) ? 3 : 4);
59
/// Returns pointer to pixel data.
61
NR_PIXBLOCK_PX (NRPixBlock *pb)
63
return ((pb->size == NR_PIXBLOCK_SIZE_TINY) ?
64
pb->data.p : pb->data.px);
66
inline unsigned char const*
67
NR_PIXBLOCK_PX (NRPixBlock const *pb)
69
return ((pb->size == NR_PIXBLOCK_SIZE_TINY) ?
70
pb->data.p : pb->data.px);
73
void nr_pixblock_setup (NRPixBlock *pb, NR_PIXBLOCK_MODE mode, int x0, int y0, int x1, int y1, bool clear);
74
void nr_pixblock_setup_fast (NRPixBlock *pb, NR_PIXBLOCK_MODE mode, int x0, int y0, int x1, int y1, bool clear);
75
void nr_pixblock_setup_extern (NRPixBlock *pb, NR_PIXBLOCK_MODE mode, int x0, int y0, int x1, int y1, unsigned char *px, int rs, bool empty, bool clear);
76
void nr_pixblock_release (NRPixBlock *pb);
78
NRPixBlock *nr_pixblock_new (NR_PIXBLOCK_MODE mode, int x0, int y0, int x1, int y1, bool clear);
79
NRPixBlock *nr_pixblock_new_fast (NR_PIXBLOCK_MODE mode, int x0, int y0, int x1, int y1, bool clear);
80
NRPixBlock *nr_pixblock_free (NRPixBlock *pb);
82
unsigned char *nr_pixelstore_4K_new (bool clear, unsigned char val);
83
void nr_pixelstore_4K_free (unsigned char *px);
84
unsigned char *nr_pixelstore_16K_new (bool clear, unsigned char val);
85
void nr_pixelstore_16K_free (unsigned char *px);
86
unsigned char *nr_pixelstore_64K_new (bool clear, unsigned char val);
87
void nr_pixelstore_64K_free (unsigned char *px);
88
unsigned char *nr_pixelstore_256K_new (bool clear, unsigned char val);
89
void nr_pixelstore_256K_free (unsigned char *px);
90
unsigned char *nr_pixelstore_1M_new (bool clear, unsigned char val);
91
void nr_pixelstore_1M_free (unsigned char *px);
97
c-file-style:"stroustrup"
98
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
103
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :