1
/* ScummVM - Graphic Adventure Engine
3
* ScummVM is the legal property of its developers, whose names
4
* are too numerous to list here. Please refer to the COPYRIGHT
5
* file distributed with this source distribution.
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; either version 2
10
* of the License, or (at your option) any later version.
12
* This program 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
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27
* This code is based on Libart_LGPL - library of basic graphic primitives
29
* Copyright (c) 1998 Raph Levien
31
* Licensed under GNU LGPL v2
35
/* Simple macros to set up storage allocation and basic types for libart
41
#include "common/scummsys.h"
45
/* These aren't, strictly speaking, configuration macros, but they're
46
damn handy to have around, and may be worth playing with for
48
#define art_new(type, n) ((type *)malloc ((n) * sizeof(type)))
50
#define art_renew(p, type, n) ((type *)realloc (p, (n) * sizeof(type)))
52
/* This one must be used carefully - in particular, p and max should
53
be variables. They can also be pstruct->el lvalues. */
54
#define art_expand(p, type, max) \
57
p = art_renew(p, type, max <<= 1); \
60
p = art_new(type, 1); \
66
double x0, y0, x1, y1;
74
/* Basic data structures and constructors for sorted vector paths */
78
int dir; /* == 0 for "up", 1 for "down" */
88
void art_svp_free(ArtSVP *svp);
90
int art_svp_seg_compare(const void *s1, const void *s2);
92
/* Basic data structures and constructors for bezier paths */
113
/* Basic data structures and constructors for simple vector paths */
115
/* CURVETO is not allowed! */
122
/* Some of the functions need to go into their own modules */
124
void art_vpath_add_point(ArtVpath **p_vpath, int *pn_points, int *pn_points_max,
125
ArtPathcode code, double x, double y);
127
ArtVpath *art_bez_path_to_vec(const ArtBpath *bez, double flatness);
129
/* The funky new SVP intersector. */
131
#ifndef ART_WIND_RULE_DEFINED
132
#define ART_WIND_RULE_DEFINED
134
ART_WIND_RULE_NONZERO,
135
ART_WIND_RULE_INTERSECT,
136
ART_WIND_RULE_ODDEVEN,
137
ART_WIND_RULE_POSITIVE
141
struct ArtSvpWriter {
142
int (*add_segment)(ArtSvpWriter *self, int wind_left, int delta_wind,
144
void (*add_point)(ArtSvpWriter *self, int seg_id, double x, double y);
145
void (*close_segment)(ArtSvpWriter *self, int seg_id);
148
ArtSvpWriter *art_svp_writer_rewind_new(ArtWindRule rule);
150
ArtSVP *art_svp_writer_rewind_reap(ArtSvpWriter *self);
152
int art_svp_seg_compare(const void *s1, const void *s2);
154
void art_svp_intersector(const ArtSVP *in, ArtSvpWriter *out);
157
/* Sort vector paths into sorted vector paths. */
159
ArtSVP *art_svp_from_vpath(ArtVpath *vpath);
161
/* Sort vector paths into sorted vector paths. */
163
enum ArtPathStrokeJoinType {
164
ART_PATH_STROKE_JOIN_MITER,
165
ART_PATH_STROKE_JOIN_ROUND,
166
ART_PATH_STROKE_JOIN_BEVEL
169
enum ArtPathStrokeCapType {
170
ART_PATH_STROKE_CAP_BUTT,
171
ART_PATH_STROKE_CAP_ROUND,
172
ART_PATH_STROKE_CAP_SQUARE
175
ArtSVP *art_svp_vpath_stroke(ArtVpath *vpath,
176
ArtPathStrokeJoinType join,
177
ArtPathStrokeCapType cap,
182
/* This version may have winding numbers exceeding 1. */
183
ArtVpath *art_svp_vpath_stroke_raw(ArtVpath *vpath,
184
ArtPathStrokeJoinType join,
185
ArtPathStrokeCapType cap,
191
/* The spiffy antialiased renderer for sorted vector paths. */
193
struct ArtSVPRenderAAStep {
195
int delta; /* stored with 16 fractional bits */
198
struct ArtSVPRenderAAIter;
200
ArtSVPRenderAAIter *art_svp_render_aa_iter(const ArtSVP *svp,
201
int x0, int y0, int x1, int y1);
203
void art_svp_render_aa_iter_step(ArtSVPRenderAAIter *iter, int *p_start,
204
ArtSVPRenderAAStep **p_steps, int *p_n_steps);
206
void art_svp_render_aa_iter_done(ArtSVPRenderAAIter *iter);
208
void art_svp_render_aa(const ArtSVP *svp,
209
int x0, int y0, int x1, int y1,
210
void (*callback)(void *callback_data,
213
ArtSVPRenderAAStep *steps, int n_steps),
214
void *callback_data);
216
} // End of namespace Sword25
218
#endif /* __ART_H__ */