fbs/fontandbitmapserver/sfbs/UTILS.H
changeset 187 9f66f99ee56f
parent 36 01a6848ebfd7
equal deleted inserted replaced
103:2717213c588a 187:9f66f99ee56f
     1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 1998-2010 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 "Eclipse Public License v1.0"
     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.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    18 
    18 
    19 #include <e32std.h>
    19 #include <e32std.h>
    20 #include <gdi.h>
    20 #include <gdi.h>
    21 #include <fntstore.h>
    21 #include <fntstore.h>
    22 #include <bitmap.h>
    22 #include <bitmap.h>
    23 
    23 #include <sgresource/sgimage.h>
    24 
    24 
       
    25 class RFbsSession;
    25 
    26 
    26 /**
    27 /**
    27 @internalComponent
    28 @internalComponent
    28 */ 
    29 */ 
    29 _LIT(KFBSERVPanicCategory,"FBSERV");
    30 _LIT(KFBSERVPanicCategory,"FBSERV");
    41 /**
    42 /**
    42 @internalComponent
    43 @internalComponent
    43 */
    44 */
    44 enum TFbsPanic
    45 enum TFbsPanic
    45 	{
    46 	{
    46 	EFbsPanicNoConnection=1,
    47 	EFbsPanicNoConnection = 1,
    47 	EFbsPanicBadConnection,
    48 	EFbsPanicBadConnection = 2,
    48 	EFbsPanicUnknownMessage,
    49 	EFbsPanicUnknownMessage = 3,
    49 	EFbsPanicActiveSchedulerError,
    50 	EFbsPanicActiveSchedulerError = 4,
    50 	EFbsPanicStartupFailed,
    51 	EFbsPanicStartupFailed = 5,
    51 	EFbsTypefaceStoreError,
    52 	EFbsTypefaceStoreError = 6,
    52 	EFbsFontCreateFailed,
    53 	EFbsFontCreateFailed = 7,
    53 	EFbsFontAddressViolation,
    54 	EFbsFontAddressViolation = 8,
    54 	EFbsBitmapInvalidFormat,
    55 	EFbsBitmapInvalidFormat = 9,
    55 	EFbsBitmapInvalidMode,
    56 	EFbsBitmapInvalidMode = 10,
    56 	EFbsBitmapInvalidCompression,
    57 	EFbsBitmapInvalidCompression = 11,
    57 	EFbsBitmapDecompressionError,
    58 	EFbsBitmapDecompressionError = 12,
    58 	EFbsPanicChunkError,
    59 	EFbsPanicChunkError = 13,
    59 	EFbsColor256UtilError,
    60 	EFbsColor256UtilError = 14,
    60 	EFbsHardwareBitmapError,
    61 	EFbsHardwareBitmapError = 15,
    61 	EFbsNotSupportedForCompression,
    62 	EFbsNotSupportedForCompression = 16,
    62 	EFbsBitmapAlignment,
    63 	EFbsBitmapAlignment = 17,
    63 	EFbsBitmapInvalidScanLinePtr,
    64 	EFbsBitmapInvalidScanLinePtr = 18,
    64 	EFbsBitmapInvalidMode2,
    65 	EFbsBitmapInvalidMode2 = 19,
    65 	EFbsBitmapInvalidMode3,
    66 	EFbsBitmapInvalidMode3 = 20,
    66 	EFbsBitmapSwappingImpossible,
    67 	EFbsBitmapSwappingImpossible = 21,
    67 	EFbsPanicBadHeapLock,
    68 	EFbsPanicBadHeapLock = 22,
    68 	EFbsShaperNotYetCalled,
    69 	EFbsShaperNotYetCalled = 23,
    69 	EFbsShaperInvalidArguments,
    70 	EFbsShaperInvalidArguments = 24,
    70 	EFbsInvalidCompressionThreshold,
    71 	EFbsInvalidCompressionThreshold = 25,
    71 	EFbsTypefaceIndexOutOfRange,
    72 	EFbsTypefaceIndexOutOfRange = 26,
    72 	EFbsPanicBitmapDataCopy,
    73 	EFbsPanicBitmapDataCopy = 27,
    73 	EFbsPanicBitmapReadOnly,
    74 	EFbsPanicBitmapReadOnly = 28,
    74 	EFbsPanicInvalidBitmapType
    75 	EFbsPanicFontNullHandle = 29,
       
    76     EFbsPanicGlyphDataIteratorClosed = 31,
       
    77 	EFbsPanicGlyphMetricsArrayOutOfBounds = 32,
       
    78 	EFbsPanicGlyphDataIteratorIndexOutOfRange = 33,
       
    79 	EFbsPanicInvalidBitmapType = 35,
       
    80 	EFbsPanicGlyphAtlasInconsistentState = 36,
       
    81 	EFbsPanicGlyphDataIteratorFailedToOpenImage = 37,
       
    82 	EFbsPanicGlyphDataIteratorInvalidState = 39,
       
    83 	EFbsPanicGlyphMetricsArrayInvalidState = 40,
    75 	};
    84 	};
    76 
    85 
    77 class TScanLine
    86 class TScanLine
    78 /**
    87 /**
    79 @internalComponent
    88 @internalComponent
   123 class TSizeInfo
   132 class TSizeInfo
   124 /**
   133 /**
   125 @internalComponent
   134 @internalComponent
   126 */
   135 */
   127 	{
   136 	{
   128 	public:
   137 public:
   129 		TSizeInfo(){}
   138 	TSizeInfo(){}
   130 		TSizeInfo(TInt aMaxHeight,TSize aDevSize):iMaxHeight(aMaxHeight),iDevSize(aDevSize) {}
   139 	TSizeInfo(TInt aMaxHeight,TSize aDevSize):iMaxHeight(aMaxHeight),iDevSize(aDevSize) {}
   131 
   140 
   132 	TInt iMaxHeight;
   141 	TInt iMaxHeight;
   133 	TSize iDevSize;
   142 	TSize iDevSize;
   134 	};
   143 	};
   135 
   144 
   180 	void DoFree(TUint8* aCell, RPointerArray<TUint8>& aCells, RArray<TInt>& aFreeCellLinks, TBool aLarge);
   189 	void DoFree(TUint8* aCell, RPointerArray<TUint8>& aCells, RArray<TInt>& aFreeCellLinks, TBool aLarge);
   181 	TInt GrowSmallSection(TInt aSize, TInt aLastFreeCell);
   190 	TInt GrowSmallSection(TInt aSize, TInt aLastFreeCell);
   182 	void ShrinkSmallSection(TInt aShrinkBy);
   191 	void ShrinkSmallSection(TInt aShrinkBy);
   183 private:
   192 private:
   184 	RChunk iChunk;
   193 	RChunk iChunk;
   185 	TInt iPageSize, iPageMask;
   194 	TInt iPageSize;
       
   195 	TInt iPageMask;
   186 	RPointerArray<TUint8> iSmallCells; // last address is not a cell but the top of the small section
   196 	RPointerArray<TUint8> iSmallCells; // last address is not a cell but the top of the small section
   187 	RArray<TInt> iFreeSmallCellLinks; // index of Nth free small cell is element 0 + element 1 + ... + element N-1
   197 	RArray<TInt> iFreeSmallCellLinks; // index of Nth free small cell is element 0 + element 1 + ... + element N-1
   188 	TInt iLargeSectionBottom; // boundary between small & large sections
   198 	TInt iLargeSectionBottom; // boundary between small & large sections
   189 	RPointerArray<TUint8> iLargeCells; // last address is not a cell but the top of the large section
   199 	RPointerArray<TUint8> iLargeCells; // last address is not a cell but the top of the large section
   190 	RArray<TInt> iFreeLargeCellLinks; // index of Nth free large cell is element 0 + element 1 + ... + element N-1
   200 	RArray<TInt> iFreeLargeCellLinks; // index of Nth free large cell is element 0 + element 1 + ... + element N-1
   262 public:
   272 public:
   263     TInt iOffset;
   273     TInt iOffset;
   264     TInt iLen;
   274     TInt iLen;
   265     };
   275     };
   266 
   276 
       
   277 /**
       
   278 Maximum number of glyphs to be sent to server/received from client at a time, 
       
   279 when retrieval of glyphs is necessary for implementation of RFbsGlyphDataIterator.
       
   280 */
       
   281 const TInt KMaxGlyphBatchSize = 8;
       
   282 
       
   283 /**
       
   284 Maximum number of TOpenFontCharMetrics structures to be sent to server/received
       
   285 from client at a time, when retrieval of glyph metrics is necessary for
       
   286 implementation of RFbsGlyphMetricsArray.
       
   287 */
       
   288 const TInt KMaxMetricsBatchSize = 16;
       
   289 
       
   290 /**
       
   291 Used by RFbsGlyphDataIterator for client/server communication of glyph info.
       
   292 Contains all the data necessary to retrieve a glyph from server and recreate
       
   293 glyph in client process.
       
   294 @internalComponent 
       
   295  */
       
   296 class TGlyphImageInfo
       
   297     {
       
   298 public:
       
   299     inline TGlyphImageInfo() : iImageId(KSgNullDrawableId), iPosX(0), iPosY(0) {}
       
   300 public:
       
   301     TSgDrawableId iImageId;
       
   302     TInt16 iPosX;
       
   303     TInt16 iPosY;
       
   304     TOpenFontCharMetrics iMetrics;
       
   305     };
       
   306 
       
   307 /**
       
   308 Used by CGlyphDataIteratorImpl. It is a container to group the 
       
   309 metadata and the image data of an individual glyph recevied from the
       
   310 server, all together. A collection of these is stored in the font,
       
   311 received from the server in batches.
       
   312 @internalComponent 
       
   313 */
       
   314 struct TGlyphBatchItem
       
   315     {
       
   316     TSglQueLink iLink;
       
   317     RSgImage iImage;
       
   318     TGlyphImageInfo iInfo;
       
   319     };
       
   320 
       
   321 /**
       
   322 Implementor class of RFbsGlyphDataIterator. This class contains all
       
   323 state information and contains much of the implementation of the
       
   324 behaviour.
       
   325 @internalComponent 
       
   326  */
       
   327 NONSHARABLE_CLASS(CGlyphDataIteratorImpl) : public CBase
       
   328     {
       
   329 public:
       
   330     CGlyphDataIteratorImpl(TInt aFbsFontHandle, const TUint* aGlyphCodes, TInt aCount);
       
   331     ~CGlyphDataIteratorImpl();
       
   332     TInt Initialise();
       
   333     TInt Next();
       
   334     void UpdateGlyphRect();
       
   335     TInt UpdateGlyphBatch(TInt aIndex);
       
   336     
       
   337 public:    
       
   338     TSglQue<TGlyphBatchItem> iGlyphBatch;   // Linked-list of the current batch of received glyphs.
       
   339     const TUint* iGlyphDataIterCodes;       // An array of glyph codes
       
   340     TInt  iGlyphDataIterCodeCount;          // The number of glyph codes in the array
       
   341     TInt  iGlyphDataIterCodeIndex;          // The index of the current glyph code in the array
       
   342     TRect iGlyphDataIterRect;               // The current glyph rectangle.
       
   343     TInt  iFbsFontHandle;                   // The Font Handle the iterator was opened with  
       
   344     RFbsSession* iFbs;
       
   345     };
       
   346 
   267 #endif
   347 #endif
   268 
       
   269