epoc32/include/bitmap.h
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
equal deleted inserted replaced
3:e1b950c65cb4 4:837f303aceeb
     1 // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     7 //
     8 // Initial Contributors:
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
     9 // Nokia Corporation - initial contribution.
    10 //
    10 //
    11 // Contributors:
    11 // Contributors:
    23 #endif
    23 #endif
    24 #if !defined(__GDI_H__)
    24 #if !defined(__GDI_H__)
    25 #include <gdi.h>
    25 #include <gdi.h>
    26 #endif
    26 #endif
    27 
    27 
       
    28 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    29 #include <graphics/bitmapuid.h>
       
    30 #endif
       
    31 
    28 #ifdef _DEBUG
    32 #ifdef _DEBUG
    29 	#define SYMBIAN_DEBUG_FBS_LOCKHEAP
    33 	#define SYMBIAN_DEBUG_FBS_LOCKHEAP
    30 #endif
    34 #endif
    31 
       
    32 /**
       
    33 @internalComponent
       
    34 */
       
    35 const TUid KCBitwiseBitmapUid={268435520};
       
    36 const TUid KCBitwiseBitmapHardwareUid={0x10009a3d};
       
    37 const TUid KMultiBitmapFileImageUid={268435522};
       
    38 const TInt KCompressionBookMarkThreshold=0x2000;
       
    39 const TInt KNumBytesPerBitmapHandle = sizeof(TInt); 						// Bitmap handle is the size of a TInt
       
    40 const TInt KMaxBitmapHandleBufferSize = KNumBytesPerBitmapHandle * 2000; 	// Maximum size of buffer to store all bitmap handles. 
       
    41 
    35 
    42 //Forward declarations
    36 //Forward declarations
    43 class CChunkPile;
    37 class CChunkPile;
    44 class TCompressionBookMark;
    38 class TCompressionBookMark;
       
    39 class CFbsRasterizer;
    45 
    40 
    46 /** 
    41 /** 
    47 Defines the types of file compression. 
    42 Defines the types of file compression. 
    48 @publishedAll
    43 @publishedAll
    49 @released
    44 @released
    64 	EThirtyTwoUBitRLECompression,
    59 	EThirtyTwoUBitRLECompression,
    65 	/** File is compressed using thirty two bit run-length encoding compression from 32-bit bitmap buffer. */
    60 	/** File is compressed using thirty two bit run-length encoding compression from 32-bit bitmap buffer. */
    66 	EThirtyTwoABitRLECompression,
    61 	EThirtyTwoABitRLECompression,
    67 	/** File is compressed as a palette plus reduced bit-per-pixel.  Only applicable to bitmaps already loaded in RAM. */
    62 	/** File is compressed as a palette plus reduced bit-per-pixel.  Only applicable to bitmaps already loaded in RAM. */
    68 	EGenericPaletteCompression,
    63 	EGenericPaletteCompression,
       
    64 	/** Extended bitmap. Data format is proprietary to licensee. */
       
    65 	EProprietaryCompression,
    69 	//Insert new enum items here!
    66 	//Insert new enum items here!
    70 	ERLECompressionLast = 255
    67 	ERLECompressionLast = 255
    71 	};
    68 	};
    72 
    69 
    73 /** 
    70 /** 
    84 	/** File is compressed as a palette plus reduced bit-per-pixel, with automatic fallback to RLE if bitmap is not suitable*/
    81 	/** File is compressed as a palette plus reduced bit-per-pixel, with automatic fallback to RLE if bitmap is not suitable*/
    85 	EPaletteCompressionWithRLEFallback
    82 	EPaletteCompressionWithRLEFallback
    86 	};
    83 	};
    87 
    84 
    88 /**
    85 /**
    89 @internalTechnology
    86 WARNING: Typedef for internal use ONLY. Compatibility is not guaranteed in future releases.
    90 */
    87 @publishedAll
       
    88 @released
       
    89  */
    91 typedef void (*TAssignFunction)(TUint8*& aDestPtr, TUint32 aColor);
    90 typedef void (*TAssignFunction)(TUint8*& aDestPtr, TUint32 aColor);
    92 
       
    93 /**
    91 /**
    94 @internalTechnology
    92 WARNING: Typedef for internal use ONLY. Compatibility is not guaranteed in future releases.
    95 */
    93 @publishedAll
       
    94 @released
       
    95  */
    96 typedef void (*TDecodeFunction)(TUint8* aDataPtr, TUint32* aPalettePtr, TUint8*& aDestPtr, TAssignFunction aAssignFunction);
    96 typedef void (*TDecodeFunction)(TUint8* aDataPtr, TUint32* aPalettePtr, TUint8*& aDestPtr, TAssignFunction aAssignFunction);
    97 
       
    98 class TRgb24bit
       
    99 /**
       
   100 @internalComponent
       
   101 */
       
   102 	{
       
   103 public:
       
   104 	TUint8 iRed;
       
   105 	TUint8 iGreen;
       
   106 	TUint8 iBlue;
       
   107 	};
       
   108 
    97 
   109 /** 
    98 /** 
   110 Contains information about the bitmap when streaming bitmaps to stores. 
    99 Contains information about the bitmap when streaming bitmaps to stores. 
   111 @publishedAll
   100 @publishedAll
   112 @released
   101 @released
   157 	TInt iPaletteEntries;
   146 	TInt iPaletteEntries;
   158 	/** The type of compression used to store the bitmap. */
   147 	/** The type of compression used to store the bitmap. */
   159 	TBitmapfileCompression iCompression;
   148 	TBitmapfileCompression iCompression;
   160 	};
   149 	};
   161 
   150 
       
   151 /**
       
   152 WARNING: Class for internal use ONLY.  Compatibility is not guaranteed in future releases.
       
   153 
       
   154 @publishedAll
       
   155 @released 
       
   156  */
   162 class TLineScanningPosition
   157 class TLineScanningPosition
   163 /**
   158 	{
   164 @internalTechnology
   159 public:
   165 */
   160 	inline TLineScanningPosition(TUint32* aSrcDataPtr);
   166 	{
       
   167 public:
       
   168 	TLineScanningPosition(TUint32* aSrcDataPtr): iSrcDataPtr((TUint8*)aSrcDataPtr), iCursorPos(0), iScanLineBuffer(NULL) {}
       
   169 public:
   161 public:
   170 	TUint8* iSrcDataPtr;
   162 	TUint8* iSrcDataPtr;
   171 	TInt iCursorPos;
   163 	TInt iCursorPos;
   172 	HBufC8* iScanLineBuffer;
   164 	HBufC8* iScanLineBuffer;
       
   165 	CFbsRasterizer* const iRasterizer;
   173 	};
   166 	};
   174 
   167 
   175 class CShiftedFileStore;
   168 class CShiftedFileStore;
       
   169 
   176 /**
   170 /**
   177 BitGdi bitmap class (pseudo-CXxx class).
   171 BitGdi bitmap class (pseudo-CXxx class).
   178 @internalComponent
   172 WARNING: Class for internal use ONLY.  Compatibility is not guaranteed in future releases.
   179 @released
   173 @released
   180 */
   174 */
   181 class CBitwiseBitmap
   175 class CBitwiseBitmap
   182 	{
   176 	{
   183 	friend class CFbTop;
   177 	friend class CFbTop;
   198 	IMPORT_C TDisplayMode DisplayMode() const;
   192 	IMPORT_C TDisplayMode DisplayMode() const;
   199 	IMPORT_C TInt HorizontalTwipsToPixels(TInt aTwips) const;
   193 	IMPORT_C TInt HorizontalTwipsToPixels(TInt aTwips) const;
   200 	IMPORT_C TInt VerticalTwipsToPixels(TInt aTwips) const;
   194 	IMPORT_C TInt VerticalTwipsToPixels(TInt aTwips) const;
   201 	IMPORT_C TInt HorizontalPixelsToTwips(TInt aPixels) const;
   195 	IMPORT_C TInt HorizontalPixelsToTwips(TInt aPixels) const;
   202 	IMPORT_C TInt VerticalPixelsToTwips(TInt aPixels) const;
   196 	IMPORT_C TInt VerticalPixelsToTwips(TInt aPixels) const;
   203 	IMPORT_C void GetPixel(TRgb& aColor,const TPoint& aPos,TUint32* aBase) const;
   197 	IMPORT_C void GetPixel(TRgb& aColor,const TPoint& aPos,TUint32* aBase, CFbsRasterizer* aRasterizer) const;
   204 	IMPORT_C TInt GetScanLinePtr(TUint32*& aSlptr, TPoint& aPixel,TInt aLength, TUint32* aBase, TLineScanningPosition& aLineScanningPosition) const;
   198 	IMPORT_C TInt GetScanLinePtr(TUint32*& aSlptr, TPoint& aPixel,TInt aLength, TUint32* aBase, TLineScanningPosition& aLineScanningPosition) const;
   205 	IMPORT_C TInt GetScanLinePtr(TUint32*& aSlptr, TInt& aLength, TPoint& aPixel,TUint32* aBase, TLineScanningPosition& aLineScanningPosition) const;
   199 	IMPORT_C TInt GetScanLinePtr(TUint32*& aSlptr, TInt& aLength, TPoint& aPixel,TUint32* aBase, TLineScanningPosition& aLineScanningPosition) const;
   206 	IMPORT_C void GetScanLine(TDes8& aBuf,const TPoint& aPixel,TInt aLength,TBool aDither,const TPoint& aDitherOffset,TDisplayMode aDispMode,TUint32* aBase, TLineScanningPosition& aLineScanningPosition) const;
   200 	IMPORT_C void GetScanLine(TDes8& aBuf,const TPoint& aPixel,TInt aLength,TBool aDither,const TPoint& aDitherOffset,TDisplayMode aDispMode,TUint32* aBase, TLineScanningPosition& aLineScanningPosition) const;
   207 	IMPORT_C void GetScanLine(TUint32*& aSlptr, TDes8& aBuf,const TPoint& aPixel,TInt aLength,TBool aDither,const TPoint& aDitherOffset,TDisplayMode aDispMode) const;
   201 	IMPORT_C void GetScanLine(TUint32*& aSlptr, TDes8& aBuf,const TPoint& aPixel,TInt aLength,TBool aDither,const TPoint& aDitherOffset,TDisplayMode aDispMode) const;
   208 	IMPORT_C void GetScanLine(TDes8& aBuf,const TPoint& aPixel,TInt aLength,TBool aDither,const TPoint& aDitherOffset,TDisplayMode aDispMode,TUint32* aBase) const;
   202 	IMPORT_C void GetScanLine(TDes8& aBuf,const TPoint& aPixel,TInt aLength,TBool aDither,const TPoint& aDitherOffset,TDisplayMode aDispMode,TUint32* aBase) const;
   209 	IMPORT_C void GetVerticalScanLine(TDes8& aBuf,TInt aX,TBool aDither,const TPoint& aDitherOffset,TDisplayMode aDispMode,TUint32* aBase) const;
   203 	IMPORT_C void GetVerticalScanLine(TDes8& aBuf,TInt aX,TBool aDither,const TPoint& aDitherOffset,TDisplayMode aDispMode,TUint32* aBase, CFbsRasterizer* aRasterizer) const;
   210 	IMPORT_C void StretchScanLine(TDes8& aBuf,const TPoint& aPixel,TInt aClipStrchX,TInt aClipStrchLen,TInt aStretchLength,TInt aOrgX,TInt aOrgLen,const TPoint& aDitherOffset,TDisplayMode aDispMode,TUint32* aBase) const;
   204 	IMPORT_C void StretchScanLine(TDes8& aBuf,const TPoint& aPixel,TInt aClipStrchX,TInt aClipStrchLen,TInt aStretchLength,TInt aOrgX,TInt aOrgLen,const TPoint& aDitherOffset,TDisplayMode aDispMode,TUint32* aBase) const;
   211 	IMPORT_C void StretchScanLine(TDes8& aBuf,const TPoint& aPixel,TInt aClipStrchX,TInt aClipStrchLen,TInt aStretchLength,TInt aOrgX,TInt aOrgLen,const TPoint& aDitherOffset,TDisplayMode aDispMode,TUint32* aBase, TLineScanningPosition& aLineScanningPosition) const;
   205 	IMPORT_C void StretchScanLine(TDes8& aBuf,const TPoint& aPixel,TInt aClipStrchX,TInt aClipStrchLen,TInt aStretchLength,TInt aOrgX,TInt aOrgLen,const TPoint& aDitherOffset,TDisplayMode aDispMode,TUint32* aBase, TLineScanningPosition& aLineScanningPosition) const;
   212 	IMPORT_C TUint32* ScanLineAddress(TUint32* aBase,TUint aY) const;
   206 	IMPORT_C TUint32* ScanLineAddress(TUint32* aBase,TUint aY) const;
   213 	IMPORT_C TBool IsMonochrome(TUint32* aBase) const;
   207 	IMPORT_C TBool IsMonochrome(TUint32* aBase) const;
   214 	IMPORT_C TBool IsLargeBitmap() const;
   208 	IMPORT_C TBool IsLargeBitmap() const;
   226 	void operator delete(TAny*, TAny*) {}     // This function exists only to prevent a compiler warning
   220 	void operator delete(TAny*, TAny*) {}     // This function exists only to prevent a compiler warning
   227 	IMPORT_C CBitwiseBitmap(RHeap* aHeap,CChunkPile* aPile);
   221 	IMPORT_C CBitwiseBitmap(RHeap* aHeap,CChunkPile* aPile);
   228 	IMPORT_C ~CBitwiseBitmap();
   222 	IMPORT_C ~CBitwiseBitmap();
   229 	IMPORT_C void Reset();
   223 	IMPORT_C void Reset();
   230 	IMPORT_C TInt Construct(const TSize& aSize,TDisplayMode aDispMode,TUid aCreatorUid);
   224 	IMPORT_C TInt Construct(const TSize& aSize,TDisplayMode aDispMode,TUid aCreatorUid);
       
   225 	IMPORT_C TInt ConstructExtended(const TSize& aSize, TDisplayMode aDispMode, TUid aType, TInt aDataSize);
   231 	IMPORT_C void ConstructL(RFs& aFs,const TDesC& aFilename,TInt32 aId,TUint aFileOffset);
   226 	IMPORT_C void ConstructL(RFs& aFs,const TDesC& aFilename,TInt32 aId,TUint aFileOffset);
   232 	IMPORT_C void ConstructL(RFile& aFile,TInt32 aId,TUint aFileOffset);
   227 	IMPORT_C void ConstructL(RFile& aFile,TInt32 aId,TUint aFileOffset);
   233 	IMPORT_C void ConstructL(CShiftedFileStore* aFileStore,TStreamId aStreamId);
   228 	IMPORT_C void ConstructL(CShiftedFileStore* aFileStore,TStreamId aStreamId);
   234 	IMPORT_C TInt CopyData(const CBitwiseBitmap& aSourceBitmap);
   229 	IMPORT_C TInt CopyData(const CBitwiseBitmap& aSourceBitmap);
   235 private:
   230 private:
   338 	static void CheckHeaderIsValidL(const SEpocBitmapHeader& aHeader);
   333 	static void CheckHeaderIsValidL(const SEpocBitmapHeader& aHeader);
   339 	static TInt CompressedFormatInfo(TDisplayMode aDispMode, TInt& aBytesPerPack, TInt& aBytesPerCompressed);
   334 	static TInt CompressedFormatInfo(TDisplayMode aDispMode, TInt& aBytesPerPack, TInt& aBytesPerCompressed);
   340 	static void BitmapFill32(TUint32* aDestPtr32, TInt aCount, TUint32 aValue32);
   335 	static void BitmapFill32(TUint32* aDestPtr32, TInt aCount, TUint32 aValue32);
   341 	static inline void BitmapFill16(TUint16* aDestPtr16, TInt aCount, TUint16 aValue16);
   336 	static inline void BitmapFill16(TUint16* aDestPtr16, TInt aCount, TUint16 aValue16);
   342 private:
   337 private:
       
   338 	struct TExtra
       
   339 		{
       
   340 #ifdef SYMBIAN_DEBUG_FBS_LOCKHEAP
       
   341 		TInt iLockCount; // number of calls to CFbsBitmap::LockHeap() not balanced by calls to CFbsBitmap::UnlockHeap()
       
   342 		TThreadId iThreadId; // id of thread that called CFbsBitmap::LockHeap() if any
       
   343 #endif
       
   344 		TInt64 iSerialNumber; // serial number of bitmap which is unique to the whole FBServ
       
   345 		TInt iTouchCount; // number of calls to TouchBitmap()i.e. number of times bitmap has been changed
       
   346 		};
       
   347 	inline TExtra* Extra() const; // only for bitmaps created in RAM
       
   348 private:
   343 	TUid iUid;
   349 	TUid iUid;
   344 	struct TSettings
   350 	struct TSettings
   345 		{
   351 		{
   346 		TSettings(TDisplayMode aDisplayMode);
   352 		TSettings(TDisplayMode aDisplayMode);
   347 		void SetDisplayModes(TDisplayMode aDisplayMode);
   353 		void SetDisplayModes(TDisplayMode aDisplayMode);
   348 		void SetCurrentDisplayMode(TDisplayMode aDisplayMode);
   354 		void SetCurrentDisplayMode(TDisplayMode aDisplayMode);
   349 		TDisplayMode CurrentDisplayMode() const;
   355 		TDisplayMode CurrentDisplayMode() const;
   350 		TDisplayMode InitialDisplayMode() const;
   356 		TDisplayMode InitialDisplayMode() const;
   351 		inline void SetDirtyBitmap();
   357 		inline void SetDirtyBitmap();
   352 		inline TBool IsDirtyBitmap() const;
   358 		inline TBool IsDirtyBitmap() const;
       
   359 		inline void SetVolatileBitmap();
       
   360 		inline TBool IsVolatileBitmap() const;
   353 		enum
   361 		enum
   354 			{
   362 			{
   355 			EBitmapFlagDirty = 0x10000 // set in the old bitmap when a re-allocating operation has created a new bitmap
   363 			EBitmapFlagDirty = 0x00010000, // set in the old bitmap when a re-allocating operation has created a new bitmap
       
   364 			EBitmapFlagVolatile = 0x00020000, // set when DataAddress() has been called but BeginDataAccess() has not
   356 			};
   365 			};
   357 		TUint32 iData;
   366 		TUint32 iData;
   358 		} iSettings;
   367 		} iSettings;
   359 	RHeap* iHeap;
   368 	RHeap* iHeap;
   360 	CChunkPile* iPile;
   369 	CChunkPile* iPile;
   361 	TInt iByteWidth;
   370 	TInt iByteWidth;
   362 	SEpocBitmapHeader iHeader;
   371 	SEpocBitmapHeader iHeader;
   363 	struct TExtra // used only in builds with SYMBIAN_DEBUG_FBS_LOCKHEAP defined
   372 	TInt iSpare;
   364 		{
       
   365 		TInt iLockCount; // number of calls to CFbsBitmap::LockHeap() not balanced by calls to CFbsBitmap::UnlockHeap()
       
   366 		TThreadId iThreadId; // id of thread that called CFbsBitmap::LockHeap() if any
       
   367 		}
       
   368 		*iExtra; // only for bitmaps created in RAM, set to 0xFFFFFFFF for ROM bitmaps by the tool chain
       
   369 	TInt iDataOffset; // offset in bytes from "this" or from base of bitmap chunk, or hardware bitmap handle
   373 	TInt iDataOffset; // offset in bytes from "this" or from base of bitmap chunk, or hardware bitmap handle
   370 	TBool iIsCompressedInRAM; //flag indicating whether CompressData has been called
   374 	TBool iIsCompressedInRAM; //flag indicating whether CompressData has been called
   371 	};
   375 	};
   372 
   376 
   373 #endif
   377 #endif