| Index: third_party/WebKit/Source/platform/image-decoders/ImageDecoder.cpp
|
| diff --git a/third_party/WebKit/Source/platform/image-decoders/ImageDecoder.cpp b/third_party/WebKit/Source/platform/image-decoders/ImageDecoder.cpp
|
| index e7eac4b4a3f696ab1f6871dafc99fab7d4d1b4e3..2bc3af2f87145db9ce2a70c8e2c05f019dfa2b21 100644
|
| --- a/third_party/WebKit/Source/platform/image-decoders/ImageDecoder.cpp
|
| +++ b/third_party/WebKit/Source/platform/image-decoders/ImageDecoder.cpp
|
| @@ -85,38 +85,28 @@ std::unique_ptr<ImageDecoder> ImageDecoder::Create(
|
| // (note: FastSharedBufferReader only makes a copy if the bytes are segmented)
|
| char buffer[kLongestSignatureLength];
|
| const FastSharedBufferReader fast_reader(data);
|
| - const ImageDecoder::SniffResult sniff_result = DetermineImageType(
|
| - fast_reader.GetConsecutiveData(0, kLongestSignatureLength, buffer),
|
| - kLongestSignatureLength);
|
| + const char* contents =
|
| + fast_reader.GetConsecutiveData(0, kLongestSignatureLength, buffer);
|
|
|
| std::unique_ptr<ImageDecoder> decoder;
|
| - switch (sniff_result) {
|
| - case SniffResult::JPEG:
|
| - decoder.reset(new JPEGImageDecoder(alpha_option, color_behavior,
|
| - max_decoded_bytes));
|
| - break;
|
| - case SniffResult::PNG:
|
| - decoder.reset(
|
| - new PNGImageDecoder(alpha_option, color_behavior, max_decoded_bytes));
|
| - break;
|
| - case SniffResult::GIF:
|
| - decoder.reset(
|
| - new GIFImageDecoder(alpha_option, color_behavior, max_decoded_bytes));
|
| - break;
|
| - case SniffResult::WEBP:
|
| - decoder.reset(new WEBPImageDecoder(alpha_option, color_behavior,
|
| - max_decoded_bytes));
|
| - break;
|
| - case SniffResult::ICO:
|
| - decoder.reset(
|
| - new ICOImageDecoder(alpha_option, color_behavior, max_decoded_bytes));
|
| - break;
|
| - case SniffResult::BMP:
|
| - decoder.reset(
|
| - new BMPImageDecoder(alpha_option, color_behavior, max_decoded_bytes));
|
| - break;
|
| - case SniffResult::kInvalid:
|
| - break;
|
| + if (MatchesJPEGSignature(contents)) {
|
| + decoder.reset(
|
| + new JPEGImageDecoder(alpha_option, color_behavior, max_decoded_bytes));
|
| + } else if (MatchesPNGSignature(contents)) {
|
| + decoder.reset(
|
| + new PNGImageDecoder(alpha_option, color_behavior, max_decoded_bytes));
|
| + } else if (MatchesGIFSignature(contents)) {
|
| + decoder.reset(
|
| + new GIFImageDecoder(alpha_option, color_behavior, max_decoded_bytes));
|
| + } else if (MatchesWebPSignature(contents)) {
|
| + decoder.reset(
|
| + new WEBPImageDecoder(alpha_option, color_behavior, max_decoded_bytes));
|
| + } else if (MatchesICOSignature(contents) || MatchesCURSignature(contents)) {
|
| + decoder.reset(
|
| + new ICOImageDecoder(alpha_option, color_behavior, max_decoded_bytes));
|
| + } else if (MatchesBMPSignature(contents)) {
|
| + decoder.reset(
|
| + new BMPImageDecoder(alpha_option, color_behavior, max_decoded_bytes));
|
| }
|
|
|
| if (decoder)
|
| @@ -129,25 +119,6 @@ bool ImageDecoder::HasSufficientDataToSniffImageType(const SharedBuffer& data) {
|
| return data.size() >= kLongestSignatureLength;
|
| }
|
|
|
| -ImageDecoder::SniffResult ImageDecoder::DetermineImageType(const char* contents,
|
| - size_t length) {
|
| - DCHECK_GE(length, kLongestSignatureLength);
|
| -
|
| - if (MatchesJPEGSignature(contents))
|
| - return SniffResult::JPEG;
|
| - if (MatchesPNGSignature(contents))
|
| - return SniffResult::PNG;
|
| - if (MatchesGIFSignature(contents))
|
| - return SniffResult::GIF;
|
| - if (MatchesWebPSignature(contents))
|
| - return SniffResult::WEBP;
|
| - if (MatchesICOSignature(contents) || MatchesCURSignature(contents))
|
| - return SniffResult::ICO;
|
| - if (MatchesBMPSignature(contents))
|
| - return SniffResult::BMP;
|
| - return SniffResult::kInvalid;
|
| -}
|
| -
|
| size_t ImageDecoder::FrameCount() {
|
| const size_t old_size = frame_buffer_cache_.size();
|
| const size_t new_size = DecodeFrameCount();
|
|
|