Bug 585817. Part 3: Remove nsSVGUtils::GetThebesComputationalSurface and use gfxPlatform::ScreenReferenceSurface instead. r=jwatt

This commit is contained in:
Robert O'Callahan 2010-08-19 13:49:35 -05:00
parent 210184cb84
commit 3ecd0a2a97
8 changed files with 12 additions and 43 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1204,28 +1204,6 @@ nsSVGUtils::ConvertToSurfaceSize(const gfxSize& aSize, PRBool *aResultOverflows)
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
nsSVGUtils::ConvertSVGMatrixToThebes(nsIDOMSVGMatrix *aMatrix)
{
@ -1250,7 +1228,7 @@ nsSVGUtils::HitTestRect(const gfxMatrix &aMatrix,
if (aMatrix.IsSingular()) {
return PR_FALSE;
}
gfxContext ctx(GetThebesComputationalSurface());
gfxContext ctx(gfxPlatform::GetPlatform()->ScreenReferenceSurface());
ctx.SetMatrix(aMatrix);
ctx.NewPath();
ctx.Rectangle(gfxRect(aRX, aRY, aRWidth, aRHeight));

View File

@ -433,13 +433,6 @@ public:
static gfxIntSize
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.
*/
@ -570,8 +563,6 @@ public:
static PRBool NumberFromString(const nsAString& aString, float* aValue,
PRBool aAllowPercentages = PR_FALSE);
static void Shutdown();
private:
/* Computational (nil) surfaces */
static gfxASurface *gThebesComputationalSurface;