1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/fbs/fontandbitmapserver/sfbs/UTILS.H Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,347 @@
1.4 +// Copyright (c) 1998-2010 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#ifndef __UTILS_H__
1.20 +#define __UTILS_H__
1.21 +
1.22 +#include <e32std.h>
1.23 +#include <gdi.h>
1.24 +#include <fntstore.h>
1.25 +#include <bitmap.h>
1.26 +#include <sgresource/sgimage.h>
1.27 +
1.28 +class RFbsSession;
1.29 +
1.30 +/**
1.31 +@internalComponent
1.32 +*/
1.33 +_LIT(KFBSERVPanicCategory,"FBSERV");
1.34 +_LIT(KFBSERVGlobalThreadName,"!Fontbitmapserver");
1.35 +_LIT(KFBSERVSharedChunkName,"FbsSharedChunk");
1.36 +_LIT(KFBSERVLargeChunkName,"FbsLargeChunk");
1.37 +#ifdef SYMBIAN_DEBUG_FBS_LOCKHEAP
1.38 +_LIT(KFBSERVDebugMutexName,"FbsDebugMutex");
1.39 +#endif
1.40 +
1.41 +/**
1.42 +@internalComponent
1.43 +*/
1.44 +const TUid KUidCFbsBitmapCreation={0x0009A2C};
1.45 +/**
1.46 +@internalComponent
1.47 +*/
1.48 +enum TFbsPanic
1.49 + {
1.50 + EFbsPanicNoConnection = 1,
1.51 + EFbsPanicBadConnection = 2,
1.52 + EFbsPanicUnknownMessage = 3,
1.53 + EFbsPanicActiveSchedulerError = 4,
1.54 + EFbsPanicStartupFailed = 5,
1.55 + EFbsTypefaceStoreError = 6,
1.56 + EFbsFontCreateFailed = 7,
1.57 + EFbsFontAddressViolation = 8,
1.58 + EFbsBitmapInvalidFormat = 9,
1.59 + EFbsBitmapInvalidMode = 10,
1.60 + EFbsBitmapInvalidCompression = 11,
1.61 + EFbsBitmapDecompressionError = 12,
1.62 + EFbsPanicChunkError = 13,
1.63 + EFbsColor256UtilError = 14,
1.64 + EFbsHardwareBitmapError = 15,
1.65 + EFbsNotSupportedForCompression = 16,
1.66 + EFbsBitmapAlignment = 17,
1.67 + EFbsBitmapInvalidScanLinePtr = 18,
1.68 + EFbsBitmapInvalidMode2 = 19,
1.69 + EFbsBitmapInvalidMode3 = 20,
1.70 + EFbsBitmapSwappingImpossible = 21,
1.71 + EFbsPanicBadHeapLock = 22,
1.72 + EFbsShaperNotYetCalled = 23,
1.73 + EFbsShaperInvalidArguments = 24,
1.74 + EFbsInvalidCompressionThreshold = 25,
1.75 + EFbsTypefaceIndexOutOfRange = 26,
1.76 + EFbsPanicBitmapDataCopy = 27,
1.77 + EFbsPanicBitmapReadOnly = 28,
1.78 + EFbsPanicFontNullHandle = 29,
1.79 + EFbsPanicGlyphDataIteratorClosed = 31,
1.80 + EFbsPanicGlyphMetricsArrayOutOfBounds = 32,
1.81 + EFbsPanicGlyphDataIteratorIndexOutOfRange = 33,
1.82 + EFbsPanicInvalidBitmapType = 35,
1.83 + EFbsPanicGlyphAtlasInconsistentState = 36,
1.84 + EFbsPanicGlyphDataIteratorFailedToOpenImage = 37,
1.85 + EFbsPanicGlyphDataIteratorInvalidState = 39,
1.86 + EFbsPanicGlyphMetricsArrayInvalidState = 40,
1.87 + };
1.88 +
1.89 +class TScanLine
1.90 +/**
1.91 +@internalComponent
1.92 +*/
1.93 + {
1.94 +public:
1.95 + TPoint iPoint;
1.96 + TInt iLength;
1.97 + TDisplayMode iDispMode;
1.98 + };
1.99 +
1.100 +class TBmpSpec
1.101 +/**
1.102 +@internalComponent
1.103 +*/
1.104 + {
1.105 +public:
1.106 + TSize iSizeInPixels;
1.107 + TDisplayMode iDispMode;
1.108 + TInt iHandle;
1.109 + TInt iServerHandle;
1.110 + TInt iAddressOffset;
1.111 + };
1.112 +
1.113 +class TBmpHandles
1.114 +/**
1.115 +@internalComponent
1.116 +*/
1.117 + {
1.118 +public:
1.119 + TInt iHandle;
1.120 + TInt iServerHandle;
1.121 + TInt iAddressOffset;
1.122 + };
1.123 +
1.124 +class TFontInfo
1.125 +/**
1.126 +@internalComponent
1.127 +*/
1.128 + {
1.129 +public:
1.130 + TInt iHandle;
1.131 + TInt iAddressOffset;
1.132 + TInt iServerHandle;
1.133 + };
1.134 +
1.135 +class TSizeInfo
1.136 +/**
1.137 +@internalComponent
1.138 +*/
1.139 + {
1.140 +public:
1.141 + TSizeInfo(){}
1.142 + TSizeInfo(TInt aMaxHeight,TSize aDevSize):iMaxHeight(aMaxHeight),iDevSize(aDevSize) {}
1.143 +
1.144 + TInt iMaxHeight;
1.145 + TSize iDevSize;
1.146 + };
1.147 +
1.148 +class TIntParcel
1.149 +/**
1.150 +@internalComponent
1.151 +*/
1.152 + {
1.153 +public:
1.154 + TInt iInt;
1.155 + };
1.156 +
1.157 +class TLoadBitmapArg
1.158 +/**
1.159 +@internalComponent
1.160 +*/
1.161 + {
1.162 +public:
1.163 + TInt iBitmapId;
1.164 + TInt iShareIfLoaded;
1.165 + TInt iFileOffset;
1.166 + };
1.167 +
1.168 +
1.169 +IMPORT_C extern const TInt KFbServLargeChunkGrowByShifter;
1.170 +IMPORT_C extern const TInt KFbServLargeChunkSizeShifter;
1.171 +IMPORT_C extern const TInt KFbServLargeChunkMinPhysicalSize;
1.172 +IMPORT_C extern const TInt KFbServLargeChunkMinVirtualSize;
1.173 +IMPORT_C extern const TInt KFbServLargeChunkMaxVirtualSize;
1.174 +
1.175 +
1.176 +class CChunkPile : public CBase
1.177 +/**
1.178 +@internalComponent
1.179 +*/
1.180 + {
1.181 +public:
1.182 + IMPORT_C ~CChunkPile();
1.183 + IMPORT_C static CChunkPile* NewL(const RChunk& aChunk);
1.184 + IMPORT_C TUint8* Alloc(TInt aSize);
1.185 + IMPORT_C void Free(TAny* aCell);
1.186 + IMPORT_C TUint8* ChunkBase() const;
1.187 + IMPORT_C static TInt VirtualSize();
1.188 +private:
1.189 + CChunkPile(const RChunk& aChunk);
1.190 + void ConstructL();
1.191 + TInt DoAlloc(TUint8*& aCell, TInt aSize, RPointerArray<TUint8>& aCells, RArray<TInt>& aFreeCellLinks, TBool aLarge);
1.192 + void DoFree(TUint8* aCell, RPointerArray<TUint8>& aCells, RArray<TInt>& aFreeCellLinks, TBool aLarge);
1.193 + TInt GrowSmallSection(TInt aSize, TInt aLastFreeCell);
1.194 + void ShrinkSmallSection(TInt aShrinkBy);
1.195 +private:
1.196 + RChunk iChunk;
1.197 + TInt iPageSize;
1.198 + TInt iPageMask;
1.199 + RPointerArray<TUint8> iSmallCells; // last address is not a cell but the top of the small section
1.200 + RArray<TInt> iFreeSmallCellLinks; // index of Nth free small cell is element 0 + element 1 + ... + element N-1
1.201 + TInt iLargeSectionBottom; // boundary between small & large sections
1.202 + RPointerArray<TUint8> iLargeCells; // last address is not a cell but the top of the large section
1.203 + RArray<TInt> iFreeLargeCellLinks; // index of Nth free large cell is element 0 + element 1 + ... + element N-1
1.204 + RCriticalSection iLock;
1.205 + };
1.206 +
1.207 +/**
1.208 +Used to pass sizes of FBServs default heap, heap for large bitmaps, and heap for small bitmaps.
1.209 +
1.210 +@internalComponent
1.211 +@test
1.212 +*/
1.213 +struct THeapSizes
1.214 + {
1.215 + TInt iDefault;
1.216 + TInt iBig;
1.217 + TInt iSmall;
1.218 + };
1.219 +
1.220 +/**
1.221 +Used when the EFbsMessRasterize message is sent from client to server. Allows pointers to items
1.222 +created on the shared FBServ heap to be passed from the server to the client as offsets from the
1.223 +heap base. Valid pointers are recreated client side using these offsets combined with the client's
1.224 +heap base.
1.225 +
1.226 +@internalComponent
1.227 + */
1.228 +struct TRasterizeParams
1.229 + {
1.230 + TInt iMetricsOffset;
1.231 + TInt iBitmapPointerOffset;
1.232 + };
1.233 +
1.234 +IMPORT_C extern const TInt KFbServWritableDataPagingMode;
1.235 +
1.236 +/**
1.237 +Used to specify the writable data paging mode of fbserv.
1.238 +This may be set using the patchable constant KFbServWritableDataPagingMode at rom-build time via the definitions:
1.239 + SYMBIAN_GRAPHICS_FBSERV_PAGEDATA -request that fbserv writable data is paged.
1.240 + SYMBIAN_GRAPHICS_FBSERV_UNPAGEDDATA -request that fbserv writable data is unpaged.
1.241 + SYMBIAN_GRAPHICS_FBSERV_PAGE_BITMAP_DATA_ONLY -request that only bitmap data is paged.
1.242 + SYMBIAN_GRAPHICS_FBSERV_PAGE_BITMAP_DATA_AND_SHARED_HEAP_ONLY -request that only bitmap data and shared heap are paged.
1.243 +@internalComponent
1.244 +*/
1.245 +enum TFbsWritableDataPagingMode
1.246 + {
1.247 + EFbsWdpDefault=0x00, //No change to the rom-build writable data paging configuration (nothing was specified).
1.248 + EFbsWdpPagedData=0x01, //SYMBIAN_GRAPHICS_FBSERV_PAGEDATA was specified.
1.249 + EFbsWdpUnpagedData=0x02, //SYMBIAN_GRAPHICS_FBSERV_UNPAGEDDATA was specified.
1.250 + EFbsWdpPageBitmapDataChunkOnly=0x03, //SYMBIAN_GRAPHICS_FBSERV_PAGE_BITMAP_DATA_ONLY was specified.
1.251 + EFbsWdpPageBitmapDataAndSharedHeapChunksOnly=0x04, //SYMBIAN_GRAPHICS_FBSERV_PAGE_BITMAP_DATA_AND_SHARED_HEAP_ONLY was specified.
1.252 + };
1.253 +
1.254 +
1.255 +/*
1.256 +Structure used to pass parameters from FBS client to FBS server.
1.257 +Used when opening/closing an outline iterator.
1.258 +@internalTechnology
1.259 +*/
1.260 +class TFBSGlyphOutlineParam
1.261 + {
1.262 +public:
1.263 + TInt iHandle;
1.264 + TInt iCount;
1.265 + TBool iHinted;
1.266 + };
1.267 +
1.268 +/*
1.269 +Structure used to pass font table/glyph outlines from FBS to FBS client.
1.270 +Used when opening an font table or an outline iterator.
1.271 +@internalTechnology
1.272 +*/
1.273 +class TOffsetLen
1.274 + {
1.275 +public:
1.276 + TInt iOffset;
1.277 + TInt iLen;
1.278 + };
1.279 +
1.280 +/**
1.281 +Maximum number of glyphs to be sent to server/received from client at a time,
1.282 +when retrieval of glyphs is necessary for implementation of RFbsGlyphDataIterator.
1.283 +*/
1.284 +const TInt KMaxGlyphBatchSize = 8;
1.285 +
1.286 +/**
1.287 +Maximum number of TOpenFontCharMetrics structures to be sent to server/received
1.288 +from client at a time, when retrieval of glyph metrics is necessary for
1.289 +implementation of RFbsGlyphMetricsArray.
1.290 +*/
1.291 +const TInt KMaxMetricsBatchSize = 16;
1.292 +
1.293 +/**
1.294 +Used by RFbsGlyphDataIterator for client/server communication of glyph info.
1.295 +Contains all the data necessary to retrieve a glyph from server and recreate
1.296 +glyph in client process.
1.297 +@internalComponent
1.298 + */
1.299 +class TGlyphImageInfo
1.300 + {
1.301 +public:
1.302 + inline TGlyphImageInfo() : iImageId(KSgNullDrawableId), iPosX(0), iPosY(0) {}
1.303 +public:
1.304 + TSgDrawableId iImageId;
1.305 + TInt16 iPosX;
1.306 + TInt16 iPosY;
1.307 + TOpenFontCharMetrics iMetrics;
1.308 + };
1.309 +
1.310 +/**
1.311 +Used by CGlyphDataIteratorImpl. It is a container to group the
1.312 +metadata and the image data of an individual glyph recevied from the
1.313 +server, all together. A collection of these is stored in the font,
1.314 +received from the server in batches.
1.315 +@internalComponent
1.316 +*/
1.317 +struct TGlyphBatchItem
1.318 + {
1.319 + TSglQueLink iLink;
1.320 + RSgImage iImage;
1.321 + TGlyphImageInfo iInfo;
1.322 + };
1.323 +
1.324 +/**
1.325 +Implementor class of RFbsGlyphDataIterator. This class contains all
1.326 +state information and contains much of the implementation of the
1.327 +behaviour.
1.328 +@internalComponent
1.329 + */
1.330 +NONSHARABLE_CLASS(CGlyphDataIteratorImpl) : public CBase
1.331 + {
1.332 +public:
1.333 + CGlyphDataIteratorImpl(TInt aFbsFontHandle, const TUint* aGlyphCodes, TInt aCount);
1.334 + ~CGlyphDataIteratorImpl();
1.335 + TInt Initialise();
1.336 + TInt Next();
1.337 + void UpdateGlyphRect();
1.338 + TInt UpdateGlyphBatch(TInt aIndex);
1.339 +
1.340 +public:
1.341 + TSglQue<TGlyphBatchItem> iGlyphBatch; // Linked-list of the current batch of received glyphs.
1.342 + const TUint* iGlyphDataIterCodes; // An array of glyph codes
1.343 + TInt iGlyphDataIterCodeCount; // The number of glyph codes in the array
1.344 + TInt iGlyphDataIterCodeIndex; // The index of the current glyph code in the array
1.345 + TRect iGlyphDataIterRect; // The current glyph rectangle.
1.346 + TInt iFbsFontHandle; // The Font Handle the iterator was opened with
1.347 + RFbsSession* iFbs;
1.348 + };
1.349 +
1.350 +#endif