Merge backout

This commit is contained in:
Chris Jones 2010-08-19 19:03:59 -05:00
commit 03736343c4
8 changed files with 43 additions and 12 deletions

View File

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

View File

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

View File

@ -316,6 +316,10 @@ 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(gfxPlatform::GetPlatform()->ScreenReferenceSurface());
return new gfxContext(nsSVGUtils::GetThebesComputationalSurface());
}
NS_IMETHODIMP

View File

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

View File

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

View File

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

View File

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