20 #include "BackGroundCompression.h" |
20 #include "BackGroundCompression.h" |
21 #include "linkedfonts.h" |
21 #include "linkedfonts.h" |
22 #include "BitwiseBitmap.inl" |
22 #include "BitwiseBitmap.inl" |
23 |
23 |
24 const TInt KFbsPriority = 0; |
24 const TInt KFbsPriority = 0; |
25 |
25 const TInt KFbsGoomMonitorSid = 0x10207218; |
26 // Setup security policies |
26 // Setup security policies |
27 const TInt KRanges[] = |
27 const TInt KRanges[] = |
28 { |
28 { |
29 0, |
29 0, |
30 EFbsMessShutdown, |
30 EFbsMessShutdown, |
35 EFbsMessUnused2, |
35 EFbsMessUnused2, |
36 EFbsMessRegisterLinkedTypeface, |
36 EFbsMessRegisterLinkedTypeface, |
37 EFbsMessFetchLinkedTypeface, |
37 EFbsMessFetchLinkedTypeface, |
38 EFbsMessUpdateLinkedTypeface, |
38 EFbsMessUpdateLinkedTypeface, |
39 EFbsMessGetFontTable, |
39 EFbsMessGetFontTable, |
|
40 EFbsMessOogmNotification, |
|
41 EFbsMessGetGlyphCacheMetrics, |
40 }; |
42 }; |
|
43 |
41 const TUint KRangeCount = sizeof(KRanges)/sizeof(TInt); |
44 const TUint KRangeCount = sizeof(KRanges)/sizeof(TInt); |
42 const TUint8 KElementsIndex[KRangeCount] = |
45 const TUint8 KElementsIndex[KRangeCount] = |
43 { |
46 { |
44 0, |
47 0, |
45 3, // For EFbsMessShutdown |
48 3, // For EFbsMessShutdown |
50 0, // ECapability_None for EFbsMessUnused2 and beyond |
53 0, // ECapability_None for EFbsMessUnused2 and beyond |
51 1, // ECapabilityWriteDeviceData for EFbsMessRegisterLinkedTypeface |
54 1, // ECapabilityWriteDeviceData for EFbsMessRegisterLinkedTypeface |
52 2, // ECapabilityReadDeviceData for EFbsMessFetchLinkedTypeface |
55 2, // ECapabilityReadDeviceData for EFbsMessFetchLinkedTypeface |
53 1, // ECapabilityWriteDeviceData for EFbsMessUpdateLinkedTypeface |
56 1, // ECapabilityWriteDeviceData for EFbsMessUpdateLinkedTypeface |
54 0, // ECapability_None for EFbsMessGetFontTable and beyond |
57 0, // ECapability_None for EFbsMessGetFontTable and beyond |
|
58 4, // SID for EFbsMessOogmNotification. |
|
59 0, // For EFbsMessGetGlyphCacheMetrics and on. |
55 }; |
60 }; |
|
61 |
56 const CPolicyServer::TPolicyElement KElements[] = |
62 const CPolicyServer::TPolicyElement KElements[] = |
57 { |
63 { |
58 {_INIT_SECURITY_POLICY_C1(ECapability_None), CPolicyServer::EFailClient}, |
64 {_INIT_SECURITY_POLICY_C1(ECapability_None), CPolicyServer::EFailClient}, |
59 {_INIT_SECURITY_POLICY_C1(ECapabilityWriteDeviceData), CPolicyServer::EFailClient}, |
65 {_INIT_SECURITY_POLICY_C1(ECapabilityWriteDeviceData), CPolicyServer::EFailClient}, |
60 {_INIT_SECURITY_POLICY_C1(ECapabilityReadDeviceData), CPolicyServer::EFailClient}, |
66 {_INIT_SECURITY_POLICY_C1(ECapabilityReadDeviceData), CPolicyServer::EFailClient}, |
61 {_INIT_SECURITY_POLICY_C1(ECapabilityPowerMgmt), CPolicyServer::EFailClient}, |
67 {_INIT_SECURITY_POLICY_C1(ECapabilityPowerMgmt), CPolicyServer::EFailClient}, |
|
68 {_INIT_SECURITY_POLICY_S0(KFbsGoomMonitorSid), CPolicyServer::EFailClient} |
62 }; |
69 }; |
|
70 |
63 const CPolicyServer::TPolicy KFbsPolicy = |
71 const CPolicyServer::TPolicy KFbsPolicy = |
64 { |
72 { |
65 CPolicyServer::EAlwaysPass, //specifies all connect attempts should pass |
73 CPolicyServer::EAlwaysPass, //specifies all connect attempts should pass |
66 KRangeCount, |
74 KRangeCount, |
67 KRanges, |
75 KRanges, |
68 KElementsIndex, |
76 KElementsIndex, |
69 KElements, |
77 KElements, |
70 }; |
78 }; |
71 |
79 |
72 CFontBitmapServer::CFontBitmapServer(): |
80 CFontBitmapServer::CFontBitmapServer(): |
73 CPolicyServer(KFbsPriority, KFbsPolicy), |
81 CPolicyServer(KFbsPriority, KFbsPolicy) |
74 iConnectionId(0), |
|
75 iTopLevelStore(NULL) |
|
76 { |
82 { |
77 } |
83 } |
78 |
84 |
79 CFontBitmapServer::~CFontBitmapServer() |
85 CFontBitmapServer::~CFontBitmapServer() |
80 { |
86 { |
83 // it may be called inside CFontBitmapServer::~CFontBitmapServer |
89 // it may be called inside CFontBitmapServer::~CFontBitmapServer |
84 } |
90 } |
85 |
91 |
86 CFontBitmapServer* CFontBitmapServer::NewL() |
92 CFontBitmapServer* CFontBitmapServer::NewL() |
87 { |
93 { |
88 CFontBitmapServer* fbs=new(ELeave) CFontBitmapServer; |
94 CFontBitmapServer* self = new(ELeave) CFontBitmapServer; |
89 CleanupStack::PushL(fbs); |
95 CleanupStack::PushL(self); |
90 fbs->iTopLevelStore=CFbTop::NewL(); |
96 self->ConstructL(); |
|
97 CleanupStack::Pop(); //self |
|
98 return self; |
|
99 } |
|
100 |
|
101 /** |
|
102 Two-phase constructor. |
|
103 */ |
|
104 void CFontBitmapServer::ConstructL() |
|
105 { |
|
106 iTopLevelStore=CFbTop::NewL(); |
91 |
107 |
92 // If fbserv data paging is configured as unpaged, automatically pin client descriptors |
108 // If fbserv data paging is configured as unpaged, automatically pin client descriptors |
93 if(!RProcess().DefaultDataPaged()) |
109 if(!RProcess().DefaultDataPaged()) |
94 { |
110 { |
95 fbs->SetPinClientDescriptors(ETrue); |
111 SetPinClientDescriptors(ETrue); |
96 } |
112 } |
97 |
113 StartL(KFBSERVGlobalThreadName); |
98 fbs->StartL(KFBSERVGlobalThreadName); |
|
99 CleanupStack::Pop(); |
|
100 return(fbs); |
|
101 } |
114 } |
102 |
115 |
103 CFbTop* CFontBitmapServer::TopLevelStore() |
116 CFbTop* CFontBitmapServer::TopLevelStore() |
104 { |
117 { |
105 return(iTopLevelStore); |
118 return(iTopLevelStore); |
106 } |
119 } |
|
120 |
107 CSession2* CFontBitmapServer::NewSessionL(const TVersion& aVersion,const RMessage2& /*aMessage*/ ) const |
121 CSession2* CFontBitmapServer::NewSessionL(const TVersion& aVersion,const RMessage2& /*aMessage*/ ) const |
108 { |
122 { |
109 TVersion v(KFbsMajorVersionNumber,KFbsMinorVersionNumber,KFbsBuildVersionNumber); |
123 TVersion v(KFbsMajorVersionNumber,KFbsMinorVersionNumber,KFbsBuildVersionNumber); |
110 if(!User::QueryVersionSupported(v,aVersion)) |
124 if(!User::QueryVersionSupported(v,aVersion)) |
111 User::Leave(KErrNotSupported); |
125 User::Leave(KErrNotSupported); |
125 TTypefaceSupport tfi; |
139 TTypefaceSupport tfi; |
126 TPckgBuf<TTypefaceSupport> ttipckg(tfi); |
140 TPckgBuf<TTypefaceSupport> ttipckg(tfi); |
127 TPckgBuf<TSize> pixelSize; |
141 TPckgBuf<TSize> pixelSize; |
128 TInt index=aMessage.Int0(); |
142 TInt index=aMessage.Int0(); |
129 TInt limit=iTopLevelStore->FontStore()->NumTypefaces(); |
143 TInt limit=iTopLevelStore->FontStore()->NumTypefaces(); |
130 if(index<0 || index>limit) |
144 if(index < 0 || index > limit) |
131 { |
145 { |
132 return KErrArgument; |
146 return KErrArgument; |
133 } |
147 } |
134 TInt ret = aMessage.Read(2, pixelSize); |
148 TInt ret = aMessage.Read(2, pixelSize); |
135 if (ret != KErrNone) |
149 if (ret != KErrNone) |
193 void CFontBitmapServer::ProcMessage(const RMessage2& aMessage, TInt aSession, TInt& aRet) |
207 void CFontBitmapServer::ProcMessage(const RMessage2& aMessage, TInt aSession, TInt& aRet) |
194 #else |
208 #else |
195 void CFontBitmapServer::ProcMessage(const RMessage2& aMessage, TInt aSession) |
209 void CFontBitmapServer::ProcMessage(const RMessage2& aMessage, TInt aSession) |
196 #endif |
210 #endif |
197 { |
211 { |
198 TInt ret=KErrNone; |
212 TInt ret=KErrNone; |
199 TBool clientPanicRequired = EFalse; |
213 TBool clientPanicRequired = EFalse; |
200 #ifdef _DEBUG |
214 #ifdef _DEBUG |
201 TInt num=0; |
215 TInt num=0; |
202 #endif |
216 #endif |
203 switch (aMessage.Function()) |
217 switch (aMessage.Function()) |
361 */ |
376 */ |
362 #ifdef _DEBUG |
377 #ifdef _DEBUG |
363 void CFontBitmapServer::GetHeapSizesL(const RMessage2& aMessage) |
378 void CFontBitmapServer::GetHeapSizesL(const RMessage2& aMessage) |
364 { |
379 { |
365 TPckgBuf<THeapSizes> data; |
380 TPckgBuf<THeapSizes> data; |
366 TInt defaultHeapSize; |
381 TInt defaultHeapSize = 0; |
367 TInt smallBmpHeapSize; |
382 TInt smallBmpHeapSize = 0; |
368 TInt bigBmpHeapSize; |
383 TInt bigBmpHeapSize = 0; |
369 |
384 |
370 User::Heap().AllocSize(defaultHeapSize); |
385 User::Heap().AllocSize(defaultHeapSize); |
371 bigBmpHeapSize = iTopLevelStore->iLargeBitmapChunk.Size(); |
386 bigBmpHeapSize = iTopLevelStore->iLargeBitmapChunk.Size(); |
372 iTopLevelStore->Heap()->AllocSize(smallBmpHeapSize); |
387 iTopLevelStore->Heap()->AllocSize(smallBmpHeapSize); |
373 |
388 |
383 User::Leave(KErrNotSupported); |
398 User::Leave(KErrNotSupported); |
384 } |
399 } |
385 #endif |
400 #endif |
386 |
401 |
387 |
402 |
388 CFontObject::CFontObject(CFontStore* aFontStore): |
403 CFontObject::CFontObject(CFontStore* aFontStore, CGlyphAtlas* aGlyphAtlas): |
389 CObject(), |
404 CObject(), |
390 iAddressPointer(NULL), |
405 iFontStore(aFontStore), |
391 iFontStore(aFontStore) |
406 iGlyphAtlas(aGlyphAtlas) |
392 { |
407 { |
393 } |
408 } |
394 |
409 |
395 CFontObject::~CFontObject() |
410 CFontObject::~CFontObject() |
396 { |
411 { |
397 if (AccessCount()==1) |
412 if (AccessCount()==1) |
|
413 { |
398 Dec(); |
414 Dec(); |
|
415 } |
399 iFontStore->ReleaseFont(iAddressPointer); |
416 iFontStore->ReleaseFont(iAddressPointer); |
|
417 if (iGlyphAtlas) |
|
418 { |
|
419 iGlyphAtlas->FontReleased(*iAddressPointer); |
|
420 } |
400 } |
421 } |
401 |
422 |
402 // CBitmapObject constructor - takes ownership of aBmp |
423 // CBitmapObject constructor - takes ownership of aBmp |
403 CBitmapObject::CBitmapObject(CFbTop& aFbTop, CBitwiseBitmap* aBmp): |
424 CBitmapObject::CBitmapObject(CFbTop& aFbTop, CBitwiseBitmap* aBmp): |
404 CObject(), |
425 CObject(), |
424 iFbTop->iBitmapCon->AddL(this); |
445 iFbTop->iBitmapCon->AddL(this); |
425 if (!aReplacement) |
446 if (!aReplacement) |
426 { |
447 { |
427 iHandle = reinterpret_cast<TInt>(this); |
448 iHandle = reinterpret_cast<TInt>(this); |
428 while (iFbTop->iBitmapObjectIndex.FindInOrder(this, Compare) != KErrNotFound) |
449 while (iFbTop->iBitmapObjectIndex.FindInOrder(this, Compare) != KErrNotFound) |
|
450 { |
429 ++iHandle; |
451 ++iHandle; |
|
452 } |
430 User::LeaveIfError(iFbTop->iBitmapObjectIndex.InsertInOrder(this, Compare)); |
453 User::LeaveIfError(iFbTop->iBitmapObjectIndex.InsertInOrder(this, Compare)); |
431 } |
454 } |
432 } |
455 } |
433 |
456 |
434 void CleanupBitmapObject(TAny* aPtr) |
457 void CleanupBitmapObject(TAny* aPtr) |
469 { |
492 { |
470 TInt index = iFbTop->iBitmapObjectIndex.FindInOrder(this, Compare); |
493 TInt index = iFbTop->iBitmapObjectIndex.FindInOrder(this, Compare); |
471 if (index != KErrNotFound) |
494 if (index != KErrNotFound) |
472 { |
495 { |
473 if (iCleanBitmap) |
496 if (iCleanBitmap) |
|
497 { |
474 iFbTop->iBitmapObjectIndex[index] = iCleanBitmap; |
498 iFbTop->iBitmapObjectIndex[index] = iCleanBitmap; |
|
499 } |
475 else |
500 else |
|
501 { |
476 iFbTop->iBitmapObjectIndex.Remove(index); |
502 iFbTop->iBitmapObjectIndex.Remove(index); |
|
503 } |
477 } |
504 } |
478 } |
505 } |
479 if (iCleanBitmap != NULL) |
506 if (iCleanBitmap != NULL) |
480 { |
507 { |
481 iCleanBitmap->SetOwner(NULL); |
508 iCleanBitmap->SetOwner(NULL); |
500 aNewBmpObj->iAddressPointer->Extra()->iTouchCount = iAddressPointer->Extra()->iTouchCount + 1; |
527 aNewBmpObj->iAddressPointer->Extra()->iTouchCount = iAddressPointer->Extra()->iTouchCount + 1; |
501 } |
528 } |
502 |
529 |
503 void CBitmapObject::Close() |
530 void CBitmapObject::Close() |
504 { |
531 { |
505 if (iCleanBitmap != NULL && Owner() != NULL && AccessCount() == 2) |
532 if ((iCleanBitmap != NULL) && (Owner() != NULL) && (AccessCount() == 2)) |
506 { |
533 { |
507 static_cast<CBitmapObject*>(Owner())->iCleanBitmap = iCleanBitmap; |
534 static_cast<CBitmapObject*>(Owner())->iCleanBitmap = iCleanBitmap; |
508 iCleanBitmap->SetOwner(Owner()); |
535 iCleanBitmap->SetOwner(Owner()); |
509 iHandle = 0; |
536 iHandle = 0; |
510 Dec(); |
537 Dec(); |
523 } |
550 } |
524 |
551 |
525 // CSharedBitmapObject constructor - takes ownership of aBmp and aKey |
552 // CSharedBitmapObject constructor - takes ownership of aBmp and aKey |
526 CSharedBitmapObject::CSharedBitmapObject(CFbTop& aFbTop, CBitwiseBitmap* aBmp, TDesC* aKey): |
553 CSharedBitmapObject::CSharedBitmapObject(CFbTop& aFbTop, CBitwiseBitmap* aBmp, TDesC* aKey): |
527 CBitmapObject(aFbTop, aBmp), |
554 CBitmapObject(aFbTop, aBmp), |
528 iKey(aKey), |
555 iKey(aKey) |
529 iNext(NULL) |
|
530 { |
556 { |
531 __ASSERT_DEBUG(iKey, User::Invariant()); |
557 __ASSERT_DEBUG(iKey, User::Invariant()); |
532 } |
558 } |
533 |
559 |
534 /** Second-phase constructor of reference counting objects for bitmaps |
560 /** Second-phase constructor of reference counting objects for bitmaps |