sl@0
|
1 |
// Copyright (c) 1998-2010 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#ifndef __UTILS_H__
|
sl@0
|
17 |
#define __UTILS_H__
|
sl@0
|
18 |
|
sl@0
|
19 |
#include <e32std.h>
|
sl@0
|
20 |
#include <gdi.h>
|
sl@0
|
21 |
#include <fntstore.h>
|
sl@0
|
22 |
#include <bitmap.h>
|
sl@0
|
23 |
#include <sgresource/sgimage.h>
|
sl@0
|
24 |
|
sl@0
|
25 |
class RFbsSession;
|
sl@0
|
26 |
|
sl@0
|
27 |
/**
|
sl@0
|
28 |
@internalComponent
|
sl@0
|
29 |
*/
|
sl@0
|
30 |
_LIT(KFBSERVPanicCategory,"FBSERV");
|
sl@0
|
31 |
_LIT(KFBSERVGlobalThreadName,"!Fontbitmapserver");
|
sl@0
|
32 |
_LIT(KFBSERVSharedChunkName,"FbsSharedChunk");
|
sl@0
|
33 |
_LIT(KFBSERVLargeChunkName,"FbsLargeChunk");
|
sl@0
|
34 |
#ifdef SYMBIAN_DEBUG_FBS_LOCKHEAP
|
sl@0
|
35 |
_LIT(KFBSERVDebugMutexName,"FbsDebugMutex");
|
sl@0
|
36 |
#endif
|
sl@0
|
37 |
|
sl@0
|
38 |
/**
|
sl@0
|
39 |
@internalComponent
|
sl@0
|
40 |
*/
|
sl@0
|
41 |
const TUid KUidCFbsBitmapCreation={0x0009A2C};
|
sl@0
|
42 |
/**
|
sl@0
|
43 |
@internalComponent
|
sl@0
|
44 |
*/
|
sl@0
|
45 |
enum TFbsPanic
|
sl@0
|
46 |
{
|
sl@0
|
47 |
EFbsPanicNoConnection = 1,
|
sl@0
|
48 |
EFbsPanicBadConnection = 2,
|
sl@0
|
49 |
EFbsPanicUnknownMessage = 3,
|
sl@0
|
50 |
EFbsPanicActiveSchedulerError = 4,
|
sl@0
|
51 |
EFbsPanicStartupFailed = 5,
|
sl@0
|
52 |
EFbsTypefaceStoreError = 6,
|
sl@0
|
53 |
EFbsFontCreateFailed = 7,
|
sl@0
|
54 |
EFbsFontAddressViolation = 8,
|
sl@0
|
55 |
EFbsBitmapInvalidFormat = 9,
|
sl@0
|
56 |
EFbsBitmapInvalidMode = 10,
|
sl@0
|
57 |
EFbsBitmapInvalidCompression = 11,
|
sl@0
|
58 |
EFbsBitmapDecompressionError = 12,
|
sl@0
|
59 |
EFbsPanicChunkError = 13,
|
sl@0
|
60 |
EFbsColor256UtilError = 14,
|
sl@0
|
61 |
EFbsHardwareBitmapError = 15,
|
sl@0
|
62 |
EFbsNotSupportedForCompression = 16,
|
sl@0
|
63 |
EFbsBitmapAlignment = 17,
|
sl@0
|
64 |
EFbsBitmapInvalidScanLinePtr = 18,
|
sl@0
|
65 |
EFbsBitmapInvalidMode2 = 19,
|
sl@0
|
66 |
EFbsBitmapInvalidMode3 = 20,
|
sl@0
|
67 |
EFbsBitmapSwappingImpossible = 21,
|
sl@0
|
68 |
EFbsPanicBadHeapLock = 22,
|
sl@0
|
69 |
EFbsShaperNotYetCalled = 23,
|
sl@0
|
70 |
EFbsShaperInvalidArguments = 24,
|
sl@0
|
71 |
EFbsInvalidCompressionThreshold = 25,
|
sl@0
|
72 |
EFbsTypefaceIndexOutOfRange = 26,
|
sl@0
|
73 |
EFbsPanicBitmapDataCopy = 27,
|
sl@0
|
74 |
EFbsPanicBitmapReadOnly = 28,
|
sl@0
|
75 |
EFbsPanicFontNullHandle = 29,
|
sl@0
|
76 |
EFbsPanicGlyphDataIteratorClosed = 31,
|
sl@0
|
77 |
EFbsPanicGlyphMetricsArrayOutOfBounds = 32,
|
sl@0
|
78 |
EFbsPanicGlyphDataIteratorIndexOutOfRange = 33,
|
sl@0
|
79 |
EFbsPanicInvalidBitmapType = 35,
|
sl@0
|
80 |
EFbsPanicGlyphAtlasInconsistentState = 36,
|
sl@0
|
81 |
EFbsPanicGlyphDataIteratorFailedToOpenImage = 37,
|
sl@0
|
82 |
EFbsPanicGlyphDataIteratorInvalidState = 39,
|
sl@0
|
83 |
EFbsPanicGlyphMetricsArrayInvalidState = 40,
|
sl@0
|
84 |
};
|
sl@0
|
85 |
|
sl@0
|
86 |
class TScanLine
|
sl@0
|
87 |
/**
|
sl@0
|
88 |
@internalComponent
|
sl@0
|
89 |
*/
|
sl@0
|
90 |
{
|
sl@0
|
91 |
public:
|
sl@0
|
92 |
TPoint iPoint;
|
sl@0
|
93 |
TInt iLength;
|
sl@0
|
94 |
TDisplayMode iDispMode;
|
sl@0
|
95 |
};
|
sl@0
|
96 |
|
sl@0
|
97 |
class TBmpSpec
|
sl@0
|
98 |
/**
|
sl@0
|
99 |
@internalComponent
|
sl@0
|
100 |
*/
|
sl@0
|
101 |
{
|
sl@0
|
102 |
public:
|
sl@0
|
103 |
TSize iSizeInPixels;
|
sl@0
|
104 |
TDisplayMode iDispMode;
|
sl@0
|
105 |
TInt iHandle;
|
sl@0
|
106 |
TInt iServerHandle;
|
sl@0
|
107 |
TInt iAddressOffset;
|
sl@0
|
108 |
};
|
sl@0
|
109 |
|
sl@0
|
110 |
class TBmpHandles
|
sl@0
|
111 |
/**
|
sl@0
|
112 |
@internalComponent
|
sl@0
|
113 |
*/
|
sl@0
|
114 |
{
|
sl@0
|
115 |
public:
|
sl@0
|
116 |
TInt iHandle;
|
sl@0
|
117 |
TInt iServerHandle;
|
sl@0
|
118 |
TInt iAddressOffset;
|
sl@0
|
119 |
};
|
sl@0
|
120 |
|
sl@0
|
121 |
class TFontInfo
|
sl@0
|
122 |
/**
|
sl@0
|
123 |
@internalComponent
|
sl@0
|
124 |
*/
|
sl@0
|
125 |
{
|
sl@0
|
126 |
public:
|
sl@0
|
127 |
TInt iHandle;
|
sl@0
|
128 |
TInt iAddressOffset;
|
sl@0
|
129 |
TInt iServerHandle;
|
sl@0
|
130 |
};
|
sl@0
|
131 |
|
sl@0
|
132 |
class TSizeInfo
|
sl@0
|
133 |
/**
|
sl@0
|
134 |
@internalComponent
|
sl@0
|
135 |
*/
|
sl@0
|
136 |
{
|
sl@0
|
137 |
public:
|
sl@0
|
138 |
TSizeInfo(){}
|
sl@0
|
139 |
TSizeInfo(TInt aMaxHeight,TSize aDevSize):iMaxHeight(aMaxHeight),iDevSize(aDevSize) {}
|
sl@0
|
140 |
|
sl@0
|
141 |
TInt iMaxHeight;
|
sl@0
|
142 |
TSize iDevSize;
|
sl@0
|
143 |
};
|
sl@0
|
144 |
|
sl@0
|
145 |
class TIntParcel
|
sl@0
|
146 |
/**
|
sl@0
|
147 |
@internalComponent
|
sl@0
|
148 |
*/
|
sl@0
|
149 |
{
|
sl@0
|
150 |
public:
|
sl@0
|
151 |
TInt iInt;
|
sl@0
|
152 |
};
|
sl@0
|
153 |
|
sl@0
|
154 |
class TLoadBitmapArg
|
sl@0
|
155 |
/**
|
sl@0
|
156 |
@internalComponent
|
sl@0
|
157 |
*/
|
sl@0
|
158 |
{
|
sl@0
|
159 |
public:
|
sl@0
|
160 |
TInt iBitmapId;
|
sl@0
|
161 |
TInt iShareIfLoaded;
|
sl@0
|
162 |
TInt iFileOffset;
|
sl@0
|
163 |
};
|
sl@0
|
164 |
|
sl@0
|
165 |
|
sl@0
|
166 |
IMPORT_C extern const TInt KFbServLargeChunkGrowByShifter;
|
sl@0
|
167 |
IMPORT_C extern const TInt KFbServLargeChunkSizeShifter;
|
sl@0
|
168 |
IMPORT_C extern const TInt KFbServLargeChunkMinPhysicalSize;
|
sl@0
|
169 |
IMPORT_C extern const TInt KFbServLargeChunkMinVirtualSize;
|
sl@0
|
170 |
IMPORT_C extern const TInt KFbServLargeChunkMaxVirtualSize;
|
sl@0
|
171 |
|
sl@0
|
172 |
|
sl@0
|
173 |
class CChunkPile : public CBase
|
sl@0
|
174 |
/**
|
sl@0
|
175 |
@internalComponent
|
sl@0
|
176 |
*/
|
sl@0
|
177 |
{
|
sl@0
|
178 |
public:
|
sl@0
|
179 |
IMPORT_C ~CChunkPile();
|
sl@0
|
180 |
IMPORT_C static CChunkPile* NewL(const RChunk& aChunk);
|
sl@0
|
181 |
IMPORT_C TUint8* Alloc(TInt aSize);
|
sl@0
|
182 |
IMPORT_C void Free(TAny* aCell);
|
sl@0
|
183 |
IMPORT_C TUint8* ChunkBase() const;
|
sl@0
|
184 |
IMPORT_C static TInt VirtualSize();
|
sl@0
|
185 |
private:
|
sl@0
|
186 |
CChunkPile(const RChunk& aChunk);
|
sl@0
|
187 |
void ConstructL();
|
sl@0
|
188 |
TInt DoAlloc(TUint8*& aCell, TInt aSize, RPointerArray<TUint8>& aCells, RArray<TInt>& aFreeCellLinks, TBool aLarge);
|
sl@0
|
189 |
void DoFree(TUint8* aCell, RPointerArray<TUint8>& aCells, RArray<TInt>& aFreeCellLinks, TBool aLarge);
|
sl@0
|
190 |
TInt GrowSmallSection(TInt aSize, TInt aLastFreeCell);
|
sl@0
|
191 |
void ShrinkSmallSection(TInt aShrinkBy);
|
sl@0
|
192 |
private:
|
sl@0
|
193 |
RChunk iChunk;
|
sl@0
|
194 |
TInt iPageSize;
|
sl@0
|
195 |
TInt iPageMask;
|
sl@0
|
196 |
RPointerArray<TUint8> iSmallCells; // last address is not a cell but the top of the small section
|
sl@0
|
197 |
RArray<TInt> iFreeSmallCellLinks; // index of Nth free small cell is element 0 + element 1 + ... + element N-1
|
sl@0
|
198 |
TInt iLargeSectionBottom; // boundary between small & large sections
|
sl@0
|
199 |
RPointerArray<TUint8> iLargeCells; // last address is not a cell but the top of the large section
|
sl@0
|
200 |
RArray<TInt> iFreeLargeCellLinks; // index of Nth free large cell is element 0 + element 1 + ... + element N-1
|
sl@0
|
201 |
RCriticalSection iLock;
|
sl@0
|
202 |
};
|
sl@0
|
203 |
|
sl@0
|
204 |
/**
|
sl@0
|
205 |
Used to pass sizes of FBServs default heap, heap for large bitmaps, and heap for small bitmaps.
|
sl@0
|
206 |
|
sl@0
|
207 |
@internalComponent
|
sl@0
|
208 |
@test
|
sl@0
|
209 |
*/
|
sl@0
|
210 |
struct THeapSizes
|
sl@0
|
211 |
{
|
sl@0
|
212 |
TInt iDefault;
|
sl@0
|
213 |
TInt iBig;
|
sl@0
|
214 |
TInt iSmall;
|
sl@0
|
215 |
};
|
sl@0
|
216 |
|
sl@0
|
217 |
/**
|
sl@0
|
218 |
Used when the EFbsMessRasterize message is sent from client to server. Allows pointers to items
|
sl@0
|
219 |
created on the shared FBServ heap to be passed from the server to the client as offsets from the
|
sl@0
|
220 |
heap base. Valid pointers are recreated client side using these offsets combined with the client's
|
sl@0
|
221 |
heap base.
|
sl@0
|
222 |
|
sl@0
|
223 |
@internalComponent
|
sl@0
|
224 |
*/
|
sl@0
|
225 |
struct TRasterizeParams
|
sl@0
|
226 |
{
|
sl@0
|
227 |
TInt iMetricsOffset;
|
sl@0
|
228 |
TInt iBitmapPointerOffset;
|
sl@0
|
229 |
};
|
sl@0
|
230 |
|
sl@0
|
231 |
IMPORT_C extern const TInt KFbServWritableDataPagingMode;
|
sl@0
|
232 |
|
sl@0
|
233 |
/**
|
sl@0
|
234 |
Used to specify the writable data paging mode of fbserv.
|
sl@0
|
235 |
This may be set using the patchable constant KFbServWritableDataPagingMode at rom-build time via the definitions:
|
sl@0
|
236 |
SYMBIAN_GRAPHICS_FBSERV_PAGEDATA -request that fbserv writable data is paged.
|
sl@0
|
237 |
SYMBIAN_GRAPHICS_FBSERV_UNPAGEDDATA -request that fbserv writable data is unpaged.
|
sl@0
|
238 |
SYMBIAN_GRAPHICS_FBSERV_PAGE_BITMAP_DATA_ONLY -request that only bitmap data is paged.
|
sl@0
|
239 |
SYMBIAN_GRAPHICS_FBSERV_PAGE_BITMAP_DATA_AND_SHARED_HEAP_ONLY -request that only bitmap data and shared heap are paged.
|
sl@0
|
240 |
@internalComponent
|
sl@0
|
241 |
*/
|
sl@0
|
242 |
enum TFbsWritableDataPagingMode
|
sl@0
|
243 |
{
|
sl@0
|
244 |
EFbsWdpDefault=0x00, //No change to the rom-build writable data paging configuration (nothing was specified).
|
sl@0
|
245 |
EFbsWdpPagedData=0x01, //SYMBIAN_GRAPHICS_FBSERV_PAGEDATA was specified.
|
sl@0
|
246 |
EFbsWdpUnpagedData=0x02, //SYMBIAN_GRAPHICS_FBSERV_UNPAGEDDATA was specified.
|
sl@0
|
247 |
EFbsWdpPageBitmapDataChunkOnly=0x03, //SYMBIAN_GRAPHICS_FBSERV_PAGE_BITMAP_DATA_ONLY was specified.
|
sl@0
|
248 |
EFbsWdpPageBitmapDataAndSharedHeapChunksOnly=0x04, //SYMBIAN_GRAPHICS_FBSERV_PAGE_BITMAP_DATA_AND_SHARED_HEAP_ONLY was specified.
|
sl@0
|
249 |
};
|
sl@0
|
250 |
|
sl@0
|
251 |
|
sl@0
|
252 |
/*
|
sl@0
|
253 |
Structure used to pass parameters from FBS client to FBS server.
|
sl@0
|
254 |
Used when opening/closing an outline iterator.
|
sl@0
|
255 |
@internalTechnology
|
sl@0
|
256 |
*/
|
sl@0
|
257 |
class TFBSGlyphOutlineParam
|
sl@0
|
258 |
{
|
sl@0
|
259 |
public:
|
sl@0
|
260 |
TInt iHandle;
|
sl@0
|
261 |
TInt iCount;
|
sl@0
|
262 |
TBool iHinted;
|
sl@0
|
263 |
};
|
sl@0
|
264 |
|
sl@0
|
265 |
/*
|
sl@0
|
266 |
Structure used to pass font table/glyph outlines from FBS to FBS client.
|
sl@0
|
267 |
Used when opening an font table or an outline iterator.
|
sl@0
|
268 |
@internalTechnology
|
sl@0
|
269 |
*/
|
sl@0
|
270 |
class TOffsetLen
|
sl@0
|
271 |
{
|
sl@0
|
272 |
public:
|
sl@0
|
273 |
TInt iOffset;
|
sl@0
|
274 |
TInt iLen;
|
sl@0
|
275 |
};
|
sl@0
|
276 |
|
sl@0
|
277 |
/**
|
sl@0
|
278 |
Maximum number of glyphs to be sent to server/received from client at a time,
|
sl@0
|
279 |
when retrieval of glyphs is necessary for implementation of RFbsGlyphDataIterator.
|
sl@0
|
280 |
*/
|
sl@0
|
281 |
const TInt KMaxGlyphBatchSize = 8;
|
sl@0
|
282 |
|
sl@0
|
283 |
/**
|
sl@0
|
284 |
Maximum number of TOpenFontCharMetrics structures to be sent to server/received
|
sl@0
|
285 |
from client at a time, when retrieval of glyph metrics is necessary for
|
sl@0
|
286 |
implementation of RFbsGlyphMetricsArray.
|
sl@0
|
287 |
*/
|
sl@0
|
288 |
const TInt KMaxMetricsBatchSize = 16;
|
sl@0
|
289 |
|
sl@0
|
290 |
/**
|
sl@0
|
291 |
Used by RFbsGlyphDataIterator for client/server communication of glyph info.
|
sl@0
|
292 |
Contains all the data necessary to retrieve a glyph from server and recreate
|
sl@0
|
293 |
glyph in client process.
|
sl@0
|
294 |
@internalComponent
|
sl@0
|
295 |
*/
|
sl@0
|
296 |
class TGlyphImageInfo
|
sl@0
|
297 |
{
|
sl@0
|
298 |
public:
|
sl@0
|
299 |
inline TGlyphImageInfo() : iImageId(KSgNullDrawableId), iPosX(0), iPosY(0) {}
|
sl@0
|
300 |
public:
|
sl@0
|
301 |
TSgDrawableId iImageId;
|
sl@0
|
302 |
TInt16 iPosX;
|
sl@0
|
303 |
TInt16 iPosY;
|
sl@0
|
304 |
TOpenFontCharMetrics iMetrics;
|
sl@0
|
305 |
};
|
sl@0
|
306 |
|
sl@0
|
307 |
/**
|
sl@0
|
308 |
Used by CGlyphDataIteratorImpl. It is a container to group the
|
sl@0
|
309 |
metadata and the image data of an individual glyph recevied from the
|
sl@0
|
310 |
server, all together. A collection of these is stored in the font,
|
sl@0
|
311 |
received from the server in batches.
|
sl@0
|
312 |
@internalComponent
|
sl@0
|
313 |
*/
|
sl@0
|
314 |
struct TGlyphBatchItem
|
sl@0
|
315 |
{
|
sl@0
|
316 |
TSglQueLink iLink;
|
sl@0
|
317 |
RSgImage iImage;
|
sl@0
|
318 |
TGlyphImageInfo iInfo;
|
sl@0
|
319 |
};
|
sl@0
|
320 |
|
sl@0
|
321 |
/**
|
sl@0
|
322 |
Implementor class of RFbsGlyphDataIterator. This class contains all
|
sl@0
|
323 |
state information and contains much of the implementation of the
|
sl@0
|
324 |
behaviour.
|
sl@0
|
325 |
@internalComponent
|
sl@0
|
326 |
*/
|
sl@0
|
327 |
NONSHARABLE_CLASS(CGlyphDataIteratorImpl) : public CBase
|
sl@0
|
328 |
{
|
sl@0
|
329 |
public:
|
sl@0
|
330 |
CGlyphDataIteratorImpl(TInt aFbsFontHandle, const TUint* aGlyphCodes, TInt aCount);
|
sl@0
|
331 |
~CGlyphDataIteratorImpl();
|
sl@0
|
332 |
TInt Initialise();
|
sl@0
|
333 |
TInt Next();
|
sl@0
|
334 |
void UpdateGlyphRect();
|
sl@0
|
335 |
TInt UpdateGlyphBatch(TInt aIndex);
|
sl@0
|
336 |
|
sl@0
|
337 |
public:
|
sl@0
|
338 |
TSglQue<TGlyphBatchItem> iGlyphBatch; // Linked-list of the current batch of received glyphs.
|
sl@0
|
339 |
const TUint* iGlyphDataIterCodes; // An array of glyph codes
|
sl@0
|
340 |
TInt iGlyphDataIterCodeCount; // The number of glyph codes in the array
|
sl@0
|
341 |
TInt iGlyphDataIterCodeIndex; // The index of the current glyph code in the array
|
sl@0
|
342 |
TRect iGlyphDataIterRect; // The current glyph rectangle.
|
sl@0
|
343 |
TInt iFbsFontHandle; // The Font Handle the iterator was opened with
|
sl@0
|
344 |
RFbsSession* iFbs;
|
sl@0
|
345 |
};
|
sl@0
|
346 |
|
sl@0
|
347 |
#endif
|