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

Side by Side Diff: third_party/WebKit/Source/platform/image-decoders/ImageDecoder.h

Issue 1796293003: Image decode color: Push color profile from browser to renderer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove prototype Created 4 years, 9 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
3 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. 3 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 ImageDecoder(AlphaOption alphaOption, GammaAndColorProfileOption colorOption s, size_t maxDecodedBytes) 86 ImageDecoder(AlphaOption alphaOption, GammaAndColorProfileOption colorOption s, size_t maxDecodedBytes)
87 : m_premultiplyAlpha(alphaOption == AlphaPremultiplied) 87 : m_premultiplyAlpha(alphaOption == AlphaPremultiplied)
88 , m_ignoreGammaAndColorProfile(colorOptions == GammaAndColorProfileIgnor ed) 88 , m_ignoreGammaAndColorProfile(colorOptions == GammaAndColorProfileIgnor ed)
89 , m_maxDecodedBytes(maxDecodedBytes) 89 , m_maxDecodedBytes(maxDecodedBytes)
90 , m_sizeAvailable(false) 90 , m_sizeAvailable(false)
91 , m_isAllDataReceived(false) 91 , m_isAllDataReceived(false)
92 , m_failed(false) { } 92 , m_failed(false) { }
93 93
94 virtual ~ImageDecoder() { } 94 virtual ~ImageDecoder() { }
95 95
96 static void setOutputDeviceColorProfile(const ColorProfile&);
97
96 // Returns a caller-owned decoder of the appropriate type. Returns 0 if 98 // Returns a caller-owned decoder of the appropriate type. Returns 0 if
97 // we can't sniff a supported type from the provided data (possibly 99 // we can't sniff a supported type from the provided data (possibly
98 // because there isn't enough data yet). 100 // because there isn't enough data yet).
99 // Sets m_maxDecodedBytes to Platform::maxImageDecodedBytes(). 101 // Sets m_maxDecodedBytes to Platform::maxImageDecodedBytes().
100 static PassOwnPtr<ImageDecoder> create(const SharedBuffer& data, AlphaOption , GammaAndColorProfileOption); 102 static PassOwnPtr<ImageDecoder> create(const SharedBuffer& data, AlphaOption , GammaAndColorProfileOption);
101 103
102 virtual String filenameExtension() const = 0; 104 virtual String filenameExtension() const = 0;
103 105
104 bool isAllDataReceived() const { return m_isAllDataReceived; } 106 bool isAllDataReceived() const { return m_isAllDataReceived; }
105 107
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 { 223 {
222 ASSERT_UNUSED(profileLength, profileLength >= iccColorProfileHeaderLengt h); 224 ASSERT_UNUSED(profileLength, profileLength >= iccColorProfileHeaderLengt h);
223 225
224 return !memcmp(&profileData[12], "mntr", 4) || !memcmp(&profileData[12], "scnr", 4); 226 return !memcmp(&profileData[12], "mntr", 4) || !memcmp(&profileData[12], "scnr", 4);
225 } 227 }
226 228
227 class OutputDeviceProfile final { 229 class OutputDeviceProfile final {
228 USING_FAST_MALLOC(OutputDeviceProfile); 230 USING_FAST_MALLOC(OutputDeviceProfile);
229 WTF_MAKE_NONCOPYABLE(OutputDeviceProfile); 231 WTF_MAKE_NONCOPYABLE(OutputDeviceProfile);
230 public: 232 public:
231 OutputDeviceProfile() 233 OutputDeviceProfile(const ColorProfile* colorProfile)
232 : m_outputDeviceProfile(0) 234 : m_outputDeviceProfile(0)
233 { 235 {
234 ColorProfile profile = screenColorProfile(); 236 if (colorProfile && !colorProfile->isEmpty())
235 if (!profile.isEmpty()) 237 m_outputDeviceProfile = qcms_profile_from_memory(colorProfile->d ata(), colorProfile->size());
236 m_outputDeviceProfile = qcms_profile_from_memory(profile.data(), profile.size());
237 238
238 if (m_outputDeviceProfile && qcms_profile_is_bogus(m_outputDevicePro file)) { 239 if (m_outputDeviceProfile && qcms_profile_is_bogus(m_outputDevicePro file)) {
239 qcms_profile_release(m_outputDeviceProfile); 240 qcms_profile_release(m_outputDeviceProfile);
240 m_outputDeviceProfile = 0; 241 m_outputDeviceProfile = 0;
241 } 242 }
242 243
243 if (!m_outputDeviceProfile) 244 if (!m_outputDeviceProfile)
244 m_outputDeviceProfile = qcms_profile_sRGB(); 245 m_outputDeviceProfile = qcms_profile_sRGB();
245 if (m_outputDeviceProfile) 246 if (m_outputDeviceProfile)
246 qcms_profile_precache_output_transform(m_outputDeviceProfile); 247 qcms_profile_precache_output_transform(m_outputDeviceProfile);
247 } 248 }
248 249
249 qcms_profile* profile() const { return m_outputDeviceProfile; } 250 qcms_profile* profile() const { return m_outputDeviceProfile; }
250 251
251 private: 252 private:
252 static ColorProfile screenColorProfile()
253 {
254 // FIXME: Add optional ICCv4 support and support for multiple monito rs.
255 WebVector<char> profile;
256 Platform::current()->screenColorProfile(&profile);
257
258 ColorProfile colorProfile;
259 colorProfile.append(profile.data(), profile.size());
260 return colorProfile;
261 }
262
263 qcms_profile* m_outputDeviceProfile; 253 qcms_profile* m_outputDeviceProfile;
264 }; 254 };
265 255
266 static qcms_profile* qcmsOutputDeviceProfile() 256 static qcms_profile* qcmsOutputDeviceProfile(const ColorProfile* colorProfil e = 0)
dcheng 2016/03/15 17:28:08 = nullptr
ccameron 2016/03/15 18:22:05 Done.
267 { 257 {
268 DEFINE_THREAD_SAFE_STATIC_LOCAL(OutputDeviceProfile, outputDeviceProfile , new OutputDeviceProfile); 258 DEFINE_THREAD_SAFE_STATIC_LOCAL(OutputDeviceProfile, outputDeviceProfile , new OutputDeviceProfile(colorProfile));
269 259
270 return outputDeviceProfile.profile(); 260 return outputDeviceProfile.profile();
271 } 261 }
272 #endif 262 #endif
273 263
274 // Sets the "decode failure" flag. For caller convenience (since so 264 // Sets the "decode failure" flag. For caller convenience (since so
275 // many callers want to return false after calling this), returns false 265 // many callers want to return false after calling this), returns false
276 // to enable easy tailcalling. Subclasses may override this to also 266 // to enable easy tailcalling. Subclasses may override this to also
277 // clean up any local data. 267 // clean up any local data.
278 virtual bool setFailed() 268 virtual bool setFailed()
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 359
370 IntSize m_size; 360 IntSize m_size;
371 bool m_sizeAvailable; 361 bool m_sizeAvailable;
372 bool m_isAllDataReceived; 362 bool m_isAllDataReceived;
373 bool m_failed; 363 bool m_failed;
374 }; 364 };
375 365
376 } // namespace blink 366 } // namespace blink
377 367
378 #endif 368 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698