This commit is contained in:
Chris Jones 2010-08-19 19:03:59 -05:00
Родитель fd3726cc3f 7f92d363c1
Коммит 03736343c4
8 изменённых файлов: 43 добавлений и 12 удалений

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

@ -47,7 +47,6 @@
#include "nsDebug.h" #include "nsDebug.h"
#include "gfxContext.h" #include "gfxContext.h"
#include "nsSVGUtils.h" #include "nsSVGUtils.h"
#include "gfxPlatform.h"
class nsSVGElement; class nsSVGElement;
class nsIContent; class nsIContent;
@ -64,7 +63,7 @@ public:
public: public:
PathGenerator(nsSVGElement* aSVGElement) PathGenerator(nsSVGElement* aSVGElement)
: mSVGElement(aSVGElement), : mSVGElement(aSVGElement),
mGfxContext(gfxPlatform::GetPlatform()->ScreenReferenceSurface()), mGfxContext(nsSVGUtils::GetThebesComputationalSurface()),
mHaveReceivedCommands(PR_FALSE) mHaveReceivedCommands(PR_FALSE)
{} {}

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

@ -48,7 +48,6 @@
#include "nsSVGUtils.h" #include "nsSVGUtils.h"
#include "nsSVGPoint.h" #include "nsSVGPoint.h"
#include "gfxContext.h" #include "gfxContext.h"
#include "gfxPlatform.h"
nsSVGElement::NumberInfo nsSVGPathElement::sNumberInfo = nsSVGElement::NumberInfo nsSVGPathElement::sNumberInfo =
{ &nsGkAtoms::pathLength, 0 }; { &nsGkAtoms::pathLength, 0 };
@ -1042,7 +1041,7 @@ nsSVGPathList::Playback(gfxContext *aCtx)
already_AddRefed<gfxFlattenedPath> already_AddRefed<gfxFlattenedPath>
nsSVGPathList::GetFlattenedPath(const gfxMatrix& aMatrix) nsSVGPathList::GetFlattenedPath(const gfxMatrix& aMatrix)
{ {
gfxContext ctx(gfxPlatform::GetPlatform()->ScreenReferenceSurface()); gfxContext ctx(nsSVGUtils::GetThebesComputationalSurface());
ctx.SetMatrix(aMatrix); ctx.SetMatrix(aMatrix);
Playback(&ctx); Playback(&ctx);

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

@ -316,6 +316,10 @@ nsLayoutStatics::Shutdown()
nsCellMap::Shutdown(); nsCellMap::Shutdown();
nsFrame::ShutdownLayerActivityTimer(); nsFrame::ShutdownLayerActivityTimer();
#ifdef MOZ_SVG
nsSVGUtils::Shutdown();
#endif
// Release all of our atoms // Release all of our atoms
nsColorNames::ReleaseTable(); nsColorNames::ReleaseTable();
nsCSSProps::ReleaseTable(); nsCSSProps::ReleaseTable();

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

@ -439,7 +439,7 @@ nsSVGGlyphFrame::GetCoveredRegion()
static gfxContext * static gfxContext *
MakeTmpCtx() { MakeTmpCtx() {
return new gfxContext(gfxPlatform::GetPlatform()->ScreenReferenceSurface()); return new gfxContext(nsSVGUtils::GetThebesComputationalSurface());
} }
NS_IMETHODIMP NS_IMETHODIMP

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

@ -45,7 +45,6 @@
#include "gfxContext.h" #include "gfxContext.h"
#include "gfxMatrix.h" #include "gfxMatrix.h"
#include "nsIInterfaceRequestorUtils.h" #include "nsIInterfaceRequestorUtils.h"
#include "gfxPlatform.h"
class nsSVGImageFrame; class nsSVGImageFrame;
@ -328,7 +327,7 @@ nsSVGImageFrame::UpdateCoveredRegion()
{ {
mRect.Empty(); mRect.Empty();
gfxContext context(gfxPlatform::GetPlatform()->ScreenReferenceSurface()); gfxContext context(nsSVGUtils::GetThebesComputationalSurface());
GeneratePath(&context); GeneratePath(&context);
context.IdentityMatrix(); context.IdentityMatrix();

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

@ -46,7 +46,6 @@
#include "nsSVGRect.h" #include "nsSVGRect.h"
#include "nsSVGPathGeometryElement.h" #include "nsSVGPathGeometryElement.h"
#include "gfxContext.h" #include "gfxContext.h"
#include "gfxPlatform.h"
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Implementation // Implementation
@ -170,7 +169,7 @@ nsSVGPathGeometryFrame::GetFrameForPoint(const nsPoint &aPoint)
PRBool isHit = PR_FALSE; PRBool isHit = PR_FALSE;
gfxContext context(gfxPlatform::GetPlatform()->ScreenReferenceSurface()); gfxContext context(nsSVGUtils::GetThebesComputationalSurface());
GeneratePath(&context); GeneratePath(&context);
gfxPoint userSpacePoint = gfxPoint userSpacePoint =
@ -250,7 +249,7 @@ nsSVGPathGeometryFrame::UpdateCoveredRegion()
{ {
mRect.Empty(); mRect.Empty();
gfxContext context(gfxPlatform::GetPlatform()->ScreenReferenceSurface()); gfxContext context(nsSVGUtils::GetThebesComputationalSurface());
GeneratePath(&context); GeneratePath(&context);
context.IdentityMatrix(); context.IdentityMatrix();
@ -362,7 +361,7 @@ nsSVGPathGeometryFrame::GetBBoxContribution(const gfxMatrix &aToBBoxUserspace)
// XXX ReportToConsole // XXX ReportToConsole
return gfxRect(0.0, 0.0, 0.0, 0.0); return gfxRect(0.0, 0.0, 0.0, 0.0);
} }
gfxContext context(gfxPlatform::GetPlatform()->ScreenReferenceSurface()); gfxContext context(nsSVGUtils::GetThebesComputationalSurface());
GeneratePath(&context, &aToBBoxUserspace); GeneratePath(&context, &aToBBoxUserspace);
context.IdentityMatrix(); context.IdentityMatrix();
return context.GetUserPathExtent(); return context.GetUserPathExtent();

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

@ -1204,6 +1204,28 @@ nsSVGUtils::ConvertToSurfaceSize(const gfxSize& aSize, PRBool *aResultOverflows)
return surfaceSize; return surfaceSize;
} }
gfxASurface *
nsSVGUtils::GetThebesComputationalSurface()
{
if (!gThebesComputationalSurface) {
nsRefPtr<gfxImageSurface> surface =
new gfxImageSurface(gfxIntSize(1, 1), gfxASurface::ImageFormatARGB32);
NS_ASSERTION(surface && !surface->CairoStatus(),
"Could not create offscreen surface");
gThebesComputationalSurface = surface;
// we want to keep this surface around
NS_IF_ADDREF(gThebesComputationalSurface);
}
return gThebesComputationalSurface;
}
void
nsSVGUtils::Shutdown()
{
NS_IF_RELEASE(gThebesComputationalSurface);
}
gfxMatrix gfxMatrix
nsSVGUtils::ConvertSVGMatrixToThebes(nsIDOMSVGMatrix *aMatrix) nsSVGUtils::ConvertSVGMatrixToThebes(nsIDOMSVGMatrix *aMatrix)
{ {
@ -1228,7 +1250,7 @@ nsSVGUtils::HitTestRect(const gfxMatrix &aMatrix,
if (aMatrix.IsSingular()) { if (aMatrix.IsSingular()) {
return PR_FALSE; return PR_FALSE;
} }
gfxContext ctx(gfxPlatform::GetPlatform()->ScreenReferenceSurface()); gfxContext ctx(GetThebesComputationalSurface());
ctx.SetMatrix(aMatrix); ctx.SetMatrix(aMatrix);
ctx.NewPath(); ctx.NewPath();
ctx.Rectangle(gfxRect(aRX, aRY, aRWidth, aRHeight)); ctx.Rectangle(gfxRect(aRX, aRY, aRWidth, aRHeight));

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

@ -433,6 +433,13 @@ public:
static gfxIntSize static gfxIntSize
ConvertToSurfaceSize(const gfxSize& aSize, PRBool *aResultOverflows); ConvertToSurfaceSize(const gfxSize& aSize, PRBool *aResultOverflows);
/*
* Get a pointer to a surface that can be used to create thebes
* contexts for various measurement purposes.
*/
static gfxASurface *
GetThebesComputationalSurface();
/* /*
* Convert a nsIDOMSVGMatrix to a gfxMatrix. * Convert a nsIDOMSVGMatrix to a gfxMatrix.
*/ */
@ -563,6 +570,8 @@ public:
static PRBool NumberFromString(const nsAString& aString, float* aValue, static PRBool NumberFromString(const nsAString& aString, float* aValue,
PRBool aAllowPercentages = PR_FALSE); PRBool aAllowPercentages = PR_FALSE);
static void Shutdown();
private: private:
/* Computational (nil) surfaces */ /* Computational (nil) surfaces */
static gfxASurface *gThebesComputationalSurface; static gfxASurface *gThebesComputationalSurface;