qcms_profile * gfxPlatform::GetCMSOutputProfile() { if (!gCMSOutputProfile) { NS_TIME_FUNCTION; nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID); if (prefs) { nsresult rv; /* 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 GetBoolPref will typically throw (and leave its out-param untouched). */ PRBool doSRGBOverride; rv = prefs->GetBoolPref(CMForceSRGBPrefName, &doSRGBOverride); if (NS_SUCCEEDED(rv) && doSRGBOverride) gCMSOutputProfile = GetCMSsRGBProfile(); if (!gCMSOutputProfile) { nsXPIDLCString fname; rv = prefs->GetCharPref(CMProfilePrefName, getter_Copies(fname)); if (NS_SUCCEEDED(rv) && !fname.IsEmpty()) { gCMSOutputProfile = qcms_profile_from_path(fname); } } } if (!gCMSOutputProfile) { gCMSOutputProfile = gfxPlatform::GetPlatform()->GetPlatformCMSOutputProfile(); } /* 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 = nsnull; } if (!gCMSOutputProfile) { gCMSOutputProfile = GetCMSsRGBProfile(); } /* Precache the LUT16 Interpolations for the output profile. See bug 444661 for details. */ qcms_profile_precache_output_transform(gCMSOutputProfile); } return gCMSOutputProfile; }
qcms_transform * gfxPlatform::GetCMSInverseRGBTransform() { if (!gCMSInverseRGBTransform) { qcms_profile *inProfile, *outProfile; inProfile = GetCMSOutputProfile(); outProfile = GetCMSsRGBProfile(); if (!inProfile || !outProfile) return nsnull; gCMSInverseRGBTransform = qcms_transform_create(inProfile, QCMS_DATA_RGB_8, outProfile, QCMS_DATA_RGB_8, QCMS_INTENT_PERCEPTUAL); } return gCMSInverseRGBTransform; }