Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1689)

Unified Diff: Source/platform/image-decoders/webp/WEBPImageDecoder.cpp

Issue 352873002: [wip] image color correction (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/platform/image-decoders/webp/WEBPImageDecoder.cpp
diff --git a/Source/platform/image-decoders/webp/WEBPImageDecoder.cpp b/Source/platform/image-decoders/webp/WEBPImageDecoder.cpp
index 0959244acb11eb169b4d405d90e8598ac20b1c46..4f88c37b0b2dbb005cb0e9b60c81be9f62830000 100644
--- a/Source/platform/image-decoders/webp/WEBPImageDecoder.cpp
+++ b/Source/platform/image-decoders/webp/WEBPImageDecoder.cpp
@@ -155,9 +155,7 @@ WEBPImageDecoder::~WEBPImageDecoder()
void WEBPImageDecoder::clear()
{
#if USE(QCMSLIB)
- if (m_transform)
- qcms_transform_release(m_transform);
- m_transform = 0;
+ clearColorTransform();
#endif
WebPDemuxDelete(m_demux);
m_demux = 0;
@@ -408,29 +406,42 @@ void WEBPImageDecoder::clearFrameBuffer(size_t frameIndex)
ImageDecoder::clearFrameBuffer(frameIndex);
}
+PassRefPtr<ColorSpaceProfile> WEBPImageDecoder::colorProfile() const
+{
+#if USE(QCMSLIB)
+ return m_colorProfile;
+#else
+ return nullptr;
+#endif
+}
+
#if USE(QCMSLIB)
-void WEBPImageDecoder::createColorTransform(const char* data, size_t size)
+void WEBPImageDecoder::clearColorTransform()
{
if (m_transform)
qcms_transform_release(m_transform);
m_transform = 0;
+}
+bool WEBPImageDecoder::createColorTransform(const char* data, size_t size)
+{
+ clearColorTransform();
+ ASSERT(size >= ImageDecoder::iccColorProfileHeaderLength);
qcms_profile* deviceProfile = ImageDecoder::qcmsOutputDeviceProfile();
if (!deviceProfile)
- return;
+ return false;
qcms_profile* inputProfile = qcms_profile_from_memory(data, size);
if (!inputProfile)
- return;
-
+ return false;
// We currently only support color profiles for RGB profiled images.
ASSERT(icSigRgbData == qcms_profile_get_color_space(inputProfile));
// The input image pixels are RGBA format.
qcms_data_type format = QCMS_DATA_RGBA_8;
// FIXME: Don't force perceptual intent if the image profile contains an intent.
m_transform = qcms_transform_create(inputProfile, format, deviceProfile, QCMS_DATA_RGBA_8, QCMS_INTENT_PERCEPTUAL);
-
qcms_profile_release(inputProfile);
+ return true;
}
void WEBPImageDecoder::readColorProfile()
@@ -453,8 +464,16 @@ void WEBPImageDecoder::readColorProfile()
else if (!ImageDecoder::inputDeviceColorProfile(profileData, profileSize))
ignoreProfile = true;
- if (!ignoreProfile)
- createColorTransform(profileData, profileSize);
+ if (!ignoreProfile && createColorTransform(profileData, profileSize)) {
+ // FIXME: paint-time color correction is assumed here.
+ qcms_profile* profile = qcms_profile_from_memory(profileData, profileSize);
+ RefPtr<ColorSpaceProfile> imageColorProfile = ColorSpaceProfile::create(profile);
+ m_hasColorProfile = !!imageColorProfile->profile();
+ m_colorProfile = m_hasColorProfile ? imageColorProfile : nullptr;
+ // Don't color correct decoded frames during decoding.
+ clearColorTransform();
+ ASSERT(!m_transform);
+ }
WebPDemuxReleaseChunkIterator(&chunkIterator);
}

Powered by Google App Engine
This is Rietveld 408576698