gfx/thebes/gfxPlatform.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     2  * This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef GFX_PLATFORM_H
     7 #define GFX_PLATFORM_H
     9 #include "prlog.h"
    10 #include "nsTArray.h"
    11 #include "nsString.h"
    12 #include "nsCOMPtr.h"
    13 #include "nsAutoPtr.h"
    15 #include "gfxTypes.h"
    16 #include "nsRect.h"
    18 #include "qcms.h"
    20 #include "mozilla/RefPtr.h"
    21 #include "GfxInfoCollector.h"
    23 #include "mozilla/layers/CompositorTypes.h"
    25 class gfxASurface;
    26 class gfxImageSurface;
    27 class gfxFont;
    28 class gfxFontGroup;
    29 struct gfxFontStyle;
    30 class gfxUserFontSet;
    31 class gfxFontEntry;
    32 class gfxProxyFontEntry;
    33 class gfxPlatformFontList;
    34 class gfxTextRun;
    35 class nsIURI;
    36 class nsIAtom;
    37 class nsIObserver;
    38 struct gfxRGBA;
    40 namespace mozilla {
    41 namespace gl {
    42 class GLContext;
    43 class SkiaGLGlue;
    44 }
    45 namespace gfx {
    46 class DrawTarget;
    47 class SourceSurface;
    48 class DataSourceSurface;
    49 class ScaledFont;
    50 class DrawEventRecorder;
    52 inline uint32_t
    53 BackendTypeBit(BackendType b)
    54 {
    55   return 1 << uint8_t(b);
    56 }
    57 }
    58 }
    60 extern cairo_user_data_key_t kDrawTarget;
    62 // pref lang id's for font prefs
    63 // !!! needs to match the list of pref font.default.xx entries listed in all.js !!!
    64 // !!! don't use as bit mask, this may grow larger !!!
    66 enum eFontPrefLang {
    67     eFontPrefLang_Western     =  0,
    68     eFontPrefLang_CentEuro    =  1,
    69     eFontPrefLang_Japanese    =  2,
    70     eFontPrefLang_ChineseTW   =  3,
    71     eFontPrefLang_ChineseCN   =  4,
    72     eFontPrefLang_ChineseHK   =  5,
    73     eFontPrefLang_Korean      =  6,
    74     eFontPrefLang_Cyrillic    =  7,
    75     eFontPrefLang_Baltic      =  8,
    76     eFontPrefLang_Greek       =  9,
    77     eFontPrefLang_Turkish     = 10,
    78     eFontPrefLang_Thai        = 11,
    79     eFontPrefLang_Hebrew      = 12,
    80     eFontPrefLang_Arabic      = 13,
    81     eFontPrefLang_Devanagari  = 14,
    82     eFontPrefLang_Tamil       = 15,
    83     eFontPrefLang_Armenian    = 16,
    84     eFontPrefLang_Bengali     = 17,
    85     eFontPrefLang_Canadian    = 18,
    86     eFontPrefLang_Ethiopic    = 19,
    87     eFontPrefLang_Georgian    = 20,
    88     eFontPrefLang_Gujarati    = 21,
    89     eFontPrefLang_Gurmukhi    = 22,
    90     eFontPrefLang_Khmer       = 23,
    91     eFontPrefLang_Malayalam   = 24,
    92     eFontPrefLang_Oriya       = 25,
    93     eFontPrefLang_Telugu      = 26,
    94     eFontPrefLang_Kannada     = 27,
    95     eFontPrefLang_Sinhala     = 28,
    96     eFontPrefLang_Tibetan     = 29,
    98     eFontPrefLang_Others      = 30, // x-unicode
   100     eFontPrefLang_CJKSet      = 31  // special code for CJK set
   101 };
   103 enum eCMSMode {
   104     eCMSMode_Off          = 0,     // No color management
   105     eCMSMode_All          = 1,     // Color manage everything
   106     eCMSMode_TaggedOnly   = 2,     // Color manage tagged Images Only
   107     eCMSMode_AllCount     = 3
   108 };
   110 enum eGfxLog {
   111     // all font enumerations, localized names, fullname/psnames, cmap loads
   112     eGfxLog_fontlist         = 0,
   113     // timing info on font initialization
   114     eGfxLog_fontinit         = 1,
   115     // dump text runs, font matching, system fallback for content
   116     eGfxLog_textrun          = 2,
   117     // dump text runs, font matching, system fallback for chrome
   118     eGfxLog_textrunui        = 3,
   119     // dump cmap coverage data as they are loaded
   120     eGfxLog_cmapdata         = 4,
   121     // text perf data
   122     eGfxLog_textperf         = 5
   123 };
   125 // when searching through pref langs, max number of pref langs
   126 const uint32_t kMaxLenPrefLangList = 32;
   128 #define UNINITIALIZED_VALUE  (-1)
   130 inline const char*
   131 GetBackendName(mozilla::gfx::BackendType aBackend)
   132 {
   133   switch (aBackend) {
   134       case mozilla::gfx::BackendType::DIRECT2D:
   135         return "direct2d";
   136       case mozilla::gfx::BackendType::COREGRAPHICS_ACCELERATED:
   137         return "quartz accelerated";
   138       case mozilla::gfx::BackendType::COREGRAPHICS:
   139         return "quartz";
   140       case mozilla::gfx::BackendType::CAIRO:
   141         return "cairo";
   142       case mozilla::gfx::BackendType::SKIA:
   143         return "skia";
   144       case mozilla::gfx::BackendType::RECORDING:
   145         return "recording";
   146       case mozilla::gfx::BackendType::DIRECT2D1_1:
   147         return "direct2d 1.1";
   148       case mozilla::gfx::BackendType::NONE:
   149         return "none";
   150   }
   151   MOZ_CRASH("Incomplete switch");
   152 }
   154 class gfxPlatform {
   155 public:
   156     typedef mozilla::gfx::IntSize IntSize;
   158     /**
   159      * Return a pointer to the current active platform.
   160      * This is a singleton; it contains mostly convenience
   161      * functions to obtain platform-specific objects.
   162      */
   163     static gfxPlatform *GetPlatform();
   166     /**
   167      * Shut down Thebes.
   168      * Init() arranges for this to be called at an appropriate time.
   169      */
   170     static void Shutdown();
   172     /**
   173      * Create an offscreen surface of the given dimensions
   174      * and image format.
   175      */
   176     virtual already_AddRefed<gfxASurface>
   177       CreateOffscreenSurface(const IntSize& size,
   178                              gfxContentType contentType) = 0;
   180     /**
   181      * Create an offscreen surface of the given dimensions and image format which
   182      * can be converted to a gfxImageSurface without copying. If we can provide
   183      * a platform-hosted surface, then we will return that instead of an actual
   184      * gfxImageSurface.
   185      * Sub-classes should override this method if CreateOffscreenSurface returns a
   186      * surface which implements GetAsImageSurface
   187      */
   188     virtual already_AddRefed<gfxASurface>
   189       CreateOffscreenImageSurface(const gfxIntSize& aSize,
   190                                   gfxContentType aContentType);
   192     virtual already_AddRefed<gfxASurface> OptimizeImage(gfxImageSurface *aSurface,
   193                                                         gfxImageFormat format);
   195     /**
   196      * Beware that these methods may return DrawTargets which are not fully supported
   197      * on the current platform and might fail silently in subtle ways. This is a massive
   198      * potential footgun. You should only use these methods for canvas drawing really.
   199      * Use extreme caution if you use them for content where you are not 100% sure we
   200      * support the DrawTarget we get back.
   201      * See SupportsAzureContentForDrawTarget.
   202      */
   203     virtual mozilla::RefPtr<mozilla::gfx::DrawTarget>
   204       CreateDrawTargetForSurface(gfxASurface *aSurface, const mozilla::gfx::IntSize& aSize);
   206     virtual mozilla::RefPtr<mozilla::gfx::DrawTarget>
   207       CreateDrawTargetForUpdateSurface(gfxASurface *aSurface, const mozilla::gfx::IntSize& aSize);
   209     /*
   210      * Creates a SourceSurface for a gfxASurface. This function does no caching,
   211      * so the caller should cache the gfxASurface if it will be used frequently.
   212      * The returned surface keeps a reference to aTarget, so it is OK to keep the
   213      * surface, even if aTarget changes.
   214      * aTarget should not keep a reference to the returned surface because that
   215      * will cause a cycle.
   216      */
   217     virtual mozilla::RefPtr<mozilla::gfx::SourceSurface>
   218       GetSourceSurfaceForSurface(mozilla::gfx::DrawTarget *aTarget, gfxASurface *aSurface);
   220     static void ClearSourceSurfaceForSurface(gfxASurface *aSurface);
   222     static mozilla::RefPtr<mozilla::gfx::DataSourceSurface>
   223         GetWrappedDataSourceSurface(gfxASurface *aSurface);
   225     virtual mozilla::TemporaryRef<mozilla::gfx::ScaledFont>
   226       GetScaledFontForFont(mozilla::gfx::DrawTarget* aTarget, gfxFont *aFont);
   228     virtual already_AddRefed<gfxASurface>
   229       GetThebesSurfaceForDrawTarget(mozilla::gfx::DrawTarget *aTarget);
   231     mozilla::RefPtr<mozilla::gfx::DrawTarget>
   232       CreateOffscreenContentDrawTarget(const mozilla::gfx::IntSize& aSize, mozilla::gfx::SurfaceFormat aFormat);
   234     mozilla::RefPtr<mozilla::gfx::DrawTarget>
   235       CreateOffscreenCanvasDrawTarget(const mozilla::gfx::IntSize& aSize, mozilla::gfx::SurfaceFormat aFormat);
   237     virtual mozilla::RefPtr<mozilla::gfx::DrawTarget>
   238       CreateDrawTargetForData(unsigned char* aData, const mozilla::gfx::IntSize& aSize, 
   239                               int32_t aStride, mozilla::gfx::SurfaceFormat aFormat);
   241     /**
   242      * Returns true if we should use Azure to render content with aTarget. For
   243      * example, it is possible that we are using Direct2D for rendering and thus
   244      * using Azure. But we want to render to a CairoDrawTarget, in which case
   245      * SupportsAzureContent will return true but SupportsAzureContentForDrawTarget
   246      * will return false.
   247      */
   248     bool SupportsAzureContentForDrawTarget(mozilla::gfx::DrawTarget* aTarget);
   250     bool SupportsAzureContentForType(mozilla::gfx::BackendType aType) {
   251       return BackendTypeBit(aType) & mContentBackendBitmask;
   252     }
   254     virtual bool UseAcceleratedSkiaCanvas();
   255     virtual void InitializeSkiaCacheLimits();
   257     void GetAzureBackendInfo(mozilla::widget::InfoObject &aObj) {
   258       aObj.DefineProperty("AzureCanvasBackend", GetBackendName(mPreferredCanvasBackend));
   259       aObj.DefineProperty("AzureSkiaAccelerated", UseAcceleratedSkiaCanvas());
   260       aObj.DefineProperty("AzureFallbackCanvasBackend", GetBackendName(mFallbackCanvasBackend));
   261       aObj.DefineProperty("AzureContentBackend", GetBackendName(mContentBackend));
   262     }
   264     mozilla::gfx::BackendType GetContentBackend() {
   265       return mContentBackend;
   266     }
   268     mozilla::gfx::BackendType GetPreferredCanvasBackend() {
   269       return mPreferredCanvasBackend;
   270     }
   272     /*
   273      * Font bits
   274      */
   276     virtual void SetupClusterBoundaries(gfxTextRun *aTextRun, const char16_t *aString);
   278     /**
   279      * Fill aListOfFonts with the results of querying the list of font names
   280      * that correspond to the given language group or generic font family
   281      * (or both, or neither).
   282      */
   283     virtual nsresult GetFontList(nsIAtom *aLangGroup,
   284                                  const nsACString& aGenericFamily,
   285                                  nsTArray<nsString>& aListOfFonts);
   287     /**
   288      * Rebuilds the any cached system font lists
   289      */
   290     virtual nsresult UpdateFontList();
   292     /**
   293      * Create the platform font-list object (gfxPlatformFontList concrete subclass).
   294      * This function is responsible to create the appropriate subclass of
   295      * gfxPlatformFontList *and* to call its InitFontList() method.
   296      */
   297     virtual gfxPlatformFontList *CreatePlatformFontList() {
   298         NS_NOTREACHED("oops, this platform doesn't have a gfxPlatformFontList implementation");
   299         return nullptr;
   300     }
   302     /**
   303      * Font name resolver, this returns actual font name(s) by the callback
   304      * function. If the font doesn't exist, the callback function is not called.
   305      * If the callback function returns false, the aAborted value is set to
   306      * true, otherwise, false.
   307      */
   308     typedef bool (*FontResolverCallback) (const nsAString& aName,
   309                                             void *aClosure);
   310     virtual nsresult ResolveFontName(const nsAString& aFontName,
   311                                      FontResolverCallback aCallback,
   312                                      void *aClosure,
   313                                      bool& aAborted) = 0;
   315     /**
   316      * Resolving a font name to family name. The result MUST be in the result of GetFontList().
   317      * If the name doesn't in the system, aFamilyName will be empty string, but not failed.
   318      */
   319     virtual nsresult GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName) = 0;
   321     /**
   322      * Create the appropriate platform font group
   323      */
   324     virtual gfxFontGroup *CreateFontGroup(const nsAString& aFamilies,
   325                                           const gfxFontStyle *aStyle,
   326                                           gfxUserFontSet *aUserFontSet) = 0;
   329     /**
   330      * Look up a local platform font using the full font face name.
   331      * (Needed to support @font-face src local().)
   332      * Ownership of the returned gfxFontEntry is passed to the caller,
   333      * who must either AddRef() or delete.
   334      */
   335     virtual gfxFontEntry* LookupLocalFont(const gfxProxyFontEntry *aProxyEntry,
   336                                           const nsAString& aFontName)
   337     { return nullptr; }
   339     /**
   340      * Activate a platform font.  (Needed to support @font-face src url().)
   341      * aFontData is a NS_Malloc'ed block that must be freed by this function
   342      * (or responsibility passed on) when it is no longer needed; the caller
   343      * will NOT free it.
   344      * Ownership of the returned gfxFontEntry is passed to the caller,
   345      * who must either AddRef() or delete.
   346      */
   347     virtual gfxFontEntry* MakePlatformFont(const gfxProxyFontEntry *aProxyEntry,
   348                                            const uint8_t *aFontData,
   349                                            uint32_t aLength);
   351     /**
   352      * Whether to allow downloadable fonts via @font-face rules
   353      */
   354     bool DownloadableFontsEnabled();
   356     /**
   357      * True when hinting should be enabled.  This setting shouldn't
   358      * change per gecko process, while the process is live.  If so the
   359      * results are not defined.
   360      *
   361      * NB: this bit is only honored by the FT2 backend, currently.
   362      */
   363     virtual bool FontHintingEnabled() { return true; }
   365     /**
   366      * True when zooming should not require reflow, so glyph metrics and
   367      * positioning should not be adjusted for device pixels.
   368      * If this is TRUE, then FontHintingEnabled() should be FALSE,
   369      * but the converse is not necessarily required; in particular,
   370      * B2G always has FontHintingEnabled FALSE, but RequiresLinearZoom
   371      * is only true for the browser process, not Gaia or other apps.
   372      *
   373      * Like FontHintingEnabled (above), this setting shouldn't
   374      * change per gecko process, while the process is live.  If so the
   375      * results are not defined.
   376      *
   377      * NB: this bit is only honored by the FT2 backend, currently.
   378      */
   379     virtual bool RequiresLinearZoom() { return false; }
   381     /**
   382      * Whether to check all font cmaps during system font fallback
   383      */
   384     bool UseCmapsDuringSystemFallback();
   386     /**
   387      * Whether to render SVG glyphs within an OpenType font wrapper
   388      */
   389     bool OpenTypeSVGEnabled();
   391     /**
   392      * Max character length of words in the word cache
   393      */
   394     uint32_t WordCacheCharLimit();
   396     /**
   397      * Max number of entries in word cache
   398      */
   399     uint32_t WordCacheMaxEntries();
   401     /**
   402      * Whether to use the SIL Graphite rendering engine
   403      * (for fonts that include Graphite tables)
   404      */
   405     bool UseGraphiteShaping();
   407     /**
   408      * Whether to use the harfbuzz shaper (depending on script complexity).
   409      *
   410      * This allows harfbuzz to be enabled selectively via the preferences.
   411      */
   412     bool UseHarfBuzzForScript(int32_t aScriptCode);
   414     // check whether format is supported on a platform or not (if unclear, returns true)
   415     virtual bool IsFontFormatSupported(nsIURI *aFontURI, uint32_t aFormatFlags) { return false; }
   417     void GetPrefFonts(nsIAtom *aLanguage, nsString& array, bool aAppendUnicode = true);
   419     // in some situations, need to make decisions about ambiguous characters, may need to look at multiple pref langs
   420     void GetLangPrefs(eFontPrefLang aPrefLangs[], uint32_t &aLen, eFontPrefLang aCharLang, eFontPrefLang aPageLang);
   422     /**
   423      * Iterate over pref fonts given a list of lang groups.  For a single lang
   424      * group, multiple pref fonts are possible.  If error occurs, returns false,
   425      * true otherwise.  Callback returns false to abort process.
   426      */
   427     typedef bool (*PrefFontCallback) (eFontPrefLang aLang, const nsAString& aName,
   428                                         void *aClosure);
   429     static bool ForEachPrefFont(eFontPrefLang aLangArray[], uint32_t aLangArrayLen,
   430                                   PrefFontCallback aCallback,
   431                                   void *aClosure);
   433     // convert a lang group to enum constant (i.e. "zh-TW" ==> eFontPrefLang_ChineseTW)
   434     static eFontPrefLang GetFontPrefLangFor(const char* aLang);
   436     // convert a lang group atom to enum constant
   437     static eFontPrefLang GetFontPrefLangFor(nsIAtom *aLang);
   439     // convert a enum constant to lang group string (i.e. eFontPrefLang_ChineseTW ==> "zh-TW")
   440     static const char* GetPrefLangName(eFontPrefLang aLang);
   442     // map a Unicode range (based on char code) to a font language for Preferences
   443     static eFontPrefLang GetFontPrefLangFor(uint8_t aUnicodeRange);
   445     // returns true if a pref lang is CJK
   446     static bool IsLangCJK(eFontPrefLang aLang);
   448     // helper method to add a pref lang to an array, if not already in array
   449     static void AppendPrefLang(eFontPrefLang aPrefLangs[], uint32_t& aLen, eFontPrefLang aAddLang);
   451     // returns a list of commonly used fonts for a given character
   452     // these are *possible* matches, no cmap-checking is done at this level
   453     virtual void GetCommonFallbackFonts(const uint32_t /*aCh*/,
   454                                         int32_t /*aRunScript*/,
   455                                         nsTArray<const char*>& /*aFontList*/)
   456     {
   457         // platform-specific override, by default do nothing
   458     }
   460     static bool OffMainThreadCompositingEnabled();
   462     /** Use gfxPlatform::GetPref* methods instead of direct calls to Preferences
   463      * to get the values for layers preferences.  These will only be evaluated
   464      * only once, and remain the same until restart.
   465      */
   466     static bool GetPrefLayersOffMainThreadCompositionEnabled();
   467     static bool CanUseDirect3D9();
   469     static bool OffMainThreadCompositionRequired();
   471     /**
   472      * Is it possible to use buffer rotation.  Note that these
   473      * check the preference, but also allow for the override to
   474      * disable it using DisableBufferRotation.
   475      */
   476     static bool BufferRotationEnabled();
   477     static void DisableBufferRotation();
   479     /**
   480      * Are we going to try color management?
   481      */
   482     static eCMSMode GetCMSMode();
   484     /**
   485      * Determines the rendering intent for color management.
   486      *
   487      * If the value in the pref gfx.color_management.rendering_intent is a
   488      * valid rendering intent as defined in gfx/qcms/qcms.h, that
   489      * value is returned. Otherwise, -1 is returned and the embedded intent
   490      * should be used.
   491      *
   492      * See bug 444014 for details.
   493      */
   494     static int GetRenderingIntent();
   496     /**
   497      * Convert a pixel using a cms transform in an endian-aware manner.
   498      *
   499      * Sets 'out' to 'in' if transform is nullptr.
   500      */
   501     static void TransformPixel(const gfxRGBA& in, gfxRGBA& out, qcms_transform *transform);
   503     /**
   504      * Return the output device ICC profile.
   505      */
   506     static qcms_profile* GetCMSOutputProfile();
   508     /**
   509      * Return the sRGB ICC profile.
   510      */
   511     static qcms_profile* GetCMSsRGBProfile();
   513     /**
   514      * Return sRGB -> output device transform.
   515      */
   516     static qcms_transform* GetCMSRGBTransform();
   518     /**
   519      * Return output -> sRGB device transform.
   520      */
   521     static qcms_transform* GetCMSInverseRGBTransform();
   523     /**
   524      * Return sRGBA -> output device transform.
   525      */
   526     static qcms_transform* GetCMSRGBATransform();
   528     virtual void FontsPrefsChanged(const char *aPref);
   530     int32_t GetBidiNumeralOption();
   532     /**
   533      * Returns a 1x1 surface that can be used to create graphics contexts
   534      * for measuring text etc as if they will be rendered to the screen
   535      */
   536     gfxASurface* ScreenReferenceSurface() { return mScreenReferenceSurface; }
   537     mozilla::gfx::DrawTarget* ScreenReferenceDrawTarget() { return mScreenReferenceDrawTarget; }
   539     virtual mozilla::gfx::SurfaceFormat Optimal2DFormatForContent(gfxContentType aContent);
   541     virtual gfxImageFormat OptimalFormatForContent(gfxContentType aContent);
   543     virtual gfxImageFormat GetOffscreenFormat()
   544     { return gfxImageFormat::RGB24; }
   546     /**
   547      * Returns a logger if one is available and logging is enabled
   548      */
   549     static PRLogModuleInfo* GetLog(eGfxLog aWhichLog);
   551     virtual int GetScreenDepth() const;
   553     /**
   554      * Return the layer debugging options to use browser-wide.
   555      */
   556     mozilla::layers::DiagnosticTypes GetLayerDiagnosticTypes();
   558     static nsIntRect FrameCounterBounds() {
   559       int bits = 16;
   560       int sizeOfBit = 3;
   561       return nsIntRect(0, 0, bits * sizeOfBit, sizeOfBit);
   562     }
   564     /**
   565      * Returns true if we should use raw memory to send data to the compositor
   566      * rather than using shmems.
   567      *
   568      * This method should not be called from the compositor thread.
   569      */
   570     bool PreferMemoryOverShmem() const;
   572     mozilla::gl::SkiaGLGlue* GetSkiaGLGlue();
   573     void PurgeSkiaCache();
   575     virtual bool IsInGonkEmulator() const { return false; }
   577 protected:
   578     gfxPlatform();
   579     virtual ~gfxPlatform();
   581     void AppendCJKPrefLangs(eFontPrefLang aPrefLangs[], uint32_t &aLen, 
   582                             eFontPrefLang aCharLang, eFontPrefLang aPageLang);
   584     /**
   585      * Helper method, creates a draw target for a specific Azure backend.
   586      * Used by CreateOffscreenDrawTarget.
   587      */
   588     mozilla::RefPtr<mozilla::gfx::DrawTarget>
   589       CreateDrawTargetForBackend(mozilla::gfx::BackendType aBackend,
   590                                  const mozilla::gfx::IntSize& aSize,
   591                                  mozilla::gfx::SurfaceFormat aFormat);
   593     /**
   594      * Initialise the preferred and fallback canvas backends
   595      * aBackendBitmask specifies the backends which are acceptable to the caller.
   596      * The backend used is determined by aBackendBitmask and the order specified
   597      * by the gfx.canvas.azure.backends pref.
   598      */
   599     void InitBackendPrefs(uint32_t aCanvasBitmask, mozilla::gfx::BackendType aCanvasDefault,
   600                           uint32_t aContentBitmask, mozilla::gfx::BackendType aContentDefault);
   602     /**
   603      * returns the first backend named in the pref gfx.canvas.azure.backends
   604      * which is a component of aBackendBitmask, a bitmask of backend types
   605      */
   606     static mozilla::gfx::BackendType GetCanvasBackendPref(uint32_t aBackendBitmask);
   608     /**
   609      * returns the first backend named in the pref gfx.content.azure.backend
   610      * which is a component of aBackendBitmask, a bitmask of backend types
   611      */
   612     static mozilla::gfx::BackendType GetContentBackendPref(uint32_t &aBackendBitmask);
   614     /**
   615      * Will return the first backend named in aBackendPrefName
   616      * allowed by aBackendBitmask, a bitmask of backend types.
   617      * It also modifies aBackendBitmask to only include backends that are
   618      * allowed given the prefs.
   619      */
   620     static mozilla::gfx::BackendType GetBackendPref(const char* aBackendPrefName,
   621                                                     uint32_t &aBackendBitmask);
   622     /**
   623      * Decode the backend enumberation from a string.
   624      */
   625     static mozilla::gfx::BackendType BackendTypeForName(const nsCString& aName);
   627     static mozilla::TemporaryRef<mozilla::gfx::ScaledFont>
   628       GetScaledFontForFontWithCairoSkia(mozilla::gfx::DrawTarget* aTarget, gfxFont* aFont);
   630     int8_t  mAllowDownloadableFonts;
   631     int8_t  mGraphiteShapingEnabled;
   632     int8_t  mOpenTypeSVGEnabled;
   634     int8_t  mBidiNumeralOption;
   636     // whether to always search font cmaps globally 
   637     // when doing system font fallback
   638     int8_t  mFallbackUsesCmaps;
   640     // which scripts should be shaped with harfbuzz
   641     int32_t mUseHarfBuzzScripts;
   643     // max character limit for words in word cache
   644     int32_t mWordCacheCharLimit;
   646     // max number of entries in word cache
   647     int32_t mWordCacheMaxEntries;
   649 private:
   650     /**
   651      * Start up Thebes.
   652      */
   653     static void Init();
   655     static void CreateCMSOutputProfile();
   657     static void GetCMSOutputProfileData(void *&mem, size_t &size);
   659     friend void RecordingPrefChanged(const char *aPrefName, void *aClosure);
   661     virtual void GetPlatformCMSOutputProfile(void *&mem, size_t &size);
   663     virtual bool SupportsOffMainThreadCompositing() { return true; }
   665     nsRefPtr<gfxASurface> mScreenReferenceSurface;
   666     mozilla::RefPtr<mozilla::gfx::DrawTarget> mScreenReferenceDrawTarget;
   667     nsTArray<uint32_t> mCJKPrefLangs;
   668     nsCOMPtr<nsIObserver> mSRGBOverrideObserver;
   669     nsCOMPtr<nsIObserver> mFontPrefsObserver;
   670     nsCOMPtr<nsIObserver> mMemoryPressureObserver;
   672     // The preferred draw target backend to use for canvas
   673     mozilla::gfx::BackendType mPreferredCanvasBackend;
   674     // The fallback draw target backend to use for canvas, if the preferred backend fails
   675     mozilla::gfx::BackendType mFallbackCanvasBackend;
   676     // The backend to use for content
   677     mozilla::gfx::BackendType mContentBackend;
   678     // Bitmask of backend types we can use to render content
   679     uint32_t mContentBackendBitmask;
   681     mozilla::widget::GfxInfoCollector<gfxPlatform> mAzureCanvasBackendCollector;
   683     mozilla::RefPtr<mozilla::gfx::DrawEventRecorder> mRecorder;
   684     bool mLayersPreferMemoryOverShmem;
   685     mozilla::RefPtr<mozilla::gl::SkiaGLGlue> mSkiaGlue;
   686 };
   688 #endif /* GFX_PLATFORM_H */

mercurial