Bug 1560820 - Remove `sGfxLogLevel`. r=nical

`sGfxLogLevel` is a global variable whose value mirrors the value of the
"gfx.logging.level" pref in the prefs table, and is kept up to date by a
prefs callback.

But "gfx.logging.level" is a static pref that already has a mirror variable,
accessible via `StaticPrefs::gfx_logging_level()`.

So we can use the latter and remove the former, and this patch does that. The
patch also removes a sentence in a comment that refers to special treatment of
LOG_DEBUG and LOG_DEBUG_PRLOG, because that sentence appears to be referring to
something (another comment?) that is no longer present.

Differential Revision: https://phabricator.services.mozilla.com/D35625

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nicholas Nethercote 2019-07-24 00:05:23 +00:00
Родитель eaff3d665c
Коммит e54f4ead1e
4 изменённых файлов: 13 добавлений и 31 удалений

Просмотреть файл

@ -190,10 +190,6 @@ void mozilla_UnlockFTLibrary(FT_Library aFTLibrary) {
namespace mozilla {
namespace gfx {
// In Gecko, this value is managed by gfx.logging.level and gets updated when
// the pref change.
Atomic<int32_t> LoggingPrefs::sGfxLogLevel(LOG_DEFAULT);
#ifdef MOZ_ENABLE_FREETYPE
FT_Library Factory::mFTLibrary = nullptr;
StaticMutex Factory::mFTLock;
@ -219,18 +215,9 @@ DrawEventRecorder* Factory::mRecorder;
mozilla::gfx::Config* Factory::sConfig = nullptr;
static void PrefChanged(const char* aPref, void*) {
mozilla::gfx::LoggingPrefs::sGfxLogLevel =
Preferences::GetInt(StaticPrefs::GetPrefName_gfx_logging_level(),
StaticPrefs::GetPrefDefault_gfx_logging_level());
}
void Factory::Init(const Config& aConfig) {
MOZ_ASSERT(!sConfig);
sConfig = new Config(aConfig);
Preferences::RegisterCallback(
PrefChanged,
nsDependentCString(StaticPrefs::GetPrefName_gfx_logging_level()));
}
void Factory::ShutDown() {

Просмотреть файл

@ -22,6 +22,7 @@
#endif
#include "2D.h"
#include "mozilla/Atomics.h"
#include "mozilla/StaticPrefs.h"
#include "Point.h"
#include "BaseRect.h"
#include "Matrix.h"
@ -52,16 +53,6 @@ inline mozilla::LogLevel PRLogLevelForLevel(int aLevel) {
}
#endif
class LoggingPrefs {
public:
// Used to choose the level of logging we get. The higher the number,
// the more logging we get. Value of zero will give you no logging,
// 1 just errors, 2 adds warnings and 3 or 4 add debug logging.
// In addition to setting the value to 4, you will need to set the
// environment variable MOZ_LOG to gfx:4. See mozilla/Logging.h for details.
static Atomic<int32_t> sGfxLogLevel;
};
/// Graphics logging is available in both debug and release builds and is
/// controlled with a gfx.logging.level preference. If not set, the default
/// for the preference is 5 in the debug builds, 1 in the release builds.
@ -146,7 +137,7 @@ struct BasicLogger {
// OutputMessage below. If making any changes here, also make it
// in the appropriate places in that method.
static bool ShouldOutputMessage(int aLevel) {
if (LoggingPrefs::sGfxLogLevel >= aLevel) {
if (StaticPrefs::gfx_logging_level() >= aLevel) {
#if defined(MOZ_WIDGET_ANDROID)
return true;
#else
@ -155,7 +146,7 @@ struct BasicLogger {
return true;
} else
# endif
if ((LoggingPrefs::sGfxLogLevel >= LOG_DEBUG_PRLOG) ||
if ((StaticPrefs::gfx_logging_level() >= LOG_DEBUG_PRLOG) ||
(aLevel < LOG_DEBUG)) {
return true;
}
@ -172,13 +163,12 @@ struct BasicLogger {
// This behavior (the higher the preference, the more we log)
// is consistent with what prlog does in general. Note that if prlog
// is in the build, but disabled, we will printf if the preferences
// requires us to log something (see sGfxLogLevel for the special
// treatment of LOG_DEBUG and LOG_DEBUG_PRLOG)
// requires us to log something.
//
// If making any logic changes to this method, you should probably
// make the corresponding change in the ShouldOutputMessage method
// above.
if (LoggingPrefs::sGfxLogLevel >= aLevel) {
if (StaticPrefs::gfx_logging_level() >= aLevel) {
#if defined(MOZ_WIDGET_ANDROID)
printf_stderr("%s%s", aString.c_str(), aNoNewline ? "" : "\n");
#else
@ -188,7 +178,7 @@ struct BasicLogger {
("%s%s", aString.c_str(), aNoNewline ? "" : "\n"));
} else
# endif
if ((LoggingPrefs::sGfxLogLevel >= LOG_DEBUG_PRLOG) ||
if ((StaticPrefs::gfx_logging_level() >= LOG_DEBUG_PRLOG) ||
(aLevel < LOG_DEBUG)) {
printf("%s%s", aString.c_str(), aNoNewline ? "" : "\n");
}

Просмотреть файл

@ -9,7 +9,6 @@
#ifndef mozilla_StaticPrefs_h
#define mozilla_StaticPrefs_h
#include "gfxPlatform.h"
#include "mozilla/Assertions.h"
#include "mozilla/Atomics.h"
#include "mozilla/TypeTraits.h"

Просмотреть файл

@ -2658,7 +2658,13 @@
value: 23456
mirror: always
# Note that "gfx.logging.level" is defined in Logging.h.
# The level of logging:
# - 0: no logging;
# - 1: adds errors;
# - 2: adds warnings;
# - 3 or 4: adds debug logging.
# If you set the value to 4, you will also need to set the environment
# variable MOZ_LOG to gfx:4. See mozilla/Logging.h for details.
- name: gfx.logging.level
type: RelaxedAtomicInt32
value: mozilla::gfx::LOG_DEFAULT