Add monitor profile support for Win
https://bugs.webkit.org/show_bug.cgi?id=88565
Patch by Tony Payne <tpayne@chromium.org> on 2012-06-19
Reviewed by Eric Seidel.
Source/Platform:
* chromium/public/Platform.h:
(Platform):
(WebKit::Platform::screenColorProfile):
Source/WebCore:
Tests: fast/images/jpeg-with-color-profile.html
fast/images/png-with-color-profile.html. Also covered by numerous
layout tests.
* WebCore.gyp/WebCore.gyp:
* platform/PlatformScreen.h:
(WebCore):
* platform/blackberry/PlatformScreenBlackBerry.cpp:
(WebCore::screenColorProfile):
(WebCore):
* platform/chromium/PlatformScreenChromium.cpp:
(WebCore::screenColorProfile):
(WebCore):
* platform/efl/PlatformScreenEfl.cpp:
(WebCore::screenColorProfile):
(WebCore):
* platform/gtk/PlatformScreenGtk.cpp:
(WebCore::screenColorProfile):
(WebCore):
* platform/image-decoders/ImageDecoder.h:
(ImageFrame):
(ImageDecoder):
(WebCore::ImageDecoder::qcmsOutputDeviceProfile):
* platform/image-decoders/jpeg/JPEGImageDecoder.cpp:
(turboSwizzled):
(colorSpaceHasAlpha):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@120789 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/Platform/ChangeLog b/Source/Platform/ChangeLog
index e7ce9f5..4bc74cb 100644
--- a/Source/Platform/ChangeLog
+++ b/Source/Platform/ChangeLog
@@ -1,3 +1,14 @@
+2012-06-19 Tony Payne <tpayne@chromium.org>
+
+ Add monitor profile support for Win
+ https://bugs.webkit.org/show_bug.cgi?id=88565
+
+ Reviewed by Eric Seidel.
+
+ * chromium/public/Platform.h:
+ (Platform):
+ (WebKit::Platform::screenColorProfile):
+
2012-06-14 James Robinson <jamesr@chromium.org>
[chromium] Use WebImageLayer in GraphicsLayerChromium for image layers
diff --git a/Source/Platform/chromium/public/Platform.h b/Source/Platform/chromium/public/Platform.h
index 3e94822..4424df5 100644
--- a/Source/Platform/chromium/public/Platform.h
+++ b/Source/Platform/chromium/public/Platform.h
@@ -38,6 +38,7 @@
#include "WebGraphicsContext3D.h"
#include "WebLocalizedString.h"
#include "WebString.h"
+#include "WebVector.h"
namespace WebKit {
@@ -239,6 +240,12 @@
virtual bool sandboxEnabled() { return false; }
+ // Screen -------------------------------------------------------------
+
+ // Supplies the system monitor color profile ("monitor") or a named ICC profile.
+ virtual void screenColorProfile(const WebString& type, WebVector<char>* profile) { }
+
+
// Sudden Termination --------------------------------------------------
// Disable/Enable sudden termination.
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 6c5edfc..0bd4432 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,37 @@
+2012-06-19 Tony Payne <tpayne@chromium.org>
+
+ Add monitor profile support for Win
+ https://bugs.webkit.org/show_bug.cgi?id=88565
+
+ Reviewed by Eric Seidel.
+
+ Tests: fast/images/jpeg-with-color-profile.html
+ fast/images/png-with-color-profile.html. Also covered by numerous
+ layout tests.
+
+ * WebCore.gyp/WebCore.gyp:
+ * platform/PlatformScreen.h:
+ (WebCore):
+ * platform/blackberry/PlatformScreenBlackBerry.cpp:
+ (WebCore::screenColorProfile):
+ (WebCore):
+ * platform/chromium/PlatformScreenChromium.cpp:
+ (WebCore::screenColorProfile):
+ (WebCore):
+ * platform/efl/PlatformScreenEfl.cpp:
+ (WebCore::screenColorProfile):
+ (WebCore):
+ * platform/gtk/PlatformScreenGtk.cpp:
+ (WebCore::screenColorProfile):
+ (WebCore):
+ * platform/image-decoders/ImageDecoder.h:
+ (ImageFrame):
+ (ImageDecoder):
+ (WebCore::ImageDecoder::qcmsOutputDeviceProfile):
+ * platform/image-decoders/jpeg/JPEGImageDecoder.cpp:
+ (turboSwizzled):
+ (colorSpaceHasAlpha):
+
2012-06-19 Erik Arvidsson <arv@chromium.org>
[V8] Fix issue where a callback got a null calling context
diff --git a/Source/WebCore/platform/PlatformScreen.h b/Source/WebCore/platform/PlatformScreen.h
index 969193f..e723308 100644
--- a/Source/WebCore/platform/PlatformScreen.h
+++ b/Source/WebCore/platform/PlatformScreen.h
@@ -37,6 +37,8 @@
typedef uint32_t PlatformDisplayID;
+typedef WTF::Vector<char> ColorProfile;
+
namespace WebCore {
class FloatRect;
@@ -50,6 +52,8 @@
FloatRect screenRect(Widget*);
FloatRect screenAvailableRect(Widget*);
+ // type can be "monitor" or the name of a profile such as "sRGB" or "Adobe RGB".
+ void screenColorProfile(Widget*, const String& type, ColorProfile&);
#if PLATFORM(MAC)
NSScreen *screenForWindow(NSWindow *);
diff --git a/Source/WebCore/platform/blackberry/PlatformScreenBlackBerry.cpp b/Source/WebCore/platform/blackberry/PlatformScreenBlackBerry.cpp
index 2ea9387..00244ac 100644
--- a/Source/WebCore/platform/blackberry/PlatformScreenBlackBerry.cpp
+++ b/Source/WebCore/platform/blackberry/PlatformScreenBlackBerry.cpp
@@ -64,4 +64,9 @@
return FloatRect(FloatPoint(), FloatSize(IntSize(BlackBerry::Platform::Graphics::Screen::primaryScreen()->size())));
}
+void screenColorProfile(Widget*, const String&, ColorProfile&)
+{
+ notImplemented();
+}
+
} // namespace WebCore
diff --git a/Source/WebCore/platform/chromium/PlatformScreenChromium.cpp b/Source/WebCore/platform/chromium/PlatformScreenChromium.cpp
index 79b9dcd..a85c089 100644
--- a/Source/WebCore/platform/chromium/PlatformScreenChromium.cpp
+++ b/Source/WebCore/platform/chromium/PlatformScreenChromium.cpp
@@ -34,6 +34,8 @@
#include "IntRect.h"
#include "PlatformSupport.h"
+#include <public/Platform.h>
+
namespace WebCore {
int screenHorizontalDPI(Widget* widget)
@@ -71,4 +73,12 @@
return PlatformSupport::screenAvailableRect(widget);
}
+void screenColorProfile(Widget*, const String& type, ColorProfile& toProfile)
+{
+ // FIXME: Add support for multiple monitors.
+ WebKit::WebVector<char> profile;
+ WebKit::Platform::current()->screenColorProfile(WebKit::WebString(type), &profile);
+ toProfile.append(profile.data(), profile.size());
+}
+
} // namespace WebCore
diff --git a/Source/WebCore/platform/efl/PlatformScreenEfl.cpp b/Source/WebCore/platform/efl/PlatformScreenEfl.cpp
index fac9597..ca655fb 100644
--- a/Source/WebCore/platform/efl/PlatformScreenEfl.cpp
+++ b/Source/WebCore/platform/efl/PlatformScreenEfl.cpp
@@ -92,4 +92,9 @@
return screenRect(widget);
}
+void screenColorProfile(Widget*, const String&, ColorProfile&)
+{
+ notImplemented();
+}
+
}
diff --git a/Source/WebCore/platform/gtk/PlatformScreenGtk.cpp b/Source/WebCore/platform/gtk/PlatformScreenGtk.cpp
index 0a3b486..4b6c1c1 100644
--- a/Source/WebCore/platform/gtk/PlatformScreenGtk.cpp
+++ b/Source/WebCore/platform/gtk/PlatformScreenGtk.cpp
@@ -137,4 +137,9 @@
}
+void screenColorProfile(Widget*, const String&, ColorProfile&)
+{
+ notImplemented();
+}
+
} // namespace WebCore
diff --git a/Source/WebCore/platform/image-decoders/ImageDecoder.h b/Source/WebCore/platform/image-decoders/ImageDecoder.h
index 98a3f5a..e92ba7d 100644
--- a/Source/WebCore/platform/image-decoders/ImageDecoder.h
+++ b/Source/WebCore/platform/image-decoders/ImageDecoder.h
@@ -31,6 +31,7 @@
#include "IntRect.h"
#include "ImageSource.h"
+#include "PlatformScreen.h"
#include "PlatformString.h"
#include "SharedBuffer.h"
#include <wtf/Assertions.h>
@@ -44,7 +45,6 @@
#if USE(QCMSLIB)
#include "qcms.h"
-#include <wtf/MainThread.h>
#if OS(DARWIN)
#include "GraphicsContextCG.h"
#include <ApplicationServices/ApplicationServices.h>
@@ -54,8 +54,6 @@
namespace WebCore {
- typedef Vector<char> ColorProfile;
-
// ImageFrame represents the decoded image data. This buffer is what all
// decoders write a single frame into.
class ImageFrame {
@@ -313,18 +311,20 @@
size_t length = CFDataGetLength(iccProfile);
const unsigned char* systemProfile = CFDataGetBytePtr(iccProfile);
outputDeviceProfile = qcms_profile_from_memory(systemProfile, length);
- if (outputDeviceProfile && qcms_profile_is_bogus(outputDeviceProfile)) {
- qcms_profile_release(outputDeviceProfile);
- outputDeviceProfile = 0;
- }
+ }
+#else
+ // FIXME: add support for multiple monitors.
+ ColorProfile profile;
+ screenColorProfile(0, "monitor", profile);
+ if (!profile.isEmpty())
+ outputDeviceProfile = qcms_profile_from_memory(profile.data(), profile.size());
+#endif
+ if (outputDeviceProfile && qcms_profile_is_bogus(outputDeviceProfile)) {
+ qcms_profile_release(outputDeviceProfile);
+ outputDeviceProfile = 0;
}
if (!outputDeviceProfile)
outputDeviceProfile = qcms_profile_sRGB();
-#else
- // FIXME: sRGB profiles don't add much value. Use the user's monitor profile.
- outputDeviceProfile = qcms_profile_sRGB();
-#endif
- // FIXME: Check that the profile is valid. Fallback to sRGB if not?
if (outputDeviceProfile)
qcms_profile_precache_output_transform(outputDeviceProfile);
}
diff --git a/Source/WebCore/platform/mac/PlatformScreenMac.mm b/Source/WebCore/platform/mac/PlatformScreenMac.mm
index 71e3cb1..273ff78 100644
--- a/Source/WebCore/platform/mac/PlatformScreenMac.mm
+++ b/Source/WebCore/platform/mac/PlatformScreenMac.mm
@@ -76,6 +76,11 @@
return toUserSpace([screenForWindow(window) visibleFrame], window);
}
+void screenColorProfile(Widget*, const String&, ColorProfile&)
+{
+ notImplemented();
+}
+
NSScreen *screenForWindow(NSWindow *window)
{
NSScreen *screen = [window screen]; // nil if the window is off-screen
diff --git a/Source/WebCore/platform/qt/PlatformScreenQt.cpp b/Source/WebCore/platform/qt/PlatformScreenQt.cpp
index 8bfbf26..5641764 100644
--- a/Source/WebCore/platform/qt/PlatformScreenQt.cpp
+++ b/Source/WebCore/platform/qt/PlatformScreenQt.cpp
@@ -143,4 +143,9 @@
return FloatRect(r.x(), r.y(), r.width(), r.height());
}
+void screenColorProfile(Widget*, const String&, ColorProfile&)
+{
+ notImplemented();
+}
+
} // namespace WebCore
diff --git a/Source/WebCore/platform/win/PlatformScreenWin.cpp b/Source/WebCore/platform/win/PlatformScreenWin.cpp
index caadde9..e1bbf59 100644
--- a/Source/WebCore/platform/win/PlatformScreenWin.cpp
+++ b/Source/WebCore/platform/win/PlatformScreenWin.cpp
@@ -118,4 +118,9 @@
return monitorInfo.rcWork;
}
+void screenColorProfile(Widget*, const String&, ColorProfile&)
+{
+ notImplemented();
+}
+
} // namespace WebCore