NS_IMETHODIMP nsThebesRenderingContext::Translate(nscoord aX, nscoord aY) { PR_LOG(gThebesGFXLog, PR_LOG_DEBUG, ("## %p nsTRC::Translate %d %d\n", this, aX, aY)); mThebes->Translate (gfxPoint(FROM_TWIPS(aX), FROM_TWIPS(aY))); return NS_OK; }
void nsThebesRenderingContext::TransformCoord (nscoord *aX, nscoord *aY) { PR_LOG(gThebesGFXLog, PR_LOG_DEBUG, ("## %p nsTRC::TransformCoord\n", this)); gfxPoint pt(FROM_TWIPS(*aX), FROM_TWIPS(*aY)); pt = mThebes->UserToDevice (pt); *aX = TO_TWIPS(pt.x); *aY = TO_TWIPS(pt.y); }
void nsRenderingContext::FillPolygon(const nsPoint twPoints[], PRInt32 aNumPoints) { if (aNumPoints == 0) return; nsAutoArrayPtr<gfxPoint> pxPoints(new gfxPoint[aNumPoints]); for (int i = 0; i < aNumPoints; i++) { pxPoints[i].x = FROM_TWIPS(twPoints[i].x); pxPoints[i].y = FROM_TWIPS(twPoints[i].y); } mThebes->NewPath(); mThebes->Polygon(pxPoints, aNumPoints); mThebes->Fill(); }
NS_IMETHODIMP nsThebesRenderingContext::DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1) { PR_LOG(gThebesGFXLog, PR_LOG_DEBUG, ("## %p nsTRC::DrawLine %d %d %d %d\n", this, aX0, aY0, aX1, aY1)); gfxPoint p0 = gfxPoint(FROM_TWIPS(aX0), FROM_TWIPS(aY0)); gfxPoint p1 = gfxPoint(FROM_TWIPS(aX1), FROM_TWIPS(aY1)); // we can't draw thick lines with gfx, so we always assume we want pixel-aligned // lines if the rendering context is at 1.0 scale gfxMatrix savedMatrix = mThebes->CurrentMatrix(); if (!savedMatrix.HasNonTranslation()) { p0 = mThebes->UserToDevice(p0); p1 = mThebes->UserToDevice(p1); p0.Round(); p1.Round(); mThebes->IdentityMatrix(); mThebes->NewPath(); // snap straight lines if (p0.x == p1.x) { mThebes->Line(p0 + gfxPoint(0.5, 0), p1 + gfxPoint(0.5, 0)); } else if (p0.y == p1.y) { mThebes->Line(p0 + gfxPoint(0, 0.5), p1 + gfxPoint(0, 0.5)); } else { mThebes->Line(p0, p1); } mThebes->Stroke(); mThebes->SetMatrix(savedMatrix); } else { mThebes->NewPath(); mThebes->Line(p0, p1); mThebes->Stroke(); } return NS_OK; }
void nsRenderingContext::DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1) { gfxPoint p0 = gfxPoint(FROM_TWIPS(aX0), FROM_TWIPS(aY0)); gfxPoint p1 = gfxPoint(FROM_TWIPS(aX1), FROM_TWIPS(aY1)); // we can't draw thick lines with gfx, so we always assume we want // pixel-aligned lines if the rendering context is at 1.0 scale gfxMatrix savedMatrix = mThebes->CurrentMatrix(); if (!savedMatrix.HasNonTranslation()) { p0 = mThebes->UserToDevice(p0); p1 = mThebes->UserToDevice(p1); p0.Round(); p1.Round(); mThebes->IdentityMatrix(); mThebes->NewPath(); // snap straight lines if (p0.x == p1.x) { mThebes->Line(p0 + gfxPoint(0.5, 0), p1 + gfxPoint(0.5, 0)); } else if (p0.y == p1.y) { mThebes->Line(p0 + gfxPoint(0, 0.5), p1 + gfxPoint(0, 0.5)); } else { mThebes->Line(p0, p1); } mThebes->Stroke(); mThebes->SetMatrix(savedMatrix); } else { mThebes->NewPath(); mThebes->Line(p0, p1); mThebes->Stroke(); } }
NS_IMETHODIMP nsThebesRenderingContext::FillPolygon(const nsPoint twPoints[], PRInt32 aNumPoints) { PR_LOG(gThebesGFXLog, PR_LOG_DEBUG, ("## %p nsTRC::FillPolygon %d\n", this, aNumPoints)); if (aNumPoints == 0) return NS_OK; if (aNumPoints == 4) { } nsAutoArrayPtr<gfxPoint> pxPoints(new gfxPoint[aNumPoints]); for (int i = 0; i < aNumPoints; i++) { pxPoints[i].x = FROM_TWIPS(twPoints[i].x); pxPoints[i].y = FROM_TWIPS(twPoints[i].y); } mThebes->NewPath(); mThebes->Polygon(pxPoints, aNumPoints); mThebes->Fill(); return NS_OK; }
void nsRenderingContext::FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) { mThebes->NewPath(); mThebes->Ellipse(gfxPoint(FROM_TWIPS(aX) + FROM_TWIPS(aWidth)/2.0, FROM_TWIPS(aY) + FROM_TWIPS(aHeight)/2.0), gfxSize(FROM_TWIPS(aWidth), FROM_TWIPS(aHeight))); mThebes->Fill(); }
NS_IMETHODIMP nsThebesRenderingContext::FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) { PR_LOG(gThebesGFXLog, PR_LOG_DEBUG, ("## %p nsTRC::FillEllipse [%d,%d,%d,%d]\n", this, aX, aY, aWidth, aHeight)); mThebes->NewPath(); mThebes->Ellipse(gfxPoint(FROM_TWIPS(aX) + FROM_TWIPS(aWidth)/2.0, FROM_TWIPS(aY) + FROM_TWIPS(aHeight)/2.0), gfxSize(FROM_TWIPS(aWidth), FROM_TWIPS(aHeight))); mThebes->Fill(); return NS_OK; }
void nsRenderingContext::Translate(const nsPoint& aPt) { mThebes->Translate(gfxPoint(FROM_TWIPS(aPt.x), FROM_TWIPS(aPt.y))); }