Back to index

lightning-sunbird  0.9+nobinonly
imgContainerGIF.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  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either the GNU General Public License Version 2 or later (the "GPL"), or
00027  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00048 #ifndef _imgContainerGIF_h_
00049 #define _imgContainerGIF_h_
00050 
00051 #include "imgIContainerObserver.h"
00052 #include "imgIContainer.h"
00053 #include "nsCOMArray.h"
00054 #include "nsCOMPtr.h"
00055 #include "nsITimer.h"
00056 #include "imgIDecoderObserver.h"
00057 #include "gfxIImageFrame.h"
00058 #include "nsWeakReference.h"
00059 
00060 #define NS_GIFCONTAINER_CID \
00061 { /* da72e7ee-4821-4452-802d-5eb2d865dd3c */         \
00062      0xda72e7ee,                                     \
00063      0x4821,                                         \
00064      0x4452,                                         \
00065     {0x80, 0x2d, 0x5e, 0xb2, 0xd8, 0x65, 0xdd, 0x3c} \
00066 }
00067 
00068 
00127 class imgContainerGIF : public imgIContainer,
00128                         public nsITimerCallback
00129 {
00130 public:
00131   NS_DECL_ISUPPORTS
00132   NS_DECL_IMGICONTAINER
00133   NS_DECL_NSITIMERCALLBACK
00134 
00135   imgContainerGIF();
00136   virtual ~imgContainerGIF();
00137 
00138 private:
00142   enum {
00143     DISPOSE_CLEAR_ALL       = -1, 
00144 
00145     DISPOSE_NOT_SPECIFIED    = 0, 
00146     DISPOSE_KEEP             = 1, 
00147     DISPOSE_CLEAR            = 2, 
00148     DISPOSE_RESTORE_PREVIOUS = 3  
00149   };
00150 
00151   inline gfxIImageFrame* inlinedGetCurrentFrame() {
00152     if (mLastCompositedFrameIndex == mCurrentAnimationFrameIndex)
00153       return mCompositingFrame;
00154 
00155     return mFrames.SafeObjectAt(mCurrentAnimationFrameIndex);
00156   }
00157 
00167   nsresult DoComposite(gfxIImageFrame** aFrameToUse, nsIntRect* aDirtyRect,
00168                        gfxIImageFrame* aPrevFrame,
00169                        gfxIImageFrame* aNextFrame,
00170                        PRInt32 aNextFrameIndex);
00171 
00182   void BuildCompositeMask(gfxIImageFrame* aCompositingFrame,
00183                           gfxIImageFrame* aOverlayFrame);
00184 
00192   void SetMaskVisibility(gfxIImageFrame *aFrame, PRBool aVisible);
00194   void SetMaskVisibility(gfxIImageFrame *aFrame,
00195                          PRInt32 aX, PRInt32 aY,
00196                          PRInt32 aWidth, PRInt32 aHeight,
00197                          PRBool aVisible);
00199   void SetMaskVisibility(gfxIImageFrame *aFrame,
00200                          nsIntRect &aRect, PRBool aVisible) {
00201     SetMaskVisibility(aFrame, aRect.x, aRect.y,
00202                       aRect.width, aRect.height, aVisible);
00203   }
00204 
00211   void BlackenFrame(gfxIImageFrame* aFrame);
00213   void BlackenFrame(gfxIImageFrame* aFrame,
00214                     PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
00216   inline void BlackenFrame(gfxIImageFrame* aFrame, nsIntRect &aRect) {
00217     BlackenFrame(aFrame, aRect.x, aRect.y, aRect.width, aRect.height);
00218   }
00219 
00221   static PRBool CopyFrameImage(gfxIImageFrame *aSrcFrame,
00222                                gfxIImageFrame *aDstFrame);
00223 
00224 
00226   nsWeakPtr                  mObserver;
00228   nsCOMArray<gfxIImageFrame> mFrames;
00229 
00231   nsIntSize                  mSize;
00233   nsIntRect                  mFirstFrameRefreshArea;
00234 
00235   PRInt32                    mCurrentDecodingFrameIndex; // 0 to numFrames-1
00236   PRInt32                    mCurrentAnimationFrameIndex; // 0 to numFrames-1
00238   PRInt32                    mLastCompositedFrameIndex;
00241   PRBool                     mDoneDecoding;
00242 
00243 
00245   PRBool                     mAnimating;
00247   PRUint16                   mAnimationMode;
00249   PRInt32                    mLoopCount;
00250 
00252   nsCOMPtr<nsITimer>         mTimer;
00253 
00262   nsCOMPtr<gfxIImageFrame>   mCompositingFrame;
00263 
00270   nsCOMPtr<gfxIImageFrame>   mCompositingPrevFrame;
00271 };
00272 
00273 #endif /* __imgContainerGIF_h__ */