blob: 0d4dcd412104d15348139285906b732ca231002b [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
reed@android.com8a1c16f2008-12-17 15:59:43 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * Copyright 2008 The Android Open Source Project
reed@android.com8a1c16f2008-12-17 15:59:43 +00004 *
epoger@google.comec3ed6a2011-07-28 14:26:00 +00005 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
reed@android.com8a1c16f2008-12-17 15:59:43 +00007 */
8
epoger@google.comec3ed6a2011-07-28 14:26:00 +00009
reed@android.com8a1c16f2008-12-17 15:59:43 +000010#include "SkPathMeasure.h"
11#include "SkGeometry.h"
12#include "SkPath.h"
13#include "SkTSearch.h"
14
15// these must be 0,1,2 since they are in our 2-bit field
16enum {
17 kLine_SegType,
reed@android.com8a1c16f2008-12-17 15:59:43 +000018 kQuad_SegType,
19 kCubic_SegType
20};
21
22#define kMaxTValue 32767
23
24static inline SkScalar tValue2Scalar(int t) {
25 SkASSERT((unsigned)t <= kMaxTValue);
26
27#ifdef SK_SCALAR_IS_FLOAT
28 return t * 3.05185e-5f; // t / 32767
29#else
30 return (t + (t >> 14)) << 1;
31#endif
32}
33
34SkScalar SkPathMeasure::Segment::getScalarT() const {
35 return tValue2Scalar(fTValue);
36}
37
38const SkPathMeasure::Segment* SkPathMeasure::NextSegment(const Segment* seg) {
39 unsigned ptIndex = seg->fPtIndex;
40
41 do {
42 ++seg;
43 } while (seg->fPtIndex == ptIndex);
44 return seg;
45}
46
47///////////////////////////////////////////////////////////////////////////////
48
49static inline int tspan_big_enough(int tspan) {
50 SkASSERT((unsigned)tspan <= kMaxTValue);
51 return tspan >> 10;
52}
53
54#if 0
55static inline bool tangents_too_curvy(const SkVector& tan0, SkVector& tan1) {
56 static const SkScalar kFlatEnoughTangentDotProd = SK_Scalar1 * 99 / 100;
57
58 SkASSERT(kFlatEnoughTangentDotProd > 0 &&
59 kFlatEnoughTangentDotProd < SK_Scalar1);
60
61 return SkPoint::DotProduct(tan0, tan1) < kFlatEnoughTangentDotProd;
62}
63#endif
64
65// can't use tangents, since we need [0..1..................2] to be seen
66// as definitely not a line (it is when drawn, but not parametrically)
67// so we compare midpoints
68#define CHEAP_DIST_LIMIT (SK_Scalar1/2) // just made this value up
69
70static bool quad_too_curvy(const SkPoint pts[3]) {
71 // diff = (a/4 + b/2 + c/4) - (a/2 + c/2)
72 // diff = -a/4 + b/2 - c/4
73 SkScalar dx = SkScalarHalf(pts[1].fX) -
74 SkScalarHalf(SkScalarHalf(pts[0].fX + pts[2].fX));
75 SkScalar dy = SkScalarHalf(pts[1].fY) -
76 SkScalarHalf(SkScalarHalf(pts[0].fY + pts[2].fY));
77
78 SkScalar dist = SkMaxScalar(SkScalarAbs(dx), SkScalarAbs(dy));
79 return dist > CHEAP_DIST_LIMIT;
80}
81
82static bool cheap_dist_exceeds_limit(const SkPoint& pt,
83 SkScalar x, SkScalar y) {
84 SkScalar dist = SkMaxScalar(SkScalarAbs(x - pt.fX), SkScalarAbs(y - pt.fY));
85 // just made up the 1/2
86 return dist > CHEAP_DIST_LIMIT;
87}
88
89static bool cubic_too_curvy(const SkPoint pts[4]) {
90 return cheap_dist_exceeds_limit(pts[1],
91 SkScalarInterp(pts[0].fX, pts[3].fX, SK_Scalar1/3),
92 SkScalarInterp(pts[0].fY, pts[3].fY, SK_Scalar1/3))
93 ||
94 cheap_dist_exceeds_limit(pts[2],
95 SkScalarInterp(pts[0].fX, pts[3].fX, SK_Scalar1*2/3),
96 SkScalarInterp(pts[0].fY, pts[3].fY, SK_Scalar1*2/3));
97}
98
99SkScalar SkPathMeasure::compute_quad_segs(const SkPoint pts[3],
100 SkScalar distance, int mint, int maxt, int ptIndex) {
101 if (tspan_big_enough(maxt - mint) && quad_too_curvy(pts)) {
102 SkPoint tmp[5];
103 int halft = (mint + maxt) >> 1;
104
105 SkChopQuadAtHalf(pts, tmp);
106 distance = this->compute_quad_segs(tmp, distance, mint, halft, ptIndex);
107 distance = this->compute_quad_segs(&tmp[2], distance, halft, maxt, ptIndex);
108 } else {
109 SkScalar d = SkPoint::Distance(pts[0], pts[2]);
110 SkASSERT(d >= 0);
111 if (!SkScalarNearlyZero(d)) {
112 distance += d;
113 Segment* seg = fSegments.append();
114 seg->fDistance = distance;
115 seg->fPtIndex = ptIndex;
116 seg->fType = kQuad_SegType;
117 seg->fTValue = maxt;
118 }
119 }
120 return distance;
121}
122
123SkScalar SkPathMeasure::compute_cubic_segs(const SkPoint pts[4],
124 SkScalar distance, int mint, int maxt, int ptIndex) {
125 if (tspan_big_enough(maxt - mint) && cubic_too_curvy(pts)) {
126 SkPoint tmp[7];
127 int halft = (mint + maxt) >> 1;
128
129 SkChopCubicAtHalf(pts, tmp);
130 distance = this->compute_cubic_segs(tmp, distance, mint, halft, ptIndex);
131 distance = this->compute_cubic_segs(&tmp[3], distance, halft, maxt, ptIndex);
132 } else {
133 SkScalar d = SkPoint::Distance(pts[0], pts[3]);
134 SkASSERT(d >= 0);
135 if (!SkScalarNearlyZero(d)) {
136 distance += d;
137 Segment* seg = fSegments.append();
138 seg->fDistance = distance;
139 seg->fPtIndex = ptIndex;
140 seg->fType = kCubic_SegType;
141 seg->fTValue = maxt;
142 }
143 }
144 return distance;
145}
146
147void SkPathMeasure::buildSegments() {
148 SkPoint pts[4];
149 int ptIndex = fFirstPtIndex;
reed@google.comfab1ddd2012-04-20 15:10:32 +0000150 SkScalar distance = 0;
reed@android.com8a1c16f2008-12-17 15:59:43 +0000151 bool isClosed = fForceClosed;
152 bool firstMoveTo = ptIndex < 0;
153 Segment* seg;
154
reed@google.comfab1ddd2012-04-20 15:10:32 +0000155 /* Note:
156 * as we accumulate distance, we have to check that the result of +=
157 * actually made it larger, since a very small delta might be > 0, but
158 * still have no effect on distance (if distance >>> delta).
159 */
reed@android.com8a1c16f2008-12-17 15:59:43 +0000160 fSegments.reset();
schenney@chromium.orga6d04d92012-01-18 18:02:10 +0000161 bool done = false;
162 do {
reed@android.com8a1c16f2008-12-17 15:59:43 +0000163 switch (fIter.next(pts)) {
164 case SkPath::kMove_Verb:
schenney@chromium.orga6d04d92012-01-18 18:02:10 +0000165 ptIndex += 1;
166 fPts.append(1, pts);
reed@android.com8a1c16f2008-12-17 15:59:43 +0000167 if (!firstMoveTo) {
schenney@chromium.orga6d04d92012-01-18 18:02:10 +0000168 done = true;
169 break;
reed@android.com8a1c16f2008-12-17 15:59:43 +0000170 }
schenney@chromium.orga6d04d92012-01-18 18:02:10 +0000171 firstMoveTo = false;
172 break;
reed@android.com8a1c16f2008-12-17 15:59:43 +0000173
reed@google.comfab1ddd2012-04-20 15:10:32 +0000174 case SkPath::kLine_Verb: {
175 SkScalar d = SkPoint::Distance(pts[0], pts[1]);
reed@android.com8a1c16f2008-12-17 15:59:43 +0000176 SkASSERT(d >= 0);
reed@google.comfab1ddd2012-04-20 15:10:32 +0000177 SkScalar prevD = distance;
schenney@chromium.orga6d04d92012-01-18 18:02:10 +0000178 distance += d;
reed@google.comfab1ddd2012-04-20 15:10:32 +0000179 if (distance > prevD) {
180 seg = fSegments.append();
181 seg->fDistance = distance;
182 seg->fPtIndex = ptIndex;
183 seg->fType = kLine_SegType;
184 seg->fTValue = kMaxTValue;
185 fPts.append(1, pts + 1);
186 ptIndex++;
187 }
188 } break;
reed@android.com8a1c16f2008-12-17 15:59:43 +0000189
reed@google.comfab1ddd2012-04-20 15:10:32 +0000190 case SkPath::kQuad_Verb: {
191 SkScalar prevD = distance;
reed@android.com8a1c16f2008-12-17 15:59:43 +0000192 distance = this->compute_quad_segs(pts, distance, 0,
193 kMaxTValue, ptIndex);
reed@google.comfab1ddd2012-04-20 15:10:32 +0000194 if (distance > prevD) {
195 fPts.append(2, pts + 1);
196 ptIndex += 2;
197 }
198 } break;
reed@android.com8a1c16f2008-12-17 15:59:43 +0000199
reed@google.comfab1ddd2012-04-20 15:10:32 +0000200 case SkPath::kCubic_Verb: {
201 SkScalar prevD = distance;
reed@android.com8a1c16f2008-12-17 15:59:43 +0000202 distance = this->compute_cubic_segs(pts, distance, 0,
203 kMaxTValue, ptIndex);
reed@google.comfab1ddd2012-04-20 15:10:32 +0000204 if (distance > prevD) {
205 fPts.append(3, pts + 1);
206 ptIndex += 3;
207 }
208 } break;
reed@android.com8a1c16f2008-12-17 15:59:43 +0000209
210 case SkPath::kClose_Verb:
211 isClosed = true;
212 break;
213
214 case SkPath::kDone_Verb:
schenney@chromium.orga6d04d92012-01-18 18:02:10 +0000215 done = true;
216 break;
reed@android.com8a1c16f2008-12-17 15:59:43 +0000217 }
schenney@chromium.orga6d04d92012-01-18 18:02:10 +0000218 } while (!done);
219
reed@android.com8a1c16f2008-12-17 15:59:43 +0000220 fLength = distance;
221 fIsClosed = isClosed;
schenney@chromium.orga6d04d92012-01-18 18:02:10 +0000222 fFirstPtIndex = ptIndex;
reed@android.com8a1c16f2008-12-17 15:59:43 +0000223
224#ifdef SK_DEBUG
225 {
226 const Segment* seg = fSegments.begin();
227 const Segment* stop = fSegments.end();
228 unsigned ptIndex = 0;
229 SkScalar distance = 0;
230
231 while (seg < stop) {
232 SkASSERT(seg->fDistance > distance);
233 SkASSERT(seg->fPtIndex >= ptIndex);
234 SkASSERT(seg->fTValue > 0);
235
236 const Segment* s = seg;
237 while (s < stop - 1 && s[0].fPtIndex == s[1].fPtIndex) {
238 SkASSERT(s[0].fType == s[1].fType);
239 SkASSERT(s[0].fTValue < s[1].fTValue);
240 s += 1;
241 }
242
243 distance = seg->fDistance;
244 ptIndex = seg->fPtIndex;
245 seg += 1;
246 }
247 // SkDebugf("\n");
248 }
249#endif
250}
251
schenney@chromium.orga6d04d92012-01-18 18:02:10 +0000252static void compute_pos_tan(const SkTDArray<SkPoint>& segmentPts, int ptIndex,
reed@android.com8a1c16f2008-12-17 15:59:43 +0000253 int segType, SkScalar t, SkPoint* pos, SkVector* tangent) {
schenney@chromium.orga6d04d92012-01-18 18:02:10 +0000254 const SkPoint* pts = &segmentPts[ptIndex];
reed@android.com8a1c16f2008-12-17 15:59:43 +0000255
256 switch (segType) {
257 case kLine_SegType:
reed@android.com8a1c16f2008-12-17 15:59:43 +0000258 if (pos) {
schenney@chromium.orga6d04d92012-01-18 18:02:10 +0000259 pos->set(SkScalarInterp(pts[0].fX, pts[1].fX, t),
260 SkScalarInterp(pts[0].fY, pts[1].fY, t));
reed@android.com8a1c16f2008-12-17 15:59:43 +0000261 }
262 if (tangent) {
schenney@chromium.orga6d04d92012-01-18 18:02:10 +0000263 tangent->setNormalize(pts[1].fX - pts[0].fX, pts[1].fY - pts[0].fY);
reed@android.com8a1c16f2008-12-17 15:59:43 +0000264 }
265 break;
reed@android.com8a1c16f2008-12-17 15:59:43 +0000266 case kQuad_SegType:
267 SkEvalQuadAt(pts, t, pos, tangent);
268 if (tangent) {
269 tangent->normalize();
270 }
271 break;
272 case kCubic_SegType:
273 SkEvalCubicAt(pts, t, pos, tangent, NULL);
274 if (tangent) {
275 tangent->normalize();
276 }
277 break;
278 default:
tomhudson@google.com0c00f212011-12-28 14:59:50 +0000279 SkDEBUGFAIL("unknown segType");
reed@android.com8a1c16f2008-12-17 15:59:43 +0000280 }
281}
282
schenney@chromium.orga6d04d92012-01-18 18:02:10 +0000283static void seg_to(const SkTDArray<SkPoint>& segmentPts, int ptIndex,
reed@android.com8a1c16f2008-12-17 15:59:43 +0000284 int segType, SkScalar startT, SkScalar stopT, SkPath* dst) {
285 SkASSERT(startT >= 0 && startT <= SK_Scalar1);
286 SkASSERT(stopT >= 0 && stopT <= SK_Scalar1);
287 SkASSERT(startT <= stopT);
288
289 if (SkScalarNearlyZero(stopT - startT)) {
290 return;
291 }
292
schenney@chromium.orga6d04d92012-01-18 18:02:10 +0000293 const SkPoint* pts = &segmentPts[ptIndex];
reed@android.com8a1c16f2008-12-17 15:59:43 +0000294 SkPoint tmp0[7], tmp1[7];
295
296 switch (segType) {
297 case kLine_SegType:
reed@android.com8a1c16f2008-12-17 15:59:43 +0000298 if (stopT == kMaxTValue) {
schenney@chromium.orga6d04d92012-01-18 18:02:10 +0000299 dst->lineTo(pts[1]);
reed@android.com8a1c16f2008-12-17 15:59:43 +0000300 } else {
schenney@chromium.orga6d04d92012-01-18 18:02:10 +0000301 dst->lineTo(SkScalarInterp(pts[0].fX, pts[1].fX, stopT),
302 SkScalarInterp(pts[0].fY, pts[1].fY, stopT));
reed@android.com8a1c16f2008-12-17 15:59:43 +0000303 }
304 break;
reed@android.com8a1c16f2008-12-17 15:59:43 +0000305 case kQuad_SegType:
306 if (startT == 0) {
307 if (stopT == SK_Scalar1) {
308 dst->quadTo(pts[1], pts[2]);
309 } else {
310 SkChopQuadAt(pts, tmp0, stopT);
311 dst->quadTo(tmp0[1], tmp0[2]);
312 }
313 } else {
314 SkChopQuadAt(pts, tmp0, startT);
315 if (stopT == SK_Scalar1) {
316 dst->quadTo(tmp0[3], tmp0[4]);
317 } else {
318 SkChopQuadAt(&tmp0[2], tmp1, SkScalarDiv(stopT - startT,
319 SK_Scalar1 - startT));
320 dst->quadTo(tmp1[1], tmp1[2]);
321 }
322 }
323 break;
324 case kCubic_SegType:
325 if (startT == 0) {
326 if (stopT == SK_Scalar1) {
327 dst->cubicTo(pts[1], pts[2], pts[3]);
328 } else {
329 SkChopCubicAt(pts, tmp0, stopT);
330 dst->cubicTo(tmp0[1], tmp0[2], tmp0[3]);
331 }
332 } else {
333 SkChopCubicAt(pts, tmp0, startT);
334 if (stopT == SK_Scalar1) {
335 dst->cubicTo(tmp0[4], tmp0[5], tmp0[6]);
336 } else {
337 SkChopCubicAt(&tmp0[3], tmp1, SkScalarDiv(stopT - startT,
338 SK_Scalar1 - startT));
339 dst->cubicTo(tmp1[1], tmp1[2], tmp1[3]);
340 }
341 }
342 break;
343 default:
tomhudson@google.com0c00f212011-12-28 14:59:50 +0000344 SkDEBUGFAIL("unknown segType");
reed@android.com8a1c16f2008-12-17 15:59:43 +0000345 sk_throw();
346 }
347}
348
349////////////////////////////////////////////////////////////////////////////////
350////////////////////////////////////////////////////////////////////////////////
351
352SkPathMeasure::SkPathMeasure() {
353 fPath = NULL;
354 fLength = -1; // signal we need to compute it
355 fForceClosed = false;
356 fFirstPtIndex = -1;
357}
358
359SkPathMeasure::SkPathMeasure(const SkPath& path, bool forceClosed) {
360 fPath = &path;
361 fLength = -1; // signal we need to compute it
362 fForceClosed = forceClosed;
363 fFirstPtIndex = -1;
364
365 fIter.setPath(path, forceClosed);
366}
367
368SkPathMeasure::~SkPathMeasure() {}
369
370/** Assign a new path, or null to have none.
371*/
372void SkPathMeasure::setPath(const SkPath* path, bool forceClosed) {
373 fPath = path;
374 fLength = -1; // signal we need to compute it
375 fForceClosed = forceClosed;
376 fFirstPtIndex = -1;
377
378 if (path) {
379 fIter.setPath(*path, forceClosed);
380 }
381 fSegments.reset();
schenney@chromium.orga6d04d92012-01-18 18:02:10 +0000382 fPts.reset();
reed@android.com8a1c16f2008-12-17 15:59:43 +0000383}
384
385SkScalar SkPathMeasure::getLength() {
386 if (fPath == NULL) {
387 return 0;
388 }
389 if (fLength < 0) {
390 this->buildSegments();
391 }
392 SkASSERT(fLength >= 0);
393 return fLength;
394}
395
396const SkPathMeasure::Segment* SkPathMeasure::distanceToSegment(
397 SkScalar distance, SkScalar* t) {
398 SkDEBUGCODE(SkScalar length = ) this->getLength();
399 SkASSERT(distance >= 0 && distance <= length);
400
401 const Segment* seg = fSegments.begin();
402 int count = fSegments.count();
403
404 int index = SkTSearch<SkScalar>(&seg->fDistance, count, distance,
405 sizeof(Segment));
406 // don't care if we hit an exact match or not, so we xor index if it is negative
407 index ^= (index >> 31);
408 seg = &seg[index];
409
410 // now interpolate t-values with the prev segment (if possible)
411 SkScalar startT = 0, startD = 0;
412 // check if the prev segment is legal, and references the same set of points
413 if (index > 0) {
414 startD = seg[-1].fDistance;
415 if (seg[-1].fPtIndex == seg->fPtIndex) {
416 SkASSERT(seg[-1].fType == seg->fType);
417 startT = seg[-1].getScalarT();
418 }
419 }
420
421 SkASSERT(seg->getScalarT() > startT);
422 SkASSERT(distance >= startD);
423 SkASSERT(seg->fDistance > startD);
424
425 *t = startT + SkScalarMulDiv(seg->getScalarT() - startT,
426 distance - startD,
427 seg->fDistance - startD);
428 return seg;
429}
430
431bool SkPathMeasure::getPosTan(SkScalar distance, SkPoint* pos,
432 SkVector* tangent) {
433 SkASSERT(fPath);
434 if (fPath == NULL) {
reed@android.com8a1c16f2008-12-17 15:59:43 +0000435 return false;
436 }
437
438 SkScalar length = this->getLength(); // call this to force computing it
439 int count = fSegments.count();
440
441 if (count == 0 || length == 0) {
schenney@chromium.orga6d04d92012-01-18 18:02:10 +0000442 return false;
reed@android.com8a1c16f2008-12-17 15:59:43 +0000443 }
444
445 // pin the distance to a legal range
446 if (distance < 0) {
447 distance = 0;
448 } else if (distance > length) {
449 distance = length;
450 }
451
452 SkScalar t;
453 const Segment* seg = this->distanceToSegment(distance, &t);
454
schenney@chromium.orga6d04d92012-01-18 18:02:10 +0000455 compute_pos_tan(fPts, seg->fPtIndex, seg->fType, t, pos, tangent);
reed@android.com8a1c16f2008-12-17 15:59:43 +0000456 return true;
457}
458
459bool SkPathMeasure::getMatrix(SkScalar distance, SkMatrix* matrix,
460 MatrixFlags flags) {
461 SkPoint position;
462 SkVector tangent;
463
464 if (this->getPosTan(distance, &position, &tangent)) {
465 if (matrix) {
466 if (flags & kGetTangent_MatrixFlag) {
467 matrix->setSinCos(tangent.fY, tangent.fX, 0, 0);
468 } else {
469 matrix->reset();
470 }
471 if (flags & kGetPosition_MatrixFlag) {
472 matrix->postTranslate(position.fX, position.fY);
473 }
474 }
475 return true;
476 }
477 return false;
478}
479
480bool SkPathMeasure::getSegment(SkScalar startD, SkScalar stopD, SkPath* dst,
481 bool startWithMoveTo) {
482 SkASSERT(dst);
483
484 SkScalar length = this->getLength(); // ensure we have built our segments
485
486 if (startD < 0) {
487 startD = 0;
488 }
489 if (stopD > length) {
490 stopD = length;
491 }
492 if (startD >= stopD) {
493 return false;
494 }
495
496 SkPoint p;
497 SkScalar startT, stopT;
498 const Segment* seg = this->distanceToSegment(startD, &startT);
499 const Segment* stopSeg = this->distanceToSegment(stopD, &stopT);
500 SkASSERT(seg <= stopSeg);
501
502 if (startWithMoveTo) {
schenney@chromium.orga6d04d92012-01-18 18:02:10 +0000503 compute_pos_tan(fPts, seg->fPtIndex, seg->fType, startT, &p, NULL);
reed@android.com8a1c16f2008-12-17 15:59:43 +0000504 dst->moveTo(p);
505 }
506
507 if (seg->fPtIndex == stopSeg->fPtIndex) {
schenney@chromium.orga6d04d92012-01-18 18:02:10 +0000508 seg_to(fPts, seg->fPtIndex, seg->fType, startT, stopT, dst);
reed@android.com8a1c16f2008-12-17 15:59:43 +0000509 } else {
510 do {
schenney@chromium.orga6d04d92012-01-18 18:02:10 +0000511 seg_to(fPts, seg->fPtIndex, seg->fType, startT, SK_Scalar1, dst);
reed@android.com8a1c16f2008-12-17 15:59:43 +0000512 seg = SkPathMeasure::NextSegment(seg);
513 startT = 0;
514 } while (seg->fPtIndex < stopSeg->fPtIndex);
schenney@chromium.orga6d04d92012-01-18 18:02:10 +0000515 seg_to(fPts, seg->fPtIndex, seg->fType, 0, stopT, dst);
reed@android.com8a1c16f2008-12-17 15:59:43 +0000516 }
517 return true;
518}
519
520bool SkPathMeasure::isClosed() {
521 (void)this->getLength();
522 return fIsClosed;
523}
524
525/** Move to the next contour in the path. Return true if one exists, or false if
526 we're done with the path.
527*/
528bool SkPathMeasure::nextContour() {
529 fLength = -1;
530 return this->getLength() > 0;
531}
532
533///////////////////////////////////////////////////////////////////////////////
534///////////////////////////////////////////////////////////////////////////////
535
536#ifdef SK_DEBUG
537
538void SkPathMeasure::dump() {
539 SkDebugf("pathmeas: length=%g, segs=%d\n", fLength, fSegments.count());
540
541 for (int i = 0; i < fSegments.count(); i++) {
542 const Segment* seg = &fSegments[i];
543 SkDebugf("pathmeas: seg[%d] distance=%g, point=%d, t=%g, type=%d\n",
544 i, seg->fDistance, seg->fPtIndex, seg->getScalarT(),
545 seg->fType);
546 }
547}
548
reed@android.com8a1c16f2008-12-17 15:59:43 +0000549#endif