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

Unified Diff: third_party/WebKit/Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp

Issue 1331533002: [poc] curve-filter Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix CanvasRenderingContext2D::createPattern crash for #40 Created 4 years, 11 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: third_party/WebKit/Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
diff --git a/third_party/WebKit/Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp b/third_party/WebKit/Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
index 5e3fd56c252b085e04744899b3ad87ddf6de2812..89c60c5fb57b4fb8d110f5701de4f2aae538d7f0 100644
--- a/third_party/WebKit/Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
+++ b/third_party/WebKit/Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
@@ -38,6 +38,7 @@
#include "platform/image-decoders/jpeg/JPEGImageDecoder.h"
#include "platform/PlatformInstrumentation.h"
+#include "platform/graphics/GraphicsScreen.h"
extern "C" {
#include <stdio.h> // jpeglib.h needs stdio FILE.
@@ -479,8 +480,22 @@ public:
if (!m_decoder->ignoresGammaAndColorProfile()) {
ColorProfile colorProfile;
readColorProfile(info(), colorProfile);
- createColorTransform(colorProfile, colorSpaceHasAlpha(m_info.out_color_space));
- if (m_transform) {
+ bool imageHasAlpha = colorSpaceHasAlpha(m_info.out_color_space);
+ RefPtr<ColorSpaceProfile> imageColorProfile = createColorTransform(colorProfile, imageHasAlpha);
+ m_decoder->setHasColorProfile(!!imageColorProfile.get());
+
+ if (m_decoder->hasColorProfile() && imageColorProfilesEnabled()) {
+ // FIXME: allow YUV decoding of color profiled images.
+ overrideColorSpace = JCS_UNKNOWN;
+ RELEASE_ASSERT(imageColorProfile->profile());
+ m_decoder->setColorProfile(imageColorProfile);
+ // Do not color correct decoded frames during decoding.
+ clearColorTransform();
+ RELEASE_ASSERT(!m_transform);
+ }
+
+ if (m_decoder->hasColorProfile() && !imageColorProfilesEnabled()) {
+ // FIXME: allow YUV decoding of color profiled images.
overrideColorSpace = JCS_UNKNOWN;
#if defined(TURBO_JPEG_RGB_SWIZZLE)
// Input RGBA data to qcms. Note: restored to BGRA on output.
@@ -488,7 +503,6 @@ public:
m_info.out_color_space = JCS_EXT_RGBA;
#endif
}
- m_decoder->setHasColorProfile(!!m_transform);
}
#endif
if (overrideColorSpace == JCS_YCbCr) {
@@ -637,32 +651,41 @@ public:
m_transform = 0;
}
- void createColorTransform(const ColorProfile& colorProfile, bool hasAlpha)
+ PassRefPtr<ColorSpaceProfile> createColorTransform(const ColorProfile& colorProfile, bool hasAlpha)
{
clearColorTransform();
if (colorProfile.isEmpty())
- return;
+ return nullptr;
+
qcms_profile* deviceProfile = ImageDecoder::qcmsOutputDeviceProfile();
if (!deviceProfile)
- return;
+ return nullptr;
+
qcms_profile* inputProfile = qcms_profile_from_memory(colorProfile.data(), colorProfile.size());
if (!inputProfile)
- return;
+ return nullptr;
+
+ if (imageColorProfilesEnabled())
+ return ColorSpaceProfile::create(inputProfile);
// We currently only support color profiles for RGB profiled images.
ASSERT(rgbData == qcms_profile_get_color_space(inputProfile));
if (qcms_profile_match(inputProfile, deviceProfile)) {
qcms_profile_release(inputProfile);
- return;
+ return nullptr;
}
// FIXME: Don't force perceptual intent if the image profile contains an intent.
qcms_data_type dataFormat = hasAlpha ? QCMS_DATA_RGBA_8 : QCMS_DATA_RGB_8;
m_transform = qcms_transform_create(inputProfile, dataFormat, deviceProfile, dataFormat, QCMS_INTENT_PERCEPTUAL);
+ if (m_transform)
+ return ColorSpaceProfile::create(inputProfile);
+
qcms_profile_release(inputProfile);
+ return nullptr;
}
#endif

Powered by Google App Engine
This is Rietveld 408576698