Bug 334999 - remove nsISVGRendererPathBuilder. r+sr=roc

This commit is contained in:
tor%cs.brown.edu 2006-05-01 15:37:18 +00:00
Родитель 69d9a11fdd
Коммит 0968548e93
16 изменённых файлов: 214 добавлений и 91 удалений

Просмотреть файл

@ -114,6 +114,9 @@ EXPORTS = \
include $(topsrcdir)/config/rules.mk
CFLAGS += $(MOZ_CAIRO_CFLAGS)
CXXFLAGS += $(MOZ_CAIRO_CFLAGS)
LOCAL_INCLUDES = \
-I$(srcdir)/../../../base \
-I$(srcdir)/../../../generic \

Просмотреть файл

@ -37,9 +37,9 @@
* ***** END LICENSE BLOCK ***** */
#include "nsSVGPathGeometryFrame.h"
#include "nsISVGRendererPathBuilder.h"
#include "nsIDOMSVGCircleElement.h"
#include "nsSVGElement.h"
#include "nsSVGUtils.h"
class nsSVGCircleFrame : public nsSVGPathGeometryFrame
{
@ -70,7 +70,7 @@ public:
PRInt32 aModType);
// nsISVGPathGeometrySource interface:
NS_IMETHOD ConstructPath(nsISVGRendererPathBuilder *pathBuilder);
NS_IMETHOD ConstructPath(cairo_t *aCtx);
};
//----------------------------------------------------------------------
@ -120,21 +120,14 @@ nsSVGCircleFrame::AttributeChanged(PRInt32 aNameSpaceID,
//----------------------------------------------------------------------
// nsISVGPathGeometrySource methods:
/* void constructPath (in nsISVGRendererPathBuilder pathBuilder); */
NS_IMETHODIMP nsSVGCircleFrame::ConstructPath(nsISVGRendererPathBuilder* pathBuilder)
NS_IMETHODIMP nsSVGCircleFrame::ConstructPath(cairo_t *aCtx)
{
float x, y, r;
nsSVGElement *element = NS_STATIC_CAST(nsSVGElement*, mContent);
element->GetAnimatedLengthValues(&x, &y, &r, nsnull);
// we should be able to build this as a single arc with startpoints
// and endpoints infinitesimally separated. Let's use two arcs
// though, so that the builder doesn't get confused:
pathBuilder->Moveto(x, y-r);
pathBuilder->Arcto(x-r, y , r, r, 0.0, 0, 0);
pathBuilder->Arcto(x , y-r, r, r, 0.0, 1, 0);
pathBuilder->ClosePath(&x,&y);
cairo_arc(aCtx, x, y, r, 0, 2*M_PI);
return NS_OK;
}

Просмотреть файл

@ -38,9 +38,9 @@
* ***** END LICENSE BLOCK ***** */
#include "nsSVGPathGeometryFrame.h"
#include "nsISVGRendererPathBuilder.h"
#include "nsIDOMSVGEllipseElement.h"
#include "nsSVGElement.h"
#include "nsSVGUtils.h"
class nsSVGEllipseFrame : public nsSVGPathGeometryFrame
{
@ -69,7 +69,7 @@ class nsSVGEllipseFrame : public nsSVGPathGeometryFrame
PRInt32 aModType);
// nsISVGPathGeometrySource interface:
NS_IMETHOD ConstructPath(nsISVGRendererPathBuilder *pathBuilder);
NS_IMETHOD ConstructPath(cairo_t *aCtx);
};
//----------------------------------------------------------------------
@ -119,19 +119,18 @@ nsSVGEllipseFrame::AttributeChanged(PRInt32 aNameSpaceID,
//----------------------------------------------------------------------
// nsISVGPathGeometrySource methods:
/* void constructPath (in nsISVGRendererPathBuilder pathBuilder); */
NS_IMETHODIMP nsSVGEllipseFrame::ConstructPath(nsISVGRendererPathBuilder* pathBuilder)
NS_IMETHODIMP nsSVGEllipseFrame::ConstructPath(cairo_t *aCtx)
{
float x, y, rx, ry;
nsSVGElement *element = NS_STATIC_CAST(nsSVGElement*, mContent);
element->GetAnimatedLengthValues(&x, &y, &rx, &ry, nsnull);
// build ellipse from two arcs
pathBuilder->Moveto(x-rx, y);
pathBuilder->Arcto(x+rx, y, rx, ry, 0.0, 0, 0);
pathBuilder->Arcto(x-rx, y, rx, ry, 0.0, 1, 0);
pathBuilder->ClosePath(&x,&y);
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);
return NS_OK;
}

Просмотреть файл

@ -35,7 +35,6 @@
* ***** END LICENSE BLOCK ***** */
#include "nsSVGPathGeometryFrame.h"
#include "nsISVGRendererPathBuilder.h"
#include "nsISVGRendererSurface.h"
#include "nsISVGRendererCanvas.h"
#include "nsISVGRenderer.h"
@ -89,7 +88,7 @@ public:
PRInt32 aModType);
// nsISVGPathGeometrySource interface:
NS_IMETHOD ConstructPath(nsISVGRendererPathBuilder *pathBuilder);
NS_IMETHOD ConstructPath(cairo_t *aCtx);
// nsISVGChildFrame interface:
NS_IMETHOD PaintSVG(nsISVGRendererCanvas* canvas);
@ -209,10 +208,9 @@ nsSVGImageFrame::AttributeChanged(PRInt32 aNameSpaceID,
//----------------------------------------------------------------------
// nsISVGPathGeometrySource methods:
/* void constructPath (in nsISVGRendererPathBuilder pathBuilder); */
/* For the purposes of the update/invalidation logic pretend to
be a rectangle. */
NS_IMETHODIMP nsSVGImageFrame::ConstructPath(nsISVGRendererPathBuilder* pathBuilder)
NS_IMETHODIMP nsSVGImageFrame::ConstructPath(cairo_t *aCtx)
{
float x, y, width, height;
@ -224,11 +222,7 @@ NS_IMETHODIMP nsSVGImageFrame::ConstructPath(nsISVGRendererPathBuilder* pathBuil
if (width == 0 || height == 0)
return NS_OK;
pathBuilder->Moveto(x, y);
pathBuilder->Lineto(x+width, y);
pathBuilder->Lineto(x+width, y+height);
pathBuilder->Lineto(x, y+height);
pathBuilder->ClosePath(&x, &y);
cairo_rectangle(aCtx, x, y, width, height);
return NS_OK;
}

Просмотреть файл

@ -38,7 +38,6 @@
* ***** END LICENSE BLOCK ***** */
#include "nsSVGPathGeometryFrame.h"
#include "nsISVGRendererPathBuilder.h"
#include "nsISVGMarkable.h"
#include "nsIDOMSVGLineElement.h"
#include "nsSVGElement.h"
@ -71,7 +70,7 @@ class nsSVGLineFrame : public nsSVGPathGeometryFrame,
PRInt32 aModType);
// nsISVGPathGeometrySource interface:
NS_IMETHOD ConstructPath(nsISVGRendererPathBuilder *pathBuilder);
NS_IMETHOD ConstructPath(cairo_t *aCtx);
// nsISVGMarkable interface
void GetMarkPoints(nsVoidArray *aMarks);
@ -134,8 +133,7 @@ nsSVGLineFrame::AttributeChanged(PRInt32 aNameSpaceID,
//----------------------------------------------------------------------
// nsISVGPathGeometrySource methods:
/* void constructPath (in nsISVGRendererPathBuilder pathBuilder); */
NS_IMETHODIMP nsSVGLineFrame::ConstructPath(nsISVGRendererPathBuilder* pathBuilder)
NS_IMETHODIMP nsSVGLineFrame::ConstructPath(cairo_t *aCtx)
{
float x1, y1, x2, y2;
@ -143,8 +141,8 @@ NS_IMETHODIMP nsSVGLineFrame::ConstructPath(nsISVGRendererPathBuilder* pathBuild
element->GetAnimatedLengthValues(&x1, &y1, &x2, &y2, nsnull);
// move to start coordinates then draw line to end coordinates
pathBuilder->Moveto(x1, y1);
pathBuilder->Lineto(x2, y2);
cairo_move_to(aCtx, x1, y1);
cairo_line_to(aCtx, x2, y2);
return NS_OK;
}

Просмотреть файл

@ -42,7 +42,6 @@
#include "nsIDOMSVGPathSegList.h"
#include "nsIDOMSVGPathSeg.h"
#include "nsIDOMSVGMatrix.h"
#include "nsISVGRendererPathBuilder.h"
#include "nsISVGMarkable.h"
#include "nsISupports.h"
#include "nsLayoutAtoms.h"
@ -70,7 +69,7 @@ public:
PRInt32 aModType);
// nsISVGPathGeometrySource interface:
NS_IMETHOD ConstructPath(nsISVGRendererPathBuilder *pathBuilder);
NS_IMETHOD ConstructPath(cairo_t *aCtx);
// nsISVGMarkable interface
void GetMarkPoints(nsVoidArray *aMarks);
@ -160,8 +159,123 @@ nsSVGPathFrame::AttributeChanged(PRInt32 aNameSpaceID,
//----------------------------------------------------------------------
// nsISVGPathGeometrySource methods:
/* void constructPath (in nsISVGRendererPathBuilder pathBuilder); */
NS_IMETHODIMP nsSVGPathFrame::ConstructPath(nsISVGRendererPathBuilder* pathBuilder)
static double
CalcVectorAngle(double ux, double uy, double vx, double vy)
{
double ta = atan2(uy, ux);
double tb = atan2(vy, vx);
if (tb >= ta)
return tb-ta;
return 2 * M_PI - (ta-tb);
}
static void
ConvertArcToCairo(cairo_t *aCtx, float x, float y, float x2, float y2,
float rx, float ry,
float angle, PRBool largeArcFlag, PRBool sweepFlag)
{
const double radPerDeg = M_PI/180.0;
double x1=x, y1=y;
// 1. Treat out-of-range parameters as described in
// http://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes
// If the endpoints (x1, y1) and (x2, y2) are identical, then this
// is equivalent to omitting the elliptical arc segment entirely
if (x1 == x2 && y1 == y2)
return;
// If rX = 0 or rY = 0 then this arc is treated as a straight line
// segment (a "lineto") joining the endpoints.
if (rx == 0.0f || ry == 0.0f) {
cairo_line_to(aCtx, x2, y2);
return;
}
// If rX or rY have negative signs, these are dropped; the absolute
// value is used instead.
if (rx<0.0) rx = -rx;
if (ry<0.0) ry = -ry;
// 2. convert to center parameterization as shown in
// http://www.w3.org/TR/SVG/implnote.html
double sinPhi = sin(angle*radPerDeg);
double cosPhi = cos(angle*radPerDeg);
double x1dash = cosPhi * (x1-x2)/2.0 + sinPhi * (y1-y2)/2.0;
double y1dash = -sinPhi * (x1-x2)/2.0 + cosPhi * (y1-y2)/2.0;
double root;
double numerator = rx*rx*ry*ry - rx*rx*y1dash*y1dash - ry*ry*x1dash*x1dash;
if (numerator < 0.0) {
// If rX , rY and are such that there is no solution (basically,
// the ellipse is not big enough to reach from (x1, y1) to (x2,
// y2)) then the ellipse is scaled up uniformly until there is
// exactly one solution (until the ellipse is just big enough).
// -> find factor s, such that numerator' with rx'=s*rx and
// ry'=s*ry becomes 0 :
float s = (float)sqrt(1.0 - numerator/(rx*rx*ry*ry));
rx *= s;
ry *= s;
root = 0.0;
}
else {
root = (largeArcFlag == sweepFlag ? -1.0 : 1.0) *
sqrt( numerator/(rx*rx*y1dash*y1dash + ry*ry*x1dash*x1dash) );
}
double cxdash = root*rx*y1dash/ry;
double cydash = -root*ry*x1dash/rx;
double cx = cosPhi * cxdash - sinPhi * cydash + (x1+x2)/2.0;
double cy = sinPhi * cxdash + cosPhi * cydash + (y1+y2)/2.0;
double theta1 = CalcVectorAngle(1.0, 0.0, (x1dash-cxdash)/rx, (y1dash-cydash)/ry);
double dtheta = CalcVectorAngle((x1dash-cxdash)/rx, (y1dash-cydash)/ry,
(-x1dash-cxdash)/rx, (-y1dash-cydash)/ry);
if (!sweepFlag && dtheta>0)
dtheta -= 2.0*M_PI;
else if (sweepFlag && dtheta<0)
dtheta += 2.0*M_PI;
// 3. convert into cubic bezier segments <= 90deg
int segments = (int)ceil(fabs(dtheta/(M_PI/2.0)));
double delta = dtheta/segments;
double t = 8.0/3.0 * sin(delta/4.0) * sin(delta/4.0) / sin(delta/2.0);
for (int i = 0; i < segments; ++i) {
double cosTheta1 = cos(theta1);
double sinTheta1 = sin(theta1);
double theta2 = theta1 + delta;
double cosTheta2 = cos(theta2);
double sinTheta2 = sin(theta2);
// a) calculate endpoint of the segment:
double xe = cosPhi * rx*cosTheta2 - sinPhi * ry*sinTheta2 + cx;
double ye = sinPhi * rx*cosTheta2 + cosPhi * ry*sinTheta2 + cy;
// b) calculate gradients at start/end points of segment:
double dx1 = t * ( - cosPhi * rx*sinTheta1 - sinPhi * ry*cosTheta1);
double dy1 = t * ( - sinPhi * rx*sinTheta1 + cosPhi * ry*cosTheta1);
double dxe = t * ( cosPhi * rx*sinTheta2 + sinPhi * ry*cosTheta2);
double dye = t * ( sinPhi * rx*sinTheta2 - cosPhi * ry*cosTheta2);
// c) draw the cubic bezier:
cairo_curve_to(aCtx, x1+dx1, y1+dy1, xe+dxe, ye+dye, xe, ye);
// do next segment
theta1 = theta2;
x1 = (float)xe;
y1 = (float)ye;
}
}
NS_IMETHODIMP nsSVGPathFrame::ConstructPath(cairo_t *aCtx)
{
PRUint32 count;
mSegments->GetNumberOfItems(&count);
@ -187,9 +301,15 @@ NS_IMETHODIMP nsSVGPathFrame::ConstructPath(nsISVGRendererPathBuilder* pathBuild
switch (type) {
case nsIDOMSVGPathSeg::PATHSEG_CLOSEPATH:
pathBuilder->ClosePath(&cx,&cy);
{
cairo_close_path(aCtx);
double dx, dy;
cairo_get_current_point(aCtx, &dx, &dy);
cx = (float)dx;
cy = (float)dy;
}
break;
case nsIDOMSVGPathSeg::PATHSEG_MOVETO_ABS:
absCoords = PR_TRUE;
case nsIDOMSVGPathSeg::PATHSEG_MOVETO_REL:
@ -210,7 +330,7 @@ NS_IMETHODIMP nsSVGPathFrame::ConstructPath(nsISVGRendererPathBuilder* pathBuild
}
cx = x;
cy = y;
pathBuilder->Moveto(x,y);
cairo_move_to(aCtx, x, y);
}
break;
@ -234,7 +354,7 @@ NS_IMETHODIMP nsSVGPathFrame::ConstructPath(nsISVGRendererPathBuilder* pathBuild
}
cx = x;
cy = y;
pathBuilder->Lineto(x,y);
cairo_line_to(aCtx, x, y);
}
break;
@ -272,7 +392,7 @@ NS_IMETHODIMP nsSVGPathFrame::ConstructPath(nsISVGRendererPathBuilder* pathBuild
cy = y;
cx1 = x2;
cy1 = y2;
pathBuilder->Curveto(x, y, x1, y1, x2, y2);
cairo_curve_to(aCtx, x1, y1, x2, y2, x, y);
}
break;
@ -312,7 +432,7 @@ NS_IMETHODIMP nsSVGPathFrame::ConstructPath(nsISVGRendererPathBuilder* pathBuild
cx1 = x1;
cy1 = y1;
pathBuilder->Curveto(x, y, x31, y31, x32, y32);
cairo_curve_to(aCtx, x31, y31, x32, y32, x, y);
}
break;
@ -350,10 +470,11 @@ NS_IMETHODIMP nsSVGPathFrame::ConstructPath(nsISVGRendererPathBuilder* pathBuild
arcseg->GetLargeArcFlag(&largeArcFlag);
arcseg->GetSweepFlag(&sweepFlag);
}
ConvertArcToCairo(aCtx, cx, cy, x, y, r1, r2,
angle, largeArcFlag, sweepFlag);
cx = x;
cy = y;
pathBuilder->Arcto(x, y, r1, r2, angle, largeArcFlag, sweepFlag);
}
break;
@ -374,7 +495,7 @@ NS_IMETHODIMP nsSVGPathFrame::ConstructPath(nsISVGRendererPathBuilder* pathBuild
lineseg->GetX(&x);
}
cx = x;
pathBuilder->Lineto(x,y);
cairo_line_to(aCtx, x, y);
}
break;
@ -395,7 +516,7 @@ NS_IMETHODIMP nsSVGPathFrame::ConstructPath(nsISVGRendererPathBuilder* pathBuild
lineseg->GetY(&y);
}
cy = y;
pathBuilder->Lineto(x,y);
cairo_line_to(aCtx, x, y);
}
break;
@ -442,7 +563,7 @@ NS_IMETHODIMP nsSVGPathFrame::ConstructPath(nsISVGRendererPathBuilder* pathBuild
cy = y;
cx1 = x2;
cy1 = y2;
pathBuilder->Curveto(x, y, x1, y1, x2, y2);
cairo_curve_to(aCtx, x1, y1, x2, y2, x, y);
}
break;
@ -491,7 +612,7 @@ NS_IMETHODIMP nsSVGPathFrame::ConstructPath(nsISVGRendererPathBuilder* pathBuild
cx1 = x1;
cy1 = y1;
pathBuilder->Curveto(x, y, x31, y31, x32, y32);
cairo_curve_to(aCtx, x31, y31, x32, y32, x, y);
}
break;

Просмотреть файл

@ -40,7 +40,6 @@
#include "nsIDOMSVGAnimatedPoints.h"
#include "nsIDOMSVGPointList.h"
#include "nsIDOMSVGPoint.h"
#include "nsISVGRendererPathBuilder.h"
#include "nsISVGMarkable.h"
#include "nsLayoutAtoms.h"
#include "nsSVGUtils.h"
@ -65,7 +64,7 @@ public:
PRInt32 aModType);
// nsISVGPathGeometrySource interface:
NS_IMETHOD ConstructPath(nsISVGRendererPathBuilder *pathBuilder);
NS_IMETHOD ConstructPath(cairo_t *aCtx);
nsCOMPtr<nsIDOMSVGPointList> mPoints;
@ -152,8 +151,7 @@ nsSVGPolygonFrame::AttributeChanged(PRInt32 aNameSpaceID,
//----------------------------------------------------------------------
// nsISVGPathGeometrySource methods:
/* void constructPath (in nsISVGRendererPathBuilder pathBuilder); */
NS_IMETHODIMP nsSVGPolygonFrame::ConstructPath(nsISVGRendererPathBuilder* pathBuilder)
NS_IMETHODIMP nsSVGPolygonFrame::ConstructPath(cairo_t *aCtx)
{
if (!mPoints) return NS_OK;
@ -170,14 +168,13 @@ NS_IMETHODIMP nsSVGPolygonFrame::ConstructPath(nsISVGRendererPathBuilder* pathBu
point->GetX(&x);
point->GetY(&y);
if (i == 0)
pathBuilder->Moveto(x, y);
cairo_move_to(aCtx, x, y);
else
pathBuilder->Lineto(x, y);
cairo_line_to(aCtx, x, y);
}
// the difference between a polyline and a polygon is that the
// polygon is closed:
float x,y;
pathBuilder->ClosePath(&x,&y);
cairo_close_path(aCtx);
return NS_OK;
}

Просмотреть файл

@ -40,7 +40,6 @@
#include "nsIDOMSVGAnimatedPoints.h"
#include "nsIDOMSVGPointList.h"
#include "nsIDOMSVGPoint.h"
#include "nsISVGRendererPathBuilder.h"
#include "nsISVGMarkable.h"
#include "nsLayoutAtoms.h"
#include "nsSVGUtils.h"
@ -79,7 +78,7 @@ public:
PRInt32 aModType);
// nsISVGPathGeometrySource interface:
NS_IMETHOD ConstructPath(nsISVGRendererPathBuilder *pathBuilder);
NS_IMETHOD ConstructPath(cairo_t *aCtx);
nsCOMPtr<nsIDOMSVGPointList> mPoints;
@ -157,8 +156,7 @@ nsSVGPolylineFrame::AttributeChanged(PRInt32 aNameSpaceID,
//----------------------------------------------------------------------
// nsISVGPathGeometrySource methods:
/* void constructPath (in nsISVGRendererPathBuilder pathBuilder); */
NS_IMETHODIMP nsSVGPolylineFrame::ConstructPath(nsISVGRendererPathBuilder* pathBuilder)
NS_IMETHODIMP nsSVGPolylineFrame::ConstructPath(cairo_t *aCtx)
{
if (!mPoints) return NS_OK;
@ -175,9 +173,9 @@ NS_IMETHODIMP nsSVGPolylineFrame::ConstructPath(nsISVGRendererPathBuilder* pathB
point->GetX(&x);
point->GetY(&y);
if (i == 0)
pathBuilder->Moveto(x, y);
cairo_move_to(aCtx, x, y);
else
pathBuilder->Lineto(x, y);
cairo_line_to(aCtx, x, y);
}
return NS_OK;

Просмотреть файл

@ -40,7 +40,6 @@
* ***** END LICENSE BLOCK ***** */
#include "nsSVGPathGeometryFrame.h"
#include "nsISVGRendererPathBuilder.h"
#include "nsIDOMSVGRectElement.h"
#include "nsSVGElement.h"
@ -72,7 +71,7 @@ public:
PRInt32 aModType);
// nsISVGPathGeometrySource interface:
NS_IMETHOD ConstructPath(nsISVGRendererPathBuilder *pathBuilder);
NS_IMETHOD ConstructPath(cairo_t *aCtx);
};
//----------------------------------------------------------------------
@ -116,9 +115,8 @@ nsSVGRectFrame::AttributeChanged(PRInt32 aNameSpaceID,
//----------------------------------------------------------------------
// nsISVGPathGeometrySource methods:
/* void constructPath (in nsISVGRendererPathBuilder pathBuilder); */
NS_IMETHODIMP
nsSVGRectFrame::ConstructPath(nsISVGRendererPathBuilder* pathBuilder)
nsSVGRectFrame::ConstructPath(cairo_t *aCtx)
{
float x, y, width, height, rx, ry;
@ -156,16 +154,37 @@ nsSVGRectFrame::ConstructPath(nsISVGRendererPathBuilder* pathBuilder)
else if (ry > halfHeight)
rx = ry = halfHeight;
pathBuilder->Moveto(x+rx, y);
pathBuilder->Lineto(x+width-rx, y);
pathBuilder->Arcto(x+width, y+ry , rx, ry, 0.0f, PR_FALSE, PR_TRUE);
pathBuilder->Lineto(x+width, y+height-ry);
pathBuilder->Arcto(x+width-rx, y+height , rx, ry, 0.0f, PR_FALSE, PR_TRUE);
pathBuilder->Lineto(x+rx,y+height);
pathBuilder->Arcto(x, y+height-ry , rx, ry, 0.0f, PR_FALSE, PR_TRUE);
pathBuilder->Lineto(x, y+ry);
pathBuilder->Arcto(x+rx, y, rx, ry, 0.0f, PR_FALSE, PR_TRUE);
pathBuilder->ClosePath(&x, &y);
if (rx == 0 && ry == 0) {
cairo_rectangle(aCtx, x, y, width, height);
} else {
// Conversion factor used for ellipse to bezier conversion.
// Gives radial error of 0.0273% in circular case.
// See comp.graphics.algorithms FAQ 4.04
const float magic = 4*(sqrt(2.)-1)/3;
cairo_move_to(aCtx, x+rx, y);
cairo_line_to(aCtx, x+width-rx, y);
cairo_curve_to(aCtx,
x+width-rx + magic*rx, y,
x+width, y+ry-magic*ry,
x+width, y+ry);
cairo_line_to(aCtx, x+width, y+height-ry);
cairo_curve_to(aCtx,
x+width, y+height-ry + magic*ry,
x+width-rx + magic*rx, y+height,
x+width-rx, y+height);
cairo_line_to(aCtx, x+rx, y+height);
cairo_curve_to(aCtx,
x+rx - magic*rx, y+height,
x, y+height-ry + magic*ry,
x, y+height-ry);
cairo_line_to(aCtx, x, y+ry);
cairo_curve_to(aCtx,
x, y+ry - magic*ry,
x+rx - magic*rx, y,
x+rx, y);
cairo_close_path(aCtx);
}
return NS_OK;
}

Просмотреть файл

@ -56,7 +56,6 @@ XPIDLSRCS = \
nsISVGRendererCanvas.idl \
nsISVGRendererGlyphGeometry.idl \
nsISVGRendererGlyphMetrics.idl \
nsISVGRendererPathBuilder.idl \
nsISVGRendererPathGeometry.idl \
nsISVGRendererRegion.idl \
nsISVGRendererSurface.idl \

Просмотреть файл

@ -60,7 +60,14 @@ interface nsISVGRendererPathBuilder;
*
* @nosubgrouping
*/
[scriptable, uuid(73c9350e-6b0b-4458-aa24-aa5333476eff)]
%{C++
#include <cairo.h>
%}
[ptr] native cairo_t(cairo_t);
[uuid(da4a0226-0d97-4e7f-9bbb-d61c4977441c)]
interface nsISVGPathGeometrySource : nsISVGGeometrySource
{
@ -72,9 +79,9 @@ interface nsISVGPathGeometrySource : nsISVGGeometrySource
/**
* Write a description of the path to the 'pathBuilder'.
*
* @param pathBuilder Object to write path description to.
* @param aCtx cairo context to write path description to.
*/
void constructPath(in nsISVGRendererPathBuilder pathBuilder);
void constructPath(in cairo_t aCtx);
const unsigned long UPDATEMASK_PATH = 0x00008000;

Просмотреть файл

Просмотреть файл

@ -73,7 +73,6 @@ CPPSRCS = \
nsSVGRendererCairo.cpp \
nsSVGCairoCanvas.cpp \
nsSVGCairoPathGeometry.cpp \
nsSVGCairoPathBuilder.cpp \
nsSVGCairoRegion.cpp \
nsSVGCairoGlyphMetrics.cpp \
nsSVGCairoGlyphGeometry.cpp \
@ -92,7 +91,7 @@ CXXFLAGS += $(MOZ_CAIRO_CFLAGS)
LOCAL_INCLUDES = \
-I$(topsrcdir)/gfx/src \
$(NULL)
$(NULL)
ifdef MOZ_ENABLE_GTK
LOCAL_INCLUDES += -I$(topsrcdir)/gfx/src/gtk

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -48,8 +48,6 @@
#include "nsIDOMSVGMatrix.h"
#include "nsISVGRendererRegion.h"
#include "nsISVGPathGeometrySource.h"
#include "nsISVGRendererPathBuilder.h"
#include "nsSVGCairoPathBuilder.h"
#include "nsMemory.h"
#include <float.h>
#include <cairo.h>
@ -179,10 +177,8 @@ nsSVGCairoPathGeometry::GeneratePath(cairo_t *ctx, nsISVGCairoCanvas* aCanvas)
}
cairo_set_matrix(ctx, &matrix);
nsCOMPtr<nsISVGRendererPathBuilder> builder;
NS_NewSVGCairoPathBuilder(getter_AddRefs(builder), ctx);
mSource->ConstructPath(builder);
builder->EndPath();
cairo_new_path(ctx);
mSource->ConstructPath(ctx);
PRUint16 type;