diff --git a/gfx/thebes/public/gfxPlatform.h b/gfx/thebes/public/gfxPlatform.h index 82d3bebb366f..8ee8291ff4aa 100644 --- a/gfx/thebes/public/gfxPlatform.h +++ b/gfx/thebes/public/gfxPlatform.h @@ -151,6 +151,11 @@ public: */ static cmsHTRANSFORM GetCMSRGBTransform(); + /** + * Return output -> sRGB device transform. + */ + static cmsHTRANSFORM GetCMSInverseRGBTransform(); + /** * Return sRGBA -> output device transform. */ diff --git a/gfx/thebes/src/gfxPlatform.cpp b/gfx/thebes/src/gfxPlatform.cpp index 62ad1b1ab0a1..fdddc03a29d5 100644 --- a/gfx/thebes/src/gfxPlatform.cpp +++ b/gfx/thebes/src/gfxPlatform.cpp @@ -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() { diff --git a/widget/src/build/Makefile.in b/widget/src/build/Makefile.in index c356f59d73d9..ec940021967b 100644 --- a/widget/src/build/Makefile.in +++ b/widget/src/build/Makefile.in @@ -96,6 +96,7 @@ EXTRA_DSO_LDOPTS = \ $(EXTRA_DSO_LIBS) \ $(MOZ_COMPONENT_LIBS) \ $(MOZ_UNICHARUTIL_LIBS) \ + $(LCMS_LIBS) \ $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/widget/src/cocoa/Makefile.in b/widget/src/cocoa/Makefile.in index 0a49b39f2c1b..d05063cc7863 100644 --- a/widget/src/cocoa/Makefile.in +++ b/widget/src/cocoa/Makefile.in @@ -136,6 +136,7 @@ EXTRA_DSO_LDOPTS += \ $(MOZ_COMPONENT_LIBS) \ -lthebes \ $(MOZ_FIX_LINK_PATHS) \ + $(LCMS_LIBS) \ $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/widget/src/gtk2/Makefile.in b/widget/src/gtk2/Makefile.in index 88332aa9fbf3..09f89eb494b9 100644 --- a/widget/src/gtk2/Makefile.in +++ b/widget/src/gtk2/Makefile.in @@ -134,6 +134,7 @@ EXTRA_DSO_LDOPTS += \ $(XLIBS) \ $(MOZ_GTK2_LIBS) \ -lthebes \ + $(LCMS_LIBS) \ $(NULL) EXPORTS = \ diff --git a/widget/src/xpwidgets/Makefile.in b/widget/src/xpwidgets/Makefile.in index 73d644bc96a7..d10b630cd4a4 100644 --- a/widget/src/xpwidgets/Makefile.in +++ b/widget/src/xpwidgets/Makefile.in @@ -61,6 +61,7 @@ REQUIRES = xpcom \ unicharutil \ view \ windowwatcher \ + lcms \ $(NULL) ifeq ($(MOZ_ENABLE_CAIRO_GFX),1) diff --git a/widget/src/xpwidgets/nsXPLookAndFeel.cpp b/widget/src/xpwidgets/nsXPLookAndFeel.cpp index b196830d6485..4b2f07d19905 100644 --- a/widget/src/xpwidgets/nsXPLookAndFeel.cpp +++ b/widget/src/xpwidgets/nsXPLookAndFeel.cpp @@ -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; }