using namespace tvg;
-constexpr auto SW_CURVE_TAG_ON = 1;
-constexpr auto SW_CURVE_TAG_CUBIC = 2;
+constexpr auto SW_CURVE_TYPE_POINT = 0;
+constexpr auto SW_CURVE_TYPE_CUBIC = 1;
constexpr auto SW_OUTLINE_FILL_WINDING = 0;
constexpr auto SW_OUTLINE_FILL_EVEN_ODD = 1;
SwPoint* pts; //the outline's points
size_t ptsCnt; //number of points in the glyph
size_t reservedPtsCnt;
- char* tags; //the points flags
+ uint8_t* types; //curve type
uint8_t fillMode; //outline fill mode
};
assert(limit);
auto pt = outline->pts + first;
- auto tags = outline->tags + first;
+ auto types = outline->types + first;
/* A contour cannot start with a cubic control point! */
- if (tags[0] == SW_CURVE_TAG_CUBIC) goto invalid_outline;
+ if (types[0] == SW_CURVE_TYPE_CUBIC) goto invalid_outline;
_moveTo(rw, UPSCALE(outline->pts[first]));
while (pt < limit) {
assert(++pt);
- assert(++tags);
+ assert(++types);
//emit a single line_to
- if (tags[0] == SW_CURVE_TAG_ON) {
+ if (types[0] == SW_CURVE_TYPE_POINT) {
_lineTo(rw, UPSCALE(*pt));
- //tag cubic
+ //types cubic
} else {
- if (pt + 1 > limit || tags[1] != SW_CURVE_TAG_CUBIC)
+ if (pt + 1 > limit || types[1] != SW_CURVE_TYPE_CUBIC)
goto invalid_outline;
pt += 2;
- tags += 2;
+ types += 2;
if (pt <= limit) {
_cubicTo(rw, UPSCALE(pt[-2]), UPSCALE(pt[-1]), UPSCALE(pt[0]));
if (n == 0) {
free(outline.pts);
outline.pts = nullptr;
- free(outline.tags);
- outline.tags = nullptr;
+ free(outline.types);
+ outline.types = nullptr;
outline.reservedPtsCnt = 0;
outline.ptsCnt = 0;
return;
outline.reservedPtsCnt = n;
outline.pts = static_cast<SwPoint*>(realloc(outline.pts, n * sizeof(SwPoint)));
assert(outline.pts);
- outline.tags = static_cast<char*>(realloc(outline.tags, n * sizeof(char)));
- assert(outline.tags);
+ outline.types = static_cast<uint8_t*>(realloc(outline.types, n * sizeof(uint8_t)));
+ assert(outline.types);
}
_growOutlinePoint(outline, 1);
outline.pts[outline.ptsCnt] = TO_SWPOINT(to);
- outline.tags[outline.ptsCnt] = SW_CURVE_TAG_ON;
+ outline.types[outline.ptsCnt] = SW_CURVE_TYPE_POINT;
if (outline.ptsCnt > 0) {
_growOutlineContour(outline, 1);
_growOutlinePoint(outline, 1);
outline.pts[outline.ptsCnt] = TO_SWPOINT(to);
- outline.tags[outline.ptsCnt] = SW_CURVE_TAG_ON;
+ outline.types[outline.ptsCnt] = SW_CURVE_TYPE_POINT;
++outline.ptsCnt;
}
_growOutlinePoint(outline, 3);
outline.pts[outline.ptsCnt] = TO_SWPOINT(ctrl1);
- outline.tags[outline.ptsCnt] = SW_CURVE_TAG_CUBIC;
+ outline.types[outline.ptsCnt] = SW_CURVE_TYPE_CUBIC;
++outline.ptsCnt;
outline.pts[outline.ptsCnt] = TO_SWPOINT(ctrl2);
- outline.tags[outline.ptsCnt] = SW_CURVE_TAG_CUBIC;
+ outline.types[outline.ptsCnt] = SW_CURVE_TYPE_CUBIC;
++outline.ptsCnt;
outline.pts[outline.ptsCnt] = TO_SWPOINT(to);
- outline.tags[outline.ptsCnt] = SW_CURVE_TAG_ON;
+ outline.types[outline.ptsCnt] = SW_CURVE_TYPE_POINT;
++outline.ptsCnt;
}
_growOutlinePoint(outline, 1);
outline.pts[outline.ptsCnt] = outline.pts[i];
- outline.tags[outline.ptsCnt] = SW_CURVE_TAG_ON;
+ outline.types[outline.ptsCnt] = SW_CURVE_TYPE_POINT;
++outline.ptsCnt;
return true;
SwOutline* outline = sdata.outline;
if (outline->cntrs) free(outline->cntrs);
if (outline->pts) free(outline->pts);
- if (outline->tags) free(outline->tags);
+ if (outline->types) free(outline->types);
free(outline);
sdata.outline = nullptr;