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

Unified Diff: third_party/WebKit/Source/platform/graphics/ImageSource.cpp

Issue 2530443004: Add target color profile to BitmapImage::draw (Closed)
Patch Set: Created 4 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/graphics/ImageSource.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/graphics/ImageSource.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/ImageSource.cpp b/third_party/WebKit/Source/platform/graphics/ImageSource.cpp
index 17ba96b7a0acc478ca833fec0d0e250c724290e9..1aa797fd9ca4d7163c10f0810d3d5498dd345672 100644
--- a/third_party/WebKit/Source/platform/graphics/ImageSource.cpp
+++ b/third_party/WebKit/Source/platform/graphics/ImageSource.cpp
@@ -51,6 +51,8 @@ bool ImageSource::setData(PassRefPtr<SharedBuffer> passData,
RefPtr<SharedBuffer> data = passData;
if (m_decoder) {
+ m_data = data;
+ m_allDataReceived = allDataReceived;
m_decoder->setData(data.release(), allDataReceived);
// If the decoder is pre-instantiated, it means we've already validated the
// data/signature at some point.
@@ -69,7 +71,14 @@ bool ImageSource::setData(PassRefPtr<SharedBuffer> passData,
}
// Insufficient data is not a failure.
- return m_decoder || !ImageDecoder::hasSufficientDataToSniffImageType(*data);
+ if (m_decoder || !ImageDecoder::hasSufficientDataToSniffImageType(*data)) {
+ m_data = data;
+ m_allDataReceived = allDataReceived;
+ return true;
+ }
+ m_data = nullptr;
+ m_allDataReceived = false;
+ return false;
}
String ImageSource::filenameExtension() const {
@@ -115,10 +124,22 @@ size_t ImageSource::frameCount() const {
return m_decoder ? m_decoder->frameCount() : 0;
}
-sk_sp<SkImage> ImageSource::createFrameAtIndex(size_t index) {
+sk_sp<SkImage> ImageSource::createFrameAtIndex(
+ size_t index,
+ sk_sp<SkColorSpace> targetColorSpace) {
+ DCHECK(targetColorSpace);
if (!m_decoder)
return nullptr;
+ if (!SkColorSpace::Equals(m_decoder->targetColorSpace().get(),
+ targetColorSpace.get())) {
+ std::unique_ptr<DeferredImageDecoder> newColorSpaceDecoder =
+ DeferredImageDecoder::create(
+ m_data, m_allDataReceived, ImageDecoder::AlphaPremultiplied,
+ ImageDecoder::ColorSpaceTransformed, targetColorSpace);
+ std::swap(m_decoder, newColorSpaceDecoder);
+ }
+
return m_decoder->createFrameAtIndex(index);
}
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/ImageSource.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698