зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1678487 - Make CMSMode an enum class. r=aosmond
Differential Revision: https://phabricator.services.mozilla.com/D104945
This commit is contained in:
Родитель
47b903f8b3
Коммит
ba4d1a3c68
|
@ -177,7 +177,7 @@ static qcms_transform* gCMSRGBATransform = nullptr;
|
|||
static qcms_transform* gCMSBGRATransform = nullptr;
|
||||
|
||||
static bool gCMSInitialized = false;
|
||||
static eCMSMode gCMSMode = eCMSMode_Off;
|
||||
static CMSMode gCMSMode = CMSMode::Off;
|
||||
|
||||
static void ShutdownCMS();
|
||||
|
||||
|
@ -2021,11 +2021,11 @@ bool gfxPlatform::OffMainThreadCompositingEnabled() {
|
|||
return UsesOffMainThreadCompositing();
|
||||
}
|
||||
|
||||
eCMSMode gfxPlatform::GetCMSMode() {
|
||||
CMSMode gfxPlatform::GetCMSMode() {
|
||||
if (!gCMSInitialized) {
|
||||
int32_t mode = StaticPrefs::gfx_color_management_mode();
|
||||
if (mode >= 0 && mode < eCMSMode_AllCount) {
|
||||
gCMSMode = static_cast<eCMSMode>(mode);
|
||||
if (mode >= 0 && mode < int32_t(CMSMode::AllCount)) {
|
||||
gCMSMode = CMSMode(mode);
|
||||
}
|
||||
|
||||
bool enableV4 = StaticPrefs::gfx_color_management_enablev4();
|
||||
|
@ -2037,7 +2037,7 @@ eCMSMode gfxPlatform::GetCMSMode() {
|
|||
return gCMSMode;
|
||||
}
|
||||
|
||||
void gfxPlatform::SetCMSModeOverride(eCMSMode aMode) {
|
||||
void gfxPlatform::SetCMSModeOverride(CMSMode aMode) {
|
||||
MOZ_ASSERT(gCMSInitialized);
|
||||
gCMSMode = aMode;
|
||||
}
|
||||
|
@ -2283,7 +2283,7 @@ static void ShutdownCMS() {
|
|||
}
|
||||
|
||||
// Reset the state variables
|
||||
gCMSMode = eCMSMode_Off;
|
||||
gCMSMode = CMSMode::Off;
|
||||
gCMSInitialized = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -74,11 +74,11 @@ class SystemFontListEntry;
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
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 class CMSMode : int32_t {
|
||||
Off = 0, // No color management
|
||||
All = 1, // Color manage everything
|
||||
TaggedOnly = 2, // Color manage tagged Images Only
|
||||
AllCount = 3
|
||||
};
|
||||
|
||||
enum eGfxLog {
|
||||
|
@ -530,12 +530,12 @@ class gfxPlatform : public mozilla::layers::MemoryPressureListener {
|
|||
/**
|
||||
* Are we going to try color management?
|
||||
*/
|
||||
static eCMSMode GetCMSMode();
|
||||
static CMSMode GetCMSMode();
|
||||
|
||||
/**
|
||||
* Used only for testing. Override the pref setting.
|
||||
*/
|
||||
static void SetCMSModeOverride(eCMSMode aMode);
|
||||
static void SetCMSModeOverride(CMSMode aMode);
|
||||
|
||||
/**
|
||||
* Determines the rendering intent for color management.
|
||||
|
|
|
@ -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() == eCMSMode_All) {
|
||||
if (gfxPlatform::GetCMSMode() == CMSMode::All) {
|
||||
qcms_transform* transform = gfxPlatform::GetCMSRGBTransform();
|
||||
if (transform) {
|
||||
return gfxPlatform::TransformPixel(aColor, transform);
|
||||
|
|
|
@ -318,10 +318,10 @@ struct StyleRGBA;
|
|||
namespace gfx {
|
||||
|
||||
/**
|
||||
* 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
|
||||
* 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
|
||||
* applicable).
|
||||
*/
|
||||
DeviceColor ToDeviceColor(const sRGBColor& aColor);
|
||||
|
|
|
@ -95,7 +95,7 @@ void Decoder::SetSurfaceFlags(SurfaceFlags aSurfaceFlags) {
|
|||
MOZ_ASSERT(!mInitialized);
|
||||
mSurfaceFlags = aSurfaceFlags;
|
||||
if (mSurfaceFlags & SurfaceFlags::NO_COLORSPACE_CONVERSION) {
|
||||
mCMSMode = eCMSMode_Off;
|
||||
mCMSMode = CMSMode::Off;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
#include "SurfaceFlags.h"
|
||||
#include "qcms.h"
|
||||
|
||||
enum class CMSMode : int32_t;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
namespace Telemetry {
|
||||
|
@ -567,7 +569,7 @@ class Decoder {
|
|||
uint8_t* mImageData; // Pointer to image data in BGRA/X
|
||||
uint32_t mImageDataLength;
|
||||
|
||||
uint32_t mCMSMode;
|
||||
CMSMode mCMSMode;
|
||||
|
||||
private:
|
||||
RefPtr<RasterImage> mImage;
|
||||
|
|
|
@ -717,7 +717,7 @@ LexerTransition<nsBMPDecoder::State> nsBMPDecoder::ReadBitfields(
|
|||
mBytesPerColor = (mH.mBIHSize == InfoHeaderLength::WIN_V2) ? 3 : 4;
|
||||
}
|
||||
|
||||
if (mCMSMode != eCMSMode_Off) {
|
||||
if (mCMSMode != CMSMode::Off) {
|
||||
switch (mH.mCsType) {
|
||||
case InfoColorSpace::EMBEDDED:
|
||||
return SeekColorProfile(aLength);
|
||||
|
|
|
@ -410,7 +410,7 @@ void nsGIFDecoder2::ConvertColormap(uint32_t* aColormap, uint32_t aColors) {
|
|||
}
|
||||
|
||||
// Apply CMS transformation if enabled and available
|
||||
if (mCMSMode == eCMSMode_All) {
|
||||
if (mCMSMode == CMSMode::All) {
|
||||
qcms_transform* transform = GetCMSsRGBTransform(SurfaceFormat::R8G8B8);
|
||||
if (transform) {
|
||||
qcms_transform_data(transform, aColormap, aColormap, aColors);
|
||||
|
|
|
@ -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 == eCMSMode_All) {
|
||||
if (mCMSMode == CMSMode::All) {
|
||||
mTransform = GetCMSsRGBTransform(format);
|
||||
}
|
||||
|
||||
|
|
|
@ -283,7 +283,7 @@ LexerTransition<nsJPEGDecoder::State> nsJPEGDecoder::ReadJPEGData(
|
|||
return Transition::TerminateFailure();
|
||||
}
|
||||
|
||||
if (mCMSMode != eCMSMode_Off) {
|
||||
if (mCMSMode != CMSMode::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 == eCMSMode_All) {
|
||||
} else if (mCMSMode == CMSMode::All) {
|
||||
mTransform = GetCMSsRGBTransform(SurfaceFormat::OS_RGBX);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -308,7 +308,7 @@ nsresult nsPNGDecoder::InitInternal() {
|
|||
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
// Ignore unused chunks
|
||||
if (mCMSMode == eCMSMode_Off || IsMetadataDecode()) {
|
||||
if (mCMSMode == CMSMode::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 != eCMSMode_Off) {
|
||||
if (decoder->mCMSMode != CMSMode::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 != eCMSMode_Off) {
|
||||
if (decoder->mCMSMode != CMSMode::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 == eCMSMode_TaggedOnly) ||
|
||||
decoder->mCMSMode == eCMSMode_All) {
|
||||
} else if ((sRGBTag && decoder->mCMSMode == CMSMode::TaggedOnly) ||
|
||||
decoder->mCMSMode == CMSMode::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
|
||||
|
|
|
@ -299,8 +299,8 @@ void nsWebPDecoder::ApplyColorProfile(const char* aProfile, size_t aLength) {
|
|||
MOZ_ASSERT(!mGotColorProfile);
|
||||
mGotColorProfile = true;
|
||||
|
||||
if (mCMSMode == eCMSMode_Off || !GetCMSOutputProfile() ||
|
||||
(mCMSMode == eCMSMode_TaggedOnly && !aProfile)) {
|
||||
if (mCMSMode == CMSMode::Off || !GetCMSOutputProfile() ||
|
||||
(mCMSMode == CMSMode::TaggedOnly && !aProfile)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ AutoInitializeImageLib::AutoInitializeImageLib() {
|
|||
|
||||
// Ensure we always color manage images with gtests.
|
||||
gfxPlatform::GetCMSMode();
|
||||
gfxPlatform::SetCMSModeOverride(eCMSMode_All);
|
||||
gfxPlatform::SetCMSModeOverride(CMSMode::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
|
||||
|
|
|
@ -4156,7 +4156,7 @@
|
|||
mirror: always
|
||||
|
||||
# 0 = Off, 1 = Full, 2 = Tagged Images Only.
|
||||
# See eCMSMode in gfx/thebes/gfxPlatform.h.
|
||||
# See CMSMode in gfx/thebes/gfxPlatform.h.
|
||||
- name: gfx.color_management.mode
|
||||
type: RelaxedAtomicInt32
|
||||
value: 2
|
||||
|
|
|
@ -828,7 +828,7 @@ nsresult nsXPLookAndFeel::GetColorValue(ColorID aID,
|
|||
// the traversal.
|
||||
if (!mozilla::ServoStyleSet::IsInServoTraversal()) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (gfxPlatform::GetCMSMode() == eCMSMode_All &&
|
||||
if (gfxPlatform::GetCMSMode() == CMSMode::All &&
|
||||
!IsSpecialColor(aID, aResult)) {
|
||||
qcms_transform* transform = gfxPlatform::GetCMSInverseRGBTransform();
|
||||
if (transform) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче