Added negative arcs to the OS X backend. Now we have a crash in one of the tests; still debugging.

This commit is contained in:
Pietro Gagliardi 2015-10-11 23:48:40 -04:00
parent 0989454106
commit f4b0e7e35e
2 changed files with 20 additions and 16 deletions

View File

@ -30,7 +30,7 @@ void uiDrawPathNewFigure(uiDrawPath *p, double x, double y)
CGPathMoveToPoint(p->path, NULL, x, y); CGPathMoveToPoint(p->path, NULL, x, y);
} }
void uiDrawPathNewFigureWithArc(uiDrawPath *p, double xCenter, double yCenter, double radius, double startAngle, double sweep) void uiDrawPathNewFigureWithArc(uiDrawPath *p, double xCenter, double yCenter, double radius, double startAngle, double sweep, int negative)
{ {
double sinStart, cosStart; double sinStart, cosStart;
double startx, starty; double startx, starty;
@ -42,7 +42,7 @@ void uiDrawPathNewFigureWithArc(uiDrawPath *p, double xCenter, double yCenter, d
startx = xCenter + radius * cosStart; startx = xCenter + radius * cosStart;
starty = yCenter + radius * sinStart; starty = yCenter + radius * sinStart;
CGPathMoveToPoint(p->path, NULL, startx, starty); CGPathMoveToPoint(p->path, NULL, startx, starty);
uiDrawPathArcTo(p, xCenter, yCenter, radius, startAngle, sweep); uiDrawPathArcTo(p, xCenter, yCenter, radius, startAngle, sweep, negative);
} }
void uiDrawPathLineTo(uiDrawPath *p, double x, double y) void uiDrawPathLineTo(uiDrawPath *p, double x, double y)
@ -52,16 +52,22 @@ void uiDrawPathLineTo(uiDrawPath *p, double x, double y)
CGPathAddLineToPoint(p->path, NULL, x, y); CGPathAddLineToPoint(p->path, NULL, x, y);
} }
void uiDrawPathArcTo(uiDrawPath *p, double xCenter, double yCenter, double radius, double startAngle, double sweep) void uiDrawPathArcTo(uiDrawPath *p, double xCenter, double yCenter, double radius, double startAngle, double sweep, int negative)
{ {
bool cw;
if (p->ended) if (p->ended)
complain("attempt to add arc to ended path in uiDrawPathArcTo()"); complain("attempt to add arc to ended path in uiDrawPathArcTo()");
if (sweep > 2 * M_PI) if (sweep > 2 * M_PI)
sweep = 2 * M_PI; sweep = 2 * M_PI;
CGPathAddRelativeArc(p->path, NULL, cw = false;
if (negative)
cw = true;
CGPathAddArc(p->path, NULL,
xCenter, yCenter, xCenter, yCenter,
radius, radius,
startAngle, sweep); startAngle, startAngle + sweep,
cw);
} }
void uiDrawPathBezierTo(uiDrawPath *p, double c1x, double c1y, double c2x, double c2y, double endX, double endY) void uiDrawPathBezierTo(uiDrawPath *p, double c1x, double c1y, double c2x, double c2y, double endX, double endY)
@ -137,7 +143,6 @@ void uiDrawStroke(uiDrawContext *c, uiDrawPath *path, uiDrawBrush *b, uiDrawStro
switch (p->Join) { switch (p->Join) {
case uiDrawLineJoinMiter: case uiDrawLineJoinMiter:
join = kCGLineJoinMiter; join = kCGLineJoinMiter;
CGContextSetMiterLimit(c->c, p->MiterLimit);
break; break;
case uiDrawLineJoinRound: case uiDrawLineJoinRound:
join = kCGLineJoinRound; join = kCGLineJoinRound;

View File

@ -1160,21 +1160,21 @@ static void drawCSFillStyle(uiAreaDrawParams *p)
sp.Thickness = 6; sp.Thickness = 6;
path = uiDrawNewPath(uiDrawFillModeAlternate); path = uiDrawNewPath(uiDrawFillModeAlternate);
uiDrawPathAddRectangle(path, 12, 12, 232, 70); // uiDrawPathAddRectangle(path, 12, 12, 232, 70);
uiDrawPathNewFigureWithArc(path, uiDrawPathNewFigureWithArc(path,
64, 64, 64, 64,
40, 40,
0, 2*M_PI, 0, 2*M_PI,
0); 0);
uiDrawPathNewFigureWithArc(path, /* uiDrawPathNewFigureWithArc(path,
192, 64, 192, 64,
40, 40,
0, -2*M_PI, 0, -2*M_PI,
1); 1);
uiDrawPathEnd(path); */ uiDrawPathEnd(path);
crsourcergba(&source, 0, 0.7, 0, 1); crsourcergba(&source, 0, 0.7, 0, 1);
uiDrawFill(p->Context, path, &source); // uiDrawFill(p->Context, path, &source);
crsourcergba(&source, 0, 0, 0, 1); crsourcergba(&source, 0, 0, 0, 1);
uiDrawStroke(p->Context, path, &source, &sp); uiDrawStroke(p->Context, path, &source, &sp);
uiDrawFreePath(path); uiDrawFreePath(path);
@ -1184,9 +1184,8 @@ static void drawCSFillStyle(uiAreaDrawParams *p)
uiDrawTransform(p->Context, &m); uiDrawTransform(p->Context, &m);
path = uiDrawNewPath(uiDrawFillModeWinding); path = uiDrawNewPath(uiDrawFillModeWinding);
uiDrawPathAddRectangle(path, 12, 12, 232, 70); // uiDrawPathAddRectangle(path, 12, 12, 232, 70);
// TODO THIS DOESN'T WORK. /* uiDrawPathNewFigureWithArc(path,
uiDrawPathNewFigureWithArc(path,
64, 64, 64, 64,
40, 40,
0, 2*M_PI, 0, 2*M_PI,
@ -1196,12 +1195,12 @@ static void drawCSFillStyle(uiAreaDrawParams *p)
40, 40,
0, -2*M_PI, 0, -2*M_PI,
1); 1);
uiDrawPathEnd(path); */ uiDrawPathEnd(path);
crsourcergba(&source, 0, 0, 0.9, 1); crsourcergba(&source, 0, 0, 0.9, 1);
uiDrawFill(p->Context, path, &source); // uiDrawFill(p->Context, path, &source);
crsourcergba(&source, 0, 0, 0, 1); crsourcergba(&source, 0, 0, 0, 1);
uiDrawStroke(p->Context, path, &source, &sp); // uiDrawStroke(p->Context, path, &source, &sp);
uiDrawFreePath(path); uiDrawFreePath(path);
} }