2012-05-21 19:27:32 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2012-05-21 15:12:37 +04:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2005-11-29 23:29:45 +03:00
|
|
|
|
2018-04-13 22:34:37 +03:00
|
|
|
#include "mozilla/FontPropertyTypes.h"
|
2018-11-14 21:07:28 +03:00
|
|
|
#include "mozilla/RDDProcessManager.h"
|
2018-09-25 16:13:51 +03:00
|
|
|
#include "mozilla/image/ImageMemoryReporter.h"
|
2017-06-14 18:39:59 +03:00
|
|
|
#include "mozilla/layers/CompositorManagerChild.h"
|
2016-05-16 09:38:34 +03:00
|
|
|
#include "mozilla/layers/CompositorThread.h"
|
2012-07-13 23:38:09 +04:00
|
|
|
#include "mozilla/layers/ImageBridgeChild.h"
|
2013-11-15 01:54:25 +04:00
|
|
|
#include "mozilla/layers/ISurfaceAllocator.h" // for GfxMemoryImageReporter
|
2018-11-16 05:13:56 +03:00
|
|
|
#include "mozilla/layers/CompositorBridgeChild.h"
|
2019-02-18 01:18:57 +03:00
|
|
|
#include "mozilla/layers/TiledContentClient.h"
|
2017-01-17 03:21:52 +03:00
|
|
|
#include "mozilla/webrender/RenderThread.h"
|
2017-11-10 15:30:53 +03:00
|
|
|
#include "mozilla/webrender/WebRenderAPI.h"
|
2017-10-30 06:31:38 +03:00
|
|
|
#include "mozilla/webrender/webrender_ffi.h"
|
2017-06-09 23:30:00 +03:00
|
|
|
#include "mozilla/layers/PaintThread.h"
|
2016-08-04 21:33:42 +03:00
|
|
|
#include "mozilla/gfx/gfxVars.h"
|
2016-05-23 10:27:01 +03:00
|
|
|
#include "mozilla/gfx/GPUProcessManager.h"
|
2016-08-21 06:59:11 +03:00
|
|
|
#include "mozilla/gfx/GraphicsMessages.h"
|
2016-03-31 00:04:10 +03:00
|
|
|
#include "mozilla/ClearOnShutdown.h"
|
2019-05-26 17:29:42 +03:00
|
|
|
#include "mozilla/StaticPrefs.h"
|
2015-10-14 09:24:00 +03:00
|
|
|
#include "mozilla/Telemetry.h"
|
2015-12-30 13:47:00 +03:00
|
|
|
#include "mozilla/TimeStamp.h"
|
2016-10-04 01:48:11 +03:00
|
|
|
#include "mozilla/Unused.h"
|
2018-11-16 05:13:56 +03:00
|
|
|
#include "mozilla/IntegerPrintfMacros.h"
|
2019-06-05 01:50:47 +03:00
|
|
|
#include "mozilla/Base64.h"
|
2012-07-13 19:25:29 +04:00
|
|
|
|
2015-05-19 21:15:34 +03:00
|
|
|
#include "mozilla/Logging.h"
|
2015-07-08 23:51:09 +03:00
|
|
|
#include "mozilla/Services.h"
|
2018-05-31 09:07:34 +03:00
|
|
|
#include "nsAppDirectoryServiceDefs.h"
|
2011-01-21 19:44:33 +03:00
|
|
|
|
2016-01-18 20:56:38 +03:00
|
|
|
#include "gfxCrashReporterUtils.h"
|
2005-11-29 23:29:45 +03:00
|
|
|
#include "gfxPlatform.h"
|
2019-05-26 17:31:53 +03:00
|
|
|
|
2015-10-28 16:31:00 +03:00
|
|
|
#include "gfxEnv.h"
|
2014-09-16 13:58:12 +04:00
|
|
|
#include "gfxTextRun.h"
|
2017-07-20 11:57:00 +03:00
|
|
|
#include "gfxUserFontSet.h"
|
2016-04-29 07:52:54 +03:00
|
|
|
#include "gfxConfig.h"
|
2018-08-07 08:47:18 +03:00
|
|
|
#include "VRProcessManager.h"
|
2017-10-05 13:12:45 +03:00
|
|
|
#include "VRThread.h"
|
2005-11-29 23:29:45 +03:00
|
|
|
|
2019-06-13 14:12:43 +03:00
|
|
|
#include "mozilla/arm.h"
|
|
|
|
|
2013-11-07 07:18:23 +04:00
|
|
|
#ifdef XP_WIN
|
|
|
|
# include <process.h>
|
|
|
|
# define getpid _getpid
|
2013-11-08 18:04:30 +04:00
|
|
|
#else
|
|
|
|
# include <unistd.h>
|
2013-11-07 07:18:23 +04:00
|
|
|
#endif
|
|
|
|
|
2012-07-13 19:25:29 +04:00
|
|
|
#include "nsXULAppAPI.h"
|
2013-11-07 03:11:18 +04:00
|
|
|
#include "nsDirectoryServiceUtils.h"
|
|
|
|
#include "nsDirectoryServiceDefs.h"
|
2012-07-13 19:25:29 +04:00
|
|
|
|
2005-11-29 23:29:45 +03:00
|
|
|
#if defined(XP_WIN)
|
2006-02-01 05:35:38 +03:00
|
|
|
# include "gfxWindowsPlatform.h"
|
2005-11-29 23:29:45 +03:00
|
|
|
#elif defined(XP_MACOSX)
|
|
|
|
# include "gfxPlatformMac.h"
|
2013-07-10 05:02:41 +04:00
|
|
|
# include "gfxQuartzSurface.h"
|
2018-07-11 00:12:58 +03:00
|
|
|
# include "nsCocoaFeatures.h"
|
2012-06-28 04:15:32 +04:00
|
|
|
#elif defined(MOZ_WIDGET_GTK)
|
2005-11-29 23:29:45 +03:00
|
|
|
# include "gfxPlatformGtk.h"
|
2010-05-11 21:27:36 +04:00
|
|
|
#elif defined(ANDROID)
|
|
|
|
# include "gfxAndroidPlatform.h"
|
2005-11-29 23:29:45 +03:00
|
|
|
#endif
|
2018-10-23 13:08:34 +03:00
|
|
|
#if defined(MOZ_WIDGET_ANDROID)
|
|
|
|
# include "mozilla/jni/Utils.h" // for IsFennec
|
|
|
|
#endif
|
2005-11-29 23:29:45 +03:00
|
|
|
|
2016-01-13 20:10:51 +03:00
|
|
|
#ifdef XP_WIN
|
|
|
|
# include "mozilla/WindowsVersion.h"
|
2017-04-30 21:38:59 +03:00
|
|
|
# include "mozilla/gfx/DeviceManagerDx.h"
|
2016-01-13 20:10:51 +03:00
|
|
|
#endif
|
|
|
|
|
2019-04-30 12:37:37 +03:00
|
|
|
#ifdef MOZ_WAYLAND
|
2019-06-10 15:41:35 +03:00
|
|
|
# include "mozilla/widget/nsWaylandDisplay.h"
|
2019-04-30 12:37:37 +03:00
|
|
|
#endif
|
|
|
|
|
2012-03-30 01:08:43 +04:00
|
|
|
#include "nsGkAtoms.h"
|
2009-08-16 17:52:12 +04:00
|
|
|
#include "gfxPlatformFontList.h"
|
2006-03-25 03:34:48 +03:00
|
|
|
#include "gfxContext.h"
|
|
|
|
#include "gfxImageSurface.h"
|
2012-02-24 14:15:46 +04:00
|
|
|
#include "nsUnicodeProperties.h"
|
2012-04-22 01:24:39 +04:00
|
|
|
#include "harfbuzz/hb.h"
|
2011-12-10 02:32:29 +04:00
|
|
|
#include "gfxGraphiteShaper.h"
|
2013-10-08 03:15:59 +04:00
|
|
|
#include "gfx2DGlue.h"
|
2013-11-08 08:50:39 +04:00
|
|
|
#include "gfxGradientCache.h"
|
2015-08-27 01:33:16 +03:00
|
|
|
#include "gfxUtils.h" // for NextPowerOfTwo
|
2018-08-21 19:40:36 +03:00
|
|
|
#include "gfxFontMissingGlyphs.h"
|
2006-03-25 03:34:48 +03:00
|
|
|
|
2017-10-10 16:11:07 +03:00
|
|
|
#include "nsExceptionHandler.h"
|
2006-09-26 08:20:41 +04:00
|
|
|
#include "nsServiceManagerUtils.h"
|
2009-01-18 23:14:14 +03:00
|
|
|
#include "nsTArray.h"
|
2013-11-01 17:52:06 +04:00
|
|
|
#include "nsIObserverService.h"
|
2015-07-30 01:21:26 +03:00
|
|
|
#include "nsIScreenManager.h"
|
2013-11-27 11:33:39 +04:00
|
|
|
#include "MainThreadUtils.h"
|
2006-09-26 08:20:41 +04:00
|
|
|
|
2008-09-09 01:47:26 +04:00
|
|
|
#include "nsWeakReference.h"
|
|
|
|
|
2007-03-20 02:16:15 +03:00
|
|
|
#include "cairo.h"
|
2009-04-07 20:02:11 +04:00
|
|
|
#include "qcms.h"
|
2007-07-24 02:02:17 +04:00
|
|
|
|
2014-11-12 04:28:50 +03:00
|
|
|
#include "imgITools.h"
|
|
|
|
|
2008-01-31 03:23:36 +03:00
|
|
|
#include "plstr.h"
|
2009-10-07 18:13:40 +04:00
|
|
|
#include "nsCRT.h"
|
2010-07-20 08:05:42 +04:00
|
|
|
#include "GLContext.h"
|
|
|
|
#include "GLContextProvider.h"
|
2014-09-18 01:23:08 +04:00
|
|
|
#include "mozilla/gfx/Logging.h"
|
2007-03-20 02:16:15 +03:00
|
|
|
|
2014-04-15 23:07:42 +04:00
|
|
|
#ifdef USE_SKIA
|
2015-09-12 06:30:14 +03:00
|
|
|
# ifdef __GNUC__
|
|
|
|
# pragma GCC diagnostic push
|
|
|
|
# pragma GCC diagnostic ignored "-Wshadow"
|
|
|
|
# endif
|
|
|
|
# include "skia/include/core/SkGraphics.h"
|
2016-07-20 22:06:29 +03:00
|
|
|
# ifdef MOZ_ENABLE_FREETYPE
|
|
|
|
# include "skia/include/ports/SkTypeface_cairo.h"
|
|
|
|
# endif
|
2018-05-15 00:47:01 +03:00
|
|
|
# include "mozilla/gfx/SkMemoryReporter.h"
|
2015-09-12 06:30:14 +03:00
|
|
|
# ifdef __GNUC__
|
|
|
|
# pragma GCC diagnostic pop // -Wshadow
|
|
|
|
# endif
|
2016-03-21 19:08:34 +03:00
|
|
|
static const uint32_t kDefaultGlyphCacheSize = -1;
|
|
|
|
|
2014-10-15 07:55:37 +04:00
|
|
|
#endif
|
2014-03-06 01:49:37 +04:00
|
|
|
|
2011-06-12 06:30:16 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2012-05-15 23:41:20 +04:00
|
|
|
#include "mozilla/Assertions.h"
|
2016-05-12 12:24:43 +03:00
|
|
|
#include "mozilla/Atomics.h"
|
2012-06-13 08:14:28 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-08-04 11:46:17 +04:00
|
|
|
#include "mozilla/Mutex.h"
|
2010-04-06 06:28:54 +04:00
|
|
|
|
2015-12-09 00:42:43 +03:00
|
|
|
#include "nsAlgorithm.h"
|
2010-08-28 18:18:41 +04:00
|
|
|
#include "nsIGfxInfo.h"
|
2013-12-13 02:13:20 +04:00
|
|
|
#include "nsIXULRuntime.h"
|
2014-12-18 19:30:06 +03:00
|
|
|
#include "VsyncSource.h"
|
2015-01-09 02:12:47 +03:00
|
|
|
#include "SoftwareVsyncSource.h"
|
2015-07-31 22:11:48 +03:00
|
|
|
#include "nscore.h" // for NS_FREE_PERMANENT_DATA
|
2015-08-02 23:59:33 +03:00
|
|
|
#include "mozilla/dom/ContentChild.h"
|
2017-03-10 23:18:48 +03:00
|
|
|
#include "mozilla/dom/TouchEvent.h"
|
2015-09-18 00:23:13 +03:00
|
|
|
#include "gfxVR.h"
|
|
|
|
#include "VRManagerChild.h"
|
2016-06-11 05:27:24 +03:00
|
|
|
#include "mozilla/gfx/GPUParent.h"
|
2017-06-24 00:23:14 +03:00
|
|
|
#include "mozilla/layers/MemoryReportingMLGPU.h"
|
2016-09-23 18:40:25 +03:00
|
|
|
#include "prsystem.h"
|
2010-08-28 18:18:41 +04:00
|
|
|
|
2011-06-12 06:30:16 +04:00
|
|
|
using namespace mozilla;
|
2012-07-13 19:25:29 +04:00
|
|
|
using namespace mozilla::layers;
|
2015-07-29 23:35:55 +03:00
|
|
|
using namespace mozilla::gl;
|
2016-04-29 07:52:54 +03:00
|
|
|
using namespace mozilla::gfx;
|
2011-06-12 06:30:16 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
gfxPlatform* gPlatform = nullptr;
|
2011-04-21 23:36:49 +04:00
|
|
|
static bool gEverInitialized = false;
|
2008-07-17 07:09:08 +04:00
|
|
|
|
2018-12-14 23:16:23 +03:00
|
|
|
static int32_t gLastUsedFrameRate = -1;
|
|
|
|
|
2017-06-22 20:45:48 +03:00
|
|
|
const ContentDeviceData* gContentDeviceInitData = nullptr;
|
|
|
|
|
2013-08-04 11:46:17 +04:00
|
|
|
static Mutex* gGfxPlatformPrefsLock = nullptr;
|
|
|
|
|
2013-09-07 07:08:36 +04:00
|
|
|
// These two may point to the same profile
|
|
|
|
static qcms_profile* gCMSOutputProfile = nullptr;
|
|
|
|
static qcms_profile* gCMSsRGBProfile = nullptr;
|
|
|
|
|
2018-06-19 16:32:29 +03:00
|
|
|
static bool gCMSRGBTransformFailed = false;
|
2013-09-07 07:08:36 +04:00
|
|
|
static qcms_transform* gCMSRGBTransform = nullptr;
|
|
|
|
static qcms_transform* gCMSInverseRGBTransform = nullptr;
|
|
|
|
static qcms_transform* gCMSRGBATransform = nullptr;
|
2019-05-09 23:45:51 +03:00
|
|
|
static qcms_transform* gCMSBGRATransform = nullptr;
|
2013-09-07 07:08:36 +04:00
|
|
|
|
|
|
|
static bool gCMSInitialized = false;
|
|
|
|
static eCMSMode gCMSMode = eCMSMode_Off;
|
2014-03-06 01:25:09 +04:00
|
|
|
|
2013-09-07 07:08:36 +04:00
|
|
|
static void ShutdownCMS();
|
|
|
|
|
2011-06-24 21:41:18 +04:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2014-06-17 13:08:23 +04:00
|
|
|
#include "mozilla/gfx/SourceSurfaceCairo.h"
|
2011-06-24 21:41:18 +04:00
|
|
|
using namespace mozilla::gfx;
|
2011-01-21 19:44:33 +03:00
|
|
|
|
2013-09-07 07:08:36 +04:00
|
|
|
/* Class to listen for pref changes so that chrome code can dynamically
|
|
|
|
force sRGB as an output profile. See Bug #452125. */
|
2015-03-21 19:28:04 +03:00
|
|
|
class SRGBOverrideObserver final : public nsIObserver,
|
2015-03-27 21:52:19 +03:00
|
|
|
public nsSupportsWeakReference {
|
2016-11-15 12:04:18 +03:00
|
|
|
~SRGBOverrideObserver() = default;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2013-09-07 07:08:36 +04:00
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
};
|
|
|
|
|
2014-11-18 01:16:55 +03:00
|
|
|
/// This override of the LogForwarder, initially used for the critical graphics
|
|
|
|
/// errors, is sending the log to the crash annotations as well, but only
|
|
|
|
/// if the capacity set with the method below is >= 2. We always retain the
|
|
|
|
/// very first critical message, and the latest capacity-1 messages are
|
|
|
|
/// rotated through. Note that we don't expect the total number of times
|
|
|
|
/// this gets called to be large - it is meant for critical errors only.
|
|
|
|
|
2014-09-18 01:23:08 +04:00
|
|
|
class CrashStatsLogForwarder : public mozilla::gfx::LogForwarder {
|
|
|
|
public:
|
Bug 1348273 - Convert crash annotations into a machine-readable list of constants; r=ted.mielczarek,njn,dholbert,mak,cpearce,mcmanus,froydnj,Dexter,jrmuizel,jchen,jimm,bz,surkov
This introduces the machinery needed to generate crash annotations from a YAML
file. The relevant C++ functions are updated to take a typed enum. JavaScript
calls are unaffected but they will throw if the string argument does not
correspond to one of the known entries in the C++ enum. The existing whitelists
and blacklists of annotations are also generated from the YAML file and all
duplicate code related to them has been consolidated. Once written out to the
.extra file the annotations are converted in string form and are no different
than the existing ones.
All existing annotations have been included in the list (and some obsolete ones
have been removed) and all call sites have been updated including tests where
appropriate.
--HG--
extra : source : 4f6c43f2830701ec5552e08e3f1b06fe6d045860
2018-07-05 16:42:11 +03:00
|
|
|
explicit CrashStatsLogForwarder(CrashReporter::Annotation aKey);
|
2016-11-15 12:16:29 +03:00
|
|
|
void Log(const std::string& aString) override;
|
|
|
|
void CrashAction(LogReason aReason) override;
|
|
|
|
bool UpdateStringsVector(const std::string& aString) override;
|
2014-11-18 01:16:55 +03:00
|
|
|
|
2016-11-15 12:16:29 +03:00
|
|
|
LoggingRecord LoggingRecordCopy() override;
|
2015-01-14 05:19:25 +03:00
|
|
|
|
2014-11-18 01:16:55 +03:00
|
|
|
void SetCircularBufferSize(uint32_t aCapacity);
|
|
|
|
|
|
|
|
private:
|
2016-02-17 02:07:37 +03:00
|
|
|
// Helper for the Log()
|
2014-11-18 01:16:55 +03:00
|
|
|
void UpdateCrashReport();
|
|
|
|
|
|
|
|
private:
|
2015-12-30 13:47:00 +03:00
|
|
|
LoggingRecord mBuffer;
|
Bug 1348273 - Convert crash annotations into a machine-readable list of constants; r=ted.mielczarek,njn,dholbert,mak,cpearce,mcmanus,froydnj,Dexter,jrmuizel,jchen,jimm,bz,surkov
This introduces the machinery needed to generate crash annotations from a YAML
file. The relevant C++ functions are updated to take a typed enum. JavaScript
calls are unaffected but they will throw if the string argument does not
correspond to one of the known entries in the C++ enum. The existing whitelists
and blacklists of annotations are also generated from the YAML file and all
duplicate code related to them has been consolidated. Once written out to the
.extra file the annotations are converted in string form and are no different
than the existing ones.
All existing annotations have been included in the list (and some obsolete ones
have been removed) and all call sites have been updated including tests where
appropriate.
--HG--
extra : source : 4f6c43f2830701ec5552e08e3f1b06fe6d045860
2018-07-05 16:42:11 +03:00
|
|
|
CrashReporter::Annotation mCrashCriticalKey;
|
2014-11-18 01:16:55 +03:00
|
|
|
uint32_t mMaxCapacity;
|
|
|
|
int32_t mIndex;
|
2014-12-19 20:03:58 +03:00
|
|
|
Mutex mMutex;
|
2014-11-18 01:16:55 +03:00
|
|
|
};
|
|
|
|
|
Bug 1348273 - Convert crash annotations into a machine-readable list of constants; r=ted.mielczarek,njn,dholbert,mak,cpearce,mcmanus,froydnj,Dexter,jrmuizel,jchen,jimm,bz,surkov
This introduces the machinery needed to generate crash annotations from a YAML
file. The relevant C++ functions are updated to take a typed enum. JavaScript
calls are unaffected but they will throw if the string argument does not
correspond to one of the known entries in the C++ enum. The existing whitelists
and blacklists of annotations are also generated from the YAML file and all
duplicate code related to them has been consolidated. Once written out to the
.extra file the annotations are converted in string form and are no different
than the existing ones.
All existing annotations have been included in the list (and some obsolete ones
have been removed) and all call sites have been updated including tests where
appropriate.
--HG--
extra : source : 4f6c43f2830701ec5552e08e3f1b06fe6d045860
2018-07-05 16:42:11 +03:00
|
|
|
CrashStatsLogForwarder::CrashStatsLogForwarder(CrashReporter::Annotation aKey)
|
2014-11-18 01:16:55 +03:00
|
|
|
: mBuffer(),
|
|
|
|
mCrashCriticalKey(aKey),
|
|
|
|
mMaxCapacity(0),
|
|
|
|
mIndex(-1),
|
2014-12-19 20:03:58 +03:00
|
|
|
mMutex("CrashStatsLogForwarder") {}
|
2014-11-18 01:16:55 +03:00
|
|
|
|
|
|
|
void CrashStatsLogForwarder::SetCircularBufferSize(uint32_t aCapacity) {
|
2014-12-19 20:03:58 +03:00
|
|
|
MutexAutoLock lock(mMutex);
|
|
|
|
|
2014-11-18 01:16:55 +03:00
|
|
|
mMaxCapacity = aCapacity;
|
|
|
|
mBuffer.reserve(static_cast<size_t>(aCapacity));
|
|
|
|
}
|
|
|
|
|
2015-12-30 13:47:00 +03:00
|
|
|
LoggingRecord CrashStatsLogForwarder::LoggingRecordCopy() {
|
2015-01-14 05:19:25 +03:00
|
|
|
MutexAutoLock lock(mMutex);
|
|
|
|
return mBuffer;
|
|
|
|
}
|
|
|
|
|
2014-11-18 01:16:55 +03:00
|
|
|
bool CrashStatsLogForwarder::UpdateStringsVector(const std::string& aString) {
|
|
|
|
// We want at least the first one and the last one. Otherwise, no point.
|
|
|
|
if (mMaxCapacity < 2) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
mIndex += 1;
|
|
|
|
MOZ_ASSERT(mIndex >= 0);
|
|
|
|
|
|
|
|
// index will count 0, 1, 2, ..., max-1, 1, 2, ..., max-1, 1, 2, ...
|
|
|
|
int32_t index = mIndex ? (mIndex - 1) % (mMaxCapacity - 1) + 1 : 0;
|
|
|
|
MOZ_ASSERT(index >= 0 && index < (int32_t)mMaxCapacity);
|
|
|
|
MOZ_ASSERT(index <= mIndex && index <= (int32_t)mBuffer.size());
|
|
|
|
|
2017-04-26 07:55:54 +03:00
|
|
|
double tStamp = (TimeStamp::NowLoRes() - TimeStamp::ProcessCreation())
|
|
|
|
.ToSecondsSigDigits();
|
2015-12-30 13:47:00 +03:00
|
|
|
|
2014-11-18 01:16:55 +03:00
|
|
|
// Checking for index >= mBuffer.size(), rather than index == mBuffer.size()
|
|
|
|
// just out of paranoia, but we know index <= mBuffer.size().
|
2015-12-30 13:47:00 +03:00
|
|
|
LoggingRecordEntry newEntry(mIndex, aString, tStamp);
|
2014-11-18 01:16:55 +03:00
|
|
|
if (index >= static_cast<int32_t>(mBuffer.size())) {
|
|
|
|
mBuffer.push_back(newEntry);
|
|
|
|
} else {
|
|
|
|
mBuffer[index] = newEntry;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CrashStatsLogForwarder::UpdateCrashReport() {
|
|
|
|
std::stringstream message;
|
2016-10-04 01:48:11 +03:00
|
|
|
std::string logAnnotation;
|
|
|
|
|
|
|
|
switch (XRE_GetProcessType()) {
|
|
|
|
case GeckoProcessType_Default:
|
|
|
|
logAnnotation = "|[";
|
|
|
|
break;
|
|
|
|
case GeckoProcessType_Content:
|
|
|
|
logAnnotation = "|[C";
|
|
|
|
break;
|
|
|
|
case GeckoProcessType_GPU:
|
|
|
|
logAnnotation = "|[G";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
logAnnotation = "|[X";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-11-15 11:55:49 +03:00
|
|
|
for (auto& it : mBuffer) {
|
|
|
|
message << logAnnotation << Get<0>(it) << "]" << Get<1>(it)
|
|
|
|
<< " (t=" << Get<2>(it) << ") ";
|
2014-11-18 01:16:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsCString reportString(message.str().c_str());
|
Bug 1348273 - Convert crash annotations into a machine-readable list of constants; r=ted.mielczarek,njn,dholbert,mak,cpearce,mcmanus,froydnj,Dexter,jrmuizel,jchen,jimm,bz,surkov
This introduces the machinery needed to generate crash annotations from a YAML
file. The relevant C++ functions are updated to take a typed enum. JavaScript
calls are unaffected but they will throw if the string argument does not
correspond to one of the known entries in the C++ enum. The existing whitelists
and blacklists of annotations are also generated from the YAML file and all
duplicate code related to them has been consolidated. Once written out to the
.extra file the annotations are converted in string form and are no different
than the existing ones.
All existing annotations have been included in the list (and some obsolete ones
have been removed) and all call sites have been updated including tests where
appropriate.
--HG--
extra : source : 4f6c43f2830701ec5552e08e3f1b06fe6d045860
2018-07-05 16:42:11 +03:00
|
|
|
nsresult annotated =
|
|
|
|
CrashReporter::AnnotateCrashReport(mCrashCriticalKey, reportString);
|
2017-10-10 16:11:07 +03:00
|
|
|
|
2014-11-18 01:16:55 +03:00
|
|
|
if (annotated != NS_OK) {
|
|
|
|
printf("Crash Annotation %s: %s",
|
Bug 1348273 - Convert crash annotations into a machine-readable list of constants; r=ted.mielczarek,njn,dholbert,mak,cpearce,mcmanus,froydnj,Dexter,jrmuizel,jchen,jimm,bz,surkov
This introduces the machinery needed to generate crash annotations from a YAML
file. The relevant C++ functions are updated to take a typed enum. JavaScript
calls are unaffected but they will throw if the string argument does not
correspond to one of the known entries in the C++ enum. The existing whitelists
and blacklists of annotations are also generated from the YAML file and all
duplicate code related to them has been consolidated. Once written out to the
.extra file the annotations are converted in string form and are no different
than the existing ones.
All existing annotations have been included in the list (and some obsolete ones
have been removed) and all call sites have been updated including tests where
appropriate.
--HG--
extra : source : 4f6c43f2830701ec5552e08e3f1b06fe6d045860
2018-07-05 16:42:11 +03:00
|
|
|
CrashReporter::AnnotationToString(mCrashCriticalKey),
|
|
|
|
message.str().c_str());
|
2014-11-18 01:16:55 +03:00
|
|
|
}
|
|
|
|
}
|
2015-07-31 22:11:48 +03:00
|
|
|
|
2016-04-26 03:23:21 +03:00
|
|
|
class LogForwarderEvent : public Runnable {
|
2019-04-11 15:36:51 +03:00
|
|
|
virtual ~LogForwarderEvent() = default;
|
2016-02-17 02:07:37 +03:00
|
|
|
|
2018-02-12 23:44:40 +03:00
|
|
|
public:
|
|
|
|
NS_INLINE_DECL_REFCOUNTING_INHERITED(LogForwarderEvent, Runnable)
|
2016-02-17 02:07:37 +03:00
|
|
|
|
2017-06-12 22:34:10 +03:00
|
|
|
explicit LogForwarderEvent(const nsCString& aMessage)
|
|
|
|
: mozilla::Runnable("LogForwarderEvent"), mMessage(aMessage) {}
|
2016-02-17 02:07:37 +03:00
|
|
|
|
|
|
|
NS_IMETHOD Run() override {
|
2016-10-04 01:48:11 +03:00
|
|
|
MOZ_ASSERT(NS_IsMainThread() &&
|
|
|
|
(XRE_IsContentProcess() || XRE_IsGPUProcess()));
|
|
|
|
|
|
|
|
if (XRE_IsContentProcess()) {
|
|
|
|
dom::ContentChild* cc = dom::ContentChild::GetSingleton();
|
|
|
|
Unused << cc->SendGraphicsError(mMessage);
|
|
|
|
} else if (XRE_IsGPUProcess()) {
|
|
|
|
GPUParent* gp = GPUParent::GetSingleton();
|
|
|
|
Unused << gp->SendGraphicsError(mMessage);
|
|
|
|
}
|
|
|
|
|
2016-02-17 02:07:37 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
nsCString mMessage;
|
|
|
|
};
|
|
|
|
|
2014-11-18 01:16:55 +03:00
|
|
|
void CrashStatsLogForwarder::Log(const std::string& aString) {
|
2014-12-19 20:03:58 +03:00
|
|
|
MutexAutoLock lock(mMutex);
|
|
|
|
|
2014-11-18 01:16:55 +03:00
|
|
|
if (UpdateStringsVector(aString)) {
|
|
|
|
UpdateCrashReport();
|
|
|
|
}
|
2016-02-17 02:07:37 +03:00
|
|
|
|
|
|
|
// Add it to the parent strings
|
|
|
|
if (!XRE_IsParentProcess()) {
|
|
|
|
nsCString stringToSend(aString.c_str());
|
|
|
|
if (NS_IsMainThread()) {
|
2016-10-04 01:48:11 +03:00
|
|
|
if (XRE_IsContentProcess()) {
|
|
|
|
dom::ContentChild* cc = dom::ContentChild::GetSingleton();
|
|
|
|
Unused << cc->SendGraphicsError(stringToSend);
|
|
|
|
} else if (XRE_IsGPUProcess()) {
|
|
|
|
GPUParent* gp = GPUParent::GetSingleton();
|
|
|
|
Unused << gp->SendGraphicsError(stringToSend);
|
|
|
|
}
|
2016-02-17 02:07:37 +03:00
|
|
|
} else {
|
|
|
|
nsCOMPtr<nsIRunnable> r1 = new LogForwarderEvent(stringToSend);
|
|
|
|
NS_DispatchToMainThread(r1);
|
|
|
|
}
|
|
|
|
}
|
2014-11-18 01:16:55 +03:00
|
|
|
}
|
2014-09-18 01:23:08 +04:00
|
|
|
|
2016-04-26 03:23:21 +03:00
|
|
|
class CrashTelemetryEvent : public Runnable {
|
2019-04-11 15:36:51 +03:00
|
|
|
virtual ~CrashTelemetryEvent() = default;
|
2015-10-14 09:24:00 +03:00
|
|
|
|
2018-02-12 23:44:40 +03:00
|
|
|
public:
|
|
|
|
NS_INLINE_DECL_REFCOUNTING_INHERITED(CrashTelemetryEvent, Runnable)
|
2015-10-14 09:24:00 +03:00
|
|
|
|
2017-06-12 22:34:10 +03:00
|
|
|
explicit CrashTelemetryEvent(uint32_t aReason)
|
|
|
|
: mozilla::Runnable("CrashTelemetryEvent"), mReason(aReason) {}
|
2015-10-14 09:24:00 +03:00
|
|
|
|
|
|
|
NS_IMETHOD Run() override {
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
Telemetry::Accumulate(Telemetry::GFX_CRASH, mReason);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
uint32_t mReason;
|
|
|
|
};
|
|
|
|
|
|
|
|
void CrashStatsLogForwarder::CrashAction(LogReason aReason) {
|
2016-10-08 12:14:49 +03:00
|
|
|
#ifndef RELEASE_OR_BETA
|
2015-10-14 09:24:00 +03:00
|
|
|
// Non-release builds crash by default, but will use telemetry
|
|
|
|
// if this environment variable is present.
|
2015-11-09 09:28:00 +03:00
|
|
|
static bool useTelemetry = gfxEnv::GfxDevCrashTelemetry();
|
2015-10-14 09:24:00 +03:00
|
|
|
#else
|
2015-10-28 16:31:00 +03:00
|
|
|
// Release builds use telemetry by default, but will crash instead
|
|
|
|
// if this environment variable is present.
|
2015-11-09 09:28:00 +03:00
|
|
|
static bool useTelemetry = !gfxEnv::GfxDevCrashMozCrash();
|
2015-10-14 09:24:00 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (useTelemetry) {
|
|
|
|
// The callers need to assure that aReason is in the range
|
|
|
|
// that the telemetry call below supports.
|
|
|
|
if (NS_IsMainThread()) {
|
|
|
|
Telemetry::Accumulate(Telemetry::GFX_CRASH, (uint32_t)aReason);
|
|
|
|
} else {
|
|
|
|
nsCOMPtr<nsIRunnable> r1 = new CrashTelemetryEvent((uint32_t)aReason);
|
|
|
|
NS_DispatchToMainThread(r1);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// ignoring aReason, we can get the information we need from the stack
|
|
|
|
MOZ_CRASH("GFX_CRASH");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(SRGBOverrideObserver, nsIObserver, nsISupportsWeakReference)
|
2013-09-07 07:08:36 +04:00
|
|
|
|
2010-05-27 09:05:30 +04:00
|
|
|
#define GFX_DOWNLOADABLE_FONTS_ENABLED "gfx.downloadable_fonts.enabled"
|
|
|
|
|
2012-03-09 06:05:40 +04:00
|
|
|
#define GFX_PREF_FALLBACK_USE_CMAPS \
|
|
|
|
"gfx.font_rendering.fallback.always_use_cmaps"
|
2009-10-07 21:16:52 +04:00
|
|
|
|
2012-09-06 08:57:54 +04:00
|
|
|
#define GFX_PREF_OPENTYPE_SVG "gfx.font_rendering.opentype_svg.enabled"
|
|
|
|
|
2013-09-11 05:36:57 +04:00
|
|
|
#define GFX_PREF_WORD_CACHE_CHARLIMIT "gfx.font_rendering.wordcache.charlimit"
|
2013-09-11 05:36:57 +04:00
|
|
|
#define GFX_PREF_WORD_CACHE_MAXENTRIES "gfx.font_rendering.wordcache.maxentries"
|
2013-09-11 05:36:57 +04:00
|
|
|
|
2011-12-10 02:32:29 +04:00
|
|
|
#define GFX_PREF_GRAPHITE_SHAPING "gfx.font_rendering.graphite.enabled"
|
2019-05-20 17:29:15 +03:00
|
|
|
#if defined(XP_MACOSX)
|
2019-05-21 21:54:09 +03:00
|
|
|
# define GFX_PREF_CORETEXT_SHAPING "gfx.font_rendering.coretext.enabled"
|
2019-05-20 17:29:15 +03:00
|
|
|
#endif
|
2011-12-10 02:32:29 +04:00
|
|
|
|
2011-12-06 16:39:19 +04:00
|
|
|
#define BIDI_NUMERAL_PREF "bidi.numeral"
|
|
|
|
|
2014-01-09 22:17:29 +04:00
|
|
|
#define GFX_PREF_CMS_FORCE_SRGB "gfx.color_management.force_srgb"
|
|
|
|
|
2018-04-05 20:53:56 +03:00
|
|
|
#define FONT_VARIATIONS_PREF "layout.css.font-variations.enabled"
|
|
|
|
|
2014-01-09 22:17:29 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
SRGBOverrideObserver::Observe(nsISupports* aSubject, const char* aTopic,
|
|
|
|
const char16_t* someData) {
|
2016-07-20 07:07:53 +03:00
|
|
|
NS_ASSERTION(NS_strcmp(someData, (u"" GFX_PREF_CMS_FORCE_SRGB)) == 0,
|
2014-01-09 22:17:29 +04:00
|
|
|
"Restarting CMS on wrong pref!");
|
|
|
|
ShutdownCMS();
|
2015-02-06 02:18:00 +03:00
|
|
|
// Update current cms profile.
|
|
|
|
gfxPlatform::CreateCMSOutputProfile();
|
2014-01-09 22:17:29 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-12 06:30:16 +04:00
|
|
|
static const char* kObservedPrefs[] = {"gfx.downloadable_fonts.",
|
|
|
|
"gfx.font_rendering.", BIDI_NUMERAL_PREF,
|
2012-07-30 18:20:58 +04:00
|
|
|
nullptr};
|
2011-06-12 06:30:16 +04:00
|
|
|
|
2018-07-06 00:43:02 +03:00
|
|
|
static void FontPrefChanged(const char* aPref, void* aData) {
|
|
|
|
MOZ_ASSERT(aPref);
|
2011-06-12 06:30:16 +04:00
|
|
|
NS_ASSERTION(gfxPlatform::GetPlatform(), "the singleton instance has gone");
|
2018-07-06 00:43:02 +03:00
|
|
|
gfxPlatform::GetPlatform()->FontsPrefsChanged(aPref);
|
2010-05-27 09:05:30 +04:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-08-10 18:15:12 +03:00
|
|
|
void gfxPlatform::OnMemoryPressure(layers::MemoryPressureReason aWhy) {
|
2013-12-05 08:52:03 +04:00
|
|
|
Factory::PurgeAllCaches();
|
2014-09-04 21:28:43 +04:00
|
|
|
gfxGradientCache::PurgeAllCaches();
|
2018-08-21 19:40:36 +03:00
|
|
|
gfxFontMissingGlyphs::Purge();
|
2018-08-10 18:15:12 +03:00
|
|
|
PurgeSkiaFontCache();
|
2018-08-20 16:23:54 +03:00
|
|
|
if (XRE_IsParentProcess()) {
|
|
|
|
layers::CompositorManagerChild* manager =
|
|
|
|
CompositorManagerChild::GetInstance();
|
|
|
|
if (manager) {
|
|
|
|
manager->SendNotifyMemoryPressure();
|
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2013-11-01 17:52:06 +04:00
|
|
|
}
|
|
|
|
|
2010-05-27 09:05:30 +04:00
|
|
|
gfxPlatform::gfxPlatform()
|
2018-06-16 17:42:33 +03:00
|
|
|
: mHasVariationFontSupport(false),
|
|
|
|
mAzureCanvasBackendCollector(this, &gfxPlatform::GetAzureBackendInfo),
|
2015-03-25 01:04:44 +03:00
|
|
|
mApzSupportCollector(this, &gfxPlatform::GetApzSupportInfo),
|
2016-07-21 09:08:39 +03:00
|
|
|
mTilesInfoCollector(this, &gfxPlatform::GetTilesSupportInfo),
|
2018-11-16 05:13:56 +03:00
|
|
|
mFrameStatsCollector(this, &gfxPlatform::GetFrameStats),
|
2019-06-05 01:50:47 +03:00
|
|
|
mCMSInfoCollector(this, &gfxPlatform::GetCMSSupportInfo),
|
2015-07-20 00:50:35 +03:00
|
|
|
mCompositorBackend(layers::LayersBackend::LAYERS_NONE),
|
2015-08-27 01:33:16 +03:00
|
|
|
mScreenDepth(0) {
|
2010-05-27 09:05:30 +04:00
|
|
|
mAllowDownloadableFonts = UNINITIALIZED_VALUE;
|
2012-03-09 06:05:40 +04:00
|
|
|
mFallbackUsesCmaps = UNINITIALIZED_VALUE;
|
|
|
|
|
2013-09-11 05:36:57 +04:00
|
|
|
mWordCacheCharLimit = UNINITIALIZED_VALUE;
|
2013-09-11 05:36:57 +04:00
|
|
|
mWordCacheMaxEntries = UNINITIALIZED_VALUE;
|
2011-12-10 02:32:29 +04:00
|
|
|
mGraphiteShapingEnabled = UNINITIALIZED_VALUE;
|
2013-05-16 20:32:41 +04:00
|
|
|
mOpenTypeSVGEnabled = UNINITIALIZED_VALUE;
|
2011-12-06 16:39:19 +04:00
|
|
|
mBidiNumeralOption = UNINITIALIZED_VALUE;
|
2012-01-28 02:38:00 +04:00
|
|
|
|
2018-03-15 08:48:54 +03:00
|
|
|
InitBackendPrefs(GetBackendPrefs());
|
2016-09-23 18:40:25 +03:00
|
|
|
|
|
|
|
mTotalSystemMemory = PR_GetPhysicalMemorySize();
|
2014-07-09 23:24:49 +04:00
|
|
|
|
2015-09-18 00:23:13 +03:00
|
|
|
VRManager::ManagerInit();
|
2010-05-27 09:05:30 +04:00
|
|
|
}
|
2008-01-31 03:23:36 +03:00
|
|
|
|
2005-11-29 23:29:45 +03:00
|
|
|
gfxPlatform* gfxPlatform::GetPlatform() {
|
2011-04-21 23:36:49 +04:00
|
|
|
if (!gPlatform) {
|
2017-06-22 20:45:48 +03:00
|
|
|
MOZ_RELEASE_ASSERT(!XRE_IsContentProcess(),
|
|
|
|
"Content Process should have called InitChild() before "
|
|
|
|
"first GetPlatform()");
|
2011-04-21 23:36:49 +04:00
|
|
|
Init();
|
|
|
|
}
|
2007-03-30 01:48:46 +04:00
|
|
|
return gPlatform;
|
|
|
|
}
|
|
|
|
|
2015-07-20 00:50:35 +03:00
|
|
|
bool gfxPlatform::Initialized() { return !!gPlatform; }
|
|
|
|
|
2019-02-26 01:07:19 +03:00
|
|
|
/* static */
|
|
|
|
void gfxPlatform::InitChild(const ContentDeviceData& aData) {
|
2017-06-22 20:45:48 +03:00
|
|
|
MOZ_ASSERT(XRE_IsContentProcess());
|
|
|
|
MOZ_RELEASE_ASSERT(!gPlatform,
|
|
|
|
"InitChild() should be called before first GetPlatform()");
|
|
|
|
// Make the provided initial ContentDeviceData available to the init
|
|
|
|
// routines, so they don't have to do a sync request from the parent.
|
|
|
|
gContentDeviceInitData = &aData;
|
|
|
|
Init();
|
|
|
|
gContentDeviceInitData = nullptr;
|
|
|
|
}
|
|
|
|
|
2013-12-11 03:10:01 +04:00
|
|
|
void RecordingPrefChanged(const char* aPrefName, void* aClosure) {
|
2013-04-09 21:37:56 +04:00
|
|
|
if (Preferences::GetBool("gfx.2d.recording", false)) {
|
|
|
|
nsAutoCString fileName;
|
2017-07-31 07:23:50 +03:00
|
|
|
nsAutoString prefFileName;
|
|
|
|
nsresult rv = Preferences::GetString("gfx.2d.recordingfile", prefFileName);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2017-12-16 18:13:30 +03:00
|
|
|
CopyUTF16toUTF8(prefFileName, fileName);
|
2013-04-09 21:37:56 +04:00
|
|
|
} else {
|
2013-11-07 03:11:18 +04:00
|
|
|
nsCOMPtr<nsIFile> tmpFile;
|
|
|
|
if (NS_FAILED(NS_GetSpecialDirectory(NS_OS_TEMP_DIR,
|
|
|
|
getter_AddRefs(tmpFile)))) {
|
2013-12-11 03:10:01 +04:00
|
|
|
return;
|
2013-11-07 03:11:18 +04:00
|
|
|
}
|
|
|
|
fileName.AppendPrintf("moz2drec_%i_%i.aer", XRE_GetProcessType(),
|
|
|
|
getpid());
|
|
|
|
|
|
|
|
nsresult rv = tmpFile->AppendNative(fileName);
|
|
|
|
if (NS_FAILED(rv)) return;
|
|
|
|
|
2017-12-16 18:13:30 +03:00
|
|
|
#ifdef XP_WIN
|
|
|
|
rv = tmpFile->GetPath(prefFileName);
|
|
|
|
CopyUTF16toUTF8(prefFileName, fileName);
|
|
|
|
#else
|
2013-11-07 03:11:18 +04:00
|
|
|
rv = tmpFile->GetNativePath(fileName);
|
2017-12-16 18:13:30 +03:00
|
|
|
#endif
|
2013-11-07 03:11:18 +04:00
|
|
|
if (NS_FAILED(rv)) return;
|
2013-04-09 21:37:56 +04:00
|
|
|
}
|
|
|
|
|
2017-12-16 18:13:30 +03:00
|
|
|
#ifdef XP_WIN
|
|
|
|
gPlatform->mRecorder =
|
|
|
|
Factory::CreateEventRecorderForFile(prefFileName.BeginReading());
|
|
|
|
#else
|
2013-04-09 21:37:56 +04:00
|
|
|
gPlatform->mRecorder =
|
|
|
|
Factory::CreateEventRecorderForFile(fileName.BeginReading());
|
2017-12-16 18:13:30 +03:00
|
|
|
#endif
|
2013-11-07 03:11:18 +04:00
|
|
|
printf_stderr("Recording to %s\n", fileName.get());
|
2013-04-09 21:37:56 +04:00
|
|
|
Factory::SetGlobalEventRecorder(gPlatform->mRecorder);
|
|
|
|
} else {
|
|
|
|
Factory::SetGlobalEventRecorder(nullptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-23 13:00:37 +03:00
|
|
|
#define WR_DEBUG_PREF "gfx.webrender.debug"
|
|
|
|
|
2019-02-17 12:18:01 +03:00
|
|
|
static void WebRenderDebugPrefChangeCallback(const char* aPrefName, void*) {
|
2019-03-07 02:01:11 +03:00
|
|
|
wr::DebugFlags flags{0};
|
2017-11-23 18:01:48 +03:00
|
|
|
#define GFX_WEBRENDER_DEBUG(suffix, bit) \
|
|
|
|
if (Preferences::GetBool(WR_DEBUG_PREF suffix, false)) { \
|
|
|
|
flags |= (bit); \
|
2017-09-27 06:58:56 +03:00
|
|
|
}
|
2017-08-23 13:00:37 +03:00
|
|
|
|
2019-03-07 02:01:11 +03:00
|
|
|
GFX_WEBRENDER_DEBUG(".profiler", wr::DebugFlags_PROFILER_DBG)
|
|
|
|
GFX_WEBRENDER_DEBUG(".render-targets", wr::DebugFlags_RENDER_TARGET_DBG)
|
|
|
|
GFX_WEBRENDER_DEBUG(".texture-cache", wr::DebugFlags_TEXTURE_CACHE_DBG)
|
|
|
|
GFX_WEBRENDER_DEBUG(".gpu-time-queries", wr::DebugFlags_GPU_TIME_QUERIES)
|
|
|
|
GFX_WEBRENDER_DEBUG(".gpu-sample-queries", wr::DebugFlags_GPU_SAMPLE_QUERIES)
|
|
|
|
GFX_WEBRENDER_DEBUG(".disable-batching", wr::DebugFlags_DISABLE_BATCHING)
|
|
|
|
GFX_WEBRENDER_DEBUG(".epochs", wr::DebugFlags_EPOCHS)
|
|
|
|
GFX_WEBRENDER_DEBUG(".compact-profiler", wr::DebugFlags_COMPACT_PROFILER)
|
|
|
|
GFX_WEBRENDER_DEBUG(".echo-driver-messages",
|
|
|
|
wr::DebugFlags_ECHO_DRIVER_MESSAGES)
|
|
|
|
GFX_WEBRENDER_DEBUG(".new-frame-indicator",
|
|
|
|
wr::DebugFlags_NEW_FRAME_INDICATOR)
|
|
|
|
GFX_WEBRENDER_DEBUG(".new-scene-indicator",
|
|
|
|
wr::DebugFlags_NEW_SCENE_INDICATOR)
|
|
|
|
GFX_WEBRENDER_DEBUG(".show-overdraw", wr::DebugFlags_SHOW_OVERDRAW)
|
|
|
|
GFX_WEBRENDER_DEBUG(".gpu-cache", wr::DebugFlags_GPU_CACHE_DBG)
|
|
|
|
GFX_WEBRENDER_DEBUG(".slow-frame-indicator",
|
|
|
|
wr::DebugFlags_SLOW_FRAME_INDICATOR)
|
|
|
|
GFX_WEBRENDER_DEBUG(".texture-cache.clear-evicted",
|
|
|
|
wr::DebugFlags_TEXTURE_CACHE_DBG_CLEAR_EVICTED)
|
|
|
|
GFX_WEBRENDER_DEBUG(".picture-caching", wr::DebugFlags_PICTURE_CACHING_DBG)
|
|
|
|
GFX_WEBRENDER_DEBUG(".primitives", wr::DebugFlags_PRIMITIVE_DBG)
|
2019-03-06 23:32:32 +03:00
|
|
|
// Bit 18 is for the zoom display, which requires the mouse position and thus
|
|
|
|
// currently only works in wrench.
|
2019-03-07 02:01:11 +03:00
|
|
|
GFX_WEBRENDER_DEBUG(".small-screen", wr::DebugFlags_SMALL_SCREEN)
|
2019-04-25 22:29:15 +03:00
|
|
|
GFX_WEBRENDER_DEBUG(".disable-opaque-pass",
|
|
|
|
wr::DebugFlags_DISABLE_OPAQUE_PASS)
|
|
|
|
GFX_WEBRENDER_DEBUG(".disable-alpha-pass", wr::DebugFlags_DISABLE_ALPHA_PASS)
|
|
|
|
GFX_WEBRENDER_DEBUG(".disable-clip-masks", wr::DebugFlags_DISABLE_CLIP_MASKS)
|
|
|
|
GFX_WEBRENDER_DEBUG(".disable-text-prims", wr::DebugFlags_DISABLE_TEXT_PRIMS)
|
|
|
|
GFX_WEBRENDER_DEBUG(".disable-gradient-prims",
|
|
|
|
wr::DebugFlags_DISABLE_GRADIENT_PRIMS)
|
2017-11-23 18:01:48 +03:00
|
|
|
#undef GFX_WEBRENDER_DEBUG
|
|
|
|
|
2019-03-07 02:01:11 +03:00
|
|
|
gfx::gfxVars::SetWebRenderDebugFlags(flags.bits);
|
2017-08-23 13:00:37 +03:00
|
|
|
}
|
|
|
|
|
2016-03-21 19:08:34 +03:00
|
|
|
#if defined(USE_SKIA)
|
|
|
|
static uint32_t GetSkiaGlyphCacheSize() {
|
|
|
|
// Only increase font cache size on non-android to save memory.
|
|
|
|
# if !defined(MOZ_WIDGET_ANDROID)
|
2017-06-07 20:11:17 +03:00
|
|
|
// 10mb as the default pref cache size on desktop due to talos perf tweaking.
|
2016-03-21 19:08:34 +03:00
|
|
|
// Chromium uses 20mb and skia default uses 2mb.
|
|
|
|
// We don't need to change the font cache count since we usually
|
|
|
|
// cache thrash due to asian character sets in talos.
|
2018-05-10 10:56:09 +03:00
|
|
|
// Only increase memory on the content process
|
2019-06-26 03:38:09 +03:00
|
|
|
uint32_t cacheSize =
|
2019-07-22 05:10:14 +03:00
|
|
|
StaticPrefs::gfx_content_skia_font_cache_size_AtStartup() * 1024 * 1024;
|
2016-03-21 19:08:34 +03:00
|
|
|
if (mozilla::BrowserTabsRemoteAutostart()) {
|
|
|
|
return XRE_IsContentProcess() ? cacheSize : kDefaultGlyphCacheSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
return cacheSize;
|
|
|
|
# else
|
|
|
|
return kDefaultGlyphCacheSize;
|
|
|
|
# endif // MOZ_WIDGET_ANDROID
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-09-15 02:24:36 +03:00
|
|
|
class WebRenderMemoryReporter final : public nsIMemoryReporter {
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIMEMORYREPORTER
|
|
|
|
|
|
|
|
private:
|
|
|
|
~WebRenderMemoryReporter() = default;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Memory reporter for WebRender.
|
|
|
|
//
|
|
|
|
// The reporting within WebRender is manual and incomplete. We could do a much
|
|
|
|
// more thorough job by depending on the malloc_size_of crate, but integrating
|
|
|
|
// that into WebRender is tricky [1].
|
|
|
|
//
|
|
|
|
// So the idea is to start with manual reporting for the large allocations
|
|
|
|
// detected by DMD, and see how much that can cover in practice (which may
|
|
|
|
// require a few rounds of iteration). If that approach turns out to be
|
|
|
|
// fundamentally insufficient, we can either duplicate more of the
|
|
|
|
// malloc_size_of functionality in WebRender, or deal with the complexity of a
|
|
|
|
// gecko-only crate dependency.
|
|
|
|
//
|
|
|
|
// [1] See https://bugzilla.mozilla.org/show_bug.cgi?id=1480293#c1
|
|
|
|
struct WebRenderMemoryReporterHelper {
|
|
|
|
WebRenderMemoryReporterHelper(nsIHandleReportCallback* aCallback,
|
|
|
|
nsISupports* aData)
|
|
|
|
: mCallback(aCallback), mData(aData) {}
|
|
|
|
nsCOMPtr<nsIHandleReportCallback> mCallback;
|
|
|
|
nsCOMPtr<nsISupports> mData;
|
|
|
|
|
|
|
|
void Report(size_t aBytes, const char* aName) const {
|
2018-09-25 19:58:13 +03:00
|
|
|
nsPrintfCString path("explicit/gfx/webrender/%s", aName);
|
|
|
|
nsCString desc(NS_LITERAL_CSTRING("CPU heap memory used by WebRender"));
|
|
|
|
ReportInternal(aBytes, path, desc, nsIMemoryReporter::KIND_HEAP);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ReportTexture(size_t aBytes, const char* aName) const {
|
|
|
|
nsPrintfCString path("gfx/webrender/textures/%s", aName);
|
|
|
|
nsCString desc(NS_LITERAL_CSTRING("GPU texture memory used by WebRender"));
|
|
|
|
ReportInternal(aBytes, path, desc, nsIMemoryReporter::KIND_OTHER);
|
|
|
|
}
|
|
|
|
|
2018-10-31 01:13:32 +03:00
|
|
|
void ReportTotalGPUBytes(size_t aBytes) const {
|
|
|
|
nsCString path(NS_LITERAL_CSTRING("gfx/webrender/total-gpu-bytes"));
|
|
|
|
nsCString desc(NS_LITERAL_CSTRING(
|
|
|
|
"Total GPU bytes used by WebRender (should match textures/ sum)"));
|
|
|
|
ReportInternal(aBytes, path, desc, nsIMemoryReporter::KIND_OTHER);
|
|
|
|
}
|
|
|
|
|
2018-09-25 19:58:13 +03:00
|
|
|
void ReportInternal(size_t aBytes, nsACString& aPath, nsACString& aDesc,
|
|
|
|
int32_t aKind) const {
|
2018-09-15 02:25:38 +03:00
|
|
|
// Generally, memory reporters pass the empty string as the process name to
|
|
|
|
// indicate "current process". However, if we're using a GPU process, the
|
|
|
|
// measurements will actually take place in that process, and it's easier to
|
|
|
|
// just note that here rather than trying to invoke the memory reporter in
|
|
|
|
// the GPU process.
|
|
|
|
nsAutoCString processName;
|
|
|
|
if (gfxConfig::IsEnabled(Feature::GPU_PROCESS)) {
|
|
|
|
GPUParent::GetGPUProcessName(processName);
|
|
|
|
}
|
|
|
|
|
2018-09-25 19:58:13 +03:00
|
|
|
mCallback->Callback(processName, aPath, aKind,
|
|
|
|
nsIMemoryReporter::UNITS_BYTES, aBytes, aDesc, mData);
|
2018-09-15 02:24:36 +03:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static void FinishAsyncMemoryReport() {
|
|
|
|
nsCOMPtr<nsIMemoryReporterManager> imgr =
|
|
|
|
do_GetService("@mozilla.org/memory-reporter-manager;1");
|
|
|
|
if (imgr) {
|
|
|
|
imgr->EndReport();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-11 22:19:59 +03:00
|
|
|
// clang-format off
|
|
|
|
// (For some reason, clang-format gets the second macro right, but totally mangles the first).
|
|
|
|
#define REPORT_INTERNER(id) \
|
2019-01-18 03:45:13 +03:00
|
|
|
helper.Report(aReport.interning.interners.id, \
|
2019-01-11 22:19:59 +03:00
|
|
|
"interning/" #id "/interners");
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
#define REPORT_DATA_STORE(id) \
|
2019-01-18 03:45:13 +03:00
|
|
|
helper.Report(aReport.interning.data_stores.id, \
|
2019-01-11 22:19:59 +03:00
|
|
|
"interning/" #id "/data-stores");
|
|
|
|
|
2018-09-15 02:24:36 +03:00
|
|
|
NS_IMPL_ISUPPORTS(WebRenderMemoryReporter, nsIMemoryReporter)
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
WebRenderMemoryReporter::CollectReports(nsIHandleReportCallback* aHandleReport,
|
|
|
|
nsISupports* aData, bool aAnonymize) {
|
|
|
|
MOZ_ASSERT(XRE_IsParentProcess());
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
layers::CompositorManagerChild* manager =
|
|
|
|
CompositorManagerChild::GetInstance();
|
|
|
|
if (!manager) {
|
|
|
|
FinishAsyncMemoryReport();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WebRenderMemoryReporterHelper helper(aHandleReport, aData);
|
|
|
|
manager->SendReportMemory(
|
|
|
|
[=](wr::MemoryReport aReport) {
|
2018-09-25 19:58:13 +03:00
|
|
|
// CPU Memory.
|
2018-09-15 02:24:36 +03:00
|
|
|
helper.Report(aReport.clip_stores, "clip-stores");
|
|
|
|
helper.Report(aReport.gpu_cache_metadata, "gpu-cache/metadata");
|
|
|
|
helper.Report(aReport.gpu_cache_cpu_mirror, "gpu-cache/cpu-mirror");
|
|
|
|
helper.Report(aReport.render_tasks, "render-tasks");
|
|
|
|
helper.Report(aReport.hit_testers, "hit-testers");
|
2018-09-25 19:58:13 +03:00
|
|
|
helper.Report(aReport.fonts, "resource-cache/fonts");
|
2018-09-19 20:36:19 +03:00
|
|
|
helper.Report(aReport.images, "resource-cache/images");
|
|
|
|
helper.Report(aReport.rasterized_blobs,
|
|
|
|
"resource-cache/rasterized-blobs");
|
2018-12-01 06:05:56 +03:00
|
|
|
helper.Report(aReport.shader_cache, "shader-cache");
|
2019-01-11 22:19:59 +03:00
|
|
|
|
|
|
|
WEBRENDER_FOR_EACH_INTERNER(REPORT_INTERNER);
|
|
|
|
WEBRENDER_FOR_EACH_INTERNER(REPORT_DATA_STORE);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-09-25 19:58:13 +03:00
|
|
|
// GPU Memory.
|
|
|
|
helper.ReportTexture(aReport.gpu_cache_textures, "gpu-cache");
|
|
|
|
helper.ReportTexture(aReport.vertex_data_textures, "vertex-data");
|
|
|
|
helper.ReportTexture(aReport.render_target_textures, "render-targets");
|
|
|
|
helper.ReportTexture(aReport.texture_cache_textures, "texture-cache");
|
2018-10-17 20:24:31 +03:00
|
|
|
helper.ReportTexture(aReport.depth_target_textures, "depth-targets");
|
2018-11-13 06:15:51 +03:00
|
|
|
helper.ReportTexture(aReport.swap_chain, "swap-chains");
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-09-15 02:24:36 +03:00
|
|
|
FinishAsyncMemoryReport();
|
|
|
|
},
|
2018-12-11 22:22:26 +03:00
|
|
|
[](mozilla::ipc::ResponseRejectReason&& aReason) {
|
2018-09-15 02:24:36 +03:00
|
|
|
FinishAsyncMemoryReport();
|
|
|
|
});
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2019-01-11 22:19:59 +03:00
|
|
|
#undef REPORT_INTERNER
|
|
|
|
#undef REPORT_DATA_STORE
|
|
|
|
|
2018-11-23 00:36:09 +03:00
|
|
|
static const char* const WR_ROLLOUT_PREF = "gfx.webrender.all.qualified";
|
2019-05-26 17:32:42 +03:00
|
|
|
static const bool WR_ROLLOUT_PREF_DEFAULTVALUE = true;
|
|
|
|
static const char* const WR_ROLLOUT_DEFAULT_PREF =
|
2018-11-23 00:36:09 +03:00
|
|
|
"gfx.webrender.all.qualified.default";
|
2019-05-26 17:32:42 +03:00
|
|
|
static const bool WR_ROLLOUT_DEFAULT_PREF_DEFAULTVALUE = false;
|
2018-11-23 00:36:09 +03:00
|
|
|
static const char* const WR_ROLLOUT_PREF_OVERRIDE =
|
|
|
|
"gfx.webrender.all.qualified.gfxPref-default-override";
|
|
|
|
static const char* const WR_ROLLOUT_HW_QUALIFIED_OVERRIDE =
|
|
|
|
"gfx.webrender.all.qualified.hardware-override";
|
|
|
|
static const char* const PROFILE_BEFORE_CHANGE_TOPIC = "profile-before-change";
|
|
|
|
|
|
|
|
// If the "gfx.webrender.all.qualified" pref is true we want to enable
|
|
|
|
// WebRender for qualified hardware. This pref may be set by the Normandy
|
|
|
|
// Preference Rollout feature. The Normandy pref rollout code sets default
|
|
|
|
// values on rolled out prefs on every startup. Default pref values are not
|
|
|
|
// persisted; they only exist in memory for that session. Gfx starts up
|
|
|
|
// before Normandy does. So it's too early to observe the WR qualified pref
|
|
|
|
// changed by Normandy rollout on gfx startup. So we add a shutdown observer to
|
|
|
|
// save the default value on shutdown, and read the saved value on startup
|
|
|
|
// instead.
|
|
|
|
class WrRolloutPrefShutdownSaver : public nsIObserver {
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
NS_IMETHOD Observe(nsISupports*, const char* aTopic,
|
|
|
|
const char16_t*) override {
|
|
|
|
if (strcmp(PROFILE_BEFORE_CHANGE_TOPIC, aTopic) != 0) {
|
|
|
|
// Not the observer we're looking for, move along.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
SaveRolloutPref();
|
|
|
|
|
|
|
|
// Shouldn't receive another notification, remove the observer.
|
|
|
|
RefPtr<WrRolloutPrefShutdownSaver> kungFuDeathGrip(this);
|
|
|
|
nsCOMPtr<nsIObserverService> observerService =
|
|
|
|
mozilla::services::GetObserverService();
|
|
|
|
if (NS_WARN_IF(!observerService)) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
observerService->RemoveObserver(this, PROFILE_BEFORE_CHANGE_TOPIC);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void AddShutdownObserver() {
|
|
|
|
MOZ_ASSERT(XRE_IsParentProcess());
|
|
|
|
nsCOMPtr<nsIObserverService> observerService =
|
|
|
|
mozilla::services::GetObserverService();
|
|
|
|
if (NS_WARN_IF(!observerService)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
RefPtr<WrRolloutPrefShutdownSaver> wrRolloutSaver =
|
|
|
|
new WrRolloutPrefShutdownSaver();
|
|
|
|
observerService->AddObserver(wrRolloutSaver, PROFILE_BEFORE_CHANGE_TOPIC,
|
|
|
|
false);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual ~WrRolloutPrefShutdownSaver() = default;
|
|
|
|
|
|
|
|
void SaveRolloutPref() {
|
|
|
|
if (Preferences::HasUserValue(WR_ROLLOUT_PREF) ||
|
|
|
|
Preferences::GetType(WR_ROLLOUT_PREF) == nsIPrefBranch::PREF_INVALID) {
|
|
|
|
// Don't need to create a backup of default value, because either:
|
|
|
|
// 1. the user or the WR SHIELD study has set a user pref value, or
|
|
|
|
// 2. we've not had a default pref set by Normandy that needs to be saved
|
|
|
|
// for reading before Normandy has started up.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool defaultValue =
|
|
|
|
Preferences::GetBool(WR_ROLLOUT_PREF, false, PrefValueKind::Default);
|
2019-05-26 17:32:42 +03:00
|
|
|
Preferences::SetBool(WR_ROLLOUT_DEFAULT_PREF, defaultValue);
|
2018-11-23 00:36:09 +03:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-05-26 17:30:37 +03:00
|
|
|
static void FrameRatePrefChanged(const char* aPref, void*) {
|
|
|
|
int32_t newRate = gfxPlatform::ForceSoftwareVsync()
|
|
|
|
? gfxPlatform::GetSoftwareVsyncRate()
|
|
|
|
: -1;
|
|
|
|
if (newRate != gLastUsedFrameRate) {
|
|
|
|
gLastUsedFrameRate = newRate;
|
|
|
|
gfxPlatform::ReInitFrameRate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-23 00:36:09 +03:00
|
|
|
NS_IMPL_ISUPPORTS(WrRolloutPrefShutdownSaver, nsIObserver)
|
2018-09-15 02:24:36 +03:00
|
|
|
|
2007-03-30 01:48:46 +04:00
|
|
|
void gfxPlatform::Init() {
|
2016-10-26 02:25:52 +03:00
|
|
|
MOZ_RELEASE_ASSERT(!XRE_IsGPUProcess(), "GFX: Not allowed in GPU process.");
|
2018-11-14 21:07:28 +03:00
|
|
|
MOZ_RELEASE_ASSERT(!XRE_IsRDDProcess(), "GFX: Not allowed in RDD process.");
|
2016-06-06 18:17:23 +03:00
|
|
|
MOZ_RELEASE_ASSERT(NS_IsMainThread(), "GFX: Not in main thread.");
|
2010-02-24 20:57:57 +03:00
|
|
|
|
2014-03-04 21:26:33 +04:00
|
|
|
if (gEverInitialized) {
|
|
|
|
MOZ_CRASH("Already started???");
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2016-08-04 21:33:42 +03:00
|
|
|
gEverInitialized = true;
|
2014-02-13 21:38:40 +04:00
|
|
|
|
2016-06-03 21:54:56 +03:00
|
|
|
gfxVars::Initialize();
|
|
|
|
|
2016-06-11 04:00:40 +03:00
|
|
|
gfxConfig::Init();
|
2016-11-02 23:57:18 +03:00
|
|
|
|
2016-11-11 03:25:52 +03:00
|
|
|
if (XRE_IsParentProcess() || recordreplay::IsRecordingOrReplaying()) {
|
2017-07-31 07:28:48 +03:00
|
|
|
GPUProcessManager::Initialize();
|
|
|
|
RDDProcessManager::Initialize();
|
2016-05-23 10:27:01 +03:00
|
|
|
|
2018-11-23 00:36:09 +03:00
|
|
|
if (Preferences::GetBool("media.wmf.skip-blacklist")) {
|
|
|
|
gfxVars::SetPDMWMFDisableD3D11Dlls(nsCString());
|
|
|
|
gfxVars::SetPDMWMFDisableD3D9Dlls(nsCString());
|
2018-11-30 13:46:48 +03:00
|
|
|
} else {
|
2018-11-23 00:36:09 +03:00
|
|
|
nsAutoCString d3d11;
|
|
|
|
Preferences::GetCString("media.wmf.disable-d3d11-for-dlls", d3d11);
|
2017-07-31 07:28:48 +03:00
|
|
|
gfxVars::SetPDMWMFDisableD3D11Dlls(d3d11);
|
2018-11-23 00:36:09 +03:00
|
|
|
nsAutoCString d3d9;
|
|
|
|
Preferences::GetCString("media.wmf.disable-d3d9-for-dlls", d3d9);
|
2017-07-31 07:28:48 +03:00
|
|
|
gfxVars::SetPDMWMFDisableD3D9Dlls(d3d9);
|
2018-11-23 00:36:09 +03:00
|
|
|
}
|
|
|
|
|
2016-01-18 20:56:38 +03:00
|
|
|
nsCOMPtr<nsIFile> file;
|
2016-04-29 07:52:54 +03:00
|
|
|
nsresult rv = NS_GetSpecialDirectory(NS_GRE_DIR, getter_AddRefs(file));
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
gfxVars::SetGREDirectory(nsString());
|
2016-01-18 20:56:38 +03:00
|
|
|
} else {
|
|
|
|
nsAutoString path;
|
|
|
|
file->GetPath(path);
|
|
|
|
gfxVars::SetGREDirectory(nsString(path));
|
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2016-01-18 20:56:38 +03:00
|
|
|
|
2013-08-04 11:46:17 +04:00
|
|
|
if (XRE_IsParentProcess()) {
|
|
|
|
WrRolloutPrefShutdownSaver::AddShutdownObserver();
|
2019-04-25 13:17:16 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsIFile> profDir;
|
|
|
|
nsresult rv = NS_GetSpecialDirectory(NS_APP_PROFILE_DIR_STARTUP,
|
|
|
|
getter_AddRefs(profDir));
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
gfxVars::SetProfDirectory(nsString());
|
|
|
|
} else {
|
|
|
|
nsAutoString path;
|
|
|
|
profDir->GetPath(path);
|
|
|
|
gfxVars::SetProfDirectory(nsString(path));
|
|
|
|
}
|
|
|
|
|
2019-05-26 17:30:57 +03:00
|
|
|
nsAutoCString path;
|
|
|
|
Preferences::GetCString("layers.windowrecording.path", path);
|
|
|
|
gfxVars::SetLayersWindowRecordingPath(path);
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2013-08-04 11:46:17 +04:00
|
|
|
|
2016-01-18 20:56:38 +03:00
|
|
|
// Drop a note in the crash report if we end up forcing an option that could
|
|
|
|
// destabilize things. New items should be appended at the end (of an
|
|
|
|
// existing or in a new section), so that we don't have to know the version to
|
|
|
|
// interpret these cryptic strings.
|
2018-11-30 13:46:48 +03:00
|
|
|
{
|
2016-01-18 20:56:38 +03:00
|
|
|
nsAutoCString forcedPrefs;
|
|
|
|
// D2D prefs
|
2019-07-22 05:10:14 +03:00
|
|
|
forcedPrefs.AppendPrintf(
|
|
|
|
"FP(D%d%d", StaticPrefs::gfx_direct2d_disabled_AtStartup(),
|
|
|
|
StaticPrefs::gfx_direct2d_force_enabled_AtStartup());
|
2016-01-18 20:56:38 +03:00
|
|
|
// Layers prefs
|
2016-08-12 00:02:11 +03:00
|
|
|
forcedPrefs.AppendPrintf(
|
2019-07-22 05:10:14 +03:00
|
|
|
"-L%d%d%d%d",
|
|
|
|
StaticPrefs::layers_amd_switchable_gfx_enabled_AtStartup(),
|
|
|
|
StaticPrefs::layers_acceleration_disabled_AtStartup_DoNotUseDirectly(),
|
|
|
|
StaticPrefs::
|
|
|
|
layers_acceleration_force_enabled_AtStartup_DoNotUseDirectly(),
|
|
|
|
StaticPrefs::layers_d3d11_force_warp_AtStartup());
|
2016-01-18 20:56:38 +03:00
|
|
|
// WebGL prefs
|
2016-08-12 00:02:11 +03:00
|
|
|
forcedPrefs.AppendPrintf(
|
2019-06-29 00:56:43 +03:00
|
|
|
"-W%d%d%d%d%d%d%d%d", StaticPrefs::webgl_angle_force_d3d11(),
|
|
|
|
StaticPrefs::webgl_angle_force_warp(), StaticPrefs::webgl_disabled(),
|
|
|
|
StaticPrefs::webgl_disable_angle(), StaticPrefs::webgl_dxgl_enabled(),
|
|
|
|
StaticPrefs::webgl_force_enabled(),
|
|
|
|
StaticPrefs::webgl_force_layers_readback(),
|
|
|
|
StaticPrefs::webgl_msaa_force());
|
2016-01-18 20:56:38 +03:00
|
|
|
// Prefs that don't fit into any of the other sections
|
2019-06-26 03:38:09 +03:00
|
|
|
forcedPrefs.AppendPrintf("-T%d%d%d) ",
|
2019-07-22 05:10:14 +03:00
|
|
|
StaticPrefs::gfx_android_rgb16_force_AtStartup(),
|
2019-03-07 02:01:11 +03:00
|
|
|
0, // SkiaGL canvas no longer supported
|
2019-07-22 05:10:14 +03:00
|
|
|
StaticPrefs::layers_force_shmem_tiles_AtStartup());
|
2016-01-18 20:56:38 +03:00
|
|
|
ScopedGfxFeatureReporter::AppNote(forcedPrefs);
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
|
|
|
|
2016-10-28 20:22:47 +03:00
|
|
|
InitMoz2DLogging();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2013-08-04 11:46:17 +04:00
|
|
|
gGfxPlatformPrefsLock = new Mutex("gfxPlatform::gGfxPlatformPrefsLock");
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2010-08-28 18:18:41 +04:00
|
|
|
/* Initialize the GfxInfo service.
|
|
|
|
* Note: we can't call functions on GfxInfo that depend
|
|
|
|
* on gPlatform until after it has been initialized
|
|
|
|
* below. GfxInfo initialization annotates our
|
|
|
|
* crash reports so we want to do it before
|
|
|
|
* we try to load any drivers and do device detection
|
|
|
|
* incase that code crashes. See bug #591561. */
|
|
|
|
nsCOMPtr<nsIGfxInfo> gfxInfo;
|
|
|
|
/* this currently will only succeed on Windows */
|
2015-07-08 23:51:09 +03:00
|
|
|
gfxInfo = services::GetGfxInfo();
|
2010-08-28 18:18:41 +04:00
|
|
|
|
2018-10-11 23:34:04 +03:00
|
|
|
if (XRE_IsParentProcess()) {
|
|
|
|
// Some gfxVars must be initialized prior gPlatform for coherent results.
|
|
|
|
gfxVars::SetDXInterop2Blocked(IsDXInterop2Blocked());
|
|
|
|
gfxVars::SetDXNV12Blocked(IsDXNV12Blocked());
|
|
|
|
gfxVars::SetDXP010Blocked(IsDXP010Blocked());
|
|
|
|
gfxVars::SetDXP016Blocked(IsDXP016Blocked());
|
|
|
|
}
|
|
|
|
|
2005-11-29 23:29:45 +03:00
|
|
|
#if defined(XP_WIN)
|
2007-03-30 01:48:46 +04:00
|
|
|
gPlatform = new gfxWindowsPlatform;
|
2005-11-29 23:29:45 +03:00
|
|
|
#elif defined(XP_MACOSX)
|
2007-03-30 01:48:46 +04:00
|
|
|
gPlatform = new gfxPlatformMac;
|
2012-06-28 04:15:32 +04:00
|
|
|
#elif defined(MOZ_WIDGET_GTK)
|
2007-03-30 01:48:46 +04:00
|
|
|
gPlatform = new gfxPlatformGtk;
|
2010-05-11 21:27:36 +04:00
|
|
|
#elif defined(ANDROID)
|
|
|
|
gPlatform = new gfxAndroidPlatform;
|
2011-04-17 05:22:41 +04:00
|
|
|
#else
|
|
|
|
# error "No gfxPlatform implementation available"
|
2005-11-29 23:29:45 +03:00
|
|
|
#endif
|
2019-04-09 22:27:16 +03:00
|
|
|
gPlatform->PopulateScreenInfo();
|
2016-04-29 07:52:54 +03:00
|
|
|
gPlatform->InitAcceleration();
|
2017-04-24 17:06:06 +03:00
|
|
|
gPlatform->InitWebRenderConfig();
|
2019-05-26 17:30:14 +03:00
|
|
|
|
2018-12-18 08:54:28 +03:00
|
|
|
// When using WebRender, we defer initialization of the D3D11 devices until
|
|
|
|
// the (rare) cases where they're used. Note that the GPU process where
|
|
|
|
// WebRender runs doesn't initialize gfxPlatform and performs explicit
|
|
|
|
// initialization of the bits it needs.
|
2019-05-26 17:29:42 +03:00
|
|
|
if (!UseWebRender()) {
|
2018-12-18 08:54:28 +03:00
|
|
|
gPlatform->EnsureDevicesInitialized();
|
|
|
|
}
|
2017-06-06 23:18:00 +03:00
|
|
|
gPlatform->InitOMTPConfig();
|
2007-03-30 01:48:46 +04:00
|
|
|
|
2016-10-28 05:21:34 +03:00
|
|
|
if (gfxConfig::IsEnabled(Feature::GPU_PROCESS)) {
|
|
|
|
GPUProcessManager* gpu = GPUProcessManager::Get();
|
|
|
|
gpu->LaunchGPUProcess();
|
|
|
|
}
|
|
|
|
|
2018-12-14 23:16:23 +03:00
|
|
|
gLastUsedFrameRate = ForceSoftwareVsync() ? GetSoftwareVsyncRate() : -1;
|
2019-05-26 17:30:37 +03:00
|
|
|
Preferences::RegisterCallback(
|
|
|
|
FrameRatePrefChanged,
|
2019-07-03 01:32:09 +03:00
|
|
|
nsDependentCString(StaticPrefs::GetPrefName_layout_frame_rate()));
|
2018-12-14 23:16:23 +03:00
|
|
|
// Set up the vsync source for the parent process.
|
|
|
|
ReInitFrameRate();
|
2017-08-16 01:32:21 +03:00
|
|
|
|
2015-12-29 20:22:51 +03:00
|
|
|
#ifdef USE_SKIA
|
|
|
|
SkGraphics::Init();
|
2016-07-20 22:06:29 +03:00
|
|
|
# ifdef MOZ_ENABLE_FREETYPE
|
|
|
|
SkInitCairoFT(gPlatform->FontHintingEnabled());
|
|
|
|
# endif
|
2015-12-29 20:22:51 +03:00
|
|
|
#endif
|
|
|
|
|
2014-06-06 17:51:24 +04:00
|
|
|
InitLayersIPC();
|
2013-06-21 01:32:04 +04:00
|
|
|
|
2015-08-07 22:37:56 +03:00
|
|
|
gPlatform->ComputeTileSize();
|
|
|
|
|
2018-04-17 23:45:29 +03:00
|
|
|
#ifdef MOZ_ENABLE_FREETYPE
|
|
|
|
Factory::SetFTLibrary(gPlatform->GetFTLibrary());
|
|
|
|
#endif
|
|
|
|
|
2018-04-25 16:03:44 +03:00
|
|
|
gPlatform->mHasVariationFontSupport = gPlatform->CheckVariationFontSupport();
|
|
|
|
|
2007-03-30 01:48:46 +04:00
|
|
|
nsresult rv;
|
2017-03-22 05:34:03 +03:00
|
|
|
rv = gfxPlatformFontList::Init();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
MOZ_CRASH("Could not initialize gfxPlatformFontList");
|
2015-05-13 08:11:25 +03:00
|
|
|
}
|
|
|
|
|
2010-11-08 14:02:27 +03:00
|
|
|
gPlatform->mScreenReferenceSurface = gPlatform->CreateOffscreenSurface(
|
2016-01-08 07:57:38 +03:00
|
|
|
IntSize(1, 1), SurfaceFormat::A8R8G8B8_UINT32);
|
2010-11-08 14:02:27 +03:00
|
|
|
if (!gPlatform->mScreenReferenceSurface) {
|
2016-12-03 00:46:53 +03:00
|
|
|
MOZ_CRASH("Could not initialize mScreenReferenceSurface");
|
2010-11-08 14:02:27 +03:00
|
|
|
}
|
|
|
|
|
2014-03-19 06:36:58 +04:00
|
|
|
gPlatform->mScreenReferenceDrawTarget =
|
|
|
|
gPlatform->CreateOffscreenContentDrawTarget(IntSize(1, 1),
|
|
|
|
SurfaceFormat::B8G8R8A8);
|
2016-05-23 22:12:10 +03:00
|
|
|
if (!gPlatform->mScreenReferenceDrawTarget ||
|
|
|
|
!gPlatform->mScreenReferenceDrawTarget->IsValid()) {
|
2017-08-09 13:00:01 +03:00
|
|
|
// If TDR is detected, create a draw target with software backend
|
|
|
|
// and it should be replaced later when the process gets the device
|
|
|
|
// reset notification.
|
|
|
|
if (!gPlatform->DidRenderingDeviceReset()) {
|
|
|
|
gfxCriticalError() << "Could not initialize mScreenReferenceDrawTarget";
|
2013-10-24 19:50:26 +04:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2013-10-24 19:50:26 +04:00
|
|
|
|
2007-04-04 07:32:43 +04:00
|
|
|
rv = gfxFontCache::Init();
|
|
|
|
if (NS_FAILED(rv)) {
|
2016-12-03 00:46:53 +03:00
|
|
|
MOZ_CRASH("Could not initialize gfxFontCache");
|
2007-04-04 07:32:43 +04:00
|
|
|
}
|
|
|
|
|
2013-09-07 07:08:36 +04:00
|
|
|
/* Create and register our CMS Override observer. */
|
|
|
|
gPlatform->mSRGBOverrideObserver = new SRGBOverrideObserver();
|
2014-01-09 22:17:29 +04:00
|
|
|
Preferences::AddWeakObserver(gPlatform->mSRGBOverrideObserver,
|
|
|
|
GFX_PREF_CMS_FORCE_SRGB);
|
2011-06-12 06:30:16 +04:00
|
|
|
|
2018-07-06 00:43:02 +03:00
|
|
|
Preferences::RegisterPrefixCallbacks(FontPrefChanged, kObservedPrefs);
|
2011-04-21 23:36:49 +04:00
|
|
|
|
2015-07-29 23:35:55 +03:00
|
|
|
GLContext::PlatformStartup();
|
2012-11-07 02:39:38 +04:00
|
|
|
|
2017-03-21 21:59:02 +03:00
|
|
|
Preferences::RegisterCallbackAndCall(RecordingPrefChanged,
|
|
|
|
"gfx.2d.recording");
|
2012-11-22 06:40:57 +04:00
|
|
|
|
2013-09-07 07:08:36 +04:00
|
|
|
CreateCMSOutputProfile();
|
2013-11-01 17:52:06 +04:00
|
|
|
|
|
|
|
// Listen to memory pressure event so we can purge DrawTarget caches
|
2018-08-10 18:15:12 +03:00
|
|
|
gPlatform->mMemoryPressureObserver =
|
|
|
|
layers::MemoryPressureObserver::Create(gPlatform);
|
2013-11-15 01:54:25 +04:00
|
|
|
|
2014-11-12 04:28:50 +03:00
|
|
|
// Request the imgITools service, implicitly initializing ImageLib.
|
|
|
|
nsCOMPtr<imgITools> imgTools = do_GetService("@mozilla.org/image/tools;1");
|
|
|
|
if (!imgTools) {
|
2016-12-03 00:46:53 +03:00
|
|
|
MOZ_CRASH("Could not initialize ImageLib");
|
2014-11-12 04:28:50 +03:00
|
|
|
}
|
|
|
|
|
2013-11-07 09:35:30 +04:00
|
|
|
RegisterStrongMemoryReporter(new GfxMemoryImageReporter());
|
2019-05-26 17:29:42 +03:00
|
|
|
if (XRE_IsParentProcess() && UseWebRender()) {
|
2018-09-15 02:24:36 +03:00
|
|
|
RegisterStrongAsyncMemoryReporter(new WebRenderMemoryReporter());
|
|
|
|
}
|
|
|
|
|
2018-05-15 00:47:01 +03:00
|
|
|
#ifdef USE_SKIA
|
|
|
|
RegisterStrongMemoryReporter(new SkMemoryReporter());
|
|
|
|
#endif
|
2017-06-24 00:23:14 +03:00
|
|
|
mlg::InitializeMemoryReporters();
|
2014-11-21 21:52:17 +03:00
|
|
|
|
2016-03-21 19:08:34 +03:00
|
|
|
#ifdef USE_SKIA
|
|
|
|
uint32_t skiaCacheSize = GetSkiaGlyphCacheSize();
|
|
|
|
if (skiaCacheSize != kDefaultGlyphCacheSize) {
|
|
|
|
SkGraphics::SetFontCacheLimit(skiaCacheSize);
|
|
|
|
}
|
|
|
|
#endif
|
2016-03-31 00:04:10 +03:00
|
|
|
|
2016-07-20 07:11:44 +03:00
|
|
|
InitNullMetadata();
|
2018-05-31 09:07:34 +03:00
|
|
|
InitOpenGLConfig();
|
|
|
|
|
|
|
|
if (XRE_IsParentProcess()) {
|
2018-04-05 20:53:56 +03:00
|
|
|
Preferences::Unlock(FONT_VARIATIONS_PREF);
|
2018-05-31 09:07:34 +03:00
|
|
|
if (!gPlatform->HasVariationFontSupport()) {
|
|
|
|
// Ensure variation fonts are disabled and the pref is locked.
|
|
|
|
Preferences::SetBool(FONT_VARIATIONS_PREF, false, PrefValueKind::Default);
|
2018-04-05 20:53:56 +03:00
|
|
|
Preferences::SetBool(FONT_VARIATIONS_PREF, false);
|
|
|
|
Preferences::Lock(FONT_VARIATIONS_PREF);
|
2016-11-15 01:13:40 +03:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
|
|
|
|
2018-02-22 23:55:36 +03:00
|
|
|
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
|
|
|
|
if (obs) {
|
2016-05-09 20:44:21 +03:00
|
|
|
obs->NotifyObservers(nullptr, "gfx-features-ready", nullptr);
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2005-11-29 23:29:45 +03:00
|
|
|
}
|
|
|
|
|
2019-02-17 12:18:01 +03:00
|
|
|
static bool IsFeatureSupported(long aFeature) {
|
2016-11-15 01:13:40 +03:00
|
|
|
nsCOMPtr<nsIGfxInfo> gfxInfo = services::GetGfxInfo();
|
|
|
|
nsCString blockId;
|
|
|
|
int32_t status;
|
2018-10-11 10:32:35 +03:00
|
|
|
if (!NS_SUCCEEDED(gfxInfo->GetFeatureStatus(aFeature, blockId, &status))) {
|
2016-11-15 01:13:40 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return status != nsIGfxInfo::FEATURE_STATUS_OK;
|
|
|
|
}
|
2019-02-26 01:07:19 +03:00
|
|
|
/* static*/
|
|
|
|
bool gfxPlatform::IsDXInterop2Blocked() {
|
2018-10-11 10:32:35 +03:00
|
|
|
return IsFeatureSupported(nsIGfxInfo::FEATURE_DX_INTEROP2);
|
|
|
|
}
|
2016-11-15 01:13:40 +03:00
|
|
|
|
2019-02-26 01:07:19 +03:00
|
|
|
/* static*/
|
|
|
|
bool gfxPlatform::IsDXNV12Blocked() {
|
2018-10-11 10:32:35 +03:00
|
|
|
return IsFeatureSupported(nsIGfxInfo::FEATURE_DX_NV12);
|
|
|
|
}
|
|
|
|
|
2019-02-26 01:07:19 +03:00
|
|
|
/* static*/
|
|
|
|
bool gfxPlatform::IsDXP010Blocked() {
|
2018-10-11 10:32:35 +03:00
|
|
|
return IsFeatureSupported(nsIGfxInfo::FEATURE_DX_P010);
|
|
|
|
}
|
|
|
|
|
2019-02-26 01:07:19 +03:00
|
|
|
/* static*/
|
|
|
|
bool gfxPlatform::IsDXP016Blocked() {
|
2018-10-11 10:32:35 +03:00
|
|
|
return IsFeatureSupported(nsIGfxInfo::FEATURE_DX_P016);
|
2018-05-17 06:07:20 +03:00
|
|
|
}
|
|
|
|
|
2019-02-26 01:07:19 +03:00
|
|
|
/* static */
|
|
|
|
int32_t gfxPlatform::MaxTextureSize() {
|
2017-07-10 17:15:24 +03:00
|
|
|
// Make sure we don't completely break rendering because of a typo in the
|
|
|
|
// pref or whatnot.
|
|
|
|
const int32_t kMinSizePref = 2048;
|
2019-07-22 05:10:14 +03:00
|
|
|
return std::max(
|
|
|
|
kMinSizePref,
|
|
|
|
StaticPrefs::gfx_max_texture_size_AtStartup_DoNotUseDirectly());
|
2017-07-10 17:15:24 +03:00
|
|
|
}
|
|
|
|
|
2019-02-26 01:07:19 +03:00
|
|
|
/* static */
|
|
|
|
int32_t gfxPlatform::MaxAllocSize() {
|
2017-07-10 17:15:24 +03:00
|
|
|
// Make sure we don't completely break rendering because of a typo in the
|
|
|
|
// pref or whatnot.
|
|
|
|
const int32_t kMinAllocPref = 10000000;
|
2019-06-26 03:38:09 +03:00
|
|
|
return std::max(kMinAllocPref,
|
2019-07-22 05:10:14 +03:00
|
|
|
StaticPrefs::gfx_max_alloc_size_AtStartup_DoNotUseDirectly());
|
2017-07-10 17:15:24 +03:00
|
|
|
}
|
|
|
|
|
2019-02-26 01:07:19 +03:00
|
|
|
/* static */
|
|
|
|
void gfxPlatform::InitMoz2DLogging() {
|
Bug 1348273 - Convert crash annotations into a machine-readable list of constants; r=ted.mielczarek,njn,dholbert,mak,cpearce,mcmanus,froydnj,Dexter,jrmuizel,jchen,jimm,bz,surkov
This introduces the machinery needed to generate crash annotations from a YAML
file. The relevant C++ functions are updated to take a typed enum. JavaScript
calls are unaffected but they will throw if the string argument does not
correspond to one of the known entries in the C++ enum. The existing whitelists
and blacklists of annotations are also generated from the YAML file and all
duplicate code related to them has been consolidated. Once written out to the
.extra file the annotations are converted in string form and are no different
than the existing ones.
All existing annotations have been included in the list (and some obsolete ones
have been removed) and all call sites have been updated including tests where
appropriate.
--HG--
extra : source : 4f6c43f2830701ec5552e08e3f1b06fe6d045860
2018-07-05 16:42:11 +03:00
|
|
|
auto fwd = new CrashStatsLogForwarder(
|
|
|
|
CrashReporter::Annotation::GraphicsCriticalError);
|
2019-07-22 05:10:14 +03:00
|
|
|
fwd->SetCircularBufferSize(StaticPrefs::gfx_logging_crash_length_AtStartup());
|
2016-10-04 01:48:11 +03:00
|
|
|
|
2017-07-10 17:15:24 +03:00
|
|
|
mozilla::gfx::Config cfg;
|
|
|
|
cfg.mLogForwarder = fwd;
|
|
|
|
cfg.mMaxTextureSize = gfxPlatform::MaxTextureSize();
|
|
|
|
cfg.mMaxAllocSize = gfxPlatform::MaxAllocSize();
|
2016-10-04 01:48:11 +03:00
|
|
|
|
2017-07-10 17:15:24 +03:00
|
|
|
gfx::Factory::Init(cfg);
|
2016-10-04 01:48:11 +03:00
|
|
|
}
|
|
|
|
|
2019-02-26 01:07:19 +03:00
|
|
|
/* static */
|
|
|
|
bool gfxPlatform::IsHeadless() {
|
2017-04-27 00:29:32 +03:00
|
|
|
static bool initialized = false;
|
|
|
|
static bool headless = false;
|
|
|
|
if (!initialized) {
|
|
|
|
initialized = true;
|
|
|
|
headless = PR_GetEnv("MOZ_HEADLESS");
|
|
|
|
}
|
|
|
|
return headless;
|
2017-04-04 17:22:00 +03:00
|
|
|
}
|
|
|
|
|
2019-05-26 17:29:42 +03:00
|
|
|
/* static */
|
|
|
|
bool gfxPlatform::UseWebRender() { return gfx::gfxVars::UseWebRender(); }
|
|
|
|
|
2014-06-06 17:51:24 +04:00
|
|
|
static bool sLayersIPCIsUp = false;
|
|
|
|
|
2019-02-26 01:07:19 +03:00
|
|
|
/* static */
|
|
|
|
void gfxPlatform::InitNullMetadata() {
|
2016-07-20 07:11:44 +03:00
|
|
|
ScrollMetadata::sNullMetadata = new ScrollMetadata();
|
|
|
|
ClearOnShutdown(&ScrollMetadata::sNullMetadata);
|
|
|
|
}
|
|
|
|
|
2007-03-20 02:16:15 +03:00
|
|
|
void gfxPlatform::Shutdown() {
|
2016-06-06 20:07:29 +03:00
|
|
|
// In some cases, gPlatform may not be created but Shutdown() called,
|
|
|
|
// e.g., during xpcshell tests.
|
2014-06-06 17:51:24 +04:00
|
|
|
if (!gPlatform) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_ASSERT(!sLayersIPCIsUp);
|
|
|
|
|
2007-03-30 01:48:46 +04:00
|
|
|
// These may be called before the corresponding subsystems have actually
|
|
|
|
// started up. That's OK, they can handle it.
|
2007-04-04 07:32:43 +04:00
|
|
|
gfxFontCache::Shutdown();
|
2013-11-08 08:50:39 +04:00
|
|
|
gfxGradientCache::Shutdown();
|
2014-06-11 01:51:24 +04:00
|
|
|
gfxAlphaBoxBlur::ShutdownBlurCache();
|
2011-12-10 02:32:29 +04:00
|
|
|
gfxGraphiteShaper::Shutdown();
|
2009-08-16 17:52:12 +04:00
|
|
|
gfxPlatformFontList::Shutdown();
|
2018-08-21 19:40:36 +03:00
|
|
|
gfxFontMissingGlyphs::Shutdown();
|
2014-08-27 02:57:49 +04:00
|
|
|
ShutdownTileCache();
|
2008-07-17 07:09:08 +04:00
|
|
|
|
|
|
|
// Free the various non-null transforms and loaded profiles
|
2013-09-07 07:08:36 +04:00
|
|
|
ShutdownCMS();
|
2008-07-17 07:09:08 +04:00
|
|
|
|
2016-06-06 20:07:29 +03:00
|
|
|
/* Unregister our CMS Override callback. */
|
|
|
|
NS_ASSERTION(gPlatform->mSRGBOverrideObserver,
|
|
|
|
"mSRGBOverrideObserver has alreay gone");
|
|
|
|
Preferences::RemoveObserver(gPlatform->mSRGBOverrideObserver,
|
|
|
|
GFX_PREF_CMS_FORCE_SRGB);
|
|
|
|
gPlatform->mSRGBOverrideObserver = nullptr;
|
|
|
|
|
2018-07-06 00:43:02 +03:00
|
|
|
Preferences::UnregisterPrefixCallbacks(FontPrefChanged, kObservedPrefs);
|
2013-11-01 17:52:06 +04:00
|
|
|
|
2016-06-06 20:07:29 +03:00
|
|
|
NS_ASSERTION(gPlatform->mMemoryPressureObserver,
|
|
|
|
"mMemoryPressureObserver has already gone");
|
2018-08-10 18:15:12 +03:00
|
|
|
if (gPlatform->mMemoryPressureObserver) {
|
|
|
|
gPlatform->mMemoryPressureObserver->Unregister();
|
|
|
|
gPlatform->mMemoryPressureObserver = nullptr;
|
2016-06-06 20:07:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (XRE_IsParentProcess()) {
|
|
|
|
gPlatform->mVsyncSource->Shutdown();
|
2011-06-12 06:30:16 +04:00
|
|
|
}
|
2009-09-10 05:22:03 +04:00
|
|
|
|
2016-06-06 20:07:29 +03:00
|
|
|
gPlatform->mVsyncSource = nullptr;
|
|
|
|
|
2012-02-09 23:05:11 +04:00
|
|
|
// Shut down the default GL context provider.
|
2015-07-29 23:35:55 +03:00
|
|
|
GLContextProvider::Shutdown();
|
2012-02-09 23:05:11 +04:00
|
|
|
|
2012-02-07 07:09:28 +04:00
|
|
|
#if defined(XP_WIN)
|
2012-02-09 23:05:11 +04:00
|
|
|
// The above shutdown calls operate on the available context providers on
|
|
|
|
// most platforms. Windows is a "special snowflake", though, and has three
|
|
|
|
// context providers available, so we have to shut all of them down.
|
|
|
|
// We should only support the default GL provider on Windows; then, this
|
|
|
|
// could go away. Unfortunately, we currently support WGL (the default) for
|
|
|
|
// WebGL on Optimus.
|
2015-07-29 23:35:55 +03:00
|
|
|
GLContextProviderEGL::Shutdown();
|
2012-02-07 07:09:28 +04:00
|
|
|
#endif
|
2010-07-20 08:05:42 +04:00
|
|
|
|
2016-06-11 04:00:40 +03:00
|
|
|
if (XRE_IsParentProcess()) {
|
|
|
|
GPUProcessManager::Shutdown();
|
2018-08-07 08:47:18 +03:00
|
|
|
VRProcessManager::Shutdown();
|
2018-11-14 21:07:28 +03:00
|
|
|
RDDProcessManager::Shutdown();
|
2016-06-11 04:00:40 +03:00
|
|
|
}
|
2016-05-23 10:27:01 +03:00
|
|
|
|
2015-11-18 18:59:11 +03:00
|
|
|
gfx::Factory::ShutDown();
|
|
|
|
|
2013-08-04 11:46:17 +04:00
|
|
|
delete gGfxPlatformPrefsLock;
|
|
|
|
|
2016-08-04 21:33:42 +03:00
|
|
|
gfxVars::Shutdown();
|
2014-03-20 10:43:30 +04:00
|
|
|
gfxFont::DestroySingletons();
|
2014-02-13 21:38:40 +04:00
|
|
|
|
2016-06-03 21:54:56 +03:00
|
|
|
gfxConfig::Shutdown();
|
|
|
|
|
2016-08-21 04:25:03 +03:00
|
|
|
gPlatform->WillShutdown();
|
|
|
|
|
2007-03-20 02:16:15 +03:00
|
|
|
delete gPlatform;
|
2012-07-30 18:20:58 +04:00
|
|
|
gPlatform = nullptr;
|
2007-03-20 02:16:15 +03:00
|
|
|
}
|
|
|
|
|
2019-02-26 01:07:19 +03:00
|
|
|
/* static */
|
|
|
|
void gfxPlatform::InitLayersIPC() {
|
2017-06-09 23:30:00 +03:00
|
|
|
if (sLayersIPCIsUp) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
sLayersIPCIsUp = true;
|
2014-06-06 17:51:24 +04:00
|
|
|
|
2017-06-09 23:30:00 +03:00
|
|
|
if (XRE_IsContentProcess()) {
|
2018-07-24 00:46:47 +03:00
|
|
|
if (gfxVars::UseOMTP() && !recordreplay::IsRecordingOrReplaying()) {
|
2017-06-09 23:30:00 +03:00
|
|
|
layers::PaintThread::Start();
|
2014-06-06 17:51:24 +04:00
|
|
|
}
|
2018-07-24 00:46:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (XRE_IsParentProcess() || recordreplay::IsRecordingOrReplaying()) {
|
2019-05-26 17:29:42 +03:00
|
|
|
if (!gfxConfig::IsEnabled(Feature::GPU_PROCESS) && UseWebRender()) {
|
2017-06-09 23:30:00 +03:00
|
|
|
wr::RenderThread::Start();
|
2018-09-25 16:13:51 +03:00
|
|
|
image::ImageMemoryReporter::InitForWebRender();
|
2017-06-09 23:30:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
layers::CompositorThreadHolder::Start();
|
|
|
|
}
|
2014-06-06 17:51:24 +04:00
|
|
|
}
|
|
|
|
|
2019-02-26 01:07:19 +03:00
|
|
|
/* static */
|
|
|
|
void gfxPlatform::ShutdownLayersIPC() {
|
2014-06-06 17:51:24 +04:00
|
|
|
if (!sLayersIPCIsUp) {
|
|
|
|
return;
|
|
|
|
}
|
2016-04-13 20:55:08 +03:00
|
|
|
sLayersIPCIsUp = false;
|
2014-06-06 17:51:24 +04:00
|
|
|
|
2015-11-24 05:33:32 +03:00
|
|
|
if (XRE_IsContentProcess()) {
|
|
|
|
gfx::VRManagerChild::ShutDown();
|
2016-04-07 16:47:35 +03:00
|
|
|
// cf bug 1215265.
|
2019-06-27 07:48:58 +03:00
|
|
|
if (StaticPrefs::layers_child_process_shutdown()) {
|
2017-06-14 18:39:59 +03:00
|
|
|
layers::CompositorManagerChild::Shutdown();
|
2016-04-25 06:54:07 +03:00
|
|
|
layers::ImageBridgeChild::ShutDown();
|
2016-04-07 16:47:35 +03:00
|
|
|
}
|
2017-06-09 23:30:00 +03:00
|
|
|
|
2018-07-24 00:46:47 +03:00
|
|
|
if (gfxVars::UseOMTP() && !recordreplay::IsRecordingOrReplaying()) {
|
2017-06-09 23:30:00 +03:00
|
|
|
layers::PaintThread::Shutdown();
|
|
|
|
}
|
2015-11-24 05:33:32 +03:00
|
|
|
} else if (XRE_IsParentProcess()) {
|
2019-04-30 12:37:37 +03:00
|
|
|
#ifdef MOZ_WAYLAND
|
|
|
|
widget::WaylandDisplayShutdown();
|
|
|
|
#endif
|
2015-11-24 05:33:32 +03:00
|
|
|
gfx::VRManagerChild::ShutDown();
|
2017-06-14 18:39:59 +03:00
|
|
|
layers::CompositorManagerChild::Shutdown();
|
2016-05-04 16:22:45 +03:00
|
|
|
layers::ImageBridgeChild::ShutDown();
|
2015-11-24 05:33:32 +03:00
|
|
|
// This has to happen after shutting down the child protocols.
|
2016-05-16 09:38:34 +03:00
|
|
|
layers::CompositorThreadHolder::Shutdown();
|
2018-09-25 16:13:51 +03:00
|
|
|
image::ImageMemoryReporter::ShutdownForWebRender();
|
2019-05-26 17:29:42 +03:00
|
|
|
// There is a case that RenderThread exists when UseWebRender() is
|
2018-02-16 03:04:07 +03:00
|
|
|
// false. This could happen when WebRender was fallbacked to compositor.
|
|
|
|
if (wr::RenderThread::Get()) {
|
2017-06-09 23:30:00 +03:00
|
|
|
wr::RenderThread::ShutDown();
|
|
|
|
|
2015-11-24 05:33:32 +03:00
|
|
|
Preferences::UnregisterCallback(WebRenderDebugPrefChangeCallback,
|
|
|
|
WR_DEBUG_PREF);
|
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
|
|
|
} else {
|
2015-11-24 05:33:32 +03:00
|
|
|
// TODO: There are other kind of processes and we should make sure gfx
|
|
|
|
// stuff is either not created there or shut down properly.
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2014-06-06 17:51:24 +04:00
|
|
|
}
|
|
|
|
|
2016-08-21 04:25:03 +03:00
|
|
|
void gfxPlatform::WillShutdown() {
|
|
|
|
// Destoy these first in case they depend on backend-specific resources.
|
|
|
|
// Otherwise, the backend's destructor would be called before the
|
|
|
|
// base gfxPlatform destructor.
|
2012-07-30 18:20:58 +04:00
|
|
|
mScreenReferenceSurface = nullptr;
|
2013-10-24 19:50:26 +04:00
|
|
|
mScreenReferenceDrawTarget = nullptr;
|
2012-05-12 01:21:41 +04:00
|
|
|
|
2007-03-20 02:16:15 +03:00
|
|
|
// The cairo folks think we should only clean up in debug builds,
|
|
|
|
// but we're generally in the habit of trying to shut down as
|
|
|
|
// cleanly as possible even in production code, so call this
|
|
|
|
// cairo_debug_* function unconditionally.
|
2007-10-26 05:21:50 +04:00
|
|
|
//
|
|
|
|
// because cairo can assert and thus crash on shutdown, don't do this in
|
|
|
|
// release builds
|
2015-07-31 22:11:48 +03:00
|
|
|
#ifdef NS_FREE_PERMANENT_DATA
|
2013-06-29 06:48:35 +04:00
|
|
|
# ifdef USE_SKIA
|
|
|
|
// must do Skia cleanup before Cairo cleanup, because Skia may be referencing
|
|
|
|
// Cairo objects e.g. through SkCairoFTTypeface
|
2015-12-18 21:53:25 +03:00
|
|
|
SkGraphics::PurgeFontCache();
|
2013-06-29 06:48:35 +04:00
|
|
|
# endif
|
|
|
|
|
|
|
|
# if MOZ_TREE_CAIRO
|
2007-03-20 02:16:15 +03:00
|
|
|
cairo_debug_reset_static_data();
|
2007-10-26 05:21:50 +04:00
|
|
|
# endif
|
2013-06-29 06:48:35 +04:00
|
|
|
#endif
|
2007-03-20 02:16:15 +03:00
|
|
|
}
|
|
|
|
|
2019-07-09 09:37:45 +03:00
|
|
|
gfxPlatform::~gfxPlatform() {}
|
2019-06-25 20:35:55 +03:00
|
|
|
|
2019-02-26 01:07:19 +03:00
|
|
|
/* static */
|
|
|
|
already_AddRefed<DrawTarget> gfxPlatform::CreateDrawTargetForSurface(
|
|
|
|
gfxASurface* aSurface, const IntSize& aSize) {
|
2015-07-07 05:11:38 +03:00
|
|
|
SurfaceFormat format = aSurface->GetSurfaceFormat();
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DrawTarget> drawTarget = Factory::CreateDrawTargetForCairoSurface(
|
|
|
|
aSurface->CairoSurface(), aSize, &format);
|
2015-03-09 22:48:20 +03:00
|
|
|
if (!drawTarget) {
|
|
|
|
gfxWarning() << "gfxPlatform::CreateDrawTargetForSurface failed in "
|
|
|
|
"CreateDrawTargetForCairoSurface";
|
|
|
|
return nullptr;
|
|
|
|
}
|
2014-06-12 23:24:05 +04:00
|
|
|
return drawTarget.forget();
|
2011-06-24 21:41:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
cairo_user_data_key_t kSourceSurface;
|
|
|
|
|
2012-10-08 06:44:36 +04:00
|
|
|
/**
|
|
|
|
* Record the backend that was used to construct the SourceSurface.
|
|
|
|
* When getting the cached SourceSurface for a gfxASurface/DrawTarget pair,
|
|
|
|
* we check to make sure the DrawTarget's backend matches the backend
|
|
|
|
* for the cached SourceSurface, and only use it if they match. This
|
|
|
|
* can avoid expensive and unnecessary readbacks.
|
|
|
|
*/
|
|
|
|
struct SourceSurfaceUserData {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<SourceSurface> mSrcSurface;
|
2012-10-08 06:44:36 +04:00
|
|
|
BackendType mBackendType;
|
|
|
|
};
|
|
|
|
|
2019-02-17 12:18:01 +03:00
|
|
|
static void SourceBufferDestroy(void* srcSurfUD) {
|
2012-10-08 06:44:36 +04:00
|
|
|
delete static_cast<SourceSurfaceUserData*>(srcSurfUD);
|
2011-06-24 21:41:18 +04:00
|
|
|
}
|
|
|
|
|
2014-03-05 07:04:05 +04:00
|
|
|
UserDataKey kThebesSurface;
|
|
|
|
|
|
|
|
struct DependentSourceSurfaceUserData {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<gfxASurface> mSurface;
|
2014-03-05 07:04:05 +04:00
|
|
|
};
|
|
|
|
|
2019-02-17 12:18:01 +03:00
|
|
|
static void SourceSurfaceDestroyed(void* aData) {
|
2014-03-05 07:04:05 +04:00
|
|
|
delete static_cast<DependentSourceSurfaceUserData*>(aData);
|
|
|
|
}
|
|
|
|
|
2013-07-12 06:44:29 +04:00
|
|
|
void gfxPlatform::ClearSourceSurfaceForSurface(gfxASurface* aSurface) {
|
|
|
|
aSurface->SetData(&kSourceSurface, nullptr, nullptr);
|
|
|
|
}
|
|
|
|
|
2019-02-26 01:07:19 +03:00
|
|
|
/* static */
|
|
|
|
already_AddRefed<SourceSurface> gfxPlatform::GetSourceSurfaceForSurface(
|
|
|
|
RefPtr<DrawTarget> aTarget, gfxASurface* aSurface, bool aIsPlugin) {
|
2013-10-24 18:35:29 +04:00
|
|
|
if (!aSurface->CairoSurface() || aSurface->CairoStatus()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2013-12-12 01:05:26 +04:00
|
|
|
if (!aTarget) {
|
2014-06-17 13:08:23 +04:00
|
|
|
aTarget = gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget();
|
2013-12-12 01:05:26 +04:00
|
|
|
}
|
|
|
|
|
2011-06-24 21:41:18 +04:00
|
|
|
void* userData = aSurface->GetData(&kSourceSurface);
|
|
|
|
|
|
|
|
if (userData) {
|
2012-10-08 06:44:36 +04:00
|
|
|
SourceSurfaceUserData* surf = static_cast<SourceSurfaceUserData*>(userData);
|
2012-07-28 04:33:08 +04:00
|
|
|
|
2014-06-20 00:35:33 +04:00
|
|
|
if (surf->mSrcSurface->IsValid() &&
|
|
|
|
surf->mBackendType == aTarget->GetBackendType()) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<SourceSurface> srcSurface(surf->mSrcSurface);
|
2015-05-01 16:14:16 +03:00
|
|
|
return srcSurface.forget();
|
2012-07-28 04:33:08 +04:00
|
|
|
}
|
|
|
|
// We can just continue here as when setting new user data the destroy
|
|
|
|
// function will be called for the old user data.
|
2011-06-24 21:41:18 +04:00
|
|
|
}
|
|
|
|
|
2015-07-07 05:11:38 +03:00
|
|
|
SurfaceFormat format = aSurface->GetSurfaceFormat();
|
2011-06-24 21:41:18 +04:00
|
|
|
|
2014-06-20 00:35:33 +04:00
|
|
|
if (aTarget->GetBackendType() == BackendType::CAIRO) {
|
2014-06-17 13:08:23 +04:00
|
|
|
// If we're going to be used with a CAIRO DrawTarget, then just create a
|
|
|
|
// SourceSurfaceCairo since we don't know the underlying type of the CAIRO
|
|
|
|
// DrawTarget and can't pick a better surface type. Doing this also avoids
|
|
|
|
// readback of aSurface's surface into memory if, for example, aSurface
|
|
|
|
// wraps an xlib cairo surface (which can be important to avoid a major
|
|
|
|
// slowdown).
|
2016-01-20 21:31:44 +03:00
|
|
|
//
|
2014-06-17 13:08:23 +04:00
|
|
|
// We return here regardless of whether CreateSourceSurfaceFromNativeSurface
|
|
|
|
// succeeds or not since we don't expect to be able to do any better below
|
|
|
|
// if it fails.
|
|
|
|
//
|
|
|
|
// Note that the returned SourceSurfaceCairo holds a strong reference to
|
|
|
|
// the cairo_surface_t* that it wraps, which essencially means it holds a
|
|
|
|
// strong reference to aSurface since aSurface shares its
|
|
|
|
// cairo_surface_t*'s reference count variable. As a result we can't cache
|
|
|
|
// srcBuffer on aSurface (see below) since aSurface would then hold a
|
|
|
|
// strong reference back to srcBuffer, creating a reference loop and a
|
|
|
|
// memory leak. Not caching is fine since wrapping is cheap enough (no
|
|
|
|
// copying) so we can just wrap again next time we're called.
|
2016-01-20 21:31:44 +03:00
|
|
|
return Factory::CreateSourceSurfaceForCairoSurface(
|
|
|
|
aSurface->CairoSurface(), aSurface->GetSize(), format);
|
2014-06-17 13:08:23 +04:00
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<SourceSurface> srcBuffer;
|
2011-06-24 21:41:18 +04:00
|
|
|
|
2014-06-17 13:08:23 +04:00
|
|
|
// Currently no other DrawTarget types implement
|
|
|
|
// CreateSourceSurfaceFromNativeSurface
|
|
|
|
|
|
|
|
if (!srcBuffer) {
|
|
|
|
// If aSurface wraps data, we can create a SourceSurfaceRawData that wraps
|
|
|
|
// the same data, then optimize it for aTarget:
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DataSourceSurface> surf = GetWrappedDataSourceSurface(aSurface);
|
2014-06-17 13:08:23 +04:00
|
|
|
if (surf) {
|
2016-08-05 20:29:12 +03:00
|
|
|
srcBuffer = aIsPlugin
|
|
|
|
? aTarget->OptimizeSourceSurfaceForUnknownAlpha(surf)
|
|
|
|
: aTarget->OptimizeSourceSurface(surf);
|
|
|
|
|
2014-06-17 13:08:23 +04:00
|
|
|
if (srcBuffer == surf) {
|
|
|
|
// GetWrappedDataSourceSurface returns a SourceSurface that holds a
|
|
|
|
// strong reference to aSurface since it wraps aSurface's data and
|
|
|
|
// needs it to stay alive. As a result we can't cache srcBuffer on
|
|
|
|
// aSurface (below) since aSurface would then hold a strong reference
|
|
|
|
// back to srcBuffer, creating a reference loop and a memory leak. Not
|
|
|
|
// caching is fine since wrapping is cheap enough (no copying) so we
|
|
|
|
// can just wrap again next time we're called.
|
|
|
|
//
|
|
|
|
// Note that the check below doesn't catch this since srcBuffer will be
|
|
|
|
// a SourceSurfaceRawData object (even if aSurface is not a
|
|
|
|
// gfxImageSurface object), which is why we need this separate check.
|
|
|
|
return srcBuffer.forget();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!srcBuffer) {
|
2014-06-20 00:35:33 +04:00
|
|
|
MOZ_ASSERT(aTarget->GetBackendType() != BackendType::CAIRO,
|
2014-06-17 13:08:23 +04:00
|
|
|
"We already tried CreateSourceSurfaceFromNativeSurface with a "
|
|
|
|
"DrawTargetCairo above");
|
|
|
|
// We've run out of performant options. We now try creating a SourceSurface
|
|
|
|
// using a temporary DrawTargetCairo and then optimizing it to aTarget's
|
|
|
|
// actual type. The CreateSourceSurfaceFromNativeSurface() call will
|
|
|
|
// likely create a DataSourceSurface (possibly involving copying and/or
|
|
|
|
// readback), and the OptimizeSourceSurface may well copy again and upload
|
|
|
|
// to the GPU. So, while this code path is rarely hit, hitting it may be
|
|
|
|
// very slow.
|
2016-01-20 21:31:44 +03:00
|
|
|
srcBuffer = Factory::CreateSourceSurfaceForCairoSurface(
|
|
|
|
aSurface->CairoSurface(), aSurface->GetSize(), format);
|
2012-09-03 03:07:05 +04:00
|
|
|
if (srcBuffer) {
|
2014-06-17 13:08:23 +04:00
|
|
|
srcBuffer = aTarget->OptimizeSourceSurface(srcBuffer);
|
2012-09-03 03:07:05 +04:00
|
|
|
}
|
|
|
|
}
|
2011-06-24 21:41:18 +04:00
|
|
|
|
|
|
|
if (!srcBuffer) {
|
2014-06-17 13:08:23 +04:00
|
|
|
return nullptr;
|
|
|
|
}
|
2012-05-21 19:27:32 +04:00
|
|
|
|
2014-06-17 13:08:23 +04:00
|
|
|
if ((srcBuffer->GetType() == SurfaceType::CAIRO &&
|
|
|
|
static_cast<SourceSurfaceCairo*>(srcBuffer.get())->GetSurface() ==
|
|
|
|
aSurface->CairoSurface()) ||
|
|
|
|
(srcBuffer->GetType() == SurfaceType::CAIRO_IMAGE &&
|
|
|
|
static_cast<DataSourceSurfaceCairo*>(srcBuffer.get())->GetSurface() ==
|
|
|
|
aSurface->CairoSurface())) {
|
|
|
|
// See the "Note that the returned SourceSurfaceCairo..." comment above.
|
|
|
|
return srcBuffer.forget();
|
2011-06-24 21:41:18 +04:00
|
|
|
}
|
|
|
|
|
2014-04-15 06:36:26 +04:00
|
|
|
// Add user data to aSurface so we can cache lookups in the future.
|
2016-11-15 12:00:08 +03:00
|
|
|
auto* srcSurfUD = new SourceSurfaceUserData;
|
2014-06-20 00:35:33 +04:00
|
|
|
srcSurfUD->mBackendType = aTarget->GetBackendType();
|
2014-04-15 06:36:26 +04:00
|
|
|
srcSurfUD->mSrcSurface = srcBuffer;
|
|
|
|
aSurface->SetData(&kSourceSurface, srcSurfUD, SourceBufferDestroy);
|
2011-06-24 21:41:18 +04:00
|
|
|
|
2014-06-12 23:24:05 +04:00
|
|
|
return srcBuffer.forget();
|
2011-06-24 21:41:18 +04:00
|
|
|
}
|
|
|
|
|
2014-04-15 06:36:26 +04:00
|
|
|
already_AddRefed<DataSourceSurface> gfxPlatform::GetWrappedDataSourceSurface(
|
|
|
|
gfxASurface* aSurface) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<gfxImageSurface> image = aSurface->GetAsImageSurface();
|
2014-04-15 06:36:26 +04:00
|
|
|
if (!image) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
RefPtr<DataSourceSurface> result = Factory::CreateWrappingDataSourceSurface(
|
2015-04-07 17:08:57 +03:00
|
|
|
image->Data(), image->Stride(), image->GetSize(),
|
2014-04-15 06:36:26 +04:00
|
|
|
ImageFormatToSurfaceFormat(image->Format()));
|
|
|
|
|
|
|
|
if (!result) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we wrapped the underlying data of aSurface, then we need to add user
|
|
|
|
// data to make sure aSurface stays alive until we are done with the data.
|
2016-11-15 12:00:08 +03:00
|
|
|
auto* srcSurfUD = new DependentSourceSurfaceUserData;
|
2014-04-15 06:36:26 +04:00
|
|
|
srcSurfUD->mSurface = aSurface;
|
|
|
|
result->AddUserData(&kThebesSurface, srcSurfUD, SourceSurfaceDestroyed);
|
|
|
|
|
2014-06-12 23:24:05 +04:00
|
|
|
return result.forget();
|
2014-04-15 06:36:26 +04:00
|
|
|
}
|
|
|
|
|
2014-11-13 01:55:13 +03:00
|
|
|
void gfxPlatform::ComputeTileSize() {
|
|
|
|
// The tile size should be picked in the parent processes
|
|
|
|
// and sent to the child processes over IPDL GetTileSize.
|
2015-07-04 04:29:00 +03:00
|
|
|
if (!XRE_IsParentProcess()) {
|
2015-08-07 22:37:56 +03:00
|
|
|
return;
|
2014-11-13 01:55:13 +03:00
|
|
|
}
|
|
|
|
|
2019-07-22 05:10:14 +03:00
|
|
|
int32_t w = StaticPrefs::layers_tile_width_AtStartup();
|
|
|
|
int32_t h = StaticPrefs::layers_tile_height_AtStartup();
|
2014-11-13 01:55:13 +03:00
|
|
|
|
2019-07-22 05:10:14 +03:00
|
|
|
if (StaticPrefs::layers_tiles_adjust_AtStartup()) {
|
2015-08-27 01:33:16 +03:00
|
|
|
gfx::IntSize screenSize = GetScreenSize();
|
|
|
|
if (screenSize.width > 0) {
|
2015-12-09 00:42:43 +03:00
|
|
|
// Choose a size so that there are between 2 and 4 tiles per screen width.
|
|
|
|
// FIXME: we should probably make sure this is within the max texture
|
|
|
|
// size, but I think everything should at least support 1024
|
2016-07-22 11:47:44 +03:00
|
|
|
w = h = clamped(int32_t(RoundUpPow2(screenSize.width)) / 4, 256, 1024);
|
2015-08-27 01:33:16 +03:00
|
|
|
}
|
2014-11-13 01:55:13 +03:00
|
|
|
}
|
|
|
|
|
2016-08-04 21:33:43 +03:00
|
|
|
// Don't allow changing the tile size after we've set it.
|
|
|
|
// Right now the code assumes that the tile size doesn't change.
|
|
|
|
MOZ_ASSERT(gfxVars::TileSize().width == -1 &&
|
|
|
|
gfxVars::TileSize().height == -1);
|
|
|
|
|
|
|
|
gfxVars::SetTileSize(IntSize(w, h));
|
2015-08-27 01:37:48 +03:00
|
|
|
}
|
|
|
|
|
2015-08-27 01:37:48 +03:00
|
|
|
void gfxPlatform::PopulateScreenInfo() {
|
|
|
|
nsCOMPtr<nsIScreenManager> manager =
|
|
|
|
do_GetService("@mozilla.org/gfx/screenmanager;1");
|
|
|
|
MOZ_ASSERT(manager, "failed to get nsIScreenManager");
|
|
|
|
|
|
|
|
nsCOMPtr<nsIScreen> screen;
|
|
|
|
manager->GetPrimaryScreen(getter_AddRefs(screen));
|
2015-08-27 01:33:16 +03:00
|
|
|
if (!screen) {
|
|
|
|
// This can happen in xpcshell, for instance
|
|
|
|
return;
|
|
|
|
}
|
2015-08-27 01:37:48 +03:00
|
|
|
|
|
|
|
screen->GetColorDepth(&mScreenDepth);
|
2017-03-29 17:14:19 +03:00
|
|
|
if (XRE_IsParentProcess()) {
|
|
|
|
gfxVars::SetScreenDepth(mScreenDepth);
|
|
|
|
}
|
2015-08-27 01:37:48 +03:00
|
|
|
|
|
|
|
int left, top;
|
|
|
|
screen->GetRect(&left, &top, &mScreenSize.width, &mScreenSize.height);
|
|
|
|
}
|
|
|
|
|
2013-05-28 02:04:37 +04:00
|
|
|
bool gfxPlatform::SupportsAzureContentForDrawTarget(DrawTarget* aTarget) {
|
2016-06-07 04:17:48 +03:00
|
|
|
if (!aTarget || !aTarget->IsValid()) {
|
2013-05-28 02:04:37 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-06-20 00:35:33 +04:00
|
|
|
return SupportsAzureContentForType(aTarget->GetBackendType());
|
2013-05-28 02:04:37 +04:00
|
|
|
}
|
|
|
|
|
2016-03-23 21:17:02 +03:00
|
|
|
void gfxPlatform::PurgeSkiaFontCache() {
|
|
|
|
#ifdef USE_SKIA
|
|
|
|
if (gfxPlatform::GetPlatform()->GetDefaultContentBackend() ==
|
|
|
|
BackendType::SKIA) {
|
|
|
|
SkGraphics::PurgeFontCache();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2012-07-25 04:45:58 +04:00
|
|
|
already_AddRefed<DrawTarget> gfxPlatform::CreateDrawTargetForBackend(
|
|
|
|
BackendType aBackend, const IntSize& aSize, SurfaceFormat aFormat) {
|
2012-01-27 22:09:20 +04:00
|
|
|
// There is a bunch of knowledge in the gfxPlatform heirarchy about how to
|
|
|
|
// create the best offscreen surface for the current system and situation. We
|
|
|
|
// can easily take advantage of this for the Cairo backend, so that's what we
|
|
|
|
// do.
|
|
|
|
// mozilla::gfx::Factory can get away without having all this knowledge for
|
|
|
|
// now, but this might need to change in the future (using
|
|
|
|
// CreateOffscreenSurface() and CreateDrawTargetForSurface() for all
|
|
|
|
// backends).
|
2014-01-10 23:06:16 +04:00
|
|
|
if (aBackend == BackendType::CAIRO) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<gfxASurface> surf =
|
|
|
|
CreateOffscreenSurface(aSize, SurfaceFormatToImageFormat(aFormat));
|
2012-07-31 11:57:28 +04:00
|
|
|
if (!surf || surf->CairoStatus()) {
|
2013-07-31 19:44:31 +04:00
|
|
|
return nullptr;
|
2012-07-24 14:18:38 +04:00
|
|
|
}
|
2012-07-24 14:18:38 +04:00
|
|
|
return CreateDrawTargetForSurface(surf, aSize);
|
2012-01-27 22:09:20 +04:00
|
|
|
}
|
2017-02-09 15:39:27 +03:00
|
|
|
return Factory::CreateDrawTarget(aBackend, aSize, aFormat);
|
2011-06-24 21:41:18 +04:00
|
|
|
}
|
|
|
|
|
2013-08-23 10:13:55 +04:00
|
|
|
already_AddRefed<DrawTarget> gfxPlatform::CreateOffscreenCanvasDrawTarget(
|
|
|
|
const IntSize& aSize, SurfaceFormat aFormat) {
|
2014-01-10 23:06:16 +04:00
|
|
|
NS_ASSERTION(mPreferredCanvasBackend != BackendType::NONE, "No backend.");
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DrawTarget> target =
|
|
|
|
CreateDrawTargetForBackend(mPreferredCanvasBackend, aSize, aFormat);
|
2014-01-10 23:06:16 +04:00
|
|
|
if (target || mFallbackCanvasBackend == BackendType::NONE) {
|
2014-06-12 23:24:05 +04:00
|
|
|
return target.forget();
|
2012-07-25 04:45:58 +04:00
|
|
|
}
|
|
|
|
|
2015-03-12 21:40:06 +03:00
|
|
|
#ifdef XP_WIN
|
|
|
|
// On Windows, the fallback backend (Cairo) should use its image backend.
|
|
|
|
return Factory::CreateDrawTarget(mFallbackCanvasBackend, aSize, aFormat);
|
|
|
|
#else
|
2012-07-25 04:45:58 +04:00
|
|
|
return CreateDrawTargetForBackend(mFallbackCanvasBackend, aSize, aFormat);
|
2015-03-12 21:40:06 +03:00
|
|
|
#endif
|
2012-07-25 04:45:58 +04:00
|
|
|
}
|
|
|
|
|
2017-08-09 13:00:01 +03:00
|
|
|
already_AddRefed<DrawTarget> gfxPlatform::CreateOffscreenContentDrawTarget(
|
|
|
|
const IntSize& aSize, SurfaceFormat aFormat, bool aFallback) {
|
|
|
|
BackendType backend = (aFallback) ? mSoftwareBackend : mContentBackend;
|
|
|
|
NS_ASSERTION(backend != BackendType::NONE, "No backend.");
|
2019-02-26 10:46:08 +03:00
|
|
|
RefPtr<DrawTarget> dt = CreateDrawTargetForBackend(backend, aSize, aFormat);
|
|
|
|
|
|
|
|
if (!dt) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We'd prefer this to take proper care and return a CaptureDT, but for the
|
|
|
|
// moment since we can't and this means we're going to be drawing on the main
|
|
|
|
// thread force it's initialization. See bug 1526045 and bug 1521368.
|
|
|
|
dt->ClearRect(gfx::Rect());
|
|
|
|
if (!dt->IsValid()) {
|
2019-02-28 17:55:34 +03:00
|
|
|
return nullptr;
|
2019-02-26 10:46:08 +03:00
|
|
|
}
|
|
|
|
return dt.forget();
|
2013-08-23 10:13:55 +04:00
|
|
|
}
|
2012-07-25 04:45:58 +04:00
|
|
|
|
2016-07-29 01:32:00 +03:00
|
|
|
already_AddRefed<DrawTarget> gfxPlatform::CreateSimilarSoftwareDrawTarget(
|
|
|
|
DrawTarget* aDT, const IntSize& aSize, SurfaceFormat aFormat) {
|
|
|
|
RefPtr<DrawTarget> dt;
|
|
|
|
|
|
|
|
if (Factory::DoesBackendSupportDataDrawtarget(aDT->GetBackendType())) {
|
|
|
|
dt = aDT->CreateSimilarDrawTarget(aSize, aFormat);
|
|
|
|
} else {
|
2016-11-21 21:17:09 +03:00
|
|
|
#ifdef USE_SKIA
|
|
|
|
BackendType backendType = BackendType::SKIA;
|
|
|
|
#else
|
|
|
|
BackendType backendType = BackendType::CAIRO;
|
|
|
|
#endif
|
|
|
|
dt = Factory::CreateDrawTarget(backendType, aSize, aFormat);
|
2016-07-29 01:32:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return dt.forget();
|
|
|
|
}
|
|
|
|
|
2019-02-26 01:07:19 +03:00
|
|
|
/* static */
|
|
|
|
already_AddRefed<DrawTarget> gfxPlatform::CreateDrawTargetForData(
|
2016-11-29 23:46:49 +03:00
|
|
|
unsigned char* aData, const IntSize& aSize, int32_t aStride,
|
|
|
|
SurfaceFormat aFormat, bool aUninitialized) {
|
2016-08-12 00:54:08 +03:00
|
|
|
BackendType backendType = gfxVars::ContentBackend();
|
|
|
|
NS_ASSERTION(backendType != BackendType::NONE, "No backend.");
|
2015-07-31 22:11:48 +03:00
|
|
|
|
2016-08-12 00:54:08 +03:00
|
|
|
if (!Factory::DoesBackendSupportDataDrawtarget(backendType)) {
|
2016-11-21 21:17:09 +03:00
|
|
|
#ifdef USE_SKIA
|
|
|
|
backendType = BackendType::SKIA;
|
|
|
|
#else
|
2015-01-08 05:34:07 +03:00
|
|
|
backendType = BackendType::CAIRO;
|
2016-11-21 21:17:09 +03:00
|
|
|
#endif
|
2015-01-08 05:34:07 +03:00
|
|
|
}
|
2015-01-08 00:58:25 +03:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DrawTarget> dt = Factory::CreateDrawTargetForData(
|
2016-11-29 23:46:49 +03:00
|
|
|
backendType, aData, aSize, aStride, aFormat, aUninitialized);
|
2015-01-08 00:58:25 +03:00
|
|
|
|
2014-06-26 11:40:12 +04:00
|
|
|
return dt.forget();
|
2012-04-02 23:15:08 +04:00
|
|
|
}
|
|
|
|
|
2019-02-26 01:07:19 +03:00
|
|
|
/* static */
|
|
|
|
BackendType gfxPlatform::BackendTypeForName(const nsCString& aName) {
|
2012-07-25 04:45:58 +04:00
|
|
|
if (aName.EqualsLiteral("cairo")) return BackendType::CAIRO;
|
|
|
|
if (aName.EqualsLiteral("skia")) return BackendType::SKIA;
|
|
|
|
if (aName.EqualsLiteral("direct2d")) return BackendType::DIRECT2D;
|
2014-09-15 01:51:27 +04:00
|
|
|
if (aName.EqualsLiteral("direct2d1.1")) return BackendType::DIRECT2D1_1;
|
2014-01-10 23:06:16 +04:00
|
|
|
return BackendType::NONE;
|
2012-07-25 04:45:58 +04:00
|
|
|
}
|
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
nsresult gfxPlatform::GetFontList(nsAtom* aLangGroup,
|
2006-01-10 23:26:40 +03:00
|
|
|
const nsACString& aGenericFamily,
|
2009-01-18 23:14:14 +03:00
|
|
|
nsTArray<nsString>& aListOfFonts) {
|
2016-03-18 15:43:38 +03:00
|
|
|
gfxPlatformFontList::PlatformFontList()->GetFontList(
|
|
|
|
aLangGroup, aGenericFamily, aListOfFonts);
|
|
|
|
return NS_OK;
|
2006-01-10 23:26:40 +03:00
|
|
|
}
|
2006-06-15 08:47:23 +04:00
|
|
|
|
|
|
|
nsresult gfxPlatform::UpdateFontList() {
|
2016-03-18 15:43:38 +03:00
|
|
|
gfxPlatformFontList::PlatformFontList()->UpdateFontList();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2018-09-12 22:34:57 +03:00
|
|
|
void gfxPlatform::GetStandardFamilyName(const nsCString& aFontName,
|
|
|
|
nsACString& aFamilyName) {
|
2016-03-18 15:43:38 +03:00
|
|
|
gfxPlatformFontList::PlatformFontList()->GetStandardFamilyName(aFontName,
|
|
|
|
aFamilyName);
|
2006-06-15 08:47:23 +04:00
|
|
|
}
|
2006-09-26 08:20:41 +04:00
|
|
|
|
2017-04-03 15:00:14 +03:00
|
|
|
nsAutoCString gfxPlatform::GetDefaultFontName(
|
|
|
|
const nsACString& aLangGroup, const nsACString& aGenericFamily) {
|
2018-08-22 16:34:16 +03:00
|
|
|
// To benefit from Return Value Optimization, all paths here must return
|
|
|
|
// this one variable:
|
2018-09-12 22:34:57 +03:00
|
|
|
nsAutoCString result;
|
2018-08-22 16:34:16 +03:00
|
|
|
|
2019-04-27 18:37:58 +03:00
|
|
|
FamilyAndGeneric fam =
|
2017-04-03 15:00:14 +03:00
|
|
|
gfxPlatformFontList::PlatformFontList()->GetDefaultFontFamily(
|
|
|
|
aLangGroup, aGenericFamily);
|
2019-04-27 18:37:58 +03:00
|
|
|
if (fam.mFamily.mIsShared) {
|
|
|
|
if (fam.mFamily.mShared) {
|
|
|
|
fontlist::FontList* fontList =
|
|
|
|
gfxPlatformFontList::PlatformFontList()->SharedFontList();
|
|
|
|
result = fam.mFamily.mShared->DisplayName().AsString(fontList);
|
|
|
|
}
|
|
|
|
} else if (fam.mFamily.mUnshared) {
|
|
|
|
fam.mFamily.mUnshared->LocalizedName(result);
|
2018-08-22 16:34:16 +03:00
|
|
|
} // (else, leave 'result' empty)
|
|
|
|
|
2018-08-27 18:26:41 +03:00
|
|
|
return result;
|
2017-04-03 15:00:14 +03:00
|
|
|
}
|
|
|
|
|
2008-10-01 07:01:53 +04:00
|
|
|
bool gfxPlatform::DownloadableFontsEnabled() {
|
2010-05-27 09:05:30 +04:00
|
|
|
if (mAllowDownloadableFonts == UNINITIALIZED_VALUE) {
|
2010-10-07 11:59:19 +04:00
|
|
|
mAllowDownloadableFonts =
|
2011-09-29 10:19:26 +04:00
|
|
|
Preferences::GetBool(GFX_DOWNLOADABLE_FONTS_ENABLED, false);
|
2008-10-01 07:01:53 +04:00
|
|
|
}
|
|
|
|
|
2010-05-27 09:05:30 +04:00
|
|
|
return mAllowDownloadableFonts;
|
2008-10-01 07:01:53 +04:00
|
|
|
}
|
|
|
|
|
2012-03-09 06:05:40 +04:00
|
|
|
bool gfxPlatform::UseCmapsDuringSystemFallback() {
|
|
|
|
if (mFallbackUsesCmaps == UNINITIALIZED_VALUE) {
|
|
|
|
mFallbackUsesCmaps =
|
|
|
|
Preferences::GetBool(GFX_PREF_FALLBACK_USE_CMAPS, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
return mFallbackUsesCmaps;
|
|
|
|
}
|
|
|
|
|
2013-05-16 20:32:41 +04:00
|
|
|
bool gfxPlatform::OpenTypeSVGEnabled() {
|
|
|
|
if (mOpenTypeSVGEnabled == UNINITIALIZED_VALUE) {
|
|
|
|
mOpenTypeSVGEnabled = Preferences::GetBool(GFX_PREF_OPENTYPE_SVG, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
return mOpenTypeSVGEnabled > 0;
|
|
|
|
}
|
|
|
|
|
2013-09-11 05:36:57 +04:00
|
|
|
uint32_t gfxPlatform::WordCacheCharLimit() {
|
|
|
|
if (mWordCacheCharLimit == UNINITIALIZED_VALUE) {
|
|
|
|
mWordCacheCharLimit =
|
|
|
|
Preferences::GetInt(GFX_PREF_WORD_CACHE_CHARLIMIT, 32);
|
|
|
|
if (mWordCacheCharLimit < 0) {
|
|
|
|
mWordCacheCharLimit = 32;
|
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2013-09-11 05:36:57 +04:00
|
|
|
|
|
|
|
return uint32_t(mWordCacheCharLimit);
|
|
|
|
}
|
|
|
|
|
2013-09-11 05:36:57 +04:00
|
|
|
uint32_t gfxPlatform::WordCacheMaxEntries() {
|
|
|
|
if (mWordCacheMaxEntries == UNINITIALIZED_VALUE) {
|
|
|
|
mWordCacheMaxEntries =
|
|
|
|
Preferences::GetInt(GFX_PREF_WORD_CACHE_MAXENTRIES, 10000);
|
|
|
|
if (mWordCacheMaxEntries < 0) {
|
|
|
|
mWordCacheMaxEntries = 10000;
|
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2013-09-11 05:36:57 +04:00
|
|
|
|
|
|
|
return uint32_t(mWordCacheMaxEntries);
|
|
|
|
}
|
|
|
|
|
2011-12-10 02:32:29 +04:00
|
|
|
bool gfxPlatform::UseGraphiteShaping() {
|
|
|
|
if (mGraphiteShapingEnabled == UNINITIALIZED_VALUE) {
|
|
|
|
mGraphiteShapingEnabled =
|
|
|
|
Preferences::GetBool(GFX_PREF_GRAPHITE_SHAPING, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
return mGraphiteShapingEnabled;
|
|
|
|
}
|
|
|
|
|
2017-07-20 11:57:00 +03:00
|
|
|
bool gfxPlatform::IsFontFormatSupported(uint32_t aFormatFlags) {
|
|
|
|
// check for strange format flags
|
|
|
|
MOZ_ASSERT(!(aFormatFlags & gfxUserFontSet::FLAG_FORMAT_NOT_USED),
|
|
|
|
"strange font format hint set");
|
|
|
|
|
|
|
|
// accept "common" formats that we support on all platforms
|
|
|
|
if (aFormatFlags & gfxUserFontSet::FLAG_FORMATS_COMMON) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// reject all other formats, known and unknown
|
|
|
|
if (aFormatFlags != 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// no format hint set, need to look at data
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-09-12 22:34:57 +03:00
|
|
|
gfxFontEntry* gfxPlatform::LookupLocalFont(const nsACString& aFontName,
|
2018-04-25 09:18:23 +03:00
|
|
|
WeightRange aWeightForEntry,
|
|
|
|
StretchRange aStretchForEntry,
|
|
|
|
SlantStyleRange aStyleForEntry) {
|
|
|
|
return gfxPlatformFontList::PlatformFontList()->LookupLocalFont(
|
|
|
|
aFontName, aWeightForEntry, aStretchForEntry, aStyleForEntry);
|
2016-03-18 15:43:38 +03:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-09-12 22:34:57 +03:00
|
|
|
gfxFontEntry* gfxPlatform::MakePlatformFont(const nsACString& aFontName,
|
2018-04-25 09:18:23 +03:00
|
|
|
WeightRange aWeightForEntry,
|
|
|
|
StretchRange aStretchForEntry,
|
|
|
|
SlantStyleRange aStyleForEntry,
|
2014-09-08 11:23:19 +04:00
|
|
|
const uint8_t* aFontData,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aLength) {
|
2018-04-25 09:18:23 +03:00
|
|
|
return gfxPlatformFontList::PlatformFontList()->MakePlatformFont(
|
|
|
|
aFontName, aWeightForEntry, aStretchForEntry, aStyleForEntry, aFontData,
|
|
|
|
aLength);
|
2009-08-30 17:55:24 +04:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2013-08-03 02:50:17 +04:00
|
|
|
mozilla::layers::DiagnosticTypes gfxPlatform::GetLayerDiagnosticTypes() {
|
2014-04-26 06:34:06 +04:00
|
|
|
mozilla::layers::DiagnosticTypes type = DiagnosticTypes::NO_DIAGNOSTIC;
|
2019-06-27 07:48:58 +03:00
|
|
|
if (StaticPrefs::layers_draw_borders()) {
|
2014-04-26 06:34:06 +04:00
|
|
|
type |= mozilla::layers::DiagnosticTypes::LAYER_BORDERS;
|
2013-08-03 02:50:17 +04:00
|
|
|
}
|
2019-06-27 07:48:58 +03:00
|
|
|
if (StaticPrefs::layers_draw_tile_borders()) {
|
2014-04-26 06:34:06 +04:00
|
|
|
type |= mozilla::layers::DiagnosticTypes::TILE_BORDERS;
|
2013-08-03 02:50:17 +04:00
|
|
|
}
|
2019-06-27 07:48:58 +03:00
|
|
|
if (StaticPrefs::layers_draw_bigimage_borders()) {
|
2014-04-26 06:34:06 +04:00
|
|
|
type |= mozilla::layers::DiagnosticTypes::BIGIMAGE_BORDERS;
|
2013-08-03 02:50:17 +04:00
|
|
|
}
|
2019-06-27 07:48:58 +03:00
|
|
|
if (StaticPrefs::layers_flash_borders()) {
|
2014-04-26 06:34:06 +04:00
|
|
|
type |= mozilla::layers::DiagnosticTypes::FLASH_BORDERS;
|
2014-03-25 20:54:39 +04:00
|
|
|
}
|
2013-08-03 02:50:17 +04:00
|
|
|
return type;
|
2013-03-21 21:08:01 +04:00
|
|
|
}
|
|
|
|
|
2018-04-30 23:05:19 +03:00
|
|
|
BackendPrefsData gfxPlatform::GetBackendPrefs() const {
|
2018-03-15 08:48:54 +03:00
|
|
|
BackendPrefsData data;
|
|
|
|
|
2019-06-24 21:45:16 +03:00
|
|
|
data.mCanvasBitmask = BackendTypeBit(BackendType::SKIA);
|
|
|
|
data.mContentBitmask = BackendTypeBit(BackendType::SKIA);
|
|
|
|
|
|
|
|
#ifdef MOZ_WIDGET_GTK
|
|
|
|
data.mCanvasBitmask |= BackendTypeBit(BackendType::CAIRO);
|
|
|
|
data.mContentBitmask |= BackendTypeBit(BackendType::CAIRO);
|
2018-03-15 08:48:54 +03:00
|
|
|
#endif
|
2019-06-24 21:45:16 +03:00
|
|
|
|
|
|
|
data.mCanvasDefault = BackendType::SKIA;
|
|
|
|
data.mContentDefault = BackendType::SKIA;
|
2018-03-15 08:48:54 +03:00
|
|
|
|
2018-06-01 18:59:07 +03:00
|
|
|
return data;
|
2018-03-15 08:48:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void gfxPlatform::InitBackendPrefs(BackendPrefsData&& aPrefsData) {
|
|
|
|
mPreferredCanvasBackend = GetCanvasBackendPref(aPrefsData.mCanvasBitmask);
|
2014-01-10 23:06:16 +04:00
|
|
|
if (mPreferredCanvasBackend == BackendType::NONE) {
|
2018-03-15 08:48:54 +03:00
|
|
|
mPreferredCanvasBackend = aPrefsData.mCanvasDefault;
|
2014-09-15 01:52:41 +04:00
|
|
|
}
|
2013-08-26 08:13:24 +04:00
|
|
|
|
2014-09-15 01:52:41 +04:00
|
|
|
if (mPreferredCanvasBackend == BackendType::DIRECT2D1_1) {
|
|
|
|
// Falling back to D2D 1.0 won't help us here. When D2D 1.1 DT creation
|
|
|
|
// fails it means the surface was too big or there's something wrong with
|
|
|
|
// the device. D2D 1.0 will encounter a similar situation.
|
2017-01-25 21:08:40 +03:00
|
|
|
mFallbackCanvasBackend = GetCanvasBackendPref(
|
2018-03-15 08:48:54 +03:00
|
|
|
aPrefsData.mCanvasBitmask & ~(BackendTypeBit(mPreferredCanvasBackend) |
|
2014-09-15 01:52:41 +04:00
|
|
|
BackendTypeBit(BackendType::DIRECT2D)));
|
2018-11-30 13:46:48 +03:00
|
|
|
} else {
|
2017-01-25 21:08:40 +03:00
|
|
|
mFallbackCanvasBackend = GetCanvasBackendPref(
|
2018-03-15 08:48:54 +03:00
|
|
|
aPrefsData.mCanvasBitmask & ~BackendTypeBit(mPreferredCanvasBackend));
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2016-11-28 11:40:29 +03:00
|
|
|
|
2018-03-15 08:48:54 +03:00
|
|
|
mContentBackendBitmask = aPrefsData.mContentBitmask;
|
2013-08-26 08:13:24 +04:00
|
|
|
mContentBackend = GetContentBackendPref(mContentBackendBitmask);
|
2014-01-10 23:06:16 +04:00
|
|
|
if (mContentBackend == BackendType::NONE) {
|
2018-03-15 08:48:54 +03:00
|
|
|
mContentBackend = aPrefsData.mContentDefault;
|
2014-01-12 08:02:18 +04:00
|
|
|
// mContentBackendBitmask is our canonical reference for supported
|
|
|
|
// backends so we need to add the default if we are using it and
|
|
|
|
// overriding the prefs.
|
2018-03-15 08:48:54 +03:00
|
|
|
mContentBackendBitmask |= BackendTypeBit(aPrefsData.mContentDefault);
|
2013-11-05 23:54:12 +04:00
|
|
|
}
|
2016-08-04 21:33:44 +03:00
|
|
|
|
2019-06-24 21:45:16 +03:00
|
|
|
uint32_t swBackendBits = BackendTypeBit(BackendType::SKIA);
|
|
|
|
#ifdef MOZ_WIDGET_GTK
|
|
|
|
swBackendBits |= BackendTypeBit(BackendType::CAIRO);
|
|
|
|
#endif
|
2016-11-28 11:40:29 +03:00
|
|
|
mSoftwareBackend = GetContentBackendPref(swBackendBits);
|
|
|
|
|
2016-08-04 21:33:44 +03:00
|
|
|
if (XRE_IsParentProcess()) {
|
|
|
|
gfxVars::SetContentBackend(mContentBackend);
|
2017-03-28 17:35:55 +03:00
|
|
|
gfxVars::SetSoftwareBackend(mSoftwareBackend);
|
2016-08-04 21:33:44 +03:00
|
|
|
}
|
2012-09-17 04:20:16 +04:00
|
|
|
}
|
|
|
|
|
2019-02-26 01:07:19 +03:00
|
|
|
/* static */
|
|
|
|
BackendType gfxPlatform::GetCanvasBackendPref(uint32_t aBackendBitmask) {
|
2013-11-05 23:54:12 +04:00
|
|
|
return GetBackendPref("gfx.canvas.azure.backends", aBackendBitmask);
|
2012-09-17 07:23:00 +04:00
|
|
|
}
|
|
|
|
|
2019-02-26 01:07:19 +03:00
|
|
|
/* static */
|
|
|
|
BackendType gfxPlatform::GetContentBackendPref(uint32_t& aBackendBitmask) {
|
2013-11-05 23:54:12 +04:00
|
|
|
return GetBackendPref("gfx.content.azure.backends", aBackendBitmask);
|
2012-09-17 07:23:00 +04:00
|
|
|
}
|
|
|
|
|
2019-02-26 01:07:19 +03:00
|
|
|
/* static */
|
|
|
|
BackendType gfxPlatform::GetBackendPref(const char* aBackendPrefName,
|
|
|
|
uint32_t& aBackendBitmask) {
|
2012-10-09 13:45:35 +04:00
|
|
|
nsTArray<nsCString> backendList;
|
2017-07-31 03:52:51 +03:00
|
|
|
nsAutoCString prefString;
|
|
|
|
if (NS_SUCCEEDED(Preferences::GetCString(aBackendPrefName, prefString))) {
|
2012-10-09 13:45:35 +04:00
|
|
|
ParseString(prefString, ',', backendList);
|
2012-07-25 04:45:58 +04:00
|
|
|
}
|
|
|
|
|
2013-08-26 08:13:24 +04:00
|
|
|
uint32_t allowedBackends = 0;
|
2014-01-10 23:06:16 +04:00
|
|
|
BackendType result = BackendType::NONE;
|
2012-10-09 13:45:35 +04:00
|
|
|
for (uint32_t i = 0; i < backendList.Length(); ++i) {
|
2013-08-26 08:13:24 +04:00
|
|
|
BackendType type = BackendTypeForName(backendList[i]);
|
2014-01-10 23:06:16 +04:00
|
|
|
if (BackendTypeBit(type) & aBackendBitmask) {
|
|
|
|
allowedBackends |= BackendTypeBit(type);
|
|
|
|
if (result == BackendType::NONE) {
|
2013-08-26 08:13:24 +04:00
|
|
|
result = type;
|
2012-07-25 04:45:58 +04:00
|
|
|
}
|
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2013-08-26 08:13:24 +04:00
|
|
|
|
|
|
|
aBackendBitmask = allowedBackends;
|
|
|
|
return result;
|
2012-07-25 04:45:58 +04:00
|
|
|
}
|
|
|
|
|
2015-04-24 22:33:35 +03:00
|
|
|
bool gfxPlatform::InSafeMode() {
|
|
|
|
static bool sSafeModeInitialized = false;
|
|
|
|
static bool sInSafeMode = false;
|
|
|
|
|
|
|
|
if (!sSafeModeInitialized) {
|
|
|
|
sSafeModeInitialized = true;
|
|
|
|
nsCOMPtr<nsIXULRuntime> xr = do_GetService("@mozilla.org/xre/runtime;1");
|
|
|
|
if (xr) {
|
|
|
|
xr->GetInSafeMode(&sInSafeMode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sInSafeMode;
|
|
|
|
}
|
|
|
|
|
2012-08-26 05:27:28 +04:00
|
|
|
bool gfxPlatform::OffMainThreadCompositingEnabled() {
|
2014-06-06 17:51:24 +04:00
|
|
|
return UsesOffMainThreadCompositing();
|
2012-08-26 05:27:28 +04:00
|
|
|
}
|
|
|
|
|
2013-09-07 07:08:36 +04:00
|
|
|
eCMSMode gfxPlatform::GetCMSMode() {
|
2015-01-14 01:02:34 +03:00
|
|
|
if (!gCMSInitialized) {
|
2019-06-26 03:38:09 +03:00
|
|
|
int32_t mode = StaticPrefs::gfx_color_management_mode();
|
2014-03-06 01:25:09 +04:00
|
|
|
if (mode >= 0 && mode < eCMSMode_AllCount) {
|
2013-09-07 07:08:36 +04:00
|
|
|
gCMSMode = static_cast<eCMSMode>(mode);
|
|
|
|
}
|
|
|
|
|
2019-06-26 03:38:09 +03:00
|
|
|
bool enableV4 = StaticPrefs::gfx_color_management_enablev4();
|
2014-03-06 01:25:09 +04:00
|
|
|
if (enableV4) {
|
2013-09-07 07:08:36 +04:00
|
|
|
qcms_enable_iccv4();
|
|
|
|
}
|
2019-06-13 14:12:43 +03:00
|
|
|
#ifdef MOZILLA_MAY_SUPPORT_NEON
|
|
|
|
if (mozilla::supports_neon()) {
|
|
|
|
qcms_enable_neon();
|
|
|
|
}
|
|
|
|
#endif
|
2015-01-14 01:02:34 +03:00
|
|
|
gCMSInitialized = true;
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2013-09-07 07:08:36 +04:00
|
|
|
return gCMSMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
int gfxPlatform::GetRenderingIntent() {
|
2019-07-25 07:08:23 +03:00
|
|
|
// StaticPrefs.yaml is using 0 as the default for the rendering
|
2015-01-14 01:02:34 +03:00
|
|
|
// intent preference, based on that being the value for
|
|
|
|
// QCMS_INTENT_DEFAULT. Assert here to catch if that ever
|
|
|
|
// changes and we can then figure out what to do about it.
|
|
|
|
MOZ_ASSERT(QCMS_INTENT_DEFAULT == 0);
|
|
|
|
|
|
|
|
/* Try to query the pref system for a rendering intent. */
|
2019-06-26 03:38:09 +03:00
|
|
|
int32_t pIntent = StaticPrefs::gfx_color_management_rendering_intent();
|
2015-01-14 01:02:34 +03:00
|
|
|
if ((pIntent < QCMS_INTENT_MIN) || (pIntent > QCMS_INTENT_MAX)) {
|
|
|
|
/* If the pref is out of range, use embedded profile. */
|
|
|
|
pIntent = -1;
|
|
|
|
}
|
|
|
|
return pIntent;
|
2013-09-07 07:08:36 +04:00
|
|
|
}
|
|
|
|
|
2014-10-17 15:53:15 +04:00
|
|
|
void gfxPlatform::TransformPixel(const Color& in, Color& out,
|
|
|
|
qcms_transform* transform) {
|
2013-09-07 07:08:36 +04:00
|
|
|
if (transform) {
|
|
|
|
/* we want the bytes in RGB order */
|
|
|
|
#ifdef IS_LITTLE_ENDIAN
|
|
|
|
/* ABGR puts the bytes in |RGBA| order on little endian */
|
2014-10-17 15:53:15 +04:00
|
|
|
uint32_t packed = in.ToABGR();
|
2013-09-07 07:08:36 +04:00
|
|
|
qcms_transform_data(transform, (uint8_t*)&packed, (uint8_t*)&packed, 1);
|
2014-10-17 15:53:15 +04:00
|
|
|
out = Color::FromABGR(packed);
|
2013-09-07 07:08:36 +04:00
|
|
|
#else
|
|
|
|
/* ARGB puts the bytes in |ARGB| order on big endian */
|
2015-09-25 04:16:50 +03:00
|
|
|
uint32_t packed = in.UnusualToARGB();
|
2013-09-07 07:08:36 +04:00
|
|
|
/* add one to move past the alpha byte */
|
|
|
|
qcms_transform_data(transform, (uint8_t*)&packed + 1, (uint8_t*)&packed + 1,
|
|
|
|
1);
|
2015-09-25 04:16:50 +03:00
|
|
|
out = Color::UnusualFromARGB(packed);
|
2013-09-07 07:08:36 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (&out != &in)
|
|
|
|
out = in;
|
|
|
|
}
|
|
|
|
|
2013-11-07 14:20:08 +04:00
|
|
|
void gfxPlatform::GetPlatformCMSOutputProfile(void*& mem, size_t& size) {
|
|
|
|
mem = nullptr;
|
|
|
|
size = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void gfxPlatform::GetCMSOutputProfileData(void*& mem, size_t& size) {
|
2017-07-31 07:28:48 +03:00
|
|
|
nsAutoCString fname;
|
|
|
|
Preferences::GetCString("gfx.color_management.display_profile", fname);
|
2019-02-01 22:10:22 +03:00
|
|
|
mem = nullptr;
|
2013-11-07 14:20:08 +04:00
|
|
|
if (!fname.IsEmpty()) {
|
2017-07-31 07:28:48 +03:00
|
|
|
qcms_data_from_path(fname.get(), &mem, &size);
|
2019-02-01 22:10:22 +03:00
|
|
|
}
|
|
|
|
if (mem == nullptr) {
|
2013-11-07 14:20:08 +04:00
|
|
|
gfxPlatform::GetPlatform()->GetPlatformCMSOutputProfile(mem, size);
|
|
|
|
}
|
2007-07-24 02:02:17 +04:00
|
|
|
}
|
|
|
|
|
2013-09-07 07:08:36 +04:00
|
|
|
void gfxPlatform::CreateCMSOutputProfile() {
|
|
|
|
if (!gCMSOutputProfile) {
|
|
|
|
/* Determine if we're using the internal override to force sRGB as
|
|
|
|
an output profile for reftests. See Bug 452125.
|
|
|
|
|
2018-11-28 12:16:55 +03:00
|
|
|
Note that we don't normally (outside of tests) set a default value
|
|
|
|
of this preference, which means nsIPrefBranch::GetBoolPref will
|
|
|
|
typically throw (and leave its out-param untouched).
|
2018-11-30 13:46:48 +03:00
|
|
|
*/
|
2013-09-07 07:08:36 +04:00
|
|
|
if (Preferences::GetBool(GFX_PREF_CMS_FORCE_SRGB, false)) {
|
|
|
|
gCMSOutputProfile = GetCMSsRGBProfile();
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2013-09-07 07:08:36 +04:00
|
|
|
|
2013-11-07 14:20:08 +04:00
|
|
|
if (!gCMSOutputProfile) {
|
|
|
|
void* mem = nullptr;
|
|
|
|
size_t size = 0;
|
2014-01-13 19:25:52 +04:00
|
|
|
|
2013-09-07 07:08:36 +04:00
|
|
|
GetCMSOutputProfileData(mem, size);
|
|
|
|
if ((mem != nullptr) && (size > 0)) {
|
|
|
|
gCMSOutputProfile = qcms_profile_from_memory(mem, size);
|
|
|
|
free(mem);
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2013-09-07 07:08:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Determine if the profile looks bogus. If so, close the profile
|
|
|
|
* and use sRGB instead. See bug 460629, */
|
|
|
|
if (gCMSOutputProfile && qcms_profile_is_bogus(gCMSOutputProfile)) {
|
|
|
|
NS_ASSERTION(gCMSOutputProfile != GetCMSsRGBProfile(),
|
|
|
|
"Builtin sRGB profile tagged as bogus!!!");
|
|
|
|
qcms_profile_release(gCMSOutputProfile);
|
|
|
|
gCMSOutputProfile = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!gCMSOutputProfile) {
|
|
|
|
gCMSOutputProfile = GetCMSsRGBProfile();
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2013-09-07 07:08:36 +04:00
|
|
|
/* Precache the LUT16 Interpolations for the output profile. See
|
|
|
|
bug 444661 for details. */
|
|
|
|
qcms_profile_precache_output_transform(gCMSOutputProfile);
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2013-09-07 07:08:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
qcms_profile* gfxPlatform::GetCMSOutputProfile() { return gCMSOutputProfile; }
|
|
|
|
|
|
|
|
qcms_profile* gfxPlatform::GetCMSsRGBProfile() {
|
|
|
|
if (!gCMSsRGBProfile) {
|
|
|
|
/* Create the profile using qcms. */
|
|
|
|
gCMSsRGBProfile = qcms_profile_sRGB();
|
|
|
|
}
|
|
|
|
return gCMSsRGBProfile;
|
|
|
|
}
|
|
|
|
|
|
|
|
qcms_transform* gfxPlatform::GetCMSRGBTransform() {
|
2018-06-19 16:32:29 +03:00
|
|
|
if (!gCMSRGBTransform && !gCMSRGBTransformFailed) {
|
2013-09-07 07:08:36 +04:00
|
|
|
qcms_profile *inProfile, *outProfile;
|
|
|
|
outProfile = GetCMSOutputProfile();
|
|
|
|
inProfile = GetCMSsRGBProfile();
|
|
|
|
|
|
|
|
if (!inProfile || !outProfile) return nullptr;
|
|
|
|
|
|
|
|
gCMSRGBTransform =
|
|
|
|
qcms_transform_create(inProfile, QCMS_DATA_RGB_8, outProfile,
|
|
|
|
QCMS_DATA_RGB_8, QCMS_INTENT_PERCEPTUAL);
|
2018-06-19 16:32:29 +03:00
|
|
|
if (!gCMSRGBTransform) {
|
|
|
|
gCMSRGBTransformFailed = true;
|
2013-09-07 07:08:36 +04:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2013-09-07 07:08:36 +04:00
|
|
|
|
|
|
|
return gCMSRGBTransform;
|
|
|
|
}
|
|
|
|
|
|
|
|
qcms_transform* gfxPlatform::GetCMSInverseRGBTransform() {
|
|
|
|
if (!gCMSInverseRGBTransform) {
|
|
|
|
qcms_profile *inProfile, *outProfile;
|
|
|
|
inProfile = GetCMSOutputProfile();
|
|
|
|
outProfile = GetCMSsRGBProfile();
|
|
|
|
|
|
|
|
if (!inProfile || !outProfile) return nullptr;
|
|
|
|
|
|
|
|
gCMSInverseRGBTransform =
|
|
|
|
qcms_transform_create(inProfile, QCMS_DATA_RGB_8, outProfile,
|
|
|
|
QCMS_DATA_RGB_8, QCMS_INTENT_PERCEPTUAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
return gCMSInverseRGBTransform;
|
|
|
|
}
|
|
|
|
|
|
|
|
qcms_transform* gfxPlatform::GetCMSRGBATransform() {
|
|
|
|
if (!gCMSRGBATransform) {
|
|
|
|
qcms_profile *inProfile, *outProfile;
|
|
|
|
outProfile = GetCMSOutputProfile();
|
|
|
|
inProfile = GetCMSsRGBProfile();
|
|
|
|
|
|
|
|
if (!inProfile || !outProfile) return nullptr;
|
|
|
|
|
|
|
|
gCMSRGBATransform =
|
|
|
|
qcms_transform_create(inProfile, QCMS_DATA_RGBA_8, outProfile,
|
|
|
|
QCMS_DATA_RGBA_8, QCMS_INTENT_PERCEPTUAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
return gCMSRGBATransform;
|
|
|
|
}
|
|
|
|
|
2019-05-09 23:45:51 +03:00
|
|
|
qcms_transform* gfxPlatform::GetCMSBGRATransform() {
|
|
|
|
if (!gCMSBGRATransform) {
|
|
|
|
qcms_profile *inProfile, *outProfile;
|
|
|
|
outProfile = GetCMSOutputProfile();
|
|
|
|
inProfile = GetCMSsRGBProfile();
|
|
|
|
|
|
|
|
if (!inProfile || !outProfile) return nullptr;
|
|
|
|
|
|
|
|
gCMSBGRATransform =
|
|
|
|
qcms_transform_create(inProfile, QCMS_DATA_BGRA_8, outProfile,
|
|
|
|
QCMS_DATA_BGRA_8, QCMS_INTENT_PERCEPTUAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
return gCMSBGRATransform;
|
|
|
|
}
|
|
|
|
|
2013-09-07 07:08:36 +04:00
|
|
|
/* Shuts down various transforms and profiles for CMS. */
|
|
|
|
static void ShutdownCMS() {
|
|
|
|
if (gCMSRGBTransform) {
|
|
|
|
qcms_transform_release(gCMSRGBTransform);
|
|
|
|
gCMSRGBTransform = nullptr;
|
|
|
|
}
|
|
|
|
if (gCMSInverseRGBTransform) {
|
|
|
|
qcms_transform_release(gCMSInverseRGBTransform);
|
|
|
|
gCMSInverseRGBTransform = nullptr;
|
|
|
|
}
|
|
|
|
if (gCMSRGBATransform) {
|
|
|
|
qcms_transform_release(gCMSRGBATransform);
|
|
|
|
gCMSRGBATransform = nullptr;
|
|
|
|
}
|
2019-05-09 23:45:51 +03:00
|
|
|
if (gCMSBGRATransform) {
|
|
|
|
qcms_transform_release(gCMSBGRATransform);
|
|
|
|
gCMSBGRATransform = nullptr;
|
|
|
|
}
|
2013-09-07 07:08:36 +04:00
|
|
|
if (gCMSOutputProfile) {
|
|
|
|
qcms_profile_release(gCMSOutputProfile);
|
|
|
|
|
|
|
|
// handle the aliased case
|
|
|
|
if (gCMSsRGBProfile == gCMSOutputProfile) gCMSsRGBProfile = nullptr;
|
|
|
|
gCMSOutputProfile = nullptr;
|
|
|
|
}
|
|
|
|
if (gCMSsRGBProfile) {
|
|
|
|
qcms_profile_release(gCMSsRGBProfile);
|
|
|
|
gCMSsRGBProfile = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reset the state variables
|
|
|
|
gCMSMode = eCMSMode_Off;
|
|
|
|
gCMSInitialized = false;
|
|
|
|
}
|
|
|
|
|
2011-12-06 16:39:19 +04:00
|
|
|
int32_t gfxPlatform::GetBidiNumeralOption() {
|
|
|
|
if (mBidiNumeralOption == UNINITIALIZED_VALUE) {
|
|
|
|
mBidiNumeralOption = Preferences::GetInt(BIDI_NUMERAL_PREF, 0);
|
2009-10-07 19:26:58 +04:00
|
|
|
}
|
2011-12-06 16:39:19 +04:00
|
|
|
return mBidiNumeralOption;
|
2009-10-07 19:26:58 +04:00
|
|
|
}
|
2010-05-27 09:05:30 +04:00
|
|
|
|
2019-02-26 01:07:19 +03:00
|
|
|
/* static */
|
|
|
|
void gfxPlatform::FlushFontAndWordCaches() {
|
2013-09-11 05:36:57 +04:00
|
|
|
gfxFontCache* fontCache = gfxFontCache::GetCache();
|
|
|
|
if (fontCache) {
|
|
|
|
fontCache->AgeAllGenerations();
|
|
|
|
fontCache->FlushShapedWordCaches();
|
|
|
|
}
|
2016-03-23 21:17:02 +03:00
|
|
|
|
|
|
|
gfxPlatform::PurgeSkiaFontCache();
|
2013-09-11 05:36:57 +04:00
|
|
|
}
|
|
|
|
|
2019-02-26 01:07:19 +03:00
|
|
|
/* static */
|
|
|
|
void gfxPlatform::ForceGlobalReflow() {
|
2018-02-22 23:55:36 +03:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
if (XRE_IsParentProcess()) {
|
|
|
|
// Modify a preference that will trigger reflow everywhere (in all
|
|
|
|
// content processes, as well as the parent).
|
|
|
|
static const char kPrefName[] = "font.internaluseonly.changed";
|
|
|
|
bool fontInternalChange = Preferences::GetBool(kPrefName, false);
|
|
|
|
Preferences::SetBool(kPrefName, !fontInternalChange);
|
|
|
|
} else {
|
|
|
|
// Send a notification that will be observed by PresShells in this
|
|
|
|
// process only.
|
|
|
|
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
|
|
|
|
if (obs) {
|
|
|
|
obs->NotifyObservers(nullptr, "font-info-updated", nullptr);
|
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2017-09-14 19:26:53 +03:00
|
|
|
}
|
|
|
|
|
2011-06-12 06:30:16 +04:00
|
|
|
void gfxPlatform::FontsPrefsChanged(const char* aPref) {
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_ASSERTION(aPref != nullptr, "null preference");
|
2010-05-27 09:05:30 +04:00
|
|
|
if (!strcmp(GFX_DOWNLOADABLE_FONTS_ENABLED, aPref)) {
|
|
|
|
mAllowDownloadableFonts = UNINITIALIZED_VALUE;
|
2012-03-09 06:05:40 +04:00
|
|
|
} else if (!strcmp(GFX_PREF_FALLBACK_USE_CMAPS, aPref)) {
|
|
|
|
mFallbackUsesCmaps = UNINITIALIZED_VALUE;
|
2013-09-11 05:36:57 +04:00
|
|
|
} else if (!strcmp(GFX_PREF_WORD_CACHE_CHARLIMIT, aPref)) {
|
|
|
|
mWordCacheCharLimit = UNINITIALIZED_VALUE;
|
2013-09-11 05:36:57 +04:00
|
|
|
FlushFontAndWordCaches();
|
|
|
|
} else if (!strcmp(GFX_PREF_WORD_CACHE_MAXENTRIES, aPref)) {
|
|
|
|
mWordCacheMaxEntries = UNINITIALIZED_VALUE;
|
|
|
|
FlushFontAndWordCaches();
|
2011-12-10 02:32:29 +04:00
|
|
|
} else if (!strcmp(GFX_PREF_GRAPHITE_SHAPING, aPref)) {
|
|
|
|
mGraphiteShapingEnabled = UNINITIALIZED_VALUE;
|
2013-09-11 05:36:57 +04:00
|
|
|
FlushFontAndWordCaches();
|
2019-05-20 17:29:15 +03:00
|
|
|
#if defined(XP_MACOSX)
|
|
|
|
} else if (!strcmp(GFX_PREF_CORETEXT_SHAPING, aPref)) {
|
|
|
|
FlushFontAndWordCaches();
|
|
|
|
#endif
|
2011-12-06 16:39:19 +04:00
|
|
|
} else if (!strcmp(BIDI_NUMERAL_PREF, aPref)) {
|
|
|
|
mBidiNumeralOption = UNINITIALIZED_VALUE;
|
2012-09-06 08:57:54 +04:00
|
|
|
} else if (!strcmp(GFX_PREF_OPENTYPE_SVG, aPref)) {
|
2013-05-16 20:32:41 +04:00
|
|
|
mOpenTypeSVGEnabled = UNINITIALIZED_VALUE;
|
2012-09-06 08:57:54 +04:00
|
|
|
gfxFontCache::GetCache()->AgeAllGenerations();
|
2017-05-16 08:30:15 +03:00
|
|
|
gfxFontCache::GetCache()->NotifyGlyphsChanged();
|
2010-05-27 09:05:30 +04:00
|
|
|
}
|
|
|
|
}
|
2011-01-21 19:44:33 +03:00
|
|
|
|
|
|
|
mozilla::LogModule* gfxPlatform::GetLog(eGfxLog aWhichLog) {
|
2014-02-14 19:27:47 +04:00
|
|
|
// logs shared across gfx
|
2015-10-30 01:58:24 +03:00
|
|
|
static LazyLogModule sFontlistLog("fontlist");
|
|
|
|
static LazyLogModule sFontInitLog("fontinit");
|
|
|
|
static LazyLogModule sTextrunLog("textrun");
|
|
|
|
static LazyLogModule sTextrunuiLog("textrunui");
|
|
|
|
static LazyLogModule sCmapDataLog("cmapdata");
|
|
|
|
static LazyLogModule sTextPerfLog("textperf");
|
2011-01-21 19:44:33 +03:00
|
|
|
|
|
|
|
switch (aWhichLog) {
|
|
|
|
case eGfxLog_fontlist:
|
|
|
|
return sFontlistLog;
|
|
|
|
case eGfxLog_fontinit:
|
|
|
|
return sFontInitLog;
|
|
|
|
case eGfxLog_textrun:
|
|
|
|
return sTextrunLog;
|
|
|
|
case eGfxLog_textrunui:
|
|
|
|
return sTextrunuiLog;
|
2012-03-09 06:05:14 +04:00
|
|
|
case eGfxLog_cmapdata:
|
|
|
|
return sCmapDataLog;
|
2013-11-25 08:59:56 +04:00
|
|
|
case eGfxLog_textperf:
|
|
|
|
return sTextPerfLog;
|
2011-01-21 19:44:33 +03:00
|
|
|
}
|
|
|
|
|
2015-06-04 09:13:42 +03:00
|
|
|
MOZ_ASSERT_UNREACHABLE("Unexpected log type");
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2011-01-21 19:44:33 +03:00
|
|
|
}
|
2012-05-15 23:41:20 +04:00
|
|
|
|
2017-08-09 13:00:01 +03:00
|
|
|
RefPtr<mozilla::gfx::DrawTarget> gfxPlatform::ScreenReferenceDrawTarget() {
|
|
|
|
return (mScreenReferenceDrawTarget)
|
|
|
|
? mScreenReferenceDrawTarget
|
|
|
|
: gPlatform->CreateOffscreenContentDrawTarget(
|
|
|
|
IntSize(1, 1), SurfaceFormat::B8G8R8A8, true);
|
|
|
|
}
|
|
|
|
|
2013-09-25 00:45:13 +04:00
|
|
|
mozilla::gfx::SurfaceFormat gfxPlatform::Optimal2DFormatForContent(
|
|
|
|
gfxContentType aContent) {
|
2012-05-26 08:38:17 +04:00
|
|
|
switch (aContent) {
|
2014-01-23 22:26:40 +04:00
|
|
|
case gfxContentType::COLOR:
|
2012-06-20 08:03:24 +04:00
|
|
|
switch (GetOffscreenFormat()) {
|
2016-01-08 07:57:38 +03:00
|
|
|
case SurfaceFormat::A8R8G8B8_UINT32:
|
2014-01-10 23:06:16 +04:00
|
|
|
return mozilla::gfx::SurfaceFormat::B8G8R8A8;
|
2016-01-08 07:57:38 +03:00
|
|
|
case SurfaceFormat::X8R8G8B8_UINT32:
|
2014-01-10 23:06:16 +04:00
|
|
|
return mozilla::gfx::SurfaceFormat::B8G8R8X8;
|
2016-01-08 07:57:38 +03:00
|
|
|
case SurfaceFormat::R5G6B5_UINT16:
|
2015-10-23 09:01:31 +03:00
|
|
|
return mozilla::gfx::SurfaceFormat::R5G6B5_UINT16;
|
2018-11-30 13:46:48 +03:00
|
|
|
default:
|
2018-06-18 08:43:11 +03:00
|
|
|
MOZ_ASSERT_UNREACHABLE(
|
|
|
|
"unknown gfxImageFormat for "
|
|
|
|
"gfxContentType::COLOR");
|
2014-01-10 23:06:16 +04:00
|
|
|
return mozilla::gfx::SurfaceFormat::B8G8R8A8;
|
2018-11-30 13:46:48 +03:00
|
|
|
}
|
2014-01-23 22:26:40 +04:00
|
|
|
case gfxContentType::ALPHA:
|
2014-01-10 23:06:16 +04:00
|
|
|
return mozilla::gfx::SurfaceFormat::A8;
|
2014-01-23 22:26:40 +04:00
|
|
|
case gfxContentType::COLOR_ALPHA:
|
2014-01-10 23:06:16 +04:00
|
|
|
return mozilla::gfx::SurfaceFormat::B8G8R8A8;
|
2012-06-20 08:03:24 +04:00
|
|
|
default:
|
2018-06-18 08:43:11 +03:00
|
|
|
MOZ_ASSERT_UNREACHABLE("unknown gfxContentType");
|
2014-01-10 23:06:16 +04:00
|
|
|
return mozilla::gfx::SurfaceFormat::B8G8R8A8;
|
2012-05-26 08:38:17 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-25 00:45:13 +04:00
|
|
|
gfxImageFormat gfxPlatform::OptimalFormatForContent(gfxContentType aContent) {
|
2012-05-26 08:38:17 +04:00
|
|
|
switch (aContent) {
|
2014-01-23 22:26:40 +04:00
|
|
|
case gfxContentType::COLOR:
|
2012-05-26 08:38:17 +04:00
|
|
|
return GetOffscreenFormat();
|
2014-01-23 22:26:40 +04:00
|
|
|
case gfxContentType::ALPHA:
|
2016-01-08 07:57:38 +03:00
|
|
|
return SurfaceFormat::A8;
|
2014-01-23 22:26:40 +04:00
|
|
|
case gfxContentType::COLOR_ALPHA:
|
2016-01-08 07:57:38 +03:00
|
|
|
return SurfaceFormat::A8R8G8B8_UINT32;
|
2012-05-26 08:38:17 +04:00
|
|
|
default:
|
2018-06-18 08:43:11 +03:00
|
|
|
MOZ_ASSERT_UNREACHABLE("unknown gfxContentType");
|
2016-01-08 07:57:38 +03:00
|
|
|
return SurfaceFormat::A8R8G8B8_UINT32;
|
2012-05-26 08:38:17 +04:00
|
|
|
}
|
|
|
|
}
|
2012-11-22 06:40:57 +04:00
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
/**
|
|
|
|
* There are a number of layers acceleration (or layers in general) preferences
|
|
|
|
* that should be consistent for the lifetime of the application (bug 840967).
|
|
|
|
* As such, we will evaluate them all as soon as one of them is evaluated
|
|
|
|
* and remember the values. Changing these preferences during the run will
|
|
|
|
* not have any effect until we restart.
|
|
|
|
*/
|
2016-05-12 12:24:43 +03:00
|
|
|
static mozilla::Atomic<bool> sLayersSupportsHardwareVideoDecoding(false);
|
2015-05-27 05:05:18 +03:00
|
|
|
static bool sLayersHardwareVideoDecodingFailed = false;
|
2014-02-27 06:53:27 +04:00
|
|
|
static bool sBufferRotationCheckPref = true;
|
2013-08-04 11:46:17 +04:00
|
|
|
|
2016-05-12 12:24:43 +03:00
|
|
|
static mozilla::Atomic<bool> sLayersAccelerationPrefsInitialized(false);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 13:20:52 +04:00
|
|
|
|
2019-02-17 12:18:01 +03:00
|
|
|
static void VideoDecodingFailedChangedCallback(const char* aPref, void*) {
|
2016-08-25 06:48:35 +03:00
|
|
|
sLayersHardwareVideoDecodingFailed = Preferences::GetBool(aPref, false);
|
2016-09-28 01:34:48 +03:00
|
|
|
gfxPlatform::GetPlatform()->UpdateCanUseHardwareVideoDecoding();
|
2016-08-25 06:48:35 +03:00
|
|
|
}
|
|
|
|
|
2016-09-28 01:34:48 +03:00
|
|
|
void gfxPlatform::UpdateCanUseHardwareVideoDecoding() {
|
|
|
|
if (XRE_IsParentProcess()) {
|
|
|
|
gfxVars::SetCanUseHardwareVideoDecoding(CanUseHardwareVideoDecoding());
|
|
|
|
}
|
2016-08-25 06:48:35 +03:00
|
|
|
}
|
|
|
|
|
2016-04-29 07:52:54 +03:00
|
|
|
void gfxPlatform::InitAcceleration() {
|
2016-04-29 07:52:54 +03:00
|
|
|
if (sLayersAccelerationPrefsInitialized) {
|
|
|
|
return;
|
|
|
|
}
|
2013-08-04 11:46:17 +04:00
|
|
|
|
2016-04-29 07:52:54 +03:00
|
|
|
InitCompositorAccelerationPrefs();
|
|
|
|
|
2016-04-29 07:52:54 +03:00
|
|
|
// If this is called for the first time on a non-main thread, we're screwed.
|
|
|
|
// At the moment there's no explicit guarantee that the main thread calls
|
|
|
|
// this before the compositor thread, but let's at least make the assumption
|
|
|
|
// explicit.
|
|
|
|
MOZ_ASSERT(NS_IsMainThread(), "can only initialize prefs on the main thread");
|
2016-04-28 08:54:24 +03:00
|
|
|
|
2017-07-25 21:02:36 +03:00
|
|
|
nsCOMPtr<nsIGfxInfo> gfxInfo = services::GetGfxInfo();
|
|
|
|
nsCString discardFailureId;
|
|
|
|
int32_t status;
|
|
|
|
|
2016-08-04 21:33:44 +03:00
|
|
|
if (XRE_IsParentProcess()) {
|
|
|
|
gfxVars::SetBrowserTabsRemoteAutostart(BrowserTabsRemoteAutostart());
|
2016-08-24 21:02:00 +03:00
|
|
|
gfxVars::SetOffscreenFormat(GetOffscreenFormat());
|
2016-08-24 21:03:00 +03:00
|
|
|
gfxVars::SetRequiresAcceleratedGLContextForCompositorOGL(
|
|
|
|
RequiresAcceleratedGLContextForCompositorOGL());
|
2017-07-25 21:02:36 +03:00
|
|
|
#ifdef XP_WIN
|
|
|
|
if (NS_SUCCEEDED(
|
|
|
|
gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_D3D11_KEYED_MUTEX,
|
|
|
|
discardFailureId, &status))) {
|
|
|
|
gfxVars::SetAllowD3D11KeyedMutex(status == nsIGfxInfo::FEATURE_STATUS_OK);
|
|
|
|
} else {
|
|
|
|
// If we couldn't properly evaluate the status, err on the side
|
|
|
|
// of caution and give this functionality to the user.
|
|
|
|
gfxCriticalNote << "Cannot evaluate keyed mutex feature status";
|
|
|
|
gfxVars::SetAllowD3D11KeyedMutex(true);
|
|
|
|
}
|
2019-07-09 09:37:45 +03:00
|
|
|
if (StaticPrefs::gfx_direct3d11_use_double_buffering() &&
|
|
|
|
IsWin10OrLater()) {
|
|
|
|
gfxVars::SetUseDoubleBufferingWithCompositor(true);
|
|
|
|
}
|
2017-07-25 21:02:36 +03:00
|
|
|
#endif
|
2016-08-04 21:33:44 +03:00
|
|
|
}
|
2016-04-29 07:52:54 +03:00
|
|
|
|
|
|
|
if (Preferences::GetBool("media.hardware-video-decoding.enabled", false) &&
|
2015-04-01 06:06:56 +03:00
|
|
|
#ifdef XP_WIN
|
2017-09-26 18:32:02 +03:00
|
|
|
Preferences::GetBool("media.wmf.dxva.enabled", true) &&
|
2015-04-01 06:06:56 +03:00
|
|
|
#endif
|
2016-04-29 07:52:54 +03:00
|
|
|
NS_SUCCEEDED(
|
|
|
|
gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING,
|
2016-04-14 00:12:47 +03:00
|
|
|
discardFailureId, &status))) {
|
2016-04-29 07:52:54 +03:00
|
|
|
if (status == nsIGfxInfo::FEATURE_STATUS_OK ||
|
2019-07-22 05:10:14 +03:00
|
|
|
StaticPrefs::media_hardware_video_decoding_force_enabled_AtStartup()) {
|
2017-04-15 00:34:01 +03:00
|
|
|
sLayersSupportsHardwareVideoDecoding = true;
|
|
|
|
}
|
2016-04-29 07:52:54 +03:00
|
|
|
}
|
2016-04-28 08:54:25 +03:00
|
|
|
|
2016-08-25 06:48:35 +03:00
|
|
|
sLayersAccelerationPrefsInitialized = true;
|
2016-04-28 08:54:25 +03:00
|
|
|
|
2016-06-11 05:27:24 +03:00
|
|
|
if (XRE_IsParentProcess()) {
|
2016-08-25 06:48:35 +03:00
|
|
|
Preferences::RegisterCallbackAndCall(
|
|
|
|
VideoDecodingFailedChangedCallback,
|
2017-03-21 21:59:02 +03:00
|
|
|
"media.hardware-video-decoding.failed");
|
2016-10-28 05:21:34 +03:00
|
|
|
InitGPUProcessPrefs();
|
2018-11-28 23:44:27 +03:00
|
|
|
|
2019-06-26 03:38:09 +03:00
|
|
|
gfxVars::SetRemoteCanvasEnabled(StaticPrefs::gfx_canvas_remote() &&
|
2018-11-28 23:44:27 +03:00
|
|
|
gfxConfig::IsEnabled(Feature::GPU_PROCESS));
|
2016-10-28 05:21:34 +03:00
|
|
|
}
|
|
|
|
}
|
2016-08-25 06:48:35 +03:00
|
|
|
|
2016-10-28 05:21:34 +03:00
|
|
|
void gfxPlatform::InitGPUProcessPrefs() {
|
|
|
|
// We want to hide this from about:support, so only set a default if the
|
|
|
|
// pref is known to be true.
|
2019-07-22 05:10:14 +03:00
|
|
|
if (!StaticPrefs::layers_gpu_process_enabled_AtStartup() &&
|
|
|
|
!StaticPrefs::layers_gpu_process_force_enabled_AtStartup()) {
|
2016-10-28 05:21:34 +03:00
|
|
|
return;
|
|
|
|
}
|
2016-06-11 05:27:24 +03:00
|
|
|
|
2016-10-28 05:21:34 +03:00
|
|
|
FeatureState& gpuProc = gfxConfig::GetFeature(Feature::GPU_PROCESS);
|
|
|
|
|
|
|
|
// We require E10S - otherwise, there is very little benefit to the GPU
|
|
|
|
// process, since the UI process must still use acceleration for
|
|
|
|
// performance.
|
|
|
|
if (!BrowserTabsRemoteAutostart()) {
|
|
|
|
gpuProc.DisableByDefault(FeatureStatus::Unavailable,
|
|
|
|
"Multi-process mode is not enabled",
|
|
|
|
NS_LITERAL_CSTRING("FEATURE_FAILURE_NO_E10S"));
|
2017-01-27 03:35:55 +03:00
|
|
|
} else {
|
2019-06-27 07:48:58 +03:00
|
|
|
gpuProc.SetDefaultFromPref(
|
2019-07-03 01:32:09 +03:00
|
|
|
StaticPrefs::GetPrefName_layers_gpu_process_enabled(), true,
|
|
|
|
StaticPrefs::GetPrefDefault_layers_gpu_process_enabled());
|
2017-01-27 03:35:55 +03:00
|
|
|
}
|
|
|
|
|
2019-07-22 05:10:14 +03:00
|
|
|
if (StaticPrefs::layers_gpu_process_force_enabled_AtStartup()) {
|
2017-01-27 03:35:55 +03:00
|
|
|
gpuProc.UserForceEnable("User force-enabled via pref");
|
2016-10-28 05:21:34 +03:00
|
|
|
}
|
2017-01-27 03:35:55 +03:00
|
|
|
|
Bug 1373739 - Make headless compositing Windows-compatible, in addition to Linux. r=dvander
To make the HeadlessCompositorWidget work under Windows as well as Linux, I had
to change the way that I hooked it into the existing CompositorWidget system.
Under GTK, the CompositorWidgetInitData and CompositorWidgetDelegate types
provided the information needed by the headless compositor widget already (the
widget client size). On Windows, however, the definitions of these types
differ, and the client size information is simply retrieved from the platform
APIs when needed.
After this patch, CompositorWidgetDelegate is renamed to
PlatformCompositorWidgetDelegate, and a new base class called
CompositorWidgetDelegate is added with "AsPlatformSpecificDelegate()" and
"AsHeadlessCompositorWidget()" methods. In non-headless mode, widgets use
AsPlatformSpecificDelegate() to access the Windows- and GTK-specific delegate
APIs. In headless mode, AsHeadlessCompositorWidget() is used to access the
singular CompositorWidget implementation for headless. Meanwhile, the
CompositorWidgetInitData IPDL type is made into a union which always contains a
headless-specific HeadlessCompositorWidgetInitData struct and under GTK and
Windows also contains an {X11,Win}CompositorWidgetInitData struct.
This also includes a small patch to ensure that the GPU process and
hardware-accelerated compositing are always disabled under headless mode. These
features weren't activated by default in the Linux environments I tested in, but
did end up activating (and then promptly crashing Firefox) when I tested on
Windows.
MozReview-Commit-ID: CocPoHBDV7H
--HG--
extra : rebase_source : 4581fa63aa3a9f32a8dc2672015a35b9be01b20f
2017-07-07 03:45:34 +03:00
|
|
|
if (IsHeadless()) {
|
|
|
|
gpuProc.ForceDisable(FeatureStatus::Blocked, "Headless mode is enabled",
|
|
|
|
NS_LITERAL_CSTRING("FEATURE_FAILURE_HEADLESS_MODE"));
|
|
|
|
return;
|
|
|
|
}
|
2016-10-28 05:21:34 +03:00
|
|
|
if (InSafeMode()) {
|
|
|
|
gpuProc.ForceDisable(FeatureStatus::Blocked, "Safe-mode is enabled",
|
|
|
|
NS_LITERAL_CSTRING("FEATURE_FAILURE_SAFE_MODE"));
|
|
|
|
return;
|
2016-06-11 05:27:24 +03:00
|
|
|
}
|
2019-06-26 03:38:09 +03:00
|
|
|
if (StaticPrefs::gfx_layerscope_enabled()) {
|
2016-11-10 21:55:32 +03:00
|
|
|
gpuProc.ForceDisable(FeatureStatus::Blocked,
|
|
|
|
"LayerScope does not work in the GPU process",
|
|
|
|
NS_LITERAL_CSTRING("FEATURE_FAILURE_LAYERSCOPE"));
|
|
|
|
return;
|
|
|
|
}
|
2019-05-27 00:43:34 +03:00
|
|
|
|
|
|
|
InitPlatformGPUProcessPrefs();
|
2016-04-28 08:54:25 +03:00
|
|
|
}
|
|
|
|
|
2016-04-29 07:52:54 +03:00
|
|
|
void gfxPlatform::InitCompositorAccelerationPrefs() {
|
|
|
|
const char* acceleratedEnv = PR_GetEnv("MOZ_ACCELERATED");
|
|
|
|
|
2016-04-29 07:52:55 +03:00
|
|
|
FeatureState& feature = gfxConfig::GetFeature(Feature::HW_COMPOSITING);
|
|
|
|
|
2016-04-29 07:52:54 +03:00
|
|
|
// Base value - does the platform allow acceleration?
|
2016-04-29 07:52:55 +03:00
|
|
|
if (feature.SetDefault(AccelerateLayersByDefault(), FeatureStatus::Blocked,
|
|
|
|
"Acceleration blocked by platform")) {
|
2019-07-22 05:10:14 +03:00
|
|
|
if (StaticPrefs::
|
|
|
|
layers_acceleration_disabled_AtStartup_DoNotUseDirectly()) {
|
2016-06-03 21:54:56 +03:00
|
|
|
feature.UserDisable("Disabled by pref",
|
|
|
|
NS_LITERAL_CSTRING("FEATURE_FAILURE_COMP_PREF"));
|
2016-04-29 07:52:54 +03:00
|
|
|
} else if (acceleratedEnv && *acceleratedEnv == '0') {
|
2016-06-03 21:54:56 +03:00
|
|
|
feature.UserDisable("Disabled by envvar",
|
|
|
|
NS_LITERAL_CSTRING("FEATURE_FAILURE_COMP_ENV"));
|
2016-04-29 07:52:54 +03:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (acceleratedEnv && *acceleratedEnv == '1') {
|
2016-04-29 07:52:55 +03:00
|
|
|
feature.UserEnable("Enabled by envvar");
|
2016-04-29 07:52:54 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// This has specific meaning elsewhere, so we always record it.
|
2019-07-22 05:10:14 +03:00
|
|
|
if (StaticPrefs::
|
|
|
|
layers_acceleration_force_enabled_AtStartup_DoNotUseDirectly()) {
|
2016-04-29 07:52:55 +03:00
|
|
|
feature.UserForceEnable("Force-enabled by pref");
|
2016-04-29 07:52:54 +03:00
|
|
|
}
|
|
|
|
|
2018-07-23 17:41:58 +03:00
|
|
|
// Safe, headless, and record/replay modes override everything.
|
2016-04-29 07:52:55 +03:00
|
|
|
if (InSafeMode()) {
|
2016-06-03 21:54:56 +03:00
|
|
|
feature.ForceDisable(FeatureStatus::Blocked,
|
|
|
|
"Acceleration blocked by safe-mode",
|
|
|
|
NS_LITERAL_CSTRING("FEATURE_FAILURE_COMP_SAFEMODE"));
|
2016-04-29 07:52:55 +03:00
|
|
|
}
|
Bug 1373739 - Make headless compositing Windows-compatible, in addition to Linux. r=dvander
To make the HeadlessCompositorWidget work under Windows as well as Linux, I had
to change the way that I hooked it into the existing CompositorWidget system.
Under GTK, the CompositorWidgetInitData and CompositorWidgetDelegate types
provided the information needed by the headless compositor widget already (the
widget client size). On Windows, however, the definitions of these types
differ, and the client size information is simply retrieved from the platform
APIs when needed.
After this patch, CompositorWidgetDelegate is renamed to
PlatformCompositorWidgetDelegate, and a new base class called
CompositorWidgetDelegate is added with "AsPlatformSpecificDelegate()" and
"AsHeadlessCompositorWidget()" methods. In non-headless mode, widgets use
AsPlatformSpecificDelegate() to access the Windows- and GTK-specific delegate
APIs. In headless mode, AsHeadlessCompositorWidget() is used to access the
singular CompositorWidget implementation for headless. Meanwhile, the
CompositorWidgetInitData IPDL type is made into a union which always contains a
headless-specific HeadlessCompositorWidgetInitData struct and under GTK and
Windows also contains an {X11,Win}CompositorWidgetInitData struct.
This also includes a small patch to ensure that the GPU process and
hardware-accelerated compositing are always disabled under headless mode. These
features weren't activated by default in the Linux environments I tested in, but
did end up activating (and then promptly crashing Firefox) when I tested on
Windows.
MozReview-Commit-ID: CocPoHBDV7H
--HG--
extra : rebase_source : 4581fa63aa3a9f32a8dc2672015a35b9be01b20f
2017-07-07 03:45:34 +03:00
|
|
|
if (IsHeadless()) {
|
|
|
|
feature.ForceDisable(
|
|
|
|
FeatureStatus::Blocked, "Acceleration blocked by headless mode",
|
|
|
|
NS_LITERAL_CSTRING("FEATURE_FAILURE_COMP_HEADLESSMODE"));
|
|
|
|
}
|
2018-07-23 17:41:58 +03:00
|
|
|
if (recordreplay::IsRecordingOrReplaying()) {
|
|
|
|
feature.ForceDisable(
|
|
|
|
FeatureStatus::Blocked, "Acceleration blocked by recording/replaying",
|
|
|
|
NS_LITERAL_CSTRING("FEATURE_FAILURE_COMP_RECORDREPLAY"));
|
|
|
|
}
|
2016-04-29 07:52:54 +03:00
|
|
|
}
|
|
|
|
|
2019-02-26 01:07:19 +03:00
|
|
|
/*static*/
|
|
|
|
bool gfxPlatform::WebRenderPrefEnabled() {
|
2019-07-22 05:10:14 +03:00
|
|
|
return StaticPrefs::gfx_webrender_all_AtStartup() ||
|
|
|
|
StaticPrefs::gfx_webrender_enabled_AtStartup_DoNotUseDirectly();
|
2017-12-21 17:25:07 +03:00
|
|
|
}
|
|
|
|
|
2019-02-26 01:07:19 +03:00
|
|
|
/*static*/
|
|
|
|
bool gfxPlatform::WebRenderEnvvarEnabled() {
|
2017-12-21 17:25:07 +03:00
|
|
|
const char* env = PR_GetEnv("MOZ_WEBRENDER");
|
|
|
|
return (env && *env == '1');
|
|
|
|
}
|
|
|
|
|
2018-12-06 22:01:01 +03:00
|
|
|
static bool WebRenderEnvvarDisabled() {
|
|
|
|
const char* env = PR_GetEnv("MOZ_WEBRENDER");
|
|
|
|
return (env && *env == '0');
|
|
|
|
}
|
|
|
|
|
2019-06-29 17:02:04 +03:00
|
|
|
static bool InMarionetteRolloutTest() {
|
|
|
|
// This pref only ever gets set in test_pref_rollout_workaround, and in
|
|
|
|
// that case we want to ignore the MOZ_WEBRENDER=0 that will be set by
|
|
|
|
// the test harness so as to actually make the test work.
|
|
|
|
return Preferences::HasUserValue(WR_ROLLOUT_HW_QUALIFIED_OVERRIDE);
|
|
|
|
}
|
|
|
|
|
2018-11-23 00:36:09 +03:00
|
|
|
// If the "gfx.webrender.all.qualified" pref is true we want to enable
|
|
|
|
// WebRender for qualifying hardware. The Normandy pref rollout code sets
|
|
|
|
// default values on rolled out prefs on every startup, but Gfx starts up
|
|
|
|
// before Normandy does. So it's too early to observe the WR qualified pref
|
|
|
|
// default value changed by Normandy rollout here yet. So we have a shutdown
|
|
|
|
// observer to save the default value on shutdown, and read the saved default
|
|
|
|
// value here instead, and emulate the behavior of the pref system, with
|
|
|
|
// respect to default/user values of the rollout pref.
|
|
|
|
static bool CalculateWrQualifiedPrefValue() {
|
|
|
|
auto clearPrefOnExit = MakeScopeExit([]() {
|
|
|
|
// Clear the mirror of the default value of the rollout pref on scope exit,
|
|
|
|
// if we have one. This ensures the user doesn't mess with the pref.
|
|
|
|
// If we need it again, we'll re-create it on shutdown.
|
2019-05-26 17:32:42 +03:00
|
|
|
Preferences::ClearUser(WR_ROLLOUT_DEFAULT_PREF);
|
2018-11-23 00:36:09 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
if (!Preferences::HasUserValue(WR_ROLLOUT_PREF) &&
|
2019-05-26 17:32:42 +03:00
|
|
|
Preferences::HasUserValue(WR_ROLLOUT_DEFAULT_PREF)) {
|
2018-11-23 00:36:09 +03:00
|
|
|
// The user has not set a user pref, and we have a default value set by the
|
2019-05-26 17:32:42 +03:00
|
|
|
// shutdown observer. Let's use this as it should be the value Normandy set
|
|
|
|
// before startup. WR_ROLLOUT_DEFAULT_PREF should only be set on shutdown by
|
|
|
|
// the shutdown observer.
|
|
|
|
// Normandy runs *during* startup, but *after* this code here runs (hence
|
|
|
|
// the need for the workaround).
|
|
|
|
// To have a value stored in the WR_ROLLOUT_DEFAULT_PREF pref here, during
|
|
|
|
// the previous run Normandy must have set a default value on the in-memory
|
|
|
|
// pref, and on shutdown we stored the default value in this
|
|
|
|
// WR_ROLLOUT_DEFAULT_PREF user pref. Then once the user restarts, we
|
|
|
|
// observe this pref. Normandy is the only way a default (not user) value
|
|
|
|
// can be set for this pref.
|
|
|
|
return Preferences::GetBool(WR_ROLLOUT_DEFAULT_PREF,
|
|
|
|
WR_ROLLOUT_DEFAULT_PREF_DEFAULTVALUE);
|
2018-11-23 00:36:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// We don't have a user value for the rollout pref, and we don't have the
|
|
|
|
// value of the rollout pref at last shutdown stored. So we should fallback
|
2019-05-26 17:32:42 +03:00
|
|
|
// to using the default. *But* if we're running
|
2018-11-23 00:36:09 +03:00
|
|
|
// under the Marionette pref rollout work-around test, we may want to override
|
|
|
|
// the default value expressed here, so we can test the "default disabled;
|
|
|
|
// rollout pref enabled" case.
|
2019-05-26 17:32:42 +03:00
|
|
|
// Note that those preferences can't be defined in all.js nor
|
|
|
|
// StaticPrefsList.h as they would create the pref, leading SaveRolloutPref()
|
|
|
|
// above to abort early as the pref would have a valid type.
|
|
|
|
// We also don't want those prefs to appear in about:config.
|
2018-11-23 00:36:09 +03:00
|
|
|
if (Preferences::HasUserValue(WR_ROLLOUT_PREF_OVERRIDE)) {
|
|
|
|
return Preferences::GetBool(WR_ROLLOUT_PREF_OVERRIDE);
|
|
|
|
}
|
2019-05-26 17:32:42 +03:00
|
|
|
return Preferences::GetBool(WR_ROLLOUT_PREF, WR_ROLLOUT_PREF_DEFAULTVALUE);
|
2018-11-23 00:36:09 +03:00
|
|
|
}
|
|
|
|
|
2019-07-04 21:54:44 +03:00
|
|
|
static void HardwareTooOldForWR(FeatureState& aFeature) {
|
2019-07-09 09:37:45 +03:00
|
|
|
aFeature.Disable(FeatureStatus::BlockedDeviceTooOld, "Device too old",
|
|
|
|
NS_LITERAL_CSTRING("FEATURE_FAILURE_DEVICE_TOO_OLD"));
|
2019-07-04 21:54:44 +03:00
|
|
|
}
|
|
|
|
|
2019-07-04 21:48:39 +03:00
|
|
|
static void UpdateWRQualificationForNvidia(FeatureState& aFeature,
|
2019-07-10 14:27:02 +03:00
|
|
|
int32_t aDeviceId,
|
|
|
|
bool* aOutGuardedByQualifiedPref) {
|
2019-07-04 21:54:44 +03:00
|
|
|
// 0x6c0 is the lowest Fermi device id. Unfortunately some Tesla
|
|
|
|
// devices that don't support D3D 10.1 have higher deviceIDs. They
|
|
|
|
// will be included, but blocked by ANGLE.
|
|
|
|
bool supported = aDeviceId >= 0x6c0;
|
|
|
|
|
|
|
|
if (!supported) {
|
|
|
|
HardwareTooOldForWR(aFeature);
|
|
|
|
return;
|
2019-07-04 21:48:39 +03:00
|
|
|
}
|
2019-07-04 21:54:44 +03:00
|
|
|
|
2019-07-10 14:27:02 +03:00
|
|
|
// Any additional Nvidia checks go here. Make sure to leave
|
|
|
|
// aOutGuardedByQualifiedPref as true unless the hardware is qualified
|
|
|
|
// for users on the release channel.
|
|
|
|
|
2019-07-12 23:46:03 +03:00
|
|
|
#if defined(XP_WIN)
|
2019-07-10 14:27:02 +03:00
|
|
|
// Nvidia devices with device id >= 0x6c0 got WR in release Firefox 67.
|
|
|
|
*aOutGuardedByQualifiedPref = false;
|
2019-07-12 23:46:03 +03:00
|
|
|
#elif defined(NIGHTLY_BUILD)
|
|
|
|
// Qualify on Linux Nightly, but leave *aOutGuardedByQualifiedPref as true
|
|
|
|
// to indicate users on release don't have it yet, and it's still guarded
|
|
|
|
// by the qualified pref.
|
|
|
|
#else
|
|
|
|
// Disqualify everywhere else
|
|
|
|
aFeature.Disable(
|
|
|
|
FeatureStatus::BlockedReleaseChannelNvidia, "Release channel and Nvidia",
|
|
|
|
NS_LITERAL_CSTRING("FEATURE_FAILURE_RELEASE_CHANNEL_NVIDIA"));
|
|
|
|
#endif
|
2019-07-04 21:48:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void UpdateWRQualificationForAMD(FeatureState& aFeature,
|
2019-07-10 14:27:02 +03:00
|
|
|
int32_t aDeviceId,
|
|
|
|
bool* aOutGuardedByQualifiedPref) {
|
2019-07-04 21:48:39 +03:00
|
|
|
// AMD deviceIDs are not very well ordered. This
|
|
|
|
// condition is based off the information in gpu-db
|
2019-07-09 09:37:45 +03:00
|
|
|
bool supported = (aDeviceId >= 0x6600 && aDeviceId < 0x66b0) ||
|
|
|
|
(aDeviceId >= 0x6700 && aDeviceId < 0x6720) ||
|
|
|
|
(aDeviceId >= 0x6780 && aDeviceId < 0x6840) ||
|
|
|
|
(aDeviceId >= 0x6860 && aDeviceId < 0x6880) ||
|
|
|
|
(aDeviceId >= 0x6900 && aDeviceId < 0x6a00) ||
|
|
|
|
(aDeviceId == 0x7300) ||
|
2019-07-10 18:02:40 +03:00
|
|
|
(aDeviceId >= 0x7310 && aDeviceId < 0x7320) ||
|
2019-07-09 09:37:45 +03:00
|
|
|
(aDeviceId >= 0x9830 && aDeviceId < 0x9870) ||
|
|
|
|
(aDeviceId >= 0x9900 && aDeviceId < 0x9a00);
|
2019-07-04 21:54:44 +03:00
|
|
|
|
|
|
|
if (!supported) {
|
|
|
|
HardwareTooOldForWR(aFeature);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-07-10 14:27:02 +03:00
|
|
|
// we have a desktop CAYMAN, SI, CIK, VI, or GFX9 device.
|
|
|
|
|
|
|
|
#if defined(XP_WIN)
|
|
|
|
// These devices got WR in release Firefox 68.
|
|
|
|
*aOutGuardedByQualifiedPref = false;
|
|
|
|
#elif defined(NIGHTLY_BUILD)
|
|
|
|
// Qualify on Linux Nightly, but leave *aOutGuardedByQualifiedPref as true
|
|
|
|
// to indicate users on release don't have it yet, and it's still guarded
|
|
|
|
// by the qualified pref.
|
|
|
|
#else
|
|
|
|
// Disqualify everywhere else
|
2019-07-09 09:37:45 +03:00
|
|
|
aFeature.Disable(FeatureStatus::BlockedReleaseChannelAMD,
|
|
|
|
"Release channel and AMD",
|
|
|
|
NS_LITERAL_CSTRING("FEATURE_FAILURE_RELEASE_CHANNEL_AMD"));
|
2019-07-10 14:27:02 +03:00
|
|
|
#endif
|
2019-07-04 21:48:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void UpdateWRQualificationForIntel(FeatureState& aFeature,
|
2019-07-09 09:37:45 +03:00
|
|
|
int32_t aDeviceId,
|
2019-07-10 14:27:02 +03:00
|
|
|
int32_t aScreenPixels,
|
|
|
|
bool* aOutGuardedByQualifiedPref) {
|
2019-07-04 21:48:39 +03:00
|
|
|
const uint16_t supportedDevices[] = {
|
|
|
|
// skylake gt2+
|
|
|
|
0x1912,
|
|
|
|
0x1913,
|
|
|
|
0x1915,
|
|
|
|
0x1916,
|
|
|
|
0x1917,
|
|
|
|
0x191a,
|
|
|
|
0x191b,
|
|
|
|
0x191d,
|
|
|
|
0x191e,
|
|
|
|
0x1921,
|
|
|
|
0x1923,
|
|
|
|
0x1926,
|
|
|
|
0x1927,
|
|
|
|
0x192b,
|
|
|
|
0x1932,
|
|
|
|
0x193b,
|
|
|
|
0x193d,
|
|
|
|
|
|
|
|
// kabylake gt2+
|
|
|
|
0x5912,
|
|
|
|
0x5916,
|
|
|
|
0x5917,
|
|
|
|
0x591a,
|
|
|
|
0x591b,
|
|
|
|
0x591c,
|
|
|
|
0x591d,
|
|
|
|
0x591e,
|
|
|
|
0x5921,
|
|
|
|
0x5926,
|
|
|
|
0x5923,
|
|
|
|
0x5927,
|
|
|
|
0x593b,
|
|
|
|
|
|
|
|
// coffeelake gt2+
|
|
|
|
0x3e91,
|
|
|
|
0x3e92,
|
|
|
|
0x3e96,
|
|
|
|
0x3e98,
|
|
|
|
0x3e9a,
|
|
|
|
0x3e9b,
|
|
|
|
0x3e94,
|
|
|
|
0x3ea0,
|
|
|
|
0x3ea9,
|
|
|
|
0x3ea2,
|
|
|
|
0x3ea6,
|
|
|
|
0x3ea7,
|
|
|
|
0x3ea8,
|
|
|
|
0x3ea5,
|
|
|
|
|
|
|
|
// broadwell gt2+
|
|
|
|
0x1612,
|
|
|
|
0x1616,
|
|
|
|
0x161a,
|
|
|
|
0x161b,
|
|
|
|
0x161d,
|
|
|
|
0x161e,
|
|
|
|
0x1622,
|
|
|
|
0x1626,
|
|
|
|
0x162a,
|
|
|
|
0x162b,
|
|
|
|
0x162d,
|
|
|
|
0x162e,
|
|
|
|
0x1632,
|
|
|
|
0x1636,
|
|
|
|
0x163a,
|
|
|
|
0x163b,
|
|
|
|
0x163d,
|
|
|
|
0x163e,
|
|
|
|
|
|
|
|
// HD Graphics 4600
|
|
|
|
0x0412,
|
|
|
|
0x0416,
|
|
|
|
0x041a,
|
|
|
|
0x041b,
|
|
|
|
0x041e,
|
|
|
|
0x0a12,
|
|
|
|
0x0a16,
|
|
|
|
0x0a1a,
|
|
|
|
0x0a1b,
|
|
|
|
0x0a1e,
|
|
|
|
};
|
|
|
|
bool supported = false;
|
|
|
|
for (uint16_t id : supportedDevices) {
|
|
|
|
if (aDeviceId == id) {
|
|
|
|
supported = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-07-04 21:54:44 +03:00
|
|
|
if (!supported) {
|
|
|
|
HardwareTooOldForWR(aFeature);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-07-06 01:08:13 +03:00
|
|
|
// Performance is not great on 4k screens with WebRender.
|
|
|
|
// Disable it for now on all release platforms, and also on Linux
|
|
|
|
// nightly. We only allow it on Windows nightly.
|
|
|
|
#if defined(XP_WIN) && defined(NIGHTLY_BUILD)
|
|
|
|
// Windows nightly, so don't do screen size checks
|
|
|
|
#else
|
|
|
|
// Windows release, Linux nightly, Linux release. Do screen size
|
|
|
|
// checks. (macOS is still completely blocked by the blocklist).
|
2019-07-10 14:26:50 +03:00
|
|
|
// On Windows release, we only allow really small screens (sub-WUXGA). On
|
|
|
|
// Linux we allow medium size screens as well (anything sub-4k).
|
|
|
|
# if defined(XP_WIN)
|
|
|
|
// Allow up to WUXGA on Windows release
|
|
|
|
const int32_t kMaxPixels = 1920 * 1200; // WUXGA
|
|
|
|
# else
|
|
|
|
// Allow up to 4k on Linux
|
2019-07-06 01:08:13 +03:00
|
|
|
const int32_t kMaxPixels = 3440 * 1440; // UWQHD
|
2019-07-10 14:26:50 +03:00
|
|
|
# endif
|
2019-07-06 01:08:13 +03:00
|
|
|
if (aScreenPixels > kMaxPixels) {
|
2019-07-04 21:54:44 +03:00
|
|
|
aFeature.Disable(
|
|
|
|
FeatureStatus::BlockedScreenTooLarge, "Screen size too large",
|
|
|
|
NS_LITERAL_CSTRING("FEATURE_FAILURE_SCREEN_SIZE_TOO_LARGE"));
|
2019-07-06 01:08:13 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (aScreenPixels <= 0) {
|
2019-07-09 09:37:45 +03:00
|
|
|
aFeature.Disable(FeatureStatus::BlockedScreenUnknown, "Screen size unknown",
|
|
|
|
NS_LITERAL_CSTRING("FEATURE_FAILURE_SCREEN_SIZE_UNKNOWN"));
|
2019-07-06 01:08:13 +03:00
|
|
|
return;
|
2019-07-04 21:48:39 +03:00
|
|
|
}
|
2019-07-06 01:08:13 +03:00
|
|
|
#endif
|
|
|
|
|
2019-07-10 14:26:50 +03:00
|
|
|
#if (defined(XP_WIN) || (defined(MOZ_WIDGET_GTK) && defined(NIGHTLY_BUILD)))
|
|
|
|
// Qualify Intel graphics cards on Windows to release and on Linux nightly
|
|
|
|
// (subject to device whitelist and screen size checks above).
|
2019-07-10 14:27:02 +03:00
|
|
|
// Leave *aOutGuardedByQualifiedPref as true to indicate no existing
|
|
|
|
// release users have this yet, and it's still guarded by the qualified pref.
|
2019-07-06 01:08:13 +03:00
|
|
|
#else
|
|
|
|
// Disqualify everywhere else
|
2019-07-09 09:37:45 +03:00
|
|
|
aFeature.Disable(FeatureStatus::BlockedReleaseChannelIntel,
|
|
|
|
"Release channel and Intel",
|
|
|
|
NS_LITERAL_CSTRING("FEATURE_FAILURE_RELEASE_CHANNEL_INTEL"));
|
2019-07-06 01:08:13 +03:00
|
|
|
#endif
|
2019-07-04 21:48:39 +03:00
|
|
|
}
|
|
|
|
|
2018-11-23 00:36:09 +03:00
|
|
|
static FeatureState& WebRenderHardwareQualificationStatus(
|
2019-07-10 14:27:02 +03:00
|
|
|
const IntSize& aScreenSize, bool aHasBattery,
|
|
|
|
bool* aOutGuardedByQualifiedPref) {
|
2018-11-23 00:36:09 +03:00
|
|
|
FeatureState& featureWebRenderQualified =
|
|
|
|
gfxConfig::GetFeature(Feature::WEBRENDER_QUALIFIED);
|
|
|
|
featureWebRenderQualified.EnableByDefault();
|
2019-07-10 14:27:02 +03:00
|
|
|
MOZ_ASSERT(aOutGuardedByQualifiedPref && *aOutGuardedByQualifiedPref);
|
2018-11-21 02:38:34 +03:00
|
|
|
|
2018-11-23 00:36:09 +03:00
|
|
|
if (Preferences::HasUserValue(WR_ROLLOUT_HW_QUALIFIED_OVERRIDE)) {
|
|
|
|
if (!Preferences::GetBool(WR_ROLLOUT_HW_QUALIFIED_OVERRIDE)) {
|
|
|
|
featureWebRenderQualified.Disable(
|
2019-05-09 20:26:55 +03:00
|
|
|
FeatureStatus::BlockedOverride, "HW qualification pref override",
|
2018-11-23 00:36:09 +03:00
|
|
|
NS_LITERAL_CSTRING("FEATURE_FAILURE_WR_QUALIFICATION_OVERRIDE"));
|
2017-04-24 17:06:06 +03:00
|
|
|
}
|
2018-11-23 00:36:09 +03:00
|
|
|
return featureWebRenderQualified;
|
2017-04-24 17:06:06 +03:00
|
|
|
}
|
|
|
|
|
2018-07-19 21:05:29 +03:00
|
|
|
nsCOMPtr<nsIGfxInfo> gfxInfo = services::GetGfxInfo();
|
2019-07-10 14:26:43 +03:00
|
|
|
nsCString failureId;
|
2018-07-19 21:05:29 +03:00
|
|
|
int32_t status;
|
2019-07-03 21:32:35 +03:00
|
|
|
if (NS_FAILED(gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_WEBRENDER,
|
2019-07-10 14:26:43 +03:00
|
|
|
failureId, &status))) {
|
2019-07-03 21:32:35 +03:00
|
|
|
featureWebRenderQualified.Disable(
|
|
|
|
FeatureStatus::BlockedNoGfxInfo, "gfxInfo is broken",
|
|
|
|
NS_LITERAL_CSTRING("FEATURE_FAILURE_WR_NO_GFX_INFO"));
|
|
|
|
return featureWebRenderQualified;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (status != nsIGfxInfo::FEATURE_STATUS_OK) {
|
|
|
|
featureWebRenderQualified.Disable(FeatureStatus::Blacklisted,
|
2019-07-10 14:26:43 +03:00
|
|
|
"No qualified hardware", failureId);
|
2019-07-03 21:32:35 +03:00
|
|
|
return featureWebRenderQualified;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoString adapterVendorID;
|
|
|
|
gfxInfo->GetAdapterVendorID(adapterVendorID);
|
|
|
|
|
|
|
|
nsAutoString adapterDeviceID;
|
|
|
|
gfxInfo->GetAdapterDeviceID(adapterDeviceID);
|
|
|
|
nsresult valid;
|
|
|
|
int32_t deviceID = adapterDeviceID.ToInteger(&valid, 16);
|
|
|
|
if (valid != NS_OK) {
|
|
|
|
featureWebRenderQualified.Disable(
|
|
|
|
FeatureStatus::BlockedDeviceUnknown, "Bad device id",
|
|
|
|
NS_LITERAL_CSTRING("FEATURE_FAILURE_BAD_DEVICE_ID"));
|
|
|
|
return featureWebRenderQualified;
|
|
|
|
}
|
|
|
|
|
|
|
|
const int32_t screenPixels = aScreenSize.width * aScreenSize.height;
|
|
|
|
|
2019-07-09 09:37:45 +03:00
|
|
|
if (adapterVendorID == u"0x10de") { // Nvidia
|
2019-07-10 14:27:02 +03:00
|
|
|
UpdateWRQualificationForNvidia(featureWebRenderQualified, deviceID,
|
|
|
|
aOutGuardedByQualifiedPref);
|
2019-07-03 21:32:35 +03:00
|
|
|
} else if (adapterVendorID == u"0x1002") { // AMD
|
2019-07-10 14:27:02 +03:00
|
|
|
UpdateWRQualificationForAMD(featureWebRenderQualified, deviceID,
|
|
|
|
aOutGuardedByQualifiedPref);
|
2019-07-03 21:32:35 +03:00
|
|
|
} else if (adapterVendorID == u"0x8086") { // Intel
|
2019-07-04 21:48:39 +03:00
|
|
|
UpdateWRQualificationForIntel(featureWebRenderQualified, deviceID,
|
2019-07-10 14:27:02 +03:00
|
|
|
screenPixels, aOutGuardedByQualifiedPref);
|
2018-07-19 21:05:29 +03:00
|
|
|
} else {
|
|
|
|
featureWebRenderQualified.Disable(
|
2019-07-03 21:32:35 +03:00
|
|
|
FeatureStatus::BlockedVendorUnsupported, "Unsupported vendor",
|
|
|
|
NS_LITERAL_CSTRING("FEATURE_FAILURE_UNSUPPORTED_VENDOR"));
|
|
|
|
}
|
|
|
|
|
2019-07-04 21:54:44 +03:00
|
|
|
if (!featureWebRenderQualified.IsEnabled()) {
|
2019-07-10 14:27:02 +03:00
|
|
|
// One of the checks above failed, early exit. If this happens then
|
|
|
|
// this population must still be guarded by the qualified pref.
|
|
|
|
MOZ_ASSERT(*aOutGuardedByQualifiedPref);
|
2019-07-04 21:54:44 +03:00
|
|
|
return featureWebRenderQualified;
|
|
|
|
}
|
|
|
|
|
2019-07-03 21:32:35 +03:00
|
|
|
// We leave checking the battery for last because we would like to know
|
|
|
|
// which users were denied WebRender only because they have a battery.
|
2019-07-04 21:54:44 +03:00
|
|
|
if (aHasBattery) {
|
2019-07-16 18:11:03 +03:00
|
|
|
#ifndef XP_WIN
|
|
|
|
// aHasBattery is only ever true on Windows, we don't check it on other
|
|
|
|
// platforms.
|
|
|
|
MOZ_ASSERT(false);
|
|
|
|
#endif
|
2019-07-10 14:27:02 +03:00
|
|
|
// We never released WR to the battery populations, so let's keep the pref
|
|
|
|
// guard for these populations. That way we can do a gradual rollout to
|
|
|
|
// the battery population using the pref.
|
|
|
|
*aOutGuardedByQualifiedPref = true;
|
|
|
|
|
2019-07-16 18:11:03 +03:00
|
|
|
// if we have a battery, ignore it if the screen is small enough.
|
2019-07-03 21:32:35 +03:00
|
|
|
const int32_t kMaxPixelsBattery = 1920 * 1200; // WUXGA
|
2019-07-16 18:11:03 +03:00
|
|
|
if (screenPixels > 0 && screenPixels <= kMaxPixelsBattery) {
|
2019-07-03 21:32:35 +03:00
|
|
|
#ifndef NIGHTLY_BUILD
|
|
|
|
featureWebRenderQualified.Disable(
|
|
|
|
FeatureStatus::BlockedReleaseChannelBattery,
|
|
|
|
"Release channel and battery",
|
|
|
|
NS_LITERAL_CSTRING("FEATURE_FAILURE_RELEASE_CHANNEL_BATTERY"));
|
|
|
|
#endif // !NIGHTLY_BUILD
|
|
|
|
} else {
|
|
|
|
featureWebRenderQualified.Disable(
|
|
|
|
FeatureStatus::BlockedHasBattery, "Has battery",
|
|
|
|
NS_LITERAL_CSTRING("FEATURE_FAILURE_WR_HAS_BATTERY"));
|
|
|
|
}
|
2018-07-19 21:05:29 +03:00
|
|
|
}
|
2018-11-23 00:36:09 +03:00
|
|
|
return featureWebRenderQualified;
|
|
|
|
}
|
|
|
|
|
|
|
|
void gfxPlatform::InitWebRenderConfig() {
|
|
|
|
bool prefEnabled = WebRenderPrefEnabled();
|
|
|
|
bool envvarEnabled = WebRenderEnvvarEnabled();
|
|
|
|
|
2019-01-30 03:21:33 +03:00
|
|
|
// WR? WR+ => means WR was enabled via gfx.webrender.all.qualified on
|
|
|
|
// qualified hardware
|
|
|
|
// WR! WR+ => means WR was enabled via gfx.webrender.{all,enabled} or
|
|
|
|
// envvar, possibly on unqualified hardware
|
2018-11-23 00:36:09 +03:00
|
|
|
// In all cases WR- means WR was not enabled, for one of many possible
|
2019-01-30 03:21:33 +03:00
|
|
|
// reasons. Prior to bug 1523788 landing the gfx.webrender.{all,enabled}
|
|
|
|
// prefs only worked on Nightly so keep that in mind when looking at older
|
|
|
|
// crash reports.
|
2018-11-23 00:36:09 +03:00
|
|
|
ScopedGfxFeatureReporter reporter("WR", prefEnabled || envvarEnabled);
|
|
|
|
if (!XRE_IsParentProcess()) {
|
|
|
|
// Force-disable WebRender in recording/replaying child processes, which
|
|
|
|
// have their own compositor.
|
|
|
|
if (recordreplay::IsRecordingOrReplaying()) {
|
|
|
|
gfxVars::SetUseWebRender(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
// The parent process runs through all the real decision-making code
|
|
|
|
// later in this function. For other processes we still want to report
|
|
|
|
// the state of the feature for crash reports.
|
2019-05-26 17:29:42 +03:00
|
|
|
if (UseWebRender()) {
|
2018-11-23 00:36:09 +03:00
|
|
|
reporter.SetSuccessful();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2018-07-19 21:05:29 +03:00
|
|
|
|
2019-07-10 14:27:02 +03:00
|
|
|
bool guardedByQualifiedPref = true;
|
2018-11-23 00:36:09 +03:00
|
|
|
FeatureState& featureWebRenderQualified =
|
2019-07-10 14:27:02 +03:00
|
|
|
WebRenderHardwareQualificationStatus(GetScreenSize(), HasBattery(),
|
|
|
|
&guardedByQualifiedPref);
|
2017-02-09 09:33:54 +03:00
|
|
|
FeatureState& featureWebRender = gfxConfig::GetFeature(Feature::WEBRENDER);
|
|
|
|
|
Bug 1342450 - Extract a MOZ_ENABLE_WEBRENDER from MOZ_BUILD_WEBRENDER so that we build but disable by default. r=rhunt,froydnj,ted
This adds back a MOZ_ENABLE_WEBRENDER define, which only controls whether or
not WebRender is enabled at runtime. The default behaviour is changed so that:
- if the user specifies --disable-webrender in the mozconfig, WebRender is
neither built nor enabled
- if the user specifies --enable-webrender in the mozconfig, WebRender is
built and enabled
- if the user specifies --enable-webrender=build in the mozconfig, WebRender is
built but not enabled, except on Android where it is neither built nor enabled
- if the user doesn't specify any of the above, the default behaviour is:
- on nightly/local builds, the same as --enable-webrender=build
- on other channels (e.g. aurora), the same as --disable-webrender
The net effect is that local/Nightly-automation builds will have WebRender
built-in but not enabled where possible (i.e. not Android). However the user
can override this behaviour via mozconfig options to either not build WebRender
at all, or to enable it in addition to building it.
MozReview-Commit-ID: IM7DdSHkIB
2017-03-23 00:38:09 +03:00
|
|
|
featureWebRender.DisableByDefault(
|
|
|
|
FeatureStatus::OptIn, "WebRender is an opt-in feature",
|
|
|
|
NS_LITERAL_CSTRING("FEATURE_FAILURE_DEFAULT_OFF"));
|
2017-02-09 09:33:54 +03:00
|
|
|
|
2018-11-23 00:36:09 +03:00
|
|
|
const bool wrQualifiedAll = CalculateWrQualifiedPrefValue();
|
|
|
|
|
2019-01-30 03:21:33 +03:00
|
|
|
// envvar works everywhere; note that we need this for testing in CI.
|
|
|
|
// Prior to bug 1523788, the `prefEnabled` check was only done on Nightly,
|
|
|
|
// so as to prevent random users from easily enabling WebRender on
|
|
|
|
// unqualified hardware in beta/release.
|
2018-05-09 22:24:38 +03:00
|
|
|
if (envvarEnabled) {
|
2018-05-03 13:02:00 +03:00
|
|
|
featureWebRender.UserEnable("Force enabled by envvar");
|
2018-05-09 22:24:38 +03:00
|
|
|
} else if (prefEnabled) {
|
|
|
|
featureWebRender.UserEnable("Force enabled by pref");
|
2019-07-10 14:27:02 +03:00
|
|
|
} else if (featureWebRenderQualified.IsEnabled()) {
|
|
|
|
// If the HW is qualified, we enable if either the HW has been qualified
|
|
|
|
// on the release channel (i.e. it's no longer guarded by the qualified
|
|
|
|
// pref), or if the qualified pref is enabled.
|
|
|
|
if (!guardedByQualifiedPref) {
|
|
|
|
featureWebRender.UserEnable("Qualified in release");
|
|
|
|
} else if (wrQualifiedAll) {
|
|
|
|
featureWebRender.UserEnable("Qualified enabled by pref");
|
|
|
|
}
|
2017-02-09 09:33:54 +03:00
|
|
|
}
|
|
|
|
|
2018-06-25 17:55:33 +03:00
|
|
|
// If the user set the pref to force-disable, let's do that. This will
|
|
|
|
// override all the other enabling prefs (gfx.webrender.enabled,
|
|
|
|
// gfx.webrender.all, and gfx.webrender.all.qualified).
|
2019-07-22 05:10:14 +03:00
|
|
|
if (StaticPrefs::gfx_webrender_force_disabled_AtStartup() ||
|
2019-06-29 17:02:04 +03:00
|
|
|
(WebRenderEnvvarDisabled() && !InMarionetteRolloutTest())) {
|
2018-06-25 17:55:33 +03:00
|
|
|
featureWebRender.UserDisable(
|
|
|
|
"User force-disabled WR",
|
|
|
|
NS_LITERAL_CSTRING("FEATURE_FAILURE_USER_FORCE_DISABLED"));
|
|
|
|
}
|
|
|
|
|
2017-08-09 02:01:36 +03:00
|
|
|
// HW_COMPOSITING being disabled implies interfacing with the GPU might break
|
|
|
|
if (!gfxConfig::IsEnabled(Feature::HW_COMPOSITING)) {
|
|
|
|
featureWebRender.ForceDisable(
|
2019-05-09 20:26:55 +03:00
|
|
|
FeatureStatus::UnavailableNoHwCompositing,
|
|
|
|
"Hardware compositing is disabled",
|
2017-08-09 02:01:36 +03:00
|
|
|
NS_LITERAL_CSTRING("FEATURE_FAILURE_WEBRENDER_NEED_HWCOMP"));
|
|
|
|
}
|
|
|
|
|
2017-02-09 09:33:54 +03:00
|
|
|
// WebRender relies on the GPU process when on Windows
|
|
|
|
#ifdef XP_WIN
|
|
|
|
if (!gfxConfig::IsEnabled(Feature::GPU_PROCESS)) {
|
|
|
|
featureWebRender.ForceDisable(
|
2019-05-09 20:26:55 +03:00
|
|
|
FeatureStatus::UnavailableNoGpuProcess, "GPU Process is disabled",
|
2017-02-09 09:33:54 +03:00
|
|
|
NS_LITERAL_CSTRING("FEATURE_FAILURE_GPU_PROCESS_DISABLED"));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (InSafeMode()) {
|
|
|
|
featureWebRender.ForceDisable(
|
2019-05-09 20:26:55 +03:00
|
|
|
FeatureStatus::UnavailableInSafeMode, "Safe-mode is enabled",
|
2017-02-09 09:33:54 +03:00
|
|
|
NS_LITERAL_CSTRING("FEATURE_FAILURE_SAFE_MODE"));
|
|
|
|
}
|
|
|
|
|
2017-03-29 17:14:19 +03:00
|
|
|
#ifdef XP_WIN
|
|
|
|
if (Preferences::GetBool("gfx.webrender.force-angle", false)) {
|
|
|
|
if (!gfxConfig::IsEnabled(Feature::D3D11_HW_ANGLE)) {
|
|
|
|
featureWebRender.ForceDisable(
|
2019-05-09 20:26:55 +03:00
|
|
|
FeatureStatus::UnavailableNoAngle, "ANGLE is disabled",
|
2017-03-29 17:14:19 +03:00
|
|
|
NS_LITERAL_CSTRING("FEATURE_FAILURE_ANGLE_DISABLED"));
|
|
|
|
} else {
|
|
|
|
gfxVars::SetUseWebRenderANGLE(gfxConfig::IsEnabled(Feature::WEBRENDER));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-03-16 03:31:38 +03:00
|
|
|
if (Preferences::GetBool("gfx.webrender.program-binary-disk", false)) {
|
|
|
|
gfxVars::SetUseWebRenderProgramBinaryDisk(
|
2018-05-31 09:07:34 +03:00
|
|
|
gfxConfig::IsEnabled(Feature::WEBRENDER));
|
2017-11-24 14:58:24 +03:00
|
|
|
}
|
|
|
|
|
2017-09-25 17:47:42 +03:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2018-10-23 13:08:34 +03:00
|
|
|
if (jni::IsFennec()) {
|
|
|
|
featureWebRender.ForceDisable(
|
|
|
|
FeatureStatus::Unavailable,
|
|
|
|
"WebRender not ready for use on non-e10s Android",
|
|
|
|
NS_LITERAL_CSTRING("FEATURE_FAILURE_ANDROID"));
|
|
|
|
}
|
2017-09-25 17:47:42 +03:00
|
|
|
#endif
|
|
|
|
|
2017-02-09 09:33:54 +03:00
|
|
|
// gfxFeature is not usable in the GPU process, so we use gfxVars to transmit
|
|
|
|
// this feature
|
2017-03-27 18:44:01 +03:00
|
|
|
if (gfxConfig::IsEnabled(Feature::WEBRENDER)) {
|
|
|
|
gfxVars::SetUseWebRender(true);
|
|
|
|
reporter.SetSuccessful();
|
2017-08-23 13:00:37 +03:00
|
|
|
|
|
|
|
if (XRE_IsParentProcess()) {
|
|
|
|
Preferences::RegisterPrefixCallbackAndCall(
|
|
|
|
WebRenderDebugPrefChangeCallback, WR_DEBUG_PREF);
|
|
|
|
}
|
2017-03-27 18:44:01 +03:00
|
|
|
}
|
2019-04-13 08:55:20 +03:00
|
|
|
#if defined(MOZ_WIDGET_GTK)
|
2019-05-29 17:59:34 +03:00
|
|
|
else {
|
|
|
|
if (gfxConfig::IsEnabled(Feature::HW_COMPOSITING)) {
|
|
|
|
// Hardware compositing should be disabled by default if we aren't using
|
|
|
|
// WebRender. We had to check if it is enabled at all, because it may
|
|
|
|
// already have been forced disabled (e.g. safe mode, headless). It may
|
|
|
|
// still be forced on by the user, and if so, this should have no effect.
|
|
|
|
gfxConfig::Disable(Feature::HW_COMPOSITING, FeatureStatus::Blocked,
|
|
|
|
"Acceleration blocked by platform");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!gfxConfig::IsEnabled(Feature::HW_COMPOSITING) &&
|
|
|
|
gfxConfig::IsEnabled(Feature::GPU_PROCESS) &&
|
2019-07-22 05:10:14 +03:00
|
|
|
!StaticPrefs::layers_gpu_process_allow_software_AtStartup()) {
|
2019-05-29 17:59:34 +03:00
|
|
|
// We have neither WebRender nor OpenGL, we don't allow the GPU process
|
|
|
|
// for basic compositor, and it wasn't disabled already.
|
|
|
|
gfxConfig::Disable(Feature::GPU_PROCESS, FeatureStatus::Unavailable,
|
|
|
|
"Hardware compositing is unavailable.");
|
|
|
|
}
|
2019-04-09 22:27:16 +03:00
|
|
|
}
|
|
|
|
#endif
|
2018-03-29 05:23:31 +03:00
|
|
|
|
|
|
|
#ifdef XP_WIN
|
2019-07-19 12:26:03 +03:00
|
|
|
if (Preferences::GetBool("gfx.webrender.flip-sequential", false)) {
|
|
|
|
// XXX relax win version to windows 8.
|
|
|
|
if (IsWin10OrLater() && UseWebRender() && gfxVars::UseWebRenderANGLE()) {
|
|
|
|
gfxVars::SetUseWebRenderFlipSequentialWin(true);
|
|
|
|
}
|
|
|
|
}
|
2018-03-29 05:23:31 +03:00
|
|
|
if (Preferences::GetBool("gfx.webrender.dcomp-win.enabled", false)) {
|
|
|
|
// XXX relax win version to windows 8.
|
2019-05-26 17:29:42 +03:00
|
|
|
if (IsWin10OrLater() && UseWebRender() && gfxVars::UseWebRenderANGLE()) {
|
2018-03-29 05:23:31 +03:00
|
|
|
gfxVars::SetUseWebRenderDCompWin(true);
|
|
|
|
}
|
|
|
|
}
|
2019-07-19 12:26:03 +03:00
|
|
|
if (Preferences::GetBool("gfx.webrender.triple-buffering.enabled", false)) {
|
|
|
|
if (gfxVars::UseWebRenderDCompWin() ||
|
|
|
|
gfxVars::UseWebRenderFlipSequentialWin()) {
|
|
|
|
gfxVars::SetUseWebRenderTripleBufferingWin(true);
|
2018-11-05 12:58:37 +03:00
|
|
|
}
|
|
|
|
}
|
2018-03-29 05:23:31 +03:00
|
|
|
#endif
|
2019-07-23 15:22:41 +03:00
|
|
|
// The RemoveShaderCacheFromDiskIfNecessary() needs to be called after
|
|
|
|
// WebRenderConfig initialization.
|
|
|
|
gfxUtils::RemoveShaderCacheFromDiskIfNecessary();
|
2017-02-09 09:33:54 +03:00
|
|
|
}
|
|
|
|
|
2017-06-06 23:18:00 +03:00
|
|
|
void gfxPlatform::InitOMTPConfig() {
|
2017-10-03 02:30:58 +03:00
|
|
|
ScopedGfxFeatureReporter reporter("OMTP");
|
2017-06-06 23:18:00 +03:00
|
|
|
|
2017-10-03 02:30:58 +03:00
|
|
|
FeatureState& omtp = gfxConfig::GetFeature(Feature::OMTP);
|
2018-01-24 01:17:52 +03:00
|
|
|
int32_t paintWorkerCount = PaintThread::CalculatePaintWorkerCount();
|
2017-06-06 23:18:00 +03:00
|
|
|
|
|
|
|
if (!XRE_IsParentProcess()) {
|
|
|
|
// The parent process runs through all the real decision-making code
|
|
|
|
// later in this function. For other processes we still want to report
|
|
|
|
// the state of the feature for crash reports.
|
|
|
|
if (gfxVars::UseOMTP()) {
|
2018-01-24 01:17:52 +03:00
|
|
|
reporter.SetSuccessful(paintWorkerCount);
|
2017-06-06 23:18:00 +03:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-10-03 02:30:58 +03:00
|
|
|
omtp.SetDefaultFromPref("layers.omtp.enabled", true,
|
2017-11-14 11:06:01 +03:00
|
|
|
Preferences::GetBool("layers.omtp.enabled", false,
|
|
|
|
PrefValueKind::Default));
|
2017-06-06 23:18:00 +03:00
|
|
|
|
2017-10-02 03:19:45 +03:00
|
|
|
if (mContentBackend == BackendType::CAIRO) {
|
2017-10-03 02:30:58 +03:00
|
|
|
omtp.ForceDisable(FeatureStatus::Broken,
|
|
|
|
"OMTP is not supported when using cairo",
|
2017-10-02 03:19:45 +03:00
|
|
|
NS_LITERAL_CSTRING("FEATURE_FAILURE_COMP_PREF"));
|
|
|
|
}
|
|
|
|
|
2018-07-11 00:12:58 +03:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
if (!nsCocoaFeatures::OnYosemiteOrLater()) {
|
|
|
|
omtp.ForceDisable(FeatureStatus::Blocked, "OMTP blocked before OSX 10.10",
|
|
|
|
NS_LITERAL_CSTRING("FEATURE_FAILURE_OMTP_OSX_MAVERICKS"));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-06-06 23:18:00 +03:00
|
|
|
if (InSafeMode()) {
|
2017-10-03 02:30:58 +03:00
|
|
|
omtp.ForceDisable(FeatureStatus::Blocked, "OMTP blocked by safe-mode",
|
|
|
|
NS_LITERAL_CSTRING("FEATURE_FAILURE_COMP_SAFEMODE"));
|
2017-06-06 23:18:00 +03:00
|
|
|
}
|
|
|
|
|
2017-10-03 02:30:58 +03:00
|
|
|
if (omtp.IsEnabled()) {
|
2017-06-06 23:18:00 +03:00
|
|
|
gfxVars::SetUseOMTP(true);
|
2018-01-24 01:17:52 +03:00
|
|
|
reporter.SetSuccessful(paintWorkerCount);
|
2017-06-06 23:18:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-01 06:06:56 +03:00
|
|
|
bool gfxPlatform::CanUseHardwareVideoDecoding() {
|
2015-01-26 03:34:28 +03:00
|
|
|
// this function is called from the compositor thread, so it is not
|
|
|
|
// safe to init the prefs etc. from here.
|
|
|
|
MOZ_ASSERT(sLayersAccelerationPrefsInitialized);
|
2015-05-27 05:05:18 +03:00
|
|
|
return sLayersSupportsHardwareVideoDecoding &&
|
|
|
|
!sLayersHardwareVideoDecodingFailed;
|
2015-01-26 03:34:28 +03:00
|
|
|
}
|
|
|
|
|
2015-07-17 01:18:05 +03:00
|
|
|
bool gfxPlatform::AccelerateLayersByDefault() {
|
|
|
|
#if defined(MOZ_GL_PROVIDER) || defined(MOZ_WIDGET_UIKIT)
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
2015-04-10 23:17:27 +03:00
|
|
|
|
2013-08-04 11:46:17 +04:00
|
|
|
bool gfxPlatform::BufferRotationEnabled() {
|
|
|
|
MutexAutoLock autoLock(*gGfxPlatformPrefsLock);
|
|
|
|
|
2019-06-27 07:48:58 +03:00
|
|
|
return sBufferRotationCheckPref &&
|
2019-07-22 05:10:14 +03:00
|
|
|
StaticPrefs::layers_bufferrotation_enabled_AtStartup();
|
2013-08-04 11:46:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void gfxPlatform::DisableBufferRotation() {
|
|
|
|
MutexAutoLock autoLock(*gGfxPlatformPrefsLock);
|
|
|
|
|
2014-02-27 06:53:27 +04:00
|
|
|
sBufferRotationCheckPref = false;
|
2013-08-16 17:18:36 +04:00
|
|
|
}
|
2013-12-21 01:37:07 +04:00
|
|
|
|
2019-02-26 01:07:19 +03:00
|
|
|
/* static */
|
|
|
|
bool gfxPlatform::UsesOffMainThreadCompositing() {
|
2016-08-23 03:25:52 +03:00
|
|
|
if (XRE_GetProcessType() == GeckoProcessType_GPU) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-06-06 17:51:24 +04:00
|
|
|
static bool firstTime = true;
|
|
|
|
static bool result = false;
|
|
|
|
|
|
|
|
if (firstTime) {
|
2016-04-29 07:52:54 +03:00
|
|
|
MOZ_ASSERT(sLayersAccelerationPrefsInitialized);
|
2016-08-04 21:33:44 +03:00
|
|
|
result = gfxVars::BrowserTabsRemoteAutostart() ||
|
2019-07-22 05:10:14 +03:00
|
|
|
!StaticPrefs::
|
|
|
|
layers_offmainthreadcomposition_force_disabled_AtStartup();
|
2014-07-23 00:46:02 +04:00
|
|
|
#if defined(MOZ_WIDGET_GTK)
|
2014-06-06 17:51:24 +04:00
|
|
|
// Linux users who chose OpenGL are being grandfathered in to OMTC
|
2019-07-22 05:10:14 +03:00
|
|
|
result |= StaticPrefs::
|
|
|
|
layers_acceleration_force_enabled_AtStartup_DoNotUseDirectly();
|
2014-07-23 00:46:02 +04:00
|
|
|
|
2014-06-06 17:51:24 +04:00
|
|
|
#endif
|
|
|
|
firstTime = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
2015-01-09 02:12:47 +03:00
|
|
|
|
Create a PaintWorker thread pool and dispatch tiles to it (bug 1425056, r=bas)
This commit adds a paint worker thread pool to PaintThread, and dispatches
tiled paints to it. The thread pool is only created if tiling is enabled,
and its size is set by 'layers.omtp.paint-workers' and defaults to 1. If
-1 is specified, it will be sized to 'max((cpu_cores * 3) / 4, 1)'.
The one tricky part of dispatching tiled paints to a thread pool is the
AsyncEndLayerTransaction message that must execute once all paints are
finished. Previously, this runnable would be queued after all the paints
had been queued, ensuring it would be run after they had all completed.
With a thread pool, there is no guarantee. Instead this commit, uses
a flag on CompositorBridgeChild to signify whether all of the paints
have been queued ('mOutstandingAsyncEndLayerTransaction'), and after
every tiled paint it is examined to see if that paint was the last
paint, and if it is to run AsyncEndLayerTransaction. In addition,
if the async paints complete before we even mark the end of the
layer transaction, we queue it like normal.
The profiler markers are also complicated by using a thread pool.
I don't know of a great way to keep them working as they are per
thread, so for now I've removed them. I may have been the only
one using them anyway.
MozReview-Commit-ID: 5LIJ9GWSfCn
--HG--
extra : rebase_source : 0c26806f337a1b4b1511945f9c72e787b426c5ba
2017-12-08 10:18:05 +03:00
|
|
|
bool gfxPlatform::UsesTiling() const {
|
2018-04-30 23:05:19 +03:00
|
|
|
bool usesSkia = GetDefaultContentBackend() == BackendType::SKIA;
|
|
|
|
|
|
|
|
// We can't just test whether the PaintThread is initialized here because
|
|
|
|
// this function is used when initializing the PaintThread. So instead we
|
|
|
|
// check the conditions that enable OMTP with parallel painting.
|
|
|
|
bool usesPOMTP = XRE_IsContentProcess() && gfxVars::UseOMTP() &&
|
2019-07-22 05:10:14 +03:00
|
|
|
(StaticPrefs::layers_omtp_paint_workers_AtStartup() == -1 ||
|
|
|
|
StaticPrefs::layers_omtp_paint_workers_AtStartup() > 1);
|
2018-04-30 23:05:19 +03:00
|
|
|
|
2019-07-22 05:10:14 +03:00
|
|
|
return StaticPrefs::layers_enable_tiles_AtStartup() ||
|
|
|
|
(StaticPrefs::layers_enable_tiles_if_skia_pomtp_AtStartup() &&
|
|
|
|
usesSkia && usesPOMTP);
|
2018-04-30 23:05:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool gfxPlatform::ContentUsesTiling() const {
|
|
|
|
BackendPrefsData data = GetBackendPrefs();
|
|
|
|
BackendType contentBackend = GetContentBackendPref(data.mContentBitmask);
|
|
|
|
if (contentBackend == BackendType::NONE) {
|
|
|
|
contentBackend = data.mContentDefault;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool contentUsesSkia = contentBackend == BackendType::SKIA;
|
|
|
|
bool contentUsesPOMTP =
|
2019-07-22 05:10:14 +03:00
|
|
|
gfxVars::UseOMTP() &&
|
|
|
|
(StaticPrefs::layers_omtp_paint_workers_AtStartup() == -1 ||
|
|
|
|
StaticPrefs::layers_omtp_paint_workers_AtStartup() > 1);
|
2018-04-10 19:29:14 +03:00
|
|
|
|
2019-07-22 05:10:14 +03:00
|
|
|
return StaticPrefs::layers_enable_tiles_AtStartup() ||
|
|
|
|
(StaticPrefs::layers_enable_tiles_if_skia_pomtp_AtStartup() &&
|
|
|
|
contentUsesSkia && contentUsesPOMTP);
|
Create a PaintWorker thread pool and dispatch tiles to it (bug 1425056, r=bas)
This commit adds a paint worker thread pool to PaintThread, and dispatches
tiled paints to it. The thread pool is only created if tiling is enabled,
and its size is set by 'layers.omtp.paint-workers' and defaults to 1. If
-1 is specified, it will be sized to 'max((cpu_cores * 3) / 4, 1)'.
The one tricky part of dispatching tiled paints to a thread pool is the
AsyncEndLayerTransaction message that must execute once all paints are
finished. Previously, this runnable would be queued after all the paints
had been queued, ensuring it would be run after they had all completed.
With a thread pool, there is no guarantee. Instead this commit, uses
a flag on CompositorBridgeChild to signify whether all of the paints
have been queued ('mOutstandingAsyncEndLayerTransaction'), and after
every tiled paint it is examined to see if that paint was the last
paint, and if it is to run AsyncEndLayerTransaction. In addition,
if the async paints complete before we even mark the end of the
layer transaction, we queue it like normal.
The profiler markers are also complicated by using a thread pool.
I don't know of a great way to keep them working as they are per
thread, so for now I've removed them. I may have been the only
one using them anyway.
MozReview-Commit-ID: 5LIJ9GWSfCn
--HG--
extra : rebase_source : 0c26806f337a1b4b1511945f9c72e787b426c5ba
2017-12-08 10:18:05 +03:00
|
|
|
}
|
|
|
|
|
2015-09-15 18:13:57 +03:00
|
|
|
/***
|
|
|
|
* The preference "layout.frame_rate" has 3 meanings depending on the value:
|
|
|
|
*
|
2018-11-28 12:16:55 +03:00
|
|
|
* -1 = Auto (default), use hardware vsync or software vsync @ 60 hz if hw
|
|
|
|
* vsync fails.
|
2015-09-15 18:13:57 +03:00
|
|
|
* 0 = ASAP mode - used during talos testing.
|
|
|
|
* X = Software vsync at a rate of X times per second.
|
|
|
|
*/
|
2015-01-09 02:12:47 +03:00
|
|
|
already_AddRefed<mozilla::gfx::VsyncSource>
|
|
|
|
gfxPlatform::CreateHardwareVsyncSource() {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<mozilla::gfx::VsyncSource> softwareVsync = new SoftwareVsyncSource();
|
2015-01-09 02:12:47 +03:00
|
|
|
return softwareVsync.forget();
|
|
|
|
}
|
2015-03-03 19:14:22 +03:00
|
|
|
|
2019-02-26 01:07:19 +03:00
|
|
|
/* static */
|
|
|
|
bool gfxPlatform::IsInLayoutAsapMode() {
|
2015-03-03 19:14:22 +03:00
|
|
|
// There are 2 modes of ASAP mode.
|
|
|
|
// 1 is that the refresh driver and compositor are in lock step
|
|
|
|
// the second is that the compositor goes ASAP and the refresh driver
|
|
|
|
// goes at whatever the configurated rate is. This only checks the version
|
|
|
|
// talos uses, which is the refresh driver and compositor are in lockstep.
|
2019-06-27 09:28:25 +03:00
|
|
|
return StaticPrefs::layout_frame_rate() == 0;
|
2015-03-03 19:14:22 +03:00
|
|
|
}
|
|
|
|
|
2019-02-26 01:07:19 +03:00
|
|
|
/* static */
|
|
|
|
bool gfxPlatform::ForceSoftwareVsync() {
|
2019-06-27 09:28:25 +03:00
|
|
|
return StaticPrefs::layout_frame_rate() > 0 ||
|
2019-03-30 09:41:48 +03:00
|
|
|
recordreplay::IsRecordingOrReplaying();
|
2015-09-15 18:13:57 +03:00
|
|
|
}
|
|
|
|
|
2019-02-26 01:07:19 +03:00
|
|
|
/* static */
|
|
|
|
int gfxPlatform::GetSoftwareVsyncRate() {
|
2019-06-27 09:28:25 +03:00
|
|
|
int preferenceRate = StaticPrefs::layout_frame_rate();
|
2015-09-15 18:13:57 +03:00
|
|
|
if (preferenceRate <= 0) {
|
|
|
|
return gfxPlatform::GetDefaultFrameRate();
|
|
|
|
}
|
|
|
|
return preferenceRate;
|
|
|
|
}
|
|
|
|
|
2019-02-26 01:07:19 +03:00
|
|
|
/* static */
|
2019-03-30 09:41:48 +03:00
|
|
|
int gfxPlatform::GetDefaultFrameRate() { return 60; }
|
2015-09-15 18:13:57 +03:00
|
|
|
|
2019-02-26 01:07:19 +03:00
|
|
|
/* static */
|
|
|
|
void gfxPlatform::ReInitFrameRate() {
|
2018-12-14 23:16:23 +03:00
|
|
|
if (XRE_IsParentProcess() || recordreplay::IsRecordingOrReplaying()) {
|
|
|
|
RefPtr<VsyncSource> oldSource = gPlatform->mVsyncSource;
|
|
|
|
|
|
|
|
// Start a new one:
|
|
|
|
if (gfxPlatform::ForceSoftwareVsync()) {
|
|
|
|
gPlatform->mVsyncSource =
|
|
|
|
(gPlatform)->gfxPlatform::CreateHardwareVsyncSource();
|
|
|
|
} else {
|
|
|
|
gPlatform->mVsyncSource = gPlatform->CreateHardwareVsyncSource();
|
|
|
|
}
|
|
|
|
// Tidy up old vsync source.
|
|
|
|
if (oldSource) {
|
|
|
|
oldSource->MoveListenersToNewSource(gPlatform->mVsyncSource);
|
|
|
|
oldSource->Shutdown();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-25 21:08:40 +03:00
|
|
|
void gfxPlatform::GetAzureBackendInfo(mozilla::widget::InfoObject& aObj) {
|
|
|
|
if (gfxConfig::IsEnabled(Feature::GPU_PROCESS)) {
|
|
|
|
aObj.DefineProperty("AzureCanvasBackend (UI Process)",
|
|
|
|
GetBackendName(mPreferredCanvasBackend));
|
|
|
|
aObj.DefineProperty("AzureFallbackCanvasBackend (UI Process)",
|
|
|
|
GetBackendName(mFallbackCanvasBackend));
|
|
|
|
aObj.DefineProperty("AzureContentBackend (UI Process)",
|
|
|
|
GetBackendName(mContentBackend));
|
|
|
|
|
2018-03-15 08:48:54 +03:00
|
|
|
// Assume content process' backend prefs.
|
|
|
|
BackendPrefsData data = GetBackendPrefs();
|
|
|
|
BackendType canvasBackend = GetCanvasBackendPref(data.mCanvasBitmask);
|
|
|
|
if (canvasBackend == BackendType::NONE) {
|
|
|
|
canvasBackend = data.mCanvasDefault;
|
|
|
|
}
|
|
|
|
BackendType contentBackend = GetContentBackendPref(data.mContentBitmask);
|
|
|
|
if (contentBackend == BackendType::NONE) {
|
|
|
|
contentBackend = data.mContentDefault;
|
2017-01-25 21:08:40 +03:00
|
|
|
}
|
2018-03-15 08:48:54 +03:00
|
|
|
aObj.DefineProperty("AzureCanvasBackend", GetBackendName(canvasBackend));
|
|
|
|
aObj.DefineProperty("AzureContentBackend", GetBackendName(contentBackend));
|
2017-01-25 21:08:40 +03:00
|
|
|
} else {
|
|
|
|
aObj.DefineProperty("AzureCanvasBackend",
|
|
|
|
GetBackendName(mPreferredCanvasBackend));
|
|
|
|
aObj.DefineProperty("AzureFallbackCanvasBackend",
|
|
|
|
GetBackendName(mFallbackCanvasBackend));
|
|
|
|
aObj.DefineProperty("AzureContentBackend", GetBackendName(mContentBackend));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-25 01:04:44 +03:00
|
|
|
void gfxPlatform::GetApzSupportInfo(mozilla::widget::InfoObject& aObj) {
|
2015-06-04 23:51:10 +03:00
|
|
|
if (!gfxPlatform::AsyncPanZoomEnabled()) {
|
2015-03-26 04:37:33 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-03-25 01:04:44 +03:00
|
|
|
if (SupportsApzWheelInput()) {
|
|
|
|
aObj.DefineProperty("ApzWheelInput", 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SupportsApzTouchInput()) {
|
|
|
|
aObj.DefineProperty("ApzTouchInput", 1);
|
|
|
|
}
|
2015-09-28 21:44:36 +03:00
|
|
|
|
|
|
|
if (SupportsApzDragInput()) {
|
|
|
|
aObj.DefineProperty("ApzDragInput", 1);
|
|
|
|
}
|
2017-06-16 00:54:03 +03:00
|
|
|
|
2019-05-26 17:29:42 +03:00
|
|
|
if (SupportsApzKeyboardInput() &&
|
2019-06-24 06:57:06 +03:00
|
|
|
!StaticPrefs::accessibility_browsewithcaret()) {
|
2017-06-16 00:54:03 +03:00
|
|
|
aObj.DefineProperty("ApzKeyboardInput", 1);
|
|
|
|
}
|
2017-08-29 23:27:19 +03:00
|
|
|
|
|
|
|
if (SupportsApzAutoscrolling()) {
|
|
|
|
aObj.DefineProperty("ApzAutoscrollInput", 1);
|
|
|
|
}
|
2015-03-25 01:04:44 +03:00
|
|
|
}
|
|
|
|
|
2016-07-21 09:08:39 +03:00
|
|
|
void gfxPlatform::GetTilesSupportInfo(mozilla::widget::InfoObject& aObj) {
|
2019-07-22 05:10:14 +03:00
|
|
|
if (!StaticPrefs::layers_enable_tiles_AtStartup()) {
|
2016-07-21 09:08:39 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-08-04 21:33:43 +03:00
|
|
|
IntSize tileSize = gfxVars::TileSize();
|
|
|
|
aObj.DefineProperty("TileHeight", tileSize.height);
|
|
|
|
aObj.DefineProperty("TileWidth", tileSize.width);
|
2016-07-21 09:08:39 +03:00
|
|
|
}
|
|
|
|
|
2018-11-16 05:13:56 +03:00
|
|
|
void gfxPlatform::GetFrameStats(mozilla::widget::InfoObject& aObj) {
|
|
|
|
uint32_t i = 0;
|
|
|
|
for (FrameStats& f : mFrameStats) {
|
|
|
|
nsPrintfCString name("Slow Frame #%02u", ++i);
|
|
|
|
|
|
|
|
nsPrintfCString value(
|
|
|
|
"Frame %" PRIu64
|
|
|
|
"(%s) CONTENT_FRAME_TIME %d - Transaction start %f, main-thread time "
|
|
|
|
"%f, full paint time %f, Skipped composites %u, Composite start %f, "
|
|
|
|
"Resource upload time %f, GPU cache upload time %f, Render time %f, "
|
|
|
|
"Composite time %f",
|
|
|
|
f.id().mId, f.url().get(), f.contentFrameTime(),
|
|
|
|
(f.transactionStart() - f.refreshStart()).ToMilliseconds(),
|
|
|
|
(f.fwdTime() - f.transactionStart()).ToMilliseconds(),
|
|
|
|
f.sceneBuiltTime()
|
|
|
|
? (f.sceneBuiltTime() - f.transactionStart()).ToMilliseconds()
|
|
|
|
: 0.0,
|
|
|
|
f.skippedComposites(),
|
|
|
|
(f.compositeStart() - f.refreshStart()).ToMilliseconds(),
|
|
|
|
f.resourceUploadTime(), f.gpuCacheUploadTime(),
|
|
|
|
(f.compositeEnd() - f.renderStart()).ToMilliseconds(),
|
|
|
|
(f.compositeEnd() - f.compositeStart()).ToMilliseconds());
|
|
|
|
aObj.DefineProperty(name.get(), value.get());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-05 01:50:47 +03:00
|
|
|
void gfxPlatform::GetCMSSupportInfo(mozilla::widget::InfoObject& aObj) {
|
|
|
|
void* profile = nullptr;
|
|
|
|
size_t size = 0;
|
|
|
|
|
|
|
|
GetCMSOutputProfileData(profile, size);
|
|
|
|
if (!profile) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-06-10 19:49:09 +03:00
|
|
|
// Some profiles can be quite large. We don't want to include giant profiles
|
|
|
|
// by default in about:support. For now, we only accept less than 8kiB.
|
|
|
|
const size_t kMaxProfileSize = 8192;
|
|
|
|
if (size < kMaxProfileSize) {
|
|
|
|
char* encodedProfile = nullptr;
|
|
|
|
nsresult rv =
|
|
|
|
Base64Encode(reinterpret_cast<char*>(profile), size, &encodedProfile);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
aObj.DefineProperty("CMSOutputProfile", encodedProfile);
|
|
|
|
free(encodedProfile);
|
|
|
|
} else {
|
|
|
|
nsPrintfCString msg("base64 encode failed 0x%08x",
|
|
|
|
static_cast<uint32_t>(rv));
|
|
|
|
aObj.DefineProperty("CMSOutputProfile", msg.get());
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
nsPrintfCString msg("%zu bytes, too large", size);
|
|
|
|
aObj.DefineProperty("CMSOutputProfile", msg.get());
|
2019-06-05 01:50:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
free(profile);
|
|
|
|
}
|
|
|
|
|
2018-11-16 05:13:56 +03:00
|
|
|
class FrameStatsComparator {
|
|
|
|
public:
|
|
|
|
bool Equals(const FrameStats& aA, const FrameStats& aB) const {
|
|
|
|
return aA.contentFrameTime() == aB.contentFrameTime();
|
|
|
|
}
|
|
|
|
// Reverse the condition here since we want the array sorted largest to
|
|
|
|
// smallest.
|
|
|
|
bool LessThan(const FrameStats& aA, const FrameStats& aB) const {
|
|
|
|
return aA.contentFrameTime() > aB.contentFrameTime();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void gfxPlatform::NotifyFrameStats(nsTArray<FrameStats>&& aFrameStats) {
|
2019-07-22 05:10:14 +03:00
|
|
|
if (!StaticPrefs::gfx_logging_slow_frames_enabled_AtStartup()) {
|
2019-05-09 17:57:57 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-11-16 05:13:56 +03:00
|
|
|
FrameStatsComparator comp;
|
|
|
|
for (FrameStats& f : aFrameStats) {
|
|
|
|
mFrameStats.InsertElementSorted(f, comp);
|
|
|
|
}
|
|
|
|
if (mFrameStats.Length() > 10) {
|
|
|
|
mFrameStats.SetLength(10);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-26 01:07:19 +03:00
|
|
|
/*static*/
|
|
|
|
uint32_t gfxPlatform::TargetFrameRate() {
|
2019-01-08 18:48:24 +03:00
|
|
|
if (gPlatform && gPlatform->mVsyncSource) {
|
|
|
|
VsyncSource::Display& display = gPlatform->mVsyncSource->GetGlobalDisplay();
|
|
|
|
return round(1000.0 / display.GetVsyncRate().ToMilliseconds());
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-02-26 01:07:19 +03:00
|
|
|
/*static*/
|
|
|
|
bool gfxPlatform::AsyncPanZoomEnabled() {
|
2016-11-16 09:01:30 +03:00
|
|
|
#if !defined(MOZ_WIDGET_ANDROID) && !defined(MOZ_WIDGET_UIKIT)
|
|
|
|
// For XUL applications (everything but Firefox on Android)
|
|
|
|
// we only want to use APZ when E10S is enabled. If
|
2015-06-04 23:51:10 +03:00
|
|
|
// we ever get input events off the main thread we can consider relaxing
|
|
|
|
// this requirement.
|
|
|
|
if (!BrowserTabsRemoteAutostart()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#endif
|
2016-08-06 00:38:51 +03:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2015-12-15 17:17:41 +03:00
|
|
|
return true;
|
|
|
|
#else
|
2019-07-22 05:10:14 +03:00
|
|
|
return StaticPrefs::
|
|
|
|
layers_async_pan_zoom_enabled_AtStartup_DoNotUseDirectly();
|
2015-12-15 17:17:41 +03:00
|
|
|
#endif
|
2015-06-04 23:51:10 +03:00
|
|
|
}
|
2015-07-13 18:53:10 +03:00
|
|
|
|
2019-02-26 01:07:19 +03:00
|
|
|
/*static*/
|
2019-06-26 03:38:09 +03:00
|
|
|
bool gfxPlatform::PerfWarnings() {
|
|
|
|
return StaticPrefs::gfx_perf_warnings_enabled();
|
|
|
|
}
|
2015-07-17 01:18:05 +03:00
|
|
|
|
2015-10-08 22:21:59 +03:00
|
|
|
void gfxPlatform::GetAcceleratedCompositorBackends(
|
|
|
|
nsTArray<LayersBackend>& aBackends) {
|
2016-06-20 19:29:47 +03:00
|
|
|
if (gfxConfig::IsEnabled(Feature::OPENGL_COMPOSITING)) {
|
2015-10-08 22:21:59 +03:00
|
|
|
aBackends.AppendElement(LayersBackend::LAYERS_OPENGL);
|
2016-06-20 19:29:47 +03:00
|
|
|
} else {
|
2015-07-17 01:18:05 +03:00
|
|
|
static int tell_me_once = 0;
|
|
|
|
if (!tell_me_once) {
|
|
|
|
NS_WARNING("OpenGL-accelerated layers are not supported on this system");
|
|
|
|
tell_me_once = 1;
|
|
|
|
}
|
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
2016-12-03 00:46:53 +03:00
|
|
|
MOZ_CRASH(
|
|
|
|
"OpenGL-accelerated layers are a hard requirement on this platform. "
|
|
|
|
"Cannot continue without support for them");
|
2015-07-17 01:18:05 +03:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void gfxPlatform::GetCompositorBackends(
|
|
|
|
bool useAcceleration, nsTArray<mozilla::layers::LayersBackend>& aBackends) {
|
|
|
|
if (useAcceleration) {
|
|
|
|
GetAcceleratedCompositorBackends(aBackends);
|
|
|
|
}
|
2015-12-23 18:22:55 +03:00
|
|
|
aBackends.AppendElement(LayersBackend::LAYERS_BASIC);
|
2015-07-17 01:18:05 +03:00
|
|
|
}
|
2015-07-20 00:50:35 +03:00
|
|
|
|
|
|
|
void gfxPlatform::NotifyCompositorCreated(LayersBackend aBackend) {
|
|
|
|
if (mCompositorBackend == aBackend) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-10-06 09:39:28 +03:00
|
|
|
if (mCompositorBackend != LayersBackend::LAYERS_NONE) {
|
|
|
|
gfxCriticalNote << "Compositors might be mixed (" << int(mCompositorBackend)
|
|
|
|
<< "," << int(aBackend) << ")";
|
|
|
|
}
|
2015-07-20 00:50:35 +03:00
|
|
|
|
|
|
|
// Set the backend before we notify so it's available immediately.
|
|
|
|
mCompositorBackend = aBackend;
|
|
|
|
|
|
|
|
// Notify that we created a compositor, so telemetry can update.
|
2017-06-12 22:34:10 +03:00
|
|
|
NS_DispatchToMainThread(
|
|
|
|
NS_NewRunnableFunction("gfxPlatform::NotifyCompositorCreated", [] {
|
|
|
|
if (nsCOMPtr<nsIObserverService> obsvc =
|
|
|
|
services::GetObserverService()) {
|
|
|
|
obsvc->NotifyObservers(nullptr, "compositor:created", nullptr);
|
|
|
|
}
|
|
|
|
}));
|
2015-07-20 00:50:35 +03:00
|
|
|
}
|
2015-08-02 23:59:33 +03:00
|
|
|
|
2019-02-26 01:07:19 +03:00
|
|
|
/* static */
|
|
|
|
void gfxPlatform::NotifyGPUProcessDisabled() {
|
2017-02-09 09:33:54 +03:00
|
|
|
if (gfxConfig::IsEnabled(Feature::WEBRENDER)) {
|
|
|
|
gfxConfig::GetFeature(Feature::WEBRENDER)
|
|
|
|
.ForceDisable(
|
|
|
|
FeatureStatus::Unavailable, "GPU Process is disabled",
|
|
|
|
NS_LITERAL_CSTRING("FEATURE_FAILURE_GPU_PROCESS_DISABLED"));
|
|
|
|
gfxVars::SetUseWebRender(false);
|
|
|
|
}
|
2018-11-28 23:44:27 +03:00
|
|
|
|
|
|
|
gfxVars::SetRemoteCanvasEnabled(false);
|
2017-02-09 09:33:54 +03:00
|
|
|
}
|
|
|
|
|
2016-08-21 06:59:11 +03:00
|
|
|
void gfxPlatform::FetchAndImportContentDeviceData() {
|
|
|
|
MOZ_ASSERT(XRE_IsContentProcess());
|
|
|
|
|
2017-06-22 20:45:48 +03:00
|
|
|
if (gContentDeviceInitData) {
|
|
|
|
ImportContentDeviceData(*gContentDeviceInitData);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-08-21 06:59:11 +03:00
|
|
|
mozilla::dom::ContentChild* cc = mozilla::dom::ContentChild::GetSingleton();
|
|
|
|
|
|
|
|
mozilla::gfx::ContentDeviceData data;
|
|
|
|
cc->SendGetGraphicsDeviceInitData(&data);
|
|
|
|
|
|
|
|
ImportContentDeviceData(data);
|
2015-08-02 23:59:33 +03:00
|
|
|
}
|
|
|
|
|
2016-08-21 06:59:11 +03:00
|
|
|
void gfxPlatform::ImportContentDeviceData(
|
|
|
|
const mozilla::gfx::ContentDeviceData& aData) {
|
|
|
|
MOZ_ASSERT(XRE_IsContentProcess());
|
2015-08-02 23:59:33 +03:00
|
|
|
|
2016-08-21 06:59:11 +03:00
|
|
|
const DevicePrefs& prefs = aData.prefs();
|
|
|
|
gfxConfig::Inherit(Feature::HW_COMPOSITING, prefs.hwCompositing());
|
|
|
|
gfxConfig::Inherit(Feature::OPENGL_COMPOSITING, prefs.oglCompositing());
|
|
|
|
}
|
2016-04-29 07:52:55 +03:00
|
|
|
|
2016-08-21 06:59:11 +03:00
|
|
|
void gfxPlatform::BuildContentDeviceData(
|
|
|
|
mozilla::gfx::ContentDeviceData* aOut) {
|
|
|
|
MOZ_ASSERT(XRE_IsParentProcess());
|
2016-08-21 06:59:11 +03:00
|
|
|
|
|
|
|
// Make sure our settings are synchronized from the GPU process.
|
|
|
|
GPUProcessManager::Get()->EnsureGPUReady();
|
|
|
|
|
2016-08-21 06:59:11 +03:00
|
|
|
aOut->prefs().hwCompositing() = gfxConfig::GetValue(Feature::HW_COMPOSITING);
|
|
|
|
aOut->prefs().oglCompositing() =
|
|
|
|
gfxConfig::GetValue(Feature::OPENGL_COMPOSITING);
|
2015-08-02 23:59:33 +03:00
|
|
|
}
|
2015-09-28 21:44:36 +03:00
|
|
|
|
2016-08-21 06:59:11 +03:00
|
|
|
void gfxPlatform::ImportGPUDeviceData(
|
|
|
|
const mozilla::gfx::GPUDeviceData& aData) {
|
|
|
|
MOZ_ASSERT(XRE_IsParentProcess());
|
|
|
|
|
|
|
|
gfxConfig::ImportChange(Feature::OPENGL_COMPOSITING, aData.oglCompositing());
|
2017-06-24 00:23:12 +03:00
|
|
|
gfxConfig::ImportChange(Feature::ADVANCED_LAYERS, aData.advancedLayers());
|
2016-08-21 06:59:11 +03:00
|
|
|
}
|
|
|
|
|
2017-03-10 23:18:48 +03:00
|
|
|
bool gfxPlatform::SupportsApzTouchInput() const {
|
|
|
|
return dom::TouchEvent::PrefEnabled(nullptr);
|
|
|
|
}
|
|
|
|
|
2015-09-28 21:44:36 +03:00
|
|
|
bool gfxPlatform::SupportsApzDragInput() const {
|
2019-06-24 06:57:06 +03:00
|
|
|
return StaticPrefs::apz_drag_enabled();
|
2015-09-28 21:44:36 +03:00
|
|
|
}
|
2016-03-01 00:41:35 +03:00
|
|
|
|
2017-06-16 00:54:03 +03:00
|
|
|
bool gfxPlatform::SupportsApzKeyboardInput() const {
|
2019-07-22 05:10:14 +03:00
|
|
|
return StaticPrefs::apz_keyboard_enabled_AtStartup();
|
2017-06-16 00:54:03 +03:00
|
|
|
}
|
|
|
|
|
2017-08-29 23:27:19 +03:00
|
|
|
bool gfxPlatform::SupportsApzAutoscrolling() const {
|
2019-06-24 06:57:06 +03:00
|
|
|
return StaticPrefs::apz_autoscroll_enabled();
|
2017-08-29 23:27:19 +03:00
|
|
|
}
|
|
|
|
|
2016-06-20 19:29:47 +03:00
|
|
|
void gfxPlatform::InitOpenGLConfig() {
|
2016-07-08 22:18:47 +03:00
|
|
|
#ifdef XP_WIN
|
|
|
|
// Don't enable by default on Windows, since it could show up in about:support
|
|
|
|
// even though it'll never get used. Only attempt if user enables the pref
|
|
|
|
if (!Preferences::GetBool("layers.prefer-opengl")) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-06-20 19:29:47 +03:00
|
|
|
FeatureState& openGLFeature =
|
|
|
|
gfxConfig::GetFeature(Feature::OPENGL_COMPOSITING);
|
|
|
|
|
|
|
|
// Check to see hw comp supported
|
|
|
|
if (!gfxConfig::IsEnabled(Feature::HW_COMPOSITING)) {
|
|
|
|
openGLFeature.DisableByDefault(
|
|
|
|
FeatureStatus::Unavailable, "Hardware compositing is disabled",
|
|
|
|
NS_LITERAL_CSTRING("FEATURE_FAILURE_OPENGL_NEED_HWCOMP"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef XP_WIN
|
|
|
|
openGLFeature.SetDefaultFromPref(
|
2019-07-03 01:32:09 +03:00
|
|
|
StaticPrefs::GetPrefName_layers_prefer_opengl(), true,
|
|
|
|
StaticPrefs::GetPrefDefault_layers_prefer_opengl());
|
2016-06-20 19:29:47 +03:00
|
|
|
#else
|
|
|
|
openGLFeature.EnableByDefault();
|
|
|
|
#endif
|
|
|
|
|
2016-09-05 01:47:19 +03:00
|
|
|
// When layers acceleration is force-enabled, enable it even for blacklisted
|
|
|
|
// devices.
|
2019-07-22 05:10:14 +03:00
|
|
|
if (StaticPrefs::
|
|
|
|
layers_acceleration_force_enabled_AtStartup_DoNotUseDirectly()) {
|
2016-09-05 01:47:19 +03:00
|
|
|
openGLFeature.UserForceEnable("Force-enabled by pref");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-06-20 19:29:47 +03:00
|
|
|
nsCString message;
|
|
|
|
nsCString failureId;
|
|
|
|
if (!IsGfxInfoStatusOkay(nsIGfxInfo::FEATURE_OPENGL_LAYERS, &message,
|
|
|
|
failureId)) {
|
|
|
|
openGLFeature.Disable(FeatureStatus::Blacklisted, message.get(), failureId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool gfxPlatform::IsGfxInfoStatusOkay(int32_t aFeature, nsCString* aOutMessage,
|
|
|
|
nsCString& aFailureId) {
|
|
|
|
nsCOMPtr<nsIGfxInfo> gfxInfo = services::GetGfxInfo();
|
|
|
|
if (!gfxInfo) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-07-22 11:47:44 +03:00
|
|
|
int32_t status;
|
2016-06-20 19:29:47 +03:00
|
|
|
if (NS_SUCCEEDED(gfxInfo->GetFeatureStatus(aFeature, aFailureId, &status)) &&
|
|
|
|
status != nsIGfxInfo::FEATURE_STATUS_OK) {
|
|
|
|
aOutMessage->AssignLiteral("#BLOCKLIST_");
|
|
|
|
aOutMessage->AppendASCII(aFailureId.get());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|