image/decoders/nsGIFDecoder2.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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/. */
     7 #ifndef _nsGIFDecoder2_h
     8 #define _nsGIFDecoder2_h
    10 #include "nsCOMPtr.h"
    11 #include "Decoder.h"
    13 #include "GIF2.h"
    15 namespace mozilla {
    16 namespace image {
    17 class RasterImage;
    19 //////////////////////////////////////////////////////////////////////
    20 // nsGIFDecoder2 Definition
    22 class nsGIFDecoder2 : public Decoder
    23 {
    24 public:
    26   nsGIFDecoder2(RasterImage &aImage);
    27   ~nsGIFDecoder2();
    29   virtual void WriteInternal(const char* aBuffer, uint32_t aCount, DecodeStrategy aStrategy);
    30   virtual void FinishInternal();
    31   virtual Telemetry::ID SpeedHistogram();
    33 private:
    34   /* These functions will be called when the decoder has a decoded row,
    35    * frame size information, etc. */
    37   void      BeginGIF();
    38   void      BeginImageFrame(uint16_t aDepth);
    39   void      EndImageFrame();
    40   void      FlushImageData();
    41   void      FlushImageData(uint32_t fromRow, uint32_t rows);
    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);
    49   inline int ClearCode() const { return 1 << mGIFStruct.datasize; }
    51   int32_t mCurrentRow;
    52   int32_t mLastFlushedRow;
    54   uint32_t mOldColor;        // The old value of the transparent pixel
    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;
    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;
    66   gif_struct mGIFStruct;
    67 };
    69 } // namespace image
    70 } // namespace mozilla
    72 #endif

mercurial