| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 ASSERT((i >= 0) && i < 3); | 262 ASSERT((i >= 0) && i < 3); |
| 263 return m_planes[i]; | 263 return m_planes[i]; |
| 264 } | 264 } |
| 265 | 265 |
| 266 size_t ImagePlanes::rowBytes(int i) const | 266 size_t ImagePlanes::rowBytes(int i) const |
| 267 { | 267 { |
| 268 ASSERT((i >= 0) && i < 3); | 268 ASSERT((i >= 0) && i < 3); |
| 269 return m_rowBytes[i]; | 269 return m_rowBytes[i]; |
| 270 } | 270 } |
| 271 | 271 |
| 272 bool ImageDecoder::hasColorProfile() const | |
| 273 { | |
| 274 #if USE(QCMSLIB) | |
| 275 return m_sourceToOutputDeviceColorTransform.get(); | |
| 276 #else | |
| 277 return false; | |
| 278 #endif | |
| 279 } | |
| 280 | |
| 281 #if USE(QCMSLIB) | 272 #if USE(QCMSLIB) |
| 282 namespace { | 273 namespace { |
| 283 | 274 |
| 284 const unsigned kIccColorProfileHeaderLength = 128; | 275 const unsigned kIccColorProfileHeaderLength = 128; |
| 285 | 276 |
| 286 bool rgbColorProfile(const char* profileData, unsigned profileLength) | 277 bool rgbColorProfile(const char* profileData, unsigned profileLength) |
| 287 { | 278 { |
| 288 ASSERT_UNUSED(profileLength, profileLength >= kIccColorProfileHeaderLength); | 279 ASSERT_UNUSED(profileLength, profileLength >= kIccColorProfileHeaderLength); |
| 289 | 280 |
| 290 return !memcmp(&profileData[16], "RGB ", 4); | 281 return !memcmp(&profileData[16], "RGB ", 4); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 } | 315 } |
| 325 if (!inputProfile) | 316 if (!inputProfile) |
| 326 return; | 317 return; |
| 327 | 318 |
| 328 // We currently only support color profiles for RGB profiled images. | 319 // We currently only support color profiles for RGB profiled images. |
| 329 ASSERT(rgbData == qcms_profile_get_color_space(inputProfile.get())); | 320 ASSERT(rgbData == qcms_profile_get_color_space(inputProfile.get())); |
| 330 | 321 |
| 331 // Take a lock around initializing and accessing the global device color pro
file. | 322 // Take a lock around initializing and accessing the global device color pro
file. |
| 332 SpinLock::Guard guard(gOutputDeviceProfileLock); | 323 SpinLock::Guard guard(gOutputDeviceProfileLock); |
| 333 | 324 |
| 334 // Initialize the output device profile. | 325 // Initialize the output device profile if it has not been received yet. |
| 335 if (!gOutputDeviceProfile) { | 326 if (!gOutputDeviceProfile) { |
| 336 // FIXME: Add optional ICCv4 support and support for multiple monitors. | 327 gOutputDeviceProfile = qcms_profile_sRGB(); |
| 337 WebVector<char> profile; | 328 qcms_profile_precache_output_transform(gOutputDeviceProfile); |
| 338 Platform::current()->screenColorProfile(&profile); | 329 } |
| 339 | 330 |
| 331 if (qcms_profile_match(inputProfile.get(), gOutputDeviceProfile)) |
| 332 return; |
| 333 |
| 334 qcms_data_type dataFormat = hasAlpha ? QCMS_DATA_RGBA_8 : QCMS_DATA_RGB_8; |
| 335 |
| 336 // FIXME: Don't force perceptual intent if the image profile contains an int
ent. |
| 337 m_sourceToOutputDeviceColorTransform = adoptPtr(qcms_transform_create(inputP
rofile.get(), dataFormat, gOutputDeviceProfile, QCMS_DATA_RGBA_8, QCMS_INTENT_PE
RCEPTUAL)); |
| 338 } |
| 339 |
| 340 void ImageDecoder::setOutputDeviceColorProfile(const WebVector<char>& profile) |
| 341 { |
| 342 SpinLock::Guard guard(gOutputDeviceProfileLock); |
| 343 |
| 344 // FIXME: Only ever accept one color profile for the duration of the process
. |
| 345 if (!gOutputDeviceProfile) { |
| 340 if (!profile.isEmpty()) | 346 if (!profile.isEmpty()) |
| 341 gOutputDeviceProfile = qcms_profile_from_memory(profile.data(), prof
ile.size()); | 347 gOutputDeviceProfile = qcms_profile_from_memory(profile.data(), prof
ile.size()); |
| 342 | 348 |
| 343 if (gOutputDeviceProfile && qcms_profile_is_bogus(gOutputDeviceProfile))
{ | 349 if (gOutputDeviceProfile && qcms_profile_is_bogus(gOutputDeviceProfile))
{ |
| 344 qcms_profile_release(gOutputDeviceProfile); | 350 qcms_profile_release(gOutputDeviceProfile); |
| 345 gOutputDeviceProfile = nullptr; | 351 gOutputDeviceProfile = nullptr; |
| 346 } | 352 } |
| 347 | 353 |
| 348 if (!gOutputDeviceProfile) | 354 if (!gOutputDeviceProfile) |
| 349 gOutputDeviceProfile = qcms_profile_sRGB(); | 355 gOutputDeviceProfile = qcms_profile_sRGB(); |
| 350 | 356 |
| 351 qcms_profile_precache_output_transform(gOutputDeviceProfile); | 357 qcms_profile_precache_output_transform(gOutputDeviceProfile); |
| 352 } | 358 } |
| 353 | |
| 354 if (qcms_profile_match(inputProfile.get(), gOutputDeviceProfile)) | |
| 355 return; | |
| 356 | |
| 357 qcms_data_type dataFormat = hasAlpha ? QCMS_DATA_RGBA_8 : QCMS_DATA_RGB_8; | |
| 358 | |
| 359 // FIXME: Don't force perceptual intent if the image profile contains an int
ent. | |
| 360 m_sourceToOutputDeviceColorTransform = adoptPtr(qcms_transform_create(inputP
rofile.get(), dataFormat, gOutputDeviceProfile, QCMS_DATA_RGBA_8, QCMS_INTENT_PE
RCEPTUAL)); | |
| 361 } | 359 } |
| 362 | 360 |
| 363 #endif // USE(QCMSLIB) | 361 bool ImageDecoder::hasColorProfile() const |
| 362 { |
| 363 return m_sourceToOutputDeviceColorTransform.get(); |
| 364 } |
| 365 |
| 366 #else // USE(QCMSLIB) |
| 367 |
| 368 void ImageDecoder::setOutputDeviceColorProfile(const WebVector<char>& colorProfi
le) |
| 369 { |
| 370 } |
| 371 |
| 372 bool ImageDecoder::hasColorProfile() const |
| 373 { |
| 374 return false; |
| 375 } |
| 376 |
| 377 #endif // !USE(QCMSLIB) |
| 364 | 378 |
| 365 } // namespace blink | 379 } // namespace blink |
| OLD | NEW |