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