1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/image/decoders/nsGIFDecoder2.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,72 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- 1.5 + * 1.6 + * This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef _nsGIFDecoder2_h 1.11 +#define _nsGIFDecoder2_h 1.12 + 1.13 +#include "nsCOMPtr.h" 1.14 +#include "Decoder.h" 1.15 + 1.16 +#include "GIF2.h" 1.17 + 1.18 +namespace mozilla { 1.19 +namespace image { 1.20 +class RasterImage; 1.21 + 1.22 +////////////////////////////////////////////////////////////////////// 1.23 +// nsGIFDecoder2 Definition 1.24 + 1.25 +class nsGIFDecoder2 : public Decoder 1.26 +{ 1.27 +public: 1.28 + 1.29 + nsGIFDecoder2(RasterImage &aImage); 1.30 + ~nsGIFDecoder2(); 1.31 + 1.32 + virtual void WriteInternal(const char* aBuffer, uint32_t aCount, DecodeStrategy aStrategy); 1.33 + virtual void FinishInternal(); 1.34 + virtual Telemetry::ID SpeedHistogram(); 1.35 + 1.36 +private: 1.37 + /* These functions will be called when the decoder has a decoded row, 1.38 + * frame size information, etc. */ 1.39 + 1.40 + void BeginGIF(); 1.41 + void BeginImageFrame(uint16_t aDepth); 1.42 + void EndImageFrame(); 1.43 + void FlushImageData(); 1.44 + void FlushImageData(uint32_t fromRow, uint32_t rows); 1.45 + 1.46 + nsresult GifWrite(const uint8_t * buf, uint32_t numbytes); 1.47 + uint32_t OutputRow(); 1.48 + bool DoLzw(const uint8_t *q); 1.49 + bool SetHold(const uint8_t* buf, uint32_t count, 1.50 + const uint8_t* buf2 = nullptr, uint32_t count2 = 0); 1.51 + 1.52 + inline int ClearCode() const { return 1 << mGIFStruct.datasize; } 1.53 + 1.54 + int32_t mCurrentRow; 1.55 + int32_t mLastFlushedRow; 1.56 + 1.57 + uint32_t mOldColor; // The old value of the transparent pixel 1.58 + 1.59 + // The frame number of the currently-decoding frame when we're in the middle 1.60 + // of decoding it, and -1 otherwise. 1.61 + int32_t mCurrentFrame; 1.62 + 1.63 + uint8_t mCurrentPass; 1.64 + uint8_t mLastFlushedPass; 1.65 + uint8_t mColorMask; // Apply this to the pixel to keep within colormap 1.66 + bool mGIFOpen; 1.67 + bool mSawTransparency; 1.68 + 1.69 + gif_struct mGIFStruct; 1.70 +}; 1.71 + 1.72 +} // namespace image 1.73 +} // namespace mozilla 1.74 + 1.75 +#endif