зеркало из https://github.com/mozilla/pjs.git
Bug 514932. Fix color profile retrieval on OS X 10.6. r=joshmoz
CMGetDeviceProfile(cmDisplayDeviceClass, cmDefaultDeviceID, cmDefaultProfileID, &device); returns cmDeviceNotRegistered on 10.6 so we need to use a different method to get the profile.
This commit is contained in:
Родитель
06e12fe5e9
Коммит
5e01f1a55c
|
@ -401,20 +401,49 @@ gfxPlatformMac::ReadAntiAliasingThreshold()
|
||||||
qcms_profile *
|
qcms_profile *
|
||||||
gfxPlatformMac::GetPlatformCMSOutputProfile()
|
gfxPlatformMac::GetPlatformCMSOutputProfile()
|
||||||
{
|
{
|
||||||
CMProfileLocation device;
|
qcms_profile *profile = nsnull;
|
||||||
CMError err = CMGetDeviceProfile(cmDisplayDeviceClass,
|
CMProfileRef cmProfile;
|
||||||
cmDefaultDeviceID,
|
CMProfileLocation *location;
|
||||||
cmDefaultProfileID,
|
UInt32 locationSize;
|
||||||
&device);
|
|
||||||
|
/* There a number of different ways that we could try to get a color
|
||||||
|
profile to use. On 10.5 all of these methods seem to give the same
|
||||||
|
results. On 10.6, the results are different and the following method,
|
||||||
|
using CGMainDisplayID() seems to best match what we are looking for.
|
||||||
|
Currently, both Google Chrome and Qt4 use a similar method.
|
||||||
|
|
||||||
|
CMTypes.h describes CMDisplayIDType:
|
||||||
|
"Data type for ColorSync DisplayID reference
|
||||||
|
On 8 & 9 this is a AVIDType
|
||||||
|
On X this is a CGSDisplayID"
|
||||||
|
|
||||||
|
CGMainDisplayID gives us a CGDirectDisplayID which presumeably
|
||||||
|
corresponds directly to a CGSDisplayID */
|
||||||
|
CGDirectDisplayID displayID = CGMainDisplayID();
|
||||||
|
|
||||||
|
CMError err = CMGetProfileByAVID(static_cast<CMDisplayIDType>(displayID), &cmProfile);
|
||||||
if (err != noErr)
|
if (err != noErr)
|
||||||
return nsnull;
|
return nsnull;
|
||||||
|
|
||||||
qcms_profile *profile = nsnull;
|
// get the size of location
|
||||||
switch (device.locType) {
|
err = NCMGetProfileLocation(cmProfile, NULL, &locationSize);
|
||||||
|
if (err != noErr)
|
||||||
|
return nsnull;
|
||||||
|
|
||||||
|
// allocate enough room for location
|
||||||
|
location = static_cast<CMProfileLocation*>(malloc(locationSize));
|
||||||
|
if (!location)
|
||||||
|
goto fail_close;
|
||||||
|
|
||||||
|
err = NCMGetProfileLocation(cmProfile, location, &locationSize);
|
||||||
|
if (err != noErr)
|
||||||
|
goto fail_location;
|
||||||
|
|
||||||
|
switch (location->locType) {
|
||||||
#ifndef __LP64__
|
#ifndef __LP64__
|
||||||
case cmFileBasedProfile: {
|
case cmFileBasedProfile: {
|
||||||
FSRef fsRef;
|
FSRef fsRef;
|
||||||
if (!FSpMakeFSRef(&device.u.fileLoc.spec, &fsRef)) {
|
if (!FSpMakeFSRef(&location->u.fileLoc.spec, &fsRef)) {
|
||||||
char path[512];
|
char path[512];
|
||||||
if (!FSRefMakePath(&fsRef, reinterpret_cast<UInt8*>(path), sizeof(path))) {
|
if (!FSRefMakePath(&fsRef, reinterpret_cast<UInt8*>(path), sizeof(path))) {
|
||||||
profile = qcms_profile_from_path(path);
|
profile = qcms_profile_from_path(path);
|
||||||
|
@ -429,7 +458,7 @@ gfxPlatformMac::GetPlatformCMSOutputProfile()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
case cmPathBasedProfile:
|
case cmPathBasedProfile:
|
||||||
profile = qcms_profile_from_path(device.u.pathLoc.path);
|
profile = qcms_profile_from_path(location->u.pathLoc.path);
|
||||||
#ifdef DEBUG_tor
|
#ifdef DEBUG_tor
|
||||||
if (profile)
|
if (profile)
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
|
@ -444,6 +473,10 @@ gfxPlatformMac::GetPlatformCMSOutputProfile()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fail_location:
|
||||||
|
free(location);
|
||||||
|
fail_close:
|
||||||
|
CMCloseProfile(cmProfile);
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче