| 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 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 // set up for the scaled size after reading the image header using this | 437 // set up for the scaled size after reading the image header using this |
| 438 // decoder, so using the full size is no longer possible. | 438 // decoder, so using the full size is no longer possible. |
| 439 if (m_info.scale_num != m_info.scale_denom) | 439 if (m_info.scale_num != m_info.scale_denom) |
| 440 overrideColorSpace = JCS_UNKNOWN; | 440 overrideColorSpace = JCS_UNKNOWN; |
| 441 jpeg_calc_output_dimensions(&m_info); | 441 jpeg_calc_output_dimensions(&m_info); |
| 442 m_decoder->setDecodedSize(m_info.output_width, m_info.output_height); | 442 m_decoder->setDecodedSize(m_info.output_width, m_info.output_height); |
| 443 | 443 |
| 444 m_decoder->setOrientation(readImageOrientation(info())); | 444 m_decoder->setOrientation(readImageOrientation(info())); |
| 445 | 445 |
| 446 // Allow color management of the decoded RGBA pixels if possible. | 446 // Allow color management of the decoded RGBA pixels if possible. |
| 447 if (!m_decoder->ignoresGammaAndColorProfile()) { | 447 if (!m_decoder->ignoresColorSpace()) { |
| 448 JOCTET* profile = nullptr; | 448 JOCTET* profile = nullptr; |
| 449 unsigned profileLength = 0; | 449 unsigned profileLength = 0; |
| 450 if (read_icc_profile(info(), &profile, &profileLength)) { | 450 if (read_icc_profile(info(), &profile, &profileLength)) { |
| 451 decoder()->setColorSpaceAndComputeTransform( | 451 decoder()->setColorSpaceAndComputeTransform( |
| 452 reinterpret_cast<char*>(profile), profileLength, | 452 reinterpret_cast<char*>(profile), profileLength); |
| 453 false /* useSRGB */); | |
| 454 free(profile); | 453 free(profile); |
| 455 } | 454 } |
| 456 if (decoder()->colorTransform()) { | 455 if (decoder()->colorTransform()) { |
| 457 overrideColorSpace = JCS_UNKNOWN; | 456 overrideColorSpace = JCS_UNKNOWN; |
| 458 } | 457 } |
| 459 } | 458 } |
| 460 if (overrideColorSpace == JCS_YCbCr) { | 459 if (overrideColorSpace == JCS_YCbCr) { |
| 461 m_info.out_color_space = JCS_YCbCr; | 460 m_info.out_color_space = JCS_YCbCr; |
| 462 m_info.raw_data_out = TRUE; | 461 m_info.raw_data_out = TRUE; |
| 463 m_uvSize = computeYUVSize( | 462 m_uvSize = computeYUVSize( |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 ->reader->fillBuffer(); | 698 ->reader->fillBuffer(); |
| 700 } | 699 } |
| 701 | 700 |
| 702 void term_source(j_decompress_ptr jd) { | 701 void term_source(j_decompress_ptr jd) { |
| 703 reinterpret_cast_ptr<decoder_source_mgr*>(jd->src) | 702 reinterpret_cast_ptr<decoder_source_mgr*>(jd->src) |
| 704 ->reader->decoder() | 703 ->reader->decoder() |
| 705 ->complete(); | 704 ->complete(); |
| 706 } | 705 } |
| 707 | 706 |
| 708 JPEGImageDecoder::JPEGImageDecoder(AlphaOption alphaOption, | 707 JPEGImageDecoder::JPEGImageDecoder(AlphaOption alphaOption, |
| 709 GammaAndColorProfileOption colorOptions, | 708 ColorSpaceOption colorOptions, |
| 710 size_t maxDecodedBytes) | 709 size_t maxDecodedBytes) |
| 711 : ImageDecoder(alphaOption, colorOptions, maxDecodedBytes) {} | 710 : ImageDecoder(alphaOption, colorOptions, maxDecodedBytes) {} |
| 712 | 711 |
| 713 JPEGImageDecoder::~JPEGImageDecoder() {} | 712 JPEGImageDecoder::~JPEGImageDecoder() {} |
| 714 | 713 |
| 715 bool JPEGImageDecoder::setSize(unsigned width, unsigned height) { | 714 bool JPEGImageDecoder::setSize(unsigned width, unsigned height) { |
| 716 if (!ImageDecoder::setSize(width, height)) | 715 if (!ImageDecoder::setSize(width, height)) |
| 717 return false; | 716 return false; |
| 718 | 717 |
| 719 if (!desiredScaleNumerator()) | 718 if (!desiredScaleNumerator()) |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 jpeg_decompress_struct* info = m_reader->info(); | 921 jpeg_decompress_struct* info = m_reader->info(); |
| 923 | 922 |
| 924 // Initialize the framebuffer if needed. | 923 // Initialize the framebuffer if needed. |
| 925 ImageFrame& buffer = m_frameBufferCache[0]; | 924 ImageFrame& buffer = m_frameBufferCache[0]; |
| 926 if (buffer.getStatus() == ImageFrame::FrameEmpty) { | 925 if (buffer.getStatus() == ImageFrame::FrameEmpty) { |
| 927 ASSERT(info->output_width == | 926 ASSERT(info->output_width == |
| 928 static_cast<JDIMENSION>(m_decodedSize.width())); | 927 static_cast<JDIMENSION>(m_decodedSize.width())); |
| 929 ASSERT(info->output_height == | 928 ASSERT(info->output_height == |
| 930 static_cast<JDIMENSION>(m_decodedSize.height())); | 929 static_cast<JDIMENSION>(m_decodedSize.height())); |
| 931 | 930 |
| 932 if (!buffer.setSizeAndColorProfile(info->output_width, info->output_height, | 931 if (!buffer.setSizeAndColorSpace(info->output_width, info->output_height, |
| 933 colorProfile())) | 932 colorSpace())) |
| 934 return setFailed(); | 933 return setFailed(); |
| 935 | 934 |
| 936 // The buffer is transparent outside the decoded area while the image is | 935 // The buffer is transparent outside the decoded area while the image is |
| 937 // loading. The image will be marked fully opaque in complete(). | 936 // loading. The image will be marked fully opaque in complete(). |
| 938 buffer.setStatus(ImageFrame::FramePartial); | 937 buffer.setStatus(ImageFrame::FramePartial); |
| 939 buffer.setHasAlpha(true); | 938 buffer.setHasAlpha(true); |
| 940 | 939 |
| 941 // For JPEGs, the frame always fills the entire image. | 940 // For JPEGs, the frame always fills the entire image. |
| 942 buffer.setOriginalFrameRect(IntRect(IntPoint(), size())); | 941 buffer.setOriginalFrameRect(IntRect(IntPoint(), size())); |
| 943 } | 942 } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1001 // has failed. | 1000 // has failed. |
| 1002 if (!m_reader->decode(onlySize) && isAllDataReceived()) | 1001 if (!m_reader->decode(onlySize) && isAllDataReceived()) |
| 1003 setFailed(); | 1002 setFailed(); |
| 1004 | 1003 |
| 1005 // If decoding is done or failed, we don't need the JPEGImageReader anymore. | 1004 // If decoding is done or failed, we don't need the JPEGImageReader anymore. |
| 1006 if (isComplete(this, onlySize) || failed()) | 1005 if (isComplete(this, onlySize) || failed()) |
| 1007 m_reader.reset(); | 1006 m_reader.reset(); |
| 1008 } | 1007 } |
| 1009 | 1008 |
| 1010 } // namespace blink | 1009 } // namespace blink |
| OLD | NEW |