| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 inline bool matchesCURSignature(const char* contents) | 73 inline bool matchesCURSignature(const char* contents) |
| 74 { | 74 { |
| 75 return !memcmp(contents, "\x00\x00\x02\x00", 4); | 75 return !memcmp(contents, "\x00\x00\x02\x00", 4); |
| 76 } | 76 } |
| 77 | 77 |
| 78 inline bool matchesBMPSignature(const char* contents) | 78 inline bool matchesBMPSignature(const char* contents) |
| 79 { | 79 { |
| 80 return !memcmp(contents, "BM", 2); | 80 return !memcmp(contents, "BM", 2); |
| 81 } | 81 } |
| 82 | 82 |
| 83 size_t ImageDecoder::longestSignatureLength() |
| 84 { |
| 85 const size_t longestSignatureLength = sizeof("RIFF????WEBPVP") - 1; |
| 86 DCHECK_EQ(14u, longestSignatureLength); |
| 87 return 14u; |
| 88 } |
| 89 |
| 83 std::unique_ptr<ImageDecoder> ImageDecoder::create(const char* contents, size_t
length, AlphaOption alphaOption, GammaAndColorProfileOption colorOptions) | 90 std::unique_ptr<ImageDecoder> ImageDecoder::create(const char* contents, size_t
length, AlphaOption alphaOption, GammaAndColorProfileOption colorOptions) |
| 84 { | 91 { |
| 85 const size_t longestSignatureLength = sizeof("RIFF????WEBPVP") - 1; | 92 if (length < longestSignatureLength()) |
| 86 ASSERT(longestSignatureLength == 14); | |
| 87 | |
| 88 if (length < longestSignatureLength) | |
| 89 return nullptr; | 93 return nullptr; |
| 90 | 94 |
| 91 size_t maxDecodedBytes = Platform::current() ? Platform::current()->maxDecod
edImageBytes() : noDecodedImageByteLimit; | 95 size_t maxDecodedBytes = Platform::current() ? Platform::current()->maxDecod
edImageBytes() : noDecodedImageByteLimit; |
| 92 | 96 |
| 93 if (matchesJPEGSignature(contents)) | 97 if (matchesJPEGSignature(contents)) |
| 94 return wrapUnique(new JPEGImageDecoder(alphaOption, colorOptions, maxDec
odedBytes)); | 98 return wrapUnique(new JPEGImageDecoder(alphaOption, colorOptions, maxDec
odedBytes)); |
| 95 | 99 |
| 96 if (matchesPNGSignature(contents)) | 100 if (matchesPNGSignature(contents)) |
| 97 return wrapUnique(new PNGImageDecoder(alphaOption, colorOptions, maxDeco
dedBytes)); | 101 return wrapUnique(new PNGImageDecoder(alphaOption, colorOptions, maxDeco
dedBytes)); |
| 98 | 102 |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 } | 387 } |
| 384 | 388 |
| 385 bool ImageDecoder::hasColorProfile() const | 389 bool ImageDecoder::hasColorProfile() const |
| 386 { | 390 { |
| 387 return false; | 391 return false; |
| 388 } | 392 } |
| 389 | 393 |
| 390 #endif // USE(QCMSLIB) | 394 #endif // USE(QCMSLIB) |
| 391 | 395 |
| 392 } // namespace blink | 396 } // namespace blink |
| OLD | NEW |