Bug 393109 - treat system colors as output device values. r+a=pavlov

This commit is contained in:
tor@cs.brown.edu 2007-08-30 09:21:16 -07:00
Родитель 66873823bd
Коммит 20b9d6b91f
7 изменённых файлов: 44 добавлений и 0 удалений

Просмотреть файл

@ -151,6 +151,11 @@ public:
*/
static cmsHTRANSFORM GetCMSRGBTransform();
/**
* Return output -> sRGB device transform.
*/
static cmsHTRANSFORM GetCMSInverseRGBTransform();
/**
* Return sRGBA -> output device transform.
*/

Просмотреть файл

@ -72,6 +72,7 @@ gfxPlatform *gPlatform = nsnull;
int gGlitzState = -1;
static cmsHPROFILE gCMSOutputProfile = nsnull;
static cmsHTRANSFORM gCMSRGBTransform = nsnull;
static cmsHTRANSFORM gCMSInverseRGBTransform = nsnull;
static cmsHTRANSFORM gCMSRGBATransform = nsnull;
gfxPlatform*
@ -357,6 +358,25 @@ gfxPlatform::GetCMSRGBTransform()
return gCMSRGBTransform;
}
cmsHTRANSFORM
gfxPlatform::GetCMSInverseRGBTransform()
{
if (!gCMSInverseRGBTransform) {
cmsHPROFILE inProfile, outProfile;
inProfile = GetCMSOutputProfile();
outProfile = cmsCreate_sRGBProfile();
if (!inProfile || !outProfile)
return nsnull;
gCMSInverseRGBTransform = cmsCreateTransform(inProfile, TYPE_RGB_8,
outProfile, TYPE_RGB_8,
INTENT_PERCEPTUAL, 0);
}
return gCMSInverseRGBTransform;
}
cmsHTRANSFORM
gfxPlatform::GetCMSRGBATransform()
{

Просмотреть файл

@ -96,6 +96,7 @@ EXTRA_DSO_LDOPTS = \
$(EXTRA_DSO_LIBS) \
$(MOZ_COMPONENT_LIBS) \
$(MOZ_UNICHARUTIL_LIBS) \
$(LCMS_LIBS) \
$(NULL)
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -136,6 +136,7 @@ EXTRA_DSO_LDOPTS += \
$(MOZ_COMPONENT_LIBS) \
-lthebes \
$(MOZ_FIX_LINK_PATHS) \
$(LCMS_LIBS) \
$(NULL)
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -134,6 +134,7 @@ EXTRA_DSO_LDOPTS += \
$(XLIBS) \
$(MOZ_GTK2_LIBS) \
-lthebes \
$(LCMS_LIBS) \
$(NULL)
EXPORTS = \

Просмотреть файл

@ -61,6 +61,7 @@ REQUIRES = xpcom \
unicharutil \
view \
windowwatcher \
lcms \
$(NULL)
ifeq ($(MOZ_ENABLE_CAIRO_GFX),1)

Просмотреть файл

@ -46,6 +46,9 @@
#include "nsCRT.h"
#include "nsFont.h"
#include "gfxPlatform.h"
#include "lcms.h"
#ifdef DEBUG
#include "nsSize.h"
#endif
@ -542,6 +545,18 @@ nsXPLookAndFeel::GetColor(const nsColorID aID, nscolor &aColor)
}
if (NS_SUCCEEDED(NativeGetColor(aID, aColor))) {
if (gfxPlatform::IsCMSEnabled()) {
cmsHTRANSFORM transform = gfxPlatform::GetCMSInverseRGBTransform();
if (transform) {
PRUint8 color[3];
color[0] = NS_GET_R(aColor);
color[1] = NS_GET_G(aColor);
color[2] = NS_GET_B(aColor);
cmsDoTransform(transform, color, color, 1);
aColor = NS_RGB(color[0], color[1], color[2]);
}
}
CACHE_COLOR(aID, aColor);
return NS_OK;
}