Back to index

lightning-sunbird  0.9+nobinonly
nsImageBeOS.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Daniel Switkin, Mathias Agopian and Sergei Dolgov
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either of the GNU General Public License Version 2 or later (the "GPL"),
00027  * or 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 
00039 #ifndef nsImageBeOS_h___
00040 #define nsImageBeOS_h___
00041 
00042 #include "nsIImage.h"
00043 #include "nsPoint.h"
00044 class BBitmap;
00045 class BView;
00046 class nsImageBeOS : public nsIImage
00047 {
00048 public:
00049        nsImageBeOS();
00050        virtual ~nsImageBeOS();
00051        
00052        NS_DECL_ISUPPORTS
00053 
00054        // Vital stats
00055        virtual PRInt32 GetBytesPix() { return mNumBytesPixel; } 
00056        virtual PRInt32 GetHeight() { return mHeight; }
00057        virtual PRInt32 GetWidth() { return mWidth; }
00058        virtual PRUint8 *GetBits() { return mImageBits; }
00059        virtual void *GetBitInfo() { return nsnull; }
00060        virtual PRBool GetIsRowOrderTopToBottom() { return PR_TRUE; }
00061        virtual PRInt32 GetLineStride() { return mRowBytes; }
00062        
00063        virtual nsColorMap *GetColorMap() { return nsnull; }
00064 
00065        // The heavy lifting
00066        NS_IMETHOD Draw(nsIRenderingContext &aContext, nsIDrawingSurface* aSurface,
00067               PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
00068        NS_IMETHOD Draw(nsIRenderingContext &aContext, nsIDrawingSurface* aSurface,
00069               PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
00070               PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight);
00071 
00072        NS_IMETHOD DrawToImage(nsIImage *aDstImage, nscoord aDX, nscoord aDY,
00073               nscoord aDWidth, nscoord aDHeight);
00074        
00075        NS_IMETHOD DrawTile(nsIRenderingContext &aContext, nsIDrawingSurface* aSurface, 
00076               PRInt32 aSXOffset, PRInt32 aSYOffset, PRInt32 aPadX, PRInt32 aPadY,
00077               const nsRect &aTileRect); 
00078        
00079        virtual void ImageUpdated(nsIDeviceContext *aContext, PRUint8 aFlags,
00080               nsRect *aUpdateRect);
00081   virtual PRBool GetIsImageComplete();
00082        virtual nsresult Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth,
00083               nsMaskRequirements aMaskRequirements);
00084 
00085        virtual PRBool IsOptimized() { return mOptimized; }
00086        virtual nsresult Optimize(nsIDeviceContext *aContext);
00087        
00088        virtual PRBool GetHasAlphaMask() { return mAlphaBits != nsnull; }
00089        virtual PRUint8 *GetAlphaBits() { return mAlphaBits; }
00090        virtual PRInt32 GetAlphaLineStride() { return mAlphaRowBytes; }
00091        
00092        virtual PRInt8 GetAlphaDepth() { return mAlphaDepth; }
00093        
00094        NS_IMETHOD LockImagePixels(PRBool aMaskPixels);
00095        NS_IMETHOD UnlockImagePixels(PRBool aMaskPixels);
00096 
00097 private:
00098        void ComputePaletteSize(PRIntn nBitCount);
00099 
00100 protected:
00101        void CreateImage(nsIDrawingSurface* aSurface);
00102        nsresult BuildImage(nsIDrawingSurface* aDrawingSurface);
00103        
00104 private:
00105        BBitmap *mImage;
00106        BBitmap *mTileBitmap;
00107        PRUint8 *mImageBits;
00108        PRInt32 mWidth;
00109        PRInt32 mHeight;
00110        PRInt32 mDepth;
00111        PRInt32 mRowBytes;
00112        PRInt32 mSizeImage;
00113        
00114        // Keeps track of what part of image has been decoded
00115        PRInt32 mDecodedX1;
00116        PRInt32 mDecodedY1;
00117        PRInt32 mDecodedX2;
00118        PRInt32 mDecodedY2;
00119        
00120        // Alpha layer members
00121        PRUint8 *mAlphaBits;
00122        PRInt16 mAlphaRowBytes;
00123        PRInt8 mAlphaDepth;
00124        
00125        // Flags set by ImageUpdated
00126        PRUint8 mFlags;
00127        PRInt8 mNumBytesPixel;
00128        PRBool mImageCurrent;
00129        PRBool mOptimized;
00130 };
00131 
00132 #endif