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

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

Issue 1309393007: [poc] redecode Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: resetColorProfileForTesting rename 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
« no previous file with comments | « third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.cpp
diff --git a/third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.cpp b/third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.cpp
index 8653487de0e030332a57d5a41027af96b177d262..00dcd6f2e8022b38be5b2cf89e34a1433a85dd9a 100644
--- a/third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.cpp
+++ b/third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.cpp
@@ -29,6 +29,8 @@
#include "config.h"
#include "platform/image-decoders/webp/WEBPImageDecoder.h"
+#include "platform/graphics/GraphicsScreen.h"
+
#if USE(QCMSLIB)
#include "qcms.h"
#endif
@@ -137,6 +139,8 @@ WEBPImageDecoder::WEBPImageDecoder(AlphaOption alphaOption, GammaAndColorProfile
, m_repetitionCount(cAnimationLoopOnce)
, m_decodedHeight(0)
{
+ fprintf(stderr, "WEBP decoder %p created %s\n", this, !isMainThread() ? "impl-side-thread" : "");
+
m_blendFunction = (alphaOption == AlphaPremultiplied) ? alphaBlendPremultiplied : alphaBlendNonPremultiplied;
}
@@ -238,6 +242,8 @@ bool WEBPImageDecoder::updateDemuxer()
m_formatFlags &= ~ICCP_FLAG;
}
+ fprintf(stderr, "WEBP decoder %p headerAvailable %dx%d %s\n", this, size().width(), size().height(), "size-only-decode");
+
#if USE(QCMSLIB)
if ((m_formatFlags & ICCP_FLAG) && !ignoresGammaAndColorProfile())
readColorProfile();
@@ -316,16 +322,36 @@ void WEBPImageDecoder::clearColorTransform()
m_transform = 0;
}
-bool WEBPImageDecoder::createColorTransform(const char* data, size_t size)
+PassRefPtr<ColorSpaceProfile> WEBPImageDecoder::createColorTransform(const char* data, size_t size)
{
clearColorTransform();
+ fprintf(stderr, "WEBP decoder %p createColorTransform ", this);
+
+ if (m_deviceProfile)
+ fprintf(stderr, ": device %p\n", m_deviceProfile.get());
+ else
+ fprintf(stderr, ": %p\n", nullptr);
+ fprintf(stderr, "image color profiles enabled: %d\n", imageColorProfilesEnabled());
+ fflush(stderr);
+
qcms_profile* deviceProfile = ImageDecoder::qcmsOutputDeviceProfile();
+ if (m_deviceProfile)
+ deviceProfile = m_deviceProfile->profile();
if (!deviceProfile)
- return false;
+ return nullptr;
+
qcms_profile* inputProfile = qcms_profile_from_memory(data, size);
if (!inputProfile)
- return false;
+ return nullptr;
+
+ fprintf(stderr, " from source profile [%s]", qcms_profile_get_description(inputProfile));
+ fprintf(stderr, " to [%s]\n", qcms_profile_get_description(deviceProfile));
+ fflush(stderr);
+
+ // There is no need to create a color transform if the color profiles match.
+ if (imageColorProfilesEnabled() && qcms_profile_match(inputProfile, deviceProfile))
+ return ColorSpaceProfile::create(inputProfile);
// We currently only support color profiles for RGB profiled images.
ASSERT(rgbData == qcms_profile_get_color_space(inputProfile));
@@ -333,15 +359,18 @@ bool WEBPImageDecoder::createColorTransform(const char* data, size_t size)
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);
+ if (m_transform)
+ return ColorSpaceProfile::create(inputProfile);
qcms_profile_release(inputProfile);
- return !!m_transform;
+ return nullptr;
}
void WEBPImageDecoder::readColorProfile()
{
WebPChunkIterator chunkIterator;
if (!WebPDemuxGetChunk(m_demux, "ICCP", 1, &chunkIterator)) {
+ RELEASE_ASSERT(!m_hasColorProfile && !m_transform);
WebPDemuxReleaseChunkIterator(&chunkIterator);
return;
}
@@ -358,8 +387,18 @@ void WEBPImageDecoder::readColorProfile()
else if (!ImageDecoder::inputDeviceColorProfile(profileData, profileSize))
ignoreProfile = true;
- if (!ignoreProfile)
- m_hasColorProfile = createColorTransform(profileData, profileSize);
+ if (ignoreProfile) {
+ RELEASE_ASSERT(!m_hasColorProfile && !m_transform);
+ WebPDemuxReleaseChunkIterator(&chunkIterator);
+ return;
+ }
+
+ RefPtr<ColorSpaceProfile> imageColorProfile = createColorTransform(profileData, profileSize);
+ m_hasColorProfile = !!imageColorProfile.get();
+ if (m_hasColorProfile && imageColorProfilesEnabled()) {
+ RELEASE_ASSERT(imageColorProfile->profile());
+ m_colorProfile = imageColorProfile;
+ }
WebPDemuxReleaseChunkIterator(&chunkIterator);
}
@@ -382,8 +421,13 @@ void WEBPImageDecoder::applyPostProcessing(size_t frameIndex)
const int left = frameRect.x();
const int top = frameRect.y();
+ if (m_decodedHeight < decodedHeight)
+ fprintf(stderr, "WEBP decoder %p %dx%d decode row %d\n", this, size().width(), size().height(), decodedHeight);
+
#if USE(QCMSLIB)
if (qcms_transform* transform = colorTransform()) {
+ if (m_decodedHeight < decodedHeight)
+ fprintf(stderr, "WEBP decoder %p %dx%d color transform row %d\n", this, size().width(), size().height(), decodedHeight);
for (int y = m_decodedHeight; y < decodedHeight; ++y) {
const int canvasY = top + y;
uint8_t* row = reinterpret_cast<uint8_t*>(buffer.getAddr(left, canvasY));
@@ -544,10 +588,12 @@ bool WEBPImageDecoder::decodeSingleFrame(const uint8_t* dataBytes, size_t dataSi
buffer.setHasAlpha((m_formatFlags & ALPHA_FLAG) || m_frameBackgroundHasAlpha);
buffer.setStatus(ImageFrame::FrameComplete);
clearDecoder();
+ fflush(stderr);
return true;
case VP8_STATUS_SUSPENDED:
if (!isAllDataReceived() && !frameIsCompleteAtIndex(frameIndex)) {
applyPostProcessing(frameIndex);
+ fflush(stderr);
return false;
}
// FALLTHROUGH
« no previous file with comments | « third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698