DrawFill(gdiplusCanvas->GetGraphics(), brush, aGrad,
DrawFill(gdiplusCanvas->GetGraphics(), pattern ? pattern : &brush, aGrad,
nsSVGGDIPlusGlyphGeometry::Render(nsISVGRendererCanvas *canvas){  // make sure that we have constructed our render objects  if (!mCoveredRegion) {    nsCOMPtr<nsISVGRendererRegion> region;    Update(nsISVGGeometrySource::UPDATEMASK_ALL, getter_AddRefs(region));  }  nsCOMPtr<nsISVGGDIPlusCanvas> gdiplusCanvas = do_QueryInterface(canvas);  NS_ASSERTION(gdiplusCanvas, "wrong svg canvas for geometry!");  if (!gdiplusCanvas) return NS_ERROR_FAILURE;  PRUint16 canvasRenderMode;  canvas->GetRenderMode(&canvasRenderMode);  if (canvasRenderMode == nsISVGRendererCanvas::SVG_RENDER_MODE_CLIP) {    nsCOMPtr<nsISVGGDIPlusGlyphMetrics> metrics;    {      nsCOMPtr<nsISVGRendererGlyphMetrics> xpmetrics;      mSource->GetMetrics(getter_AddRefs(xpmetrics));      metrics = do_QueryInterface(xpmetrics);      NS_ASSERTION(metrics, "wrong metrics object!");      if (!metrics)        return NS_ERROR_FAILURE;    }      FontFamily fontFamily;    metrics->GetFont()->GetFamily(&fontFamily);      nsAutoString text;    mSource->GetCharacterData(text);    float x,y;    mSource->GetX(&x);    mSource->GetY(&y);      GraphicsPath path;    path.AddString(PromiseFlatString(text).get(), -1,                   &fontFamily, metrics->GetFont()->GetStyle(),                   metrics->GetFont()->GetSize(),                   PointF(x,y), StringFormat::GenericTypographic());    PRUint16 rule;    mSource->GetClipRule(&rule);    if (rule == nsISVGGeometrySource::FILL_RULE_EVENODD)      path.SetFillMode(FillModeAlternate);    else      path.SetFillMode(FillModeWinding);    Region *region = gdiplusCanvas->GetClipRegion();    if (region)      region->Union(&path);    return NS_OK;  }  PRBool hasFill = PR_FALSE, hasStroke = PR_FALSE;  PRUint16 filltype, stroketype;  PRUint16 fillServerType = 0, strokeServerType = 0;  mSource->GetFillPaintType(&filltype);  if (filltype != nsISVGGeometrySource::PAINT_TYPE_NONE)    hasFill = PR_TRUE;  if (filltype == nsISVGGeometrySource::PAINT_TYPE_SERVER) {    if(NS_FAILED(mSource->GetFillPaintServerType(&fillServerType)))      hasFill = PR_FALSE;  }  mSource->GetStrokePaintType(&stroketype);  if (stroketype != nsISVGGeometrySource::PAINT_TYPE_NONE && mStroke)    hasStroke = PR_TRUE;  if (stroketype == nsISVGGeometrySource::PAINT_TYPE_SERVER) {    if(NS_FAILED(mSource->GetStrokePaintServerType(&strokeServerType)))      hasStroke = PR_FALSE;  }  if (!hasFill && !hasStroke) return NS_OK; // nothing to paint    gdiplusCanvas->GetGraphics()->SetSmoothingMode(SmoothingModeAntiAlias);  //gdiplusCanvas->GetGraphics()->SetPixelOffsetMode(PixelOffsetModeHalf);    nsAutoString text;  mSource->GetCharacterData(text);  float x,y;  mSource->GetX(&x);  mSource->GetY(&y);  if (hasFill) {    nscolor color;    mSource->GetFillPaint(&color);    float opacity;    mSource->GetFillOpacity(&opacity);    SolidBrush brush(Color((BYTE)(opacity*255),NS_GET_R(color),NS_GET_G(color),NS_GET_B(color)));      nsCOMPtr<nsISVGGradient> aGrad;    if (filltype != nsISVGGeometrySource::PAINT_TYPE_SOLID_COLOR) {      if (fillServerType == nsISVGGeometrySource::PAINT_TYPE_GRADIENT) {        mSource->GetFillGradient(getter_AddRefs(aGrad));      }    }      nsAutoString text;    mSource->GetCharacterData(text);    DrawFill(gdiplusCanvas->GetGraphics(), brush, aGrad,             PromiseFlatString(text).get(), text.Length(), x, y);  }    if (hasStroke) {    nscolor color;    mSource->GetStrokePaint(&color);            float opacity;    mSource->GetStrokeOpacity(&opacity);      nsCOMPtr<nsISVGGradient> aGrad;    if (stroketype != nsISVGGeometrySource::PAINT_TYPE_SOLID_COLOR) {      if (strokeServerType == nsISVGGeometrySource::PAINT_TYPE_GRADIENT) {        mSource->GetStrokeGradient(getter_AddRefs(aGrad));      }    }    SolidBrush brush(Color((BYTE)(opacity*255), NS_GET_R(color), NS_GET_G(color), NS_GET_B(color)));    // this is the 'normal' case    if (stroketype == nsISVGGeometrySource::PAINT_TYPE_SOLID_COLOR) {      gdiplusCanvas->GetGraphics()->FillPath(&brush, mStroke);    } else if (strokeServerType == nsISVGGeometrySource::PAINT_TYPE_GRADIENT) {      nsCOMPtr<nsISVGRendererRegion> region;      GetCoveredRegion(getter_AddRefs(region));      nsCOMPtr<nsISVGGDIPlusRegion> aRegion = do_QueryInterface(region);      nsCOMPtr<nsIDOMSVGMatrix> ctm;      mSource->GetCanvasTM(getter_AddRefs(ctm));              GDIPlusGradient(aRegion, aGrad, ctm,                      gdiplusCanvas->GetGraphics(), mSource,                      gradCBPath, this);    }  }    return NS_OK;}