source: trunk/third/librsvg/art_render.h @ 17277

Revision 17277, 4.8 KB checked in by amb, 23 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r17276, which included commits to RCS files with non-trunk default branches.
Line 
1/* This file is adapted from art_render.h in Libart version 2.3.0 */
2
3#include <libart_lgpl/libart-features.h>
4
5#if LIBART_MAJOR_VERSION == 2 && LIBART_MINOR_VERSION < 3
6
7/*
8 * art_render.h: Modular rendering architecture.
9 *
10 * Libart_LGPL - library of basic graphic primitives
11 * Copyright (C) 2000 Raph Levien
12 *
13 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Library General Public
15 * License as published by the Free Software Foundation; either
16 * version 2 of the License, or (at your option) any later version.
17 *
18 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21 * Library General Public License for more details.
22 *
23 * You should have received a copy of the GNU Library General Public
24 * License along with this library; if not, write to the
25 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26 * Boston, MA 02111-1307, USA.
27 */
28
29#ifndef __ART_RENDER_H__
30#define __ART_RENDER_H__
31
32#ifdef __cplusplus
33extern "C" {
34#endif /* __cplusplus */
35
36/* Workaround for older versions of Libart that didn't define art_u16 */
37#ifndef ART_SIZEOF_SHORT
38typedef unsigned short art_u16;
39#endif
40
41/* Render object */
42
43#ifndef ART_MAX_DEPTH
44#define ART_MAX_DEPTH 16
45#endif
46
47#if ART_MAX_DEPTH == 16
48typedef art_u16 ArtPixMaxDepth;
49#define ART_PIX_MAX_FROM_8(x) ((x) | ((x) << 8))
50#define ART_PIX_8_FROM_MAX(x) (((x) + 0x80 - (((x) + 0x80) >> 8)) >> 8)
51#else
52#if ART_MAX_DEPTH == 8
53typedef art_u8 ArtPixMaxDepth;
54#define ART_PIX_MAX_FROM_8(x) (x)
55#define ART_PIX_8_FROM_MAX(x) (x)
56#else
57#error ART_MAX_DEPTH must be either 8 or 16
58#endif
59#endif
60
61#define ART_MAX_CHAN 16
62
63typedef struct _ArtRender ArtRender;
64typedef struct _ArtRenderCallback ArtRenderCallback;
65typedef struct _ArtRenderMaskRun ArtRenderMaskRun;
66typedef struct _ArtImageSource ArtImageSource;
67typedef struct _ArtMaskSource ArtMaskSource;
68
69typedef enum {
70  ART_ALPHA_NONE      = 0,
71  ART_ALPHA_SEPARATE  = 1,
72  ART_ALPHA_PREMUL    = 2
73} ArtAlphaType;
74
75typedef enum {
76  ART_COMPOSITE_NORMAL,
77  ART_COMPOSITE_MULTIPLY,
78  /* todo: more */
79  ART_COMPOSITE_CUSTOM
80} ArtCompositingMode;
81
82typedef enum {
83  ART_IMAGE_SOURCE_CAN_CLEAR = 1,
84  ART_IMAGE_SOURCE_CAN_COMPOSITE = 2
85} ArtImageSourceFlags;
86
87struct _ArtRenderMaskRun {
88  int x;
89  int alpha;
90};
91
92struct _ArtRenderCallback {
93  void (*render) (ArtRenderCallback *self, ArtRender *render,
94                  art_u8 *dest, int y);
95  void (*done) (ArtRenderCallback *self, ArtRender *render);
96};
97
98struct _ArtImageSource {
99  ArtRenderCallback super;
100  void (*negotiate) (ArtImageSource *self, ArtRender *render,
101                     ArtImageSourceFlags *p_flags,
102                     int *p_buf_depth, ArtAlphaType *p_alpha_type);
103};
104
105struct _ArtMaskSource {
106  ArtRenderCallback super;
107  int (*can_drive) (ArtMaskSource *self, ArtRender *render);
108  /* For each mask source, ::prepare() is invoked if it is not
109     a driver, or ::invoke_driver() if it is. */
110  void (*invoke_driver) (ArtMaskSource *self, ArtRender *render);
111  void (*prepare) (ArtMaskSource *self, ArtRender *render, art_boolean first);
112};
113
114struct _ArtRender {
115  /* parameters of destination image */
116  int x0, y0;
117  int x1, y1;
118  art_u8 *pixels;
119  int rowstride;
120  int n_chan;
121  int depth;
122  ArtAlphaType alpha_type;
123
124  art_boolean clear;
125  ArtPixMaxDepth clear_color[ART_MAX_CHAN + 1];
126  art_u32 opacity; /* [0..0x10000] */
127
128  ArtCompositingMode compositing_mode;
129
130  ArtAlphaGamma *alphagamma;
131
132  art_u8 *alpha_buf;
133
134  /* parameters of intermediate buffer */
135  int buf_depth;
136  ArtAlphaType buf_alpha;
137  art_u8 *image_buf;
138
139  /* driving alpha scanline data */
140  /* A "run" is a contiguous sequence of x values with the same alpha value. */
141  int n_run;
142  ArtRenderMaskRun *run;
143
144  /* A "span" is a contiguous sequence of x values with non-zero alpha. */
145  int n_span;
146  int *span_x;
147
148  art_boolean need_span;
149};
150
151ArtRender *
152art_render_new (int x0, int y0, int x1, int y1,
153                art_u8 *pixels, int rowstride,
154                int n_chan, int depth, ArtAlphaType alpha_type,
155                ArtAlphaGamma *alphagamma);
156
157void
158art_render_invoke (ArtRender *render);
159
160void
161art_render_clear (ArtRender *render, const ArtPixMaxDepth *clear_color);
162
163void
164art_render_clear_rgb (ArtRender *render, art_u32 clear_rgb);
165
166void
167art_render_mask_solid (ArtRender *render, int opacity);
168
169void
170art_render_image_solid (ArtRender *render, ArtPixMaxDepth *color);
171
172/* The next two functions are for custom mask sources only. */
173void
174art_render_add_mask_source (ArtRender *render, ArtMaskSource *mask_source);
175
176void
177art_render_invoke_callbacks (ArtRender *render, art_u8 *dest, int y);
178
179/* The following function is for custom image sources only. */
180void
181art_render_add_image_source (ArtRender *render, ArtImageSource *image_source);
182
183#ifdef __cplusplus
184}
185#endif /* __cplusplus */
186
187#endif /* __ART_RENDER_H__ */
188
189#else
190
191#include <libart_lgpl/art_render.h>
192
193#endif
Note: See TracBrowser for help on using the repository browser.