| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006 Apple Computer, Inc. | 2 * Copyright (C) 2006 Apple Computer, Inc. |
| 3 * | 3 * |
| 4 * Portions are Copyright (C) 2001-6 mozilla.org | 4 * Portions are Copyright (C) 2001-6 mozilla.org |
| 5 * | 5 * |
| 6 * Other contributors: | 6 * Other contributors: |
| 7 * Stuart Parmenter <stuart@mozilla.com> | 7 * Stuart Parmenter <stuart@mozilla.com> |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Lesser General Public | 10 * modify it under the terms of the GNU Lesser General Public |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 // YUV decoding is performed on full sized images. At this point, bu
ffers and various | 444 // YUV decoding is performed on full sized images. At this point, bu
ffers and various |
| 445 // image info structs have already been setup to the scaled size aft
er reading the | 445 // image info structs have already been setup to the scaled size aft
er reading the |
| 446 // image header using this decoder, so using the full size is no lon
ger possible. | 446 // image header using this decoder, so using the full size is no lon
ger possible. |
| 447 if (m_info.scale_num != m_info.scale_denom) | 447 if (m_info.scale_num != m_info.scale_denom) |
| 448 overrideColorSpace = JCS_UNKNOWN; | 448 overrideColorSpace = JCS_UNKNOWN; |
| 449 jpeg_calc_output_dimensions(&m_info); | 449 jpeg_calc_output_dimensions(&m_info); |
| 450 m_decoder->setDecodedSize(m_info.output_width, m_info.output_height)
; | 450 m_decoder->setDecodedSize(m_info.output_width, m_info.output_height)
; |
| 451 | 451 |
| 452 m_decoder->setOrientation(readImageOrientation(info())); | 452 m_decoder->setOrientation(readImageOrientation(info())); |
| 453 | 453 |
| 454 #if USE(QCMSLIB) | |
| 455 // Allow color management of the decoded RGBA pixels if possible. | 454 // Allow color management of the decoded RGBA pixels if possible. |
| 456 if (!m_decoder->ignoresGammaAndColorProfile()) { | 455 if (!m_decoder->ignoresGammaAndColorProfile()) { |
| 457 #if USE(ICCJPEG) | 456 #if USE(ICCJPEG) |
| 458 JOCTET* profile = nullptr; | 457 JOCTET* profile = nullptr; |
| 459 unsigned profileLength = 0; | 458 unsigned profileLength = 0; |
| 460 if (read_icc_profile(info(), &profile, &profileLength)) { | 459 if (read_icc_profile(info(), &profile, &profileLength)) { |
| 461 decoder()->setColorProfileAndTransform(reinterpret_cast<char
*>(profile), profileLength, colorSpaceHasAlpha(info()->out_color_space), false /
* useSRGB */); | 460 decoder()->setColorProfileAndComputeTransform(reinterpret_ca
st<char*>(profile), profileLength, colorSpaceHasAlpha(info()->out_color_space),
false /* useSRGB */); |
| 462 free(profile); | 461 free(profile); |
| 463 } | 462 } |
| 464 #endif // USE(ICCJPEG) | 463 #endif // USE(ICCJPEG) |
| 464 #if USE(QCMSLIB) |
| 465 if (decoder()->colorTransform()) { | 465 if (decoder()->colorTransform()) { |
| 466 overrideColorSpace = JCS_UNKNOWN; | 466 overrideColorSpace = JCS_UNKNOWN; |
| 467 #if defined(TURBO_JPEG_RGB_SWIZZLE) | 467 #if defined(TURBO_JPEG_RGB_SWIZZLE) |
| 468 // Input RGBA data to qcms. Note: restored to BGRA on output
. | 468 // Input RGBA data to qcms. Note: restored to BGRA on output
. |
| 469 if (m_info.out_color_space == JCS_EXT_BGRA) | 469 if (m_info.out_color_space == JCS_EXT_BGRA) |
| 470 m_info.out_color_space = JCS_EXT_RGBA; | 470 m_info.out_color_space = JCS_EXT_RGBA; |
| 471 #endif // defined(TURBO_JPEG_RGB_SWIZZLE) | 471 #endif // defined(TURBO_JPEG_RGB_SWIZZLE) |
| 472 } | 472 } |
| 473 #endif // USE(QCMSLIB) |
| 473 } | 474 } |
| 474 #endif // USE(QCMSLIB) | |
| 475 if (overrideColorSpace == JCS_YCbCr) { | 475 if (overrideColorSpace == JCS_YCbCr) { |
| 476 m_info.out_color_space = JCS_YCbCr; | 476 m_info.out_color_space = JCS_YCbCr; |
| 477 m_info.raw_data_out = TRUE; | 477 m_info.raw_data_out = TRUE; |
| 478 m_uvSize = computeYUVSize(&m_info, 1); // U size and V size have
to be the same if we got here | 478 m_uvSize = computeYUVSize(&m_info, 1); // U size and V size have
to be the same if we got here |
| 479 } | 479 } |
| 480 | 480 |
| 481 // Don't allocate a giant and superfluous memory buffer when the | 481 // Don't allocate a giant and superfluous memory buffer when the |
| 482 // image is a sequential JPEG. | 482 // image is a sequential JPEG. |
| 483 m_info.buffered_image = jpeg_has_multiple_scans(&m_info); | 483 m_info.buffered_image = jpeg_has_multiple_scans(&m_info); |
| 484 if (m_info.buffered_image) { | 484 if (m_info.buffered_image) { |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 return false; | 920 return false; |
| 921 | 921 |
| 922 jpeg_decompress_struct* info = m_reader->info(); | 922 jpeg_decompress_struct* info = m_reader->info(); |
| 923 | 923 |
| 924 // Initialize the framebuffer if needed. | 924 // Initialize the framebuffer if needed. |
| 925 ImageFrame& buffer = m_frameBufferCache[0]; | 925 ImageFrame& buffer = m_frameBufferCache[0]; |
| 926 if (buffer.getStatus() == ImageFrame::FrameEmpty) { | 926 if (buffer.getStatus() == ImageFrame::FrameEmpty) { |
| 927 ASSERT(info->output_width == static_cast<JDIMENSION>(m_decodedSize.width
())); | 927 ASSERT(info->output_width == static_cast<JDIMENSION>(m_decodedSize.width
())); |
| 928 ASSERT(info->output_height == static_cast<JDIMENSION>(m_decodedSize.heig
ht())); | 928 ASSERT(info->output_height == static_cast<JDIMENSION>(m_decodedSize.heig
ht())); |
| 929 | 929 |
| 930 if (!buffer.setSize(info->output_width, info->output_height)) | 930 if (!buffer.setSizeAndColorProfile(info->output_width, info->output_heig
ht, colorProfile())) |
| 931 return setFailed(); | 931 return setFailed(); |
| 932 | 932 |
| 933 // The buffer is transparent outside the decoded area while the image is | 933 // The buffer is transparent outside the decoded area while the image is |
| 934 // loading. The image will be marked fully opaque in complete(). | 934 // loading. The image will be marked fully opaque in complete(). |
| 935 buffer.setStatus(ImageFrame::FramePartial); | 935 buffer.setStatus(ImageFrame::FramePartial); |
| 936 buffer.setHasAlpha(true); | 936 buffer.setHasAlpha(true); |
| 937 | 937 |
| 938 // For JPEGs, the frame always fills the entire image. | 938 // For JPEGs, the frame always fills the entire image. |
| 939 buffer.setOriginalFrameRect(IntRect(IntPoint(), size())); | 939 buffer.setOriginalFrameRect(IntRect(IntPoint(), size())); |
| 940 } | 940 } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 998 // has failed. | 998 // has failed. |
| 999 if (!m_reader->decode(onlySize) && isAllDataReceived()) | 999 if (!m_reader->decode(onlySize) && isAllDataReceived()) |
| 1000 setFailed(); | 1000 setFailed(); |
| 1001 | 1001 |
| 1002 // If decoding is done or failed, we don't need the JPEGImageReader anymore. | 1002 // If decoding is done or failed, we don't need the JPEGImageReader anymore. |
| 1003 if (isComplete(this, onlySize) || failed()) | 1003 if (isComplete(this, onlySize) || failed()) |
| 1004 m_reader.reset(); | 1004 m_reader.reset(); |
| 1005 } | 1005 } |
| 1006 | 1006 |
| 1007 } // namespace blink | 1007 } // namespace blink |
| OLD | NEW |