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

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: Draw layered images with a recording GraphicContext Created 5 years, 1 month 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 01b8f3f880c53b73c69c7ec9112396a946a50381..50aa9ee21a8046b5a6b16128315578f5da815969 100644
--- a/third_party/WebKit/Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
+++ b/third_party/WebKit/Source/platform/image-decoders/jpeg/JPEGImageDecoder.cpp
@@ -39,6 +39,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.
@@ -477,8 +478,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.
@@ -486,7 +501,6 @@ public:
m_info.out_color_space = JCS_EXT_RGBA;
#endif
}
- m_decoder->setHasColorProfile(!!m_transform);
}
#endif
if (overrideColorSpace == JCS_YCbCr) {
@@ -635,24 +649,31 @@ 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;
+
// We currently only support color profiles for RGB profiled images.
ASSERT(rgbData == qcms_profile_get_color_space(inputProfile));
qcms_data_type dataFormat = hasAlpha ? QCMS_DATA_RGBA_8 : QCMS_DATA_RGB_8;
// FIXME: Don't force perceptual intent if the image profile contains an intent.
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