2001-02-21 01:45:10 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
2012-05-21 15:12:37 +04:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2001-02-21 01:45:10 +03:00
|
|
|
|
2015-04-06 02:22:00 +03:00
|
|
|
#ifndef mozilla_image_decoders_nsGIFDecoder2_h
|
|
|
|
#define mozilla_image_decoders_nsGIFDecoder2_h
|
2001-02-21 01:45:10 +03:00
|
|
|
|
2010-08-23 06:30:46 +04:00
|
|
|
#include "Decoder.h"
|
2001-02-21 01:45:10 +03:00
|
|
|
|
|
|
|
#include "GIF2.h"
|
2014-11-14 20:59:00 +03:00
|
|
|
#include "nsCOMPtr.h"
|
2001-02-21 01:45:10 +03:00
|
|
|
|
2010-08-14 08:09:49 +04:00
|
|
|
namespace mozilla {
|
2012-01-06 20:02:27 +04:00
|
|
|
namespace image {
|
2010-08-14 08:09:49 +04:00
|
|
|
class RasterImage;
|
|
|
|
|
2001-02-21 01:45:10 +03:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// nsGIFDecoder2 Definition
|
|
|
|
|
2010-08-23 06:30:46 +04:00
|
|
|
class nsGIFDecoder2 : public Decoder
|
2001-02-21 01:45:10 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2015-01-16 02:11:35 +03:00
|
|
|
explicit nsGIFDecoder2(RasterImage* aImage);
|
2005-03-10 16:31:26 +03:00
|
|
|
~nsGIFDecoder2();
|
2001-05-31 18:25:33 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void WriteInternal(const char* aBuffer, uint32_t aCount) override;
|
|
|
|
virtual void FinishInternal() override;
|
|
|
|
virtual Telemetry::ID SpeedHistogram() override;
|
2010-08-23 06:30:46 +04:00
|
|
|
|
2007-06-25 20:41:21 +04:00
|
|
|
private:
|
2014-11-14 20:59:00 +03:00
|
|
|
// These functions will be called when the decoder has a decoded row,
|
|
|
|
// frame size information, etc.
|
2001-05-31 18:25:33 +04:00
|
|
|
|
2007-06-25 20:41:21 +04:00
|
|
|
void BeginGIF();
|
2015-01-11 22:43:32 +03:00
|
|
|
void BeginImageFrame(uint16_t aDepth);
|
2007-06-25 20:41:21 +04:00
|
|
|
void EndImageFrame();
|
2010-09-12 19:22:30 +04:00
|
|
|
void FlushImageData();
|
2012-08-22 19:56:38 +04:00
|
|
|
void FlushImageData(uint32_t fromRow, uint32_t rows);
|
2003-02-22 19:38:47 +03:00
|
|
|
|
2014-11-14 20:59:00 +03:00
|
|
|
nsresult GifWrite(const uint8_t* buf, uint32_t numbytes);
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t OutputRow();
|
2014-11-14 20:59:00 +03:00
|
|
|
bool DoLzw(const uint8_t* q);
|
2013-01-28 21:27:35 +04:00
|
|
|
bool SetHold(const uint8_t* buf, uint32_t count,
|
|
|
|
const uint8_t* buf2 = nullptr, uint32_t count2 = 0);
|
2003-02-22 19:38:47 +03:00
|
|
|
|
2007-06-25 20:41:21 +04:00
|
|
|
inline int ClearCode() const { return 1 << mGIFStruct.datasize; }
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mCurrentRow;
|
|
|
|
int32_t mLastFlushedRow;
|
2001-04-25 23:52:49 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mOldColor; // The old value of the transparent pixel
|
2009-07-22 08:20:01 +04:00
|
|
|
|
|
|
|
// The frame number of the currently-decoding frame when we're in the middle
|
|
|
|
// of decoding it, and -1 otherwise.
|
2014-06-18 18:54:59 +04:00
|
|
|
int32_t mCurrentFrameIndex;
|
2009-07-22 08:20:01 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint8_t mCurrentPass;
|
|
|
|
uint8_t mLastFlushedPass;
|
|
|
|
uint8_t mColorMask; // Apply this to the pixel to keep within colormap
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mGIFOpen;
|
|
|
|
bool mSawTransparency;
|
2001-02-21 01:45:10 +03:00
|
|
|
|
2007-06-25 20:41:21 +04:00
|
|
|
gif_struct mGIFStruct;
|
|
|
|
};
|
2002-09-18 03:05:27 +04:00
|
|
|
|
2012-01-06 20:02:27 +04:00
|
|
|
} // namespace image
|
2010-08-23 06:30:46 +04:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2015-04-06 02:22:00 +03:00
|
|
|
#endif // mozilla_image_decoders_nsGIFDecoder2_h
|