image/decoders/nsGIFDecoder2.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial