| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 enum GIFQuery { GIFFullQuery, GIFSizeQuery, GIFFrameCountQuery }; | 42 enum GIFQuery { GIFFullQuery, GIFSizeQuery, GIFFrameCountQuery }; |
| 43 | 43 |
| 44 // ImageDecoder | 44 // ImageDecoder |
| 45 virtual String filenameExtension() const { return "gif"; } | 45 virtual String filenameExtension() const { return "gif"; } |
| 46 virtual void setData(SharedBuffer* data, bool allDataReceived); | 46 virtual void setData(SharedBuffer* data, bool allDataReceived); |
| 47 virtual bool isSizeAvailable(); | 47 virtual bool isSizeAvailable(); |
| 48 virtual bool setSize(unsigned width, unsigned height); | 48 virtual bool setSize(unsigned width, unsigned height); |
| 49 virtual size_t frameCount(); | 49 virtual size_t frameCount(); |
| 50 virtual int repetitionCount() const; | 50 virtual int repetitionCount() const; |
| 51 virtual ImageFrame* frameBufferAtIndex(size_t index); | 51 virtual ImageFrame* frameBufferAtIndex(size_t index); |
| 52 virtual bool frameIsCompleteAtIndex(size_t) const; |
| 53 virtual float frameDurationAtIndex(size_t) const; |
| 52 // CAUTION: setFailed() deletes |m_reader|. Be careful to avoid | 54 // CAUTION: setFailed() deletes |m_reader|. Be careful to avoid |
| 53 // accessing deleted memory, especially when calling this from inside | 55 // accessing deleted memory, especially when calling this from inside |
| 54 // GIFImageReader! | 56 // GIFImageReader! |
| 55 virtual bool setFailed(); | 57 virtual bool setFailed(); |
| 56 virtual void clearFrameBufferCache(size_t clearBeforeFrame); | 58 virtual void clearFrameBufferCache(size_t clearBeforeFrame); |
| 57 | 59 |
| 58 // Callbacks from the GIF reader. | 60 // Callbacks from the GIF reader. |
| 59 bool haveDecodedRow(unsigned frameIndex, const Vector<unsigned char>& ro
wBuffer, size_t width, size_t rowNumber, unsigned repeatCount, bool writeTranspa
rentPixels); | 61 bool haveDecodedRow(unsigned frameIndex, const Vector<unsigned char>& ro
wBuffer, size_t width, size_t rowNumber, unsigned repeatCount, bool writeTranspa
rentPixels); |
| 60 bool frameComplete(unsigned frameIndex, unsigned frameDuration, ImageFra
me::FrameDisposalMethod disposalMethod); | 62 bool frameComplete(unsigned frameIndex, unsigned frameDuration, ImageFra
me::FrameDisposalMethod disposalMethod); |
| 61 void gifComplete(); | 63 void gifComplete(); |
| 62 | 64 |
| 63 private: | 65 private: |
| 64 // If the query is GIFFullQuery, decodes the image up to (but not | 66 // If the query is GIFFullQuery, decodes the image up to (but not |
| 65 // including) |haltAtFrame|. Otherwise, decodes as much as is needed to | 67 // including) |haltAtFrame|. Otherwise, decodes as much as is needed to |
| 66 // answer the query, ignoring bitmap data. If decoding fails but there | 68 // answer the query, ignoring bitmap data. If decoding fails but there |
| 67 // is no more data coming, sets the "decode failure" flag. | 69 // is no more data coming, sets the "decode failure" flag. |
| 68 void decode(unsigned haltAtFrame, GIFQuery); | 70 void decode(unsigned haltAtFrame, GIFQuery); |
| 69 | 71 |
| 70 // Called to initialize the frame buffer with the given index, based on | 72 // Called to initialize the frame buffer with the given index, based on |
| 71 // the previous frame's disposal method. Returns true on success. On | 73 // the previous frame's disposal method. Returns true on success. On |
| 72 // failure, this will mark the image as failed. | 74 // failure, this will mark the image as failed. |
| 73 bool initFrameBuffer(unsigned frameIndex); | 75 bool initFrameBuffer(unsigned frameIndex); |
| 74 | 76 |
| 77 // Return true only if the file is known to be truncated. |
| 78 bool truncated() const; |
| 79 |
| 75 bool m_currentBufferSawAlpha; | 80 bool m_currentBufferSawAlpha; |
| 76 mutable int m_repetitionCount; | 81 mutable int m_repetitionCount; |
| 77 OwnPtr<GIFImageReader> m_reader; | 82 OwnPtr<GIFImageReader> m_reader; |
| 78 }; | 83 }; |
| 79 | 84 |
| 80 } // namespace WebCore | 85 } // namespace WebCore |
| 81 | 86 |
| 82 #endif | 87 #endif |
| OLD | NEW |