Bug 376929 - Remove direct use of cairo from SVG path generation.r=jwatt, sr=roc

This commit is contained in:
tor@cs.brown.edu 2007-04-16 13:57:09 -07:00
parent dbedaced03
commit c972330b62
20 changed files with 108 additions and 227 deletions

View File

@ -41,6 +41,7 @@
#include "nsSVGLength2.h"
#include "nsGkAtoms.h"
#include "nsSVGUtils.h"
#include "gfxContext.h"
typedef nsSVGPathGeometryElement nsSVGCircleElementBase;
@ -63,7 +64,7 @@ public:
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGCircleElementBase::)
// nsSVGPathGeometryElement methods:
virtual void ConstructPath(cairo_t *aCtx);
virtual void ConstructPath(gfxContext *aCtx);
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
@ -147,12 +148,12 @@ nsSVGCircleElement::GetLengthInfo()
// nsSVGPathGeometryElement methods
void
nsSVGCircleElement::ConstructPath(cairo_t *aCtx)
nsSVGCircleElement::ConstructPath(gfxContext *aCtx)
{
float x, y, r;
GetAnimatedLengthValues(&x, &y, &r, nsnull);
if (r > 0.0f)
cairo_arc(aCtx, x, y, r, 0, 2*M_PI);
aCtx->Arc(gfxPoint(x, y), r, 0, 2*M_PI);
}

View File

@ -42,6 +42,7 @@
#include "nsSVGLength2.h"
#include "nsGkAtoms.h"
#include "nsSVGUtils.h"
#include "gfxContext.h"
typedef nsSVGPathGeometryElement nsSVGEllipseElementBase;
@ -64,7 +65,7 @@ public:
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGEllipseElementBase::)
// nsSVGPathGeometryElement methods:
virtual void ConstructPath(cairo_t *aCtx);
virtual void ConstructPath(gfxContext *aCtx);
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
@ -155,17 +156,17 @@ nsSVGEllipseElement::GetLengthInfo()
// nsSVGPathGeometryElement methods
void
nsSVGEllipseElement::ConstructPath(cairo_t *aCtx)
nsSVGEllipseElement::ConstructPath(gfxContext *aCtx)
{
float x, y, rx, ry;
GetAnimatedLengthValues(&x, &y, &rx, &ry, nsnull);
if (rx > 0.0f && ry > 0.0f) {
cairo_save(aCtx);
cairo_translate(aCtx, x, y);
cairo_scale(aCtx, rx, ry);
cairo_arc(aCtx, 0, 0, 1, 0, 2 * M_PI);
cairo_restore(aCtx);
aCtx->Save();
aCtx->Translate(gfxPoint(x, y));
aCtx->Scale(rx, ry);
aCtx->Arc(gfxPoint(0, 0), 1, 0, 2 * M_PI);
aCtx->Restore();
}
}

View File

@ -52,6 +52,7 @@
#include "nsIDOMSVGURIReference.h"
#include "nsImageLoadingContent.h"
#include "nsSVGLength2.h"
#include "gfxContext.h"
class nsIDOMSVGAnimatedString;
class nsIDOMSVGAnimatedPreserveAspectRatio;
@ -96,7 +97,7 @@ public:
NS_IMETHODIMP_(PRBool) IsAttributeMapped(const nsIAtom* name) const;
// nsSVGPathGeometryElement methods:
virtual void ConstructPath(cairo_t *aCtx);
virtual void ConstructPath(gfxContext *aCtx);
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
@ -353,7 +354,7 @@ nsSVGImageElement::IsAttributeMapped(const nsIAtom* name) const
/* For the purposes of the update/invalidation logic pretend to
be a rectangle. */
void
nsSVGImageElement::ConstructPath(cairo_t *aCtx)
nsSVGImageElement::ConstructPath(gfxContext *aCtx)
{
float x, y, width, height;
@ -362,5 +363,5 @@ nsSVGImageElement::ConstructPath(cairo_t *aCtx)
if (width == 0 || height == 0)
return;
cairo_rectangle(aCtx, x, y, width, height);
aCtx->Rectangle(gfxRect(x, y, width, height));
}

View File

@ -41,6 +41,7 @@
#include "nsIDOMSVGLineElement.h"
#include "nsSVGLength2.h"
#include "nsGkAtoms.h"
#include "gfxContext.h"
typedef nsSVGPathGeometryElement nsSVGLineElementBase;
@ -68,7 +69,7 @@ public:
// nsSVGPathGeometryElement methods:
virtual PRBool IsMarkable() { return PR_TRUE; }
virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks);
virtual void ConstructPath(cairo_t *aCtx);
virtual void ConstructPath(gfxContext *aCtx);
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
@ -185,12 +186,12 @@ nsSVGLineElement::GetMarkPoints(nsTArray<nsSVGMark> *aMarks) {
}
void
nsSVGLineElement::ConstructPath(cairo_t *aCtx)
nsSVGLineElement::ConstructPath(gfxContext *aCtx)
{
float x1, y1, x2, y2;
GetAnimatedLengthValues(&x1, &y1, &x2, &y2, nsnull);
cairo_move_to(aCtx, x1, y1);
cairo_line_to(aCtx, x2, y2);
aCtx->MoveTo(gfxPoint(x1, y1));
aCtx->LineTo(gfxPoint(x2, y2));
}

View File

@ -40,7 +40,6 @@
#define __NS_SVGMATRIX_H__
#include "nsIDOMSVGMatrix.h"
#include "cairo.h"
nsresult
NS_NewSVGMatrix(nsIDOMSVGMatrix** result,

View File

@ -45,7 +45,6 @@
#include "nsCOMArray.h"
#include "nsIDOMSVGPathSeg.h"
#include "nsTArray.h"
#include <cairo.h>
class nsSVGPathList;

View File

@ -47,6 +47,7 @@
#include "nsISVGValueUtils.h"
#include "nsSVGUtils.h"
#include "nsSVGPoint.h"
#include "gfxContext.h"
nsSVGElement::NumberInfo nsSVGPathElement::sNumberInfo =
{ &nsGkAtoms::pathLength, 0 };
@ -103,7 +104,7 @@ nsSVGPathElement::GetTotalLength(float *_retval)
{
*_retval = 0;
nsAutoPtr<nsSVGFlattenedPath> flat(GetFlattenedPath(nsnull));
nsRefPtr<gfxFlattenedPath> flat = GetFlattenedPath(nsnull);
if (!flat)
return NS_ERROR_FAILURE;
@ -117,7 +118,7 @@ nsSVGPathElement::GetTotalLength(float *_retval)
NS_IMETHODIMP
nsSVGPathElement::GetPointAtLength(float distance, nsIDOMSVGPoint **_retval)
{
nsAutoPtr<nsSVGFlattenedPath> flat(GetFlattenedPath(nsnull));
nsRefPtr<gfxFlattenedPath> flat = GetFlattenedPath(nsnull);
if (!flat)
return NS_ERROR_FAILURE;
@ -129,10 +130,9 @@ nsSVGPathElement::GetPointAtLength(float distance, nsIDOMSVGPoint **_retval)
distance = PR_MAX(0, distance);
distance = PR_MIN(totalLength, distance);
float x, y, angle;
flat->FindPoint(0, distance, 0, &x, &y, &angle);
gfxPoint pt = flat->FindPoint(gfxPoint(distance, 0));
return NS_NewSVGPoint(_retval, x, y);
return NS_NewSVGPoint(_retval, pt.x, pt.y);
}
/* unsigned long getPathSegAtLength (in float distance); */
@ -471,43 +471,20 @@ nsSVGPathElement::DidModifySVGObservable(nsISVGValue* observable,
return nsSVGPathElementBase::DidModifySVGObservable(observable, aModType);
}
nsSVGFlattenedPath *
already_AddRefed<gfxFlattenedPath>
nsSVGPathElement::GetFlattenedPath(nsIDOMSVGMatrix *aMatrix)
{
cairo_surface_t *dummySurface =
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1);
if (!dummySurface)
return nsnull;
cairo_t *ctx = cairo_create(dummySurface);
if (cairo_status(ctx) != CAIRO_STATUS_SUCCESS) {
cairo_destroy(ctx);
cairo_surface_destroy(dummySurface);
return nsnull;
}
gfxContext ctx(nsSVGUtils::GetThebesComputationalSurface());
if (aMatrix) {
cairo_matrix_t matrix = nsSVGUtils::ConvertSVGMatrixToCairo(aMatrix);
cairo_set_matrix(ctx, &matrix);
ctx.SetMatrix(nsSVGUtils::ConvertSVGMatrixToThebes(aMatrix));
}
mPathData.Playback(ctx);
mPathData.Playback(&ctx);
cairo_identity_matrix(ctx);
ctx.IdentityMatrix();
cairo_path_t *path = cairo_copy_path_flat(ctx);
cairo_destroy(ctx);
cairo_surface_destroy(dummySurface);
if (!path)
return nsnull;
nsSVGFlattenedPath *retval = new nsSVGFlattenedPath(path);
if (!retval)
cairo_path_destroy(path);
return retval;
return ctx.GetFlattenedPath();
}
//----------------------------------------------------------------------
@ -994,7 +971,7 @@ nsSVGPathList::Clear()
}
void
nsSVGPathList::Playback(cairo_t *aCtx)
nsSVGPathList::Playback(gfxContext *aCtx)
{
float *args = mArguments;
for (PRUint32 i = 0; i < mNumCommands; i++) {
@ -1003,20 +980,21 @@ nsSVGPathList::Playback(cairo_t *aCtx)
command = (command >> (2 * (i % 4))) & 0x3;
switch (command) {
case MOVETO:
cairo_move_to(aCtx, args[0], args[1]);
aCtx->MoveTo(gfxPoint(args[0], args[1]));
args += 2;
break;
case LINETO:
cairo_line_to(aCtx, args[0], args[1]);
aCtx->LineTo(gfxPoint(args[0], args[1]));
args += 2;
break;
case CURVETO:
cairo_curve_to(aCtx,
args[0], args[1], args[2], args[3], args[4], args[5]);
aCtx->CurveTo(gfxPoint(args[0], args[1]),
gfxPoint(args[2], args[3]),
gfxPoint(args[4], args[5]));
args += 6;
break;
case CLOSEPATH:
cairo_close_path(aCtx);
aCtx->ClosePath();
break;
default:
break;
@ -1024,97 +1002,8 @@ nsSVGPathList::Playback(cairo_t *aCtx)
}
}
//==================================================================
// nsSVGFlattenedPath
static float
CalcSubLengthAndAdvance(cairo_path_data_t *aData,
float *aPathStartX, float *aPathStartY,
float *aCurrentX, float *aCurrentY)
{
float sublength = 0;
switch (aData->header.type) {
case CAIRO_PATH_MOVE_TO:
{
*aCurrentX = *aPathStartX = aData[1].point.x;
*aCurrentY = *aPathStartY = aData[1].point.y;
break;
}
case CAIRO_PATH_LINE_TO:
{
float dx = aData[1].point.x - *aCurrentX;
float dy = aData[1].point.y - *aCurrentY;
sublength = sqrt(dx * dx + dy * dy);
*aCurrentX = aData[1].point.x;
*aCurrentY = aData[1].point.y;
break;
}
case CAIRO_PATH_CURVE_TO:
/* should never happen with a flattened path */
NS_WARNING("curve_to in flattened path");
break;
case CAIRO_PATH_CLOSE_PATH:
{
float dx = *aPathStartX - *aCurrentX;
float dy = *aPathStartY - *aCurrentY;
sublength = sqrt(dx * dx + dy * dy);
*aCurrentX = *aPathStartX;
*aCurrentY = *aPathStartY;
break;
}
}
return sublength;
}
float
nsSVGFlattenedPath::GetLength()
{
float length = 0; // current summed length
float sx = 0, sy = 0; // start of current subpath
float x = 0, y = 0; // current point
for (PRInt32 i = 0; i < mPath->num_data; i += mPath->data[i].header.length) {
length += CalcSubLengthAndAdvance(&mPath->data[i], &sx, &sy, &x, &y);
}
return length;
}
void
nsSVGFlattenedPath::FindPoint(float aAdvance, float aXOffset, float aYOffset,
float *aX, float *aY, float *aAngle)
{
float length = 0; // current summed length
float sx = 0, sy = 0; // start of current subpath
float x = 0, y = 0; // current point
float midpoint = aXOffset + aAdvance/2;
for (PRInt32 i = 0; i < mPath->num_data; i += mPath->data[i].header.length) {
float prevX = x;
float prevY = y;
float sublength = CalcSubLengthAndAdvance(&mPath->data[i],
&sx, &sy, &x, &y);
if (sublength != 0 && length + sublength >= midpoint) {
float ratio = (aXOffset - length) / sublength;
*aX = prevX * (1.0f - ratio) + x * ratio;
*aY = prevY * (1.0f - ratio) + y * ratio;
float dx = x - prevX;
float dy = y - prevY;
*aAngle = atan2(dy, dx);
float normalization = 1.0 / sqrt(dx * dx + dy * dy);
*aX += - aYOffset * dy * normalization;
*aY += aYOffset * dx * normalization;
return;
}
length += sublength;
}
}
void
nsSVGPathElement::ConstructPath(cairo_t *aCtx)
nsSVGPathElement::ConstructPath(gfxContext *aCtx)
{
mPathData.Playback(aCtx);
}

View File

@ -43,7 +43,9 @@
#include "nsIDOMSVGPathElement.h"
#include "nsIDOMSVGAnimatedPathData.h"
#include "nsSVGNumber2.h"
#include "cairo.h"
#include "gfxPath.h"
class gfxContext;
class nsSVGPathList
{
@ -53,7 +55,7 @@ public:
enum { MOVETO, LINETO, CURVETO, CLOSEPATH };
nsSVGPathList() : mArguments(nsnull), mNumCommands(0), mNumArguments(0) {}
~nsSVGPathList() { Clear(); }
void Playback(cairo_t *aCtx);
void Playback(gfxContext *aCtx);
protected:
void Clear();
@ -63,25 +65,6 @@ protected:
PRUint32 mNumArguments;
};
class nsSVGFlattenedPath
{
private:
cairo_path_t *mPath;
public:
nsSVGFlattenedPath(cairo_path_t *aPath) : mPath(aPath) {}
~nsSVGFlattenedPath() { if (mPath) cairo_path_destroy(mPath); }
// Returns calculated length of path
float GetLength();
// Finds a point aXOffset along this path, for a character with
// aAdvance wide, offset from the path by aYOffset. Returns
// position and angle.
void FindPoint(float aAdvance, float aXOffset, float aYOffset,
float *aX, float *aY, float *aAngle);
};
typedef nsSVGPathGeometryElement nsSVGPathElementBase;
class nsSVGPathElement : public nsSVGPathElementBase,
@ -119,9 +102,9 @@ public:
virtual PRBool IsDependentAttribute(nsIAtom *aName);
virtual PRBool IsMarkable();
virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks);
virtual void ConstructPath(cairo_t *aCtx);
virtual void ConstructPath(gfxContext *aCtx);
virtual nsSVGFlattenedPath *GetFlattenedPath(nsIDOMSVGMatrix *aMatrix);
virtual already_AddRefed<gfxFlattenedPath> GetFlattenedPath(nsIDOMSVGMatrix *aMatrix);
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;

View File

@ -66,7 +66,7 @@ nsSVGPathGeometryElement::GetMarkPoints(nsTArray<nsSVGMark> *aMarks)
{
}
nsSVGFlattenedPath *
already_AddRefed<gfxFlattenedPath>
nsSVGPathGeometryElement::GetFlattenedPath(nsIDOMSVGMatrix *aMatrix)
{
return nsnull;

View File

@ -39,7 +39,7 @@
#include "nsSVGGraphicElement.h"
#include "nsTArray.h"
#include "cairo.h"
#include "gfxPath.h"
struct nsSVGMark {
float x, y, angle;
@ -47,8 +47,8 @@ struct nsSVGMark {
x(aX), y(aY), angle(aAngle) {}
};
class nsSVGFlattenedPath;
class nsIDOMSVGMatrix;
class gfxContext;
typedef nsSVGGraphicElement nsSVGPathGeometryElementBase;
@ -60,8 +60,8 @@ public:
virtual PRBool IsDependentAttribute(nsIAtom *aName);
virtual PRBool IsMarkable();
virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks);
virtual void ConstructPath(cairo_t *aCtx) = 0;
virtual nsSVGFlattenedPath *GetFlattenedPath(nsIDOMSVGMatrix *aMatrix);
virtual void ConstructPath(gfxContext *aCtx) = 0;
virtual already_AddRefed<gfxFlattenedPath> GetFlattenedPath(nsIDOMSVGMatrix *aMatrix);
};
#endif

View File

@ -35,6 +35,7 @@
* ***** END LICENSE BLOCK ***** */
#include "nsSVGPolyElement.h"
#include "gfxContext.h"
//----------------------------------------------------------------------
// nsISupports methods
@ -158,7 +159,7 @@ nsSVGPolyElement::GetMarkPoints(nsTArray<nsSVGMark> *aMarks)
}
void
nsSVGPolyElement::ConstructPath(cairo_t *aCtx)
nsSVGPolyElement::ConstructPath(gfxContext *aCtx)
{
if (!mPoints)
return;
@ -177,9 +178,9 @@ nsSVGPolyElement::ConstructPath(cairo_t *aCtx)
point->GetX(&x);
point->GetY(&y);
if (i == 0)
cairo_move_to(aCtx, x, y);
aCtx->MoveTo(gfxPoint(x, y));
else
cairo_line_to(aCtx, x, y);
aCtx->LineTo(gfxPoint(x, y));
}
}

View File

@ -43,6 +43,8 @@
typedef nsSVGPathGeometryElement nsSVGPolyElementBase;
class gfxContext;
class nsSVGPolyElement : public nsSVGPolyElementBase,
public nsIDOMSVGAnimatedPoints
{
@ -63,7 +65,7 @@ public:
virtual PRBool IsDependentAttribute(nsIAtom *aName);
virtual PRBool IsMarkable() { return PR_TRUE; }
virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks);
virtual void ConstructPath(cairo_t *aCtx);
virtual void ConstructPath(gfxContext *aCtx);
protected:
nsCOMPtr<nsIDOMSVGPointList> mPoints;

View File

@ -38,6 +38,7 @@
#include "nsSVGPolyElement.h"
#include "nsIDOMSVGPolygonElement.h"
#include "gfxContext.h"
typedef nsSVGPolyElement nsSVGPolygonElementBase;
@ -62,7 +63,7 @@ public:
// nsSVGPathGeometryElement methods:
virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks);
virtual void ConstructPath(cairo_t *aCtx);
virtual void ConstructPath(gfxContext *aCtx);
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
};
@ -115,12 +116,12 @@ nsSVGPolygonElement::GetMarkPoints(nsTArray<nsSVGMark> *aMarks)
}
void
nsSVGPolygonElement::ConstructPath(cairo_t *aCtx)
nsSVGPolygonElement::ConstructPath(gfxContext *aCtx)
{
nsSVGPolygonElementBase::ConstructPath(aCtx);
// the difference between a polyline and a polygon is that the
// polygon is closed:
cairo_close_path(aCtx);
aCtx->ClosePath();
}

View File

@ -41,6 +41,7 @@
#include "nsIDOMSVGRectElement.h"
#include "nsSVGLength2.h"
#include "nsGkAtoms.h"
#include "gfxContext.h"
typedef nsSVGPathGeometryElement nsSVGRectElementBase;
@ -63,7 +64,7 @@ public:
NS_FORWARD_NSIDOMSVGELEMENT(nsSVGRectElementBase::)
// nsSVGPathGeometryElement methods:
virtual void ConstructPath(cairo_t *aCtx);
virtual void ConstructPath(gfxContext *aCtx);
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
@ -168,7 +169,7 @@ nsSVGRectElement::GetLengthInfo()
// nsSVGPathGeometryElement methods
void
nsSVGRectElement::ConstructPath(cairo_t *aCtx)
nsSVGRectElement::ConstructPath(gfxContext *aCtx)
{
float x, y, width, height, rx, ry;
@ -181,7 +182,7 @@ nsSVGRectElement::ConstructPath(cairo_t *aCtx)
/* optimize the no rounded corners case */
if (rx == 0 && ry == 0) {
cairo_rectangle(aCtx, x, y, width, height);
aCtx->Rectangle(gfxRect(x, y, width, height));
return;
}
@ -218,26 +219,30 @@ nsSVGRectElement::ConstructPath(cairo_t *aCtx)
const float magic_x = magic*rx;
const float magic_y = magic*ry;
cairo_move_to(aCtx, x+rx, y);
cairo_line_to(aCtx, x+width-rx, y);
cairo_curve_to(aCtx,
x+width-rx + magic_x, y,
x+width, y+ry-magic_y,
x+width, y+ry);
cairo_line_to(aCtx, x+width, y+height-ry);
cairo_curve_to(aCtx,
x+width, y+height-ry + magic_y,
x+width-rx + magic_x, y+height,
x+width-rx, y+height);
cairo_line_to(aCtx, x+rx, y+height);
cairo_curve_to(aCtx,
x+rx - magic_x, y+height,
x, y+height-ry + magic_y,
x, y+height-ry);
cairo_line_to(aCtx, x, y+ry);
cairo_curve_to(aCtx,
x, y+ry - magic_y,
x+rx - magic_x, y,
x+rx, y);
cairo_close_path(aCtx);
aCtx->MoveTo(gfxPoint(x + rx, y));
aCtx->LineTo(gfxPoint(x + width - rx, y));
aCtx->CurveTo(gfxPoint(x + width - rx + magic_x, y),
gfxPoint(x + width, y + ry - magic_y),
gfxPoint(x + width, y + ry));
aCtx->LineTo(gfxPoint(x + width, y + height - ry));
aCtx->CurveTo(gfxPoint(x + width, y + height - ry + magic_y),
gfxPoint(x + width - rx + magic_x, y+height),
gfxPoint(x + width - rx, y + height));
aCtx->LineTo(gfxPoint(x + rx, y + height));
aCtx->CurveTo(gfxPoint(x + rx - magic_x, y + height),
gfxPoint(x, y + height - ry + magic_y),
gfxPoint(x, y + height - ry));
aCtx->LineTo(gfxPoint(x, y + ry));
aCtx->CurveTo(gfxPoint(x, y + ry - magic_y),
gfxPoint(x + rx - magic_x, y),
gfxPoint(x + rx, y));
aCtx->ClosePath();
}

View File

@ -556,7 +556,7 @@ nsSVGGlyphFrame::GetCharacterPosition(gfxContext *aContext,
if (!textPath)
return NS_OK;
nsAutoPtr<nsSVGFlattenedPath> data(textPath->GetFlattenedPath());
nsRefPtr<gfxFlattenedPath> data = textPath->GetFlattenedPath();
/* textPath frame, but invalid target */
if (!data)
@ -578,25 +578,25 @@ nsSVGGlyphFrame::GetCharacterPosition(gfxContext *aContext,
cairo_text_extents(ctx,
NS_ConvertUTF16toUTF8(Substring(aText, i, 1)).get(),
&extent);
float advance = extent.x_advance;
float halfAdvance = extent.x_advance / 2.0;
/* have we run off the end of the path? */
if (x + advance / 2 > length)
if (x + halfAdvance > length)
break;
/* check that we've advanced to the start of the path */
if (x + advance / 2 >= 0.0f) {
if (x + halfAdvance >= 0.0f) {
cp[i].draw = PR_TRUE;
// add y (normal)
// add rotation
// move point back along tangent
data->FindPoint(advance, x, mY,
&(cp[i].x),
&(cp[i].y),
&(cp[i].angle));
gfxPoint pt = data->FindPoint(gfxPoint(x + halfAdvance, mY),
&(cp[i].angle));
cp[i].x = pt.x - cos(cp[i].angle) * halfAdvance;
cp[i].y = pt.y - sin(cp[i].angle) * halfAdvance;
}
x += advance;
x += 2 * halfAdvance;
}
*aCharacterPosition = cp;

View File

@ -151,9 +151,9 @@ public:
protected:
struct nsSVGCharacterPosition {
PRBool draw;
gfxFloat angle;
float x, y;
float angle;
PRBool draw;
};
// VC6 does not allow the inner class to access protected members

View File

@ -669,7 +669,6 @@ nsSVGPathGeometryFrame::GeneratePath(gfxContext* aContext)
NS_ASSERTION(ctm, "graphic source didn't specify a ctm");
gfxMatrix matrix = nsSVGUtils::ConvertSVGMatrixToThebes(ctm);
cairo_t *ctx = aContext->GetCairo();
if (matrix.IsSingular()) {
aContext->IdentityMatrix();
@ -680,7 +679,7 @@ nsSVGPathGeometryFrame::GeneratePath(gfxContext* aContext)
aContext->Multiply(matrix);
aContext->NewPath();
NS_STATIC_CAST(nsSVGPathGeometryElement*, mContent)->ConstructPath(ctx);
NS_STATIC_CAST(nsSVGPathGeometryElement*, mContent)->ConstructPath(aContext);
}
PRUint16

View File

@ -320,7 +320,7 @@ GetSingleValue(nsISVGGlyphFragmentLeaf *fragment,
nsSVGTextPathFrame *textPath = fragment->FindTextPathParent();
if (textPath) {
nsAutoPtr<nsSVGFlattenedPath> data(textPath->GetFlattenedPath());
nsRefPtr<gfxFlattenedPath> data = textPath->GetFlattenedPath();
if (!data)
return;

View File

@ -187,7 +187,7 @@ nsSVGTextPathFrame::GetPathFrame() {
return path;
}
nsSVGFlattenedPath *
already_AddRefed<gfxFlattenedPath>
nsSVGTextPathFrame::GetFlattenedPath() {
nsIFrame *path = GetPathFrame();
if (!path)

View File

@ -44,8 +44,7 @@
#include "nsIDOMSVGPathSegList.h"
#include "nsSVGLengthList.h"
#include "nsIDOMSVGLength.h"
class nsSVGFlattenedPath;
#include "gfxPath.h"
typedef nsSVGTSpanFrame nsSVGTextPathFrameBase;
@ -83,7 +82,7 @@ public:
nsISVGValue::modificationType aModType);
// nsSVGTextPathFrame methods:
nsSVGFlattenedPath *GetFlattenedPath();
already_AddRefed<gfxFlattenedPath> GetFlattenedPath();
nsIFrame *GetPathFrame();
// nsISupports interface: