image/decoders/nsGIFDecoder2.h

branch
TOR_BUG_9701
changeset 10
ac0c01689b40
equal deleted inserted replaced
-1:000000000000 0:d2143c6f7fa4
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 #ifndef _nsGIFDecoder2_h
8 #define _nsGIFDecoder2_h
9
10 #include "nsCOMPtr.h"
11 #include "Decoder.h"
12
13 #include "GIF2.h"
14
15 namespace mozilla {
16 namespace image {
17 class RasterImage;
18
19 //////////////////////////////////////////////////////////////////////
20 // nsGIFDecoder2 Definition
21
22 class nsGIFDecoder2 : public Decoder
23 {
24 public:
25
26 nsGIFDecoder2(RasterImage &aImage);
27 ~nsGIFDecoder2();
28
29 virtual void WriteInternal(const char* aBuffer, uint32_t aCount, DecodeStrategy aStrategy);
30 virtual void FinishInternal();
31 virtual Telemetry::ID SpeedHistogram();
32
33 private:
34 /* These functions will be called when the decoder has a decoded row,
35 * frame size information, etc. */
36
37 void BeginGIF();
38 void BeginImageFrame(uint16_t aDepth);
39 void EndImageFrame();
40 void FlushImageData();
41 void FlushImageData(uint32_t fromRow, uint32_t rows);
42
43 nsresult GifWrite(const uint8_t * buf, uint32_t numbytes);
44 uint32_t OutputRow();
45 bool DoLzw(const uint8_t *q);
46 bool SetHold(const uint8_t* buf, uint32_t count,
47 const uint8_t* buf2 = nullptr, uint32_t count2 = 0);
48
49 inline int ClearCode() const { return 1 << mGIFStruct.datasize; }
50
51 int32_t mCurrentRow;
52 int32_t mLastFlushedRow;
53
54 uint32_t mOldColor; // The old value of the transparent pixel
55
56 // The frame number of the currently-decoding frame when we're in the middle
57 // of decoding it, and -1 otherwise.
58 int32_t mCurrentFrame;
59
60 uint8_t mCurrentPass;
61 uint8_t mLastFlushedPass;
62 uint8_t mColorMask; // Apply this to the pixel to keep within colormap
63 bool mGIFOpen;
64 bool mSawTransparency;
65
66 gif_struct mGIFStruct;
67 };
68
69 } // namespace image
70 } // namespace mozilla
71
72 #endif

mercurial