|
1 // |
|
2 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 // All rights reserved. |
|
4 // This component and the accompanying materials are made available |
|
5 // under the terms of the License "Symbian Foundation License v1.0" |
|
6 // which accompanies this distribution, and is available |
|
7 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
8 // |
|
9 // Initial Contributors: |
|
10 // Nokia Corporation - initial contribution. |
|
11 // |
|
12 // Contributors: |
|
13 // |
|
14 // Description: |
|
15 // |
|
16 |
|
17 #include "T_DataFbsBitGcBitmap.h" |
|
18 |
|
19 |
|
20 /// Commands |
|
21 _LIT(KCmdNewL, "new"); |
|
22 _LIT(KCmdAddress, "Address"); |
|
23 _LIT(KCmdLockHeap, "LockHeap"); |
|
24 _LIT(KCmdUnlockHeap, "UnlockHeap"); |
|
25 _LIT(KCmdDestructorGeneral, "~"); |
|
26 _LIT(KCmdDestructor, "~CFbsBitGcBitmap"); |
|
27 |
|
28 //Log |
|
29 _LIT(KLogErrNum, "Error=%d"); |
|
30 _LIT(KLogInfoCmdnewL, "execute new CFbsBitGcBitmap()"); |
|
31 _LIT(KLogInfoCmdDestructor1, "execute ~CFbsBitGcBitmap()"); |
|
32 |
|
33 //Fields |
|
34 _LIT(KFldExpectedWidth, "expectedWidth"); |
|
35 _LIT(KFldExpectedHeight, "expectedHeight"); |
|
36 |
|
37 |
|
38 CT_DataFbsBitGcBitmap* CT_DataFbsBitGcBitmap::NewL() |
|
39 { |
|
40 CT_DataFbsBitGcBitmap* ret = new (ELeave) CT_DataFbsBitGcBitmap(); |
|
41 CleanupStack::PushL(ret); |
|
42 ret->ConstructL(); |
|
43 CleanupStack::Pop(ret); |
|
44 return ret; |
|
45 } |
|
46 |
|
47 CT_DataFbsBitGcBitmap::CT_DataFbsBitGcBitmap() |
|
48 : iFbsBitGcBitmap(NULL) |
|
49 { |
|
50 |
|
51 } |
|
52 |
|
53 void CT_DataFbsBitGcBitmap::ConstructL() |
|
54 { |
|
55 |
|
56 } |
|
57 |
|
58 CT_DataFbsBitGcBitmap::~CT_DataFbsBitGcBitmap() |
|
59 { |
|
60 DestroyData(); |
|
61 } |
|
62 |
|
63 TAny* CT_DataFbsBitGcBitmap::GetObject() |
|
64 { |
|
65 return iFbsBitGcBitmap; |
|
66 } |
|
67 |
|
68 void CT_DataFbsBitGcBitmap::SetObjectL(TAny* aAny) |
|
69 { |
|
70 DestroyData(); |
|
71 iFbsBitGcBitmap = static_cast<CFbsBitGcBitmap*> (aAny); |
|
72 } |
|
73 |
|
74 void CT_DataFbsBitGcBitmap::DisownObjectL() |
|
75 { |
|
76 iFbsBitGcBitmap = NULL; |
|
77 } |
|
78 |
|
79 CFbsBitmap* CT_DataFbsBitGcBitmap::GetFbsBitmap() const |
|
80 { |
|
81 return iFbsBitGcBitmap; |
|
82 } |
|
83 |
|
84 /** |
|
85 * Process a command read from the ini file |
|
86 * |
|
87 * @param aCommand the command to process |
|
88 * @param aSection the entry in the ini file requiring the command to be processed |
|
89 * @return ETrue if the command is processed |
|
90 */ |
|
91 TBool CT_DataFbsBitGcBitmap::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex) |
|
92 { |
|
93 TBool ret = ETrue; |
|
94 if (aCommand==KCmdNewL) |
|
95 { |
|
96 DoCmdNewL(); |
|
97 } |
|
98 else if ( aCommand==KCmdDestructorGeneral || aCommand==KCmdDestructor ) |
|
99 { |
|
100 DoCmdDestructor(); |
|
101 } |
|
102 else if ( aCommand==KCmdAddress) |
|
103 { |
|
104 DoCmdAddress(aSection); |
|
105 } |
|
106 else if(aCommand==KCmdLockHeap) |
|
107 { |
|
108 DoCmdLockHeap(); |
|
109 } |
|
110 else if(aCommand==KCmdUnlockHeap) |
|
111 { |
|
112 DoCmdUnlockHeap(); |
|
113 } |
|
114 else |
|
115 { |
|
116 ret=CT_DataFbsBitmap::DoCommandL(aCommand, aSection, aAsyncErrorIndex); |
|
117 } |
|
118 |
|
119 return ret; |
|
120 } |
|
121 |
|
122 void CT_DataFbsBitGcBitmap::DestroyData() |
|
123 { |
|
124 delete iFbsBitGcBitmap; |
|
125 iFbsBitGcBitmap = NULL; |
|
126 } |
|
127 |
|
128 void CT_DataFbsBitGcBitmap::DoCmdDestructor() |
|
129 { |
|
130 INFO_PRINTF1(KLogInfoCmdDestructor1); |
|
131 DestroyData(); |
|
132 } |
|
133 |
|
134 void CT_DataFbsBitGcBitmap::DoCmdNewL() |
|
135 { |
|
136 DestroyData(); |
|
137 TInt err = KErrNone; |
|
138 INFO_PRINTF1(KLogInfoCmdnewL); |
|
139 TRAP(err, iFbsBitGcBitmap = new (ELeave) CFbsBitGcBitmap()); |
|
140 if ( err!=KErrNone ) |
|
141 { |
|
142 ERR_PRINTF2(KLogErrNum, err); |
|
143 SetError(err); |
|
144 } |
|
145 } |
|
146 |
|
147 void CT_DataFbsBitGcBitmap::DoCmdAddress(const TDesC& aSection) |
|
148 { |
|
149 INFO_PRINTF1(_L("execute CFbsBitGcBitmap::Address()")); |
|
150 CBitwiseBitmap* bmp=iFbsBitGcBitmap->Address(); |
|
151 if(bmp==NULL) |
|
152 { |
|
153 INFO_PRINTF1(_L("The bitmap address is NULL")); |
|
154 return; |
|
155 } |
|
156 |
|
157 TInt displaymode=bmp->DisplayMode(); |
|
158 TSize size=bmp->SizeInPixels(); |
|
159 TInt sizeH=size.iHeight; |
|
160 TInt sizeW=size.iWidth; |
|
161 TInt expectedWidth, expectedHeight; |
|
162 if(GetIntFromConfig(aSection,KFldExpectedWidth, expectedWidth)) |
|
163 { |
|
164 if(expectedWidth!=sizeW) |
|
165 { |
|
166 ERR_PRINTF3(_L("The bitmap width in pixel is: %d not as expected: %d"), sizeW, expectedWidth); |
|
167 SetBlockResult(EFail); |
|
168 } |
|
169 else |
|
170 { |
|
171 INFO_PRINTF2(_L("The bitmap width in pixel is: %d as expected"),sizeW); |
|
172 } |
|
173 } |
|
174 |
|
175 if(GetIntFromConfig(aSection, KFldExpectedHeight, expectedHeight)) |
|
176 { |
|
177 if(expectedHeight!=sizeH) |
|
178 { |
|
179 ERR_PRINTF3(_L("The bitmap height in pixel is: %d not as expected: %d"), sizeH, expectedHeight); |
|
180 SetBlockResult(EFail); |
|
181 } |
|
182 else |
|
183 { |
|
184 INFO_PRINTF2(_L("The bitmap height in pixel is: %d as expected"),sizeH); |
|
185 } |
|
186 } |
|
187 } |
|
188 |
|
189 void CT_DataFbsBitGcBitmap::DoCmdLockHeap() |
|
190 { |
|
191 INFO_PRINTF1(_L("execute CFbsBitGcBitmap::LockHeap()")); |
|
192 iFbsBitGcBitmap->LockHeap(); |
|
193 } |
|
194 |
|
195 void CT_DataFbsBitGcBitmap::DoCmdUnlockHeap() |
|
196 { |
|
197 INFO_PRINTF1(_L("execute CFbsBitGcBitmap::UnlockHeap")); |
|
198 iFbsBitGcBitmap->UnlockHeap(); |
|
199 } |