~ubuntu-branches/ubuntu/maverick/gcompris/maverick

« back to all changes in this revision

Viewing changes to src/libart_lgpl/art_render.h

  • Committer: Bazaar Package Importer
  • Author(s): Marc Gariepy, Marc Gariepy, Stephane Graber
  • Date: 2010-01-04 17:42:49 UTC
  • mfrom: (1.1.14 upstream)
  • Revision ID: james.westby@ubuntu.com-20100104174249-7bupatd9dtxyhvs4
Tags: 9.0-0ubuntu1
[Marc Gariepy]
* New upstream release (9.0).
* Remove cache.c from POTFILES to avoid FTBFS
* Remove unneeded rm in debian/rules (file no longer exists upstream)

[Stephane Graber]
* Bump Debian standards to 3.8.3
* Add patch system (dpatch)

Show diffs side-by-side

added added

removed removed

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