GDIPlusLinearGradient(nsISVGGradient *aGrad, Matrix *aMatrix, Graphics *aGFX,
GDIPlusLinearGradient(nsISVGGradient *aGrad, Matrix *aMatrix, Graphics *aGFX, Matrix *aCTM,
GDIPlusLinearGradient(nsISVGGradient *aGrad, Matrix *aMatrix, Graphics *aGFX,                      void(*aCallback)(Graphics *, Brush*, void *), void *aData){  float fX1, fY1, fX2, fY2;      nsCOMPtr<nsISVGLinearGradient>aLgrad = do_QueryInterface(aGrad);  NS_ASSERTION(aLgrad, "error gradient did not provide a Linear Gradient interface");    aLgrad->GetX1(&fX1);  aLgrad->GetX2(&fX2);  aLgrad->GetY1(&fY1);  aLgrad->GetY2(&fY2);  LinearGradientBrush gradient(PointF(fX1, fY1), PointF(fX2, fY2),                               Color(0xff, 0, 0), Color(0, 0xff, 0));  PRUint16 aSpread;  aGrad->GetSpreadMethod(&aSpread);  if (aSpread == nsIDOMSVGGradientElement::SVG_SPREADMETHOD_PAD)    gradient.SetWrapMode(WrapModeTileFlipX);  else if (aSpread == nsIDOMSVGGradientElement::SVG_SPREADMETHOD_REFLECT)    gradient.SetWrapMode(WrapModeTileFlipX);  else if (aSpread == nsIDOMSVGGradientElement::SVG_SPREADMETHOD_REPEAT)    gradient.SetWrapMode(WrapModeTile);  PRUint32 nStops;  Color *stopsCol;  REAL *stopsPos;  GDIPlusGetStops(aGrad, &stopsCol, &stopsPos, &nStops, PR_FALSE);  gradient.SetInterpolationColors(stopsCol, stopsPos, nStops);  SolidBrush leftBrush(stopsCol[0]);  SolidBrush rightBrush(stopsCol[nStops-1]);  delete [] stopsCol;  delete [] stopsPos;  gradient.MultiplyTransform(aMatrix, MatrixOrderAppend);  if (aSpread == nsIDOMSVGGradientElement::SVG_SPREADMETHOD_PAD) {    float dx = fX2 - fX1;    float dy = fY2 - fY1;    // what we really want is a halfspace, but we don't have that...#define INF 100    PointF rect[4];    rect[0].X = fX1 + dy; rect[0].Y = fY1 - dx;    rect[1].X = fX2 + dy; rect[1].Y = fY2 - dx;    rect[2].X = fX2 - dy; rect[2].Y = fY2 + dx;    rect[3].X = fX1 - dy; rect[3].Y = fY1 + dx;        GraphicsPath left;    left.StartFigure();    rect[0].X = fX1 + INF * dy;  rect[0].Y = fY1 - INF * dx;    rect[1].X = fX1 + INF * dx + INF * dy;  rect[1].Y = fY1 + INF * dy - INF * dx;    rect[2].X = fX1 + INF * dx - INF * dy;  rect[2].Y = fY1 + INF * dy + INF * dx;    rect[3].X = fX1 - INF * dy;  rect[3].Y = fY1 + INF * dx;    left.AddPolygon(rect, 4);    left.Transform(aMatrix);        GraphicsPath center;    center.StartFigure();    rect[0].X = fX1 + INF * dy;  rect[0].Y = fY1 - INF * dx;    rect[1].X = fX2 + INF * dy;  rect[1].Y = fY2 - INF * dx;    rect[2].X = fX2 - INF * dy;  rect[2].Y = fY2 + INF * dx;    rect[3].X = fX1 - INF * dy;  rect[3].Y = fY1 + INF * dx;    center.AddPolygon(rect, 4);    center.Transform(aMatrix);        GraphicsPath right;    right.StartFigure();    rect[0].X = fX2 - INF * dx + INF * dy;  rect[0].Y = fY2 - INF * dy - INF * dx;    rect[1].X = fX2 + INF * dy;  rect[1].Y = fY2 - INF * dx;    rect[2].X = fX2 - INF * dy;  rect[2].Y = fY2 + INF * dx;    rect[3].X = fX2 - INF * dx - INF * dy;  rect[3].Y = fY2 - INF * dy + INF * dx;    right.AddPolygon(rect, 4);    right.Transform(aMatrix);        Region leftRegion(&left), centerRegion(&center), rightRegion(&right), oldClip;    aGFX->GetClip(&oldClip);        aGFX->SetClip(&leftRegion, CombineModeExclude);    aCallback(aGFX, &leftBrush, aData);    aGFX->SetClip(&oldClip);        aGFX->SetClip(&centerRegion, CombineModeIntersect);    aCallback(aGFX, &gradient, aData);    aGFX->SetClip(&oldClip);        aGFX->SetClip(&rightRegion, CombineModeExclude);    aCallback(aGFX, &rightBrush, aData);    aGFX->SetClip(&oldClip);  } else {    aCallback(aGFX, &gradient, aData);  }}