diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index 9e480553b04b..4b7c86ed289e 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -238,6 +238,15 @@ gfxPlatform::Init() if (!gPlatform) return NS_ERROR_OUT_OF_MEMORY; + gPlatform->mScreenReferenceSurface = + gPlatform->CreateOffscreenSurface(gfxIntSize(1,1), + gfxASurface::ImageFormatARGB32); + if (!gPlatform->mScreenReferenceSurface) { + NS_ERROR("Could not initialize mScreenReferenceSurface"); + Shutdown(); + return NS_ERROR_OUT_OF_MEMORY; + } + nsresult rv; #if defined(XP_MACOSX) || defined(XP_WIN) || defined(ANDROID) // temporary, until this is implemented on others diff --git a/gfx/thebes/gfxPlatform.h b/gfx/thebes/gfxPlatform.h index 14883c79fb84..f1f3ff413b7d 100644 --- a/gfx/thebes/gfxPlatform.h +++ b/gfx/thebes/gfxPlatform.h @@ -339,6 +339,12 @@ public: virtual void FontsPrefsChanged(nsIPrefBranch *aPrefBranch, const char *aPref); + /** + * Returns a 1x1 surface that can be used to create graphics contexts + * for measuring text etc as if they will be rendered to the screen + */ + gfxASurface* ScreenReferenceSurface() { return mScreenReferenceSurface; } + protected: gfxPlatform(); virtual ~gfxPlatform(); @@ -356,8 +362,8 @@ protected: private: virtual qcms_profile* GetPlatformCMSOutputProfile(); + nsRefPtr mScreenReferenceSurface; nsTArray mCJKPrefLangs; - nsCOMPtr overrideObserver; };