Beispiel #1
0
void
PathBuilderCG::QuadraticBezierTo(const Point &aCP1,
                                 const Point &aCP2)
{
  if (!aCP1.IsFinite() || !aCP2.IsFinite()) {
    return;
  }

  if (CGPathIsEmpty(mCGPath))
    MoveTo(aCP1);
  CGPathAddQuadCurveToPoint(mCGPath, nullptr,
                            aCP1.x, aCP1.y,
                            aCP2.x, aCP2.y);
}
Beispiel #2
0
void
PathBuilderCG::Arc(const Point &aOrigin, Float aRadius, Float aStartAngle,
                 Float aEndAngle, bool aAntiClockwise)
{
  if (!aOrigin.IsFinite() || !IsFinite(aRadius) ||
      !IsFinite(aStartAngle) || !IsFinite(aEndAngle)) {
    return;
  }

  // Disabled for now due to a CG bug when using CGPathAddArc with stroke
  // dashing and rotation transforms that are multiples of 90 degrees. See:
  // https://bugzilla.mozilla.org/show_bug.cgi?id=949661#c8
#if 0
  // Core Graphic's initial coordinate system is y-axis up, whereas Moz2D's is
  // y-axis down. Core Graphics therefore considers "clockwise" to mean "sweep
  // in the direction of decreasing angle" whereas Moz2D considers it to mean
  // "sweep in the direction of increasing angle". In other words if this
  // Moz2D method is instructed to sweep anti-clockwise we need to tell
  // CGPathAddArc to sweep clockwise, and vice versa. Hence why we pass the
  // value of aAntiClockwise directly to CGPathAddArc's "clockwise" bool
  // parameter.
  CGPathAddArc(mCGPath, nullptr,
               aOrigin.x, aOrigin.y,
               aRadius,
               aStartAngle,
               aEndAngle,
               aAntiClockwise);
#endif
  ArcToBezier(this, aOrigin, Size(aRadius, aRadius), aStartAngle, aEndAngle,
              aAntiClockwise);
}
Beispiel #3
0
void
PathBuilderCG::MoveTo(const Point &aPoint)
{
  if (!aPoint.IsFinite()) {
    return;
  }
  CGPathMoveToPoint(mCGPath, nullptr, aPoint.x, aPoint.y);
}
Beispiel #4
0
void
PathBuilderCG::LineTo(const Point &aPoint)
{
  if (!aPoint.IsFinite()) {
    return;
  }

  if (CGPathIsEmpty(mCGPath))
    MoveTo(aPoint);
  else
    CGPathAddLineToPoint(mCGPath, nullptr, aPoint.x, aPoint.y);
}