Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes

gfxPlatform Class Reference

#include <gfxPlatform.h>

Inheritance diagram for gfxPlatform:
Collaboration diagram for gfxPlatform:

List of all members.

Public Types

typedef PRBool(* FontResolverCallback )(const nsAString &aName, void *aClosure)
 Font name resolver, this returns actual font name(s) by the callback function.
typedef PRBool(* PrefFontCallback )(eFontPrefLang aLang, const nsAString &aName, void *aClosure)
 Iterate over pref fonts given a list of lang groups.

Public Member Functions

virtual already_AddRefed
< gfxASurface
CreateOffscreenSurface (const gfxIntSize &size, gfxASurface::gfxContentType contentType)=0
 Create an offscreen surface of the given dimensions and image format.
virtual already_AddRefed
< gfxASurface
OptimizeImage (gfxImageSurface *aSurface, gfxASurface::gfxImageFormat format)
virtual void SetupClusterBoundaries (gfxTextRun *aTextRun, const PRUnichar *aString)
virtual nsresult GetFontList (nsIAtom *aLangGroup, const nsACString &aGenericFamily, nsTArray< nsString > &aListOfFonts)
 Fill aListOfFonts with the results of querying the list of font names that correspond to the given language group or generic font family (or both, or neither).
virtual nsresult UpdateFontList ()
 Rebuilds the any cached system font lists.
virtual gfxPlatformFontList * CreatePlatformFontList ()
 Create the platform font-list object (gfxPlatformFontList concrete subclass).
virtual nsresult ResolveFontName (const nsAString &aFontName, FontResolverCallback aCallback, void *aClosure, PRBool &aAborted)=0
virtual nsresult GetStandardFamilyName (const nsAString &aFontName, nsAString &aFamilyName)=0
 Resolving a font name to family name.
virtual gfxFontGroupCreateFontGroup (const nsAString &aFamilies, const gfxFontStyle *aStyle, gfxUserFontSet *aUserFontSet)=0
 Create the appropriate platform font group.
virtual gfxFontEntryLookupLocalFont (const gfxProxyFontEntry *aProxyEntry, const nsAString &aFontName)
 Look up a local platform font using the full font face name.
virtual gfxFontEntryMakePlatformFont (const gfxProxyFontEntry *aProxyEntry, const PRUint8 *aFontData, PRUint32 aLength)
 Activate a platform font.
PRBool DownloadableFontsEnabled ()
 Whether to allow downloadable fonts via -face rules.
PRBool SanitizeDownloadedFonts ()
 Whether to sanitize downloaded fonts using the OTS library.
PRBool PreserveOTLTablesWhenSanitizing ()
 Whether to preserve OpenType layout tables when sanitizing.
PRInt8 UseHarfBuzzLevel ()
 Whether to use the harfbuzz shaper (depending on script complexity).
virtual PRBool IsFontFormatSupported (nsIURI *aFontURI, PRUint32 aFormatFlags)
void GetPrefFonts (nsIAtom *aLanguage, nsString &array, PRBool aAppendUnicode=1)
void GetLangPrefs (eFontPrefLang aPrefLangs[], PRUint32 &aLen, eFontPrefLang aCharLang, eFontPrefLang aPageLang)
virtual void FontsPrefsChanged (nsIPrefBranch *aPrefBranch, const char *aPref)
gfxASurfaceScreenReferenceSurface ()
 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.
virtual gfxImageFormat GetOffscreenFormat ()

Static Public Member Functions

static gfxPlatformGetPlatform ()
 Return a pointer to the current active platform.
static nsresult Init ()
 Start up Thebes.
static void Shutdown ()
 Clean up static objects to shut down thebes.
static PRBool ForEachPrefFont (eFontPrefLang aLangArray[], PRUint32 aLangArrayLen, PrefFontCallback aCallback, void *aClosure)
static eFontPrefLang GetFontPrefLangFor (const char *aLang)
static eFontPrefLang GetFontPrefLangFor (nsIAtom *aLang)
static const char * GetPrefLangName (eFontPrefLang aLang)
static eFontPrefLang GetFontPrefLangFor (PRUint8 aUnicodeRange)
static PRBool IsLangCJK (eFontPrefLang aLang)
static void AppendPrefLang (eFontPrefLang aPrefLangs[], PRUint32 &aLen, eFontPrefLang aAddLang)
static eCMSMode GetCMSMode ()
 Are we going to try color management?
static int GetRenderingIntent ()
 Determines the rendering intent for color management.
static void TransformPixel (const gfxRGBA &in, gfxRGBA &out, qcms_transform *transform)
 Convert a pixel using a cms transform in an endian-aware manner.
static qcms_profileGetCMSOutputProfile ()
 Return the output device ICC profile.
static qcms_profileGetCMSsRGBProfile ()
 Return the sRGB ICC profile.
static qcms_transformGetCMSRGBTransform ()
 Return sRGB -> output device transform.
static qcms_transformGetCMSInverseRGBTransform ()
 Return output -> sRGB device transform.
static qcms_transformGetCMSRGBATransform ()
 Return sRGBA -> output device transform.
static PRLogModuleInfoGetLog (eGfxLog aWhichLog)
 Returns a logger if one is available and logging is enabled.

Protected Member Functions

 gfxPlatform ()
virtual ~gfxPlatform ()
void AppendCJKPrefLangs (eFontPrefLang aPrefLangs[], PRUint32 &aLen, eFontPrefLang aCharLang, eFontPrefLang aPageLang)

Static Protected Member Functions

static PRBool GetBoolPref (const char *aPref, PRBool aDefault)

Protected Attributes

PRBool mAllowDownloadableFonts
PRBool mDownloadableFontsSanitize
PRBool mSanitizePreserveOTLTables
PRInt8 mUseHarfBuzzLevel

Member Typedef Documentation

typedef PRBool(* gfxPlatform::FontResolverCallback)(const nsAString &aName, void *aClosure)

Font name resolver, this returns actual font name(s) by the callback function.

If the font doesn't exist, the callback function is not called. If the callback function returns PR_FALSE, the aAborted value is set to PR_TRUE, otherwise, PR_FALSE.

typedef PRBool(* gfxPlatform::PrefFontCallback)(eFontPrefLang aLang, const nsAString &aName, void *aClosure)

Iterate over pref fonts given a list of lang groups.

For a single lang group, multiple pref fonts are possible. If error occurs, returns PR_FALSE, PR_TRUE otherwise. Callback returns PR_FALSE to abort process.


Constructor & Destructor Documentation

gfxPlatform::gfxPlatform (  )  [protected]
virtual gfxPlatform::~gfxPlatform (  )  [protected, virtual]

Member Function Documentation

void gfxPlatform::AppendCJKPrefLangs ( eFontPrefLang  aPrefLangs[],
PRUint32 &  aLen,
eFontPrefLang  aCharLang,
eFontPrefLang  aPageLang 
) [protected]
static void gfxPlatform::AppendPrefLang ( eFontPrefLang  aPrefLangs[],
PRUint32 &  aLen,
eFontPrefLang  aAddLang 
) [static]
virtual gfxFontGroup* gfxPlatform::CreateFontGroup ( const nsAString aFamilies,
const gfxFontStyle aStyle,
gfxUserFontSet aUserFontSet 
) [pure virtual]

Create the appropriate platform font group.

Implemented in gfxPlatformGtk.

virtual already_AddRefed<gfxASurface> gfxPlatform::CreateOffscreenSurface ( const gfxIntSize size,
gfxASurface::gfxContentType  contentType 
) [pure virtual]

Create an offscreen surface of the given dimensions and image format.

Implemented in gfxPlatformGtk.

virtual gfxPlatformFontList* gfxPlatform::CreatePlatformFontList (  )  [inline, virtual]

Create the platform font-list object (gfxPlatformFontList concrete subclass).

This function is responsible to create the appropriate subclass of gfxPlatformFontList *and* to call its InitFontList() method.

PRBool gfxPlatform::DownloadableFontsEnabled (  ) 

Whether to allow downloadable fonts via -face rules.

virtual void gfxPlatform::FontsPrefsChanged ( nsIPrefBranch aPrefBranch,
const char *  aPref 
) [virtual]
static PRBool gfxPlatform::ForEachPrefFont ( eFontPrefLang  aLangArray[],
PRUint32  aLangArrayLen,
PrefFontCallback  aCallback,
void *  aClosure 
) [static]
static PRBool gfxPlatform::GetBoolPref ( const char *  aPref,
PRBool  aDefault 
) [static, protected]
static qcms_transform* gfxPlatform::GetCMSInverseRGBTransform (  )  [static]

Return output -> sRGB device transform.

static eCMSMode gfxPlatform::GetCMSMode (  )  [static]

Are we going to try color management?

static qcms_profile* gfxPlatform::GetCMSOutputProfile (  )  [static]

Return the output device ICC profile.

static qcms_transform* gfxPlatform::GetCMSRGBATransform (  )  [static]

Return sRGBA -> output device transform.

static qcms_transform* gfxPlatform::GetCMSRGBTransform (  )  [static]

Return sRGB -> output device transform.

static qcms_profile* gfxPlatform::GetCMSsRGBProfile (  )  [static]

Return the sRGB ICC profile.

virtual nsresult gfxPlatform::GetFontList ( nsIAtom aLangGroup,
const nsACString aGenericFamily,
nsTArray< nsString > &  aListOfFonts 
) [virtual]

Fill aListOfFonts with the results of querying the list of font names that correspond to the given language group or generic font family (or both, or neither).

Reimplemented in gfxPlatformGtk.

static eFontPrefLang gfxPlatform::GetFontPrefLangFor ( const char *  aLang  )  [static]
static eFontPrefLang gfxPlatform::GetFontPrefLangFor ( nsIAtom aLang  )  [static]
static eFontPrefLang gfxPlatform::GetFontPrefLangFor ( PRUint8  aUnicodeRange  )  [static]
void gfxPlatform::GetLangPrefs ( eFontPrefLang  aPrefLangs[],
PRUint32 &  aLen,
eFontPrefLang  aCharLang,
eFontPrefLang  aPageLang 
)
static PRLogModuleInfo* gfxPlatform::GetLog ( eGfxLog  aWhichLog  )  [static]

Returns a logger if one is available and logging is enabled.

virtual gfxImageFormat gfxPlatform::GetOffscreenFormat (  )  [inline, virtual]

Reimplemented in gfxPlatformGtk.

static gfxPlatform* gfxPlatform::GetPlatform (  )  [static]

Return a pointer to the current active platform.

This is a singleton; it contains mostly convenience functions to obtain platform-specific objects.

Reimplemented in gfxPlatformGtk.

void gfxPlatform::GetPrefFonts ( nsIAtom aLanguage,
nsString &  array,
PRBool  aAppendUnicode = 1 
)
static const char* gfxPlatform::GetPrefLangName ( eFontPrefLang  aLang  )  [static]
static int gfxPlatform::GetRenderingIntent (  )  [static]

Determines the rendering intent for color management.

If the value in the pref gfx.color_management.rendering_intent is a valid rendering intent as defined in gfx/qcms/qcms.h, that value is returned. Otherwise, -1 is returned and the embedded intent should be used.

See bug 444014 for details.

virtual nsresult gfxPlatform::GetStandardFamilyName ( const nsAString aFontName,
nsAString aFamilyName 
) [pure virtual]

Resolving a font name to family name.

The result MUST be in the result of GetFontList(). If the name doesn't in the system, aFamilyName will be empty string, but not failed.

Implemented in gfxPlatformGtk.

static nsresult gfxPlatform::Init (  )  [static]

Start up Thebes.

This can fail.

virtual PRBool gfxPlatform::IsFontFormatSupported ( nsIURI aFontURI,
PRUint32  aFormatFlags 
) [inline, virtual]
static PRBool gfxPlatform::IsLangCJK ( eFontPrefLang  aLang  )  [static]
virtual gfxFontEntry* gfxPlatform::LookupLocalFont ( const gfxProxyFontEntry aProxyEntry,
const nsAString aFontName 
) [inline, virtual]

Look up a local platform font using the full font face name.

(Needed to support -face src local().) Ownership of the returned gfxFontEntry is passed to the caller, who must either AddRef() or delete.

virtual gfxFontEntry* gfxPlatform::MakePlatformFont ( const gfxProxyFontEntry aProxyEntry,
const PRUint8 *  aFontData,
PRUint32  aLength 
) [virtual]

Activate a platform font.

(Needed to support -face src url().) aFontData is a NS_Malloc'ed block that must be freed by this function (or responsibility passed on) when it is no longer needed; the caller will NOT free it. Ownership of the returned gfxFontEntry is passed to the caller, who must either AddRef() or delete.

virtual already_AddRefed<gfxASurface> gfxPlatform::OptimizeImage ( gfxImageSurface aSurface,
gfxASurface::gfxImageFormat  format 
) [virtual]
PRBool gfxPlatform::PreserveOTLTablesWhenSanitizing (  ) 

Whether to preserve OpenType layout tables when sanitizing.

virtual nsresult gfxPlatform::ResolveFontName ( const nsAString aFontName,
FontResolverCallback  aCallback,
void *  aClosure,
PRBool aAborted 
) [pure virtual]

Implemented in gfxPlatformGtk.

PRBool gfxPlatform::SanitizeDownloadedFonts (  ) 

Whether to sanitize downloaded fonts using the OTS library.

gfxASurface* gfxPlatform::ScreenReferenceSurface (  )  [inline]

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.

virtual void gfxPlatform::SetupClusterBoundaries ( gfxTextRun aTextRun,
const PRUnichar aString 
) [virtual]
static void gfxPlatform::Shutdown (  )  [static]

Clean up static objects to shut down thebes.

static void gfxPlatform::TransformPixel ( const gfxRGBA in,
gfxRGBA out,
qcms_transform transform 
) [static]

Convert a pixel using a cms transform in an endian-aware manner.

Sets 'out' to 'in' if transform is NULL.

virtual nsresult gfxPlatform::UpdateFontList (  )  [virtual]

Rebuilds the any cached system font lists.

Reimplemented in gfxPlatformGtk.

PRInt8 gfxPlatform::UseHarfBuzzLevel (  ) 

Whether to use the harfbuzz shaper (depending on script complexity).

This allows harfbuzz to be enabled selectively via the preferences. Current "harfbuzz level" options: <= 0 will never use the harfbuzz shaper; = 1 will use it for "simple" scripts (Latin, Cyrillic, CJK, etc); >= 2 will use it for all scripts, including those requiring complex shaping for correct rendering (Arabic, Indic, etc).

Depending how harfbuzz complex-script support evolves, we may want to update this mechanism - e.g., separating complex-bidi from Indic, or other distinctions.


Member Data Documentation

PRInt8 gfxPlatform::mUseHarfBuzzLevel [protected]

The documentation for this class was generated from the following file: