| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 // where 0 means "infinite". But ImageSource::repetitionCount() | 232 // where 0 means "infinite". But ImageSource::repetitionCount() |
| 233 // returns -1 for "infinite", and 0 and up for "show the image | 233 // returns -1 for "infinite", and 0 and up for "show the image |
| 234 // animation one cycle more than the value". Subtract one here | 234 // animation one cycle more than the value". Subtract one here |
| 235 // to correctly handle the finite and infinite cases. | 235 // to correctly handle the finite and infinite cases. |
| 236 --m_repetitionCount; | 236 --m_repetitionCount; |
| 237 // FIXME: Implement ICC profile support for animated images. | 237 // FIXME: Implement ICC profile support for animated images. |
| 238 m_formatFlags &= ~ICCP_FLAG; | 238 m_formatFlags &= ~ICCP_FLAG; |
| 239 } | 239 } |
| 240 | 240 |
| 241 #if USE(QCMSLIB) | 241 #if USE(QCMSLIB) |
| 242 if ((m_formatFlags & ICCP_FLAG) && !ignoresGammaAndColorProfile()) | 242 if (!ignoresGammaAndColorProfile()) { |
| 243 readColorProfile(); | 243 ColorProfileStatus status; |
| 244 if ((m_formatFlags & ICCP_FLAG)) { |
| 245 status = readColorProfile(); |
| 246 } else { |
| 247 status = ColorProfileNone; |
| 248 } |
| 249 Platform::current()->histogramEnumeration("ColorManagement.WEBPColor
ProfileStatus", status, ColorProfileStatus::ValueCount); |
| 250 } |
| 244 #endif | 251 #endif |
| 245 } | 252 } |
| 246 | 253 |
| 247 ASSERT(isDecodedSizeAvailable()); | 254 ASSERT(isDecodedSizeAvailable()); |
| 248 return true; | 255 return true; |
| 249 } | 256 } |
| 250 | 257 |
| 251 bool WEBPImageDecoder::initFrameBuffer(size_t frameIndex) | 258 bool WEBPImageDecoder::initFrameBuffer(size_t frameIndex) |
| 252 { | 259 { |
| 253 ImageFrame& buffer = m_frameBufferCache[frameIndex]; | 260 ImageFrame& buffer = m_frameBufferCache[frameIndex]; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 | 316 |
| 310 #if USE(QCMSLIB) | 317 #if USE(QCMSLIB) |
| 311 | 318 |
| 312 void WEBPImageDecoder::clearColorTransform() | 319 void WEBPImageDecoder::clearColorTransform() |
| 313 { | 320 { |
| 314 if (m_transform) | 321 if (m_transform) |
| 315 qcms_transform_release(m_transform); | 322 qcms_transform_release(m_transform); |
| 316 m_transform = 0; | 323 m_transform = 0; |
| 317 } | 324 } |
| 318 | 325 |
| 319 bool WEBPImageDecoder::createColorTransform(const char* data, size_t size) | 326 bool WEBPImageDecoder::createColorTransform(const char* data, size_t size, Color
ProfileStatus& status) |
| 320 { | 327 { |
| 321 clearColorTransform(); | 328 clearColorTransform(); |
| 322 | 329 |
| 330 qcms_profile* inputProfile = qcms_profile_from_memory(data, size); |
| 331 if (!inputProfile) { |
| 332 status = ColorProfileFailedDecode; |
| 333 return false; |
| 334 } |
| 335 |
| 323 qcms_profile* deviceProfile = ImageDecoder::qcmsOutputDeviceProfile(); | 336 qcms_profile* deviceProfile = ImageDecoder::qcmsOutputDeviceProfile(); |
| 324 if (!deviceProfile) | 337 if (!deviceProfile) |
| 325 return false; | 338 return false; |
| 326 qcms_profile* inputProfile = qcms_profile_from_memory(data, size); | |
| 327 if (!inputProfile) | |
| 328 return false; | |
| 329 | |
| 330 // We currently only support color profiles for RGB profiled images. | 339 // We currently only support color profiles for RGB profiled images. |
| 331 ASSERT(rgbData == qcms_profile_get_color_space(inputProfile)); | 340 ASSERT(rgbData == qcms_profile_get_color_space(inputProfile)); |
| 332 // The input image pixels are RGBA format. | 341 // The input image pixels are RGBA format. |
| 333 qcms_data_type format = QCMS_DATA_RGBA_8; | 342 qcms_data_type format = QCMS_DATA_RGBA_8; |
| 334 // FIXME: Don't force perceptual intent if the image profile contains an int
ent. | 343 // FIXME: Don't force perceptual intent if the image profile contains an int
ent. |
| 335 m_transform = qcms_transform_create(inputProfile, format, deviceProfile, QCM
S_DATA_RGBA_8, QCMS_INTENT_PERCEPTUAL); | 344 m_transform = qcms_transform_create(inputProfile, format, deviceProfile, QCM
S_DATA_RGBA_8, QCMS_INTENT_PERCEPTUAL); |
| 336 | 345 |
| 337 qcms_profile_release(inputProfile); | 346 qcms_profile_release(inputProfile); |
| 338 return !!m_transform; | 347 return !!m_transform; |
| 339 } | 348 } |
| 340 | 349 |
| 341 void WEBPImageDecoder::readColorProfile() | 350 ColorProfileStatus WEBPImageDecoder::readColorProfile() |
| 342 { | 351 { |
| 343 WebPChunkIterator chunkIterator; | 352 WebPChunkIterator chunkIterator; |
| 344 if (!WebPDemuxGetChunk(m_demux, "ICCP", 1, &chunkIterator)) { | 353 if (!WebPDemuxGetChunk(m_demux, "ICCP", 1, &chunkIterator)) { |
| 345 WebPDemuxReleaseChunkIterator(&chunkIterator); | 354 WebPDemuxReleaseChunkIterator(&chunkIterator); |
| 346 return; | 355 return ColorProfileNotFound; |
| 347 } | 356 } |
| 348 | 357 |
| 349 const char* profileData = reinterpret_cast<const char*>(chunkIterator.chunk.
bytes); | 358 const char* profileData = reinterpret_cast<const char*>(chunkIterator.chunk.
bytes); |
| 350 size_t profileSize = chunkIterator.chunk.size; | 359 size_t profileSize = chunkIterator.chunk.size; |
| 351 | 360 |
| 352 // Only accept RGB color profiles from input class devices. | 361 // Only accept RGB color profiles from input class devices. |
| 353 bool ignoreProfile = false; | 362 ColorProfileStatus status = ColorProfileSuccess; |
| 354 if (profileSize < ImageDecoder::iccColorProfileHeaderLength) | 363 if (profileSize < ImageDecoder::iccColorProfileHeaderLength) |
| 355 ignoreProfile = true; | 364 status = ColorProfileIsCorrupted; |
| 365 else if (ImageDecoder::isICCv4(profileData, profileSize)) |
| 366 status = ColorProfileIsV4; |
| 356 else if (!ImageDecoder::rgbColorProfile(profileData, profileSize)) | 367 else if (!ImageDecoder::rgbColorProfile(profileData, profileSize)) |
| 357 ignoreProfile = true; | 368 status = ColorProfileIsNotRGB; |
| 358 else if (!ImageDecoder::inputDeviceColorProfile(profileData, profileSize)) | 369 else if (!ImageDecoder::inputDeviceColorProfile(profileData, profileSize)) |
| 359 ignoreProfile = true; | 370 status = ColorProfileIsNotAnInputProfile; |
| 360 | 371 |
| 361 if (!ignoreProfile) | 372 if (status == ColorProfileSuccess) |
| 362 m_hasColorProfile = createColorTransform(profileData, profileSize); | 373 m_hasColorProfile = createColorTransform(profileData, profileSize, statu
s); |
| 363 | 374 |
| 364 WebPDemuxReleaseChunkIterator(&chunkIterator); | 375 WebPDemuxReleaseChunkIterator(&chunkIterator); |
| 376 return status; |
| 365 } | 377 } |
| 366 | 378 |
| 367 #endif // USE(QCMSLIB) | 379 #endif // USE(QCMSLIB) |
| 368 | 380 |
| 369 void WEBPImageDecoder::applyPostProcessing(size_t frameIndex) | 381 void WEBPImageDecoder::applyPostProcessing(size_t frameIndex) |
| 370 { | 382 { |
| 371 ImageFrame& buffer = m_frameBufferCache[frameIndex]; | 383 ImageFrame& buffer = m_frameBufferCache[frameIndex]; |
| 372 int width; | 384 int width; |
| 373 int decodedHeight; | 385 int decodedHeight; |
| 374 if (!WebPIDecGetRGB(m_decoder, &decodedHeight, &width, 0, 0)) | 386 if (!WebPIDecGetRGB(m_decoder, &decodedHeight, &width, 0, 0)) |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 return false; | 563 return false; |
| 552 } | 564 } |
| 553 // FALLTHROUGH | 565 // FALLTHROUGH |
| 554 default: | 566 default: |
| 555 clear(); | 567 clear(); |
| 556 return setFailed(); | 568 return setFailed(); |
| 557 } | 569 } |
| 558 } | 570 } |
| 559 | 571 |
| 560 } // namespace blink | 572 } // namespace blink |
| OLD | NEW |