Backed out 5 changesets (bug 1678487) for multiple failures. CLOSED TREE

Backed out changeset 00242b4230f2 (bug 1678487)
Backed out changeset 63612a51cfee (bug 1678487)
Backed out changeset bd0321ad1968 (bug 1678487)
Backed out changeset c6a4d3c17d39 (bug 1678487)
Backed out changeset 5de112a29a87 (bug 1678487)
This commit is contained in:
Brindusan Cristian 2021-02-13 02:41:17 +02:00
parent 55d1d2d099
commit d930c1c648
16 changed files with 543 additions and 351 deletions

View File

@ -152,9 +152,6 @@ static const uint32_t kDefaultGlyphCacheSize = -1;
#include "mozilla/gfx/GPUParent.h"
#include "prsystem.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/gfx/SourceSurfaceCairo.h"
using namespace mozilla;
using namespace mozilla::layers;
using namespace mozilla::gl;
@ -169,17 +166,34 @@ const ContentDeviceData* gContentDeviceInitData = nullptr;
static Mutex* gGfxPlatformPrefsLock = nullptr;
bool gfxPlatform::gCMSInitialized = false;
CMSMode gfxPlatform::gCMSMode = CMSMode::Off;
// These two may point to the same profile
qcms_profile* gfxPlatform::gCMSOutputProfile = nullptr;
qcms_profile* gfxPlatform::gCMSsRGBProfile = nullptr;
static qcms_profile* gCMSOutputProfile = nullptr;
static qcms_profile* gCMSsRGBProfile = nullptr;
qcms_transform* gfxPlatform::gCMSRGBTransform = nullptr;
qcms_transform* gfxPlatform::gCMSInverseRGBTransform = nullptr;
qcms_transform* gfxPlatform::gCMSRGBATransform = nullptr;
qcms_transform* gfxPlatform::gCMSBGRATransform = nullptr;
static bool gCMSRGBTransformFailed = false;
static qcms_transform* gCMSRGBTransform = nullptr;
static qcms_transform* gCMSInverseRGBTransform = nullptr;
static qcms_transform* gCMSRGBATransform = nullptr;
static qcms_transform* gCMSBGRATransform = nullptr;
static bool gCMSInitialized = false;
static eCMSMode gCMSMode = eCMSMode_Off;
static void ShutdownCMS();
#include "mozilla/gfx/2D.h"
#include "mozilla/gfx/SourceSurfaceCairo.h"
/* Class to listen for pref changes so that chrome code can dynamically
force sRGB as an output profile. See Bug #452125. */
class SRGBOverrideObserver final : public nsIObserver,
public nsSupportsWeakReference {
~SRGBOverrideObserver() = default;
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
};
/// This override of the LogForwarder, initially used for the critical graphics
/// errors, is sending the log to the crash annotations as well, but only
@ -391,6 +405,8 @@ void CrashStatsLogForwarder::CrashAction(LogReason aReason) {
}
}
NS_IMPL_ISUPPORTS(SRGBOverrideObserver, nsIObserver, nsISupportsWeakReference)
#define GFX_DOWNLOADABLE_FONTS_ENABLED "gfx.downloadable_fonts.enabled"
#define GFX_PREF_FALLBACK_USE_CMAPS \
@ -408,8 +424,27 @@ void CrashStatsLogForwarder::CrashAction(LogReason aReason) {
#define BIDI_NUMERAL_PREF "bidi.numeral"
#define GFX_PREF_CMS_FORCE_SRGB "gfx.color_management.force_srgb"
#define FONT_VARIATIONS_PREF "layout.css.font-variations.enabled"
NS_IMETHODIMP
SRGBOverrideObserver::Observe(nsISupports* aSubject, const char* aTopic,
const char16_t* someData) {
NS_ASSERTION(NS_strcmp(someData, (u"" GFX_PREF_CMS_FORCE_SRGB)) == 0,
"Restarting CMS on wrong pref!");
ShutdownCMS();
// Update current cms profile.
gfxPlatform::CreateCMSOutputProfile();
// FIXME(aosmond): This is also racy for the transforms but the pref is only
// used for dev purposes. It can be made a static pref in a followup once the
// dependency on it is removed from the gtest suite (see bug 1620600).
gfxPlatform::GetCMSRGBTransform();
gfxPlatform::GetCMSRGBATransform();
gfxPlatform::GetCMSBGRATransform();
return NS_OK;
}
static const char* kObservedPrefs[] = {"gfx.downloadable_fonts.",
"gfx.font_rendering.", BIDI_NUMERAL_PREF,
nullptr};
@ -992,15 +1027,25 @@ void gfxPlatform::Init() {
MOZ_CRASH("Could not initialize gfxFontCache");
}
/* Create and register our CMS Override observer. */
gPlatform->mSRGBOverrideObserver = new SRGBOverrideObserver();
Preferences::AddWeakObserver(gPlatform->mSRGBOverrideObserver,
GFX_PREF_CMS_FORCE_SRGB);
Preferences::RegisterPrefixCallbacks(FontPrefChanged, kObservedPrefs);
GLContext::PlatformStartup();
Preferences::RegisterCallbackAndCall(RecordingPrefChanged,
"gfx.2d.recording");
CreateCMSOutputProfile();
// Create the sRGB to output display profile transforms. They can be accessed
// off the main thread so we want to avoid a race condition.
InitializeCMS();
GetCMSRGBTransform();
GetCMSRGBATransform();
GetCMSBGRATransform();
// Listen to memory pressure event so we can purge DrawTarget caches
gPlatform->mMemoryPressureObserver =
@ -1234,6 +1279,13 @@ void gfxPlatform::Shutdown() {
// Free the various non-null transforms and loaded profiles
ShutdownCMS();
/* 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;
Preferences::UnregisterPrefixCallbacks(FontPrefChanged, kObservedPrefs);
NS_ASSERTION(gPlatform->mMemoryPressureObserver,
@ -2015,7 +2067,23 @@ bool gfxPlatform::OffMainThreadCompositingEnabled() {
return UsesOffMainThreadCompositing();
}
void gfxPlatform::SetCMSModeOverride(CMSMode aMode) {
eCMSMode gfxPlatform::GetCMSMode() {
if (!gCMSInitialized) {
int32_t mode = StaticPrefs::gfx_color_management_mode();
if (mode >= 0 && mode < eCMSMode_AllCount) {
gCMSMode = static_cast<eCMSMode>(mode);
}
bool enableV4 = StaticPrefs::gfx_color_management_enablev4();
if (enableV4) {
qcms_enable_iccv4();
}
gCMSInitialized = true;
}
return gCMSMode;
}
void gfxPlatform::SetCMSModeOverride(eCMSMode aMode) {
MOZ_ASSERT(gCMSInitialized);
gCMSMode = aMode;
}
@ -2089,82 +2157,121 @@ const mozilla::gfx::ContentDeviceData* gfxPlatform::GetInitContentDeviceData() {
return gContentDeviceInitData;
}
void gfxPlatform::InitializeCMS() {
MOZ_DIAGNOSTIC_ASSERT(NS_IsMainThread());
MOZ_DIAGNOSTIC_ASSERT(!gCMSInitialized);
{
int32_t mode = StaticPrefs::gfx_color_management_mode();
if (mode >= 0 && mode < int32_t(CMSMode::AllCount)) {
gCMSMode = CMSMode(mode);
}
bool enableV4 = StaticPrefs::gfx_color_management_enablev4();
if (enableV4) {
qcms_enable_iccv4();
}
}
gCMSsRGBProfile = qcms_profile_sRGB();
/* Determine if we're using the internal override to force sRGB as
an output profile for reftests. See Bug 452125.
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).
*/
if (StaticPrefs::gfx_color_management_force_srgb()) {
gCMSOutputProfile = gCMSsRGBProfile;
}
void gfxPlatform::CreateCMSOutputProfile() {
if (!gCMSOutputProfile) {
nsTArray<uint8_t> outputProfileData =
gfxPlatform::GetPlatform()->GetPlatformCMSOutputProfileData();
if (!outputProfileData.IsEmpty()) {
gCMSOutputProfile = qcms_profile_from_memory(outputProfileData.Elements(),
outputProfileData.Length());
/* Determine if we're using the internal override to force sRGB as
an output profile for reftests. See Bug 452125.
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).
*/
if (Preferences::GetBool(GFX_PREF_CMS_FORCE_SRGB, false)) {
gCMSOutputProfile = GetCMSsRGBProfile();
}
if (!gCMSOutputProfile) {
nsTArray<uint8_t> outputProfileData =
gfxPlatform::GetPlatform()->GetPlatformCMSOutputProfileData();
if (!outputProfileData.IsEmpty()) {
gCMSOutputProfile = qcms_profile_from_memory(
outputProfileData.Elements(), outputProfileData.Length());
}
}
/* 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();
}
/* Precache the LUT16 Interpolations for the output profile. See
bug 444661 for details. */
qcms_profile_precache_output_transform(gCMSOutputProfile);
}
}
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() {
if (!gCMSRGBTransform && !gCMSRGBTransformFailed) {
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);
if (!gCMSRGBTransform) {
gCMSRGBTransformFailed = true;
}
}
/* 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 != gCMSsRGBProfile,
"Builtin sRGB profile tagged as bogus!!!");
qcms_profile_release(gCMSOutputProfile);
gCMSOutputProfile = nullptr;
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);
}
if (!gCMSOutputProfile) {
gCMSOutputProfile = gCMSsRGBProfile;
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);
}
/* Precache the LUT16 Interpolations for the output profile. See
bug 444661 for details. */
qcms_profile_precache_output_transform(gCMSOutputProfile);
return gCMSRGBATransform;
}
// Create the RGB transform.
gCMSRGBTransform = qcms_transform_create(
gCMSsRGBProfile, QCMS_DATA_RGB_8, gCMSOutputProfile,
QCMS_DATA_RGB_8, QCMS_INTENT_PERCEPTUAL);
qcms_transform* gfxPlatform::GetCMSBGRATransform() {
if (!gCMSBGRATransform) {
qcms_profile *inProfile, *outProfile;
outProfile = GetCMSOutputProfile();
inProfile = GetCMSsRGBProfile();
// And the inverse.
gCMSInverseRGBTransform = qcms_transform_create(
gCMSOutputProfile, QCMS_DATA_RGB_8, gCMSsRGBProfile,
QCMS_DATA_RGB_8, QCMS_INTENT_PERCEPTUAL);
if (!inProfile || !outProfile) return nullptr;
// The RGBA transform.
gCMSRGBATransform = qcms_transform_create(
gCMSsRGBProfile, QCMS_DATA_RGBA_8, gCMSOutputProfile,
QCMS_DATA_RGBA_8, QCMS_INTENT_PERCEPTUAL);
gCMSBGRATransform =
qcms_transform_create(inProfile, QCMS_DATA_BGRA_8, outProfile,
QCMS_DATA_BGRA_8, QCMS_INTENT_PERCEPTUAL);
}
// And the BGRA one.
gCMSBGRATransform = qcms_transform_create(
gCMSsRGBProfile, QCMS_DATA_BGRA_8, gCMSOutputProfile,
QCMS_DATA_BGRA_8, QCMS_INTENT_PERCEPTUAL);
gCMSInitialized = true;
return gCMSBGRATransform;
}
qcms_transform* gfxPlatform::GetCMSOSRGBATransform() {
@ -2192,7 +2299,7 @@ qcms_data_type gfxPlatform::GetCMSOSRGBAType() {
}
/* Shuts down various transforms and profiles for CMS. */
void gfxPlatform::ShutdownCMS() {
static void ShutdownCMS() {
if (gCMSRGBTransform) {
qcms_transform_release(gCMSRGBTransform);
gCMSRGBTransform = nullptr;
@ -2213,9 +2320,7 @@ void gfxPlatform::ShutdownCMS() {
qcms_profile_release(gCMSOutputProfile);
// handle the aliased case
if (gCMSsRGBProfile == gCMSOutputProfile) {
gCMSsRGBProfile = nullptr;
}
if (gCMSsRGBProfile == gCMSOutputProfile) gCMSsRGBProfile = nullptr;
gCMSOutputProfile = nullptr;
}
if (gCMSsRGBProfile) {
@ -2224,7 +2329,7 @@ void gfxPlatform::ShutdownCMS() {
}
// Reset the state variables
gCMSMode = CMSMode::Off;
gCMSMode = eCMSMode_Off;
gCMSInitialized = false;
}

View File

@ -74,11 +74,11 @@ class SystemFontListEntry;
} \
} while (0)
enum class CMSMode : int32_t {
Off = 0, // No color management
All = 1, // Color manage everything
TaggedOnly = 2, // Color manage tagged Images Only
AllCount = 3
enum eCMSMode {
eCMSMode_Off = 0, // No color management
eCMSMode_All = 1, // Color manage everything
eCMSMode_TaggedOnly = 2, // Color manage tagged Images Only
eCMSMode_AllCount = 3
};
enum eGfxLog {
@ -530,15 +530,12 @@ class gfxPlatform : public mozilla::layers::MemoryPressureListener {
/**
* Are we going to try color management?
*/
static CMSMode GetCMSMode() {
MOZ_ASSERT(gCMSInitialized);
return gCMSMode;
}
static eCMSMode GetCMSMode();
/**
* Used only for testing. Override the pref setting.
*/
static void SetCMSModeOverride(CMSMode aMode);
static void SetCMSModeOverride(eCMSMode aMode);
/**
* Determines the rendering intent for color management.
@ -561,50 +558,32 @@ class gfxPlatform : public mozilla::layers::MemoryPressureListener {
/**
* Return the output device ICC profile.
*/
static qcms_profile* GetCMSOutputProfile() {
MOZ_ASSERT(gCMSInitialized);
return gCMSOutputProfile;
}
static qcms_profile* GetCMSOutputProfile();
/**
* Return the sRGB ICC profile.
*/
static qcms_profile* GetCMSsRGBProfile() {
MOZ_ASSERT(gCMSInitialized);
return gCMSsRGBProfile;
}
static qcms_profile* GetCMSsRGBProfile();
/**
* Return sRGB -> output device transform.
*/
static qcms_transform* GetCMSRGBTransform() {
MOZ_ASSERT(gCMSInitialized);
return gCMSRGBTransform;
}
static qcms_transform* GetCMSRGBTransform();
/**
* Return output -> sRGB device transform.
*/
static qcms_transform* GetCMSInverseRGBTransform() {
MOZ_ASSERT(gCMSInitialized);
return gCMSInverseRGBTransform;
}
static qcms_transform* GetCMSInverseRGBTransform();
/**
* Return sRGBA -> output device transform.
*/
static qcms_transform* GetCMSRGBATransform() {
MOZ_ASSERT(gCMSInitialized);
return gCMSRGBATransform;
}
static qcms_transform* GetCMSRGBATransform();
/**
* Return sBGRA -> output device transform.
*/
static qcms_transform* GetCMSBGRATransform() {
MOZ_ASSERT(gCMSInitialized);
return gCMSBGRATransform;
}
static qcms_transform* GetCMSBGRATransform();
/**
* Return OS RGBA -> output device transform.
@ -973,21 +952,7 @@ class gfxPlatform : public mozilla::layers::MemoryPressureListener {
static void Init();
static void InitOpenGLConfig();
static bool gCMSInitialized;
static CMSMode gCMSMode;
// These two may point to the same profile
static qcms_profile* gCMSOutputProfile;
static qcms_profile* gCMSsRGBProfile;
static qcms_transform* gCMSRGBTransform;
static qcms_transform* gCMSInverseRGBTransform;
static qcms_transform* gCMSRGBATransform;
static qcms_transform* gCMSBGRATransform;
static void InitializeCMS();
static void ShutdownCMS();
static void CreateCMSOutputProfile();
friend void RecordingPrefChanged(const char* aPrefName, void* aClosure);
@ -1018,6 +983,7 @@ class gfxPlatform : public mozilla::layers::MemoryPressureListener {
static bool IsDXP016Blocked();
RefPtr<gfxASurface> mScreenReferenceSurface;
nsCOMPtr<nsIObserver> mSRGBOverrideObserver;
RefPtr<mozilla::layers::MemoryPressureObserver> mMemoryPressureObserver;
// The preferred draw target backend to use for canvas

View File

@ -1464,7 +1464,7 @@ DeviceColor ToDeviceColor(const sRGBColor& aColor) {
// need to return the same object from all return points in this function. We
// could declare a local Color variable and use that, but we might as well
// just use aColor.
if (gfxPlatform::GetCMSMode() == CMSMode::All) {
if (gfxPlatform::GetCMSMode() == eCMSMode_All) {
qcms_transform* transform = gfxPlatform::GetCMSRGBTransform();
if (transform) {
return gfxPlatform::TransformPixel(aColor, transform);

View File

@ -318,10 +318,10 @@ struct StyleRGBA;
namespace gfx {
/**
* If the CMS mode is CMSMode::All, these functions transform the passed
* color to a device color using the transform returned by
* gfxPlatform::GetCMSRGBTransform(). If the CMS mode is some other value, the
* color is returned unchanged (other than a type change to Moz2D Color, if
* If the CMS mode is eCMSMode_All, these functions transform the passed
* color to a device color using the transform returened by gfxPlatform::
* GetCMSRGBTransform(). If the CMS mode is some other value, the color is
* returned unchanged (other than a type change to Moz2D Color, if
* applicable).
*/
DeviceColor ToDeviceColor(const sRGBColor& aColor);

View File

@ -95,7 +95,7 @@ void Decoder::SetSurfaceFlags(SurfaceFlags aSurfaceFlags) {
MOZ_ASSERT(!mInitialized);
mSurfaceFlags = aSurfaceFlags;
if (mSurfaceFlags & SurfaceFlags::NO_COLORSPACE_CONVERSION) {
mCMSMode = CMSMode::Off;
mCMSMode = eCMSMode_Off;
}
}

View File

@ -20,8 +20,6 @@
#include "SurfaceFlags.h"
#include "qcms.h"
enum class CMSMode : int32_t;
namespace mozilla {
namespace Telemetry {
@ -569,7 +567,7 @@ class Decoder {
uint8_t* mImageData; // Pointer to image data in BGRA/X
uint32_t mImageDataLength;
CMSMode mCMSMode;
uint32_t mCMSMode;
private:
RefPtr<RasterImage> mImage;

View File

@ -717,7 +717,7 @@ LexerTransition<nsBMPDecoder::State> nsBMPDecoder::ReadBitfields(
mBytesPerColor = (mH.mBIHSize == InfoHeaderLength::WIN_V2) ? 3 : 4;
}
if (mCMSMode != CMSMode::Off) {
if (mCMSMode != eCMSMode_Off) {
switch (mH.mCsType) {
case InfoColorSpace::EMBEDDED:
return SeekColorProfile(aLength);

View File

@ -410,7 +410,7 @@ void nsGIFDecoder2::ConvertColormap(uint32_t* aColormap, uint32_t aColors) {
}
// Apply CMS transformation if enabled and available
if (mCMSMode == CMSMode::All) {
if (mCMSMode == eCMSMode_All) {
qcms_transform* transform = GetCMSsRGBTransform(SurfaceFormat::R8G8B8);
if (transform) {
qcms_transform_data(transform, aColormap, aColormap, aColors);

View File

@ -58,7 +58,7 @@ LexerTransition<nsIconDecoder::State> nsIconDecoder::ReadHeader(
// premultiplied, so we can't support the surface flags with icons right now.
SurfacePipeFlags pipeFlags = SurfacePipeFlags();
if (transform) {
if (mCMSMode == CMSMode::All) {
if (mCMSMode == eCMSMode_All) {
mTransform = GetCMSsRGBTransform(format);
}

View File

@ -283,7 +283,7 @@ LexerTransition<nsJPEGDecoder::State> nsJPEGDecoder::ReadJPEGData(
return Transition::TerminateFailure();
}
if (mCMSMode != CMSMode::Off) {
if (mCMSMode != eCMSMode_Off) {
if ((mInProfile = GetICCProfile(mInfo)) != nullptr &&
GetCMSOutputProfile()) {
uint32_t profileSpace = qcms_profile_get_color_space(mInProfile);
@ -326,7 +326,7 @@ LexerTransition<nsJPEGDecoder::State> nsJPEGDecoder::ReadJPEGData(
GetCMSOutputProfile(),
outputType, (qcms_intent)intent);
}
} else if (mCMSMode == CMSMode::All) {
} else if (mCMSMode == eCMSMode_All) {
mTransform = GetCMSsRGBTransform(SurfaceFormat::OS_RGBX);
}
}

View File

@ -308,7 +308,7 @@ nsresult nsPNGDecoder::InitInternal() {
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
// Ignore unused chunks
if (mCMSMode == CMSMode::Off || IsMetadataDecode()) {
if (mCMSMode == eCMSMode_Off || IsMetadataDecode()) {
png_set_keep_unknown_chunks(mPNG, 1, color_chunks, 2);
}
@ -584,7 +584,7 @@ void nsPNGDecoder::info_callback(png_structp png_ptr, png_infop info_ptr) {
uint32_t intent = -1;
bool sRGBTag = false;
if (!decoder->IsMetadataDecode()) {
if (decoder->mCMSMode != CMSMode::Off) {
if (decoder->mCMSMode != eCMSMode_Off) {
intent = gfxPlatform::GetRenderingIntent();
uint32_t pIntent =
decoder->ReadColorProfile(png_ptr, info_ptr, color_type, &sRGBTag);
@ -597,7 +597,7 @@ void nsPNGDecoder::info_callback(png_structp png_ptr, png_infop info_ptr) {
png_set_gray_to_rgb(png_ptr);
// only do gamma correction if CMS isn't entirely disabled
if (decoder->mCMSMode != CMSMode::Off) {
if (decoder->mCMSMode != eCMSMode_Off) {
PNGDoGammaCorrection(png_ptr, info_ptr);
}
}
@ -685,8 +685,8 @@ void nsPNGDecoder::info_callback(png_structp png_ptr, png_infop info_ptr) {
decoder->mTransform = qcms_transform_create(decoder->mInProfile, inType,
decoder->GetCMSOutputProfile(),
outType, (qcms_intent)intent);
} else if ((sRGBTag && decoder->mCMSMode == CMSMode::TaggedOnly) ||
decoder->mCMSMode == CMSMode::All) {
} else if ((sRGBTag && decoder->mCMSMode == eCMSMode_TaggedOnly) ||
decoder->mCMSMode == eCMSMode_All) {
// If the transform happens with SurfacePipe, it will be in RGBA if we
// have an alpha channel, because the swizzle and premultiplication
// happens after color management. Otherwise it will be in OS_RGBA because

View File

@ -299,8 +299,8 @@ void nsWebPDecoder::ApplyColorProfile(const char* aProfile, size_t aLength) {
MOZ_ASSERT(!mGotColorProfile);
mGotColorProfile = true;
if (mCMSMode == CMSMode::Off || !GetCMSOutputProfile() ||
(mCMSMode == CMSMode::TaggedOnly && !aProfile)) {
if (mCMSMode == eCMSMode_Off || !GetCMSOutputProfile() ||
(mCMSMode == eCMSMode_TaggedOnly && !aProfile)) {
return;
}

View File

@ -55,7 +55,8 @@ AutoInitializeImageLib::AutoInitializeImageLib() {
gfxPlatform::GetPlatform();
// Ensure we always color manage images with gtests.
gfxPlatform::SetCMSModeOverride(CMSMode::All);
gfxPlatform::GetCMSMode();
gfxPlatform::SetCMSModeOverride(eCMSMode_All);
// Depending on initialization order, it is possible that our pref changes
// have not taken effect yet because there are pending gfx-related events on

View File

@ -4145,18 +4145,13 @@
#endif
mirror: always
- name: gfx.color_management.force_srgb
type: RelaxedAtomicBool
value: false
mirror: always
- name: gfx.color_management.enablev4
type: RelaxedAtomicBool
value: false
mirror: always
# 0 = Off, 1 = Full, 2 = Tagged Images Only.
# See CMSMode in gfx/thebes/gfxPlatform.h.
# See eCMSMode in gfx/thebes/gfxPlatform.h.
- name: gfx.color_management.mode
type: RelaxedAtomicInt32
value: 2

View File

@ -509,12 +509,10 @@ nsXPLookAndFeel::~nsXPLookAndFeel() {
sInstance = nullptr;
}
static bool IsSpecialColor(LookAndFeel::ColorID aID, nscolor aColor) {
using ColorID = LookAndFeel::ColorID;
bool nsXPLookAndFeel::IsSpecialColor(ColorID aID, nscolor& aColor) {
switch (aID) {
case ColorID::TextSelectForeground:
return aColor == NS_DONT_CHANGE_COLOR;
return (aColor == NS_DONT_CHANGE_COLOR);
case ColorID::IMESelectedRawTextBackground:
case ColorID::IMESelectedConvertedTextBackground:
case ColorID::IMERawInputBackground:
@ -530,19 +528,16 @@ static bool IsSpecialColor(LookAndFeel::ColorID aID, nscolor aColor) {
case ColorID::SpellCheckerUnderline:
return NS_IS_SELECTION_SPECIAL_COLOR(aColor);
default:
break;
/*
* In GetColor(), every color that is not a special color is color
* corrected. Use false to make other colors color corrected.
*/
return false;
}
/*
* In GetColor(), every color that is not a special color is color
* corrected. Use false to make other colors color corrected.
*/
return false;
}
// Returns whether there is a CSS color name for this color.
static bool ColorIsCSSAccessible(LookAndFeel::ColorID aID) {
using ColorID = LookAndFeel::ColorID;
bool nsXPLookAndFeel::ColorIsNotCSSAccessible(ColorID aID) {
switch (aID) {
case ColorID::WindowBackground:
case ColorID::WindowForeground:
@ -573,209 +568,338 @@ static bool ColorIsCSSAccessible(LookAndFeel::ColorID aID) {
case ColorID::IMESelectedConvertedTextForeground:
case ColorID::IMESelectedConvertedTextUnderline:
case ColorID::SpellCheckerUnderline:
return false;
return true;
default:
break;
}
return true;
return false;
}
nscolor nsXPLookAndFeel::GetStandinForNativeColor(ColorID aID) {
nscolor result = NS_RGB(0xFF, 0xFF, 0xFF);
// The stand-in colors are taken from the Windows 7 Aero theme
// except Mac-specific colors which are taken from Mac OS 10.7.
#define COLOR(name_, r, g, b) \
case ColorID::name_: \
return NS_RGB(r, g, b);
switch (aID) {
// CSS 2 colors:
COLOR(Activeborder, 0xB4, 0xB4, 0xB4)
COLOR(Activecaption, 0x99, 0xB4, 0xD1)
COLOR(Appworkspace, 0xAB, 0xAB, 0xAB)
COLOR(Background, 0x00, 0x00, 0x00)
COLOR(Buttonface, 0xF0, 0xF0, 0xF0)
COLOR(Buttonhighlight, 0xFF, 0xFF, 0xFF)
COLOR(Buttonshadow, 0xA0, 0xA0, 0xA0)
COLOR(Buttontext, 0x00, 0x00, 0x00)
COLOR(Captiontext, 0x00, 0x00, 0x00)
COLOR(Graytext, 0x6D, 0x6D, 0x6D)
COLOR(Highlight, 0x33, 0x99, 0xFF)
COLOR(Highlighttext, 0xFF, 0xFF, 0xFF)
COLOR(Inactiveborder, 0xF4, 0xF7, 0xFC)
COLOR(Inactivecaption, 0xBF, 0xCD, 0xDB)
COLOR(Inactivecaptiontext, 0x43, 0x4E, 0x54)
COLOR(Infobackground, 0xFF, 0xFF, 0xE1)
COLOR(Infotext, 0x00, 0x00, 0x00)
COLOR(Menu, 0xF0, 0xF0, 0xF0)
COLOR(Menutext, 0x00, 0x00, 0x00)
COLOR(Scrollbar, 0xC8, 0xC8, 0xC8)
COLOR(Threeddarkshadow, 0x69, 0x69, 0x69)
COLOR(Threedface, 0xF0, 0xF0, 0xF0)
COLOR(Threedhighlight, 0xFF, 0xFF, 0xFF)
COLOR(Threedlightshadow, 0xE3, 0xE3, 0xE3)
COLOR(Threedshadow, 0xA0, 0xA0, 0xA0)
COLOR(Window, 0xFF, 0xFF, 0xFF)
COLOR(Windowframe, 0x64, 0x64, 0x64)
COLOR(Windowtext, 0x00, 0x00, 0x00)
COLOR(MozButtondefault, 0x69, 0x69, 0x69)
COLOR(Field, 0xFF, 0xFF, 0xFF)
COLOR(Fieldtext, 0x00, 0x00, 0x00)
COLOR(MozDialog, 0xF0, 0xF0, 0xF0)
COLOR(MozDialogtext, 0x00, 0x00, 0x00)
COLOR(MozColheadertext, 0x00, 0x00, 0x00)
COLOR(MozColheaderhovertext, 0x00, 0x00, 0x00)
COLOR(MozDragtargetzone, 0xFF, 0xFF, 0xFF)
COLOR(MozCellhighlight, 0xF0, 0xF0, 0xF0)
COLOR(MozCellhighlighttext, 0x00, 0x00, 0x00)
COLOR(MozHtmlCellhighlight, 0x33, 0x99, 0xFF)
COLOR(MozHtmlCellhighlighttext, 0xFF, 0xFF, 0xFF)
COLOR(MozButtonhoverface, 0xF0, 0xF0, 0xF0)
COLOR(MozGtkButtonactivetext, 0x00, 0x00, 0x00)
COLOR(MozButtonhovertext, 0x00, 0x00, 0x00)
COLOR(MozMenuhover, 0x33, 0x99, 0xFF)
COLOR(MozMenuhovertext, 0x00, 0x00, 0x00)
COLOR(MozMenubartext, 0x00, 0x00, 0x00)
COLOR(MozMenubarhovertext, 0x00, 0x00, 0x00)
COLOR(MozOddtreerow, 0xFF, 0xFF, 0xFF)
COLOR(MozMacChromeActive, 0xB2, 0xB2, 0xB2)
COLOR(MozMacChromeInactive, 0xE1, 0xE1, 0xE1)
COLOR(MozMacFocusring, 0x60, 0x9D, 0xD7)
COLOR(MozMacMenuselect, 0x38, 0x75, 0xD7)
COLOR(MozMacMenushadow, 0xA3, 0xA3, 0xA3)
COLOR(MozMacMenutextdisable, 0x88, 0x88, 0x88)
COLOR(MozMacMenutextselect, 0xFF, 0xFF, 0xFF)
COLOR(MozMacDisabledtoolbartext, 0x3F, 0x3F, 0x3F)
COLOR(MozMacSecondaryhighlight, 0xD4, 0xD4, 0xD4)
COLOR(MozMacVibrancyLight, 0xf7, 0xf7, 0xf7)
COLOR(MozMacVibrantTitlebarLight, 0xf7, 0xf7, 0xf7)
COLOR(MozMacVibrancyDark, 0x28, 0x28, 0x28)
COLOR(MozMacVibrantTitlebarDark, 0x28, 0x28, 0x28)
COLOR(MozMacMenupopup, 0xe6, 0xe6, 0xe6)
COLOR(MozMacMenuitem, 0xe6, 0xe6, 0xe6)
COLOR(MozMacActiveMenuitem, 0x0a, 0x64, 0xdc)
COLOR(MozMacSourceList, 0xf7, 0xf7, 0xf7)
COLOR(MozMacSourceListSelection, 0xc8, 0xc8, 0xc8)
COLOR(MozMacActiveSourceListSelection, 0x0a, 0x64, 0xdc)
COLOR(MozMacTooltip, 0xf7, 0xf7, 0xf7)
// Seems to be the default color (hardcoded because of bug 1065998)
COLOR(MozWinAccentcolor, 0x9E, 0x9E, 0x9E)
COLOR(MozWinAccentcolortext, 0x00, 0x00, 0x00)
COLOR(MozWinMediatext, 0xFF, 0xFF, 0xFF)
COLOR(MozWinCommunicationstext, 0xFF, 0xFF, 0xFF)
COLOR(MozNativehyperlinktext, 0x00, 0x66, 0xCC)
COLOR(MozComboboxtext, 0x00, 0x00, 0x00)
COLOR(MozCombobox, 0xFF, 0xFF, 0xFF)
default:
case ColorID::Activeborder:
result = NS_RGB(0xB4, 0xB4, 0xB4);
break;
}
return NS_RGB(0xFF, 0xFF, 0xFF);
}
// Uncomment the #define below if you want to debug system color use in a skin
// that uses them. When set, it will make all system color pairs that are
// appropriate for foreground/background pairing the same. This means if the
// skin is using system colors correctly you will not be able to see *any* text.
//
// #define DEBUG_SYSTEM_COLOR_USE
#ifdef DEBUG_SYSTEM_COLOR_USE
static nsresult SystemColorUseDebuggingColor(LookAndFeel::ColorID aID,
nscolor& aResult) {
using ColorID = LookAndFeel::ColorID;
switch (aID) {
// css2 http://www.w3.org/TR/REC-CSS2/ui.html#system-colors
case ColorID::Activecaption:
// active window caption background
case ColorID::Captiontext:
// text in active window caption
aResult = NS_RGB(0xff, 0x00, 0x00);
result = NS_RGB(0x99, 0xB4, 0xD1);
break;
case ColorID::Highlight:
// background of selected item
case ColorID::Highlighttext:
// text of selected item
aResult = NS_RGB(0xff, 0xff, 0x00);
case ColorID::Appworkspace:
result = NS_RGB(0xAB, 0xAB, 0xAB);
break;
case ColorID::Inactivecaption:
// inactive window caption
case ColorID::Inactivecaptiontext:
// text in inactive window caption
aResult = NS_RGB(0x66, 0x66, 0x00);
case ColorID::Background:
result = NS_RGB(0x00, 0x00, 0x00);
break;
case ColorID::Infobackground:
// tooltip background color
case ColorID::Infotext:
// tooltip text color
aResult = NS_RGB(0x00, 0xff, 0x00);
break;
case ColorID::Menu:
// menu background
case ColorID::Menutext:
// menu text
aResult = NS_RGB(0x00, 0xff, 0xff);
break;
case ColorID::Threedface:
case ColorID::Buttonface:
// 3-D face color
result = NS_RGB(0xF0, 0xF0, 0xF0);
break;
case ColorID::Buttonhighlight:
result = NS_RGB(0xFF, 0xFF, 0xFF);
break;
case ColorID::Buttonshadow:
result = NS_RGB(0xA0, 0xA0, 0xA0);
break;
case ColorID::Buttontext:
// text on push buttons
aResult = NS_RGB(0x00, 0x66, 0x66);
result = NS_RGB(0x00, 0x00, 0x00);
break;
case ColorID::Captiontext:
result = NS_RGB(0x00, 0x00, 0x00);
break;
case ColorID::Graytext:
result = NS_RGB(0x6D, 0x6D, 0x6D);
break;
case ColorID::Highlight:
result = NS_RGB(0x33, 0x99, 0xFF);
break;
case ColorID::Highlighttext:
result = NS_RGB(0xFF, 0xFF, 0xFF);
break;
case ColorID::Inactiveborder:
result = NS_RGB(0xF4, 0xF7, 0xFC);
break;
case ColorID::Inactivecaption:
result = NS_RGB(0xBF, 0xCD, 0xDB);
break;
case ColorID::Inactivecaptiontext:
result = NS_RGB(0x43, 0x4E, 0x54);
break;
case ColorID::Infobackground:
result = NS_RGB(0xFF, 0xFF, 0xE1);
break;
case ColorID::Infotext:
result = NS_RGB(0x00, 0x00, 0x00);
break;
case ColorID::Menu:
result = NS_RGB(0xF0, 0xF0, 0xF0);
break;
case ColorID::Menutext:
result = NS_RGB(0x00, 0x00, 0x00);
break;
case ColorID::Scrollbar:
result = NS_RGB(0xC8, 0xC8, 0xC8);
break;
case ColorID::Threeddarkshadow:
result = NS_RGB(0x69, 0x69, 0x69);
break;
case ColorID::Threedface:
result = NS_RGB(0xF0, 0xF0, 0xF0);
break;
case ColorID::Threedhighlight:
result = NS_RGB(0xFF, 0xFF, 0xFF);
break;
case ColorID::Threedlightshadow:
result = NS_RGB(0xE3, 0xE3, 0xE3);
break;
case ColorID::Threedshadow:
result = NS_RGB(0xA0, 0xA0, 0xA0);
break;
case ColorID::Window:
result = NS_RGB(0xFF, 0xFF, 0xFF);
break;
case ColorID::Windowframe:
result = NS_RGB(0x64, 0x64, 0x64);
break;
case ColorID::Windowtext:
aResult = NS_RGB(0x00, 0x00, 0xff);
result = NS_RGB(0x00, 0x00, 0x00);
break;
case ColorID::MozButtondefault:
result = NS_RGB(0x69, 0x69, 0x69);
break;
// from the CSS3 working draft (not yet finalized)
// http://www.w3.org/tr/2000/wd-css3-userint-20000216.html#color
case ColorID::Field:
result = NS_RGB(0xFF, 0xFF, 0xFF);
break;
case ColorID::Fieldtext:
aResult = NS_RGB(0xff, 0x00, 0xff);
result = NS_RGB(0x00, 0x00, 0x00);
break;
case ColorID::MozDialog:
case ColorID::MozDialogtext:
aResult = NS_RGB(0x66, 0x00, 0x66);
result = NS_RGB(0xF0, 0xF0, 0xF0);
break;
case ColorID::MozDialogtext:
case ColorID::MozColheadertext:
case ColorID::MozColheaderhovertext:
result = NS_RGB(0x00, 0x00, 0x00);
break;
case ColorID::MozDragtargetzone:
result = NS_RGB(0xFF, 0xFF, 0xFF);
break;
case ColorID::MozCellhighlight:
result = NS_RGB(0xF0, 0xF0, 0xF0);
break;
case ColorID::MozCellhighlighttext:
result = NS_RGB(0x00, 0x00, 0x00);
break;
case ColorID::MozHtmlCellhighlight:
result = NS_RGB(0x33, 0x99, 0xFF);
break;
case ColorID::MozHtmlCellhighlighttext:
result = NS_RGB(0xFF, 0xFF, 0xFF);
break;
case ColorID::MozButtonhoverface:
result = NS_RGB(0xF0, 0xF0, 0xF0);
break;
case ColorID::MozGtkButtonactivetext:
case ColorID::MozButtonhovertext:
result = NS_RGB(0x00, 0x00, 0x00);
break;
case ColorID::MozMenuhover:
result = NS_RGB(0x33, 0x99, 0xFF);
break;
case ColorID::MozMenuhovertext:
result = NS_RGB(0x00, 0x00, 0x00);
break;
case ColorID::MozMenubartext:
result = NS_RGB(0x00, 0x00, 0x00);
break;
case ColorID::MozMenubarhovertext:
result = NS_RGB(0x00, 0x00, 0x00);
break;
case ColorID::MozOddtreerow:
result = NS_RGB(0xFF, 0xFF, 0xFF);
break;
case ColorID::MozMacChromeActive:
result = NS_RGB(0xB2, 0xB2, 0xB2);
break;
case ColorID::MozMacChromeInactive:
result = NS_RGB(0xE1, 0xE1, 0xE1);
break;
case ColorID::MozMacFocusring:
result = NS_RGB(0x60, 0x9D, 0xD7);
break;
case ColorID::MozMacMenuselect:
result = NS_RGB(0x38, 0x75, 0xD7);
break;
case ColorID::MozMacMenushadow:
result = NS_RGB(0xA3, 0xA3, 0xA3);
break;
case ColorID::MozMacMenutextdisable:
result = NS_RGB(0x88, 0x88, 0x88);
break;
case ColorID::MozMacMenutextselect:
result = NS_RGB(0xFF, 0xFF, 0xFF);
break;
case ColorID::MozMacDisabledtoolbartext:
result = NS_RGB(0x3F, 0x3F, 0x3F);
break;
case ColorID::MozMacSecondaryhighlight:
result = NS_RGB(0xD4, 0xD4, 0xD4);
break;
case ColorID::MozMacVibrancyLight:
case ColorID::MozMacVibrantTitlebarLight:
result = NS_RGB(0xf7, 0xf7, 0xf7);
break;
case ColorID::MozMacVibrancyDark:
case ColorID::MozMacVibrantTitlebarDark:
result = NS_RGB(0x28, 0x28, 0x28);
break;
case ColorID::MozMacMenupopup:
result = NS_RGB(0xe6, 0xe6, 0xe6);
break;
case ColorID::MozMacMenuitem:
result = NS_RGB(0xe6, 0xe6, 0xe6);
break;
case ColorID::MozMacActiveMenuitem:
result = NS_RGB(0x0a, 0x64, 0xdc);
break;
case ColorID::MozMacSourceList:
result = NS_RGB(0xf7, 0xf7, 0xf7);
break;
case ColorID::MozMacSourceListSelection:
result = NS_RGB(0xc8, 0xc8, 0xc8);
break;
case ColorID::MozMacActiveSourceListSelection:
result = NS_RGB(0x0a, 0x64, 0xdc);
break;
case ColorID::MozMacTooltip:
result = NS_RGB(0xf7, 0xf7, 0xf7);
break;
case ColorID::MozWinAccentcolor:
// Seems to be the default color (hardcoded because of bug 1065998)
result = NS_RGB(0x9E, 0x9E, 0x9E);
break;
case ColorID::MozWinAccentcolortext:
result = NS_RGB(0x00, 0x00, 0x00);
break;
case ColorID::MozWinMediatext:
result = NS_RGB(0xFF, 0xFF, 0xFF);
break;
case ColorID::MozWinCommunicationstext:
result = NS_RGB(0xFF, 0xFF, 0xFF);
break;
case ColorID::MozNativehyperlinktext:
result = NS_RGB(0x00, 0x66, 0xCC);
break;
case ColorID::MozComboboxtext:
result = NS_RGB(0x00, 0x00, 0x00);
break;
case ColorID::MozCombobox:
result = NS_RGB(0xFF, 0xFF, 0xFF);
break;
default:
return NS_ERROR_NOT_AVAILABLE;
break;
}
return NS_OK;
return result;
}
#endif
//
// All these routines will return NS_OK if they have a value,
// in which case the nsLookAndFeel should use that value;
// otherwise we'll return NS_ERROR_NOT_AVAILABLE, in which case, the
// platform-specific nsLookAndFeel should use its own values instead.
//
nsresult nsXPLookAndFeel::GetColorValue(ColorID aID,
bool aUseStandinsForNativeColors,
nscolor& aResult) {
if (!sInitialized) {
Init();
}
if (!sInitialized) Init();
// define DEBUG_SYSTEM_COLOR_USE if you want to debug system color
// use in a skin that uses them. When set, it will make all system
// color pairs that are appropriate for foreground/background
// pairing the same. This means if the skin is using system colors
// correctly you will not be able to see *any* text.
#undef DEBUG_SYSTEM_COLOR_USE
#ifdef DEBUG_SYSTEM_COLOR_USE
if (NS_SUCCEEDED(SystemColorUseDebuggingColor(aID, aResult))) {
return NS_OK;
}
#endif
{
nsresult rv = NS_OK;
switch (aID) {
// css2 http://www.w3.org/TR/REC-CSS2/ui.html#system-colors
case ColorID::Activecaption:
// active window caption background
case ColorID::Captiontext:
// text in active window caption
aResult = NS_RGB(0xff, 0x00, 0x00);
break;
// We only use standins for colors that we can access via CSS.
aUseStandinsForNativeColors =
aUseStandinsForNativeColors && ColorIsCSSAccessible(aID);
case ColorID::Highlight:
// background of selected item
case ColorID::Highlighttext:
// text of selected item
aResult = NS_RGB(0xff, 0xff, 0x00);
break;
case ColorID::Inactivecaption:
// inactive window caption
case ColorID::Inactivecaptiontext:
// text in inactive window caption
aResult = NS_RGB(0x66, 0x66, 0x00);
break;
case ColorID::Infobackground:
// tooltip background color
case ColorID::Infotext:
// tooltip text color
aResult = NS_RGB(0x00, 0xff, 0x00);
break;
case ColorID::Menu:
// menu background
case ColorID::Menutext:
// menu text
aResult = NS_RGB(0x00, 0xff, 0xff);
break;
case ColorID::Threedface:
case ColorID::Buttonface:
// 3-D face color
case ColorID::Buttontext:
// text on push buttons
aResult = NS_RGB(0x00, 0x66, 0x66);
break;
case ColorID::Window:
case ColorID::Windowtext:
aResult = NS_RGB(0x00, 0x00, 0xff);
break;
// from the CSS3 working draft (not yet finalized)
// http://www.w3.org/tr/2000/wd-css3-userint-20000216.html#color
case ColorID::Field:
case ColorID::Fieldtext:
aResult = NS_RGB(0xff, 0x00, 0xff);
break;
case ColorID::MozDialog:
case ColorID::MozDialogtext:
aResult = NS_RGB(0x66, 0x00, 0x66);
break;
default:
rv = NS_ERROR_NOT_AVAILABLE;
}
if (NS_SUCCEEDED(rv)) return rv;
}
#endif // DEBUG_SYSTEM_COLOR_USE
if (aUseStandinsForNativeColors && ColorIsNotCSSAccessible(aID)) {
aUseStandinsForNativeColors = false;
}
if (!aUseStandinsForNativeColors && IS_COLOR_CACHED(aID)) {
aResult = sCachedColors[uint32_t(aID)];
@ -824,23 +948,24 @@ nsresult nsXPLookAndFeel::GetColorValue(ColorID aID,
}
if (NS_SUCCEEDED(NativeGetColor(aID, aResult))) {
if (gfxPlatform::GetCMSMode() == CMSMode::All &&
!IsSpecialColor(aID, aResult)) {
qcms_transform* transform = gfxPlatform::GetCMSInverseRGBTransform();
if (transform) {
uint8_t color[4];
color[0] = NS_GET_R(aResult);
color[1] = NS_GET_G(aResult);
color[2] = NS_GET_B(aResult);
color[3] = NS_GET_A(aResult);
qcms_transform_data(transform, color, color, 1);
aResult = NS_RGBA(color[0], color[1], color[2], color[3]);
if (!mozilla::ServoStyleSet::IsInServoTraversal()) {
MOZ_ASSERT(NS_IsMainThread());
if ((gfxPlatform::GetCMSMode() == eCMSMode_All) &&
!IsSpecialColor(aID, aResult)) {
qcms_transform* transform = gfxPlatform::GetCMSInverseRGBTransform();
if (transform) {
uint8_t color[4];
color[0] = NS_GET_R(aResult);
color[1] = NS_GET_G(aResult);
color[2] = NS_GET_B(aResult);
color[3] = NS_GET_A(aResult);
qcms_transform_data(transform, color, color, 1);
aResult = NS_RGBA(color[0], color[1], color[2], color[3]);
}
}
}
// NOTE: Servo holds a lock and the main thread is paused, so writing to the
// global cache here is fine.
CACHE_COLOR(aID, aResult);
CACHE_COLOR(aID, aResult);
}
return NS_OK;
}

View File

@ -103,10 +103,12 @@ class nsXPLookAndFeel : public mozilla::LookAndFeel {
static void IntPrefChanged(nsLookAndFeelIntPref* data);
static void FloatPrefChanged(nsLookAndFeelFloatPref* data);
static void ColorPrefChanged(unsigned int index, const char* prefName);
static nscolor GetStandinForNativeColor(ColorID);
void InitFromPref(nsLookAndFeelIntPref* aPref);
void InitFromPref(nsLookAndFeelFloatPref* aPref);
void InitColorFromPref(int32_t aIndex);
bool IsSpecialColor(ColorID aID, nscolor& aColor);
bool ColorIsNotCSSAccessible(ColorID aID);
nscolor GetStandinForNativeColor(ColorID aID);
void RecordTelemetry();
virtual void RecordLookAndFeelSpecificTelemetry() {}