| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006 Apple Computer, Inc. | 2 * Copyright (C) 2006 Apple Computer, Inc. |
| 3 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. | 3 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. |
| 4 * | 4 * |
| 5 * Portions are Copyright (C) 2001 mozilla.org | 5 * Portions are Copyright (C) 2001 mozilla.org |
| 6 * | 6 * |
| 7 * Other contributors: | 7 * Other contributors: |
| 8 * Stuart Parmenter <stuart@mozilla.com> | 8 * Stuart Parmenter <stuart@mozilla.com> |
| 9 * | 9 * |
| 10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 #define JMPBUF(png_ptr) png_ptr->jmpbuf | 56 #define JMPBUF(png_ptr) png_ptr->jmpbuf |
| 57 #endif | 57 #endif |
| 58 | 58 |
| 59 namespace { | 59 namespace { |
| 60 | 60 |
| 61 inline blink::PNGImageDecoder* imageDecoder(png_structp png) | 61 inline blink::PNGImageDecoder* imageDecoder(png_structp png) |
| 62 { | 62 { |
| 63 return static_cast<blink::PNGImageDecoder*>(png_get_progressive_ptr(png)); | 63 return static_cast<blink::PNGImageDecoder*>(png_get_progressive_ptr(png)); |
| 64 } | 64 } |
| 65 | 65 |
| 66 // Called when image header information is available (including the size). | |
| 67 void PNGAPI pngHeaderAvailable(png_structp png, png_infop) | 66 void PNGAPI pngHeaderAvailable(png_structp png, png_infop) |
| 68 { | 67 { |
| 69 imageDecoder(png)->headerAvailable(); | 68 imageDecoder(png)->headerAvailable(); |
| 70 } | 69 } |
| 71 | 70 |
| 72 // Called when a decoded row is ready. | 71 void PNGAPI pngRowAvailable(png_structp png, png_bytep row, png_uint_32 rowIndex
, int state) |
| 73 void PNGAPI pngRowAvailable(png_structp png, png_bytep rowBuffer, png_uint_32 ro
wIndex, int interlacePass) | |
| 74 { | 72 { |
| 75 imageDecoder(png)->rowAvailable(rowBuffer, rowIndex, interlacePass); | 73 imageDecoder(png)->rowAvailable(row, rowIndex, state); |
| 76 } | 74 } |
| 77 | 75 |
| 78 // Called when decoding completes. | |
| 79 void PNGAPI pngComplete(png_structp png, png_infop) | 76 void PNGAPI pngComplete(png_structp png, png_infop) |
| 80 { | 77 { |
| 81 imageDecoder(png)->complete(); | 78 imageDecoder(png)->complete(); |
| 82 } | 79 } |
| 83 | 80 |
| 84 // Called when decoding fails. | |
| 85 void PNGAPI pngFailed(png_structp png, png_const_charp) | 81 void PNGAPI pngFailed(png_structp png, png_const_charp) |
| 86 { | 82 { |
| 87 longjmp(JMPBUF(png), 1); | 83 longjmp(JMPBUF(png), 1); |
| 88 } | 84 } |
| 89 | 85 |
| 90 } // anonymous | 86 } // anonymous |
| 91 | 87 |
| 92 namespace blink { | 88 namespace blink { |
| 93 | 89 |
| 94 class PNGImageReader { | 90 class PNGImageReader { |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 // has failed. | 533 // has failed. |
| 538 if (!m_reader->decode(*m_data, onlySize) && isAllDataReceived()) | 534 if (!m_reader->decode(*m_data, onlySize) && isAllDataReceived()) |
| 539 setFailed(); | 535 setFailed(); |
| 540 | 536 |
| 541 // If decoding is done or failed, we don't need the PNGImageReader anymore. | 537 // If decoding is done or failed, we don't need the PNGImageReader anymore. |
| 542 if (isComplete() || failed()) | 538 if (isComplete() || failed()) |
| 543 m_reader.clear(); | 539 m_reader.clear(); |
| 544 } | 540 } |
| 545 | 541 |
| 546 } // namespace blink | 542 } // namespace blink |
| OLD | NEW |