mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 460629 - Bogus ICC profile detection for LCMS.r=vlad,a191=beltzner
This commit is contained in:
parent
eb4f4f25b0
commit
020c84f8c9
@ -598,10 +598,6 @@ gfxPlatform::GetCMSOutputProfile()
|
||||
getter_Copies(fname));
|
||||
if (NS_SUCCEEDED(rv) && !fname.IsEmpty()) {
|
||||
gCMSOutputProfile = cmsOpenProfileFromFile(fname, "r");
|
||||
if (gCMSOutputProfile)
|
||||
fprintf(stderr,
|
||||
"ICM profile read from %s successfully\n",
|
||||
fname.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -611,6 +607,15 @@ gfxPlatform::GetCMSOutputProfile()
|
||||
gfxPlatform::GetPlatform()->GetPlatformCMSOutputProfile();
|
||||
}
|
||||
|
||||
/* Determine if the profile looks bogus. If so, close the profile
|
||||
* and use sRGB instead. See bug 460629, */
|
||||
if (gCMSOutputProfile && cmsProfileIsBogus(gCMSOutputProfile)) {
|
||||
NS_ASSERTION(gCMSOutputProfile != GetCMSsRGBProfile(),
|
||||
"Builtin sRGB profile tagged as bogus!!!");
|
||||
cmsCloseProfile(gCMSOutputProfile);
|
||||
gCMSOutputProfile = nsnull;
|
||||
}
|
||||
|
||||
if (!gCMSOutputProfile) {
|
||||
gCMSOutputProfile = GetCMSsRGBProfile();
|
||||
}
|
||||
|
@ -855,6 +855,7 @@ LCMSAPI LPcmsCIExyY LCMSEXPORT cmsD50_xyY(void);
|
||||
LCMSAPI cmsHPROFILE LCMSEXPORT cmsOpenProfileFromFile(const char *ICCProfile, const char *sAccess);
|
||||
LCMSAPI cmsHPROFILE LCMSEXPORT cmsOpenProfileFromMem(LPVOID MemPtr, DWORD dwSize);
|
||||
LCMSAPI LCMSBOOL LCMSEXPORT cmsCloseProfile(cmsHPROFILE hProfile);
|
||||
LCMSAPI LCMSBOOL LCMSEXPORT cmsProfileIsBogus(cmsHPROFILE hProfile);
|
||||
|
||||
// Predefined run-time profiles
|
||||
|
||||
|
@ -2523,7 +2523,47 @@ cmsHPROFILE LCMSEXPORT cmsOpenProfileFromMem(LPVOID MemPtr, DWORD dwSize)
|
||||
|
||||
}
|
||||
|
||||
// Checks a profile for obvious inconsistencies and returns
|
||||
// TRUE if the profile looks bogus and should probably be
|
||||
// ignored.
|
||||
LCMSBOOL LCMSEXPORT cmsProfileIsBogus(cmsHPROFILE hProfile)
|
||||
{
|
||||
|
||||
cmsCIEXYZTRIPLE primaries;
|
||||
VEC3 sum, target, tolerance;
|
||||
unsigned i;
|
||||
|
||||
// Read the primaries
|
||||
cmsTakeColorants(&primaries, hProfile);
|
||||
|
||||
// Sum the values
|
||||
sum.n[0] = primaries.Red.X + primaries.Green.X + primaries.Blue.X;
|
||||
sum.n[1] = primaries.Red.Y + primaries.Green.Y + primaries.Blue.Y;
|
||||
sum.n[2] = primaries.Red.Z + primaries.Green.Z + primaries.Blue.Z;
|
||||
|
||||
// Build our target vector (see mozilla bug 460629)
|
||||
target.n[0] = 0.96420;
|
||||
target.n[1] = 1.00000;
|
||||
target.n[2] = 0.82491;
|
||||
|
||||
// Our tolerance vector - Recommended by Chris Murphy based on
|
||||
// conversion from the LAB space criterion of no more than 3 in any one
|
||||
// channel. This is similar to, but slightly more tolerant than Adobe's
|
||||
// criterion.
|
||||
tolerance.n[0] = 0.02;
|
||||
tolerance.n[1] = 0.02;
|
||||
tolerance.n[2] = 0.04;
|
||||
|
||||
// Compare with our tolerance
|
||||
for (i = 0; i < 3; ++i) {
|
||||
if (!(((sum.n[i] - tolerance.n[i]) <= target.n[i]) &&
|
||||
((sum.n[i] + tolerance.n[i]) >= target.n[i])))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// All Good
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
LCMSBOOL LCMSEXPORT cmsCloseProfile(cmsHPROFILE hProfile)
|
||||
{
|
||||
|
@ -10,6 +10,7 @@ EXPORTS
|
||||
cmsSmoothGamma = cmsSmoothGamma
|
||||
cmsBuildRGB2XYZtransferMatrix= cmsBuildRGB2XYZtransferMatrix
|
||||
cmsPrecacheProfile = cmsPrecacheProfile
|
||||
cmsProfileIsBogus = cmsProfileIsBogus
|
||||
cmsCloseProfile = cmsCloseProfile
|
||||
cmsCreateProofingTransform = cmsCreateProofingTransform
|
||||
cmsCreateRGBProfile = cmsCreateRGBProfile
|
||||
|
Loading…
Reference in New Issue
Block a user