| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 // This class decodes the PNG image format. | 36 // This class decodes the PNG image format. |
| 37 class PNGImageDecoder : public ImageDecoder { | 37 class PNGImageDecoder : public ImageDecoder { |
| 38 public: | 38 public: |
| 39 PNGImageDecoder(ImageSource::AlphaOption, ImageSource::GammaAndColorProf
ileOption); | 39 PNGImageDecoder(ImageSource::AlphaOption, ImageSource::GammaAndColorProf
ileOption); |
| 40 virtual ~PNGImageDecoder(); | 40 virtual ~PNGImageDecoder(); |
| 41 | 41 |
| 42 // ImageDecoder | 42 // ImageDecoder |
| 43 virtual String filenameExtension() const { return "png"; } | 43 virtual String filenameExtension() const { return "png"; } |
| 44 virtual bool isSizeAvailable(); | 44 virtual bool isSizeAvailable(); |
| 45 virtual bool setSize(unsigned width, unsigned height); | |
| 46 virtual ImageFrame* frameBufferAtIndex(size_t index); | 45 virtual ImageFrame* frameBufferAtIndex(size_t index); |
| 47 // CAUTION: setFailed() deletes |m_reader|. Be careful to avoid | 46 // CAUTION: setFailed() deletes |m_reader|. Be careful to avoid |
| 48 // accessing deleted memory, especially when calling this from inside | 47 // accessing deleted memory, especially when calling this from inside |
| 49 // PNGImageReader! | 48 // PNGImageReader! |
| 50 virtual bool setFailed(); | 49 virtual bool setFailed(); |
| 51 | 50 |
| 52 // Callbacks from libpng | 51 // Callbacks from libpng |
| 53 void headerAvailable(); | 52 void headerAvailable(); |
| 54 void rowAvailable(unsigned char* rowBuffer, unsigned rowIndex, int inter
lacePass); | 53 void rowAvailable(unsigned char* rowBuffer, unsigned rowIndex, int inter
lacePass); |
| 55 void pngComplete(); | 54 void pngComplete(); |
| 56 | 55 |
| 57 bool isComplete() const | 56 bool isComplete() const |
| 58 { | 57 { |
| 59 return !m_frameBufferCache.isEmpty() && (m_frameBufferCache.first().
status() == ImageFrame::FrameComplete); | 58 return !m_frameBufferCache.isEmpty() && (m_frameBufferCache.first().
status() == ImageFrame::FrameComplete); |
| 60 } | 59 } |
| 61 | 60 |
| 62 private: | 61 private: |
| 63 // Decodes the image. If |onlySize| is true, stops decoding after | 62 // Decodes the image. If |onlySize| is true, stops decoding after |
| 64 // calculating the image size. If decoding fails but there is no more | 63 // calculating the image size. If decoding fails but there is no more |
| 65 // data coming, sets the "decode failure" flag. | 64 // data coming, sets the "decode failure" flag. |
| 66 void decode(bool onlySize); | 65 void decode(bool onlySize); |
| 67 | 66 |
| 68 OwnPtr<PNGImageReader> m_reader; | 67 OwnPtr<PNGImageReader> m_reader; |
| 69 bool m_doNothingOnFailure; | 68 bool m_doNothingOnFailure; |
| 70 }; | 69 }; |
| 71 | 70 |
| 72 } // namespace WebCore | 71 } // namespace WebCore |
| 73 | 72 |
| 74 #endif | 73 #endif |
| OLD | NEW |