Bug 393109 - treat system colors as output device values. r+a=pavlov
--- a/gfx/thebes/public/gfxPlatform.h
+++ b/gfx/thebes/public/gfxPlatform.h
@@ -147,16 +147,21 @@ public:
static cmsHPROFILE GetCMSOutputProfile();
/**
* Return sRGB -> output device transform.
*/
static cmsHTRANSFORM GetCMSRGBTransform();
/**
+ * Return output -> sRGB device transform.
+ */
+ static cmsHTRANSFORM GetCMSInverseRGBTransform();
+
+ /**
* Return sRGBA -> output device transform.
*/
static cmsHTRANSFORM GetCMSRGBATransform();
protected:
gfxPlatform() { }
virtual ~gfxPlatform();
--- a/gfx/thebes/src/gfxPlatform.cpp
+++ b/gfx/thebes/src/gfxPlatform.cpp
@@ -67,16 +67,17 @@
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
gfxPlatform *gPlatform = nsnull;
int gGlitzState = -1;
static cmsHPROFILE gCMSOutputProfile = nsnull;
static cmsHTRANSFORM gCMSRGBTransform = nsnull;
+static cmsHTRANSFORM gCMSInverseRGBTransform = nsnull;
static cmsHTRANSFORM gCMSRGBATransform = nsnull;
gfxPlatform*
gfxPlatform::GetPlatform()
{
return gPlatform;
}
@@ -353,16 +354,35 @@ gfxPlatform::GetCMSRGBTransform()
outProfile, TYPE_RGB_8,
INTENT_PERCEPTUAL, 0);
}
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()
{
if (!gCMSRGBATransform) {
cmsHPROFILE inProfile, outProfile;
outProfile = GetCMSOutputProfile();
inProfile = cmsCreate_sRGBProfile();
if (!inProfile || !outProfile)
--- a/widget/src/build/Makefile.in
+++ b/widget/src/build/Makefile.in
@@ -91,16 +91,17 @@ SHARED_LIBRARY_LIBS = \
../xpwidgets/$(LIB_PREFIX)xpwidgets_s.$(LIB_SUFFIX) \
$(NULL)
EXTRA_DSO_LDOPTS = \
$(LIBS_DIR) \
$(EXTRA_DSO_LIBS) \
$(MOZ_COMPONENT_LIBS) \
$(MOZ_UNICHARUTIL_LIBS) \
+ $(LCMS_LIBS) \
$(NULL)
include $(topsrcdir)/config/rules.mk
DEFINES += -D_IMPL_NS_WIDGET -DMOZ_UNICODE
--- a/widget/src/cocoa/Makefile.in
+++ b/widget/src/cocoa/Makefile.in
@@ -131,16 +131,17 @@ SHARED_LIBRARY_LIBS = ../xpwidgets/libxp
EXTRA_DSO_LDOPTS += \
$(MOZ_UNICHARUTIL_LIBS) \
$(TK_LIBS) \
$(call EXPAND_LIBNAME_PATH,gkgfx,$(DEPTH)/gfx/src) \
$(MOZ_COMPONENT_LIBS) \
-lthebes \
$(MOZ_FIX_LINK_PATHS) \
+ $(LCMS_LIBS) \
$(NULL)
include $(topsrcdir)/config/rules.mk
NIB_FILES = \
classes.nib \
info.nib \
keyedobjects.nib \
--- a/widget/src/gtk2/Makefile.in
+++ b/widget/src/gtk2/Makefile.in
@@ -129,16 +129,17 @@ EXTRA_DSO_LDOPTS += \
$(MOZ_COMPONENT_LIBS) \
-lgkgfx \
-lgtkxtbin \
$(MOZ_STARTUP_NOTIFICATION_LIBS) \
$(XLDFLAGS) \
$(XLIBS) \
$(MOZ_GTK2_LIBS) \
-lthebes \
+ $(LCMS_LIBS) \
$(NULL)
EXPORTS = \
nsGTKToolkit.h \
nsIImageToPixbuf.h \
mozdrawingarea.h \
mozcontainer.h \
$(NULL)
--- a/widget/src/xpwidgets/Makefile.in
+++ b/widget/src/xpwidgets/Makefile.in
@@ -56,16 +56,17 @@ REQUIRES = xpcom \
pref \
locale \
necko \
htmlparser \
uconv \
unicharutil \
view \
windowwatcher \
+ lcms \
$(NULL)
ifeq ($(MOZ_ENABLE_CAIRO_GFX),1)
REQUIRES += thebes cairo
endif
DEFINES += -D_IMPL_NS_WIDGET -DUSE_TLS_FOR_TOOLKIT
--- a/widget/src/xpwidgets/nsXPLookAndFeel.cpp
+++ b/widget/src/xpwidgets/nsXPLookAndFeel.cpp
@@ -41,16 +41,19 @@
#include "nsIServiceManager.h"
#include "nsIPrefBranch2.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsIObserver.h"
#include "nsCRT.h"
#include "nsFont.h"
+#include "gfxPlatform.h"
+#include "lcms.h"
+
#ifdef DEBUG
#include "nsSize.h"
#endif
NS_IMPL_ISUPPORTS2(nsXPLookAndFeel, nsILookAndFeel, nsIObserver)
nsLookAndFeelIntPref nsXPLookAndFeel::sIntPrefs[] =
{
@@ -537,16 +540,28 @@ nsXPLookAndFeel::GetColor(const nsColorI
if (aID == eColor_TextSelectBackgroundAttention) {
// This makes the selection stand out when typeaheadfind is on
// Used with nsISelectionController::SELECTION_ATTENTION
aColor = NS_RGB(0x38, 0xd8, 0x78);
return NS_OK;
}
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;
}
return NS_ERROR_NOT_AVAILABLE;
}
NS_IMETHODIMP