Bug 1444940 [wpt PR 9917] - Writable streams: test changes to abort() under error...
[gecko.git] / gfx / thebes / gfxPlatform.h
blob3bbf2b763f26f7203bc303cfc676b5e076b53fdf
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 "mozilla/Logging.h"
10 #include "mozilla/gfx/Types.h"
11 #include "nsTArray.h"
12 #include "nsString.h"
13 #include "nsCOMPtr.h"
14 #include "nsUnicodeScriptCodes.h"
16 #include "gfxTypes.h"
17 #include "gfxFontFamilyList.h"
18 #include "gfxBlur.h"
19 #include "gfxSkipChars.h"
20 #include "nsRect.h"
22 #include "qcms.h"
24 #include "mozilla/RefPtr.h"
25 #include "GfxInfoCollector.h"
27 #include "mozilla/layers/CompositorTypes.h"
29 class gfxASurface;
30 class gfxFont;
31 class gfxFontGroup;
32 struct gfxFontStyle;
33 class gfxUserFontSet;
34 class gfxFontEntry;
35 class gfxPlatformFontList;
36 class gfxTextRun;
37 class nsIURI;
38 class nsAtom;
39 class nsIObserver;
40 class SRGBOverrideObserver;
41 class gfxTextPerfMetrics;
42 typedef struct FT_LibraryRec_ *FT_Library;
44 namespace mozilla {
45 namespace gl {
46 class SkiaGLGlue;
47 } // namespace gl
48 namespace gfx {
49 class DrawTarget;
50 class SourceSurface;
51 class DataSourceSurface;
52 class ScaledFont;
53 class DrawEventRecorder;
54 class VsyncSource;
55 class ContentDeviceData;
56 class GPUDeviceData;
57 class FeatureState;
59 inline uint32_t
60 BackendTypeBit(BackendType b)
62 return 1 << uint8_t(b);
65 } // namespace gfx
66 namespace dom {
67 class SystemFontListEntry;
69 } // namespace mozilla
71 #define MOZ_PERFORMANCE_WARNING(module, ...) \
72 do { \
73 if (gfxPlatform::PerfWarnings()) { \
74 printf_stderr("[" module "] " __VA_ARGS__); \
75 } \
76 } while (0)
78 enum eCMSMode {
79 eCMSMode_Off = 0, // No color management
80 eCMSMode_All = 1, // Color manage everything
81 eCMSMode_TaggedOnly = 2, // Color manage tagged Images Only
82 eCMSMode_AllCount = 3
85 enum eGfxLog {
86 // all font enumerations, localized names, fullname/psnames, cmap loads
87 eGfxLog_fontlist = 0,
88 // timing info on font initialization
89 eGfxLog_fontinit = 1,
90 // dump text runs, font matching, system fallback for content
91 eGfxLog_textrun = 2,
92 // dump text runs, font matching, system fallback for chrome
93 eGfxLog_textrunui = 3,
94 // dump cmap coverage data as they are loaded
95 eGfxLog_cmapdata = 4,
96 // text perf data
97 eGfxLog_textperf = 5
100 // when searching through pref langs, max number of pref langs
101 const uint32_t kMaxLenPrefLangList = 32;
103 #define UNINITIALIZED_VALUE (-1)
105 inline const char*
106 GetBackendName(mozilla::gfx::BackendType aBackend)
108 switch (aBackend) {
109 case mozilla::gfx::BackendType::DIRECT2D:
110 return "direct2d";
111 case mozilla::gfx::BackendType::CAIRO:
112 return "cairo";
113 case mozilla::gfx::BackendType::SKIA:
114 return "skia";
115 case mozilla::gfx::BackendType::RECORDING:
116 return "recording";
117 case mozilla::gfx::BackendType::DIRECT2D1_1:
118 return "direct2d 1.1";
119 case mozilla::gfx::BackendType::WEBRENDER_TEXT:
120 return "webrender text";
121 case mozilla::gfx::BackendType::NONE:
122 return "none";
123 case mozilla::gfx::BackendType::BACKEND_LAST:
124 return "invalid";
126 MOZ_CRASH("Incomplete switch");
129 enum class DeviceResetReason
131 OK = 0,
132 HUNG,
133 REMOVED,
134 RESET,
135 DRIVER_ERROR,
136 INVALID_CALL,
137 OUT_OF_MEMORY,
138 FORCED_RESET,
139 UNKNOWN,
140 D3D9_RESET
143 enum class ForcedDeviceResetReason
145 OPENSHAREDHANDLE = 0,
146 COMPOSITOR_UPDATED,
149 struct BackendPrefsData
151 uint32_t mCanvasBitmask = 0;
152 mozilla::gfx::BackendType mCanvasDefault = mozilla::gfx::BackendType::NONE;
153 uint32_t mContentBitmask = 0;
154 mozilla::gfx::BackendType mContentDefault = mozilla::gfx::BackendType::NONE;
157 class gfxPlatform {
158 friend class SRGBOverrideObserver;
160 public:
161 typedef mozilla::gfx::Color Color;
162 typedef mozilla::gfx::DataSourceSurface DataSourceSurface;
163 typedef mozilla::gfx::DrawTarget DrawTarget;
164 typedef mozilla::gfx::IntSize IntSize;
165 typedef mozilla::gfx::SourceSurface SourceSurface;
166 typedef mozilla::unicode::Script Script;
169 * Return a pointer to the current active platform.
170 * This is a singleton; it contains mostly convenience
171 * functions to obtain platform-specific objects.
173 static gfxPlatform *GetPlatform();
176 * Returns whether or not graphics has been initialized yet. This is
177 * intended for Telemetry where we don't necessarily want to initialize
178 * graphics just to observe its state.
180 static bool Initialized();
183 * Shut down Thebes.
184 * Init() arranges for this to be called at an appropriate time.
186 static void Shutdown();
189 * Initialize gfxPlatform (if not already done) in a child process, with
190 * the provided ContentDeviceData.
192 static void InitChild(const mozilla::gfx::ContentDeviceData& aData);
194 static void InitLayersIPC();
195 static void ShutdownLayersIPC();
198 * Initialize ScrollMetadata statics. Does not depend on gfxPlatform.
200 static void InitNullMetadata();
202 static int32_t MaxTextureSize();
203 static int32_t MaxAllocSize();
204 static void InitMoz2DLogging();
206 static bool IsHeadless();
209 * Create an offscreen surface of the given dimensions
210 * and image format.
212 virtual already_AddRefed<gfxASurface>
213 CreateOffscreenSurface(const IntSize& aSize,
214 gfxImageFormat aFormat) = 0;
217 * Beware that this method may return DrawTargets which are not fully supported
218 * on the current platform and might fail silently in subtle ways. This is a massive
219 * potential footgun. You should only use these methods for canvas drawing really.
220 * Use extreme caution if you use them for content where you are not 100% sure we
221 * support the DrawTarget we get back.
222 * See SupportsAzureContentForDrawTarget.
224 static already_AddRefed<DrawTarget>
225 CreateDrawTargetForSurface(gfxASurface *aSurface, const mozilla::gfx::IntSize& aSize);
228 * Creates a SourceSurface for a gfxASurface. This function does no caching,
229 * so the caller should cache the gfxASurface if it will be used frequently.
230 * The returned surface keeps a reference to aTarget, so it is OK to keep the
231 * surface, even if aTarget changes.
232 * aTarget should not keep a reference to the returned surface because that
233 * will cause a cycle.
235 * This function is static so that it can be accessed from
236 * PluginInstanceChild (where we can't call gfxPlatform::GetPlatform()
237 * because the prefs service can only be accessed from the main process).
239 * aIsPlugin is used to tell the backend that they can optimize this surface
240 * specifically because it's used for a plugin. This is mostly for Skia.
242 static already_AddRefed<SourceSurface> GetSourceSurfaceForSurface(
243 RefPtr<mozilla::gfx::DrawTarget> aTarget,
244 gfxASurface* aSurface,
245 bool aIsPlugin = false);
247 static void ClearSourceSurfaceForSurface(gfxASurface *aSurface);
249 static already_AddRefed<DataSourceSurface>
250 GetWrappedDataSourceSurface(gfxASurface *aSurface);
252 already_AddRefed<DrawTarget> CreateOffscreenContentDrawTarget(
253 const mozilla::gfx::IntSize& aSize,
254 mozilla::gfx::SurfaceFormat aFormat,
255 bool aFallback = false);
257 already_AddRefed<DrawTarget>
258 CreateOffscreenCanvasDrawTarget(const mozilla::gfx::IntSize& aSize, mozilla::gfx::SurfaceFormat aFormat);
260 already_AddRefed<DrawTarget>
261 CreateSimilarSoftwareDrawTarget(DrawTarget* aDT, const IntSize &aSize, mozilla::gfx::SurfaceFormat aFormat);
263 static already_AddRefed<DrawTarget>
264 CreateDrawTargetForData(unsigned char* aData,
265 const mozilla::gfx::IntSize& aSize,
266 int32_t aStride,
267 mozilla::gfx::SurfaceFormat aFormat,
268 bool aUninitialized = false);
271 * Returns true if we should use Azure to render content with aTarget. For
272 * example, it is possible that we are using Direct2D for rendering and thus
273 * using Azure. But we want to render to a CairoDrawTarget, in which case
274 * SupportsAzureContent will return true but SupportsAzureContentForDrawTarget
275 * will return false.
277 bool SupportsAzureContentForDrawTarget(mozilla::gfx::DrawTarget* aTarget);
279 bool SupportsAzureContentForType(mozilla::gfx::BackendType aType) {
280 return BackendTypeBit(aType) & mContentBackendBitmask;
283 /// This function also lets us know if the current preferences/platform
284 /// combination allows for both accelerated and not accelerated canvas
285 /// implementations. If it does, and other relevant preferences are
286 /// asking for it, we will examine the commands in the first few seconds
287 /// of the canvas usage, and potentially change to accelerated or
288 /// non-accelerated canvas.
289 virtual bool AllowOpenGLCanvas();
290 virtual void InitializeSkiaCacheLimits();
292 static bool AsyncPanZoomEnabled();
294 virtual void GetAzureBackendInfo(mozilla::widget::InfoObject &aObj);
295 void GetApzSupportInfo(mozilla::widget::InfoObject& aObj);
296 void GetTilesSupportInfo(mozilla::widget::InfoObject& aObj);
298 // Get the default content backend that will be used with the default
299 // compositor. If the compositor is known when calling this function,
300 // GetContentBackendFor() should be called instead.
301 mozilla::gfx::BackendType GetDefaultContentBackend() {
302 return mContentBackend;
305 /// Return the software backend to use by default.
306 mozilla::gfx::BackendType GetSoftwareBackend() {
307 return mSoftwareBackend;
310 // Return the best content backend available that is compatible with the
311 // given layers backend.
312 virtual mozilla::gfx::BackendType GetContentBackendFor(mozilla::layers::LayersBackend aLayers) {
313 return mContentBackend;
316 virtual mozilla::gfx::BackendType GetPreferredCanvasBackend() {
317 return mPreferredCanvasBackend;
319 mozilla::gfx::BackendType GetFallbackCanvasBackend() {
320 return mFallbackCanvasBackend;
323 * Font bits
326 virtual void SetupClusterBoundaries(gfxTextRun *aTextRun, const char16_t *aString);
329 * Fill aListOfFonts with the results of querying the list of font names
330 * that correspond to the given language group or generic font family
331 * (or both, or neither).
333 virtual nsresult GetFontList(nsAtom *aLangGroup,
334 const nsACString& aGenericFamily,
335 nsTArray<nsString>& aListOfFonts);
338 * Fill aFontList with a list of SystemFontListEntry records for the
339 * available fonts on the platform; used to pass the list from chrome to
340 * content process. Currently implemented only on MacOSX and Linux.
342 virtual void ReadSystemFontList(
343 InfallibleTArray<mozilla::dom::SystemFontListEntry>* aFontList)
347 * Rebuilds the any cached system font lists
349 virtual nsresult UpdateFontList();
352 * Create the platform font-list object (gfxPlatformFontList concrete subclass).
353 * This function is responsible to create the appropriate subclass of
354 * gfxPlatformFontList *and* to call its InitFontList() method.
356 virtual gfxPlatformFontList *CreatePlatformFontList() {
357 NS_NOTREACHED("oops, this platform doesn't have a gfxPlatformFontList implementation");
358 return nullptr;
362 * Resolving a font name to family name. The result MUST be in the result of GetFontList().
363 * If the name doesn't in the system, aFamilyName will be empty string, but not failed.
365 virtual nsresult GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName);
368 * Returns default font name (localized family name) for aLangGroup and
369 * aGenericFamily. The result is typically the first font in
370 * font.name-list.<aGenericFamily>.<aLangGroup>. However, if it's not
371 * available in the system, this may return second or later font in the
372 * pref. If there are no available fonts in the pref, returns empty string.
374 nsString GetDefaultFontName(const nsACString& aLangGroup,
375 const nsACString& aGenericFamily);
378 * Create the appropriate platform font group
380 virtual gfxFontGroup*
381 CreateFontGroup(const mozilla::FontFamilyList& aFontFamilyList,
382 const gfxFontStyle *aStyle,
383 gfxTextPerfMetrics* aTextPerf,
384 gfxUserFontSet *aUserFontSet,
385 gfxFloat aDevToCssSize) = 0;
388 * Look up a local platform font using the full font face name.
389 * (Needed to support @font-face src local().)
390 * Ownership of the returned gfxFontEntry is passed to the caller,
391 * who must either AddRef() or delete.
393 virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName,
394 uint16_t aWeight,
395 int16_t aStretch,
396 uint8_t aStyle);
399 * Activate a platform font. (Needed to support @font-face src url().)
400 * aFontData is a NS_Malloc'ed block that must be freed by this function
401 * (or responsibility passed on) when it is no longer needed; the caller
402 * will NOT free it.
403 * Ownership of the returned gfxFontEntry is passed to the caller,
404 * who must either AddRef() or delete.
406 virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName,
407 uint16_t aWeight,
408 int16_t aStretch,
409 uint8_t aStyle,
410 const uint8_t* aFontData,
411 uint32_t aLength);
414 * Whether to allow downloadable fonts via @font-face rules
416 bool DownloadableFontsEnabled();
419 * True when hinting should be enabled. This setting shouldn't
420 * change per gecko process, while the process is live. If so the
421 * results are not defined.
423 * NB: this bit is only honored by the FT2 backend, currently.
425 virtual bool FontHintingEnabled() { return true; }
428 * True when zooming should not require reflow, so glyph metrics and
429 * positioning should not be adjusted for device pixels.
430 * If this is TRUE, then FontHintingEnabled() should be FALSE,
431 * but the converse is not necessarily required;
433 * Like FontHintingEnabled (above), this setting shouldn't
434 * change per gecko process, while the process is live. If so the
435 * results are not defined.
437 * NB: this bit is only honored by the FT2 backend, currently.
439 virtual bool RequiresLinearZoom() { return false; }
442 * Whether the frame->StyleFont().mFont.smoothing field is respected by
443 * text rendering on this platform.
445 virtual bool RespectsFontStyleSmoothing() const { return false; }
448 * Whether to check all font cmaps during system font fallback
450 bool UseCmapsDuringSystemFallback();
453 * Whether to render SVG glyphs within an OpenType font wrapper
455 bool OpenTypeSVGEnabled();
458 * Max character length of words in the word cache
460 uint32_t WordCacheCharLimit();
463 * Max number of entries in word cache
465 uint32_t WordCacheMaxEntries();
468 * Whether to use the SIL Graphite rendering engine
469 * (for fonts that include Graphite tables)
471 bool UseGraphiteShaping();
473 // Check whether format is supported on a platform (if unclear, returns true).
474 // Default implementation checks for "common" formats that we support across
475 // all platforms, but individual platform implementations may override.
476 virtual bool IsFontFormatSupported(uint32_t aFormatFlags);
478 virtual bool DidRenderingDeviceReset(DeviceResetReason* aResetReason = nullptr) { return false; }
480 // returns a list of commonly used fonts for a given character
481 // these are *possible* matches, no cmap-checking is done at this level
482 virtual void GetCommonFallbackFonts(uint32_t /*aCh*/, uint32_t /*aNextCh*/,
483 Script /*aRunScript*/,
484 nsTArray<const char*>& /*aFontList*/)
486 // platform-specific override, by default do nothing
489 // Are we in safe mode?
490 static bool InSafeMode();
492 static bool OffMainThreadCompositingEnabled();
494 void UpdateCanUseHardwareVideoDecoding();
496 // Returns a prioritized list of all available compositor backends.
497 void GetCompositorBackends(bool useAcceleration, nsTArray<mozilla::layers::LayersBackend>& aBackends);
500 * Is it possible to use buffer rotation. Note that these
501 * check the preference, but also allow for the override to
502 * disable it using DisableBufferRotation.
504 static bool BufferRotationEnabled();
505 static void DisableBufferRotation();
508 * Are we going to try color management?
510 static eCMSMode GetCMSMode();
513 * Determines the rendering intent for color management.
515 * If the value in the pref gfx.color_management.rendering_intent is a
516 * valid rendering intent as defined in gfx/qcms/qcms.h, that
517 * value is returned. Otherwise, -1 is returned and the embedded intent
518 * should be used.
520 * See bug 444014 for details.
522 static int GetRenderingIntent();
525 * Convert a pixel using a cms transform in an endian-aware manner.
527 * Sets 'out' to 'in' if transform is nullptr.
529 static void TransformPixel(const Color& in, Color& out, qcms_transform *transform);
532 * Return the output device ICC profile.
534 static qcms_profile* GetCMSOutputProfile();
537 * Return the sRGB ICC profile.
539 static qcms_profile* GetCMSsRGBProfile();
542 * Return sRGB -> output device transform.
544 static qcms_transform* GetCMSRGBTransform();
547 * Return output -> sRGB device transform.
549 static qcms_transform* GetCMSInverseRGBTransform();
552 * Return sRGBA -> output device transform.
554 static qcms_transform* GetCMSRGBATransform();
556 virtual void FontsPrefsChanged(const char *aPref);
558 int32_t GetBidiNumeralOption();
561 * This is a bit ugly, but useful... force all presContexts to reflow,
562 * by toggling a preference that they observe. This is used when
563 * something about platform settings changes that might have an effect
564 * on layout, such as font rendering settings that influence metrics.
566 static void ForceGlobalReflow();
568 static void
569 FlushFontAndWordCaches();
572 * Returns a 1x1 surface that can be used to create graphics contexts
573 * for measuring text etc as if they will be rendered to the screen
575 gfxASurface* ScreenReferenceSurface() { return mScreenReferenceSurface; }
578 * Returns a 1x1 DrawTarget that can be used for measuring text etc. as
579 * it would measure if rendered on-screen. Guaranteed to return a
580 * non-null and valid DrawTarget.
582 RefPtr<mozilla::gfx::DrawTarget> ScreenReferenceDrawTarget();
584 virtual mozilla::gfx::SurfaceFormat Optimal2DFormatForContent(gfxContentType aContent);
586 virtual gfxImageFormat OptimalFormatForContent(gfxContentType aContent);
588 virtual gfxImageFormat GetOffscreenFormat()
589 { return mozilla::gfx::SurfaceFormat::X8R8G8B8_UINT32; }
591 virtual bool UsesTiling() const;
594 * Returns a logger if one is available and logging is enabled
596 static mozilla::LogModule* GetLog(eGfxLog aWhichLog);
598 int GetScreenDepth() const { return mScreenDepth; }
599 mozilla::gfx::IntSize GetScreenSize() const { return mScreenSize; }
602 * Return the layer debugging options to use browser-wide.
604 mozilla::layers::DiagnosticTypes GetLayerDiagnosticTypes();
606 mozilla::gl::SkiaGLGlue* GetSkiaGLGlue();
607 void PurgeSkiaGPUCache();
608 static void PurgeSkiaFontCache();
610 static bool UsesOffMainThreadCompositing();
612 bool HasEnoughTotalSystemMemoryForSkiaGL();
615 * Get the hardware vsync source for each platform.
616 * Should only exist and be valid on the parent process
618 virtual mozilla::gfx::VsyncSource* GetHardwareVsync() {
619 MOZ_ASSERT(mVsyncSource != nullptr);
620 MOZ_ASSERT(XRE_IsParentProcess());
621 return mVsyncSource;
625 * True if layout rendering should use ASAP mode, which means
626 * the refresh driver and compositor should render ASAP.
627 * Used for talos testing purposes
629 static bool IsInLayoutAsapMode();
632 * Returns the software vsync rate to use.
634 static int GetSoftwareVsyncRate();
637 * Returns whether or not a custom vsync rate is set.
639 static bool ForceSoftwareVsync();
642 * Returns the default frame rate for the refresh driver / software vsync.
644 static int GetDefaultFrameRate();
647 * Used to test which input types are handled via APZ.
649 virtual bool SupportsApzWheelInput() const {
650 return false;
652 bool SupportsApzTouchInput() const;
653 bool SupportsApzDragInput() const;
654 bool SupportsApzKeyboardInput() const;
655 bool SupportsApzAutoscrolling() const;
657 virtual void FlushContentDrawing() {}
659 // If a device reset has occurred, schedule any necessary paints in the
660 // widget. This should only be used within nsRefreshDriver.
661 virtual void SchedulePaintIfDeviceReset() {}
664 * Helper method, creates a draw target for a specific Azure backend.
665 * Used by CreateOffscreenDrawTarget.
667 already_AddRefed<DrawTarget>
668 CreateDrawTargetForBackend(mozilla::gfx::BackendType aBackend,
669 const mozilla::gfx::IntSize& aSize,
670 mozilla::gfx::SurfaceFormat aFormat);
673 * Wrapper around gfxPrefs::PerfWarnings().
674 * Extracted into a function to avoid including gfxPrefs.h from this file.
676 static bool PerfWarnings();
678 static void NotifyGPUProcessDisabled();
680 void NotifyCompositorCreated(mozilla::layers::LayersBackend aBackend);
681 mozilla::layers::LayersBackend GetCompositorBackend() const {
682 return mCompositorBackend;
685 virtual void CompositorUpdated() {}
687 // Plugin async drawing support.
688 virtual bool SupportsPluginDirectBitmapDrawing() {
689 return false;
692 // Some platforms don't support CompositorOGL in an unaccelerated OpenGL
693 // context. These platforms should return true here.
694 virtual bool RequiresAcceleratedGLContextForCompositorOGL() const {
695 return false;
699 * Check the blocklist for a feature. Returns false if the feature is blocked
700 * with an appropriate message and failure ID.
701 * */
702 static bool IsGfxInfoStatusOkay(int32_t aFeature, nsCString* aOutMessage,
703 nsCString& aFailureId);
705 const gfxSkipChars& EmptySkipChars() const { return kEmptySkipChars; }
708 * Return information on how child processes should initialize graphics
709 * devices.
711 virtual void BuildContentDeviceData(mozilla::gfx::ContentDeviceData* aOut);
714 * Imports settings from the GPU process. This should only be called through
715 * GPUProcessManager, in the UI process.
717 virtual void ImportGPUDeviceData(const mozilla::gfx::GPUDeviceData& aData);
719 virtual FT_Library GetFTLibrary() {
720 return nullptr;
723 // you probably want to use gfxVars::UseWebRender() instead of this
724 static bool WebRenderPrefEnabled();
725 // you probably want to use gfxVars::UseWebRender() instead of this
726 static bool WebRenderEnvvarEnabled();
728 protected:
729 gfxPlatform();
730 virtual ~gfxPlatform();
732 virtual void InitAcceleration();
733 virtual void InitWebRenderConfig();
736 * Called immediately before deleting the gfxPlatform object.
738 virtual void WillShutdown();
741 * Initialized hardware vsync based on each platform.
743 virtual already_AddRefed<mozilla::gfx::VsyncSource> CreateHardwareVsyncSource();
745 // Returns whether or not layers should be accelerated by default on this platform.
746 virtual bool AccelerateLayersByDefault();
748 // Returns a prioritized list of available compositor backends for acceleration.
749 virtual void GetAcceleratedCompositorBackends(nsTArray<mozilla::layers::LayersBackend>& aBackends);
751 // Returns preferences of canvas and content backends.
752 virtual BackendPrefsData GetBackendPrefs();
755 * Initialise the preferred and fallback canvas backends
756 * aBackendBitmask specifies the backends which are acceptable to the caller.
757 * The backend used is determined by aBackendBitmask and the order specified
758 * by the gfx.canvas.azure.backends pref.
760 void InitBackendPrefs(BackendPrefsData&& aPrefsData);
763 * Content-process only. Requests device preferences from the parent process
764 * and updates any cached settings.
766 void FetchAndImportContentDeviceData();
767 virtual void ImportContentDeviceData(const mozilla::gfx::ContentDeviceData& aData);
770 * Increase the global device counter after a device has been removed/reset.
772 void BumpDeviceCounter();
775 * returns the first backend named in the pref gfx.canvas.azure.backends
776 * which is a component of aBackendBitmask, a bitmask of backend types
778 static mozilla::gfx::BackendType GetCanvasBackendPref(uint32_t aBackendBitmask);
781 * returns the first backend named in the pref gfx.content.azure.backend
782 * which is a component of aBackendBitmask, a bitmask of backend types
784 static mozilla::gfx::BackendType GetContentBackendPref(uint32_t &aBackendBitmask);
787 * Will return the first backend named in aBackendPrefName
788 * allowed by aBackendBitmask, a bitmask of backend types.
789 * It also modifies aBackendBitmask to only include backends that are
790 * allowed given the prefs.
792 static mozilla::gfx::BackendType GetBackendPref(const char* aBackendPrefName,
793 uint32_t &aBackendBitmask);
795 * Decode the backend enumberation from a string.
797 static mozilla::gfx::BackendType BackendTypeForName(const nsCString& aName);
799 virtual bool CanUseHardwareVideoDecoding();
801 int8_t mAllowDownloadableFonts;
802 int8_t mGraphiteShapingEnabled;
803 int8_t mOpenTypeSVGEnabled;
805 int8_t mBidiNumeralOption;
807 // whether to always search font cmaps globally
808 // when doing system font fallback
809 int8_t mFallbackUsesCmaps;
811 // max character limit for words in word cache
812 int32_t mWordCacheCharLimit;
814 // max number of entries in word cache
815 int32_t mWordCacheMaxEntries;
817 uint64_t mTotalSystemMemory;
819 // Hardware vsync source. Only valid on parent process
820 RefPtr<mozilla::gfx::VsyncSource> mVsyncSource;
822 RefPtr<mozilla::gfx::DrawTarget> mScreenReferenceDrawTarget;
824 private:
826 * Start up Thebes.
828 static void Init();
830 static void InitOpenGLConfig();
831 static void CreateCMSOutputProfile();
833 static void GetCMSOutputProfileData(void *&mem, size_t &size);
835 friend void RecordingPrefChanged(const char *aPrefName, void *aClosure);
837 virtual void GetPlatformCMSOutputProfile(void *&mem, size_t &size);
840 * Calling this function will compute and set the ideal tile size for the
841 * platform. This will only have an effect in the parent process; child processes
842 * should be updated via SetTileSize to match the value computed in the parent.
844 void ComputeTileSize();
847 * This uses nsIScreenManager to determine the screen size and color depth
849 void PopulateScreenInfo();
851 void InitCompositorAccelerationPrefs();
852 void InitGPUProcessPrefs();
853 void InitOMTPConfig();
855 static bool IsDXInterop2Blocked();
857 RefPtr<gfxASurface> mScreenReferenceSurface;
858 nsCOMPtr<nsIObserver> mSRGBOverrideObserver;
859 nsCOMPtr<nsIObserver> mFontPrefsObserver;
860 nsCOMPtr<nsIObserver> mMemoryPressureObserver;
862 // The preferred draw target backend to use for canvas
863 mozilla::gfx::BackendType mPreferredCanvasBackend;
864 // The fallback draw target backend to use for canvas, if the preferred backend fails
865 mozilla::gfx::BackendType mFallbackCanvasBackend;
866 // The backend to use for content
867 mozilla::gfx::BackendType mContentBackend;
868 // The backend to use when we need it not to be accelerated.
869 mozilla::gfx::BackendType mSoftwareBackend;
870 // Bitmask of backend types we can use to render content
871 uint32_t mContentBackendBitmask;
873 mozilla::widget::GfxInfoCollector<gfxPlatform> mAzureCanvasBackendCollector;
874 mozilla::widget::GfxInfoCollector<gfxPlatform> mApzSupportCollector;
875 mozilla::widget::GfxInfoCollector<gfxPlatform> mTilesInfoCollector;
877 RefPtr<mozilla::gfx::DrawEventRecorder> mRecorder;
878 RefPtr<mozilla::gl::SkiaGLGlue> mSkiaGlue;
880 // Backend that we are compositing with. NONE, if no compositor has been
881 // created yet.
882 mozilla::layers::LayersBackend mCompositorBackend;
884 int32_t mScreenDepth;
885 mozilla::gfx::IntSize mScreenSize;
887 // An instance of gfxSkipChars which is empty. It is used as the
888 // basis for error-case iterators.
889 const gfxSkipChars kEmptySkipChars;
892 #endif /* GFX_PLATFORM_H */