Bug 1378355 - Extract gfxPlatform wrappers for MaxAllocSize and MaxTextureSize. r=bas

This allows us to reuse the minimum bound guards on the pref values in other
places that want to use the prefs.

MozReview-Commit-ID: 7XKuM5u1GB8

--HG--
extra : rebase_source : 9cf85c7cbe2e8511ad2db59e7bf7ba6e8db79883
This commit is contained in:
Kartikaya Gupta 2017-07-10 10:15:24 -04:00
parent 1fd7214235
commit 78bfd54626
4 changed files with 31 additions and 20 deletions

View File

@ -215,17 +215,6 @@ Factory::Init(const Config& aConfig)
MOZ_ASSERT(!sConfig);
sConfig = new Config(aConfig);
// Make sure we don't completely break rendering because of a typo in the
// pref or whatnot.
const int32_t kMinAllocPref = 10000000;
const int32_t kMinSizePref = 2048;
if (sConfig->mMaxAllocSize < kMinAllocPref) {
sConfig->mMaxAllocSize = kMinAllocPref;
}
if (sConfig->mMaxTextureSize < kMinSizePref) {
sConfig->mMaxTextureSize = kMinSizePref;
}
#ifdef MOZ_ENABLE_FREETYPE
mFTLock = new Mutex("Factory::mFTLock");
#endif

View File

@ -848,18 +848,36 @@ gfxPlatform::IsDXInterop2Blocked()
return status != nsIGfxInfo::FEATURE_STATUS_OK;
}
/* static */ int32_t
gfxPlatform::MaxTextureSize()
{
// Make sure we don't completely break rendering because of a typo in the
// pref or whatnot.
const int32_t kMinSizePref = 2048;
return std::max(kMinSizePref, gfxPrefs::MaxTextureSizeDoNotUseDirectly());
}
/* static */ int32_t
gfxPlatform::MaxAllocSize()
{
// Make sure we don't completely break rendering because of a typo in the
// pref or whatnot.
const int32_t kMinAllocPref = 10000000;
return std::max(kMinAllocPref, gfxPrefs::MaxAllocSizeDoNotUseDirectly());
}
/* static */ void
gfxPlatform::InitMoz2DLogging()
{
auto fwd = new CrashStatsLogForwarder("GraphicsCriticalError");
fwd->SetCircularBufferSize(gfxPrefs::GfxLoggingCrashLength());
auto fwd = new CrashStatsLogForwarder("GraphicsCriticalError");
fwd->SetCircularBufferSize(gfxPrefs::GfxLoggingCrashLength());
mozilla::gfx::Config cfg;
cfg.mLogForwarder = fwd;
cfg.mMaxTextureSize = gfxPrefs::MaxTextureSize();
cfg.mMaxAllocSize = gfxPrefs::MaxAllocSize();
mozilla::gfx::Config cfg;
cfg.mLogForwarder = fwd;
cfg.mMaxTextureSize = gfxPlatform::MaxTextureSize();
cfg.mMaxAllocSize = gfxPlatform::MaxAllocSize();
gfx::Factory::Init(cfg);
gfx::Factory::Init(cfg);
}
/* static */ bool

View File

@ -189,6 +189,8 @@ public:
*/
static void InitNullMetadata();
static int32_t MaxTextureSize();
static int32_t MaxAllocSize();
static void InitMoz2DLogging();
static bool IsHeadless();

View File

@ -448,8 +448,10 @@ private:
// The maximums here are quite conservative, we can tighten them if problems show up.
DECL_GFX_PREF(Once, "gfx.logging.texture-usage.enabled", GfxLoggingTextureUsageEnabled, bool, false);
DECL_GFX_PREF(Once, "gfx.logging.peak-texture-usage.enabled",GfxLoggingPeakTextureUsageEnabled, bool, false);
DECL_GFX_PREF(Once, "gfx.max-alloc-size", MaxAllocSize, int32_t, (int32_t)500000000);
DECL_GFX_PREF(Once, "gfx.max-texture-size", MaxTextureSize, int32_t, (int32_t)32767);
// Use gfxPlatform::MaxAllocSize instead of the pref directly
DECL_GFX_PREF(Once, "gfx.max-alloc-size", MaxAllocSizeDoNotUseDirectly, int32_t, (int32_t)500000000);
// Use gfxPlatform::MaxTextureSize instead of the pref directly
DECL_GFX_PREF(Once, "gfx.max-texture-size", MaxTextureSizeDoNotUseDirectly, int32_t, (int32_t)32767);
DECL_GFX_PREF(Live, "gfx.partialpresent.force", PartialPresent, int32_t, 0);
DECL_GFX_PREF(Live, "gfx.perf-warnings.enabled", PerfWarnings, bool, false);
DECL_GFX_PREF(Live, "gfx.SurfaceTexture.detach.enabled", SurfaceTextureDetachEnabled, bool, true);