-rw-r--r-- | core/multimedia/opieplayer/libflash/config.in | 2 | ||||
-rw-r--r-- | core/multimedia/opieplayer/libflash/shape.cc | 2 | ||||
-rw-r--r-- | core/multimedia/opieplayer/libmad/config.in | 2 | ||||
-rw-r--r-- | core/multimedia/opieplayer/libmpeg3/config.in | 2 | ||||
-rw-r--r-- | core/multimedia/opieplayer/modplug/config.in | 2 | ||||
-rw-r--r-- | core/multimedia/opieplayer/wavplugin/config.in | 2 |
6 files changed, 7 insertions, 5 deletions
diff --git a/core/multimedia/opieplayer/libflash/config.in b/core/multimedia/opieplayer/libflash/config.in index 91a57da..258e8ee 100644 --- a/core/multimedia/opieplayer/libflash/config.in +++ b/core/multimedia/opieplayer/libflash/config.in | |||
@@ -1,4 +1,4 @@ | |||
1 | # config #LIBFLASH | 1 | # config #LIBFLASH |
2 | # boolean "libflash" | 2 | # boolean "libflash" |
3 | # default "y" | 3 | # default "y" |
4 | # depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE | 4 | # depends ( LIBQPE || LIBQPE-X11 ) |
diff --git a/core/multimedia/opieplayer/libflash/shape.cc b/core/multimedia/opieplayer/libflash/shape.cc index 0d8df93..4d4ecb8 100644 --- a/core/multimedia/opieplayer/libflash/shape.cc +++ b/core/multimedia/opieplayer/libflash/shape.cc | |||
@@ -1,1205 +1,1207 @@ | |||
1 | ///////////////////////////////////////////////////////////// | 1 | ///////////////////////////////////////////////////////////// |
2 | // Flash Plugin and Player | 2 | // Flash Plugin and Player |
3 | // Copyright (C) 1998,1999 Olivier Debon | 3 | // Copyright (C) 1998,1999 Olivier Debon |
4 | // | 4 | // |
5 | // This program is free software; you can redistribute it and/or | 5 | // This program is free software; you can redistribute it and/or |
6 | // modify it under the terms of the GNU General Public License | 6 | // modify it under the terms of the GNU General Public License |
7 | // as published by the Free Software Foundation; either version 2 | 7 | // as published by the Free Software Foundation; either version 2 |
8 | // of the License, or (at your option) any later version. | 8 | // of the License, or (at your option) any later version. |
9 | // | 9 | // |
10 | // This program is distributed in the hope that it will be useful, | 10 | // This program is distributed in the hope that it will be useful, |
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | // GNU General Public License for more details. | 13 | // GNU General Public License for more details. |
14 | // | 14 | // |
15 | // You should have received a copy of the GNU General Public License | 15 | // You should have received a copy of the GNU General Public License |
16 | // along with this program; if not, write to the Free Software | 16 | // along with this program; if not, write to the Free Software |
17 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | // | 18 | // |
19 | /////////////////////////////////////////////////////////////// | 19 | /////////////////////////////////////////////////////////////// |
20 | // Author : Olivier Debon <odebon@club-internet.fr> | 20 | // Author : Olivier Debon <odebon@club-internet.fr> |
21 | // | 21 | // |
22 | 22 | ||
23 | #include "swf.h" | 23 | #include "swf.h" |
24 | 24 | ||
25 | #include "math.h" | ||
26 | |||
25 | #ifdef RCSID | 27 | #ifdef RCSID |
26 | static char *rcsid = "$Id$"; | 28 | static char *rcsid = "$Id$"; |
27 | #endif | 29 | #endif |
28 | 30 | ||
29 | #define PRINT 0 | 31 | #define PRINT 0 |
30 | 32 | ||
31 | #define ABS(v) ((v) < 0 ? -(v) : (v)) | 33 | #define ABS(v) ((v) < 0 ? -(v) : (v)) |
32 | 34 | ||
33 | static void prepareStyles(GraphicDevice *gd, Matrix *matrix, Cxform *cxform, FillStyleDef *f, long n); | 35 | static void prepareStyles(GraphicDevice *gd, Matrix *matrix, Cxform *cxform, FillStyleDef *f, long n); |
34 | 36 | ||
35 | static void clearStyles(GraphicDevice *gd, FillStyleDef *f, long n); | 37 | static void clearStyles(GraphicDevice *gd, FillStyleDef *f, long n); |
36 | 38 | ||
37 | static void drawShape(GraphicDevice *gd, Matrix *matrix1, Cxform *cxform, Shape *shape, | 39 | static void drawShape(GraphicDevice *gd, Matrix *matrix1, Cxform *cxform, Shape *shape, |
38 | ShapeAction shapeAction, void *id,ScanLineFunc scan_line_func); | 40 | ShapeAction shapeAction, void *id,ScanLineFunc scan_line_func); |
39 | 41 | ||
40 | // Constructor | 42 | // Constructor |
41 | 43 | ||
42 | Shape::Shape(long id, int level) : Character(ShapeType, id) | 44 | Shape::Shape(long id, int level) : Character(ShapeType, id) |
43 | { | 45 | { |
44 | defLevel = level; | 46 | defLevel = level; |
45 | 47 | ||
46 | defaultFillStyle.type = f_Solid; | 48 | defaultFillStyle.type = f_Solid; |
47 | defaultFillStyle.color.red = 0; | 49 | defaultFillStyle.color.red = 0; |
48 | defaultFillStyle.color.green = 0; | 50 | defaultFillStyle.color.green = 0; |
49 | defaultFillStyle.color.blue = 0; | 51 | defaultFillStyle.color.blue = 0; |
50 | defaultFillStyle.color.alpha = ALPHA_OPAQUE; | 52 | defaultFillStyle.color.alpha = ALPHA_OPAQUE; |
51 | 53 | ||
52 | defaultLineStyle.width = 0; | 54 | defaultLineStyle.width = 0; |
53 | 55 | ||
54 | // This is to force a first update | 56 | // This is to force a first update |
55 | lastMat.a = 0; | 57 | lastMat.a = 0; |
56 | lastMat.d = 0; | 58 | lastMat.d = 0; |
57 | shape_size += sizeof(Shape); | 59 | shape_size += sizeof(Shape); |
58 | shape_nb ++; | 60 | shape_nb ++; |
59 | 61 | ||
60 | file_ptr = NULL; | 62 | file_ptr = NULL; |
61 | getStyles = 0; | 63 | getStyles = 0; |
62 | getAlpha = 0; | 64 | getAlpha = 0; |
63 | } | 65 | } |
64 | 66 | ||
65 | Shape::~Shape() | 67 | Shape::~Shape() |
66 | { | 68 | { |
67 | if (file_ptr) { | 69 | if (file_ptr) { |
68 | free(file_ptr); | 70 | free(file_ptr); |
69 | } | 71 | } |
70 | } | 72 | } |
71 | 73 | ||
72 | void | 74 | void |
73 | Shape::setBoundingBox(Rect rect) | 75 | Shape::setBoundingBox(Rect rect) |
74 | { | 76 | { |
75 | boundary = rect; | 77 | boundary = rect; |
76 | } | 78 | } |
77 | 79 | ||
78 | void | 80 | void |
79 | Shape::getBoundingBox(Rect *bb, DisplayListEntry *e) | 81 | Shape::getBoundingBox(Rect *bb, DisplayListEntry *e) |
80 | { | 82 | { |
81 | *bb = boundary; | 83 | *bb = boundary; |
82 | } | 84 | } |
83 | 85 | ||
84 | int | 86 | int |
85 | Shape::execute(GraphicDevice *gd, Matrix *matrix, Cxform *cxform) | 87 | Shape::execute(GraphicDevice *gd, Matrix *matrix, Cxform *cxform) |
86 | { | 88 | { |
87 | //printf("TagId = %d\n", getTagId()); | 89 | //printf("TagId = %d\n", getTagId()); |
88 | //if (getTagId() != 220) return 0; | 90 | //if (getTagId() != 220) return 0; |
89 | 91 | ||
90 | if (cxform) { | 92 | if (cxform) { |
91 | defaultFillStyle.color = cxform->getColor(gd->getForegroundColor()); | 93 | defaultFillStyle.color = cxform->getColor(gd->getForegroundColor()); |
92 | } else { | 94 | } else { |
93 | defaultFillStyle.color = gd->getForegroundColor(); | 95 | defaultFillStyle.color = gd->getForegroundColor(); |
94 | } | 96 | } |
95 | defaultFillStyle.color.pixel = gd->allocColor(defaultFillStyle.color); | 97 | defaultFillStyle.color.pixel = gd->allocColor(defaultFillStyle.color); |
96 | 98 | ||
97 | drawShape(gd, matrix, cxform, this, ShapeDraw, NULL, 0); | 99 | drawShape(gd, matrix, cxform, this, ShapeDraw, NULL, 0); |
98 | return 0; | 100 | return 0; |
99 | } | 101 | } |
100 | 102 | ||
101 | void | 103 | void |
102 | Shape::getRegion(GraphicDevice *gd, Matrix *matrix, void *id, ScanLineFunc scan_line_func) | 104 | Shape::getRegion(GraphicDevice *gd, Matrix *matrix, void *id, ScanLineFunc scan_line_func) |
103 | { | 105 | { |
104 | gd->setClipping(0); | 106 | gd->setClipping(0); |
105 | drawShape(gd,matrix,0,this,ShapeGetRegion,id,scan_line_func); | 107 | drawShape(gd,matrix,0,this,ShapeGetRegion,id,scan_line_func); |
106 | gd->setClipping(1); | 108 | gd->setClipping(1); |
107 | } | 109 | } |
108 | 110 | ||
109 | /************************************************************************/ | 111 | /************************************************************************/ |
110 | 112 | ||
111 | /* create a new path */ | 113 | /* create a new path */ |
112 | 114 | ||
113 | static void newPath(ShapeParser *shape, | 115 | static void newPath(ShapeParser *shape, |
114 | long x, long y) | 116 | long x, long y) |
115 | { | 117 | { |
116 | Path *p; | 118 | Path *p; |
117 | long x1,y1; | 119 | long x1,y1; |
118 | 120 | ||
119 | p=&shape->curPath; | 121 | p=&shape->curPath; |
120 | 122 | ||
121 | x1 = shape->matrix->getX(x, y); | 123 | x1 = shape->matrix->getX(x, y); |
122 | y1 = shape->matrix->getY(x, y); | 124 | y1 = shape->matrix->getY(x, y); |
123 | 125 | ||
124 | p->lastX = x1; | 126 | p->lastX = x1; |
125 | p->lastY = y1; | 127 | p->lastY = y1; |
126 | 128 | ||
127 | p->nb_edges = 0; | 129 | p->nb_edges = 0; |
128 | p->nb_segments = 0; | 130 | p->nb_segments = 0; |
129 | } | 131 | } |
130 | 132 | ||
131 | 133 | ||
132 | static void addSegment1(ShapeParser *shape, | 134 | static void addSegment1(ShapeParser *shape, |
133 | long x, long y, | 135 | long x, long y, |
134 | FillStyleDef *f0, | 136 | FillStyleDef *f0, |
135 | FillStyleDef *f1, | 137 | FillStyleDef *f1, |
136 | LineStyleDef *l) | 138 | LineStyleDef *l) |
137 | { | 139 | { |
138 | Path *p; | 140 | Path *p; |
139 | p=&shape->curPath; | 141 | p=&shape->curPath; |
140 | 142 | ||
141 | if (l) { | 143 | if (l) { |
142 | /* a line is defined ... it will be drawn later */ | 144 | /* a line is defined ... it will be drawn later */ |
143 | LineSegment *ls; | 145 | LineSegment *ls; |
144 | 146 | ||
145 | ls = new LineSegment; | 147 | ls = new LineSegment; |
146 | if (ls != NULL) { | 148 | if (ls != NULL) { |
147 | ls->l = l; | 149 | ls->l = l; |
148 | ls->x1 = p->lastX; | 150 | ls->x1 = p->lastX; |
149 | ls->y1 = p->lastY; | 151 | ls->y1 = p->lastY; |
150 | ls->x2 = x; | 152 | ls->x2 = x; |
151 | ls->y2 = y; | 153 | ls->y2 = y; |
152 | ls->first = (p->nb_segments == 0); | 154 | ls->first = (p->nb_segments == 0); |
153 | ls->next = NULL; | 155 | ls->next = NULL; |
154 | if (shape->last_line == NULL) { | 156 | if (shape->last_line == NULL) { |
155 | shape->first_line = ls; | 157 | shape->first_line = ls; |
156 | } else { | 158 | } else { |
157 | shape->last_line->next = ls; | 159 | shape->last_line->next = ls; |
158 | } | 160 | } |
159 | shape->last_line = ls; | 161 | shape->last_line = ls; |
160 | } | 162 | } |
161 | } | 163 | } |
162 | 164 | ||
163 | /* anti antialiasing not needed if line */ | 165 | /* anti antialiasing not needed if line */ |
164 | if (!shape->reverse) { | 166 | if (!shape->reverse) { |
165 | shape->gd->addSegment(p->lastX,p->lastY,x,y,f0,f1,l ? 0 : 1); | 167 | shape->gd->addSegment(p->lastX,p->lastY,x,y,f0,f1,l ? 0 : 1); |
166 | } else { | 168 | } else { |
167 | shape->gd->addSegment(p->lastX,p->lastY,x,y,f1,f0,l ? 0 : 1); | 169 | shape->gd->addSegment(p->lastX,p->lastY,x,y,f1,f0,l ? 0 : 1); |
168 | } | 170 | } |
169 | 171 | ||
170 | p->lastX = x; | 172 | p->lastX = x; |
171 | p->lastY = y; | 173 | p->lastY = y; |
172 | 174 | ||
173 | p->nb_segments++; | 175 | p->nb_segments++; |
174 | } | 176 | } |
175 | 177 | ||
176 | 178 | ||
177 | static void addLine(ShapeParser *shape, long x, long y, | 179 | static void addLine(ShapeParser *shape, long x, long y, |
178 | FillStyleDef *f0, | 180 | FillStyleDef *f0, |
179 | FillStyleDef *f1, | 181 | FillStyleDef *f1, |
180 | LineStyleDef *l) | 182 | LineStyleDef *l) |
181 | { | 183 | { |
182 | long x1,y1; | 184 | long x1,y1; |
183 | Path *p; | 185 | Path *p; |
184 | 186 | ||
185 | p=&shape->curPath; | 187 | p=&shape->curPath; |
186 | 188 | ||
187 | x1 = shape->matrix->getX(x, y); | 189 | x1 = shape->matrix->getX(x, y); |
188 | y1 = shape->matrix->getY(x, y); | 190 | y1 = shape->matrix->getY(x, y); |
189 | 191 | ||
190 | addSegment1(shape,x1,y1,f0,f1,l); | 192 | addSegment1(shape,x1,y1,f0,f1,l); |
191 | 193 | ||
192 | p->nb_edges++; | 194 | p->nb_edges++; |
193 | } | 195 | } |
194 | 196 | ||
195 | 197 | ||
196 | // This is based on Divide and Conquer algorithm. | 198 | // This is based on Divide and Conquer algorithm. |
197 | 199 | ||
198 | #define BFRAC_BITS 0 | 200 | #define BFRAC_BITS 0 |
199 | #define BFRAC (1 << BFRAC_BITS) | 201 | #define BFRAC (1 << BFRAC_BITS) |
200 | 202 | ||
201 | static void | 203 | static void |
202 | bezierBuildPoints (ShapeParser *s, | 204 | bezierBuildPoints (ShapeParser *s, |
203 | int subdivisions, | 205 | int subdivisions, |
204 | long a1X, long a1Y, | 206 | long a1X, long a1Y, |
205 | long cX, long cY, | 207 | long cX, long cY, |
206 | long a2X, long a2Y) | 208 | long a2X, long a2Y) |
207 | { | 209 | { |
208 | long c1X,c1Y; | 210 | long c1X,c1Y; |
209 | long c2X,c2Y; | 211 | long c2X,c2Y; |
210 | long X,Y; | 212 | long X,Y; |
211 | long xmin,ymin,xmax,ymax; | 213 | long xmin,ymin,xmax,ymax; |
212 | 214 | ||
213 | if (subdivisions != 0) { | 215 | if (subdivisions != 0) { |
214 | 216 | ||
215 | /* find the bounding box */ | 217 | /* find the bounding box */ |
216 | 218 | ||
217 | if (a1X < cX) { | 219 | if (a1X < cX) { |
218 | xmin = a1X; | 220 | xmin = a1X; |
219 | xmax = cX; | 221 | xmax = cX; |
220 | } else { | 222 | } else { |
221 | xmin = cX; | 223 | xmin = cX; |
222 | xmax = a1X; | 224 | xmax = a1X; |
223 | } | 225 | } |
224 | if (a2X < xmin) xmin = a2X; | 226 | if (a2X < xmin) xmin = a2X; |
225 | if (a2X > xmax) xmax = a2X; | 227 | if (a2X > xmax) xmax = a2X; |
226 | 228 | ||
227 | if (a1Y < cY) { | 229 | if (a1Y < cY) { |
228 | ymin = a1Y; | 230 | ymin = a1Y; |
229 | ymax = cY; | 231 | ymax = cY; |
230 | } else { | 232 | } else { |
231 | ymin = cY; | 233 | ymin = cY; |
232 | ymax = a1Y; | 234 | ymax = a1Y; |
233 | } | 235 | } |
234 | if (a2Y < ymin) ymin = a2Y; | 236 | if (a2Y < ymin) ymin = a2Y; |
235 | if (a2Y > ymax) ymax = a2Y; | 237 | if (a2Y > ymax) ymax = a2Y; |
236 | 238 | ||
237 | if (((xmax - xmin) + (ymax - ymin)) >= (BFRAC*FRAC*2)) { | 239 | if (((xmax - xmin) + (ymax - ymin)) >= (BFRAC*FRAC*2)) { |
238 | // Control point 1 | 240 | // Control point 1 |
239 | c1X = (a1X+cX) >> 1; | 241 | c1X = (a1X+cX) >> 1; |
240 | c1Y = (a1Y+cY) >> 1; | 242 | c1Y = (a1Y+cY) >> 1; |
241 | 243 | ||
242 | // Control point 2 | 244 | // Control point 2 |
243 | c2X = (a2X+cX) >> 1; | 245 | c2X = (a2X+cX) >> 1; |
244 | c2Y = (a2Y+cY) >> 1; | 246 | c2Y = (a2Y+cY) >> 1; |
245 | 247 | ||
246 | // New point | 248 | // New point |
247 | X = (c1X+c2X) >> 1; | 249 | X = (c1X+c2X) >> 1; |
248 | Y = (c1Y+c2Y) >> 1; | 250 | Y = (c1Y+c2Y) >> 1; |
249 | 251 | ||
250 | subdivisions--; | 252 | subdivisions--; |
251 | 253 | ||
252 | bezierBuildPoints(s, subdivisions, | 254 | bezierBuildPoints(s, subdivisions, |
253 | a1X, a1Y, c1X, c1Y, X, Y); | 255 | a1X, a1Y, c1X, c1Y, X, Y); |
254 | bezierBuildPoints(s, subdivisions, | 256 | bezierBuildPoints(s, subdivisions, |
255 | X, Y, c2X, c2Y, a2X, a2Y); | 257 | X, Y, c2X, c2Y, a2X, a2Y); |
256 | 258 | ||
257 | return; | 259 | return; |
258 | } | 260 | } |
259 | } | 261 | } |
260 | 262 | ||
261 | addSegment1(s, (a2X+(BFRAC/2)) >> BFRAC_BITS, | 263 | addSegment1(s, (a2X+(BFRAC/2)) >> BFRAC_BITS, |
262 | (a2Y+(BFRAC/2)) >> BFRAC_BITS, s->f0, s->f1, s->l); | 264 | (a2Y+(BFRAC/2)) >> BFRAC_BITS, s->f0, s->f1, s->l); |
263 | } | 265 | } |
264 | 266 | ||
265 | /* this code is broken, but useful to get something */ | 267 | /* this code is broken, but useful to get something */ |
266 | static void flushPaths(ShapeParser *s) | 268 | static void flushPaths(ShapeParser *s) |
267 | { | 269 | { |
268 | LineSegment *ls; | 270 | LineSegment *ls; |
269 | LineStyleDef *l; | 271 | LineStyleDef *l; |
270 | long nx,ny,nn,w; | 272 | long nx,ny,nn,w; |
271 | GraphicDevice *gd = s->gd; | 273 | GraphicDevice *gd = s->gd; |
272 | 274 | ||
273 | /* draw the filled polygon */ | 275 | /* draw the filled polygon */ |
274 | gd->drawPolygon(); | 276 | gd->drawPolygon(); |
275 | 277 | ||
276 | /* draw the lines */ | 278 | /* draw the lines */ |
277 | ls = s->first_line; | 279 | ls = s->first_line; |
278 | if (ls != NULL) { | 280 | if (ls != NULL) { |
279 | do { | 281 | do { |
280 | l = ls->l; | 282 | l = ls->l; |
281 | 283 | ||
282 | #if 0 | 284 | #if 0 |
283 | printf("line %d %d %d %d width=%d\n", | 285 | printf("line %d %d %d %d width=%d\n", |
284 | ls->x1, ls->y1, ls->x2, ls->y2, l->width); | 286 | ls->x1, ls->y1, ls->x2, ls->y2, l->width); |
285 | #endif | 287 | #endif |
286 | 288 | ||
287 | /* XXX: this width is false, but it is difficult (and expensive) | 289 | /* XXX: this width is false, but it is difficult (and expensive) |
288 | to have the correct one */ | 290 | to have the correct one */ |
289 | w = ABS((long)(s->matrix->a * l->width)); | 291 | w = ABS((long)(s->matrix->a * l->width)); |
290 | 292 | ||
291 | if (w <= ((3*FRAC)/2)) { | 293 | if (w <= ((3*FRAC)/2)) { |
292 | w = FRAC; | 294 | w = FRAC; |
293 | } | 295 | } |
294 | #ifdef THIN_LINES | 296 | #ifdef THIN_LINES |
295 | if (w <= ((3*FRAC)/2)) { | 297 | if (w <= ((3*FRAC)/2)) { |
296 | // draw the thin lines only in shapeAction == shapeDraw | 298 | // draw the thin lines only in shapeAction == shapeDraw |
297 | if (gd->scan_line_func == NULL) { | 299 | if (gd->scan_line_func == NULL) { |
298 | gd->setForegroundColor(l->fillstyle.color); | 300 | gd->setForegroundColor(l->fillstyle.color); |
299 | gd->drawLine(ls->x1, ls->y1, ls->x2, ls->y2, w); | 301 | gd->drawLine(ls->x1, ls->y1, ls->x2, ls->y2, w); |
300 | } | 302 | } |
301 | } else { | 303 | } else { |
302 | #else | 304 | #else |
303 | { | 305 | { |
304 | #endif | 306 | #endif |
305 | /* compute the normal vector */ | 307 | /* compute the normal vector */ |
306 | 308 | ||
307 | nx = -(ls->y2 - ls->y1); | 309 | nx = -(ls->y2 - ls->y1); |
308 | ny = (ls->x2 - ls->x1); | 310 | ny = (ls->x2 - ls->x1); |
309 | 311 | ||
310 | /* normalize & width */ | 312 | /* normalize & width */ |
311 | nn = 2 * (long) sqrt(nx * nx + ny * ny); | 313 | nn = 2 * (long) sqrt(nx * nx + ny * ny); |
312 | 314 | ||
313 | #define UL ls->x1 + nx -ny, ls->y1 + ny +nx | 315 | #define UL ls->x1 + nx -ny, ls->y1 + ny +nx |
314 | #define UR ls->x2 + nx +ny, ls->y2 + ny -nx | 316 | #define UR ls->x2 + nx +ny, ls->y2 + ny -nx |
315 | #define LL ls->x1 - nx -ny, ls->y1 - ny +nx | 317 | #define LL ls->x1 - nx -ny, ls->y1 - ny +nx |
316 | #define LR ls->x2 - nx +ny, ls->y2 - ny -nx | 318 | #define LR ls->x2 - nx +ny, ls->y2 - ny -nx |
317 | 319 | ||
318 | if (nn > 0) { | 320 | if (nn > 0) { |
319 | nx = (nx * w) / nn; | 321 | nx = (nx * w) / nn; |
320 | ny = (ny * w) / nn; | 322 | ny = (ny * w) / nn; |
321 | 323 | ||
322 | /* top segment */ | 324 | /* top segment */ |
323 | gd->addSegment(UL, UR, NULL, &l->fillstyle, 1); | 325 | gd->addSegment(UL, UR, NULL, &l->fillstyle, 1); |
324 | 326 | ||
325 | /* bottom segment */ | 327 | /* bottom segment */ |
326 | gd->addSegment(LL, LR, &l->fillstyle, NULL, 1); | 328 | gd->addSegment(LL, LR, &l->fillstyle, NULL, 1); |
327 | 329 | ||
328 | /* right segment */ | 330 | /* right segment */ |
329 | gd->addSegment(UR, LR, &l->fillstyle, NULL, 1); | 331 | gd->addSegment(UR, LR, &l->fillstyle, NULL, 1); |
330 | 332 | ||
331 | /* left segment */ | 333 | /* left segment */ |
332 | gd->addSegment(UL, LL, NULL, &l->fillstyle, 1); | 334 | gd->addSegment(UL, LL, NULL, &l->fillstyle, 1); |
333 | 335 | ||
334 | /* draw the line polygon */ | 336 | /* draw the line polygon */ |
335 | gd->drawPolygon(); | 337 | gd->drawPolygon(); |
336 | } | 338 | } |
337 | } | 339 | } |
338 | 340 | ||
339 | ls = ls->next; | 341 | ls = ls->next; |
340 | } while (ls != NULL); | 342 | } while (ls != NULL); |
341 | 343 | ||
342 | /* delete the line structures */ | 344 | /* delete the line structures */ |
343 | 345 | ||
344 | ls = s->first_line; | 346 | ls = s->first_line; |
345 | while (ls != NULL) { | 347 | while (ls != NULL) { |
346 | LineSegment *ls1; | 348 | LineSegment *ls1; |
347 | ls1 = ls->next; | 349 | ls1 = ls->next; |
348 | delete ls; | 350 | delete ls; |
349 | ls = ls1; | 351 | ls = ls1; |
350 | } | 352 | } |
351 | 353 | ||
352 | /* reset the line pointers */ | 354 | /* reset the line pointers */ |
353 | s->first_line = NULL; | 355 | s->first_line = NULL; |
354 | s->last_line = NULL; | 356 | s->last_line = NULL; |
355 | } | 357 | } |
356 | } | 358 | } |
357 | 359 | ||
358 | 360 | ||
359 | static void addBezier(ShapeParser *shape, | 361 | static void addBezier(ShapeParser *shape, |
360 | long ctrlX1, long ctrlY1, | 362 | long ctrlX1, long ctrlY1, |
361 | long newX1, long newY1, | 363 | long newX1, long newY1, |
362 | FillStyleDef *f0, | 364 | FillStyleDef *f0, |
363 | FillStyleDef *f1, | 365 | FillStyleDef *f1, |
364 | LineStyleDef *l) | 366 | LineStyleDef *l) |
365 | { | 367 | { |
366 | long newX,newY,ctrlX,ctrlY; | 368 | long newX,newY,ctrlX,ctrlY; |
367 | Path *p; | 369 | Path *p; |
368 | 370 | ||
369 | p=&shape->curPath; | 371 | p=&shape->curPath; |
370 | 372 | ||
371 | /* note: we do the matrix multiplication before calculating the | 373 | /* note: we do the matrix multiplication before calculating the |
372 | bezier points (faster !) */ | 374 | bezier points (faster !) */ |
373 | 375 | ||
374 | ctrlX = shape->matrix->getX(ctrlX1, ctrlY1); | 376 | ctrlX = shape->matrix->getX(ctrlX1, ctrlY1); |
375 | ctrlY = shape->matrix->getY(ctrlX1, ctrlY1); | 377 | ctrlY = shape->matrix->getY(ctrlX1, ctrlY1); |
376 | newX = shape->matrix->getX(newX1, newY1); | 378 | newX = shape->matrix->getX(newX1, newY1); |
377 | newY = shape->matrix->getY(newX1, newY1); | 379 | newY = shape->matrix->getY(newX1, newY1); |
378 | 380 | ||
379 | shape->f0 = f0; | 381 | shape->f0 = f0; |
380 | shape->f1 = f1; | 382 | shape->f1 = f1; |
381 | shape->l = l; | 383 | shape->l = l; |
382 | 384 | ||
383 | bezierBuildPoints(shape, 3, | 385 | bezierBuildPoints(shape, 3, |
384 | p->lastX<<BFRAC_BITS,p->lastY<<BFRAC_BITS, | 386 | p->lastX<<BFRAC_BITS,p->lastY<<BFRAC_BITS, |
385 | ctrlX<<BFRAC_BITS,ctrlY<<BFRAC_BITS, | 387 | ctrlX<<BFRAC_BITS,ctrlY<<BFRAC_BITS, |
386 | newX<<BFRAC_BITS,newY<<BFRAC_BITS); | 388 | newX<<BFRAC_BITS,newY<<BFRAC_BITS); |
387 | 389 | ||
388 | p->nb_edges++; | 390 | p->nb_edges++; |
389 | } | 391 | } |
390 | 392 | ||
391 | /***********************************************************************/ | 393 | /***********************************************************************/ |
392 | 394 | ||
393 | 395 | ||
394 | /* bit parser */ | 396 | /* bit parser */ |
395 | 397 | ||
396 | static void InitBitParser(struct BitParser *b,U8 *buf) | 398 | static void InitBitParser(struct BitParser *b,U8 *buf) |
397 | { | 399 | { |
398 | b->ptr = buf; | 400 | b->ptr = buf; |
399 | } | 401 | } |
400 | 402 | ||
401 | static void InitBits(struct BitParser *b) | 403 | static void InitBits(struct BitParser *b) |
402 | { | 404 | { |
403 | // Reset the bit position and buffer. | 405 | // Reset the bit position and buffer. |
404 | b->m_bitPos = 0; | 406 | b->m_bitPos = 0; |
405 | b->m_bitBuf = 0; | 407 | b->m_bitBuf = 0; |
406 | } | 408 | } |
407 | 409 | ||
408 | 410 | ||
409 | 411 | ||
410 | static inline U8 GetByte(struct BitParser *b) | 412 | static inline U8 GetByte(struct BitParser *b) |
411 | { | 413 | { |
412 | U8 v; | 414 | U8 v; |
413 | v = *b->ptr++; | 415 | v = *b->ptr++; |
414 | return v; | 416 | return v; |
415 | } | 417 | } |
416 | 418 | ||
417 | static inline U16 GetWord(struct BitParser *b) | 419 | static inline U16 GetWord(struct BitParser *b) |
418 | { | 420 | { |
419 | U8 *s; | 421 | U8 *s; |
420 | U16 v; | 422 | U16 v; |
421 | s = b->ptr; | 423 | s = b->ptr; |
422 | v = s[0] | ((U16) s[1] << 8); | 424 | v = s[0] | ((U16) s[1] << 8); |
423 | b->ptr = s + 2; | 425 | b->ptr = s + 2; |
424 | return v; | 426 | return v; |
425 | } | 427 | } |
426 | 428 | ||
427 | static inline U32 GetDWord(struct BitParser *b) | 429 | static inline U32 GetDWord(struct BitParser *b) |
428 | { | 430 | { |
429 | U32 v; | 431 | U32 v; |
430 | U8 * s = b->ptr; | 432 | U8 * s = b->ptr; |
431 | v = (U32) s[0] | ((U32) s[1] << 8) | | 433 | v = (U32) s[0] | ((U32) s[1] << 8) | |
432 | ((U32) s[2] << 16) | ((U32) s [3] << 24); | 434 | ((U32) s[2] << 16) | ((U32) s [3] << 24); |
433 | b->ptr = s + 4; | 435 | b->ptr = s + 4; |
434 | return v; | 436 | return v; |
435 | } | 437 | } |
436 | 438 | ||
437 | static inline U32 GetBit (struct BitParser *b) | 439 | static inline U32 GetBit (struct BitParser *b) |
438 | { | 440 | { |
439 | U32 v; | 441 | U32 v; |
440 | S32 m_bitPos = b->m_bitPos; | 442 | S32 m_bitPos = b->m_bitPos; |
441 | U32 m_bitBuf = b->m_bitBuf; | 443 | U32 m_bitBuf = b->m_bitBuf; |
442 | 444 | ||
443 | if (m_bitPos == 0) { | 445 | if (m_bitPos == 0) { |
444 | m_bitBuf = (U32)(*b->ptr++) << 24; | 446 | m_bitBuf = (U32)(*b->ptr++) << 24; |
445 | m_bitPos = 8; | 447 | m_bitPos = 8; |
446 | } | 448 | } |
447 | 449 | ||
448 | v = (m_bitBuf >> 31); | 450 | v = (m_bitBuf >> 31); |
449 | 451 | ||
450 | m_bitPos--; | 452 | m_bitPos--; |
451 | m_bitBuf <<= 1; | 453 | m_bitBuf <<= 1; |
452 | 454 | ||
453 | b->m_bitPos = m_bitPos; | 455 | b->m_bitPos = m_bitPos; |
454 | b->m_bitBuf = m_bitBuf; | 456 | b->m_bitBuf = m_bitBuf; |
455 | 457 | ||
456 | return v; | 458 | return v; |
457 | } | 459 | } |
458 | 460 | ||
459 | static inline U32 GetBits (struct BitParser *b, int n) | 461 | static inline U32 GetBits (struct BitParser *b, int n) |
460 | { | 462 | { |
461 | U32 v; | 463 | U32 v; |
462 | S32 m_bitPos = b->m_bitPos; | 464 | S32 m_bitPos = b->m_bitPos; |
463 | U32 m_bitBuf = b->m_bitBuf; | 465 | U32 m_bitBuf = b->m_bitBuf; |
464 | 466 | ||
465 | if (n == 0) | 467 | if (n == 0) |
466 | return 0; | 468 | return 0; |
467 | 469 | ||
468 | while (m_bitPos < n) { | 470 | while (m_bitPos < n) { |
469 | m_bitBuf |= (U32)(*b->ptr++) << (24 - m_bitPos); | 471 | m_bitBuf |= (U32)(*b->ptr++) << (24 - m_bitPos); |
470 | m_bitPos += 8; | 472 | m_bitPos += 8; |
471 | } | 473 | } |
472 | 474 | ||
473 | v = m_bitBuf >> (32 - n); | 475 | v = m_bitBuf >> (32 - n); |
474 | m_bitBuf <<= n; | 476 | m_bitBuf <<= n; |
475 | m_bitPos -= n; | 477 | m_bitPos -= n; |
476 | 478 | ||
477 | b->m_bitPos = m_bitPos; | 479 | b->m_bitPos = m_bitPos; |
478 | b->m_bitBuf = m_bitBuf; | 480 | b->m_bitBuf = m_bitBuf; |
479 | return v; | 481 | return v; |
480 | } | 482 | } |
481 | 483 | ||
482 | // Get n bits from the string with sign extension. | 484 | // Get n bits from the string with sign extension. |
483 | static inline S32 GetSBits (struct BitParser *b,S32 n) | 485 | static inline S32 GetSBits (struct BitParser *b,S32 n) |
484 | { | 486 | { |
485 | // Get the number as an unsigned value. | 487 | // Get the number as an unsigned value. |
486 | S32 v = (S32) GetBits(b,n); | 488 | S32 v = (S32) GetBits(b,n); |
487 | 489 | ||
488 | // Is the number negative? | 490 | // Is the number negative? |
489 | if (v & (1L << (n - 1))) | 491 | if (v & (1L << (n - 1))) |
490 | { | 492 | { |
491 | // Yes. Extend the sign. | 493 | // Yes. Extend the sign. |
492 | v |= -1L << n; | 494 | v |= -1L << n; |
493 | } | 495 | } |
494 | 496 | ||
495 | return v; | 497 | return v; |
496 | } | 498 | } |
497 | 499 | ||
498 | 500 | ||
499 | 501 | ||
500 | /************************************************************************/ | 502 | /************************************************************************/ |
501 | 503 | ||
502 | static void GetMatrix(BitParser *b, Matrix* mat) | 504 | static void GetMatrix(BitParser *b, Matrix* mat) |
503 | { | 505 | { |
504 | InitBits(b); | 506 | InitBits(b); |
505 | 507 | ||
506 | // Scale terms | 508 | // Scale terms |
507 | if (GetBit(b)) | 509 | if (GetBit(b)) |
508 | { | 510 | { |
509 | int nBits = (int) GetBits(b,5); | 511 | int nBits = (int) GetBits(b,5); |
510 | mat->a = (float)(GetSBits(b,nBits))/(float)0x10000; | 512 | mat->a = (float)(GetSBits(b,nBits))/(float)0x10000; |
511 | mat->d = (float)(GetSBits(b,nBits))/(float)0x10000; | 513 | mat->d = (float)(GetSBits(b,nBits))/(float)0x10000; |
512 | } | 514 | } |
513 | else | 515 | else |
514 | { | 516 | { |
515 | mat->a = mat->d = 1.0; | 517 | mat->a = mat->d = 1.0; |
516 | } | 518 | } |
517 | 519 | ||
518 | // Rotate/skew terms | 520 | // Rotate/skew terms |
519 | if (GetBit(b)) | 521 | if (GetBit(b)) |
520 | { | 522 | { |
521 | int nBits = (int)GetBits(b,5); | 523 | int nBits = (int)GetBits(b,5); |
522 | mat->c = (float)(GetSBits(b,nBits))/(float)0x10000; | 524 | mat->c = (float)(GetSBits(b,nBits))/(float)0x10000; |
523 | mat->b = (float)(GetSBits(b,nBits))/(float)0x10000; | 525 | mat->b = (float)(GetSBits(b,nBits))/(float)0x10000; |
524 | } | 526 | } |
525 | else | 527 | else |
526 | { | 528 | { |
527 | mat->b = mat->c = 0.0; | 529 | mat->b = mat->c = 0.0; |
528 | } | 530 | } |
529 | 531 | ||
530 | // Translate terms | 532 | // Translate terms |
531 | int nBits = (int) GetBits(b,5); | 533 | int nBits = (int) GetBits(b,5); |
532 | mat->tx = GetSBits(b,nBits); | 534 | mat->tx = GetSBits(b,nBits); |
533 | mat->ty = GetSBits(b,nBits); | 535 | mat->ty = GetSBits(b,nBits); |
534 | } | 536 | } |
535 | 537 | ||
536 | static FillStyleDef * ParseFillStyle(ShapeParser *shape, long *n, long getAlpha) | 538 | static FillStyleDef * ParseFillStyle(ShapeParser *shape, long *n, long getAlpha) |
537 | { | 539 | { |
538 | BitParser *b = &shape->bit_parser; | 540 | BitParser *b = &shape->bit_parser; |
539 | FillStyleDef *defs; | 541 | FillStyleDef *defs; |
540 | U16 i = 0; | 542 | U16 i = 0; |
541 | 543 | ||
542 | // Get the number of fills. | 544 | // Get the number of fills. |
543 | U16 nFills = GetByte(b); | 545 | U16 nFills = GetByte(b); |
544 | 546 | ||
545 | // Do we have a larger number? | 547 | // Do we have a larger number? |
546 | if (nFills == 255) | 548 | if (nFills == 255) |
547 | { | 549 | { |
548 | // Get the larger number. | 550 | // Get the larger number. |
549 | nFills = GetWord(b); | 551 | nFills = GetWord(b); |
550 | } | 552 | } |
551 | 553 | ||
552 | *n = nFills; | 554 | *n = nFills; |
553 | defs = new FillStyleDef[ nFills ]; | 555 | defs = new FillStyleDef[ nFills ]; |
554 | if (defs == NULL) return NULL; | 556 | if (defs == NULL) return NULL; |
555 | 557 | ||
556 | // Get each of the fill style. | 558 | // Get each of the fill style. |
557 | for (i = 0; i < nFills; i++) | 559 | for (i = 0; i < nFills; i++) |
558 | { | 560 | { |
559 | U16 fillStyle = GetByte(b); | 561 | U16 fillStyle = GetByte(b); |
560 | 562 | ||
561 | defs[i].type = (FillType) fillStyle; | 563 | defs[i].type = (FillType) fillStyle; |
562 | 564 | ||
563 | if (fillStyle & 0x10) | 565 | if (fillStyle & 0x10) |
564 | { | 566 | { |
565 | defs[i].type = (FillType) (fillStyle & 0x12); | 567 | defs[i].type = (FillType) (fillStyle & 0x12); |
566 | 568 | ||
567 | // Get the gradient matrix. | 569 | // Get the gradient matrix. |
568 | GetMatrix(b,&(defs[i].matrix)); | 570 | GetMatrix(b,&(defs[i].matrix)); |
569 | 571 | ||
570 | // Get the number of colors. | 572 | // Get the number of colors. |
571 | defs[i].gradient.nbGradients = GetByte(b); | 573 | defs[i].gradient.nbGradients = GetByte(b); |
572 | 574 | ||
573 | // Get each of the colors. | 575 | // Get each of the colors. |
574 | for (U16 j = 0; j < defs[i].gradient.nbGradients; j++) | 576 | for (U16 j = 0; j < defs[i].gradient.nbGradients; j++) |
575 | { | 577 | { |
576 | defs[i].gradient.ratio[j] = GetByte(b); | 578 | defs[i].gradient.ratio[j] = GetByte(b); |
577 | defs[i].gradient.color[j].red = GetByte(b); | 579 | defs[i].gradient.color[j].red = GetByte(b); |
578 | defs[i].gradient.color[j].green = GetByte(b); | 580 | defs[i].gradient.color[j].green = GetByte(b); |
579 | defs[i].gradient.color[j].blue = GetByte(b); | 581 | defs[i].gradient.color[j].blue = GetByte(b); |
580 | if (getAlpha) { | 582 | if (getAlpha) { |
581 | defs[i].gradient.color[j].alpha = GetByte(b); | 583 | defs[i].gradient.color[j].alpha = GetByte(b); |
582 | } else { | 584 | } else { |
583 | defs[i].gradient.color[j].alpha = ALPHA_OPAQUE; | 585 | defs[i].gradient.color[j].alpha = ALPHA_OPAQUE; |
584 | } | 586 | } |
585 | } | 587 | } |
586 | } | 588 | } |
587 | else if (fillStyle & 0x40) | 589 | else if (fillStyle & 0x40) |
588 | { | 590 | { |
589 | defs[i].type = (FillType) (fillStyle & 0x41); | 591 | defs[i].type = (FillType) (fillStyle & 0x41); |
590 | 592 | ||
591 | // Get the bitmapId | 593 | // Get the bitmapId |
592 | defs[i].bitmap = (Bitmap *)shape->dict->getCharacter(GetWord(b)); | 594 | defs[i].bitmap = (Bitmap *)shape->dict->getCharacter(GetWord(b)); |
593 | // Get the bitmap matrix. | 595 | // Get the bitmap matrix. |
594 | GetMatrix(b,&(defs[i].matrix)); | 596 | GetMatrix(b,&(defs[i].matrix)); |
595 | } | 597 | } |
596 | else | 598 | else |
597 | { | 599 | { |
598 | defs[i].type = (FillType) 0; | 600 | defs[i].type = (FillType) 0; |
599 | 601 | ||
600 | // A solid color | 602 | // A solid color |
601 | defs[i].color.red = GetByte(b); | 603 | defs[i].color.red = GetByte(b); |
602 | defs[i].color.green = GetByte(b); | 604 | defs[i].color.green = GetByte(b); |
603 | defs[i].color.blue = GetByte(b); | 605 | defs[i].color.blue = GetByte(b); |
604 | if (getAlpha) { | 606 | if (getAlpha) { |
605 | defs[i].color.alpha = GetByte(b); | 607 | defs[i].color.alpha = GetByte(b); |
606 | } else { | 608 | } else { |
607 | defs[i].color.alpha = ALPHA_OPAQUE; | 609 | defs[i].color.alpha = ALPHA_OPAQUE; |
608 | } | 610 | } |
609 | } | 611 | } |
610 | } | 612 | } |
611 | 613 | ||
612 | return defs; | 614 | return defs; |
613 | } | 615 | } |
614 | 616 | ||
615 | static LineStyleDef * ParseLineStyle(ShapeParser *shape, long *n, long getAlpha) | 617 | static LineStyleDef * ParseLineStyle(ShapeParser *shape, long *n, long getAlpha) |
616 | { | 618 | { |
617 | BitParser *b = &shape->bit_parser; | 619 | BitParser *b = &shape->bit_parser; |
618 | LineStyleDef *defs,*def; | 620 | LineStyleDef *defs,*def; |
619 | FillStyleDef *f; | 621 | FillStyleDef *f; |
620 | long i; | 622 | long i; |
621 | 623 | ||
622 | // Get the number of lines. | 624 | // Get the number of lines. |
623 | U16 nLines = GetByte(b); | 625 | U16 nLines = GetByte(b); |
624 | 626 | ||
625 | // Do we have a larger number? | 627 | // Do we have a larger number? |
626 | if (nLines == 255) | 628 | if (nLines == 255) |
627 | { | 629 | { |
628 | // Get the larger number. | 630 | // Get the larger number. |
629 | nLines = GetWord(b); | 631 | nLines = GetWord(b); |
630 | } | 632 | } |
631 | 633 | ||
632 | *n = nLines; | 634 | *n = nLines; |
633 | defs = new LineStyleDef[ nLines ]; | 635 | defs = new LineStyleDef[ nLines ]; |
634 | if (defs == NULL) return NULL; | 636 | if (defs == NULL) return NULL; |
635 | 637 | ||
636 | // Get each of the line styles. | 638 | // Get each of the line styles. |
637 | for (i = 0; i < nLines; i++) | 639 | for (i = 0; i < nLines; i++) |
638 | { | 640 | { |
639 | def=&defs[i]; | 641 | def=&defs[i]; |
640 | def->width = GetWord(b); | 642 | def->width = GetWord(b); |
641 | def->color.red = GetByte(b); | 643 | def->color.red = GetByte(b); |
642 | def->color.green = GetByte(b); | 644 | def->color.green = GetByte(b); |
643 | def->color.blue = GetByte(b); | 645 | def->color.blue = GetByte(b); |
644 | if (getAlpha) { | 646 | if (getAlpha) { |
645 | def->color.alpha = GetByte(b); | 647 | def->color.alpha = GetByte(b); |
646 | } else { | 648 | } else { |
647 | def->color.alpha = ALPHA_OPAQUE; | 649 | def->color.alpha = ALPHA_OPAQUE; |
648 | } | 650 | } |
649 | 651 | ||
650 | f=&def->fillstyle; | 652 | f=&def->fillstyle; |
651 | f->type = f_Solid; | 653 | f->type = f_Solid; |
652 | f->color = def->color; | 654 | f->color = def->color; |
653 | if (shape->cxform) { | 655 | if (shape->cxform) { |
654 | f->color = shape->cxform->getColor(f->color); | 656 | f->color = shape->cxform->getColor(f->color); |
655 | } | 657 | } |
656 | f->color.pixel = shape->gd->allocColor(f->color); | 658 | f->color.pixel = shape->gd->allocColor(f->color); |
657 | } | 659 | } |
658 | 660 | ||
659 | return defs; | 661 | return defs; |
660 | } | 662 | } |
661 | 663 | ||
662 | /* 0 = end of shape */ | 664 | /* 0 = end of shape */ |
663 | static int ParseShapeRecord(ShapeParser *shape, ShapeRecord *sr, long getAlpha) | 665 | static int ParseShapeRecord(ShapeParser *shape, ShapeRecord *sr, long getAlpha) |
664 | { | 666 | { |
665 | BitParser *b = &shape->bit_parser; | 667 | BitParser *b = &shape->bit_parser; |
666 | 668 | ||
667 | // Determine if this is an edge. | 669 | // Determine if this is an edge. |
668 | BOOL isEdge = (BOOL) GetBit(b); | 670 | BOOL isEdge = (BOOL) GetBit(b); |
669 | 671 | ||
670 | if (!isEdge) | 672 | if (!isEdge) |
671 | { | 673 | { |
672 | // Handle a state change | 674 | // Handle a state change |
673 | U16 flags = (U16) GetBits(b,5); | 675 | U16 flags = (U16) GetBits(b,5); |
674 | 676 | ||
675 | // Are we at the end? | 677 | // Are we at the end? |
676 | if (flags == 0) | 678 | if (flags == 0) |
677 | { | 679 | { |
678 | // End of shape | 680 | // End of shape |
679 | return 0; | 681 | return 0; |
680 | } | 682 | } |
681 | 683 | ||
682 | sr->type = shapeNonEdge; | 684 | sr->type = shapeNonEdge; |
683 | sr->flags = (ShapeFlags)flags; | 685 | sr->flags = (ShapeFlags)flags; |
684 | 686 | ||
685 | // Process a move to. | 687 | // Process a move to. |
686 | if (flags & flagsMoveTo) | 688 | if (flags & flagsMoveTo) |
687 | { | 689 | { |
688 | U16 nBits = (U16) GetBits(b,5); | 690 | U16 nBits = (U16) GetBits(b,5); |
689 | sr->x = GetSBits(b,nBits); | 691 | sr->x = GetSBits(b,nBits); |
690 | sr->y = GetSBits(b,nBits); | 692 | sr->y = GetSBits(b,nBits); |
691 | } | 693 | } |
692 | 694 | ||
693 | // Get new fill info. | 695 | // Get new fill info. |
694 | if (flags & flagsFill0) | 696 | if (flags & flagsFill0) |
695 | { | 697 | { |
696 | sr->fillStyle0 = GetBits(b,shape->m_nFillBits); | 698 | sr->fillStyle0 = GetBits(b,shape->m_nFillBits); |
697 | } | 699 | } |
698 | if (flags & flagsFill1) | 700 | if (flags & flagsFill1) |
699 | { | 701 | { |
700 | sr->fillStyle1 = GetBits(b,shape->m_nFillBits); | 702 | sr->fillStyle1 = GetBits(b,shape->m_nFillBits); |
701 | } | 703 | } |
702 | 704 | ||
703 | // Get new line info | 705 | // Get new line info |
704 | if (flags & flagsLine) | 706 | if (flags & flagsLine) |
705 | { | 707 | { |
706 | sr->lineStyle = GetBits(b,shape->m_nLineBits); | 708 | sr->lineStyle = GetBits(b,shape->m_nLineBits); |
707 | } | 709 | } |
708 | 710 | ||
709 | // Check to get a new set of styles for a new shape layer. | 711 | // Check to get a new set of styles for a new shape layer. |
710 | if (flags & flagsNewStyles) | 712 | if (flags & flagsNewStyles) |
711 | { | 713 | { |
712 | FillStyleDef *fillDefs; | 714 | FillStyleDef *fillDefs; |
713 | LineStyleDef *lineDefs; | 715 | LineStyleDef *lineDefs; |
714 | long n; | 716 | long n; |
715 | 717 | ||
716 | // Parse the style. | 718 | // Parse the style. |
717 | fillDefs = ParseFillStyle(shape, &n, getAlpha); | 719 | fillDefs = ParseFillStyle(shape, &n, getAlpha); |
718 | if (fillDefs == NULL) return 0; | 720 | if (fillDefs == NULL) return 0; |
719 | 721 | ||
720 | sr->newFillStyles = fillDefs; | 722 | sr->newFillStyles = fillDefs; |
721 | sr->nbNewFillStyles = n; | 723 | sr->nbNewFillStyles = n; |
722 | 724 | ||
723 | lineDefs = ParseLineStyle(shape, &n, getAlpha); | 725 | lineDefs = ParseLineStyle(shape, &n, getAlpha); |
724 | if (lineDefs == NULL) return 0; | 726 | if (lineDefs == NULL) return 0; |
725 | 727 | ||
726 | sr->newLineStyles = lineDefs; | 728 | sr->newLineStyles = lineDefs; |
727 | sr->nbNewLineStyles = n; | 729 | sr->nbNewLineStyles = n; |
728 | 730 | ||
729 | InitBits(b);// Bug ! | 731 | InitBits(b);// Bug ! |
730 | 732 | ||
731 | // Reset. | 733 | // Reset. |
732 | shape->m_nFillBits = (U16) GetBits(b,4); | 734 | shape->m_nFillBits = (U16) GetBits(b,4); |
733 | shape->m_nLineBits = (U16) GetBits(b,4); | 735 | shape->m_nLineBits = (U16) GetBits(b,4); |
734 | } | 736 | } |
735 | 737 | ||
736 | //if (flags & flagsEndShape) | 738 | //if (flags & flagsEndShape) |
737 | //printf("\tEnd of shape.\n\n"); | 739 | //printf("\tEnd of shape.\n\n"); |
738 | 740 | ||
739 | return flags & flagsEndShape ? 0 : 1; | 741 | return flags & flagsEndShape ? 0 : 1; |
740 | } | 742 | } |
741 | else | 743 | else |
742 | { | 744 | { |
743 | if (GetBit(b)) | 745 | if (GetBit(b)) |
744 | { | 746 | { |
745 | sr->type = shapeLine; | 747 | sr->type = shapeLine; |
746 | 748 | ||
747 | // Handle a line | 749 | // Handle a line |
748 | U16 nBits = (U16) GetBits(b,4) + 2;// nBits is biased by 2 | 750 | U16 nBits = (U16) GetBits(b,4) + 2;// nBits is biased by 2 |
749 | 751 | ||
750 | // Save the deltas | 752 | // Save the deltas |
751 | if (GetBit(b)) | 753 | if (GetBit(b)) |
752 | { | 754 | { |
753 | // Handle a general line. | 755 | // Handle a general line. |
754 | sr->dX = GetSBits(b,nBits); | 756 | sr->dX = GetSBits(b,nBits); |
755 | sr->dY = GetSBits(b,nBits); | 757 | sr->dY = GetSBits(b,nBits); |
756 | } | 758 | } |
757 | else | 759 | else |
758 | { | 760 | { |
759 | // Handle a vert or horiz line. | 761 | // Handle a vert or horiz line. |
760 | if (GetBit(b)) | 762 | if (GetBit(b)) |
761 | { | 763 | { |
762 | // Vertical line | 764 | // Vertical line |
763 | sr->dY = GetSBits(b,nBits); | 765 | sr->dY = GetSBits(b,nBits); |
764 | sr->dX = 0; | 766 | sr->dX = 0; |
765 | } | 767 | } |
766 | else | 768 | else |
767 | { | 769 | { |
768 | // Horizontal line | 770 | // Horizontal line |
769 | sr->dX = GetSBits(b,nBits); | 771 | sr->dX = GetSBits(b,nBits); |
770 | sr->dY = 0; | 772 | sr->dY = 0; |
771 | } | 773 | } |
772 | } | 774 | } |
773 | } | 775 | } |
774 | else | 776 | else |
775 | { | 777 | { |
776 | sr->type = shapeCurve; | 778 | sr->type = shapeCurve; |
777 | 779 | ||
778 | // Handle a curve | 780 | // Handle a curve |
779 | U16 nBits = (U16) GetBits(b,4) + 2;// nBits is biased by 2 | 781 | U16 nBits = (U16) GetBits(b,4) + 2;// nBits is biased by 2 |
780 | 782 | ||
781 | // Get the control | 783 | // Get the control |
782 | sr->ctrlX = GetSBits(b,nBits); | 784 | sr->ctrlX = GetSBits(b,nBits); |
783 | sr->ctrlY = GetSBits(b,nBits); | 785 | sr->ctrlY = GetSBits(b,nBits); |
784 | 786 | ||
785 | // Get the anchor | 787 | // Get the anchor |
786 | sr->anchorX = GetSBits(b,nBits); | 788 | sr->anchorX = GetSBits(b,nBits); |
787 | sr->anchorY = GetSBits(b,nBits); | 789 | sr->anchorY = GetSBits(b,nBits); |
788 | } | 790 | } |
789 | 791 | ||
790 | return 1; | 792 | return 1; |
791 | } | 793 | } |
792 | } | 794 | } |
793 | 795 | ||
794 | static void drawShape(GraphicDevice *gd, Matrix *matrix1, Cxform *cxform, Shape *shape, | 796 | static void drawShape(GraphicDevice *gd, Matrix *matrix1, Cxform *cxform, Shape *shape, |
795 | ShapeAction shapeAction, void *id,ScanLineFunc scan_line_func) | 797 | ShapeAction shapeAction, void *id,ScanLineFunc scan_line_func) |
796 | { | 798 | { |
797 | LineStyleDef *l; | 799 | LineStyleDef *l; |
798 | FillStyleDef *f0; | 800 | FillStyleDef *f0; |
799 | FillStyleDef *f1; | 801 | FillStyleDef *f1; |
800 | ShapeRecord sr1,*sr = &sr1; | 802 | ShapeRecord sr1,*sr = &sr1; |
801 | int firstPoint; | 803 | int firstPoint; |
802 | long lastX,lastY; | 804 | long lastX,lastY; |
803 | LineStyleDef *curLineStyle; | 805 | LineStyleDef *curLineStyle; |
804 | long curNbLineStyles; | 806 | long curNbLineStyles; |
805 | FillStyleDef *curFillStyle; | 807 | FillStyleDef *curFillStyle; |
806 | long curNbFillStyles; | 808 | long curNbFillStyles; |
807 | StyleList *sl; | 809 | StyleList *sl; |
808 | ShapeParser sp1,*sp=&sp1; | 810 | ShapeParser sp1,*sp=&sp1; |
809 | BitParser *b; | 811 | BitParser *b; |
810 | Matrix mat,*matrix; | 812 | Matrix mat,*matrix; |
811 | 813 | ||
812 | mat = (*gd->adjust) * (*matrix1); | 814 | mat = (*gd->adjust) * (*matrix1); |
813 | matrix = &mat; | 815 | matrix = &mat; |
814 | 816 | ||
815 | sp->reverse = (mat.a * mat.d) < 0; | 817 | sp->reverse = (mat.a * mat.d) < 0; |
816 | 818 | ||
817 | curLineStyle = NULL; | 819 | curLineStyle = NULL; |
818 | curNbLineStyles = 0; | 820 | curNbLineStyles = 0; |
819 | curFillStyle = NULL; | 821 | curFillStyle = NULL; |
820 | curNbFillStyles = 0; | 822 | curNbFillStyles = 0; |
821 | sp->style_list = NULL; | 823 | sp->style_list = NULL; |
822 | 824 | ||
823 | sp->shape = shape; | 825 | sp->shape = shape; |
824 | sp->gd = gd; | 826 | sp->gd = gd; |
825 | sp->matrix = matrix; | 827 | sp->matrix = matrix; |
826 | sp->cxform = cxform; | 828 | sp->cxform = cxform; |
827 | sp->dict = shape->dict; | 829 | sp->dict = shape->dict; |
828 | 830 | ||
829 | if (shapeAction == ShapeGetRegion) { | 831 | if (shapeAction == ShapeGetRegion) { |
830 | gd->scan_line_func = scan_line_func; | 832 | gd->scan_line_func = scan_line_func; |
831 | gd->scan_line_func_id = id; | 833 | gd->scan_line_func_id = id; |
832 | } else { | 834 | } else { |
833 | gd->scan_line_func = NULL; | 835 | gd->scan_line_func = NULL; |
834 | } | 836 | } |
835 | 837 | ||
836 | b = &sp->bit_parser; | 838 | b = &sp->bit_parser; |
837 | InitBitParser(b,shape->file_ptr); | 839 | InitBitParser(b,shape->file_ptr); |
838 | 840 | ||
839 | if (shape->getStyles) { | 841 | if (shape->getStyles) { |
840 | // ShapeWithStyle | 842 | // ShapeWithStyle |
841 | curFillStyle = ParseFillStyle(sp, &curNbFillStyles, shape->getAlpha); | 843 | curFillStyle = ParseFillStyle(sp, &curNbFillStyles, shape->getAlpha); |
842 | if (curFillStyle == NULL) return; | 844 | if (curFillStyle == NULL) return; |
843 | 845 | ||
844 | curLineStyle = ParseLineStyle(sp, &curNbLineStyles, shape->getAlpha); | 846 | curLineStyle = ParseLineStyle(sp, &curNbLineStyles, shape->getAlpha); |
845 | if (curLineStyle == NULL) return; | 847 | if (curLineStyle == NULL) return; |
846 | 848 | ||
847 | sl = new StyleList; | 849 | sl = new StyleList; |
848 | if (sl == NULL) return; | 850 | if (sl == NULL) return; |
849 | 851 | ||
850 | sl->next = NULL; | 852 | sl->next = NULL; |
851 | sl->newFillStyles = curFillStyle; | 853 | sl->newFillStyles = curFillStyle; |
852 | sl->nbNewFillStyles = curNbFillStyles; | 854 | sl->nbNewFillStyles = curNbFillStyles; |
853 | sl->newLineStyles = curLineStyle; | 855 | sl->newLineStyles = curLineStyle; |
854 | sl->nbNewLineStyles = curNbLineStyles; | 856 | sl->nbNewLineStyles = curNbLineStyles; |
855 | 857 | ||
856 | sp->style_list = sl; | 858 | sp->style_list = sl; |
857 | 859 | ||
858 | if (shapeAction == ShapeDraw) { | 860 | if (shapeAction == ShapeDraw) { |
859 | prepareStyles(gd, matrix, cxform, curFillStyle, curNbFillStyles); | 861 | prepareStyles(gd, matrix, cxform, curFillStyle, curNbFillStyles); |
860 | } | 862 | } |
861 | } | 863 | } |
862 | 864 | ||
863 | InitBits(b); | 865 | InitBits(b); |
864 | sp->m_nFillBits = (U16) GetBits(b,4); | 866 | sp->m_nFillBits = (U16) GetBits(b,4); |
865 | sp->m_nLineBits = (U16) GetBits(b,4); | 867 | sp->m_nLineBits = (U16) GetBits(b,4); |
866 | 868 | ||
867 | l = 0; | 869 | l = 0; |
868 | f0 = 0; | 870 | f0 = 0; |
869 | f1 = 0; | 871 | f1 = 0; |
870 | firstPoint = 1; | 872 | firstPoint = 1; |
871 | lastX = 0; | 873 | lastX = 0; |
872 | lastY = 0; | 874 | lastY = 0; |
873 | sp->curPath.nb_edges = 0; | 875 | sp->curPath.nb_edges = 0; |
874 | sp->first_line = NULL; | 876 | sp->first_line = NULL; |
875 | sp->last_line = NULL; | 877 | sp->last_line = NULL; |
876 | 878 | ||
877 | for(;;) { | 879 | for(;;) { |
878 | if (ParseShapeRecord(sp, sr, shape->getAlpha) == 0) break; | 880 | if (ParseShapeRecord(sp, sr, shape->getAlpha) == 0) break; |
879 | 881 | ||
880 | switch (sr->type) | 882 | switch (sr->type) |
881 | { | 883 | { |
882 | case shapeNonEdge: | 884 | case shapeNonEdge: |
883 | if (sr->flags & flagsNewStyles) { | 885 | if (sr->flags & flagsNewStyles) { |
884 | 886 | ||
885 | curFillStyle = sr->newFillStyles; | 887 | curFillStyle = sr->newFillStyles; |
886 | curNbFillStyles = sr->nbNewFillStyles; | 888 | curNbFillStyles = sr->nbNewFillStyles; |
887 | curLineStyle = sr->newLineStyles; | 889 | curLineStyle = sr->newLineStyles; |
888 | curNbLineStyles = sr->nbNewLineStyles; | 890 | curNbLineStyles = sr->nbNewLineStyles; |
889 | 891 | ||
890 | sl = new StyleList; | 892 | sl = new StyleList; |
891 | sl->next = sp->style_list; | 893 | sl->next = sp->style_list; |
892 | sl->newFillStyles = sr->newFillStyles; | 894 | sl->newFillStyles = sr->newFillStyles; |
893 | sl->nbNewFillStyles = sr->nbNewFillStyles; | 895 | sl->nbNewFillStyles = sr->nbNewFillStyles; |
894 | sl->newLineStyles = sr->newLineStyles; | 896 | sl->newLineStyles = sr->newLineStyles; |
895 | sl->nbNewLineStyles = sr->nbNewLineStyles; | 897 | sl->nbNewLineStyles = sr->nbNewLineStyles; |
896 | 898 | ||
897 | sp->style_list = sl; | 899 | sp->style_list = sl; |
898 | 900 | ||
899 | if (shapeAction == ShapeDraw) { | 901 | if (shapeAction == ShapeDraw) { |
900 | prepareStyles(gd, matrix, cxform, curFillStyle, curNbFillStyles); | 902 | prepareStyles(gd, matrix, cxform, curFillStyle, curNbFillStyles); |
901 | } | 903 | } |
902 | } | 904 | } |
903 | if (sr->flags & flagsFill0) { | 905 | if (sr->flags & flagsFill0) { |
904 | if (sr->fillStyle0) { | 906 | if (sr->fillStyle0) { |
905 | if (curFillStyle) { | 907 | if (curFillStyle) { |
906 | f0 = &curFillStyle[sr->fillStyle0-1]; | 908 | f0 = &curFillStyle[sr->fillStyle0-1]; |
907 | } else { | 909 | } else { |
908 | f0 = &shape->defaultFillStyle; | 910 | f0 = &shape->defaultFillStyle; |
909 | } | 911 | } |
910 | } else { | 912 | } else { |
911 | f0 = 0; | 913 | f0 = 0; |
912 | } | 914 | } |
913 | } | 915 | } |
914 | if (sr->flags & flagsFill1) { | 916 | if (sr->flags & flagsFill1) { |
915 | if (sr->fillStyle1) { | 917 | if (sr->fillStyle1) { |
916 | if (curFillStyle) { | 918 | if (curFillStyle) { |
917 | f1 = &curFillStyle[sr->fillStyle1-1]; | 919 | f1 = &curFillStyle[sr->fillStyle1-1]; |
918 | } else { | 920 | } else { |
919 | f1 = &shape->defaultFillStyle; | 921 | f1 = &shape->defaultFillStyle; |
920 | } | 922 | } |
921 | } else { | 923 | } else { |
922 | f1 = 0; | 924 | f1 = 0; |
923 | } | 925 | } |
924 | } | 926 | } |
925 | if (sr->flags & flagsLine) { | 927 | if (sr->flags & flagsLine) { |
926 | if (sr->lineStyle) { | 928 | if (sr->lineStyle) { |
927 | l = &curLineStyle[sr->lineStyle-1]; | 929 | l = &curLineStyle[sr->lineStyle-1]; |
928 | } else { | 930 | } else { |
929 | l = 0; | 931 | l = 0; |
930 | } | 932 | } |
931 | } | 933 | } |
932 | if (sr->flags & flagsMoveTo) { | 934 | if (sr->flags & flagsMoveTo) { |
933 | if (sp->curPath.nb_edges == 0) { | 935 | if (sp->curPath.nb_edges == 0) { |
934 | /* if no edges, draw the polygon, then the lines */ | 936 | /* if no edges, draw the polygon, then the lines */ |
935 | flushPaths(sp); | 937 | flushPaths(sp); |
936 | } | 938 | } |
937 | 939 | ||
938 | newPath(sp, sr->x, sr->y); | 940 | newPath(sp, sr->x, sr->y); |
939 | firstPoint = 0; | 941 | firstPoint = 0; |
940 | 942 | ||
941 | lastX = sr->x; | 943 | lastX = sr->x; |
942 | lastY = sr->y; | 944 | lastY = sr->y; |
943 | 945 | ||
944 | #if PRINT | 946 | #if PRINT |
945 | printf("---------\nX,Y = %4d,%4d\n", sr->x/20, sr->y/20); | 947 | printf("---------\nX,Y = %4d,%4d\n", sr->x/20, sr->y/20); |
946 | #endif | 948 | #endif |
947 | } | 949 | } |
948 | break; | 950 | break; |
949 | case shapeCurve: | 951 | case shapeCurve: |
950 | // Handle Bezier Curves !!! | 952 | // Handle Bezier Curves !!! |
951 | if (firstPoint) { | 953 | if (firstPoint) { |
952 | newPath(sp, 0, 0); | 954 | newPath(sp, 0, 0); |
953 | firstPoint = 0; | 955 | firstPoint = 0; |
954 | } | 956 | } |
955 | { | 957 | { |
956 | long newX,newY,ctrlX,ctrlY; | 958 | long newX,newY,ctrlX,ctrlY; |
957 | 959 | ||
958 | ctrlX = lastX+sr->ctrlX; | 960 | ctrlX = lastX+sr->ctrlX; |
959 | ctrlY = lastY+sr->ctrlY; | 961 | ctrlY = lastY+sr->ctrlY; |
960 | newX = ctrlX+sr->anchorX; | 962 | newX = ctrlX+sr->anchorX; |
961 | newY = ctrlY+sr->anchorY; | 963 | newY = ctrlY+sr->anchorY; |
962 | 964 | ||
963 | #if 1 | 965 | #if 1 |
964 | addBezier(sp, ctrlX, ctrlY, newX, newY, f0 , f1, l); | 966 | addBezier(sp, ctrlX, ctrlY, newX, newY, f0 , f1, l); |
965 | #else | 967 | #else |
966 | addLine(sp, newX, newY, f0, f1, l); | 968 | addLine(sp, newX, newY, f0, f1, l); |
967 | #endif | 969 | #endif |
968 | 970 | ||
969 | lastX = newX; | 971 | lastX = newX; |
970 | lastY = newY; | 972 | lastY = newY; |
971 | } | 973 | } |
972 | break; | 974 | break; |
973 | case shapeLine: | 975 | case shapeLine: |
974 | if (firstPoint) { | 976 | if (firstPoint) { |
975 | newPath(sp, 0, 0); | 977 | newPath(sp, 0, 0); |
976 | firstPoint = 0; | 978 | firstPoint = 0; |
977 | } | 979 | } |
978 | 980 | ||
979 | lastX += sr->dX; | 981 | lastX += sr->dX; |
980 | lastY += sr->dY; | 982 | lastY += sr->dY; |
981 | 983 | ||
982 | addLine(sp, lastX, lastY, f0, f1, l); | 984 | addLine(sp, lastX, lastY, f0, f1, l); |
983 | #if PRINT | 985 | #if PRINT |
984 | printf(" X, Y = %4d,%4d\n", lastX/20, lastY/20); | 986 | printf(" X, Y = %4d,%4d\n", lastX/20, lastY/20); |
985 | #endif | 987 | #endif |
986 | break; | 988 | break; |
987 | } | 989 | } |
988 | } | 990 | } |
989 | 991 | ||
990 | /* XXX: should test if there is something to draw */ | 992 | /* XXX: should test if there is something to draw */ |
991 | flushPaths(sp); | 993 | flushPaths(sp); |
992 | 994 | ||
993 | /* free the styles */ | 995 | /* free the styles */ |
994 | while (sp->style_list) { | 996 | while (sp->style_list) { |
995 | StyleList *sl; | 997 | StyleList *sl; |
996 | 998 | ||
997 | sl=sp->style_list; | 999 | sl=sp->style_list; |
998 | sp->style_list = sl->next; | 1000 | sp->style_list = sl->next; |
999 | 1001 | ||
1000 | if (shapeAction == ShapeDraw) { | 1002 | if (shapeAction == ShapeDraw) { |
1001 | clearStyles(gd, sl->newFillStyles, sl->nbNewFillStyles); | 1003 | clearStyles(gd, sl->newFillStyles, sl->nbNewFillStyles); |
1002 | } | 1004 | } |
1003 | 1005 | ||
1004 | delete[] sl->newFillStyles; | 1006 | delete[] sl->newFillStyles; |
1005 | delete[] sl->newLineStyles; | 1007 | delete[] sl->newLineStyles; |
1006 | 1008 | ||
1007 | delete sl; | 1009 | delete sl; |
1008 | } | 1010 | } |
1009 | } | 1011 | } |
1010 | 1012 | ||
1011 | static void | 1013 | static void |
1012 | prepareStyles(GraphicDevice *gd, Matrix *matrix, Cxform *cxform, | 1014 | prepareStyles(GraphicDevice *gd, Matrix *matrix, Cxform *cxform, |
1013 | FillStyleDef *ftab, long n) | 1015 | FillStyleDef *ftab, long n) |
1014 | { | 1016 | { |
1015 | long fs; | 1017 | long fs; |
1016 | FillStyleDef *f; | 1018 | FillStyleDef *f; |
1017 | 1019 | ||
1018 | for(fs = 0; fs < n; fs++) | 1020 | for(fs = 0; fs < n; fs++) |
1019 | { | 1021 | { |
1020 | f = ftab + fs; | 1022 | f = ftab + fs; |
1021 | switch (f->type) | 1023 | switch (f->type) |
1022 | { | 1024 | { |
1023 | case f_None: | 1025 | case f_None: |
1024 | break; | 1026 | break; |
1025 | case f_Solid: | 1027 | case f_Solid: |
1026 | if (cxform) { | 1028 | if (cxform) { |
1027 | f->color = cxform->getColor(f->color); | 1029 | f->color = cxform->getColor(f->color); |
1028 | } | 1030 | } |
1029 | f->color.pixel = gd->allocColor(f->color); | 1031 | f->color.pixel = gd->allocColor(f->color); |
1030 | break; | 1032 | break; |
1031 | case f_LinearGradient: | 1033 | case f_LinearGradient: |
1032 | case f_RadialGradient: | 1034 | case f_RadialGradient: |
1033 | { | 1035 | { |
1034 | Matrix mat; | 1036 | Matrix mat; |
1035 | int n,r,l; | 1037 | int n,r,l; |
1036 | long red, green, blue, alpha; | 1038 | long red, green, blue, alpha; |
1037 | long dRed, dGreen, dBlue, dAlpha; | 1039 | long dRed, dGreen, dBlue, dAlpha; |
1038 | long min,max; | 1040 | long min,max; |
1039 | Matrix *m; | 1041 | Matrix *m; |
1040 | 1042 | ||
1041 | mat = *(matrix) * f->matrix; | 1043 | mat = *(matrix) * f->matrix; |
1042 | // Compute inverted matrix | 1044 | // Compute inverted matrix |
1043 | f->gradient.imat = mat.invert(); | 1045 | f->gradient.imat = mat.invert(); |
1044 | 1046 | ||
1045 | /* renormalize the matrix */ | 1047 | /* renormalize the matrix */ |
1046 | m=&f->gradient.imat; | 1048 | m=&f->gradient.imat; |
1047 | if (f->type == f_LinearGradient) { | 1049 | if (f->type == f_LinearGradient) { |
1048 | m->a = m->a * FRAC * (1/128.0) * 65536.0; | 1050 | m->a = m->a * FRAC * (1/128.0) * 65536.0; |
1049 | m->b = m->b * FRAC * (1/128.0) * 65536.0; | 1051 | m->b = m->b * FRAC * (1/128.0) * 65536.0; |
1050 | m->tx = (long) ((m->tx + 16384) * (1/128.0) * 65536.0); | 1052 | m->tx = (long) ((m->tx + 16384) * (1/128.0) * 65536.0); |
1051 | } else { | 1053 | } else { |
1052 | m->a = m->a * FRAC * (1/64.0) * 65536.0; | 1054 | m->a = m->a * FRAC * (1/64.0) * 65536.0; |
1053 | m->b = m->b * FRAC * (1/64.0) * 65536.0; | 1055 | m->b = m->b * FRAC * (1/64.0) * 65536.0; |
1054 | m->c = m->c * FRAC * (1/64.0) * 65536.0; | 1056 | m->c = m->c * FRAC * (1/64.0) * 65536.0; |
1055 | m->d = m->d * FRAC * (1/64.0) * 65536.0; | 1057 | m->d = m->d * FRAC * (1/64.0) * 65536.0; |
1056 | m->tx = (long) (m->tx * (1/64.0) * 65536.0); | 1058 | m->tx = (long) (m->tx * (1/64.0) * 65536.0); |
1057 | m->ty = (long) (m->ty * (1/64.0) * 65536.0); | 1059 | m->ty = (long) (m->ty * (1/64.0) * 65536.0); |
1058 | } | 1060 | } |
1059 | 1061 | ||
1060 | // Reset translation in inverted matrix | 1062 | // Reset translation in inverted matrix |
1061 | f->gradient.has_alpha = 0; | 1063 | f->gradient.has_alpha = 0; |
1062 | 1064 | ||
1063 | // Build a 256 color ramp | 1065 | // Build a 256 color ramp |
1064 | f->gradient.ramp = new Color[256]; | 1066 | f->gradient.ramp = new Color[256]; |
1065 | if (f->gradient.ramp == NULL) { | 1067 | if (f->gradient.ramp == NULL) { |
1066 | // Invalidate fill style | 1068 | // Invalidate fill style |
1067 | f->type = f_None; | 1069 | f->type = f_None; |
1068 | continue; | 1070 | continue; |
1069 | } | 1071 | } |
1070 | 1072 | ||
1071 | // Store min and max | 1073 | // Store min and max |
1072 | min = f->gradient.ratio[0]; | 1074 | min = f->gradient.ratio[0]; |
1073 | max = f->gradient.ratio[f->gradient.nbGradients-1]; | 1075 | max = f->gradient.ratio[f->gradient.nbGradients-1]; |
1074 | for(r=0; r < f->gradient.nbGradients-1; r++) | 1076 | for(r=0; r < f->gradient.nbGradients-1; r++) |
1075 | { | 1077 | { |
1076 | Color start,end; | 1078 | Color start,end; |
1077 | 1079 | ||
1078 | l = f->gradient.ratio[r+1]-f->gradient.ratio[r]; | 1080 | l = f->gradient.ratio[r+1]-f->gradient.ratio[r]; |
1079 | if (l == 0) continue; | 1081 | if (l == 0) continue; |
1080 | 1082 | ||
1081 | if (cxform) { | 1083 | if (cxform) { |
1082 | start = cxform->getColor(f->gradient.color[r]); | 1084 | start = cxform->getColor(f->gradient.color[r]); |
1083 | end = cxform->getColor(f->gradient.color[r+1]); | 1085 | end = cxform->getColor(f->gradient.color[r+1]); |
1084 | } else { | 1086 | } else { |
1085 | start = f->gradient.color[r]; | 1087 | start = f->gradient.color[r]; |
1086 | end = f->gradient.color[r+1]; | 1088 | end = f->gradient.color[r+1]; |
1087 | } | 1089 | } |
1088 | 1090 | ||
1089 | if (start.alpha != ALPHA_OPAQUE || | 1091 | if (start.alpha != ALPHA_OPAQUE || |
1090 | end.alpha != ALPHA_OPAQUE) { | 1092 | end.alpha != ALPHA_OPAQUE) { |
1091 | f->gradient.has_alpha = 1; | 1093 | f->gradient.has_alpha = 1; |
1092 | } | 1094 | } |
1093 | 1095 | ||
1094 | dRed = end.red - start.red; | 1096 | dRed = end.red - start.red; |
1095 | dGreen = end.green - start.green; | 1097 | dGreen = end.green - start.green; |
1096 | dBlue = end.blue - start.blue; | 1098 | dBlue = end.blue - start.blue; |
1097 | dAlpha = end.alpha - start.alpha; | 1099 | dAlpha = end.alpha - start.alpha; |
1098 | 1100 | ||
1099 | dRed = (dRed<<16)/l; | 1101 | dRed = (dRed<<16)/l; |
1100 | dGreen = (dGreen<<16)/l; | 1102 | dGreen = (dGreen<<16)/l; |
1101 | dBlue = (dBlue<<16)/l; | 1103 | dBlue = (dBlue<<16)/l; |
1102 | dAlpha = (dAlpha<<16)/l; | 1104 | dAlpha = (dAlpha<<16)/l; |
1103 | 1105 | ||
1104 | red = start.red <<16; | 1106 | red = start.red <<16; |
1105 | green = start.green <<16; | 1107 | green = start.green <<16; |
1106 | blue = start.blue <<16; | 1108 | blue = start.blue <<16; |
1107 | alpha = start.alpha <<16; | 1109 | alpha = start.alpha <<16; |
1108 | 1110 | ||
1109 | for (n=f->gradient.ratio[r]; n<=f->gradient.ratio[r+1]; n++) { | 1111 | for (n=f->gradient.ratio[r]; n<=f->gradient.ratio[r+1]; n++) { |
1110 | f->gradient.ramp[n].red = red>>16; | 1112 | f->gradient.ramp[n].red = red>>16; |
1111 | f->gradient.ramp[n].green = green>>16; | 1113 | f->gradient.ramp[n].green = green>>16; |
1112 | f->gradient.ramp[n].blue = blue>>16; | 1114 | f->gradient.ramp[n].blue = blue>>16; |
1113 | f->gradient.ramp[n].alpha = alpha>>16; | 1115 | f->gradient.ramp[n].alpha = alpha>>16; |
1114 | 1116 | ||
1115 | f->gradient.ramp[n].pixel = gd->allocColor(f->gradient.ramp[n]); | 1117 | f->gradient.ramp[n].pixel = gd->allocColor(f->gradient.ramp[n]); |
1116 | red += dRed; | 1118 | red += dRed; |
1117 | green += dGreen; | 1119 | green += dGreen; |
1118 | blue += dBlue; | 1120 | blue += dBlue; |
1119 | alpha += dAlpha; | 1121 | alpha += dAlpha; |
1120 | } | 1122 | } |
1121 | } | 1123 | } |
1122 | for(n=0; n<min; n++) { | 1124 | for(n=0; n<min; n++) { |
1123 | f->gradient.ramp[n] = f->gradient.ramp[min]; | 1125 | f->gradient.ramp[n] = f->gradient.ramp[min]; |
1124 | } | 1126 | } |
1125 | for(n=max; n<256; n++) { | 1127 | for(n=max; n<256; n++) { |
1126 | f->gradient.ramp[n] = f->gradient.ramp[max]; | 1128 | f->gradient.ramp[n] = f->gradient.ramp[max]; |
1127 | } | 1129 | } |
1128 | } | 1130 | } |
1129 | break; | 1131 | break; |
1130 | case f_TiledBitmap: | 1132 | case f_TiledBitmap: |
1131 | case f_clippedBitmap: | 1133 | case f_clippedBitmap: |
1132 | if (f->bitmap) { | 1134 | if (f->bitmap) { |
1133 | Matrix *m; | 1135 | Matrix *m; |
1134 | 1136 | ||
1135 | f->cmap = gd->getColormap(f->bitmap->colormap, | 1137 | f->cmap = gd->getColormap(f->bitmap->colormap, |
1136 | f->bitmap->nbColors, cxform); | 1138 | f->bitmap->nbColors, cxform); |
1137 | if (f->cmap == NULL) { | 1139 | if (f->cmap == NULL) { |
1138 | /* Get the normal cmap anyway */ | 1140 | /* Get the normal cmap anyway */ |
1139 | f->cmap = f->bitmap->colormap; | 1141 | f->cmap = f->bitmap->colormap; |
1140 | } | 1142 | } |
1141 | 1143 | ||
1142 | f->bitmap_matrix = *(matrix) * f->matrix; | 1144 | f->bitmap_matrix = *(matrix) * f->matrix; |
1143 | 1145 | ||
1144 | f->bitmap_matrix = f->bitmap_matrix.invert(); | 1146 | f->bitmap_matrix = f->bitmap_matrix.invert(); |
1145 | 1147 | ||
1146 | m=&f->bitmap_matrix; | 1148 | m=&f->bitmap_matrix; |
1147 | m->a = m->a * FRAC * 65536.0; | 1149 | m->a = m->a * FRAC * 65536.0; |
1148 | m->b = m->b * FRAC * 65536.0; | 1150 | m->b = m->b * FRAC * 65536.0; |
1149 | m->c = m->c * FRAC * 65536.0; | 1151 | m->c = m->c * FRAC * 65536.0; |
1150 | m->d = m->d * FRAC * 65536.0; | 1152 | m->d = m->d * FRAC * 65536.0; |
1151 | m->tx = (long) (m->tx * 65536.0); | 1153 | m->tx = (long) (m->tx * 65536.0); |
1152 | m->ty = (long) (m->ty * 65536.0); | 1154 | m->ty = (long) (m->ty * 65536.0); |
1153 | 1155 | ||
1154 | f->alpha_table = NULL; | 1156 | f->alpha_table = NULL; |
1155 | 1157 | ||
1156 | if (f->bitmap->alpha_buf && cxform) { | 1158 | if (f->bitmap->alpha_buf && cxform) { |
1157 | unsigned char *alpha_table; | 1159 | unsigned char *alpha_table; |
1158 | int i; | 1160 | int i; |
1159 | 1161 | ||
1160 | alpha_table = (unsigned char *)malloc (256); | 1162 | alpha_table = (unsigned char *)malloc (256); |
1161 | if (alpha_table != NULL) { | 1163 | if (alpha_table != NULL) { |
1162 | for(i=0;i<256;i++) { | 1164 | for(i=0;i<256;i++) { |
1163 | alpha_table[i] = cxform->getAlpha(i); | 1165 | alpha_table[i] = cxform->getAlpha(i); |
1164 | } | 1166 | } |
1165 | } | 1167 | } |
1166 | f->alpha_table = alpha_table; | 1168 | f->alpha_table = alpha_table; |
1167 | } | 1169 | } |
1168 | } | 1170 | } |
1169 | break; | 1171 | break; |
1170 | } | 1172 | } |
1171 | } | 1173 | } |
1172 | } | 1174 | } |
1173 | 1175 | ||
1174 | static void | 1176 | static void |
1175 | clearStyles(GraphicDevice *gd, FillStyleDef *ftab, long n) | 1177 | clearStyles(GraphicDevice *gd, FillStyleDef *ftab, long n) |
1176 | { | 1178 | { |
1177 | long fs; | 1179 | long fs; |
1178 | FillStyleDef *f; | 1180 | FillStyleDef *f; |
1179 | 1181 | ||
1180 | for(fs = 0; fs < n; fs++) | 1182 | for(fs = 0; fs < n; fs++) |
1181 | { | 1183 | { |
1182 | f = ftab + fs; | 1184 | f = ftab + fs; |
1183 | switch (f->type) | 1185 | switch (f->type) |
1184 | { | 1186 | { |
1185 | case f_Solid: | 1187 | case f_Solid: |
1186 | break; | 1188 | break; |
1187 | case f_LinearGradient: | 1189 | case f_LinearGradient: |
1188 | case f_RadialGradient: | 1190 | case f_RadialGradient: |
1189 | if (f->gradient.ramp) { | 1191 | if (f->gradient.ramp) { |
1190 | delete f->gradient.ramp; | 1192 | delete f->gradient.ramp; |
1191 | } | 1193 | } |
1192 | break; | 1194 | break; |
1193 | case f_TiledBitmap: | 1195 | case f_TiledBitmap: |
1194 | case f_clippedBitmap: | 1196 | case f_clippedBitmap: |
1195 | if (f->bitmap) { | 1197 | if (f->bitmap) { |
1196 | if (f->cmap && f->cmap != f->bitmap->colormap) delete f->cmap; | 1198 | if (f->cmap && f->cmap != f->bitmap->colormap) delete f->cmap; |
1197 | if (f->alpha_table) free(f->alpha_table); | 1199 | if (f->alpha_table) free(f->alpha_table); |
1198 | } | 1200 | } |
1199 | break; | 1201 | break; |
1200 | case f_None: | 1202 | case f_None: |
1201 | break; | 1203 | break; |
1202 | } | 1204 | } |
1203 | } | 1205 | } |
1204 | } | 1206 | } |
1205 | 1207 | ||
diff --git a/core/multimedia/opieplayer/libmad/config.in b/core/multimedia/opieplayer/libmad/config.in index 72249dc..f38e52d 100644 --- a/core/multimedia/opieplayer/libmad/config.in +++ b/core/multimedia/opieplayer/libmad/config.in | |||
@@ -1,4 +1,4 @@ | |||
1 | config LIBMAD | 1 | config LIBMAD |
2 | boolean "opieplayer1-libmadplugin (plugin with shoutcast/icecast support to play MP3 files)" | 2 | boolean "opieplayer1-libmadplugin (plugin with shoutcast/icecast support to play MP3 files)" |
3 | default "y" | 3 | default "y" |
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE && OPIEPLAYER | 4 | depends ( LIBQPE || LIBQPE-X11 ) && OPIEPLAYER |
diff --git a/core/multimedia/opieplayer/libmpeg3/config.in b/core/multimedia/opieplayer/libmpeg3/config.in index b965a40..d964fb9 100644 --- a/core/multimedia/opieplayer/libmpeg3/config.in +++ b/core/multimedia/opieplayer/libmpeg3/config.in | |||
@@ -1,4 +1,4 @@ | |||
1 | config LIBMPEG3 | 1 | config LIBMPEG3 |
2 | boolean "opieplayer1-libmpeg3plugin (play MPEG3 video files)" | 2 | boolean "opieplayer1-libmpeg3plugin (play MPEG3 video files)" |
3 | default "y" | 3 | default "y" |
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE && OPIEPLAYER | 4 | depends ( LIBQPE || LIBQPE-X11 ) && OPIEPLAYER |
diff --git a/core/multimedia/opieplayer/modplug/config.in b/core/multimedia/opieplayer/modplug/config.in index 86e4725..d7496b0 100644 --- a/core/multimedia/opieplayer/modplug/config.in +++ b/core/multimedia/opieplayer/modplug/config.in | |||
@@ -1,4 +1,4 @@ | |||
1 | config MODPLUG | 1 | config MODPLUG |
2 | boolean "opieplayer1-modplugin (play MOD/XM/S3M/IT amiga tracker modules)" | 2 | boolean "opieplayer1-modplugin (play MOD/XM/S3M/IT amiga tracker modules)" |
3 | default "y" | 3 | default "y" |
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE && OPIEPLAYER | 4 | depends ( LIBQPE || LIBQPE-X11 ) && OPIEPLAYER |
diff --git a/core/multimedia/opieplayer/wavplugin/config.in b/core/multimedia/opieplayer/wavplugin/config.in index 56bdfab..b7dddc5 100644 --- a/core/multimedia/opieplayer/wavplugin/config.in +++ b/core/multimedia/opieplayer/wavplugin/config.in | |||
@@ -1,4 +1,4 @@ | |||
1 | config WAVPLUGIN | 1 | config WAVPLUGIN |
2 | boolean "opieplayer1-wavplugin (play WAV files)" | 2 | boolean "opieplayer1-wavplugin (play WAV files)" |
3 | default "y" | 3 | default "y" |
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE && OPIEPLAYER | 4 | depends ( LIBQPE || LIBQPE-X11 ) && OPIEPLAYER |