michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef _nsGIFDecoder2_h michael@0: #define _nsGIFDecoder2_h michael@0: michael@0: #include "nsCOMPtr.h" michael@0: #include "Decoder.h" michael@0: michael@0: #include "GIF2.h" michael@0: michael@0: namespace mozilla { michael@0: namespace image { michael@0: class RasterImage; michael@0: michael@0: ////////////////////////////////////////////////////////////////////// michael@0: // nsGIFDecoder2 Definition michael@0: michael@0: class nsGIFDecoder2 : public Decoder michael@0: { michael@0: public: michael@0: michael@0: nsGIFDecoder2(RasterImage &aImage); michael@0: ~nsGIFDecoder2(); michael@0: michael@0: virtual void WriteInternal(const char* aBuffer, uint32_t aCount, DecodeStrategy aStrategy); michael@0: virtual void FinishInternal(); michael@0: virtual Telemetry::ID SpeedHistogram(); michael@0: michael@0: private: michael@0: /* These functions will be called when the decoder has a decoded row, michael@0: * frame size information, etc. */ michael@0: michael@0: void BeginGIF(); michael@0: void BeginImageFrame(uint16_t aDepth); michael@0: void EndImageFrame(); michael@0: void FlushImageData(); michael@0: void FlushImageData(uint32_t fromRow, uint32_t rows); michael@0: michael@0: nsresult GifWrite(const uint8_t * buf, uint32_t numbytes); michael@0: uint32_t OutputRow(); michael@0: bool DoLzw(const uint8_t *q); michael@0: bool SetHold(const uint8_t* buf, uint32_t count, michael@0: const uint8_t* buf2 = nullptr, uint32_t count2 = 0); michael@0: michael@0: inline int ClearCode() const { return 1 << mGIFStruct.datasize; } michael@0: michael@0: int32_t mCurrentRow; michael@0: int32_t mLastFlushedRow; michael@0: michael@0: uint32_t mOldColor; // The old value of the transparent pixel michael@0: michael@0: // The frame number of the currently-decoding frame when we're in the middle michael@0: // of decoding it, and -1 otherwise. michael@0: int32_t mCurrentFrame; michael@0: michael@0: uint8_t mCurrentPass; michael@0: uint8_t mLastFlushedPass; michael@0: uint8_t mColorMask; // Apply this to the pixel to keep within colormap michael@0: bool mGIFOpen; michael@0: bool mSawTransparency; michael@0: michael@0: gif_struct mGIFStruct; michael@0: }; michael@0: michael@0: } // namespace image michael@0: } // namespace mozilla michael@0: michael@0: #endif