Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 381622 - complete cairo removal from svg. r+sr=roc
Browse files Browse the repository at this point in the history
  • Loading branch information
Unknown committed May 23, 2007
1 parent 0b90ef6 commit b68151e
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 87 deletions.
3 changes: 0 additions & 3 deletions content/svg/content/src/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,6 @@ EXPORTS = \

include $(topsrcdir)/config/rules.mk

CFLAGS += $(MOZ_CAIRO_CFLAGS)
CXXFLAGS += $(MOZ_CAIRO_CFLAGS)

INCLUDES += \
-I$(srcdir)/../../../shared/public \
-I$(srcdir)/../../../html/base/src \
Expand Down
3 changes: 0 additions & 3 deletions layout/svg/base/src/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,6 @@ EXPORTS = \

include $(topsrcdir)/config/rules.mk

CFLAGS += $(MOZ_CAIRO_CFLAGS)
CXXFLAGS += $(MOZ_CAIRO_CFLAGS)

LOCAL_INCLUDES = \
-I$(srcdir)/../../../base \
-I$(srcdir)/../../../generic \
Expand Down
1 change: 0 additions & 1 deletion layout/svg/base/src/nsSVGImageFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
#include "nsSVGElement.h"
#include "nsSVGUtils.h"
#include "nsSVGMatrix.h"
#include "cairo.h"
#include "gfxContext.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsThebesImage.h"
Expand Down
68 changes: 6 additions & 62 deletions layout/svg/base/src/nsSVGUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
#include "nsAttrValue.h"
#include "nsSVGGeometryFrame.h"
#include "nsIScriptError.h"
#include "cairo.h"
#include "gfxContext.h"
#include "gfxMatrix.h"
#include "gfxRect.h"
Expand Down Expand Up @@ -352,7 +351,6 @@ nsSVGMaskProperty::ParentChainChanged(nsIContent *aContent)
mFrame->DeleteProperty(nsGkAtoms::mask);
}

cairo_surface_t *nsSVGUtils::mCairoComputationalSurface = nsnull;
gfxASurface *nsSVGUtils::mThebesComputationalSurface = nsnull;

// c = n / 255
Expand Down Expand Up @@ -1257,16 +1255,6 @@ nsSVGUtils::ToBoundingPixelRect(const gfxRect& rect)
nscoord(ceil(rect.YMost()) - floor(rect.Y())));
}

cairo_surface_t *
nsSVGUtils::GetCairoComputationalSurface()
{
if (!mCairoComputationalSurface)
mCairoComputationalSurface =
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1);

return mCairoComputationalSurface;
}

gfxASurface *
nsSVGUtils::GetThebesComputationalSurface()
{
Expand All @@ -1282,20 +1270,6 @@ nsSVGUtils::GetThebesComputationalSurface()
return mThebesComputationalSurface;
}

cairo_matrix_t
nsSVGUtils::ConvertSVGMatrixToCairo(nsIDOMSVGMatrix *aMatrix)
{
float A, B, C, D, E, F;
aMatrix->GetA(&A);
aMatrix->GetB(&B);
aMatrix->GetC(&C);
aMatrix->GetD(&D);
aMatrix->GetE(&E);
aMatrix->GetF(&F);
cairo_matrix_t m = { A, B, C, D, E, F };
return m;
}

gfxMatrix
nsSVGUtils::ConvertSVGMatrixToThebes(nsIDOMSVGMatrix *aMatrix)
{
Expand All @@ -1317,50 +1291,20 @@ nsSVGUtils::HitTestRect(nsIDOMSVGMatrix *aMatrix,
PRBool result = PR_TRUE;

if (aMatrix) {
cairo_matrix_t matrix = ConvertSVGMatrixToCairo(aMatrix);
cairo_t *ctx = cairo_create(GetCairoComputationalSurface());
if (cairo_status(ctx) != CAIRO_STATUS_SUCCESS) {
cairo_destroy(ctx);
return PR_FALSE;
}
cairo_set_tolerance(ctx, 1.0);
gfxContext ctx(GetThebesComputationalSurface());
ctx.SetMatrix(ConvertSVGMatrixToThebes(aMatrix));

cairo_set_matrix(ctx, &matrix);
cairo_new_path(ctx);
cairo_rectangle(ctx, aRX, aRY, aRWidth, aRHeight);
cairo_identity_matrix(ctx);
ctx.NewPath();
ctx.Rectangle(gfxRect(aRX, aRY, aRWidth, aRHeight));
ctx.IdentityMatrix();

if (!cairo_in_fill(ctx, aX, aY))
if (!ctx.PointInFill(gfxPoint(aX, aY)))
result = PR_FALSE;

cairo_destroy(ctx);
}

return result;
}

void
nsSVGUtils::UserToDeviceBBox(cairo_t *ctx,
double *xmin, double *ymin,
double *xmax, double *ymax)
{
double x[3], y[3];
x[0] = *xmin; y[0] = *ymax;
x[1] = *xmax; y[1] = *ymax;
x[2] = *xmax; y[2] = *ymin;

cairo_user_to_device(ctx, xmin, ymin);
*xmax = *xmin;
*ymax = *ymin;
for (int i = 0; i < 3; i++) {
cairo_user_to_device(ctx, &x[i], &y[i]);
*xmin = PR_MIN(*xmin, x[i]);
*xmax = PR_MAX(*xmax, x[i]);
*ymin = PR_MIN(*ymin, y[i]);
*ymax = PR_MAX(*ymax, y[i]);
}
}

void
nsSVGUtils::CompositeSurfaceMatrix(gfxContext *aContext,
gfxASurface *aSurface,
Expand Down
19 changes: 1 addition & 18 deletions layout/svg/base/src/nsSVGUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
#include "nsCOMPtr.h"
#include "nsISVGValue.h"
#include "nsRect.h"
#include "cairo.h"

class nsIDocument;
class nsPresContext;
Expand Down Expand Up @@ -305,20 +304,12 @@ class nsSVGUtils
ToBoundingPixelRect(const gfxRect& rect);

/*
* Get a pointer to a surface that can be used to create cairo
* Get a pointer to a surface that can be used to create thebes
* contexts for various measurement purposes.
*/
static cairo_surface_t *
GetCairoComputationalSurface();
static gfxASurface *
GetThebesComputationalSurface();

/*
* Convert a nsIDOMSVGMatrix to a cairo_matrix_t.
*/
static cairo_matrix_t
ConvertSVGMatrixToCairo(nsIDOMSVGMatrix *aMatrix);

/*
* Convert a nsIDOMSVGMatrix to a gfxMatrix.
*/
Expand All @@ -333,13 +324,6 @@ class nsSVGUtils
float aRX, float aRY, float aRWidth, float aRHeight,
float aX, float aY);

/*
* Convert a rectangle from cairo user space to device space.
*/
static void
UserToDeviceBBox(cairo_t *ctx,
double *xmin, double *ymin,
double *xmax, double *ymax);

static void CompositeSurfaceMatrix(gfxContext *aContext,
gfxASurface *aSurface,
Expand All @@ -359,7 +343,6 @@ class nsSVGUtils

private:
/* Computational (nil) surfaces */
static cairo_surface_t *mCairoComputationalSurface;
static gfxASurface *mThebesComputationalSurface;
};

Expand Down

0 comments on commit b68151e

Please sign in to comment.