michael@0: /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef GFX_PLATFORM_H michael@0: #define GFX_PLATFORM_H michael@0: michael@0: #include "prlog.h" michael@0: #include "nsTArray.h" michael@0: #include "nsString.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsAutoPtr.h" michael@0: michael@0: #include "gfxTypes.h" michael@0: #include "nsRect.h" michael@0: michael@0: #include "qcms.h" michael@0: michael@0: #include "mozilla/RefPtr.h" michael@0: #include "GfxInfoCollector.h" michael@0: michael@0: #include "mozilla/layers/CompositorTypes.h" michael@0: michael@0: class gfxASurface; michael@0: class gfxImageSurface; michael@0: class gfxFont; michael@0: class gfxFontGroup; michael@0: struct gfxFontStyle; michael@0: class gfxUserFontSet; michael@0: class gfxFontEntry; michael@0: class gfxProxyFontEntry; michael@0: class gfxPlatformFontList; michael@0: class gfxTextRun; michael@0: class nsIURI; michael@0: class nsIAtom; michael@0: class nsIObserver; michael@0: struct gfxRGBA; michael@0: michael@0: namespace mozilla { michael@0: namespace gl { michael@0: class GLContext; michael@0: class SkiaGLGlue; michael@0: } michael@0: namespace gfx { michael@0: class DrawTarget; michael@0: class SourceSurface; michael@0: class DataSourceSurface; michael@0: class ScaledFont; michael@0: class DrawEventRecorder; michael@0: michael@0: inline uint32_t michael@0: BackendTypeBit(BackendType b) michael@0: { michael@0: return 1 << uint8_t(b); michael@0: } michael@0: } michael@0: } michael@0: michael@0: extern cairo_user_data_key_t kDrawTarget; michael@0: michael@0: // pref lang id's for font prefs michael@0: // !!! needs to match the list of pref font.default.xx entries listed in all.js !!! michael@0: // !!! don't use as bit mask, this may grow larger !!! michael@0: michael@0: enum eFontPrefLang { michael@0: eFontPrefLang_Western = 0, michael@0: eFontPrefLang_CentEuro = 1, michael@0: eFontPrefLang_Japanese = 2, michael@0: eFontPrefLang_ChineseTW = 3, michael@0: eFontPrefLang_ChineseCN = 4, michael@0: eFontPrefLang_ChineseHK = 5, michael@0: eFontPrefLang_Korean = 6, michael@0: eFontPrefLang_Cyrillic = 7, michael@0: eFontPrefLang_Baltic = 8, michael@0: eFontPrefLang_Greek = 9, michael@0: eFontPrefLang_Turkish = 10, michael@0: eFontPrefLang_Thai = 11, michael@0: eFontPrefLang_Hebrew = 12, michael@0: eFontPrefLang_Arabic = 13, michael@0: eFontPrefLang_Devanagari = 14, michael@0: eFontPrefLang_Tamil = 15, michael@0: eFontPrefLang_Armenian = 16, michael@0: eFontPrefLang_Bengali = 17, michael@0: eFontPrefLang_Canadian = 18, michael@0: eFontPrefLang_Ethiopic = 19, michael@0: eFontPrefLang_Georgian = 20, michael@0: eFontPrefLang_Gujarati = 21, michael@0: eFontPrefLang_Gurmukhi = 22, michael@0: eFontPrefLang_Khmer = 23, michael@0: eFontPrefLang_Malayalam = 24, michael@0: eFontPrefLang_Oriya = 25, michael@0: eFontPrefLang_Telugu = 26, michael@0: eFontPrefLang_Kannada = 27, michael@0: eFontPrefLang_Sinhala = 28, michael@0: eFontPrefLang_Tibetan = 29, michael@0: michael@0: eFontPrefLang_Others = 30, // x-unicode michael@0: michael@0: eFontPrefLang_CJKSet = 31 // special code for CJK set michael@0: }; michael@0: michael@0: enum eCMSMode { michael@0: eCMSMode_Off = 0, // No color management michael@0: eCMSMode_All = 1, // Color manage everything michael@0: eCMSMode_TaggedOnly = 2, // Color manage tagged Images Only michael@0: eCMSMode_AllCount = 3 michael@0: }; michael@0: michael@0: enum eGfxLog { michael@0: // all font enumerations, localized names, fullname/psnames, cmap loads michael@0: eGfxLog_fontlist = 0, michael@0: // timing info on font initialization michael@0: eGfxLog_fontinit = 1, michael@0: // dump text runs, font matching, system fallback for content michael@0: eGfxLog_textrun = 2, michael@0: // dump text runs, font matching, system fallback for chrome michael@0: eGfxLog_textrunui = 3, michael@0: // dump cmap coverage data as they are loaded michael@0: eGfxLog_cmapdata = 4, michael@0: // text perf data michael@0: eGfxLog_textperf = 5 michael@0: }; michael@0: michael@0: // when searching through pref langs, max number of pref langs michael@0: const uint32_t kMaxLenPrefLangList = 32; michael@0: michael@0: #define UNINITIALIZED_VALUE (-1) michael@0: michael@0: inline const char* michael@0: GetBackendName(mozilla::gfx::BackendType aBackend) michael@0: { michael@0: switch (aBackend) { michael@0: case mozilla::gfx::BackendType::DIRECT2D: michael@0: return "direct2d"; michael@0: case mozilla::gfx::BackendType::COREGRAPHICS_ACCELERATED: michael@0: return "quartz accelerated"; michael@0: case mozilla::gfx::BackendType::COREGRAPHICS: michael@0: return "quartz"; michael@0: case mozilla::gfx::BackendType::CAIRO: michael@0: return "cairo"; michael@0: case mozilla::gfx::BackendType::SKIA: michael@0: return "skia"; michael@0: case mozilla::gfx::BackendType::RECORDING: michael@0: return "recording"; michael@0: case mozilla::gfx::BackendType::DIRECT2D1_1: michael@0: return "direct2d 1.1"; michael@0: case mozilla::gfx::BackendType::NONE: michael@0: return "none"; michael@0: } michael@0: MOZ_CRASH("Incomplete switch"); michael@0: } michael@0: michael@0: class gfxPlatform { michael@0: public: michael@0: typedef mozilla::gfx::IntSize IntSize; michael@0: michael@0: /** michael@0: * Return a pointer to the current active platform. michael@0: * This is a singleton; it contains mostly convenience michael@0: * functions to obtain platform-specific objects. michael@0: */ michael@0: static gfxPlatform *GetPlatform(); michael@0: michael@0: michael@0: /** michael@0: * Shut down Thebes. michael@0: * Init() arranges for this to be called at an appropriate time. michael@0: */ michael@0: static void Shutdown(); michael@0: michael@0: /** michael@0: * Create an offscreen surface of the given dimensions michael@0: * and image format. michael@0: */ michael@0: virtual already_AddRefed michael@0: CreateOffscreenSurface(const IntSize& size, michael@0: gfxContentType contentType) = 0; michael@0: michael@0: /** michael@0: * Create an offscreen surface of the given dimensions and image format which michael@0: * can be converted to a gfxImageSurface without copying. If we can provide michael@0: * a platform-hosted surface, then we will return that instead of an actual michael@0: * gfxImageSurface. michael@0: * Sub-classes should override this method if CreateOffscreenSurface returns a michael@0: * surface which implements GetAsImageSurface michael@0: */ michael@0: virtual already_AddRefed michael@0: CreateOffscreenImageSurface(const gfxIntSize& aSize, michael@0: gfxContentType aContentType); michael@0: michael@0: virtual already_AddRefed OptimizeImage(gfxImageSurface *aSurface, michael@0: gfxImageFormat format); michael@0: michael@0: /** michael@0: * Beware that these methods may return DrawTargets which are not fully supported michael@0: * on the current platform and might fail silently in subtle ways. This is a massive michael@0: * potential footgun. You should only use these methods for canvas drawing really. michael@0: * Use extreme caution if you use them for content where you are not 100% sure we michael@0: * support the DrawTarget we get back. michael@0: * See SupportsAzureContentForDrawTarget. michael@0: */ michael@0: virtual mozilla::RefPtr michael@0: CreateDrawTargetForSurface(gfxASurface *aSurface, const mozilla::gfx::IntSize& aSize); michael@0: michael@0: virtual mozilla::RefPtr michael@0: CreateDrawTargetForUpdateSurface(gfxASurface *aSurface, const mozilla::gfx::IntSize& aSize); michael@0: michael@0: /* michael@0: * Creates a SourceSurface for a gfxASurface. This function does no caching, michael@0: * so the caller should cache the gfxASurface if it will be used frequently. michael@0: * The returned surface keeps a reference to aTarget, so it is OK to keep the michael@0: * surface, even if aTarget changes. michael@0: * aTarget should not keep a reference to the returned surface because that michael@0: * will cause a cycle. michael@0: */ michael@0: virtual mozilla::RefPtr michael@0: GetSourceSurfaceForSurface(mozilla::gfx::DrawTarget *aTarget, gfxASurface *aSurface); michael@0: michael@0: static void ClearSourceSurfaceForSurface(gfxASurface *aSurface); michael@0: michael@0: static mozilla::RefPtr michael@0: GetWrappedDataSourceSurface(gfxASurface *aSurface); michael@0: michael@0: virtual mozilla::TemporaryRef michael@0: GetScaledFontForFont(mozilla::gfx::DrawTarget* aTarget, gfxFont *aFont); michael@0: michael@0: virtual already_AddRefed michael@0: GetThebesSurfaceForDrawTarget(mozilla::gfx::DrawTarget *aTarget); michael@0: michael@0: mozilla::RefPtr michael@0: CreateOffscreenContentDrawTarget(const mozilla::gfx::IntSize& aSize, mozilla::gfx::SurfaceFormat aFormat); michael@0: michael@0: mozilla::RefPtr michael@0: CreateOffscreenCanvasDrawTarget(const mozilla::gfx::IntSize& aSize, mozilla::gfx::SurfaceFormat aFormat); michael@0: michael@0: virtual mozilla::RefPtr michael@0: CreateDrawTargetForData(unsigned char* aData, const mozilla::gfx::IntSize& aSize, michael@0: int32_t aStride, mozilla::gfx::SurfaceFormat aFormat); michael@0: michael@0: /** michael@0: * Returns true if we should use Azure to render content with aTarget. For michael@0: * example, it is possible that we are using Direct2D for rendering and thus michael@0: * using Azure. But we want to render to a CairoDrawTarget, in which case michael@0: * SupportsAzureContent will return true but SupportsAzureContentForDrawTarget michael@0: * will return false. michael@0: */ michael@0: bool SupportsAzureContentForDrawTarget(mozilla::gfx::DrawTarget* aTarget); michael@0: michael@0: bool SupportsAzureContentForType(mozilla::gfx::BackendType aType) { michael@0: return BackendTypeBit(aType) & mContentBackendBitmask; michael@0: } michael@0: michael@0: virtual bool UseAcceleratedSkiaCanvas(); michael@0: virtual void InitializeSkiaCacheLimits(); michael@0: michael@0: void GetAzureBackendInfo(mozilla::widget::InfoObject &aObj) { michael@0: aObj.DefineProperty("AzureCanvasBackend", GetBackendName(mPreferredCanvasBackend)); michael@0: aObj.DefineProperty("AzureSkiaAccelerated", UseAcceleratedSkiaCanvas()); michael@0: aObj.DefineProperty("AzureFallbackCanvasBackend", GetBackendName(mFallbackCanvasBackend)); michael@0: aObj.DefineProperty("AzureContentBackend", GetBackendName(mContentBackend)); michael@0: } michael@0: michael@0: mozilla::gfx::BackendType GetContentBackend() { michael@0: return mContentBackend; michael@0: } michael@0: michael@0: mozilla::gfx::BackendType GetPreferredCanvasBackend() { michael@0: return mPreferredCanvasBackend; michael@0: } michael@0: michael@0: /* michael@0: * Font bits michael@0: */ michael@0: michael@0: virtual void SetupClusterBoundaries(gfxTextRun *aTextRun, const char16_t *aString); michael@0: michael@0: /** michael@0: * Fill aListOfFonts with the results of querying the list of font names michael@0: * that correspond to the given language group or generic font family michael@0: * (or both, or neither). michael@0: */ michael@0: virtual nsresult GetFontList(nsIAtom *aLangGroup, michael@0: const nsACString& aGenericFamily, michael@0: nsTArray& aListOfFonts); michael@0: michael@0: /** michael@0: * Rebuilds the any cached system font lists michael@0: */ michael@0: virtual nsresult UpdateFontList(); michael@0: michael@0: /** michael@0: * Create the platform font-list object (gfxPlatformFontList concrete subclass). michael@0: * This function is responsible to create the appropriate subclass of michael@0: * gfxPlatformFontList *and* to call its InitFontList() method. michael@0: */ michael@0: virtual gfxPlatformFontList *CreatePlatformFontList() { michael@0: NS_NOTREACHED("oops, this platform doesn't have a gfxPlatformFontList implementation"); michael@0: return nullptr; michael@0: } michael@0: michael@0: /** michael@0: * Font name resolver, this returns actual font name(s) by the callback michael@0: * function. If the font doesn't exist, the callback function is not called. michael@0: * If the callback function returns false, the aAborted value is set to michael@0: * true, otherwise, false. michael@0: */ michael@0: typedef bool (*FontResolverCallback) (const nsAString& aName, michael@0: void *aClosure); michael@0: virtual nsresult ResolveFontName(const nsAString& aFontName, michael@0: FontResolverCallback aCallback, michael@0: void *aClosure, michael@0: bool& aAborted) = 0; michael@0: michael@0: /** michael@0: * Resolving a font name to family name. The result MUST be in the result of GetFontList(). michael@0: * If the name doesn't in the system, aFamilyName will be empty string, but not failed. michael@0: */ michael@0: virtual nsresult GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName) = 0; michael@0: michael@0: /** michael@0: * Create the appropriate platform font group michael@0: */ michael@0: virtual gfxFontGroup *CreateFontGroup(const nsAString& aFamilies, michael@0: const gfxFontStyle *aStyle, michael@0: gfxUserFontSet *aUserFontSet) = 0; michael@0: michael@0: michael@0: /** michael@0: * Look up a local platform font using the full font face name. michael@0: * (Needed to support @font-face src local().) michael@0: * Ownership of the returned gfxFontEntry is passed to the caller, michael@0: * who must either AddRef() or delete. michael@0: */ michael@0: virtual gfxFontEntry* LookupLocalFont(const gfxProxyFontEntry *aProxyEntry, michael@0: const nsAString& aFontName) michael@0: { return nullptr; } michael@0: michael@0: /** michael@0: * Activate a platform font. (Needed to support @font-face src url().) michael@0: * aFontData is a NS_Malloc'ed block that must be freed by this function michael@0: * (or responsibility passed on) when it is no longer needed; the caller michael@0: * will NOT free it. michael@0: * Ownership of the returned gfxFontEntry is passed to the caller, michael@0: * who must either AddRef() or delete. michael@0: */ michael@0: virtual gfxFontEntry* MakePlatformFont(const gfxProxyFontEntry *aProxyEntry, michael@0: const uint8_t *aFontData, michael@0: uint32_t aLength); michael@0: michael@0: /** michael@0: * Whether to allow downloadable fonts via @font-face rules michael@0: */ michael@0: bool DownloadableFontsEnabled(); michael@0: michael@0: /** michael@0: * True when hinting should be enabled. This setting shouldn't michael@0: * change per gecko process, while the process is live. If so the michael@0: * results are not defined. michael@0: * michael@0: * NB: this bit is only honored by the FT2 backend, currently. michael@0: */ michael@0: virtual bool FontHintingEnabled() { return true; } michael@0: michael@0: /** michael@0: * True when zooming should not require reflow, so glyph metrics and michael@0: * positioning should not be adjusted for device pixels. michael@0: * If this is TRUE, then FontHintingEnabled() should be FALSE, michael@0: * but the converse is not necessarily required; in particular, michael@0: * B2G always has FontHintingEnabled FALSE, but RequiresLinearZoom michael@0: * is only true for the browser process, not Gaia or other apps. michael@0: * michael@0: * Like FontHintingEnabled (above), this setting shouldn't michael@0: * change per gecko process, while the process is live. If so the michael@0: * results are not defined. michael@0: * michael@0: * NB: this bit is only honored by the FT2 backend, currently. michael@0: */ michael@0: virtual bool RequiresLinearZoom() { return false; } michael@0: michael@0: /** michael@0: * Whether to check all font cmaps during system font fallback michael@0: */ michael@0: bool UseCmapsDuringSystemFallback(); michael@0: michael@0: /** michael@0: * Whether to render SVG glyphs within an OpenType font wrapper michael@0: */ michael@0: bool OpenTypeSVGEnabled(); michael@0: michael@0: /** michael@0: * Max character length of words in the word cache michael@0: */ michael@0: uint32_t WordCacheCharLimit(); michael@0: michael@0: /** michael@0: * Max number of entries in word cache michael@0: */ michael@0: uint32_t WordCacheMaxEntries(); michael@0: michael@0: /** michael@0: * Whether to use the SIL Graphite rendering engine michael@0: * (for fonts that include Graphite tables) michael@0: */ michael@0: bool UseGraphiteShaping(); michael@0: michael@0: /** michael@0: * Whether to use the harfbuzz shaper (depending on script complexity). michael@0: * michael@0: * This allows harfbuzz to be enabled selectively via the preferences. michael@0: */ michael@0: bool UseHarfBuzzForScript(int32_t aScriptCode); michael@0: michael@0: // check whether format is supported on a platform or not (if unclear, returns true) michael@0: virtual bool IsFontFormatSupported(nsIURI *aFontURI, uint32_t aFormatFlags) { return false; } michael@0: michael@0: void GetPrefFonts(nsIAtom *aLanguage, nsString& array, bool aAppendUnicode = true); michael@0: michael@0: // in some situations, need to make decisions about ambiguous characters, may need to look at multiple pref langs michael@0: void GetLangPrefs(eFontPrefLang aPrefLangs[], uint32_t &aLen, eFontPrefLang aCharLang, eFontPrefLang aPageLang); michael@0: michael@0: /** michael@0: * Iterate over pref fonts given a list of lang groups. For a single lang michael@0: * group, multiple pref fonts are possible. If error occurs, returns false, michael@0: * true otherwise. Callback returns false to abort process. michael@0: */ michael@0: typedef bool (*PrefFontCallback) (eFontPrefLang aLang, const nsAString& aName, michael@0: void *aClosure); michael@0: static bool ForEachPrefFont(eFontPrefLang aLangArray[], uint32_t aLangArrayLen, michael@0: PrefFontCallback aCallback, michael@0: void *aClosure); michael@0: michael@0: // convert a lang group to enum constant (i.e. "zh-TW" ==> eFontPrefLang_ChineseTW) michael@0: static eFontPrefLang GetFontPrefLangFor(const char* aLang); michael@0: michael@0: // convert a lang group atom to enum constant michael@0: static eFontPrefLang GetFontPrefLangFor(nsIAtom *aLang); michael@0: michael@0: // convert a enum constant to lang group string (i.e. eFontPrefLang_ChineseTW ==> "zh-TW") michael@0: static const char* GetPrefLangName(eFontPrefLang aLang); michael@0: michael@0: // map a Unicode range (based on char code) to a font language for Preferences michael@0: static eFontPrefLang GetFontPrefLangFor(uint8_t aUnicodeRange); michael@0: michael@0: // returns true if a pref lang is CJK michael@0: static bool IsLangCJK(eFontPrefLang aLang); michael@0: michael@0: // helper method to add a pref lang to an array, if not already in array michael@0: static void AppendPrefLang(eFontPrefLang aPrefLangs[], uint32_t& aLen, eFontPrefLang aAddLang); michael@0: michael@0: // returns a list of commonly used fonts for a given character michael@0: // these are *possible* matches, no cmap-checking is done at this level michael@0: virtual void GetCommonFallbackFonts(const uint32_t /*aCh*/, michael@0: int32_t /*aRunScript*/, michael@0: nsTArray& /*aFontList*/) michael@0: { michael@0: // platform-specific override, by default do nothing michael@0: } michael@0: michael@0: static bool OffMainThreadCompositingEnabled(); michael@0: michael@0: /** Use gfxPlatform::GetPref* methods instead of direct calls to Preferences michael@0: * to get the values for layers preferences. These will only be evaluated michael@0: * only once, and remain the same until restart. michael@0: */ michael@0: static bool GetPrefLayersOffMainThreadCompositionEnabled(); michael@0: static bool CanUseDirect3D9(); michael@0: michael@0: static bool OffMainThreadCompositionRequired(); michael@0: michael@0: /** michael@0: * Is it possible to use buffer rotation. Note that these michael@0: * check the preference, but also allow for the override to michael@0: * disable it using DisableBufferRotation. michael@0: */ michael@0: static bool BufferRotationEnabled(); michael@0: static void DisableBufferRotation(); michael@0: michael@0: /** michael@0: * Are we going to try color management? michael@0: */ michael@0: static eCMSMode GetCMSMode(); michael@0: michael@0: /** michael@0: * Determines the rendering intent for color management. michael@0: * michael@0: * If the value in the pref gfx.color_management.rendering_intent is a michael@0: * valid rendering intent as defined in gfx/qcms/qcms.h, that michael@0: * value is returned. Otherwise, -1 is returned and the embedded intent michael@0: * should be used. michael@0: * michael@0: * See bug 444014 for details. michael@0: */ michael@0: static int GetRenderingIntent(); michael@0: michael@0: /** michael@0: * Convert a pixel using a cms transform in an endian-aware manner. michael@0: * michael@0: * Sets 'out' to 'in' if transform is nullptr. michael@0: */ michael@0: static void TransformPixel(const gfxRGBA& in, gfxRGBA& out, qcms_transform *transform); michael@0: michael@0: /** michael@0: * Return the output device ICC profile. michael@0: */ michael@0: static qcms_profile* GetCMSOutputProfile(); michael@0: michael@0: /** michael@0: * Return the sRGB ICC profile. michael@0: */ michael@0: static qcms_profile* GetCMSsRGBProfile(); michael@0: michael@0: /** michael@0: * Return sRGB -> output device transform. michael@0: */ michael@0: static qcms_transform* GetCMSRGBTransform(); michael@0: michael@0: /** michael@0: * Return output -> sRGB device transform. michael@0: */ michael@0: static qcms_transform* GetCMSInverseRGBTransform(); michael@0: michael@0: /** michael@0: * Return sRGBA -> output device transform. michael@0: */ michael@0: static qcms_transform* GetCMSRGBATransform(); michael@0: michael@0: virtual void FontsPrefsChanged(const char *aPref); michael@0: michael@0: int32_t GetBidiNumeralOption(); michael@0: michael@0: /** michael@0: * Returns a 1x1 surface that can be used to create graphics contexts michael@0: * for measuring text etc as if they will be rendered to the screen michael@0: */ michael@0: gfxASurface* ScreenReferenceSurface() { return mScreenReferenceSurface; } michael@0: mozilla::gfx::DrawTarget* ScreenReferenceDrawTarget() { return mScreenReferenceDrawTarget; } michael@0: michael@0: virtual mozilla::gfx::SurfaceFormat Optimal2DFormatForContent(gfxContentType aContent); michael@0: michael@0: virtual gfxImageFormat OptimalFormatForContent(gfxContentType aContent); michael@0: michael@0: virtual gfxImageFormat GetOffscreenFormat() michael@0: { return gfxImageFormat::RGB24; } michael@0: michael@0: /** michael@0: * Returns a logger if one is available and logging is enabled michael@0: */ michael@0: static PRLogModuleInfo* GetLog(eGfxLog aWhichLog); michael@0: michael@0: virtual int GetScreenDepth() const; michael@0: michael@0: /** michael@0: * Return the layer debugging options to use browser-wide. michael@0: */ michael@0: mozilla::layers::DiagnosticTypes GetLayerDiagnosticTypes(); michael@0: michael@0: static nsIntRect FrameCounterBounds() { michael@0: int bits = 16; michael@0: int sizeOfBit = 3; michael@0: return nsIntRect(0, 0, bits * sizeOfBit, sizeOfBit); michael@0: } michael@0: michael@0: /** michael@0: * Returns true if we should use raw memory to send data to the compositor michael@0: * rather than using shmems. michael@0: * michael@0: * This method should not be called from the compositor thread. michael@0: */ michael@0: bool PreferMemoryOverShmem() const; michael@0: michael@0: mozilla::gl::SkiaGLGlue* GetSkiaGLGlue(); michael@0: void PurgeSkiaCache(); michael@0: michael@0: virtual bool IsInGonkEmulator() const { return false; } michael@0: michael@0: protected: michael@0: gfxPlatform(); michael@0: virtual ~gfxPlatform(); michael@0: michael@0: void AppendCJKPrefLangs(eFontPrefLang aPrefLangs[], uint32_t &aLen, michael@0: eFontPrefLang aCharLang, eFontPrefLang aPageLang); michael@0: michael@0: /** michael@0: * Helper method, creates a draw target for a specific Azure backend. michael@0: * Used by CreateOffscreenDrawTarget. michael@0: */ michael@0: mozilla::RefPtr michael@0: CreateDrawTargetForBackend(mozilla::gfx::BackendType aBackend, michael@0: const mozilla::gfx::IntSize& aSize, michael@0: mozilla::gfx::SurfaceFormat aFormat); michael@0: michael@0: /** michael@0: * Initialise the preferred and fallback canvas backends michael@0: * aBackendBitmask specifies the backends which are acceptable to the caller. michael@0: * The backend used is determined by aBackendBitmask and the order specified michael@0: * by the gfx.canvas.azure.backends pref. michael@0: */ michael@0: void InitBackendPrefs(uint32_t aCanvasBitmask, mozilla::gfx::BackendType aCanvasDefault, michael@0: uint32_t aContentBitmask, mozilla::gfx::BackendType aContentDefault); michael@0: michael@0: /** michael@0: * returns the first backend named in the pref gfx.canvas.azure.backends michael@0: * which is a component of aBackendBitmask, a bitmask of backend types michael@0: */ michael@0: static mozilla::gfx::BackendType GetCanvasBackendPref(uint32_t aBackendBitmask); michael@0: michael@0: /** michael@0: * returns the first backend named in the pref gfx.content.azure.backend michael@0: * which is a component of aBackendBitmask, a bitmask of backend types michael@0: */ michael@0: static mozilla::gfx::BackendType GetContentBackendPref(uint32_t &aBackendBitmask); michael@0: michael@0: /** michael@0: * Will return the first backend named in aBackendPrefName michael@0: * allowed by aBackendBitmask, a bitmask of backend types. michael@0: * It also modifies aBackendBitmask to only include backends that are michael@0: * allowed given the prefs. michael@0: */ michael@0: static mozilla::gfx::BackendType GetBackendPref(const char* aBackendPrefName, michael@0: uint32_t &aBackendBitmask); michael@0: /** michael@0: * Decode the backend enumberation from a string. michael@0: */ michael@0: static mozilla::gfx::BackendType BackendTypeForName(const nsCString& aName); michael@0: michael@0: static mozilla::TemporaryRef michael@0: GetScaledFontForFontWithCairoSkia(mozilla::gfx::DrawTarget* aTarget, gfxFont* aFont); michael@0: michael@0: int8_t mAllowDownloadableFonts; michael@0: int8_t mGraphiteShapingEnabled; michael@0: int8_t mOpenTypeSVGEnabled; michael@0: michael@0: int8_t mBidiNumeralOption; michael@0: michael@0: // whether to always search font cmaps globally michael@0: // when doing system font fallback michael@0: int8_t mFallbackUsesCmaps; michael@0: michael@0: // which scripts should be shaped with harfbuzz michael@0: int32_t mUseHarfBuzzScripts; michael@0: michael@0: // max character limit for words in word cache michael@0: int32_t mWordCacheCharLimit; michael@0: michael@0: // max number of entries in word cache michael@0: int32_t mWordCacheMaxEntries; michael@0: michael@0: private: michael@0: /** michael@0: * Start up Thebes. michael@0: */ michael@0: static void Init(); michael@0: michael@0: static void CreateCMSOutputProfile(); michael@0: michael@0: static void GetCMSOutputProfileData(void *&mem, size_t &size); michael@0: michael@0: friend void RecordingPrefChanged(const char *aPrefName, void *aClosure); michael@0: michael@0: virtual void GetPlatformCMSOutputProfile(void *&mem, size_t &size); michael@0: michael@0: virtual bool SupportsOffMainThreadCompositing() { return true; } michael@0: michael@0: nsRefPtr mScreenReferenceSurface; michael@0: mozilla::RefPtr mScreenReferenceDrawTarget; michael@0: nsTArray mCJKPrefLangs; michael@0: nsCOMPtr mSRGBOverrideObserver; michael@0: nsCOMPtr mFontPrefsObserver; michael@0: nsCOMPtr mMemoryPressureObserver; michael@0: michael@0: // The preferred draw target backend to use for canvas michael@0: mozilla::gfx::BackendType mPreferredCanvasBackend; michael@0: // The fallback draw target backend to use for canvas, if the preferred backend fails michael@0: mozilla::gfx::BackendType mFallbackCanvasBackend; michael@0: // The backend to use for content michael@0: mozilla::gfx::BackendType mContentBackend; michael@0: // Bitmask of backend types we can use to render content michael@0: uint32_t mContentBackendBitmask; michael@0: michael@0: mozilla::widget::GfxInfoCollector mAzureCanvasBackendCollector; michael@0: michael@0: mozilla::RefPtr mRecorder; michael@0: bool mLayersPreferMemoryOverShmem; michael@0: mozilla::RefPtr mSkiaGlue; michael@0: }; michael@0: michael@0: #endif /* GFX_PLATFORM_H */