Back to index

lightning-sunbird  0.9+nobinonly
nsGIFDecoder2.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
00002  *
00003  * ***** BEGIN LICENSE BLOCK *****
00004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00005  *
00006  * The contents of this file are subject to the Mozilla Public License Version
00007  * 1.1 (the "License"); you may not use this file except in compliance with
00008  * the License. You may obtain a copy of the License at
00009  * http://www.mozilla.org/MPL/
00010  *
00011  * Software distributed under the License is distributed on an "AS IS" basis,
00012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013  * for the specific language governing rights and limitations under the
00014  * License.
00015  *
00016  * The Original Code is mozilla.org code.
00017  *
00018  * The Initial Developer of the Original Code is
00019  * Netscape Communications Corporation.
00020  * Portions created by the Initial Developer are Copyright (C) 2001
00021  * the Initial Developer. All Rights Reserved.
00022  *
00023  * Contributor(s):
00024  *   Chris Saari <saari@netscape.com>
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either the GNU General Public License Version 2 or later (the "GPL"), or
00028  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00029  * in which case the provisions of the GPL or the LGPL are applicable instead
00030  * of those above. If you wish to allow use of your version of this file only
00031  * under the terms of either the GPL or the LGPL, and not to allow others to
00032  * use your version of this file under the terms of the MPL, indicate your
00033  * decision by deleting the provisions above and replace them with the notice
00034  * and other provisions required by the GPL or the LGPL. If you do not delete
00035  * the provisions above, a recipient may use your version of this file under
00036  * the terms of any one of the MPL, the GPL or the LGPL.
00037  *
00038  * ***** END LICENSE BLOCK ***** */
00039 
00040 #ifndef _nsGIFDecoder2_h
00041 #define _nsGIFDecoder2_h
00042 
00043 #include "nsCOMPtr.h"
00044 #include "imgIDecoder.h"
00045 #include "imgContainerGIF.h"
00046 #include "imgIDecoderObserver.h"
00047 #include "gfxIImageFrame.h"
00048 
00049 #include "GIF2.h"
00050 
00051 #define NS_GIFDECODER2_CID \
00052 { /* 797bec5a-1dd2-11b2-a7f8-ca397e0179c4 */         \
00053      0x797bec5a,                                     \
00054      0x1dd2,                                         \
00055      0x11b2,                                         \
00056     {0xa7, 0xf8, 0xca, 0x39, 0x7e, 0x01, 0x79, 0xc4} \
00057 }
00058 
00060 // nsGIFDecoder2 Definition
00061 
00062 class nsGIFDecoder2 : public imgIDecoder   
00063 {
00064 public:
00065   NS_DECL_ISUPPORTS
00066   NS_DECL_IMGIDECODER
00067 
00068   nsGIFDecoder2();
00069   ~nsGIFDecoder2();
00070   
00071   nsresult ProcessData(unsigned char *data, PRUint32 count, PRUint32 *_retval);
00072 
00073   NS_METHOD FlushImageData();
00074 
00075   /* These functions will be called when the decoder has a decoded
00076    * rows, frame size information, etc. */
00077 
00078   static int BeginGIF(
00079     void* aClientData,
00080     PRUint32 aLogicalScreenWidth, 
00081     PRUint32 aLogicalScreenHeight,
00082     PRUint8  aBackgroundRGBIndex);
00083     
00084   static int EndGIF(
00085     void*    aClientData,
00086     int      aAnimationLoopCount);
00087   
00088   static int BeginImageFrame(
00089     void*    aClientData,
00090     PRUint32 aFrameNumber,   /* Frame number, 1-n */
00091     PRUint32 aFrameXOffset,  /* X offset in logical screen */
00092     PRUint32 aFrameYOffset,  /* Y offset in logical screen */
00093     PRUint32 aFrameWidth,    
00094     PRUint32 aFrameHeight);
00095   
00096   static int EndImageFrame(
00097     void* aClientData,
00098     PRUint32 aFrameNumber,
00099     PRUint32 aDelayTimeout);
00100   
00101   static int HaveDecodedRow(
00102     void* aClientData,
00103     PRUint8* aRowBufPtr,   /* Pointer to single scanline temporary buffer */
00104     int aRow,              /* Row number? */
00105     int aDuplicateCount,   /* Number of times to duplicate the row? */
00106     int aInterlacePass);
00107 
00108 private:
00109   nsCOMPtr<imgIContainer> mImageContainer;
00110   nsCOMPtr<gfxIImageFrame> mImageFrame;
00111   nsCOMPtr<imgIDecoderObserver> mObserver; // this is just qi'd from mRequest for speed
00112   PRInt32 mCurrentRow;
00113   PRInt32 mLastFlushedRow;
00114 
00115   gif_struct *mGIFStruct;
00116   
00117   PRUint8 *mAlphaLine;
00118   PRUint8 *mRGBLine;
00119   PRUint32 mRGBLineMaxSize;
00120   PRUint32 mAlphaLineMaxSize;
00121   PRUint8 mBackgroundRGBIndex;
00122   PRUint8 mCurrentPass;
00123   PRUint8 mLastFlushedPass;
00124   PRPackedBool mGIFOpen;
00125 };
00126 
00127 void nsGifShutdown();
00128 
00129 #endif