2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
2012-05-21 04:12:37 -07: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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef _nsGIFDecoder2_h
|
|
|
|
#define _nsGIFDecoder2_h
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
2010-08-22 19:30:46 -07:00
|
|
|
#include "Decoder.h"
|
2012-12-18 08:37:15 -08:00
|
|
|
#include "imgDecoderObserver.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#include "GIF2.h"
|
|
|
|
|
2010-08-13 21:09:49 -07:00
|
|
|
namespace mozilla {
|
2012-01-06 08:02:27 -08:00
|
|
|
namespace image {
|
2010-08-13 21:09:49 -07:00
|
|
|
class RasterImage;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// nsGIFDecoder2 Definition
|
|
|
|
|
2010-08-22 19:30:46 -07:00
|
|
|
class nsGIFDecoder2 : public Decoder
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2012-12-18 08:37:15 -08:00
|
|
|
nsGIFDecoder2(RasterImage &aImage, imgDecoderObserver* aObserver);
|
2007-03-22 10:30:00 -07:00
|
|
|
~nsGIFDecoder2();
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual void WriteInternal(const char* aBuffer, uint32_t aCount);
|
2010-09-12 08:22:30 -07:00
|
|
|
virtual void FinishInternal();
|
2011-09-22 13:25:56 -07:00
|
|
|
virtual Telemetry::ID SpeedHistogram();
|
2010-08-22 19:30:46 -07:00
|
|
|
|
2007-06-25 09:41:21 -07:00
|
|
|
private:
|
|
|
|
/* These functions will be called when the decoder has a decoded row,
|
|
|
|
* frame size information, etc. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-06-25 09:41:21 -07:00
|
|
|
void BeginGIF();
|
2012-08-22 08:56:38 -07:00
|
|
|
nsresult BeginImageFrame(uint16_t aDepth);
|
2007-06-25 09:41:21 -07:00
|
|
|
void EndImageFrame();
|
2010-09-12 08:22:30 -07:00
|
|
|
void FlushImageData();
|
2012-08-22 08:56:38 -07:00
|
|
|
void FlushImageData(uint32_t fromRow, uint32_t rows);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
nsresult GifWrite(const uint8_t * buf, uint32_t numbytes);
|
|
|
|
uint32_t OutputRow();
|
|
|
|
bool DoLzw(const uint8_t *q);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-06-25 09:41:21 -07:00
|
|
|
inline int ClearCode() const { return 1 << mGIFStruct.datasize; }
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mCurrentRow;
|
|
|
|
int32_t mLastFlushedRow;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t *mImageData; // Pointer to image data in either Cairo or 8bit format
|
|
|
|
uint32_t *mColormap; // Current colormap to be used in Cairo format
|
|
|
|
uint32_t mColormapSize;
|
|
|
|
uint32_t mOldColor; // The old value of the transparent pixel
|
2009-07-21 21:20:01 -07:00
|
|
|
|
|
|
|
// The frame number of the currently-decoding frame when we're in the middle
|
|
|
|
// of decoding it, and -1 otherwise.
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mCurrentFrame;
|
2009-07-21 21:20:01 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t mCurrentPass;
|
|
|
|
uint8_t mLastFlushedPass;
|
|
|
|
uint8_t mColorMask; // Apply this to the pixel to keep within colormap
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mGIFOpen;
|
|
|
|
bool mSawTransparency;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-06-25 09:41:21 -07:00
|
|
|
gif_struct mGIFStruct;
|
|
|
|
};
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-01-06 08:02:27 -08:00
|
|
|
} // namespace image
|
2010-08-22 19:30:46 -07:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|