|
1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <hal.h> |
|
17 #include <bautils.h> |
|
18 #include <bitdraw.h> |
|
19 #include <s32mem.h> |
|
20 #include "TDefect.h" |
|
21 #include <graphics/bitmap.inl> |
|
22 #include <graphics/gdi/gdiconsts.h> |
|
23 |
|
24 _LIT(KRamBitmapOnZ, "z:\\system\\data\\16RAM.mbm"); |
|
25 _LIT(KRamCBitmapOnZ, "z:\\system\\data\\16RAMC.mbm"); |
|
26 |
|
27 _LIT(KRamBitmap, "c:\\16RAM.mbm"); |
|
28 _LIT(KRamCBitmap, "c:\\16RAMC.mbm"); |
|
29 |
|
30 _LIT(KZeroSizeMbmRam, "c:\\ZeroSizeRam.mbm"); |
|
31 _LIT(KZeroSizeMbmZ, "z:\\system\\data\\ZeroSizeRam.mbm"); |
|
32 |
|
33 _LIT(KRomBitmap, "z:\\system\\data\\16ROM.mbm"); |
|
34 _LIT(KRomCBitmap, "z:\\system\\data\\16ROMC.mbm"); |
|
35 |
|
36 _LIT(KRomRsc_RomMbm, "z:\\system\\data\\RomRsc_RomMbm.rsc"); |
|
37 _LIT(KRomRsc_RomMbm2, "z:\\system\\data\\RomRsc_RomMbm2.rsc"); |
|
38 _LIT(KRamRsc_RamMbmOnZ, "z:\\system\\data\\RamRsc_RamMbm.rsc"); |
|
39 _LIT(KRamRsc_RamMbm2OnZ, "z:\\system\\data\\RamRsc_RamMbm2.rsc"); |
|
40 _LIT(KRamRsc_RamMbm, "c:\\RamRsc_RamMbm.rsc"); |
|
41 _LIT(KRamRsc_RamMbm2, "c:\\RamRsc_RamMbm2.rsc"); |
|
42 _LIT(KRscFileHeader, "z:\\system\\data\\RscHeader2.bin"); |
|
43 _LIT(KRscFileData, "z:\\system\\data\\DummyRscFile.rsc"); |
|
44 _LIT(KRomRsc_RamMbm, "z:\\system\\data\\RomRsc_RamMbm.rsc"); |
|
45 _LIT(KRamRsc_RomMbmOnZ, "z:\\system\\data\\RamRsc_RomMbm.rsc"); |
|
46 _LIT(KRamRsc_RomMbm, "c:\\RamRsc_RomMbm.rsc"); |
|
47 _LIT(KRamRsc_RomMbm2OnZ, "z:\\system\\data\\RamRsc_RomMbm2.rsc"); |
|
48 _LIT(KRamRsc_RomMbm2, "c:\\RamRsc_RomMbm2.rsc"); |
|
49 _LIT(KRomRsc_RamMbm2, "z:\\system\\data\\RomRsc_RamMbm2.rsc"); |
|
50 |
|
51 _LIT(KComprRamBitmap16, "z:\\system\\data\\paint16ramc.mbm"); |
|
52 _LIT(KComprRomBitmap16, "z:\\system\\data\\paint16romc.mbm"); |
|
53 _LIT(KComprRamBitmap24, "z:\\system\\data\\paint24ramc.mbm"); |
|
54 _LIT(KComprRomBitmap24, "z:\\system\\data\\paint24romc.mbm"); |
|
55 |
|
56 _LIT(KComprRamBitmap8, "z:\\system\\data\\8ramc.mbm"); |
|
57 _LIT(KComprRomBitmap8, "z:\\system\\data\\8romc.mbm"); |
|
58 _LIT(KComprRamBitmap12, "z:\\system\\data\\12ramc.mbm"); |
|
59 _LIT(KComprRomBitmap12, "z:\\system\\data\\12romc.mbm"); |
|
60 |
|
61 _LIT(KTestBmp, "z:\\system\\data\\BmCTest.mbm"); |
|
62 |
|
63 _LIT(KBitBltSrcBmp, "z:\\system\\data\\BitBltSrc.mbm"); |
|
64 _LIT(KBitBltMaskedBmp, "z:\\system\\data\\BitBltMasked.mbm"); |
|
65 |
|
66 _LIT(KBmpCompr12, "z:\\system\\data\\compr12_2.mbm"); |
|
67 _LIT(KBmpCompr16, "z:\\system\\data\\compr16_2.mbm"); |
|
68 _LIT(KBmpZCompr12, "z:\\system\\data\\racompr12_2.mbm"); |
|
69 _LIT(KBmpZCompr16, "z:\\system\\data\\racompr16_2.mbm"); |
|
70 _LIT(KBmpCCompr12, "c:\\racompr12_2.mbm"); |
|
71 _LIT(KBmpCCompr16, "c:\\racompr16_2.mbm"); |
|
72 |
|
73 _LIT(KBmp16_1, "c:\\Mbm16_1.mbm"); |
|
74 _LIT(KBmp16_2, "c:\\Mbm16_2.mbm"); |
|
75 _LIT(KBmp16_3, "c:\\Mbm16_3.mbm"); |
|
76 |
|
77 _LIT(KRam24BitmapOnZ, "z:\\system\\data\\24RAM.mbm"); |
|
78 _LIT(KRamC24BitmapOnZ, "z:\\system\\data\\24RAMC.mbm"); |
|
79 |
|
80 _LIT(KRam24Bitmap, "c:\\24RAM.mbm"); |
|
81 _LIT(KRamC24Bitmap, "c:\\24RAMC.mbm"); |
|
82 |
|
83 _LIT(KRom24Bitmap, "z:\\system\\data\\24ROM.mbm"); |
|
84 _LIT(KRomC24Bitmap, "z:\\system\\data\\24ROMC.mbm"); |
|
85 |
|
86 //Note: Do not name functions with Defect numbers, instead give a meaningful name. |
|
87 |
|
88 // |
|
89 // |
|
90 //Note: Some display modes will be scaled - see |
|
91 //CTDefect::CreateScreenDeviceL(TDisplayMode aDisplayMode, TAllowScaling aScaling), |
|
92 //SetScalingFactor() call |
|
93 |
|
94 // |
|
95 // |
|
96 //If we have to handle RAM located file with an embedded ROM mbm file section - |
|
97 //KRomMBMInRamRSC should be ETrue. |
|
98 //If it is not allowed to do that - KRomMBMInRamRSC should be EFalse. |
|
99 //#pragma warning(disable : 4127) //conditional expression is constant |
|
100 //Constant KRomMBMInRamRSc removed temporarily due to invalid test scenario |
|
101 //LOCAL_D const TBool KRomMBMInRamRSC = EFalse; |
|
102 |
|
103 // |
|
104 // |
|
105 |
|
106 // |
|
107 // |
|
108 //Globals |
|
109 LOCAL_D RFs TheFs; |
|
110 //Delay time in microseconds, used at the end of some test methods |
|
111 const TInt KDelayTime = 1;//1500000; |
|
112 |
|
113 // |
|
114 // |
|
115 //Create/Destroy test environment global functions |
|
116 |
|
117 //Delete "aFullName" file. |
|
118 LOCAL_C void DeleteDataFile(const TDesC& aFullName) |
|
119 { |
|
120 RFs fsSession; |
|
121 TInt err = fsSession.Connect(); |
|
122 if(err == KErrNone) |
|
123 { |
|
124 TEntry entry; |
|
125 if(fsSession.Entry(aFullName, entry) == KErrNone) |
|
126 { |
|
127 RDebug::Print(_L("Deleting \"%S\" file.\n"), &aFullName); |
|
128 err = fsSession.SetAtt(aFullName, 0, KEntryAttReadOnly); |
|
129 if(err != KErrNone) |
|
130 { |
|
131 RDebug::Print(_L("Error %d changing \"%S\" file attributes.\n"), err, &aFullName); |
|
132 } |
|
133 err = fsSession.Delete(aFullName); |
|
134 if(err != KErrNone) |
|
135 { |
|
136 RDebug::Print(_L("Error %d deleting \"%S\" file.\n"), err, &aFullName); |
|
137 } |
|
138 } |
|
139 fsSession.Close(); |
|
140 } |
|
141 else |
|
142 { |
|
143 RDebug::Print(_L("Error %d connecting file session. File: %S.\n"), err, &aFullName); |
|
144 } |
|
145 } |
|
146 |
|
147 //Copy test bitmaps from Z: to C: drive. RFs::Connect() had to be called already |
|
148 //on "TheFs" object. |
|
149 LOCAL_C void CopyDataFiles() |
|
150 { |
|
151 BaflUtils::CopyFile(TheFs, KRamBitmapOnZ, KRamBitmap); |
|
152 BaflUtils::CopyFile(TheFs, KRamCBitmapOnZ, KRamCBitmap); |
|
153 BaflUtils::CopyFile(TheFs, KRamRsc_RamMbmOnZ, KRamRsc_RamMbm); |
|
154 BaflUtils::CopyFile(TheFs, KRamRsc_RamMbm2OnZ, KRamRsc_RamMbm2); |
|
155 BaflUtils::CopyFile(TheFs, KRamRsc_RomMbmOnZ, KRamRsc_RomMbm); |
|
156 BaflUtils::CopyFile(TheFs, KRamRsc_RomMbm2OnZ, KRamRsc_RomMbm2); |
|
157 BaflUtils::CopyFile(TheFs, KZeroSizeMbmZ, KZeroSizeMbmRam); |
|
158 BaflUtils::CopyFile(TheFs, KBmpZCompr12, KBmpCCompr12); |
|
159 BaflUtils::CopyFile(TheFs, KBmpZCompr16, KBmpCCompr16); |
|
160 BaflUtils::CopyFile(TheFs, KRamBitmap, KBmp16_1); |
|
161 BaflUtils::CopyFile(TheFs, KRamBitmap, KBmp16_2); |
|
162 BaflUtils::CopyFile(TheFs, KRamBitmap, KBmp16_3); |
|
163 BaflUtils::CopyFile(TheFs, KRam24BitmapOnZ, KRam24Bitmap); |
|
164 BaflUtils::CopyFile(TheFs, KRamC24BitmapOnZ, KRamC24Bitmap); |
|
165 } |
|
166 |
|
167 //Delete data files used by the test |
|
168 LOCAL_C void DeleteDataFiles() |
|
169 { |
|
170 DeleteDataFile(KRamBitmap); |
|
171 DeleteDataFile(KRamCBitmap); |
|
172 DeleteDataFile(KRamRsc_RamMbm); |
|
173 DeleteDataFile(KRamRsc_RamMbm2); |
|
174 DeleteDataFile(KRamRsc_RomMbm); |
|
175 DeleteDataFile(KRamRsc_RomMbm2); |
|
176 DeleteDataFile(KRam24Bitmap); |
|
177 DeleteDataFile(KRamC24Bitmap); |
|
178 DeleteDataFile(_L("c:\\temp.mbm")); |
|
179 DeleteDataFile(_L("c:\\temp2.mbm")); |
|
180 DeleteDataFile(KZeroSizeMbmRam ); |
|
181 DeleteDataFile(KBmpCCompr12); |
|
182 DeleteDataFile(KBmpCCompr16); |
|
183 DeleteDataFile(KBmp16_1); |
|
184 DeleteDataFile(KBmp16_2); |
|
185 DeleteDataFile(KBmp16_3); |
|
186 } |
|
187 |
|
188 // |
|
189 // |
|
190 //Global functions |
|
191 |
|
192 //Return file size in bytes of "aFileName" file. |
|
193 LOCAL_C TInt FileSizeL(const TDesC& aFileName) |
|
194 { |
|
195 RFile file; |
|
196 User::LeaveIfError(file.Open(TheFs, aFileName, EFileRead)); |
|
197 CleanupClosePushL(file); |
|
198 TInt size = 0; |
|
199 User::LeaveIfError(file.Size(size)); |
|
200 CleanupStack::PopAndDestroy(&file); |
|
201 return size; |
|
202 } |
|
203 |
|
204 //Creates CFbsBitGcBitmap instance and loads it with bitmap N#0 from "aFileName" file. |
|
205 //CFbsBitGcBitmap instance will be pushed in the cleanup stack. |
|
206 CFbsBitGcBitmap* LoadBitmapLC(const TDesC& aFileName) |
|
207 { |
|
208 CFbsBitGcBitmap* bmp = new (ELeave) CFbsBitGcBitmap; |
|
209 CleanupStack::PushL(bmp); |
|
210 User::LeaveIfError(bmp->Load(aFileName, 0)); |
|
211 return bmp; |
|
212 } |
|
213 |
|
214 //Creates "SIZE" CFbsBitGcBitmap instance and loads them with bitmap N#0 from "aBmpFiles" |
|
215 //files. CFbsBitGcBitmap instances will be pushed in the cleanup stack. |
|
216 template <TInt SIZE> void LoadBitmapsLC(CFbsBitGcBitmap* (*aBmp)[SIZE], TPtrC aBmpFiles[]) |
|
217 { |
|
218 for(TInt ii=0;ii<SIZE;ii++) |
|
219 { |
|
220 (*aBmp)[ii] = LoadBitmapLC(aBmpFiles[ii]); |
|
221 } |
|
222 } |
|
223 |
|
224 //Displays "aBmp" array of bitmaps. |
|
225 template <TInt SIZE> void DisplayBitmaps(CFbsBitGcBitmap* (*aBmp)[SIZE], |
|
226 CFbsScreenDevice* aDevice, |
|
227 CFbsBitGc* aGc) |
|
228 { |
|
229 for(TInt ii=0;ii<SIZE;ii++) |
|
230 { |
|
231 TSize size = (*aBmp)[ii]->SizeInPixels(); |
|
232 aGc->Clear(); |
|
233 aGc->DrawBitmap(TRect(size), (*aBmp)[ii]); |
|
234 aDevice->Update(); |
|
235 User::After(KDelayTime); |
|
236 } |
|
237 } |
|
238 |
|
239 //Destroys "aBmp" array of bitmaps. |
|
240 template <TInt SIZE> void DestroyBitmaps(CFbsBitGcBitmap* (*aBmp)[SIZE]) |
|
241 { |
|
242 for(TInt ii=(SIZE-1);ii>-1;ii--) |
|
243 { |
|
244 CleanupStack::PopAndDestroy((*aBmp)[ii]); |
|
245 } |
|
246 } |
|
247 |
|
248 //Compares 2 bitmaps from "aBmp" array. |
|
249 //The first bitmap index is aBmp1, the second bitmap index is aBmp2. |
|
250 //The function compares bitmaps line by line and asserts their pixel values. |
|
251 template <TInt SIZE, TInt MAXLEN> void CompareBitmaps(CFbsBitGcBitmap* (*aBmp)[SIZE], |
|
252 TDisplayMode aDispMode, |
|
253 TInt aBmp1, |
|
254 TInt aBmp2, |
|
255 CTGraphicsBase *aTest) |
|
256 { |
|
257 TUint8 line1[MAXLEN]; |
|
258 TUint8 line2[MAXLEN]; |
|
259 TPtr8 p1(line1, MAXLEN, MAXLEN); |
|
260 TPtr8 p2(line2, MAXLEN, MAXLEN); |
|
261 TSize size1 = (*aBmp)[aBmp1]->SizeInPixels(); |
|
262 TSize size2 = (*aBmp)[aBmp2]->SizeInPixels(); |
|
263 TInt minHeight = Min(size1.iHeight, size2.iHeight); |
|
264 TInt minWidth = Min(size1.iWidth, size2.iWidth); |
|
265 for(TInt ii=0;ii<minHeight;ii++) |
|
266 { |
|
267 (*aBmp)[aBmp1]->GetScanLine(p1, TPoint(0,ii), minWidth, aDispMode); |
|
268 (*aBmp)[aBmp2]->GetScanLine(p2, TPoint(0,ii), minWidth, aDispMode); |
|
269 aTest->TEST(p1.Length() == p2.Length()); |
|
270 for(TInt j=0;j<p1.Length();j++) |
|
271 { |
|
272 aTest->TEST(line1[j] == line2[j]); |
|
273 } |
|
274 } |
|
275 } |
|
276 |
|
277 //Compares the Alpha Channel Values of the First Pixel in the two bitmaps. |
|
278 //The pixel value is obtained from DataAddress(). |
|
279 TBool CompareFirstPixelAlphaChannel(CFbsBitmap* aBmp1, CFbsBitmap* aBmp2) |
|
280 { |
|
281 return ( (*aBmp1->DataAddress() & 0xff000000) == (*aBmp2->DataAddress() & 0xff000000) ); |
|
282 } |
|
283 |
|
284 // |
|
285 // |
|
286 |
|
287 CTDefect::CTDefect(CTestStep* aStep) : |
|
288 CTGraphicsBase(aStep), |
|
289 iDevice(NULL), |
|
290 iBmpDevice(NULL), |
|
291 iGc(NULL), |
|
292 iBitmap(NULL), |
|
293 iSize(0, 0), |
|
294 iCurrentMode(ENone) |
|
295 { |
|
296 } |
|
297 |
|
298 CTDefect::~CTDefect() |
|
299 { |
|
300 DestroyFont(); |
|
301 DeleteBitmap(); |
|
302 DeleteGraphicsContext(); |
|
303 DeleteBitmapDevice(); |
|
304 DeleteScreenDevice(); |
|
305 } |
|
306 |
|
307 void CTDefect::ConstructL() |
|
308 { |
|
309 INFO_PRINTF1(_L("Create screen device")); |
|
310 CreateScreenDeviceL(); |
|
311 |
|
312 TUint32* romAddress = NULL; |
|
313 if(!CFbsBitmap::IsFileInRom(KRomBitmap, romAddress)) //check any rom bitmap |
|
314 { |
|
315 INFO_PRINTF2(_L("Skipping tests of ROM bitmaps since file \"%S\" is reported to not be a ROM bitmap."), |
|
316 &KRomBitmap); |
|
317 INFO_PRINTF1(_L("This should only occur on non-XIP ROMs, e.g. NAND ROMs, where ROM bitmaps aren't supported.")); |
|
318 iSkipRomBitmapTests = ETrue; |
|
319 } |
|
320 } |
|
321 |
|
322 void CTDefect::CreateScreenDeviceL(TAllowScaling aScaling) |
|
323 { |
|
324 DeleteGraphicsContext(); |
|
325 DeleteScreenDevice(); |
|
326 TDisplayMode mode[] = {EColor256, EColor4K, EColor16M, EColor16MU, EColor64K, |
|
327 EGray256, EGray16, EGray4, EGray2, EColor16, EColor16MA, EColor16MAP}; |
|
328 TInt ii; |
|
329 TInt err = KErrNotSupported; |
|
330 for(ii=0;(ii<TInt(sizeof(mode)/sizeof(mode[0]))) && (err == KErrNotSupported);++ii) |
|
331 { |
|
332 err = CreateScreenDeviceL(mode[ii], aScaling); |
|
333 } |
|
334 if (err==KErrNone) |
|
335 { |
|
336 _LIT(KLog,"Sucessfully created screen device %S"); |
|
337 INFO_PRINTF2(KLog,&ColorModeName(mode[ii])); |
|
338 } |
|
339 TEST(err == KErrNone); |
|
340 } |
|
341 |
|
342 TInt CTDefect::CreateScreenDeviceL(TDisplayMode aDisplayMode, TAllowScaling aScaling) |
|
343 { |
|
344 DeleteGraphicsContext(); |
|
345 DeleteScreenDevice(); |
|
346 TRAPD(err, iDevice=CFbsScreenDevice::NewL(KNullDesC,aDisplayMode)); |
|
347 if(err == KErrNotSupported) |
|
348 { |
|
349 return err; |
|
350 } |
|
351 if (err!=KErrNone) |
|
352 { |
|
353 _LIT(KLog,"Failed to create screen device %S return value %d"); |
|
354 INFO_PRINTF3(KLog,&ColorModeName(aDisplayMode),err); |
|
355 } |
|
356 else |
|
357 { |
|
358 _LIT(KLog,"Created Screen Device iDevice=0x%x"); |
|
359 INFO_PRINTF2(KLog,iDevice); |
|
360 } |
|
361 TEST(err == KErrNone); |
|
362 err = iDevice->CreateContext((CGraphicsContext*&)iGc); |
|
363 TEST(err == KErrNone); |
|
364 if(aScaling == EScalingAllowed) |
|
365 { |
|
366 iDevice->SetScalingFactor(TPoint(31, 11), 2, 2, 1, 1); |
|
367 iGc->Activate(iDevice); |
|
368 } |
|
369 iGc->SetUserDisplayMode(aDisplayMode); |
|
370 iDevice->ChangeScreenDevice(NULL); |
|
371 iDevice->SetAutoUpdate(EFalse); |
|
372 iSize = iDevice->SizeInPixels(); |
|
373 iCurrentMode = aDisplayMode; |
|
374 return err; |
|
375 } |
|
376 |
|
377 void CTDefect::RunTestCaseL(TInt aCurTestCase) |
|
378 { |
|
379 ((CTDefectStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); |
|
380 switch(aCurTestCase) |
|
381 { |
|
382 case 1: |
|
383 ((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0045")); |
|
384 INFO_PRINTF1(_L("DEF014364")); |
|
385 DEF014364L(); |
|
386 INFO_PRINTF1(_L("Cleared DEF014364\n")); |
|
387 break; |
|
388 case 2: |
|
389 ((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0046")); |
|
390 INFO_PRINTF1(_L("DEF017758")); |
|
391 DEF017758(); |
|
392 INFO_PRINTF1(_L("Cleared DEF017758\n")); |
|
393 break; |
|
394 case 3: |
|
395 ((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0047")); |
|
396 INFO_PRINTF1(_L("16 bpp bitmap comperssion")); |
|
397 BitmapCompressionL(E16BppBmpType); |
|
398 break; |
|
399 case 4: |
|
400 ((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0047")); |
|
401 INFO_PRINTF1(_L("24 bpp bitmap comperssion")); |
|
402 BitmapCompressionL(E24BppBmpType); |
|
403 break; |
|
404 case 5: |
|
405 ((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0048")); |
|
406 INFO_PRINTF1(_L("New RSC file format")); |
|
407 NewRscFormatL(); |
|
408 break; |
|
409 case 6: |
|
410 ((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0049")); |
|
411 INFO_PRINTF1(_L("INC031920 - 16 bpp bitmaps")); |
|
412 INC031920L(E16BppBmpType, ETrue); |
|
413 INC031920L(E16BppBmpType, EFalse); |
|
414 break; |
|
415 case 7: |
|
416 ((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0049")); |
|
417 INFO_PRINTF1(_L("INC031920 - 24 bpp bitmaps")); |
|
418 INC031920L(E24BppBmpType, ETrue); |
|
419 INC031920L(E24BppBmpType, EFalse); |
|
420 break; |
|
421 case 8: |
|
422 ((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0050")); |
|
423 INFO_PRINTF1(_L("8 bit bitmap compression - ROM")); |
|
424 Test8bitBmpComressionL(); |
|
425 break; |
|
426 case 9: |
|
427 ((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0051")); |
|
428 INFO_PRINTF1(_L("12 bit bitmap compression - ROM")); |
|
429 Test12bitBmpComressionL(); |
|
430 break; |
|
431 case 10: |
|
432 ((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0044")); |
|
433 INFO_PRINTF1(_L("ZeroSizeBitmap")); |
|
434 ZeroSizeBitmap(); |
|
435 break; |
|
436 case 11: |
|
437 ((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0052")); |
|
438 INFO_PRINTF1(_L("DEF034134")); |
|
439 DEF034134L(); |
|
440 break; |
|
441 case 12: |
|
442 ((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0053")); |
|
443 INFO_PRINTF1(_L("Test tiling occurs correctly")); |
|
444 TestTilingHorizontalAndVerticalL(); |
|
445 break; |
|
446 case 13: |
|
447 ((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0054")); |
|
448 INFO_PRINTF1(_L("Borderline cases for DrawPie")); |
|
449 DrawPieBorderlineCasesL(); |
|
450 break; |
|
451 case 14: |
|
452 ((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0055")); |
|
453 INFO_PRINTF1(_L("INC037380")); |
|
454 INC037380L(); |
|
455 break; |
|
456 case 15: |
|
457 ((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0056")); |
|
458 INFO_PRINTF1(_L("INC037474")); |
|
459 INC037474L(); |
|
460 break; |
|
461 case 16: |
|
462 ((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0058")); |
|
463 INFO_PRINTF1(_L("CFbsBitmap::SetDisplayMode() test")); |
|
464 TestSettingDisplayModeL(); |
|
465 break; |
|
466 case 17: |
|
467 ((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0059")); |
|
468 INFO_PRINTF1(_L("CFbsBitmap::SetDisplayMode() test 2")); |
|
469 TestSettingDisplayMode2L(); |
|
470 break; |
|
471 case 18: |
|
472 ((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0060")); |
|
473 INFO_PRINTF1(_L("CFbsBitmap::SwappingWidthAndHeight() test")); |
|
474 TestSwappingWidthAndHeightL(); |
|
475 break; |
|
476 case 19: |
|
477 ((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0057")); |
|
478 INFO_PRINTF1(_L("INC037370")); |
|
479 INC037370L(); |
|
480 break; |
|
481 case 20: |
|
482 ((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0061")); |
|
483 INFO_PRINTF1(_L("DEF038774")); |
|
484 DEF038774L(); |
|
485 break; |
|
486 case 21: |
|
487 ((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0062")); |
|
488 INFO_PRINTF1(_L("INC070043L")); |
|
489 INC070043L(); |
|
490 break; |
|
491 case 22: |
|
492 ((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0043")); |
|
493 INFO_PRINTF1(_L("OOM test")); |
|
494 TestOom(); |
|
495 break; |
|
496 case 23: |
|
497 ((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0063")); |
|
498 INFO_PRINTF1(_L("Bitmaps Swapping Test")); |
|
499 BitmapsSwappingTest(); |
|
500 break; |
|
501 case 24: |
|
502 ((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0064")); |
|
503 INFO_PRINTF1(_L("INC093055")); |
|
504 INC093055L(); |
|
505 break; |
|
506 case 25: |
|
507 ((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0016")); |
|
508 INFO_PRINTF1(_L("PDEF103809")); |
|
509 PDEF103809L(); |
|
510 break; |
|
511 case 26: |
|
512 /** |
|
513 @SYMTestCaseID GRAPHICS-BITGDI-0018 |
|
514 |
|
515 @SYMDEF DEF104856 |
|
516 |
|
517 @SYMTestCaseDesc Test that the bitmap and mask are drawn correctly testing |
|
518 CFbsBitGc::DoBitBltMaskedFlicker in order to test the DEF104856 fix |
|
519 introduced in CFbsBitGc::DoBitBltMaskedFlicker method |
|
520 |
|
521 @SYMTestPriority High |
|
522 |
|
523 @SYMTestStatus Implemented |
|
524 |
|
525 @SYMTestActions Create compressed EColor64K bitmap and mask and draw bitmap calling |
|
526 CFbsBitGc::BitBltMasked with an offscreen bitmap device |
|
527 |
|
528 @SYMTestExpectedResults The resulting bitmap is not altered or corrupted by the code module |
|
529 **/ |
|
530 ((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0018")); |
|
531 INFO_PRINTF1(_L("BitBltMasked Flicker Test - DEF104856")); |
|
532 TestDoBltMaskedL(EColor64K, EColor64K, EColor64K, TSize(16,16), EFalse, ETrue); |
|
533 break; |
|
534 case 27: |
|
535 /** |
|
536 @SYMTestCaseID GRAPHICS-BITGDI-0019 |
|
537 |
|
538 @SYMDEF DEF104856 |
|
539 |
|
540 @SYMTestCaseDesc Test that the bitmap and mask are drawn correctly testing |
|
541 CFbsBitGc::DoBitBltMaskedNonFlicker in order to test the DEF104856 fix |
|
542 introduced in CFbsBitGc::DoBitBltMaskedNonFlicker method |
|
543 |
|
544 @SYMTestPriority High |
|
545 |
|
546 @SYMTestStatus Implemented |
|
547 |
|
548 @SYMTestActions Create compressed EColor64K bitmap and mask and draw bitmap calling |
|
549 CFbsBitGc::BitBltMasked with a screen device and brush style EVerticalHatchBrush |
|
550 |
|
551 @SYMTestExpectedResults The resulting bitmap is not altered or corrupted by the code module |
|
552 **/ |
|
553 ((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0019")); |
|
554 INFO_PRINTF1(_L("BitBltMasked non Flicker Test - DEF104856")); |
|
555 TestDoBltMaskedL(EColor64K, EColor64K, EColor64K, TSize(16,16), ETrue, ETrue); |
|
556 break; |
|
557 case 28: |
|
558 /** |
|
559 @SYMTestCaseID GRAPHICS-BITGDI-0092 |
|
560 |
|
561 @SYMDEF DEF108338 |
|
562 |
|
563 @SYMTestCaseDesc Test that the bitmap is drawn correctly by testing |
|
564 that the correct area of the mask is used for masking. |
|
565 CFbsBitGc::DoBitBltMaskedFlicker is called in this case. |
|
566 |
|
567 @SYMTestPriority High |
|
568 |
|
569 @SYMTestStatus Implemented |
|
570 |
|
571 @SYMTestActions Create compressed EColor64K bitmap and EGray2 mask and draw bitmap calling |
|
572 CFbsBitGc::BitBltMasked with a screen device. The drawing is done in a loop |
|
573 to simulate the scrolling effect as in a browser. |
|
574 |
|
575 @SYMTestExpectedResults All the stripes should pass the integrity check. |
|
576 **/ |
|
577 ((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0092")); |
|
578 INFO_PRINTF1(_L("BitBltMasked Flicker - DEF108338")); |
|
579 TestDoBltMaskedL(EColor64K, EGray2, EColor16MU, TSize(96,96), EFalse, EFalse); |
|
580 break; |
|
581 case 29: |
|
582 /** |
|
583 @SYMTestCaseID GRAPHICS-BITGDI-0093 |
|
584 |
|
585 @SYMDEF DEF108338 |
|
586 |
|
587 @SYMTestCaseDesc Test that the bitmap is drawn correctly by testing |
|
588 that the correct area of the mask is used for masking. |
|
589 CFbsBitGc::DoBitBltMaskedNonFlicker is called in this case. |
|
590 |
|
591 @SYMTestPriority High |
|
592 |
|
593 @SYMTestStatus Implemented |
|
594 |
|
595 @SYMTestActions Create compressed EColor64K bitmap and EGray2 mask and draw bitmap calling |
|
596 CFbsBitGc::BitBltMasked with a screen device. The drawing is done in a loop |
|
597 to simulate the scrolling effect as in a browser. |
|
598 |
|
599 @SYMTestExpectedResults All the stripes should pass the integrity check. |
|
600 **/ |
|
601 ((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0093")); |
|
602 INFO_PRINTF1(_L("BitBltMasked Non Flicker - DEF108338")); |
|
603 //skip the test if the screen does not have a fast blit interface. |
|
604 if(CFbsDrawDevice::DisplayMode16M() == ENone) |
|
605 { |
|
606 INFO_PRINTF1(_L("Test skipped - The screen does not have a fast blit interface!")); |
|
607 break; |
|
608 } |
|
609 TestDoBltMaskedL(EColor64K, EGray2, EColor16MU, TSize(96,96), ETrue, EFalse); |
|
610 break; |
|
611 case 30: |
|
612 /** |
|
613 @SYMTestCaseID GRAPHICS-BITGDI-0020 |
|
614 |
|
615 @SYMDEF DEF103736 |
|
616 |
|
617 @SYMTestCaseDesc Test to check that EColor16MAP mode correctly draws bitmaps when using a EColor16MAP mask |
|
618 |
|
619 @SYMTestPriority Normal |
|
620 |
|
621 @SYMTestStatus Implemented |
|
622 |
|
623 @SYMTestActions Create compressed EColor16MAP bitmap and mask and draw bitmap calling |
|
624 CFbsBitGc::BitBltMasked with an offscreen bitmap device |
|
625 |
|
626 @SYMTestExpectedResults The resulting bitmap is not altered or corrupted by the code module |
|
627 **/ |
|
628 ((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0020")); |
|
629 INFO_PRINTF1(_L("BitBltMasked non Flicker Test ECOLOR16MAP - DEF103736")); |
|
630 TestDoBltMaskedL(EColor16MAP, EColor16MAP, EColor16MAP, TSize(16,16), EFalse, ETrue); |
|
631 break; |
|
632 case 31: |
|
633 /** |
|
634 @SYMTestCaseID GRAPHICS-BITGDI-0094 |
|
635 |
|
636 @SYMDEF PDEF108863 |
|
637 |
|
638 @SYMTestCaseDesc Test that CFbsBitGc::DoBitBltAlpha() function behaves correctly |
|
639 when source is EColor16MU, mask is EGray256, both source and mask are compressed |
|
640 and the screen driver has no MFastBlit interface. |
|
641 |
|
642 @SYMTestPriority High |
|
643 |
|
644 @SYMTestStatus Implemented |
|
645 |
|
646 @SYMTestActions Create compressed EColor16MU bitmap and EGray256 mask and draw bitmap calling |
|
647 CFbsBitGc::BitBltMasked with a screen device. Where screen driver has no MFastBlit interface. |
|
648 |
|
649 @SYMTestExpectedResults All the stripes should pass the integrity check. |
|
650 **/ |
|
651 ((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0094")); |
|
652 INFO_PRINTF1(_L("PDEF108863 - DoBitBltAlpha for EColor16MU source, EGray256 mask and no MFastBlit interface")); |
|
653 TestDoBltMaskedL(EColor16MU, EGray256, EColor16MA, TSize(96,96), EFalse, EFalse); |
|
654 break; |
|
655 case 32: |
|
656 ((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0095")); |
|
657 INFO_PRINTF1(_L("PDEF110934 - DoBitBltMasked for mask height is less/greater than the bitmap height")); |
|
658 TestDoBitBltMaskedSizeL(); |
|
659 break; |
|
660 case 33: |
|
661 /** |
|
662 @SYMTestCaseID GRAPHICS-BITGDI-0096 |
|
663 |
|
664 @SYMDEF PDEF114309 |
|
665 |
|
666 @SYMTestCaseDesc Test to check that EColor16MU mode correctly BitBltMasks when source and mask are of EColor16MA |
|
667 |
|
668 @SYMTestPriority Normal |
|
669 |
|
670 @SYMTestStatus Implemented |
|
671 |
|
672 @SYMTestActions Create source, mask and destination bitmaps of EColor16MA, EColor16MA and EColor16MU respectively |
|
673 Call BitBltMaksed on the destination device and check the output |
|
674 |
|
675 @SYMTestExpectedResults The resulting bitmap contents should match the calculated value |
|
676 **/ |
|
677 ((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0096")); |
|
678 INFO_PRINTF1(_L("BitBltMasked for EColor16MU with source and mask of EColor16MA - PDEF114309")); |
|
679 TestBitBltMaskedEColor16MUL(); |
|
680 break; |
|
681 case 34: |
|
682 ((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0102")); |
|
683 INFO_PRINTF1(_L("Externalize()/Internalize() of CFbsBitGcExtraData in CFbsBitmap - DEF120360")); |
|
684 ExternalizeInternalizeCFbsBitGCExtraData(); |
|
685 break; |
|
686 case 35: |
|
687 ((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0086")); |
|
688 INFO_PRINTF1(_L("Test BitBlt with 16MU source & target copies rather than overwrites alpha channel - DEF121299")); |
|
689 TestBitBltOperationsOn16muUndefinedByteL(); |
|
690 break; |
|
691 case 36: |
|
692 ((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0107")); |
|
693 INFO_PRINTF1(_L("Test DrawBitmap() with clipping and scaling - DEF126160")); |
|
694 TestClippedScaledBitmapL(); |
|
695 break; |
|
696 case 37: |
|
697 ((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0109")); |
|
698 INFO_PRINTF1(_L("Test TestDrawBitmapTwipsNotSet() - DEF128522")); |
|
699 TestDrawBitmapTwipsNotSet(); |
|
700 break; |
|
701 case 38: |
|
702 ((CTDefectStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0119")); |
|
703 INFO_PRINTF1(_L("Test DrawBitmapMasked() with compressed bitmaps")); |
|
704 TestDrawBitmapMaskedL(); |
|
705 break; |
|
706 case 39: |
|
707 ((CTDefectStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); |
|
708 ((CTDefectStep*)iStep)->CloseTMSGraphicsStep(); |
|
709 TestComplete(); |
|
710 break; |
|
711 } |
|
712 ((CTDefectStep*)iStep)->RecordTestResultL(); |
|
713 } |
|
714 |
|
715 void CTDefect::TestBitBltMaskedEColor16MUL() |
|
716 { |
|
717 TInt width = 128; |
|
718 TInt height = 178; |
|
719 |
|
720 TSize size(width, height); |
|
721 TInt transpFactor = 100; |
|
722 |
|
723 // Create a destination bitmap of EColro16MU and fill some color in it |
|
724 CFbsBitmap* destBitmap = new CFbsBitmap(); |
|
725 CleanupStack::PushL(destBitmap); |
|
726 User::LeaveIfError(destBitmap->Create(size, EColor16MU)); |
|
727 CFbsBitmapDevice* destDev = CFbsBitmapDevice::NewL(destBitmap); |
|
728 CleanupStack::PushL(destDev); |
|
729 CFbsBitGc* destGc = NULL; |
|
730 User::LeaveIfError(destDev->CreateContext(destGc)); |
|
731 CleanupStack::PushL(destGc); |
|
732 |
|
733 destGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
734 destGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
735 destGc->SetBrushColor(KRgbRed); |
|
736 destGc->DrawRect(TRect(TPoint(), size)); |
|
737 |
|
738 // Create a source bitmap fill it with some color and then draw it with some color with transparency on it |
|
739 CFbsBitmap* srcBitmap = new (ELeave) CFbsBitmap; |
|
740 CleanupStack::PushL(srcBitmap); |
|
741 User::LeaveIfError(srcBitmap->Create(size, EColor16MA)); |
|
742 CFbsBitmapDevice* srcDev = CFbsBitmapDevice::NewL(srcBitmap); |
|
743 CleanupStack::PushL(srcDev); |
|
744 CFbsBitGc* srcGc = NULL; |
|
745 User::LeaveIfError(srcDev->CreateContext(srcGc)); |
|
746 CleanupStack::PushL(srcGc); |
|
747 |
|
748 srcGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
749 srcGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); |
|
750 srcGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
751 srcGc->SetBrushColor(TRgb(0xff,0xff,0xff,transpFactor)); |
|
752 srcGc->DrawRect(TRect(TPoint(), size)); |
|
753 |
|
754 // Create a mask bitmap and fill with TRgb(30,30,30) |
|
755 CFbsBitmap* maskBitmap = new (ELeave) CFbsBitmap; |
|
756 CleanupStack::PushL(maskBitmap); |
|
757 User::LeaveIfError(maskBitmap->Create(size, EColor16MA)); |
|
758 CFbsBitmapDevice* maskDev = CFbsBitmapDevice::NewL(maskBitmap); |
|
759 CleanupStack::PushL(maskDev); |
|
760 CFbsBitGc* maskGc = NULL; |
|
761 User::LeaveIfError(maskDev->CreateContext(maskGc)); |
|
762 CleanupStack::PushL(maskGc); |
|
763 |
|
764 maskGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
765 maskGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
766 maskGc->SetBrushColor(TRgb( 30, 30, 30 )); |
|
767 maskGc->DrawRect(size); |
|
768 |
|
769 // Then call BitBltMaksed() on it |
|
770 destGc->SetDrawMode(CGraphicsContext::EDrawModePEN); |
|
771 destGc->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
772 destGc->BitBltMasked(TPoint(), srcBitmap, TRect(size), maskBitmap, ETrue); |
|
773 |
|
774 // These are the values that we gave for source bitmaps |
|
775 TUint32 srcPixel = 0x64FFFFFF; // i,e TRgb(0xff,0xff,0xff,transpFactor) |
|
776 TUint8 srcMask = 0x64; // transpFactor |
|
777 TUint32 destPixel = 0xFFFFFFFF; // White becasue nothing has drawn on it |
|
778 |
|
779 // When we draw source bitmap with transparency, it actually alpha blends |
|
780 // with the above parameters |
|
781 srcPixel = AlphaBlendWithDestAlphaFF(srcPixel, srcMask, destPixel); |
|
782 |
|
783 // For displaymode which has alpha, mask is inverted i,e 255-30 = 225 or 0xE1 |
|
784 srcMask = 0xE1; // mask bitmap's TRgb( 30, 30, 30 ) |
|
785 destPixel = 0xFFFF0000; // KRgbRed of destination bitmap |
|
786 destPixel = AlphaBlendWithDestAlphaFF(srcPixel, srcMask, destPixel); |
|
787 |
|
788 // Function to check the contents of the destination bitmap, |
|
789 // if the INC111510 fix is not applied then this function will fail |
|
790 CheckBitmapContents(destDev, width, height, destPixel); |
|
791 |
|
792 CleanupStack::PopAndDestroy(9, destBitmap); |
|
793 } |
|
794 |
|
795 // This function is for alpha blending when the destination alpha is FF |
|
796 TUint32 CTDefect::AlphaBlendWithDestAlphaFF(const TUint32 aSrcPixel, const TUint8 aMask, TUint32 aDestPixel) |
|
797 { |
|
798 if(aMask) |
|
799 { |
|
800 if(aMask == 0xFF) |
|
801 return 0xff000000|aSrcPixel; |
|
802 |
|
803 // This is the formula used for alpha blending |
|
804 // (a) (mask * src + (255 - mask) * dest) / 255 This is the ideal formula |
|
805 // (b) ((mask * (src - dest)) >> 8) + dest A faster approximation to (a) |
|
806 // (c) ((mask * (256 + src - dest) >> 8) + dest - mask Equivalent to (b) but can be used on multiple colors at a time |
|
807 |
|
808 const TUint32 s_rb = aSrcPixel & 0x00FF00FF; |
|
809 const TUint32 d_rb = aDestPixel & 0x00FF00FF; |
|
810 const TUint32 mask2 = aMask | (aMask << 16); |
|
811 const TUint32 rb = ((((aMask * ((0x01000100 + s_rb) - d_rb)) >> 8) + d_rb) - mask2) & 0x00FF00FF; |
|
812 |
|
813 const TInt s_g = (aSrcPixel & 0xFF00) >> 8; |
|
814 const TInt d_g = (aDestPixel & 0xFF00) >> 8; |
|
815 const TInt g = ((aMask * (s_g - d_g)) >> 8) + d_g; |
|
816 |
|
817 return(rb | (g<<8) | 0xff000000); |
|
818 } |
|
819 |
|
820 return aDestPixel; |
|
821 } |
|
822 |
|
823 // This function is to check each pixel of the given bitmap |
|
824 void CTDefect::CheckBitmapContents(CFbsDevice* aDevice, TInt aWidth, TInt aHeight, TUint32 aExpectedValue) |
|
825 { |
|
826 TRgb color; |
|
827 for(TInt y = 0; y < aHeight; ++y) |
|
828 { |
|
829 for(TInt x = 0; x < aWidth; ++x) |
|
830 { |
|
831 aDevice->GetPixel(color, TPoint(x, y)); |
|
832 if(aExpectedValue != color.Internal()) |
|
833 { |
|
834 TEST(EFalse); |
|
835 return; |
|
836 } |
|
837 } |
|
838 } |
|
839 } |
|
840 |
|
841 /** |
|
842 @SYMTestCaseID GRAPHICS-BITGDI-0043 |
|
843 |
|
844 @SYMDEF INC042156L |
|
845 |
|
846 @SYMTestCaseDesc Out of memory test |
|
847 |
|
848 @SYMTestPriority High |
|
849 |
|
850 @SYMTestStatus Implemented |
|
851 |
|
852 @SYMTestActions Sets the next heap allocation to fail before attempting various bitmaps operations |
|
853 |
|
854 @SYMTestExpectedResults Allocation should fail gracefullly |
|
855 */ |
|
856 void CTDefect::TestOom() |
|
857 { |
|
858 TInt err, tryCount = 0; |
|
859 |
|
860 INFO_PRINTF1(_L("INC042156L")); |
|
861 |
|
862 do |
|
863 { |
|
864 User::__DbgSetAllocFail(RHeap::EUser, RHeap::EFailNext, ++tryCount); |
|
865 User::__DbgMarkStart(RHeap::EUser); |
|
866 { |
|
867 TRAP(err, INC042156L()); |
|
868 } |
|
869 User::__DbgMarkEnd(RHeap::EUser, 0); |
|
870 } |
|
871 while(err == KErrNoMemory); |
|
872 |
|
873 if(err == KErrNone) |
|
874 { |
|
875 // Reset |
|
876 User::__DbgSetAllocFail(RHeap::EUser,RHeap::ENone,1); |
|
877 } |
|
878 else |
|
879 { |
|
880 TEST(err == KErrNone); |
|
881 } |
|
882 |
|
883 INFO_PRINTF2(_L("- server succeeded at heap failure rate of %i"), tryCount); |
|
884 User::After(3000000); |
|
885 } |
|
886 |
|
887 |
|
888 /** |
|
889 @SYMTestCaseID GRAPHICS-BITGDI-0044 |
|
890 |
|
891 @SYMDEF |
|
892 |
|
893 @SYMTestCaseDesc tests that CBitwiseBitmap::SizeOfByteDataCompressed, SizeOfTwelveBitDataCompressed, SizeOfSixteenBitDataCompressed & |
|
894 SizeOfTwentyFourBitDataCompressed can handle zero size bitmaps |
|
895 |
|
896 @SYMTestPriority High |
|
897 |
|
898 @SYMTestStatus Implemented |
|
899 |
|
900 @SYMTestActions Loads a zerosize bitmap the compresses it |
|
901 |
|
902 @SYMTestExpectedResults Test should perform graphics operations succesfully. |
|
903 */ |
|
904 void CTDefect::ZeroSizeBitmap() |
|
905 { |
|
906 DeleteBitmap(); |
|
907 iBitmap = new (ELeave) CFbsBitmap; |
|
908 |
|
909 TInt err = iBitmap->Load(KZeroSizeMbmRam); |
|
910 TEST(err == KErrCorrupt); |
|
911 if(err != KErrCorrupt) |
|
912 { |
|
913 err =iBitmap->Compress(); |
|
914 TEST(err == KErrNone); |
|
915 } |
|
916 } |
|
917 |
|
918 /** |
|
919 @SYMTestCaseID GRAPHICS-BITGDI-0045 |
|
920 |
|
921 @SYMDEF DEF014364 |
|
922 |
|
923 @SYMTestCaseDesc Tests opening of a corrupt bitmap and resizing to (0,0) |
|
924 |
|
925 @SYMTestPriority High |
|
926 |
|
927 @SYMTestStatus Implemented |
|
928 |
|
929 @SYMTestActions tries to open a corrupt bitmap then attempts to resize a new bitmap to (0,0) size |
|
930 |
|
931 @SYMTestExpectedResults Test should perform graphics operations succesfully. |
|
932 */ |
|
933 void CTDefect::DEF014364L() |
|
934 { |
|
935 DeleteBitmap(); |
|
936 iBitmap = new (ELeave) CFbsBitmap; |
|
937 TInt err = iBitmap->Load(_L("z:\\system\\data\\Corrupt000.wbmp")); |
|
938 //It should not be possible to open corrupted bitmap file. |
|
939 if (err!=KErrNotSupported) |
|
940 { |
|
941 _LIT(KLog,"Corrupt bitmap Corrupt000.wbmp gave wrong error code when opening err=%d"); |
|
942 INFO_PRINTF2(KLog,err); |
|
943 } |
|
944 TEST(err == KErrNotSupported); |
|
945 err = iBitmap->Create(TSize(20, 20), iCurrentMode); |
|
946 if (err!=KErrNone) |
|
947 { |
|
948 _LIT(KLog,"Failed to create bitmap err=%d"); |
|
949 INFO_PRINTF2(KLog,err); |
|
950 } |
|
951 TEST(err == KErrNone); |
|
952 DeleteBitmapDevice(); |
|
953 TRAP(err, iBmpDevice = CFbsBitmapDevice::NewL(iBitmap)); |
|
954 if (err!=KErrNone) |
|
955 { |
|
956 _LIT(KLog,"Failed to create bitmap device err=%d"); |
|
957 INFO_PRINTF2(KLog,err); |
|
958 } |
|
959 TEST(err == KErrNone); |
|
960 //It should not be possible to resize bitmap device to (0, 0) size. |
|
961 //Yes it should, setting size to 0,0 is necessary to maintain |
|
962 //6.1 application compatibility with 7.0s. |
|
963 err = iBmpDevice->Resize(TSize(0, 0)); |
|
964 if (err!=KErrNone) |
|
965 { |
|
966 _LIT(KLog,"Failed to resize bitmap err=%d"); |
|
967 INFO_PRINTF2(KLog,err); |
|
968 } |
|
969 TEST(err == KErrNone); |
|
970 //It should be possible to resize bitmap to (0, 0) size. |
|
971 err = iBitmap->Resize(TSize(0, 0)); |
|
972 if (err!=KErrNone) |
|
973 { |
|
974 _LIT(KLog,"Failed to resize bitmap2 err=%d"); |
|
975 INFO_PRINTF2(KLog,err); |
|
976 } |
|
977 TEST(err == KErrNone); |
|
978 //The next call should not fail with "Divide by Zero" exception on WINS platform. |
|
979 iGc->DrawBitmap(TRect(0, 0, 10, 10), iBitmap, TRect(0, 0, 10, 10)); |
|
980 } |
|
981 |
|
982 //DEF023605 - Panic when bmp file is opened using Paint. |
|
983 void CTDefect::DEF023605L() |
|
984 { |
|
985 DeleteBitmap(); |
|
986 iBitmap = new (ELeave) CFbsBitmap; |
|
987 TInt err = iBitmap->Create(iSize, iCurrentMode); |
|
988 TEST(err == KErrNone); |
|
989 //It should not be possible to resize bitmap to (max_int, ...) size. |
|
990 err = iBitmap->Resize(TSize(0x7FFFFFFF, 16)); |
|
991 TEST(err == KErrNone); |
|
992 } |
|
993 |
|
994 /** |
|
995 @SYMTestCaseID GRAPHICS-BITGDI-0046 |
|
996 |
|
997 @SYMDEF DEF017758 |
|
998 |
|
999 @SYMTestCaseDesc Memory leak detected on target when using DirectScreenAccess |
|
1000 |
|
1001 @SYMTestPriority High |
|
1002 |
|
1003 @SYMTestStatus Implemented |
|
1004 |
|
1005 @SYMTestActions |
|
1006 |
|
1007 // |
|
1008 //The statement between __UHEAP_MARK and __UHEAP_END can cause memory leak! |
|
1009 //Obviously we have some kind of first time memory allocation when the |
|
1010 //method is called for the first time. Exactly the same method is called from |
|
1011 //CFbsScreenDevice::ConstructL() method. |
|
1012 // |
|
1013 //To see the problem: |
|
1014 //1. Comment HAL::Get() call into E32Main(). |
|
1015 //2. Build ARM4 UDEB version of TDefect and make sure it is used into rom image build |
|
1016 //3. Build textshell rom image: |
|
1017 // buildrom assabet textshell_70s graphics_70s.iby graphicstests_70s.iby |
|
1018 //4. Run TDefect app on the assabet. |
|
1019 // You will see a memory leak. If you uncomment HAL::Get() call into E32Main() and repeat |
|
1020 // steps 1..4 - everything is OK. |
|
1021 //PS: If you don't want to build all graphics test app, you may have to comment |
|
1022 // some IBY file includes into graphicstests_70s.iby file. |
|
1023 // If there is a memory leak - the test will still report status "OK", but you |
|
1024 // can see the memory leak message on the assabet. That's happening because |
|
1025 // the memory leak appears after the last __UHEAP_MARKEND macro in E32Main(). |
|
1026 // |
|
1027 |
|
1028 @SYMTestExpectedResults Test should perform graphics operations succesfully. |
|
1029 */ |
|
1030 void CTDefect::DEF017758() |
|
1031 { |
|
1032 TRAPD(err, DEF017758L()); |
|
1033 TEST(err == KErrNone); |
|
1034 } |
|
1035 |
|
1036 void CTDefect::DEF017758L() |
|
1037 { |
|
1038 RDebug::Print(_L("Getting video memory address\r\n")); |
|
1039 RDebug::Print(_L("Start\r\n")); |
|
1040 TInt address = 0; |
|
1041 |
|
1042 __UHEAP_MARK; |
|
1043 User::LeaveIfError(HAL::Get(KDefaultScreenNo, HALData::EDisplayMemoryAddress, address)); |
|
1044 __UHEAP_MARKEND; |
|
1045 RDebug::Print(_L("End\n")); |
|
1046 } |
|
1047 |
|
1048 /** |
|
1049 @SYMTestCaseID GRAPHICS-BITGDI-0047 |
|
1050 |
|
1051 @SYMDEF |
|
1052 |
|
1053 @SYMTestCaseDesc The main purpose of this method is to test RAM/ROM bitmap compression. |
|
1054 |
|
1055 @SYMTestPriority High |
|
1056 |
|
1057 @SYMTestStatus Implemented |
|
1058 |
|
1059 @SYMTestActions |
|
1060 |
|
1061 - loads and displays ROM compressed bitmap. |
|
1062 - loads and displays ROM bitmap - no compression. |
|
1063 - loads and displays RAM compressed bitmap. |
|
1064 - loads and displays RAM bitmap - no compression. |
|
1065 - loads, compress and displays RAM bitmap. |
|
1066 - stretches, moves and resizes RAM compressed bitmap. |
|
1067 - compares byte by byte compressed and uncompressed bitmap images. |
|
1068 Note: if you want to have better visibility of the bitmaps shown on |
|
1069 the screen - change "KDelayTime" constant to be 1500000. |
|
1070 @param TBitmapType aBitmapType - tested bitmaps type - 16 bpp, 24 bpp, ... |
|
1071 @return None |
|
1072 |
|
1073 @SYMTestExpectedResults Test should perform graphics operations succesfully. |
|
1074 */ |
|
1075 void CTDefect::BitmapCompressionL(TBitmapType aBitmapType) |
|
1076 { |
|
1077 CreateScreenDeviceL(); |
|
1078 CreateFontL(); |
|
1079 |
|
1080 TRect rc(10, 20, 610, 220); |
|
1081 TBuf<100> text; |
|
1082 TInt mbm_offset = 0; |
|
1083 TInt err; |
|
1084 TPtrC BitmapTypeName[ELastBmpType] = {_L("16 bpp"), _L("24 bpp")}; |
|
1085 typedef enum {ERAMFileType, ERAMCFileType, EROMFileType, EROMCFileType, ELastBmpFileType} TBitmapFileType; |
|
1086 TPtrC BitmapFile[ELastBmpFileType][ELastBmpType] = |
|
1087 { |
|
1088 {KRamBitmap(), KRam24Bitmap()}, |
|
1089 {KRamCBitmap(), KRamC24Bitmap()}, |
|
1090 {KRomBitmap(), KRom24Bitmap()}, |
|
1091 {KRomCBitmap(), KRomC24Bitmap()} |
|
1092 }; |
|
1093 |
|
1094 if(!iSkipRomBitmapTests) |
|
1095 { |
|
1096 //ROM compressed bitmap. |
|
1097 text = BitmapTypeName[aBitmapType]; |
|
1098 text += _L(" ROM compressed bitmap."); |
|
1099 DisplayBitmapL(BitmapFile[EROMCFileType][aBitmapType], 0, mbm_offset, text, rc); |
|
1100 |
|
1101 //ROM bitmap - no compression. |
|
1102 text = BitmapTypeName[aBitmapType]; |
|
1103 text += _L(" ROM bitmap - no compression."); |
|
1104 DisplayBitmapL(BitmapFile[EROMFileType][aBitmapType], 0, mbm_offset, text, rc); |
|
1105 } |
|
1106 |
|
1107 //RAM compressed bitmap. |
|
1108 text = BitmapTypeName[aBitmapType]; |
|
1109 text += _L(" RAM compressed bitmap."); |
|
1110 DisplayBitmapL(BitmapFile[ERAMCFileType][aBitmapType], 0, mbm_offset, text, rc); |
|
1111 |
|
1112 //RAM bitmap - no compression. |
|
1113 text = BitmapTypeName[aBitmapType]; |
|
1114 text += _L(" RAM bitmap - no compression."); |
|
1115 DisplayBitmapL(BitmapFile[ERAMFileType][aBitmapType], 0, mbm_offset, text, rc); |
|
1116 |
|
1117 //RAM bitmap - no compression. Compress it! |
|
1118 err = iBitmap->Compress(); |
|
1119 TEST(err == KErrNone); |
|
1120 TEST(iBitmap->IsCompressedInRAM()); |
|
1121 text = BitmapTypeName[aBitmapType]; |
|
1122 text += _L(" RAM bitmap - compressed now."); |
|
1123 DisplayBitmap(text, rc); |
|
1124 err = iBitmap->Save(_L("c:\\temp.mbm")); |
|
1125 TEST(err == KErrNone); |
|
1126 |
|
1127 //RAM compressed bitmap - stretch the bitmap. |
|
1128 text = BitmapTypeName[aBitmapType]; |
|
1129 text += _L(" RAM compressed bitmap - stretch the bitmap."); |
|
1130 TRect rc2(10, 20, 410, 150); |
|
1131 DisplayBitmap(text, rc2); |
|
1132 |
|
1133 //RAM compressed bitmap - move the bitmap. |
|
1134 text = BitmapTypeName[aBitmapType]; |
|
1135 text += _L(" RAM compressed bitmap - move the bitmap."); |
|
1136 for(TInt j=0;j<10;j++) |
|
1137 { |
|
1138 TRect rc2(10 + j * 10, 20 + j * 5, 410 + j * 10, 150 + j * 5); |
|
1139 DisplayBitmap(text, rc2); |
|
1140 } |
|
1141 |
|
1142 //RAM compressed bitmap - resize the bitmap. |
|
1143 iGc->Clear(); |
|
1144 err = iBitmap->Save(_L("c:\\temp2.mbm")); |
|
1145 TEST(err == KErrNone); |
|
1146 CFbsBitmap* resizedBitmap = new (ELeave) CFbsBitmap; |
|
1147 CleanupStack::PushL(resizedBitmap); |
|
1148 err = resizedBitmap->Load(_L("c:\\temp2.mbm")); |
|
1149 TEST(err == KErrNone); |
|
1150 err = resizedBitmap->Resize(TSize(300, 100)); |
|
1151 TEST(err == KErrNone); |
|
1152 iGc->DrawBitmap(TRect(10, 20, 310, 120), resizedBitmap); |
|
1153 text = BitmapTypeName[aBitmapType]; |
|
1154 text += _L(" RAM compressed bitmap - resize the bitmap."); |
|
1155 iGc->DrawText(text, TPoint(10, 15)); |
|
1156 iDevice->Update(); |
|
1157 User::After(KDelayTime); |
|
1158 CleanupStack::PopAndDestroy(resizedBitmap); |
|
1159 |
|
1160 iGc->Clear(); |
|
1161 iGc->DrawText(_L("Compare compressed and uncompressed bitmap data."), TPoint(10, 15)); |
|
1162 iDevice->Update(); |
|
1163 |
|
1164 DestroyFont(); |
|
1165 |
|
1166 CFbsBitmap* compressedBitmap = new (ELeave) CFbsBitmap; |
|
1167 CleanupStack::PushL(compressedBitmap); |
|
1168 err = compressedBitmap->Load(_L("c:\\temp.mbm")); |
|
1169 TEST(err == KErrNone); |
|
1170 |
|
1171 CFbsBitmap* uncompressedBitmap = new (ELeave) CFbsBitmap; |
|
1172 CleanupStack::PushL(uncompressedBitmap); |
|
1173 err = uncompressedBitmap->Load(BitmapFile[ERAMFileType][aBitmapType]); |
|
1174 TEST(err == KErrNone); |
|
1175 |
|
1176 //Compare compressed and uncompressed bitmaps. |
|
1177 TEST(compressedBitmap->SizeInPixels() == uncompressedBitmap->SizeInPixels()); |
|
1178 TSize sizeInPixels = compressedBitmap->SizeInPixels(); |
|
1179 TInt BitmapBytesPerPixel[ELastBmpType] = {2, 3}; |
|
1180 HBufC8* compressedLine = HBufC8::NewLC(sizeInPixels.iWidth * BitmapBytesPerPixel[aBitmapType]); |
|
1181 TPtr8 p1 = compressedLine->Des(); |
|
1182 HBufC8* uncompressedLine = HBufC8::NewLC(sizeInPixels.iWidth * BitmapBytesPerPixel[aBitmapType]); |
|
1183 TPtr8 p2 = uncompressedLine->Des(); |
|
1184 TDisplayMode BitmapScreenMode[ELastBmpType] = {EColor64K, EColor16M}; |
|
1185 for(TInt ii=0;ii<sizeInPixels.iHeight;ii++) |
|
1186 { |
|
1187 compressedBitmap->GetScanLine(p1, TPoint(0,ii), sizeInPixels.iWidth, BitmapScreenMode[aBitmapType]); |
|
1188 uncompressedBitmap->GetScanLine(p2, TPoint(0,ii), sizeInPixels.iWidth, BitmapScreenMode[aBitmapType]); |
|
1189 TEST(p1 == p2); |
|
1190 } |
|
1191 |
|
1192 CleanupStack::PopAndDestroy(uncompressedLine); |
|
1193 CleanupStack::PopAndDestroy(compressedLine); |
|
1194 CleanupStack::PopAndDestroy(uncompressedBitmap); |
|
1195 CleanupStack::PopAndDestroy(compressedBitmap); |
|
1196 |
|
1197 User::After(KDelayTime); |
|
1198 } |
|
1199 |
|
1200 /** |
|
1201 @SYMTestCaseID GRAPHICS-BITGDI-0048 |
|
1202 |
|
1203 @SYMDEF |
|
1204 |
|
1205 @SYMTestCaseDesc The main purpose of this method is to test new resource files format. |
|
1206 |
|
1207 @SYMTestPriority High |
|
1208 |
|
1209 @SYMTestStatus Implemented |
|
1210 |
|
1211 @SYMTestActions The new resoure files format is: RSC file header + RSC file section + MBM file section. |
|
1212 The method consequently does: |
|
1213 - loads and displays new RSC file format: RSC file in ROM. MBM file in ROM. |
|
1214 - loads and displays new RSC file format: RSC file in RAM. MBM file in RAM. |
|
1215 - loads and displays new RSC file format: RSC file in ROM. MBM file in ROM. 2 bitmaps. |
|
1216 - loads and displays new RSC file format: RSC file in RAM. MBM file in RAM. 2 bitmaps. |
|
1217 - loads and displays new RSC file format: RSC file in ROM. MBM file in RAM. |
|
1218 Note: if you want to have better visibility of the bitmaps shown on |
|
1219 the screen - change "KDelayTime" constant to be 1500000. |
|
1220 |
|
1221 @SYMTestExpectedResults Test should perform graphics operations succesfully. |
|
1222 */ |
|
1223 void CTDefect::NewRscFormatL() |
|
1224 { |
|
1225 CreateScreenDeviceL(); |
|
1226 CreateFontL(); |
|
1227 |
|
1228 TRect rc(10, 20, 610, 220); |
|
1229 TPtrC text(_L("RSC file in ROM. MBM file in ROM.")); |
|
1230 TInt mbm_offset = ::FileSizeL(KRscFileHeader) + ::FileSizeL(KRscFileData); |
|
1231 |
|
1232 //RSC file in ROM. MBM file in ROM. |
|
1233 if(!iSkipRomBitmapTests) |
|
1234 DisplayBitmapL(KRomRsc_RomMbm, 0, mbm_offset, text, rc); |
|
1235 |
|
1236 //RSC file in RAM. MBM file in RAM. |
|
1237 text.Set(_L("RSC file in RAM. MBM file in RAM.")); |
|
1238 DisplayBitmapL(KRamRsc_RamMbm, 0, mbm_offset, text, rc); |
|
1239 |
|
1240 TInt ii; |
|
1241 TRect rect[] = {TRect(10, 20, 170, 100), TRect(10, 20, 35, 94)}; |
|
1242 |
|
1243 //RSC file in ROM. MBM file in ROM. Multiple bitmaps. |
|
1244 if(!iSkipRomBitmapTests) |
|
1245 { |
|
1246 text.Set(_L("RSC file in ROM. MBM file in ROM. Multiple bitmaps.")); |
|
1247 for(ii=0;ii<TInt(sizeof(rect)/sizeof(rect[0]));ii++) |
|
1248 { |
|
1249 DisplayBitmapL(KRomRsc_RomMbm2, ii, mbm_offset, text, rect[ii]); |
|
1250 } |
|
1251 } |
|
1252 |
|
1253 //RSC file in RAM. MBM file in RAM. Multiple bitmaps. |
|
1254 text.Set(_L("RSC file in RAM. MBM file in RAM. Multiple bitmaps.")); |
|
1255 for(ii=0;ii<TInt(sizeof(rect)/sizeof(rect[0]));ii++) |
|
1256 { |
|
1257 DisplayBitmapL(KRamRsc_RamMbm2, ii, mbm_offset, text, rect[ii]); |
|
1258 } |
|
1259 |
|
1260 //RSC file in ROM. MBM file in RAM. |
|
1261 text.Set(_L("RSC file in ROM. MBM file in RAM.")); |
|
1262 DisplayBitmapL(KRomRsc_RamMbm, 0, mbm_offset, text, rc); |
|
1263 |
|
1264 //RSC file in ROM. MBM file in RAM. Multiple bitmaps. |
|
1265 text.Set(_L("RSC file in ROM. MBM file in RAM. Multiple bitmaps.")); |
|
1266 for(ii=0;ii<TInt(sizeof(rect)/sizeof(rect[0]));ii++) |
|
1267 { |
|
1268 DisplayBitmapL(KRomRsc_RamMbm2, ii, mbm_offset, text, rect[ii]); |
|
1269 } |
|
1270 |
|
1271 DestroyFont(); |
|
1272 } |
|
1273 |
|
1274 /** |
|
1275 @SYMTestCaseID GRAPHICS-BITGDI-0049 |
|
1276 |
|
1277 @SYMDEF |
|
1278 |
|
1279 @SYMTestCaseDesc tests that 16bpp/24bpp bitmap compression works correctly |
|
1280 |
|
1281 @SYMTestPriority High |
|
1282 |
|
1283 @SYMTestStatus Implemented |
|
1284 |
|
1285 @SYMTestActions Creates a compress bitmap and mask and draws to it |
|
1286 |
|
1287 @SYMTestExpectedResults Test should perform graphics operations succesfully. |
|
1288 */ |
|
1289 void CTDefect::INC031920L(TBitmapType aBitmapType, TBool aRomBitmap) |
|
1290 { |
|
1291 if(iSkipRomBitmapTests && aRomBitmap) |
|
1292 return; |
|
1293 |
|
1294 CreateScreenDeviceL(); |
|
1295 CreateFontL(); |
|
1296 |
|
1297 TPtrC filename; |
|
1298 switch(aBitmapType) |
|
1299 { |
|
1300 case E16BppBmpType: |
|
1301 filename.Set(aRomBitmap ? KComprRomBitmap16() : KComprRamBitmap16()); |
|
1302 break; |
|
1303 case E24BppBmpType: |
|
1304 filename.Set(aRomBitmap ? KComprRomBitmap24() : KComprRamBitmap24()); |
|
1305 break; |
|
1306 default: |
|
1307 TEST(EFalse); //should never get here |
|
1308 } |
|
1309 |
|
1310 CFbsBitmap* brush_bitmap = new (ELeave) CFbsBitmap; |
|
1311 CleanupStack::PushL(brush_bitmap); |
|
1312 TInt err = brush_bitmap->Load(filename, 10); |
|
1313 TEST(err == KErrNone); |
|
1314 iGc->UseBrushPattern(brush_bitmap); |
|
1315 |
|
1316 TInt brush_style = CGraphicsContext::ENullBrush; |
|
1317 for(TInt ii=0;ii<25;ii++) |
|
1318 { |
|
1319 if(++brush_style == CGraphicsContext::EDiamondCrossHatchBrush) |
|
1320 { |
|
1321 brush_style = CGraphicsContext::ESolidBrush; |
|
1322 } |
|
1323 iGc->SetBrushStyle(static_cast <CGraphicsContext::TBrushStyle> (brush_style)); |
|
1324 |
|
1325 DeleteBitmap(); |
|
1326 iBitmap = new (ELeave) CFbsBitmap; |
|
1327 err = iBitmap->Load(filename, ii); |
|
1328 TEST(err == KErrNone); |
|
1329 TSize size = iBitmap->SizeInPixels(); |
|
1330 |
|
1331 CFbsBitmap* mask_bitmap = new (ELeave) CFbsBitmap; |
|
1332 CleanupStack::PushL(mask_bitmap); |
|
1333 err = mask_bitmap->Load(filename, (ii+3)<25 ? (ii+3) : (ii-3)); |
|
1334 TEST(err == KErrNone); |
|
1335 |
|
1336 TPoint pt(0, 0); |
|
1337 TRect rc(0, 0, size.iWidth, size.iHeight); |
|
1338 //If there is a problem with BitBltMasked - it can fail with "Access violation" |
|
1339 //exception on the emulator. |
|
1340 iGc->BitBltMasked(pt, iBitmap, rc, mask_bitmap, ETrue); |
|
1341 iGc->DrawRect(rc); |
|
1342 iDevice->Update(); |
|
1343 User::After(KDelayTime); |
|
1344 |
|
1345 CleanupStack::PopAndDestroy(mask_bitmap); |
|
1346 } |
|
1347 |
|
1348 CleanupStack::PopAndDestroy(brush_bitmap); |
|
1349 DestroyFont(); |
|
1350 } |
|
1351 |
|
1352 /** |
|
1353 @SYMTestCaseID GRAPHICS-BITGDI-0050 |
|
1354 |
|
1355 @SYMDEF |
|
1356 |
|
1357 @SYMTestCaseDesc 8 bit bitmap compression - ROM |
|
1358 |
|
1359 @SYMTestPriority High |
|
1360 |
|
1361 @SYMTestStatus Implemented |
|
1362 |
|
1363 @SYMTestActions Creates and draws to an 8bbp compressed bitmap |
|
1364 |
|
1365 @SYMTestExpectedResults Test should perform graphics operations succesfully. |
|
1366 */ |
|
1367 void CTDefect::Test8bitBmpComressionL() |
|
1368 { |
|
1369 CreateScreenDeviceL(); |
|
1370 CreateFontL(); |
|
1371 |
|
1372 TRect rc(10, 20, 610, 220); |
|
1373 TPtrC text(_L("8 bpp RAM compressed bitmap.")); |
|
1374 DisplayBitmapL(KComprRamBitmap8, 0, 0, text, rc); |
|
1375 |
|
1376 if(!iSkipRomBitmapTests) |
|
1377 { |
|
1378 text.Set(_L("8 bpp ROM compressed bitmap.")); |
|
1379 DisplayBitmapL(KComprRomBitmap8, 0, 0, text, rc); |
|
1380 } |
|
1381 |
|
1382 DestroyFont(); |
|
1383 } |
|
1384 |
|
1385 /** |
|
1386 @SYMTestCaseID GRAPHICS-BITGDI-0051 |
|
1387 |
|
1388 @SYMDEF |
|
1389 |
|
1390 @SYMTestCaseDesc 12 bpp ROM compressed bitmap |
|
1391 |
|
1392 @SYMTestPriority High |
|
1393 |
|
1394 @SYMTestStatus Implemented |
|
1395 |
|
1396 @SYMTestActions Creates and draws to an 12bbp compressed bitmap |
|
1397 |
|
1398 @SYMTestExpectedResults Test should perform graphics operations succesfully. |
|
1399 */ |
|
1400 void CTDefect::Test12bitBmpComressionL() |
|
1401 { |
|
1402 CreateScreenDeviceL(); |
|
1403 CreateFontL(); |
|
1404 |
|
1405 TRect rc(10, 20, 610, 220); |
|
1406 TPtrC text(_L("12 bpp RAM compressed bitmap.")); |
|
1407 DisplayBitmapL(KComprRamBitmap12, 0, 0, text, rc); |
|
1408 |
|
1409 if(!iSkipRomBitmapTests) |
|
1410 { |
|
1411 text.Set(_L("12 bpp ROM compressed bitmap.")); |
|
1412 DisplayBitmapL(KComprRomBitmap12, 0, 0, text, rc); |
|
1413 } |
|
1414 |
|
1415 DestroyFont(); |
|
1416 } |
|
1417 |
|
1418 /** |
|
1419 @SYMTestCaseID GRAPHICS-BITGDI-0052 |
|
1420 |
|
1421 @SYMDEF DEF034134 |
|
1422 |
|
1423 @SYMTestCaseDesc BMCONV has a limitation on the number of bitmaps it can use. |
|
1424 |
|
1425 @SYMTestPriority High |
|
1426 |
|
1427 @SYMTestStatus Implemented |
|
1428 |
|
1429 @SYMTestActions Loads up a mbm contaiing 8 bitmaps and draws them |
|
1430 |
|
1431 @SYMTestExpectedResults Test should perform graphics operations succesfully. |
|
1432 */ |
|
1433 void CTDefect::DEF034134L() |
|
1434 { |
|
1435 CreateScreenDeviceL(); |
|
1436 CreateFontL(); |
|
1437 |
|
1438 TBuf<64> text; |
|
1439 for(TInt ii=0;ii<8;ii++) |
|
1440 //8 - it is the number of bitmaps in mbm file - see GenBitmaps.mk where this mbm file is generated |
|
1441 { |
|
1442 text.Format(_L("Bitmap %d"), ii+1); |
|
1443 DeleteBitmap(); |
|
1444 iBitmap = new (ELeave) CFbsBitmap; |
|
1445 TInt err = iBitmap->Load(KTestBmp, ii); |
|
1446 TEST(err == KErrNone); |
|
1447 TSize size = iBitmap->SizeInPixels(); |
|
1448 DisplayBitmap(text, TRect(20, 20, 20 + size.iWidth, 20 + size.iHeight)); |
|
1449 } |
|
1450 |
|
1451 DestroyFont(); |
|
1452 } |
|
1453 |
|
1454 /** |
|
1455 @SYMTestCaseID GRAPHICS-BITGDI-0053 |
|
1456 |
|
1457 @SYMDEF DEF036156 |
|
1458 |
|
1459 @SYMTestCaseDesc When using a mask that's smaller than the bitmap being blitted, |
|
1460 the mask should be tiled horizontally and vertically until it's the correct size and then applied to the bitmap. |
|
1461 |
|
1462 @SYMTestPriority High |
|
1463 |
|
1464 @SYMTestStatus Implemented |
|
1465 |
|
1466 @SYMTestActions Creates bitmap, mask and brush and tests that tiling occurs correctly |
|
1467 |
|
1468 @SYMTestExpectedResults Test should perform graphics operations succesfully. |
|
1469 */ |
|
1470 void CTDefect::TestTilingHorizontalAndVerticalL() |
|
1471 { |
|
1472 TDisplayMode mode[] = {EColor256, EColor4K, EColor16M, EColor16MU, EColor64K, |
|
1473 EGray256, EGray16, EGray4, EGray2, EColor16, EColor16MA, EColor16MAP}; |
|
1474 TInt err; |
|
1475 |
|
1476 //Create&load source bitmap |
|
1477 CFbsBitmap* srcBmp = new (ELeave) CFbsBitmap; |
|
1478 CleanupStack::PushL(srcBmp); |
|
1479 err = srcBmp->Load(KBitBltSrcBmp, 0); |
|
1480 TEST(err == KErrNone); |
|
1481 TSize size1 = srcBmp->SizeInPixels(); |
|
1482 TPoint pt1(10, 20); |
|
1483 TRect rc1(pt1.iX, pt1.iY, pt1.iX + size1.iWidth, pt1.iY + size1.iHeight); |
|
1484 |
|
1485 //Create&load mask bitmap |
|
1486 CFbsBitmap* maskBmp = new (ELeave) CFbsBitmap; |
|
1487 CleanupStack::PushL(maskBmp); |
|
1488 err = maskBmp->Load(KBitBltMaskedBmp, 0); |
|
1489 TEST(err == KErrNone); |
|
1490 TSize size2 = maskBmp->SizeInPixels(); |
|
1491 TInt offset = 40; |
|
1492 TPoint pt2(pt1.iX, pt1.iY + size1.iHeight + offset); |
|
1493 TRect rc2(pt2.iX, pt2.iY, pt2.iX + size2.iWidth, pt2.iY + size2.iHeight); |
|
1494 |
|
1495 //Create&load brush bitmap |
|
1496 CFbsBitmap* brush_bitmap = new (ELeave) CFbsBitmap; |
|
1497 CleanupStack::PushL(brush_bitmap); |
|
1498 err = brush_bitmap->Load(KComprRamBitmap16, 10); |
|
1499 TEST(err == KErrNone); |
|
1500 |
|
1501 for(TInt ii=0;ii<TInt(sizeof(mode)/sizeof(mode[0]));++ii) |
|
1502 { |
|
1503 err = CreateScreenDeviceL(mode[ii]); |
|
1504 if(err == KErrNotSupported) |
|
1505 { |
|
1506 continue; |
|
1507 } |
|
1508 TEST(err == KErrNone); |
|
1509 |
|
1510 CreateFontL(); |
|
1511 |
|
1512 iGc->Clear(); |
|
1513 |
|
1514 iGc->DrawText(_L("Src bitmap"), TPoint(pt1.iX, pt1.iY - 2)); |
|
1515 iGc->DrawBitmap(rc1, srcBmp); |
|
1516 |
|
1517 iGc->DrawText(_L("Mask bitmap"), TPoint(pt2.iX, pt2.iY - 2)); |
|
1518 iGc->DrawBitmap(rc2, maskBmp); |
|
1519 |
|
1520 TBuf<64> text2; |
|
1521 _LIT(KMaskMode,"BitBltMasked, Mode: E%S"); |
|
1522 text2.Format(KMaskMode, &ColorModeName(ii)); |
|
1523 iGc->DrawText(text2, TPoint(150, pt2.iY-2)); |
|
1524 |
|
1525 TPoint pt(pt1.iX + size1.iWidth + offset, pt1.iY); |
|
1526 TRect rc(0, 0, size1.iWidth, size1.iHeight); |
|
1527 |
|
1528 CGraphicsContext::TBrushStyle brushStyle[] = |
|
1529 { |
|
1530 CGraphicsContext::ENullBrush, |
|
1531 CGraphicsContext::ESolidBrush, |
|
1532 CGraphicsContext::EPatternedBrush |
|
1533 }; |
|
1534 |
|
1535 TBuf<32> text[sizeof(brushStyle)/sizeof(brushStyle[0])] = |
|
1536 { |
|
1537 _L("NonFlicker"), |
|
1538 _L("NonFlickerSolid"), |
|
1539 _L("NonFlickerPatterned") |
|
1540 }; |
|
1541 |
|
1542 iGc->UseBrushPattern(brush_bitmap); |
|
1543 |
|
1544 for(TInt j=0;j<TInt(sizeof(brushStyle)/sizeof(brushStyle[0]));pt.iX+=150,j++) |
|
1545 { |
|
1546 iGc->DrawText(text[j], TPoint(pt.iX, pt.iY - 2)); |
|
1547 iGc->SetBrushStyle(brushStyle[j]); |
|
1548 iGc->BitBltMasked(pt, srcBmp, rc, maskBmp, ETrue); |
|
1549 } |
|
1550 |
|
1551 iDevice->Update(); |
|
1552 User::After(500000); |
|
1553 |
|
1554 DestroyFont(); |
|
1555 }//end of - for(TInt ii=0;ii<TInt(sizeof(mode)/sizeof(mode[0]));++ii) |
|
1556 |
|
1557 CleanupStack::PopAndDestroy(brush_bitmap); |
|
1558 CleanupStack::PopAndDestroy(maskBmp); |
|
1559 CleanupStack::PopAndDestroy(srcBmp); |
|
1560 DestroyFont(); |
|
1561 } |
|
1562 |
|
1563 /** |
|
1564 @SYMTestCaseID GRAPHICS-BITGDI-0054 |
|
1565 |
|
1566 @SYMDEF INC036348 + DEF081298 |
|
1567 |
|
1568 @SYMTestCaseDesc Pie drawing is incorrect in some borderline cases |
|
1569 |
|
1570 @SYMTestPriority High |
|
1571 |
|
1572 @SYMTestStatus Implemented |
|
1573 |
|
1574 @SYMTestActions draws pie charts with boundry values and tests it is drawn correctly |
|
1575 |
|
1576 @SYMTestExpectedResults Test should perform graphics operations succesfully. |
|
1577 */ |
|
1578 void CTDefect::DrawPieBorderlineCasesL() |
|
1579 { |
|
1580 CreateScreenDeviceL(); |
|
1581 CreateFontL(); |
|
1582 |
|
1583 DrawPie(_L("INC036348 - Missing points"), TRect(0, 0, 100, 100), TPoint(346, -462), TPoint( 50, -462)); |
|
1584 DrawPie(_L("INC036348 - Extra points"), TRect(0, 0, 100, 100), TPoint(562, -462), TPoint(187, -462)); |
|
1585 DrawPie(_L("INC036348 - Draws different range 1"), TRect(0, 0, 100, 100), TPoint(187, -462), TPoint( 50, -462)); |
|
1586 DrawPie(_L("INC036348 - Draws different range 2"), TRect(0, 0, 100, 100), TPoint( 50, 562), TPoint(186, 562)); |
|
1587 |
|
1588 const TInt rectLength = 300; |
|
1589 const TInt rectWidth = 100; |
|
1590 for (TInt y = 0; y <= rectWidth; y++) |
|
1591 { |
|
1592 DrawPie(_L("DEF081298"), TRect(0, 0, rectLength, rectWidth), TPoint(0, 0), TPoint(0, y)); |
|
1593 } |
|
1594 for (TInt x = 0; x <= rectLength; x++) |
|
1595 { |
|
1596 DrawPie(_L("DEF081298"), TRect(0, 0, rectLength, rectWidth), TPoint(0, 0), TPoint(x, rectWidth)); |
|
1597 } |
|
1598 for (TInt y = rectWidth; y >= 0; y--) |
|
1599 { |
|
1600 DrawPie(_L("DEF081298"), TRect(0, 0, rectLength, rectWidth), TPoint(0, 0), TPoint(rectLength, y)); |
|
1601 } |
|
1602 for (TInt x = rectLength; x >= 0; x--) |
|
1603 { |
|
1604 DrawPie(_L("DEF081298"), TRect(0, 0, rectLength, rectWidth), TPoint(0, 0), TPoint(x, 0)); |
|
1605 } |
|
1606 |
|
1607 DestroyFont(); |
|
1608 } |
|
1609 |
|
1610 /** |
|
1611 @SYMTestCaseID GRAPHICS-BITGDI-0055 |
|
1612 |
|
1613 @SYMDEF Panic in bitgdi in Typhoon 30. |
|
1614 |
|
1615 @SYMTestCaseDesc INC037380 |
|
1616 |
|
1617 @SYMTestPriority normal |
|
1618 |
|
1619 @SYMTestStatus Implemented |
|
1620 |
|
1621 @SYMTestActions Test BitBltMasked works correctly with 64K bitmaps and EGray256 masks |
|
1622 |
|
1623 @SYMTestExpectedResults Test should perform graphics operations succesfully. |
|
1624 */ |
|
1625 void CTDefect::INC037380L() |
|
1626 { |
|
1627 TInt ii; |
|
1628 TInt err; |
|
1629 //Create the screen device |
|
1630 err = CreateScreenDeviceL(EColor64K); |
|
1631 if (err == KErrNotSupported) |
|
1632 err = CreateScreenDeviceL(EColor16MA); |
|
1633 if (err == KErrNotSupported) |
|
1634 err = CreateScreenDeviceL(EColor16MAP); |
|
1635 if (err == KErrNotSupported) |
|
1636 return; |
|
1637 User::LeaveIfError(err); |
|
1638 //Create source bitmap |
|
1639 CFbsBitmap* srcBmp = new (ELeave) CFbsBitmap; |
|
1640 CleanupStack::PushL(srcBmp); |
|
1641 User::LeaveIfError(srcBmp->Create(TSize(500, 1), EColor16M)); |
|
1642 TBitmapUtil bmpUtil1(srcBmp); |
|
1643 bmpUtil1.Begin(TPoint(0, 0)); |
|
1644 for(ii=0;ii<500;ii++) |
|
1645 { |
|
1646 bmpUtil1.SetPos(TPoint(ii,0)); |
|
1647 bmpUtil1.SetPixel(ii); |
|
1648 } |
|
1649 bmpUtil1.End(); |
|
1650 //Create mask bitmap |
|
1651 CFbsBitmap* maskBmp = new (ELeave) CFbsBitmap; |
|
1652 CleanupStack::PushL(maskBmp); |
|
1653 User::LeaveIfError(maskBmp->Create(TSize(20, 1), EGray256)); |
|
1654 TBitmapUtil bmpUtil2(maskBmp); |
|
1655 bmpUtil2.Begin(TPoint(0, 0)); |
|
1656 for(ii=0;ii<20;ii++) |
|
1657 { |
|
1658 bmpUtil1.SetPos(TPoint(ii,0)); |
|
1659 bmpUtil2.SetPixel(100 + ii); |
|
1660 } |
|
1661 bmpUtil2.End(); |
|
1662 //Create brush bitmap |
|
1663 CFbsBitmap* brush_bitmap = new (ELeave) CFbsBitmap; |
|
1664 CleanupStack::PushL(brush_bitmap); |
|
1665 User::LeaveIfError(brush_bitmap->Create(TSize(20, 1), EColor64K)); |
|
1666 TBitmapUtil bmpUtil3(brush_bitmap); |
|
1667 bmpUtil3.Begin(TPoint(0, 0)); |
|
1668 for(ii=0;ii<20;ii++) |
|
1669 { |
|
1670 bmpUtil1.SetPos(TPoint(ii,0)); |
|
1671 bmpUtil3.SetPixel(200 + ii); |
|
1672 } |
|
1673 bmpUtil3.End(); |
|
1674 |
|
1675 iGc->Clear(); |
|
1676 iGc->DrawBitmap(TRect(0, 20, 500, 21), srcBmp); |
|
1677 iGc->DrawBitmap(TRect(0, 22, 20, 23), maskBmp); |
|
1678 iGc->UseBrushPattern(brush_bitmap); |
|
1679 iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1680 |
|
1681 //The following call panics if the fix doesn't exist. |
|
1682 iGc->BitBltMasked(TPoint(0, 0), srcBmp, TRect(0, 0, 500, 1), maskBmp, ETrue); |
|
1683 |
|
1684 iDevice->Update(); |
|
1685 |
|
1686 CleanupStack::PopAndDestroy(brush_bitmap); |
|
1687 CleanupStack::PopAndDestroy(maskBmp); |
|
1688 CleanupStack::PopAndDestroy(srcBmp); |
|
1689 } |
|
1690 |
|
1691 /** |
|
1692 @SYMTestCaseID GRAPHICS-BITGDI-0056 |
|
1693 |
|
1694 @SYMDEF INC037474 |
|
1695 |
|
1696 @SYMTestCaseDesc CBitwiseBitmap::GenerateLineFromCompressedSixteenBitData() is very slow |
|
1697 |
|
1698 @SYMTestPriority High |
|
1699 |
|
1700 @SYMTestStatus Implemented |
|
1701 |
|
1702 @SYMTestActions measures the time the GenerateLineFromCompressedSixteenBitData method takes with different target modes |
|
1703 |
|
1704 @SYMTestExpectedResults Test should perform graphics operations succesfully. |
|
1705 */ |
|
1706 void CTDefect::INC037474L() |
|
1707 { |
|
1708 TPtrC bmpFile[] = |
|
1709 { |
|
1710 KBmpCompr12(), |
|
1711 KBmpCompr16(), |
|
1712 KBmpCCompr12(), |
|
1713 KBmpCCompr16() |
|
1714 }; |
|
1715 TPtrC tt[] = {_L("rom"), _L("rom"), _L("ram"), _L("ram")}; |
|
1716 TBool inRam[] = {EFalse, EFalse, ETrue, ETrue}; |
|
1717 TInt bpp[] = {12, 16, 12, 16}; |
|
1718 TDisplayMode targetMode[] = {EColor4K, EColor64K, EColor4K, EColor64K}; |
|
1719 const TInt KMaxScanLineLen = 800; |
|
1720 TBuf8<KMaxScanLineLen> scanLineBuf; |
|
1721 for(TInt ii=0;ii<TInt(sizeof(bmpFile)/sizeof(bmpFile[0]));ii++) |
|
1722 { |
|
1723 if(iSkipRomBitmapTests && !inRam[ii]) |
|
1724 continue; |
|
1725 |
|
1726 CFbsBitGcBitmap* bmp = ::LoadBitmapLC(bmpFile[ii]); |
|
1727 if(inRam[ii]) |
|
1728 { |
|
1729 User::LeaveIfError(bmp->Compress()); |
|
1730 } |
|
1731 // |
|
1732 TDesC& des = tt[ii]; |
|
1733 INFO_PRINTF3(_L("%d bpp %S compressed bitmap, GetScanLine test"), bpp[ii], &des); |
|
1734 TSize size = bmp->SizeInPixels(); |
|
1735 TEST(TInt(size.iWidth * sizeof(TInt16)) <= KMaxScanLineLen); |
|
1736 bmp->LockHeap(); |
|
1737 CBitwiseBitmap* bmp2 = bmp->Address(); |
|
1738 TUint32* dataAddr = bmp->DataAddress(); |
|
1739 TLineScanningPosition scanLinePos(dataAddr); |
|
1740 TPoint pt00(0, 0); |
|
1741 TUint timeStart = User::TickCount(); |
|
1742 for(TInt j=0;j<100;j++) |
|
1743 { |
|
1744 TPoint startPixel(0, 0); |
|
1745 for(TInt k=0;k<size.iHeight;k++) |
|
1746 { |
|
1747 startPixel.iY = k; |
|
1748 bmp2->GetScanLine(scanLineBuf, startPixel, size.iWidth, |
|
1749 EFalse, pt00, targetMode[ii], |
|
1750 dataAddr, scanLinePos); |
|
1751 } |
|
1752 } |
|
1753 TUint timeEnd = User::TickCount(); |
|
1754 INFO_PRINTF4(_L("%d bpp %S compressed bitmap, time = %d"), bpp[ii], &des, timeEnd - timeStart); |
|
1755 bmp->UnlockHeap(); |
|
1756 // |
|
1757 CleanupStack::PopAndDestroy(bmp); |
|
1758 } |
|
1759 } |
|
1760 |
|
1761 /** |
|
1762 @SYMTestCaseID GRAPHICS-BITGDI-0057 |
|
1763 |
|
1764 @SYMDEF INC037370 |
|
1765 |
|
1766 @SYMTestCaseDesc Corrupted compressed images |
|
1767 |
|
1768 @SYMTestPriority normal |
|
1769 |
|
1770 @SYMTestStatus Implemented |
|
1771 |
|
1772 @SYMTestActions Creates some compressed bitmaps, resizes them and compares results |
|
1773 |
|
1774 @SYMTestExpectedResults Test should perform graphics operations succesfully. |
|
1775 */ |
|
1776 //INC037370 - Corrupted compressed images |
|
1777 void CTDefect::INC037370L() |
|
1778 { |
|
1779 CreateScreenDeviceL(); |
|
1780 TPtrC bmpFile[] = {KBmp16_1(), KBmp16_2(), KBmp16_3()}; |
|
1781 CFbsBitGcBitmap* bmp[] = {NULL, NULL, NULL}; |
|
1782 const TInt bmpArrSize = sizeof(bmp) / sizeof(bmp[0]); |
|
1783 //Load the bitmaps |
|
1784 ::LoadBitmapsLC<bmpArrSize>(&bmp, bmpFile); |
|
1785 TInt ii; |
|
1786 //Compress the bitmaps |
|
1787 for(ii=0;ii<bmpArrSize;ii++) |
|
1788 { |
|
1789 bmp[ii]->Compress(); |
|
1790 } |
|
1791 //Display the bitmaps |
|
1792 ::DisplayBitmaps<bmpArrSize>(&bmp, iDevice, iGc); |
|
1793 //Resize bitmap[0] |
|
1794 const TInt KResize = 100; |
|
1795 TSize size = bmp[0]->SizeInPixels(); |
|
1796 size.iWidth -= KResize; |
|
1797 size.iHeight -= KResize; |
|
1798 bmp[0]->Resize(size); |
|
1799 //Display the bitmaps again. If the defect is not fixed - bmp[0] image is corrupted! |
|
1800 ::DisplayBitmaps<bmpArrSize>(&bmp, iDevice, iGc); |
|
1801 //Compare bmp[0] and bmp[1]. If the defect is not fixed - the test will fail! |
|
1802 ::CompareBitmaps<bmpArrSize, 1000>(&bmp, EColor64K, 0, 1, this); |
|
1803 //Resize bitmap[1] |
|
1804 size = bmp[1]->SizeInPixels(); |
|
1805 size.iWidth += KResize; |
|
1806 size.iHeight += KResize; |
|
1807 bmp[1]->Resize(size); |
|
1808 //Display the bitmaps again. If the defect is not fixed - bmp[1] image is corrupted! |
|
1809 ::DisplayBitmaps<bmpArrSize>(&bmp, iDevice, iGc); |
|
1810 //Compare bmp[1] and bmp[2]. If the defect is not fixed - the test will fail! |
|
1811 ::CompareBitmaps<bmpArrSize, 1000>(&bmp, EColor64K, 1, 2, this); |
|
1812 //Destroy the bitmaps |
|
1813 ::DestroyBitmaps<bmpArrSize>(&bmp); |
|
1814 } |
|
1815 |
|
1816 /** |
|
1817 @SYMTestCaseID GRAPHICS-BITGDI-0058 |
|
1818 |
|
1819 @SYMDEF |
|
1820 |
|
1821 @SYMTestCaseDesc Tests setting of various display modes |
|
1822 |
|
1823 @SYMTestPriority High |
|
1824 |
|
1825 @SYMTestStatus Implemented |
|
1826 |
|
1827 @SYMTestActions Sets display modes then displays bitmaps |
|
1828 |
|
1829 @SYMTestExpectedResults Test should perform graphics operations succesfully. |
|
1830 */ |
|
1831 //Test CFbsBitmap::SetDisplayMode() |
|
1832 void CTDefect::TestSettingDisplayModeL() |
|
1833 { |
|
1834 TDisplayMode mode[] = {ENone, EGray2, EGray4, EGray16, EGray256, EColor16, EColor256, |
|
1835 EColor64K, EColor16M, ERgb, EColor4K, EColor16MU, EColor16MA, EColor16MAP}; |
|
1836 _LIT(KLog,"Running test with display mode %S (index=%d)"); |
|
1837 for(TInt ii=0;ii<TInt(sizeof(mode)/sizeof(mode[0]));ii++) |
|
1838 { |
|
1839 if(mode[ii] == ENone || mode[ii] == ERgb || CreateScreenDeviceL(mode[ii]) != KErrNone) |
|
1840 { |
|
1841 continue; |
|
1842 } |
|
1843 INFO_PRINTF3(KLog,&ColorModeName(mode[ii]),ii); |
|
1844 DestroyFont(); |
|
1845 CreateFontL(); |
|
1846 |
|
1847 TRect rc(10, 20, 610, 220); |
|
1848 |
|
1849 DeleteBitmap(); |
|
1850 iBitmap = new (ELeave) CFbsBitmap; |
|
1851 TInt err = iBitmap->Load(KRamBitmap, 0); |
|
1852 TEST(err == KErrNone); |
|
1853 TDisplayMode initialDisplayMode = iBitmap->InitialDisplayMode(); |
|
1854 TInt bmpMode; |
|
1855 //From the initial display mode to EGray2 mode. |
|
1856 for(bmpMode=initialDisplayMode;bmpMode!=ENone;bmpMode--) |
|
1857 { |
|
1858 DisplayBitmap(rc, mode[ii], TDisplayMode(bmpMode)); |
|
1859 } |
|
1860 //From EGray2 mode to the initial display mode |
|
1861 for(bmpMode=EGray2;bmpMode<=initialDisplayMode;bmpMode++) |
|
1862 { |
|
1863 DisplayBitmap(rc, mode[ii], TDisplayMode(bmpMode)); |
|
1864 } |
|
1865 } |
|
1866 } |
|
1867 |
|
1868 /** |
|
1869 @SYMTestCaseID GRAPHICS-BITGDI-0059 |
|
1870 |
|
1871 @SYMDEF |
|
1872 |
|
1873 @SYMTestCaseDesc Tests setting of various display modes |
|
1874 |
|
1875 @SYMTestPriority High |
|
1876 |
|
1877 @SYMTestStatus Implemented |
|
1878 |
|
1879 @SYMTestActions tests display modes are set correctly by checking scanline data wlan |
|
1880 |
|
1881 |
|
1882 @SYMTestExpectedResults Test should perform graphics operations succesfully. |
|
1883 */ |
|
1884 void CTDefect::TestSettingDisplayMode2L() |
|
1885 { |
|
1886 // Try color mode 64K, 256 and 16MA |
|
1887 TInt err=CreateScreenDeviceL(EColor64K); |
|
1888 if (err!=KErrNone) |
|
1889 err=CreateScreenDeviceL(EColor256); |
|
1890 if (err!=KErrNone) |
|
1891 err=CreateScreenDeviceL(EColor16MA); |
|
1892 if (err!=KErrNone) |
|
1893 err=CreateScreenDeviceL(EColor16MAP); |
|
1894 User::LeaveIfError(err); |
|
1895 DeleteBitmap(); |
|
1896 const TInt KBmpWidth = 100; |
|
1897 //The bitmap data - for EColor16MU - the pixel with the largest width in bits |
|
1898 const TInt bytePerPixel = 4; |
|
1899 TUint8 srcBmpData[KBmpWidth * bytePerPixel]; |
|
1900 Mem::Fill(srcBmpData, sizeof(srcBmpData) / 2, 0xFF); //First half is white colored |
|
1901 Mem::Fill(srcBmpData + sizeof(srcBmpData) / 2, sizeof(srcBmpData) / 2, 0x00);//Second half is black colored |
|
1902 //The bitmap |
|
1903 iBitmap = new (ELeave) CFbsBitmap; |
|
1904 User::LeaveIfError(iBitmap->Create(TSize(KBmpWidth, 1), EColor16MU)); |
|
1905 const TSize KSize = iBitmap->SizeInPixels(); |
|
1906 TPtr8 p(srcBmpData, KBmpWidth * bytePerPixel, KBmpWidth * bytePerPixel); |
|
1907 iBitmap->SetScanLine(p, 0); |
|
1908 TDisplayMode mode[] = {EColor16MAP, EColor16MA, EColor16MU, EColor16M, EColor64K, |
|
1909 EColor4K, EColor256, EGray256, EColor16, |
|
1910 EGray16, EGray4, EGray2}; |
|
1911 TInt ii; |
|
1912 for(ii=0;ii<TInt(sizeof(mode)/sizeof(mode[0]));ii++) |
|
1913 { |
|
1914 SetAndCheckDisplayMode(mode[ii], KSize); |
|
1915 } |
|
1916 for(ii=((sizeof(mode)/sizeof(mode[0]))-1);ii!=-1;ii--) |
|
1917 { |
|
1918 SetAndCheckDisplayMode(mode[ii], KSize); |
|
1919 } |
|
1920 } |
|
1921 |
|
1922 void CTDefect::SetAndCheckDisplayMode(TDisplayMode aMode, const TSize& aInitialSize) |
|
1923 { |
|
1924 TInt err = iBitmap->SetDisplayMode(aMode); |
|
1925 TEST(err == KErrNone); |
|
1926 TSize size = iBitmap->SizeInPixels(); |
|
1927 TEST(aInitialSize == size); |
|
1928 TEST(iBitmap->DisplayMode() == aMode); |
|
1929 INFO_PRINTF2(_L("Check scanline in display mode: %d"), aMode); |
|
1930 CheckScanLine(); |
|
1931 } |
|
1932 |
|
1933 void CTDefect::CheckScanLine() |
|
1934 { |
|
1935 TSize size = iBitmap->SizeInPixels(); |
|
1936 TInt j; |
|
1937 TRgb whiteColor(0xFF, 0xFF, 0xFF); |
|
1938 TPoint pt(0, 0); |
|
1939 for(j=0;j<(size.iWidth/2);j++) |
|
1940 { |
|
1941 TRgb color; |
|
1942 pt.iX = j; |
|
1943 iBitmap->GetPixel(color, pt); |
|
1944 TEST(color == whiteColor); |
|
1945 } |
|
1946 TRgb blackColor(0x00, 0x00, 0x00); |
|
1947 for(j=(size.iWidth/2);j<size.iWidth;j++) |
|
1948 { |
|
1949 TRgb color; |
|
1950 pt.iX = j; |
|
1951 iBitmap->GetPixel(color, pt); |
|
1952 if(color != blackColor) |
|
1953 { |
|
1954 ERR_PRINTF1(_L("Scan line error")); |
|
1955 } |
|
1956 TEST(color == blackColor); |
|
1957 } |
|
1958 } |
|
1959 |
|
1960 /** |
|
1961 @SYMTestCaseID GRAPHICS-BITGDI-0060 |
|
1962 |
|
1963 @SYMDEF |
|
1964 |
|
1965 @SYMTestCaseDesc tests swapping a bitmaps width and height |
|
1966 |
|
1967 @SYMTestPriority High |
|
1968 |
|
1969 @SYMTestStatus Implemented |
|
1970 |
|
1971 @SYMTestActions Creates a bitmap, swaps its width and height and tests for correct size |
|
1972 |
|
1973 @SYMTestExpectedResults Test should perform graphics operations succesfully. |
|
1974 */ |
|
1975 void CTDefect::TestSwappingWidthAndHeightL() |
|
1976 { |
|
1977 // Try color mode 64K, 256 and 16MA |
|
1978 TInt err=CreateScreenDeviceL(EColor64K); |
|
1979 if (err!=KErrNone) |
|
1980 err=CreateScreenDeviceL(EColor256); |
|
1981 if (err!=KErrNone) |
|
1982 err = CreateScreenDeviceL(EColor16MA); |
|
1983 if (err!=KErrNone) |
|
1984 err = CreateScreenDeviceL(EColor16MAP); |
|
1985 User::LeaveIfError(err); |
|
1986 DestroyFont(); |
|
1987 CreateFontL(); |
|
1988 |
|
1989 DeleteBitmap(); |
|
1990 iBitmap = new (ELeave) CFbsBitmap; |
|
1991 err = iBitmap->Load(KRamBitmap, 0); |
|
1992 TEST(err == KErrNone); |
|
1993 |
|
1994 TSize size1_1 = iBitmap->SizeInPixels(); |
|
1995 TSize size1_2 = iBitmap->SizeInTwips(); |
|
1996 TRect rc(10, 20, 610, 220); |
|
1997 TPtrC text(_L("Before swapping")); |
|
1998 DisplayBitmap(text, rc); |
|
1999 |
|
2000 iBitmap->SwapWidthAndHeight(); |
|
2001 TSize size2_1 = iBitmap->SizeInPixels(); |
|
2002 TSize size2_2 = iBitmap->SizeInTwips(); |
|
2003 TEST(size1_1.iWidth == size2_1.iHeight && size1_1.iHeight == size2_1.iWidth); |
|
2004 TEST(size1_2.iWidth == size2_2.iHeight && size1_2.iHeight == size2_2.iWidth); |
|
2005 |
|
2006 text.Set(_L("After swapping")); |
|
2007 DisplayBitmap(text, rc); |
|
2008 rc = TRect(10, 20, 210, 620); |
|
2009 DisplayBitmap(text, rc); |
|
2010 |
|
2011 DeleteBitmap(); |
|
2012 iBitmap = new (ELeave) CFbsBitmap; |
|
2013 iBitmap->Create(TSize(17, 1), EGray2); |
|
2014 |
|
2015 DeleteBitmap(); |
|
2016 iBitmap = new (ELeave) CFbsBitmap; |
|
2017 iBitmap->Create(TSize(1, 17), EGray2); |
|
2018 } |
|
2019 |
|
2020 /** |
|
2021 @SYMTestCaseID GRAPHICS-BITGDI-0061 |
|
2022 |
|
2023 @SYMDEF DEF038774 |
|
2024 |
|
2025 @SYMTestCaseDesc Buffer overflow when using CFbsBitmapDevice::GetScanLine and EGray2 disp.mode |
|
2026 EGray4, EGray16, EColor16 modes also tested. |
|
2027 |
|
2028 @SYMTestPriority High |
|
2029 |
|
2030 @SYMTestStatus Implemented |
|
2031 |
|
2032 @SYMTestActions Creates bitmap of various width depending on the colour mode and checks that its buffer |
|
2033 does not get an overflow when written to |
|
2034 |
|
2035 @SYMTestExpectedResults Test should perform graphics operations succesfully. |
|
2036 */ |
|
2037 void CTDefect::DEF038774L() |
|
2038 { |
|
2039 enum {KHeight = 1};//Bitmaps height - in pixels |
|
2040 TDisplayMode testMode[] = {EGray2, EGray4, EGray16, EColor16, EColor4K, EColor64K, EColor16M, EColor16MU, EColor16MA, EColor16MAP};//tested display modes |
|
2041 const TInt pixelPerByte[] ={8, 4, 2, 2, 0, 0, 0, 0, 0}; |
|
2042 const TInt bytePerPixel[] ={0, 0, 0, 0, 2, 2, 3, 4, 4}; |
|
2043 const TInt bitmapWidth[] = {22, 7, 11, 11, 3, 3, 1, 1, 1};//bitmaps width |
|
2044 const TUint8 KTestVal1 = 0xA3;//test value |
|
2045 const TUint8 KTestVal2 = 0xF7;//test value |
|
2046 TUint8 scanLineData[100];//100 should be enough for all possible modes which are tested |
|
2047 for(TInt ii=0;ii<TInt(sizeof(testMode)/sizeof(testMode[0]));ii++) |
|
2048 { |
|
2049 TSize size(bitmapWidth[ii], KHeight);//bitmap size - in pixels |
|
2050 CreateBitmapL(size, testMode[ii]); |
|
2051 //Initialize the bitmap scanline |
|
2052 TInt scanLineLen = 0; |
|
2053 if(pixelPerByte[ii]) |
|
2054 { |
|
2055 scanLineLen = bitmapWidth[ii] / pixelPerByte[ii]; |
|
2056 } |
|
2057 else |
|
2058 { |
|
2059 scanLineLen = bitmapWidth[ii] * bytePerPixel[ii]; |
|
2060 } |
|
2061 Mem::Fill(scanLineData, scanLineLen, KTestVal1); |
|
2062 TPtr8 p(scanLineData, scanLineLen, scanLineLen); |
|
2063 iBitmap->SetScanLine(p, 0); |
|
2064 //Create bitmap device (KWidth, KHeight) size |
|
2065 DeleteBitmapDevice(); |
|
2066 iBmpDevice = CFbsBitmapDevice::NewL(iBitmap); |
|
2067 //Fill the scanLineData with control values |
|
2068 Mem::Fill(scanLineData, sizeof(scanLineData), KTestVal2); |
|
2069 //GetScanLine test - check the (scanLineLen + 1) byte |
|
2070 iBmpDevice->GetScanLine(p, TPoint(), bitmapWidth[ii], testMode[ii]); |
|
2071 TEST(scanLineData[scanLineLen + 1] == KTestVal2); |
|
2072 } |
|
2073 } |
|
2074 |
|
2075 /** |
|
2076 @SYMTestCaseID GRAPHICS-BITGDI-0086 |
|
2077 |
|
2078 @SYMDEF DEF121299 |
|
2079 |
|
2080 @SYMTestCaseDesc Ensure alpha channel is not overwritten in 16MU BitBlt/DrawBitmap Operations. |
|
2081 |
|
2082 @SYMTestPriority High |
|
2083 |
|
2084 @SYMTestStatus Implemented |
|
2085 |
|
2086 @SYMTestActions Creates 1x1 or 2x2 pixel Bitmaps with non 0x00/0xFF alpha channel to test BitBlt/DrawBitmap operations. |
|
2087 |
|
2088 @SYMTestExpectedResults Test should perform graphics operations succesfully. |
|
2089 */ |
|
2090 void CTDefect::TestBitBltOperationsOn16muUndefinedByteL() |
|
2091 { |
|
2092 //Create a source bitmap and set the Alpha channel to a Non 0xFF/0x00 value. |
|
2093 CFbsBitmap* srcbmp = new(ELeave) CFbsBitmap(); |
|
2094 CleanupStack::PushL(srcbmp); |
|
2095 User::LeaveIfError(srcbmp->Create(TSize(1,1), EColor16MU)); |
|
2096 |
|
2097 *(srcbmp->DataAddress()) = 0x55000000; |
|
2098 |
|
2099 CFbsBitmap* destbmp = new(ELeave) CFbsBitmap(); |
|
2100 CleanupStack::PushL(destbmp); |
|
2101 //Create this one as 2x2 so DrawBitmap tests will work. |
|
2102 User::LeaveIfError(destbmp->Create(TSize(2,2), EColor16MU)); |
|
2103 |
|
2104 //Create Bitmap Device & Gc to perform BitBlt/DrawBmp operations. |
|
2105 CFbsBitmapDevice* bmpdev = CFbsBitmapDevice::NewL(destbmp); |
|
2106 CleanupStack::PushL(bmpdev); |
|
2107 CFbsBitGc* bmpgc; |
|
2108 User::LeaveIfError(bmpdev->CreateContext(bmpgc)); |
|
2109 CleanupStack::PushL(bmpgc); |
|
2110 bmpgc->Activate(bmpdev); |
|
2111 |
|
2112 //Create Extra Mask Bitmap |
|
2113 CFbsBitmap* bmpmask16mu = new(ELeave)CFbsBitmap(); |
|
2114 CleanupStack::PushL(bmpmask16mu); |
|
2115 User::LeaveIfError(bmpmask16mu->Create(TSize(2,2), EColor16MU)); |
|
2116 |
|
2117 //BitBlt |
|
2118 INFO_PRINTF1(_L("Performing BitBlt() Test")); |
|
2119 bmpgc->BitBlt(TPoint(0,0), srcbmp); |
|
2120 TEST(CompareFirstPixelAlphaChannel(srcbmp, destbmp)); |
|
2121 |
|
2122 //BitBltMasked |
|
2123 INFO_PRINTF1(_L("Performing BitBltMasked() Test")); |
|
2124 bmpgc->BitBltMasked(TPoint(0,0), srcbmp, TRect(TPoint(0,0), TSize(1,1)), srcbmp, EFalse); |
|
2125 TEST(CompareFirstPixelAlphaChannel(srcbmp, destbmp)); |
|
2126 |
|
2127 CleanupStack::PopAndDestroy(5, srcbmp); |
|
2128 } |
|
2129 |
|
2130 |
|
2131 void CTDefect::DeleteBitmap() |
|
2132 { |
|
2133 if(iBitmap) |
|
2134 { |
|
2135 iBitmap->Reset(); |
|
2136 } |
|
2137 delete iBitmap; |
|
2138 iBitmap = NULL; |
|
2139 } |
|
2140 |
|
2141 void CTDefect::DeleteBitmapDevice() |
|
2142 { |
|
2143 delete iBmpDevice; |
|
2144 iBmpDevice = NULL; |
|
2145 } |
|
2146 |
|
2147 void CTDefect::DeleteScreenDevice() |
|
2148 { |
|
2149 delete iDevice; |
|
2150 iDevice = NULL; |
|
2151 } |
|
2152 |
|
2153 void CTDefect::DeleteGraphicsContext() |
|
2154 { |
|
2155 delete iGc; |
|
2156 iGc = NULL; |
|
2157 } |
|
2158 |
|
2159 void CTDefect::DisplayBitmapL(const TDesC& aFileName, TInt aBitmapNo, TInt aBitmapOffset, const TDesC& aText, const TRect& aRc) |
|
2160 { |
|
2161 DeleteBitmap(); |
|
2162 iBitmap = new (ELeave) CFbsBitmap; |
|
2163 TInt err = iBitmap->Load(aFileName, aBitmapNo, EFalse, aBitmapOffset); |
|
2164 if(err) |
|
2165 INFO_PRINTF3(_L("Error (%d) while loading bitmap (%S)"), err, &aFileName); |
|
2166 TEST(err == KErrNone); |
|
2167 DisplayBitmap(aText, aRc); |
|
2168 } |
|
2169 |
|
2170 void CTDefect::DisplayBitmap(const TDesC& aText, const TRect& aRc) |
|
2171 { |
|
2172 iGc->Clear(); |
|
2173 iGc->DrawBitmap(aRc, iBitmap); |
|
2174 iGc->DrawText(aText, TPoint(10, 15)); |
|
2175 iDevice->Update(); |
|
2176 User::After(KDelayTime); |
|
2177 } |
|
2178 |
|
2179 void CTDefect::DisplayBitmap(const TRect& aRc, TDisplayMode aScreenMode, TDisplayMode aBmpMode) |
|
2180 { |
|
2181 if (aBmpMode==ENone || aBmpMode==ERgb) |
|
2182 { |
|
2183 return; |
|
2184 } |
|
2185 _LIT(KLog,"ScreenMode: %S, SetDisplayMode: %S"); |
|
2186 TBuf<128> text; |
|
2187 text.Format(KLog,&ColorModeName(aScreenMode),&ColorModeName(aBmpMode)); |
|
2188 INFO_PRINTF1(text); |
|
2189 TInt err = iBitmap->SetDisplayMode(aBmpMode); |
|
2190 TEST(err == KErrNone); |
|
2191 DisplayBitmap(text, aRc); |
|
2192 } |
|
2193 |
|
2194 void CTDefect::CreateFontL() |
|
2195 { |
|
2196 CFbsFont* font = NULL; |
|
2197 TFontSpec fs(_L("Swiss"), 12); |
|
2198 User::LeaveIfError(iDevice->GetNearestFontToDesignHeightInPixels(font, fs)); |
|
2199 iGc->UseFont(font); |
|
2200 } |
|
2201 |
|
2202 void CTDefect::DestroyFont() |
|
2203 { |
|
2204 if(iGc) |
|
2205 { |
|
2206 iGc->DiscardFont(); |
|
2207 } |
|
2208 } |
|
2209 |
|
2210 void CTDefect::DrawPie(const TDesC& aText, const TRect& aRc, const TPoint& aPtStart, const TPoint& aPtEnd) |
|
2211 { |
|
2212 const TRgb green(0x00, 0xFF, 0x00); |
|
2213 const TRgb red(0xFF, 0x00, 0x00); |
|
2214 const TRgb blue(0x00, 0x00, 0xFF); |
|
2215 const TRgb white(0xFF, 0xFF, 0xFF); |
|
2216 |
|
2217 iGc->SetBrushColor(white); |
|
2218 iGc->Clear(); |
|
2219 iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
2220 iGc->SetBrushColor(green); |
|
2221 iGc->DrawRect(aRc); |
|
2222 iGc->SetPenColor(blue); |
|
2223 iGc->SetBrushColor(red); |
|
2224 iGc->DrawPie(aRc, aPtStart, aPtEnd); |
|
2225 iGc->SetBrushColor(blue); |
|
2226 iGc->DrawLine( |
|
2227 TPoint(aRc.iTl.iX, aRc.iTl.iY + aRc.Height() / 2), |
|
2228 TPoint(aRc.iTl.iX + aRc.Width(), aRc.iTl.iY + aRc.Height() / 2)); |
|
2229 iGc->DrawLine( |
|
2230 TPoint(aRc.iTl.iX + aRc.Width() / 2, aRc.iTl.iY), |
|
2231 TPoint(aRc.iTl.iX + aRc.Width() / 2, aRc.iTl.iY + aRc.Height())); |
|
2232 iGc->DrawText( |
|
2233 aText, |
|
2234 TPoint(aRc.iTl.iX, aRc.iTl.iY + aRc.Height() + 15)); |
|
2235 iDevice->Update(); |
|
2236 User::After(10000); |
|
2237 } |
|
2238 |
|
2239 void CTDefect::CreateBitmapL(const TSize& aSize, TDisplayMode aMode) |
|
2240 { |
|
2241 DeleteBitmap(); |
|
2242 iBitmap = new (ELeave) CFbsBitmap; |
|
2243 User::LeaveIfError(iBitmap->Create(aSize, aMode)); |
|
2244 } |
|
2245 |
|
2246 |
|
2247 static void DisconnectFbsSession(TAny*) |
|
2248 { |
|
2249 RFbsSession::Disconnect(); |
|
2250 } |
|
2251 |
|
2252 void CTDefect::INC042156L() |
|
2253 { |
|
2254 User::LeaveIfError(RFbsSession::Connect()); |
|
2255 CleanupStack::PushL(TCleanupItem(DisconnectFbsSession, NULL)); |
|
2256 |
|
2257 TInt mbm_offset = 0; |
|
2258 TBuf<100> text; |
|
2259 TPtrC BitmapTypeName[ELastBmpType] = {_L("16 bpp"), _L("24 bpp")}; |
|
2260 typedef enum {ERAMFileType, ERAMCFileType, EROMFileType, EROMCFileType, ELastBmpFileType} TBitmapFileType; |
|
2261 TPtrC BitmapFile[ELastBmpFileType][ELastBmpType] = |
|
2262 { |
|
2263 {KRamBitmap(), KRam24Bitmap()}, |
|
2264 {KRamCBitmap(), KRamC24Bitmap()}, |
|
2265 {KRomBitmap(), KRom24Bitmap()}, |
|
2266 {KRomCBitmap(), KRomC24Bitmap()} |
|
2267 }; |
|
2268 |
|
2269 text = BitmapTypeName[E24BppBmpType]; |
|
2270 text += _L(" ROM compressed bitmap."); |
|
2271 |
|
2272 const TInt KWidth = 20; |
|
2273 const TInt KHeight = 20; |
|
2274 const TInt KAddLength = 10; |
|
2275 CFbsBitmap* fbsBmp = NULL; |
|
2276 |
|
2277 //Create and compress RAM bitmap |
|
2278 //The compression allows us to use the scanline buffer |
|
2279 fbsBmp = new (ELeave) CFbsBitmap; |
|
2280 CleanupStack::PushL(fbsBmp); |
|
2281 User::LeaveIfError(fbsBmp->Create(TSize(KWidth, KHeight), EColor64K)); |
|
2282 User::LeaveIfError(fbsBmp->Compress()); |
|
2283 TSize size = fbsBmp->SizeInPixels(); |
|
2284 |
|
2285 TUint32* slptr=NULL; |
|
2286 TPoint coord(0,0); |
|
2287 TLineScanningPosition lineScanPos(fbsBmp->DataAddress()); |
|
2288 CFbsBitGcBitmap* srce = (CFbsBitGcBitmap*) fbsBmp; // CFbsBitmap |
|
2289 CBitwiseBitmap* bmp = srce->Address(); |
|
2290 |
|
2291 //Test GetScanLinePtr() |
|
2292 User::LeaveIfError(bmp->GetScanLinePtr(slptr, size.iWidth, coord, fbsBmp->DataAddress(), lineScanPos)); |
|
2293 |
|
2294 //Resize the RAM bitmap |
|
2295 //The scanline buffer will be reallocated |
|
2296 User::LeaveIfError(fbsBmp->Resize(TSize(KWidth + KAddLength, KHeight + KAddLength))); |
|
2297 size = fbsBmp->SizeInPixels(); |
|
2298 |
|
2299 slptr = NULL; |
|
2300 lineScanPos.iSrcDataPtr = (TUint8*)fbsBmp->DataAddress(); |
|
2301 lineScanPos.iCursorPos = 0; |
|
2302 lineScanPos.iScanLineBuffer = 0; |
|
2303 srce = (CFbsBitGcBitmap*) fbsBmp; // CFbsBitmap |
|
2304 bmp = srce->Address(); |
|
2305 |
|
2306 //Test GetScanLinePtr() |
|
2307 User::LeaveIfError(bmp->GetScanLinePtr(slptr, size.iWidth, coord, fbsBmp->DataAddress(), lineScanPos)); |
|
2308 //Destroy RAM bitmap internal data |
|
2309 fbsBmp->Reset(); |
|
2310 |
|
2311 //Load RAM compressed bitmap |
|
2312 //The RAM bitmap is bigger than the previous one, so |
|
2313 //the scanline buffer will be reallocated |
|
2314 User::LeaveIfError(fbsBmp->Load(BitmapFile[ERAMCFileType][E24BppBmpType], 0, EFalse, mbm_offset)); |
|
2315 size = fbsBmp->SizeInPixels(); |
|
2316 TEST(size.iWidth > (KWidth + KAddLength)); |
|
2317 |
|
2318 slptr = NULL; |
|
2319 lineScanPos.iSrcDataPtr = (TUint8*)fbsBmp->DataAddress(); |
|
2320 lineScanPos.iCursorPos = 0; |
|
2321 lineScanPos.iScanLineBuffer = 0; |
|
2322 srce = (CFbsBitGcBitmap*) fbsBmp; // CFbsBitmap |
|
2323 bmp = srce->Address(); |
|
2324 |
|
2325 //Test GetScanLinePtr() |
|
2326 User::LeaveIfError(bmp->GetScanLinePtr(slptr, size.iWidth, coord, fbsBmp->DataAddress(), lineScanPos)); |
|
2327 |
|
2328 CleanupStack::PopAndDestroy(fbsBmp); |
|
2329 CleanupStack::PopAndDestroy();//cleanupItem |
|
2330 } |
|
2331 |
|
2332 /** |
|
2333 @SYMTestCaseID GRAPHICS-BITGDI-0062 |
|
2334 |
|
2335 @SYMDEF INC070043 |
|
2336 |
|
2337 @SYMTestCaseDesc DrawBitmap() assumes always that source is of type EColor16MA |
|
2338 |
|
2339 @SYMTestPriority High |
|
2340 |
|
2341 @SYMTestStatus Implemented |
|
2342 |
|
2343 @SYMTestActions Tests that drawing 16MU to 16MU uses the correct alpha values when required and not assume a transparent alpha |
|
2344 |
|
2345 @SYMTestExpectedResults Test should perform graphics operations succesfully. |
|
2346 */ |
|
2347 void CTDefect::INC070043L() |
|
2348 { |
|
2349 const TInt KWidth = 100; |
|
2350 const TInt KHeight = 100; |
|
2351 const TInt KWidth11 = KWidth + 20; |
|
2352 const TInt KHeight11 = KHeight + 20; |
|
2353 |
|
2354 //source bitmap |
|
2355 CFbsBitmap* fbsSourceBmp = new (ELeave) CFbsBitmap; |
|
2356 CleanupStack::PushL(fbsSourceBmp); |
|
2357 User::LeaveIfError(fbsSourceBmp->Create(TSize(KWidth, KHeight), EColor16MU)); |
|
2358 fbsSourceBmp->SetSizeInTwips(TSize(KWidth, KHeight)); |
|
2359 |
|
2360 CFbsBitGc* theBitmapContextSrc = NULL; |
|
2361 CFbsBitmapDevice* theBitmapDeviceSrc = CFbsBitmapDevice::NewL(fbsSourceBmp); |
|
2362 CleanupStack::PushL(theBitmapDeviceSrc); |
|
2363 theBitmapDeviceSrc->CreateContext(theBitmapContextSrc); |
|
2364 CleanupStack::PushL(theBitmapContextSrc); |
|
2365 |
|
2366 //make a drawing |
|
2367 theBitmapContextSrc -> SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
2368 theBitmapContextSrc -> SetPenColor(TRgb(0, 0, 255)); |
|
2369 theBitmapContextSrc -> DrawRect(TRect(0, 0, KWidth, KHeight)); |
|
2370 |
|
2371 //destination bitmap |
|
2372 CFbsBitmap* fbsDestBmp = new (ELeave) CFbsBitmap; |
|
2373 CleanupStack::PushL(fbsDestBmp); |
|
2374 User::LeaveIfError(fbsDestBmp->Create(TSize(KWidth, KHeight), EColor16MU)); |
|
2375 fbsDestBmp->SetSizeInTwips(TSize(KWidth, KHeight)); |
|
2376 |
|
2377 CFbsBitGc* theBitmapContextDest = NULL; |
|
2378 CFbsBitmapDevice* theBitmapDeviceDest = CFbsBitmapDevice::NewL(fbsDestBmp); |
|
2379 CleanupStack::PushL(theBitmapDeviceDest); |
|
2380 theBitmapDeviceDest->CreateContext(theBitmapContextDest); |
|
2381 CleanupStack::PushL(theBitmapContextDest); |
|
2382 |
|
2383 //bigger destination bitmap |
|
2384 CFbsBitmap* fbsDestBmp1 = new (ELeave) CFbsBitmap; |
|
2385 CleanupStack::PushL(fbsDestBmp1); |
|
2386 User::LeaveIfError(fbsDestBmp1->Create(TSize(KWidth11, KHeight11), EColor16MU)); |
|
2387 fbsDestBmp1->SetSizeInTwips(TSize(KWidth11, KHeight11)); |
|
2388 |
|
2389 CFbsBitGc* theBitmapContextDest1 = NULL; |
|
2390 CFbsBitmapDevice* theBitmapDeviceDest1 = CFbsBitmapDevice::NewL(fbsDestBmp1); |
|
2391 CleanupStack::PushL(theBitmapDeviceDest1); |
|
2392 theBitmapDeviceDest1->CreateContext(theBitmapContextDest1); |
|
2393 CleanupStack::PushL(theBitmapContextDest1); |
|
2394 |
|
2395 |
|
2396 //make a drawing |
|
2397 INFO_PRINTF1(_L("Drawing from 16MU to 16MU memory bitmap")); |
|
2398 theBitmapContextDest-> SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
2399 theBitmapContextDest -> SetPenColor(TRgb(0, 255, 0)); |
|
2400 theBitmapContextDest -> DrawRect(TRect(0, 0, KWidth, KHeight)); |
|
2401 |
|
2402 |
|
2403 theBitmapContextDest->DrawBitmap(TPoint(0, 0), fbsSourceBmp); |
|
2404 |
|
2405 CFbsBitGcBitmap* bmp1 = (CFbsBitGcBitmap*)fbsDestBmp; |
|
2406 CFbsBitGcBitmap* bmp2 = (CFbsBitGcBitmap*)fbsSourceBmp; |
|
2407 CFbsBitGcBitmap* bmp[] = {bmp1, bmp2}; |
|
2408 const TInt bmpArrSize = sizeof(bmp) / sizeof(bmp[0]); |
|
2409 ::CompareBitmaps<bmpArrSize, 1000>(&bmp, EColor16MU, 0, 1, this); |
|
2410 |
|
2411 // load from the file |
|
2412 CFbsBitmap* fbsSourceBmp1 = new (ELeave) CFbsBitmap; |
|
2413 CleanupStack::PushL(fbsSourceBmp1); |
|
2414 TInt err = fbsSourceBmp1->Load(_L("z:\\system\\data\\DrawBitmap16MU.MBM")); |
|
2415 fbsSourceBmp1->SetSizeInTwips(TSize(KWidth, KHeight)); |
|
2416 |
|
2417 //with compression |
|
2418 CFbsBitmap* fbsSourceBmp2 = new (ELeave) CFbsBitmap; |
|
2419 CleanupStack::PushL(fbsSourceBmp2); |
|
2420 err = fbsSourceBmp2->Load(_L("z:\\system\\data\\DrawBitmapComp16MU.MBM")); |
|
2421 fbsSourceBmp2->SetSizeInTwips(TSize(KWidth, KHeight)); |
|
2422 |
|
2423 INFO_PRINTF1(_L("Drawing from 16MU to 16MU bitmap")); |
|
2424 theBitmapContextDest->DrawBitmap(TPoint(0, 0), fbsSourceBmp1); |
|
2425 bmp1 = (CFbsBitGcBitmap*)fbsDestBmp; |
|
2426 bmp2 = (CFbsBitGcBitmap*)fbsSourceBmp1; |
|
2427 CFbsBitGcBitmap* bmp11[] = {bmp1, bmp2}; |
|
2428 const TInt bmpArrSize1 = sizeof(bmp11) / sizeof(bmp11[0]); |
|
2429 ::CompareBitmaps<bmpArrSize1, 1000>(&bmp11, EColor16MU, 0, 1, this); |
|
2430 |
|
2431 // drawing to the bigger destination |
|
2432 INFO_PRINTF1(_L("Drawing from 16MU to 16MU bitmap, where source and distination bitmaps have a different size")); |
|
2433 theBitmapContextDest1-> SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
2434 theBitmapContextDest1 -> SetPenColor(TRgb(0, 255, 0)); |
|
2435 theBitmapContextDest1 -> DrawRect(TRect(0, 0, KWidth11, KHeight11)); |
|
2436 theBitmapContextDest1->DrawBitmap(TPoint(0, 0), fbsSourceBmp1); |
|
2437 bmp1 = (CFbsBitGcBitmap*)fbsDestBmp1; |
|
2438 bmp2 = (CFbsBitGcBitmap*)fbsSourceBmp1; |
|
2439 CFbsBitGcBitmap* bmp22[] = {bmp1, bmp2}; |
|
2440 const TInt bmpArrSize2 = sizeof(bmp22) / sizeof(bmp22[0]); |
|
2441 ::CompareBitmaps<bmpArrSize2, 1000>(&bmp22, EColor16MU, 0, 1, this); |
|
2442 |
|
2443 // drawing to the compressed bitmap |
|
2444 INFO_PRINTF1(_L("Drawing from 16MU to 16MU bitmap, where source bitmap is compressed")); |
|
2445 theBitmapContextDest -> DrawRect(TRect(0, 0, KWidth, KHeight)); |
|
2446 theBitmapContextDest->DrawBitmap(TPoint(0, 0), fbsSourceBmp2); |
|
2447 bmp1 = (CFbsBitGcBitmap*)fbsDestBmp; |
|
2448 bmp2 = (CFbsBitGcBitmap*)fbsSourceBmp2; |
|
2449 CFbsBitGcBitmap* bmp33[] = {bmp1, bmp2}; |
|
2450 const TInt bmpArrSize3 = sizeof(bmp33) / sizeof(bmp33[0]); |
|
2451 ::CompareBitmaps<bmpArrSize3, 1000>(&bmp33, EColor16MU, 0, 1, this); |
|
2452 |
|
2453 |
|
2454 CleanupStack::PopAndDestroy(fbsSourceBmp2); |
|
2455 CleanupStack::PopAndDestroy(fbsSourceBmp1); |
|
2456 |
|
2457 CleanupStack::PopAndDestroy(theBitmapContextDest1); |
|
2458 CleanupStack::PopAndDestroy(theBitmapDeviceDest1); |
|
2459 CleanupStack::PopAndDestroy(fbsDestBmp1); |
|
2460 |
|
2461 CleanupStack::PopAndDestroy(theBitmapContextDest); |
|
2462 CleanupStack::PopAndDestroy(theBitmapDeviceDest); |
|
2463 CleanupStack::PopAndDestroy(fbsDestBmp); |
|
2464 |
|
2465 CleanupStack::PopAndDestroy(theBitmapContextSrc); |
|
2466 CleanupStack::PopAndDestroy(theBitmapDeviceSrc); |
|
2467 CleanupStack::PopAndDestroy(fbsSourceBmp); |
|
2468 } |
|
2469 |
|
2470 |
|
2471 /** |
|
2472 @SYMTestCaseID GRAPHICS-BITGDI-0063 |
|
2473 |
|
2474 @SYMDEF |
|
2475 |
|
2476 @SYMTestCaseDesc The behaviour of SwapWidthAndHeight() is different for both Create() |
|
2477 and Load() functions. This might be a defect but needs no bother unless |
|
2478 a solution is requested by clients. |
|
2479 |
|
2480 Lets suppose we have a bitmap of size (40, 12) and a CFbsBitmap object |
|
2481 contructed to hold it. When we use Create() and EColor16 for color depth |
|
2482 as in the following: |
|
2483 iBitmap = new (ELeave) CFbsBitmap; |
|
2484 iBitmap->Create(iSize, EColor16); |
|
2485 the size of the bitmap internally will be 240bytes for EColor16. THE SIZE WILL |
|
2486 BE DIFFERENT FOR EACH COLOR DEPTH. |
|
2487 |
|
2488 When applying SwapWidthAndHeight() the function finds that the size available |
|
2489 (240Bytes) is less than the one needed after the swap (360Byes). This applies |
|
2490 to EColor16, EGray16, EGray4, EGray2 colors modes always and to the rest when |
|
2491 the dimenssions of the bitmap are irrelative (width too much bigger than height). |
|
2492 Before the fix is added SwapWidthAndHeight() used to leave without applying the |
|
2493 swapping. The fix however reallocates memory to fit the new swapped bitmap. |
|
2494 |
|
2495 Now if we use Load() without Create() as in the following: |
|
2496 iBitmap = new (ELeave) CFbsBitmap; |
|
2497 iBitmap->Load(KBmp16_2, 0); |
|
2498 the color depth of the system that best matches the bitmap's will be used. In |
|
2499 our case here it is EColor64K.So the size of the bitmap will be 960Bytes.Changing |
|
2500 the color depth via SetDisplayMode(...) will limit the modification to color |
|
2501 depths that are less than the one used for the bitmap, ie EColor64K. ONLY THE |
|
2502 COLOR DEPTH WILL CHANGE BUT THE SIZE OF THE BITMAP WILL NOT BE RECALCULATED. |
|
2503 This means that the size of the new swapped bitmap will always be less than the |
|
2504 original one with 960Bytes. That why SwapWidthAndHeight() will always pass with |
|
2505 Load() function, unlike using Create() which recalulates the new size. |
|
2506 |
|
2507 @SYMTestPriority High |
|
2508 |
|
2509 @SYMTestStatus Implemented |
|
2510 |
|
2511 @SYMTestActions Creates bitmaps in various colour modes and blits |
|
2512 |
|
2513 @SYMTestExpectedResults Test should perform graphics operations succesfully. |
|
2514 */ |
|
2515 void CTDefect::BitmapsSwappingTest() |
|
2516 { |
|
2517 CreateScreenDeviceL(); |
|
2518 // All color depths are to be tested. Before the fix EColor16, EGray16, EGray4, EGray2 |
|
2519 // used to fail the swapping. |
|
2520 TDisplayMode testMode[] = {EColor4K, EColor64K, EColor16M, EColor16MU, EColor256, EGray256, |
|
2521 /**/ EColor16, EGray16, EGray4, EGray2 /**/}; |
|
2522 |
|
2523 for(TInt ii=0;ii<TInt(sizeof(testMode)/sizeof(testMode[0]));ii++) |
|
2524 { |
|
2525 DeleteBitmap(); |
|
2526 iBitmap = new (ELeave) CFbsBitmap; |
|
2527 User::LeaveIfError(iBitmap->Create(iSize, testMode[ii])); |
|
2528 |
|
2529 iGc->Clear(); |
|
2530 iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
2531 iGc->SetBrushColor(TRgb(0x00, 0x00, 0x00)); |
|
2532 // Apply the swap for the created bitmap with the specified color depth |
|
2533 User::LeaveIfError(iBitmap->SwapWidthAndHeight()); |
|
2534 iGc->BitBlt(TPoint(0, 0), iBitmap); |
|
2535 iDevice->Update(); |
|
2536 } |
|
2537 } |
|
2538 |
|
2539 /** |
|
2540 @SYMTestCaseID GRAPHICS-BITGDI-0064 |
|
2541 |
|
2542 @SYMDEF INC093055 |
|
2543 |
|
2544 @SYMTestCaseDesc BitGdi causes buffer overflow in WServ |
|
2545 |
|
2546 @SYMTestPriority High |
|
2547 |
|
2548 @SYMTestStatus Implemented |
|
2549 |
|
2550 @SYMTestActions tests the rotation of the screen and bitbltmasked. |
|
2551 |
|
2552 @SYMTestExpectedResults Test should perform graphics operations succesfully and no overflow should occur. |
|
2553 */ |
|
2554 |
|
2555 void CTDefect::INC093055L() |
|
2556 { |
|
2557 TInt si; |
|
2558 TInt sj; |
|
2559 TInt err; |
|
2560 //Create the screen device |
|
2561 err = CreateScreenDeviceL(EColor64K); |
|
2562 if(err == KErrNotSupported) |
|
2563 { |
|
2564 return; |
|
2565 } |
|
2566 TSize bmpSize(700,700); |
|
2567 User::LeaveIfError(err); |
|
2568 //Create source bitmap |
|
2569 CFbsBitmap* srcBmp = new (ELeave) CFbsBitmap; |
|
2570 CleanupStack::PushL(srcBmp); |
|
2571 User::LeaveIfError(srcBmp->Create(bmpSize, EColor16M)); |
|
2572 TBitmapUtil bmpUtil1(srcBmp); |
|
2573 bmpUtil1.Begin(TPoint(0, 0)); |
|
2574 for(si=0;si<bmpSize.iWidth; ++si) |
|
2575 { |
|
2576 for(sj=0; sj < bmpSize.iHeight; ++sj) |
|
2577 { |
|
2578 bmpUtil1.SetPos(TPoint(si, sj)); |
|
2579 bmpUtil1.SetPixel(0xffff00); |
|
2580 } |
|
2581 } |
|
2582 bmpUtil1.End(); |
|
2583 //Create mask bitmap |
|
2584 CFbsBitmap* maskBmp = new (ELeave) CFbsBitmap; |
|
2585 CleanupStack::PushL(maskBmp); |
|
2586 User::LeaveIfError(maskBmp->Create(bmpSize, EGray256)); |
|
2587 TBitmapUtil bmpUtil2(maskBmp); |
|
2588 bmpUtil2.Begin(TPoint(0, 0)); |
|
2589 for(si=0;si<bmpSize.iWidth; ++si) |
|
2590 { |
|
2591 for(sj=0; sj < bmpSize.iHeight; ++sj) |
|
2592 { |
|
2593 bmpUtil2.SetPos(TPoint(si, sj)); |
|
2594 bmpUtil2.SetPixel(0xff00ff); |
|
2595 } |
|
2596 } |
|
2597 bmpUtil2.End(); |
|
2598 CFbsDrawDevice *pDev; |
|
2599 |
|
2600 pDev = CFbsDrawDevice::NewScreenDeviceL(0, EColor64K); |
|
2601 CleanupStack::PushL(pDev); |
|
2602 pDev->InitScreen(); |
|
2603 TRect rect(TPoint(20,20), srcBmp->SizeInPixels()); |
|
2604 iGc->Clear(); |
|
2605 iGc->SetClippingRect(rect); |
|
2606 iGc->BitBltMasked(rect.iTl, srcBmp, bmpSize, maskBmp, ETrue); |
|
2607 iGc->CancelClippingRect(); |
|
2608 iDevice->Update(); |
|
2609 User::After(2000000); |
|
2610 pDev->SetOrientation(CFbsDrawDevice::EOrientationRotated90); |
|
2611 iGc->Clear(); |
|
2612 iGc->SetClippingRect(rect); |
|
2613 iGc->BitBltMasked(rect.iTl, srcBmp, bmpSize, srcBmp, ETrue); |
|
2614 iGc->CancelClippingRect(); |
|
2615 iDevice->Update(); |
|
2616 User::After(2000000); |
|
2617 pDev->SetOrientation(CFbsDrawDevice::EOrientationRotated180); |
|
2618 iGc->Clear(); |
|
2619 iGc->SetClippingRect(rect); |
|
2620 iGc->BitBltMasked(rect.iTl, srcBmp, bmpSize, maskBmp, ETrue); |
|
2621 iGc->CancelClippingRect(); |
|
2622 iDevice->Update(); |
|
2623 User::After(2000000); |
|
2624 pDev->SetOrientation(CFbsDrawDevice::EOrientationRotated270); |
|
2625 iGc->Clear(); |
|
2626 iGc->SetClippingRect(rect); |
|
2627 iGc->BitBltMasked(rect.iTl, srcBmp, bmpSize, maskBmp, ETrue); |
|
2628 iGc->CancelClippingRect(); |
|
2629 iDevice->Update(); |
|
2630 User::After(2000000); |
|
2631 pDev->SetOrientation(CFbsDrawDevice::EOrientationNormal); |
|
2632 CleanupStack::PopAndDestroy(pDev); |
|
2633 CleanupStack::PopAndDestroy(maskBmp); |
|
2634 CleanupStack::PopAndDestroy(srcBmp); |
|
2635 } |
|
2636 |
|
2637 /** |
|
2638 @SYMTestCaseID GRAPHICS-BITGDI-0016 |
|
2639 |
|
2640 @SYMDEF PDEF103809 |
|
2641 |
|
2642 @SYMTestCaseDesc Test externalize/internalize of CFbsBitGc |
|
2643 |
|
2644 @SYMTestPriority Medium |
|
2645 |
|
2646 @SYMTestStatus Implemented |
|
2647 |
|
2648 @SYMTestActions Create CFbsBitGc but do not associate a font with it - externalize it - internalize it - check whether font has been created |
|
2649 @SYMTestExpectedResults no font created |
|
2650 |
|
2651 @SYMTestExpectedResults Test should perform graphics operations succesfully. |
|
2652 */ |
|
2653 |
|
2654 void CTDefect::PDEF103809L() |
|
2655 { |
|
2656 RFbsSession::Connect(); |
|
2657 |
|
2658 CFbsScreenDevice* scr=NULL; //To stop a warning |
|
2659 TDisplayMode mode[] = {EColor64K, EColor16MA, EColor16MAP}; |
|
2660 TInt ii; |
|
2661 TInt err = KErrNotSupported; |
|
2662 for(ii=0;(ii<TInt(sizeof(mode)/sizeof(mode[0]))) && (err == KErrNotSupported);++ii) |
|
2663 { |
|
2664 TRAP(err,scr=CFbsScreenDevice::NewL(KDefaultScreenNo,mode[ii])); |
|
2665 } |
|
2666 if (err!=KErrNone) |
|
2667 { |
|
2668 if (err==KErrNotSupported) |
|
2669 { |
|
2670 _LIT(KLog,"Hardware doesn't support mode Color64K, Color16MA or EColor16MAP"); |
|
2671 INFO_PRINTF1(KLog); |
|
2672 } |
|
2673 else |
|
2674 { |
|
2675 _LIT(KLog,"Failed to created Screen Device %S, err=%d"); |
|
2676 INFO_PRINTF3(KLog,&ColorModeName(mode[ii]),err); |
|
2677 } |
|
2678 User::Leave(err); |
|
2679 } |
|
2680 _LIT(KLog,"Created Screen Device with mode %S"); |
|
2681 INFO_PRINTF2(KLog,&ColorModeName(mode[ii])); |
|
2682 scr->SetAutoUpdate(ETrue); |
|
2683 CleanupStack::PushL(scr); |
|
2684 |
|
2685 CFbsBitGc* gc = NULL; |
|
2686 User::LeaveIfError(scr->CreateContext(gc)); |
|
2687 CleanupStack::PushL(gc); |
|
2688 |
|
2689 // before |
|
2690 TBool before = gc->IsFontUsed(); |
|
2691 INFO_PRINTF2(_L("before: %d"),before); |
|
2692 TEST(before==EFalse); |
|
2693 |
|
2694 // create buffer for save/restore |
|
2695 CBufFlat* buf = CBufFlat::NewL(256); |
|
2696 CleanupStack::PushL(buf); |
|
2697 |
|
2698 // save and then restore |
|
2699 RBufWriteStream ws(*buf,0); |
|
2700 gc->ExternalizeL(ws); |
|
2701 ws.Close(); |
|
2702 RBufReadStream rs(*buf,0); |
|
2703 gc->InternalizeL(rs); |
|
2704 rs.Close(); |
|
2705 |
|
2706 // after |
|
2707 TBool after = gc->IsFontUsed(); |
|
2708 INFO_PRINTF2(_L("after: %d"),after); |
|
2709 TEST(after==EFalse); |
|
2710 |
|
2711 CleanupStack::PopAndDestroy(3, scr); |
|
2712 RFbsSession::Disconnect(); |
|
2713 } |
|
2714 |
|
2715 //Method Initialising src and mask bitmap for DEF104856, DEF108338, DEF103736, PDEF108863 and PDEF110934 |
|
2716 void CTDefect::InitialiseSourceAndMaskLC(CFbsBitmap*& aSrc, TDisplayMode aSrcDispMode, CFbsBitmap*& aMask, TDisplayMode aMaskDispMode, TSize aPicSize, TInt aNumMaskBars, TInt aMaskBarHeight, TSize* aMaskSize) |
|
2717 { |
|
2718 TInt err; |
|
2719 // create src bitmap object |
|
2720 aSrc = new(ELeave) CFbsBitmap; |
|
2721 CleanupStack::PushL(aSrc); |
|
2722 err = aSrc->Create(aPicSize, aSrcDispMode); |
|
2723 |
|
2724 // create mask bitmap object |
|
2725 aMask = new(ELeave) CFbsBitmap; |
|
2726 CleanupStack::PushL(aMask); |
|
2727 if(aMaskSize == NULL ) |
|
2728 { |
|
2729 err = aMask->Create(aPicSize, aMaskDispMode); |
|
2730 } |
|
2731 else |
|
2732 { |
|
2733 err = aMask->Create(*aMaskSize, aMaskDispMode); |
|
2734 } |
|
2735 TEST(err == KErrNone); |
|
2736 |
|
2737 // initialise source |
|
2738 TBitmapUtil srcUtil(aSrc); |
|
2739 srcUtil.Begin(TPoint(0, 0)); |
|
2740 for(TInt y = 0; y < aPicSize.iHeight; ++y) |
|
2741 { |
|
2742 for(TInt x = 0; x < aPicSize.iWidth; ++x) |
|
2743 { |
|
2744 srcUtil.SetPos(TPoint(x, y)); |
|
2745 srcUtil.SetPixel(Color(KRgbRed, aSrcDispMode)); |
|
2746 } |
|
2747 } |
|
2748 srcUtil.End(); |
|
2749 err = aSrc->Compress(); |
|
2750 TEST(err == KErrNone); |
|
2751 |
|
2752 // initialise mask |
|
2753 TBitmapUtil maskUtil(aMask); |
|
2754 maskUtil.Begin(TPoint(0, 0)); |
|
2755 TUint32 maskColor; |
|
2756 if(aMaskSize != NULL) |
|
2757 { |
|
2758 aPicSize = *aMaskSize; |
|
2759 } |
|
2760 for(TInt y = 0; y < aPicSize.iHeight; ++y) |
|
2761 { |
|
2762 for(TInt x = 0; x < aPicSize.iWidth; ++x) |
|
2763 { |
|
2764 maskUtil.SetPos(TPoint(x, y)); |
|
2765 if (((x / (aPicSize.iWidth / aNumMaskBars)) & 1) ^ ((y / aMaskBarHeight) & 1)) |
|
2766 { |
|
2767 maskColor = Color(KRgbWhite, aMaskDispMode); |
|
2768 } |
|
2769 else |
|
2770 { |
|
2771 maskColor = Color(KRgbBlack, aMaskDispMode); |
|
2772 } |
|
2773 maskUtil.SetPixel(maskColor); |
|
2774 } |
|
2775 } |
|
2776 maskUtil.End(); |
|
2777 err = aMask->Compress(); |
|
2778 TEST(err == KErrNone); |
|
2779 } |
|
2780 |
|
2781 /** |
|
2782 Method to check images drawn for TestDoDrawBitmapMaskedL() and TestDoBitBltMaskedL() against expected images drawn. |
|
2783 This method will start checking from point (0,0) of the device drawn to. |
|
2784 @param aDevice Device drawn to |
|
2785 @param aWidth Width of area to check |
|
2786 @param aHeight Height of area to check |
|
2787 @param aPattern Pattern to determine which colour to start checking against |
|
2788 @param aBarHeight Expected height of alternating bars in pixels |
|
2789 */ |
|
2790 void CTDefect::CheckResults(CFbsDevice* aDevice, TInt aWidth, TInt aHeight, TInt aPattern, TInt aBarHeight) |
|
2791 { |
|
2792 TRgb color; |
|
2793 TRgb checkColor = aPattern == 1? KRgbGreen : KRgbRed; |
|
2794 |
|
2795 for(TInt y = 0; y < aHeight; ++y) |
|
2796 { |
|
2797 for(TInt x = 0; x < aWidth; ++x) |
|
2798 { |
|
2799 aDevice->GetPixel(color, TPoint(x, y)); |
|
2800 if(color != checkColor) |
|
2801 { |
|
2802 TEST(EFalse); |
|
2803 return; |
|
2804 } |
|
2805 } |
|
2806 if (y % aBarHeight == aBarHeight - 1) |
|
2807 { |
|
2808 checkColor = checkColor == KRgbGreen ? KRgbRed : KRgbGreen; |
|
2809 } |
|
2810 } |
|
2811 } |
|
2812 |
|
2813 void CTDefect::TestDoBltMaskedL(TDisplayMode aSrcDispMode, TDisplayMode aMaskDispMode, TDisplayMode aDeviceDispMode, TSize aPicSize, TBool aUseScreenDevice, TBool aInvertMask, TSize* aMaskSize) |
|
2814 { |
|
2815 // create and initialise source and mask bitmap |
|
2816 CFbsBitmap* src = NULL; |
|
2817 CFbsBitmap* mask = NULL; |
|
2818 // Number of vertical changes to mask colour in a row |
|
2819 const TInt KNumMaskBars = 4; |
|
2820 // Height of each bar in pixels |
|
2821 const TInt KMaskBarHeight = 1; |
|
2822 |
|
2823 InitialiseSourceAndMaskLC(src, aSrcDispMode, mask, aMaskDispMode, aPicSize, KNumMaskBars, KMaskBarHeight, aMaskSize); |
|
2824 TInt err; |
|
2825 CFbsDevice* fbsDevice = NULL; |
|
2826 if (aUseScreenDevice) |
|
2827 { |
|
2828 // create screen device |
|
2829 TRAPD(err, fbsDevice = CFbsScreenDevice::NewL(KNullDesC, aDeviceDispMode)); |
|
2830 if (err == KErrNotSupported) |
|
2831 { |
|
2832 INFO_PRINTF1(_L("Display mode is not supported by scdv")); |
|
2833 CleanupStack::PopAndDestroy(2, src); |
|
2834 return; |
|
2835 } |
|
2836 } |
|
2837 else |
|
2838 { |
|
2839 // create device bitmap |
|
2840 CFbsBitmap* deviceBitmap = new(ELeave) CFbsBitmap; |
|
2841 err = deviceBitmap->Create(aPicSize, aDeviceDispMode); |
|
2842 TEST(err == KErrNone); |
|
2843 CleanupStack::PushL(deviceBitmap); |
|
2844 // create bitmap device |
|
2845 fbsDevice = CFbsBitmapDevice::NewL(deviceBitmap); |
|
2846 } |
|
2847 CleanupStack::PushL(fbsDevice); |
|
2848 // create graphics context |
|
2849 CFbsBitGc* gcContext = NULL; |
|
2850 err = fbsDevice->CreateContext(gcContext); |
|
2851 TEST(err == KErrNone); |
|
2852 TEST(gcContext != NULL); |
|
2853 CleanupStack::PushL(gcContext); |
|
2854 gcContext->SetBrushColor(KRgbGreen); |
|
2855 |
|
2856 TInt barwidth = aPicSize.iWidth/KNumMaskBars; |
|
2857 TSize barSize(barwidth, aPicSize.iHeight); |
|
2858 TInt currentPattern = aInvertMask ? 0 : 1; |
|
2859 for(TInt x = 0; x < aPicSize.iWidth; x += barwidth) |
|
2860 { |
|
2861 gcContext->Clear(); |
|
2862 gcContext->BitBltMasked(TPoint(0, 0), src, TRect(TPoint(x, 0), barSize), mask, aInvertMask); |
|
2863 CheckResults(fbsDevice, barwidth, aPicSize.iHeight, currentPattern, KMaskBarHeight); |
|
2864 currentPattern ^= 1; |
|
2865 } |
|
2866 if (aUseScreenDevice) |
|
2867 { |
|
2868 CleanupStack::PopAndDestroy(4, src); // gcContext, fbsDevice, mask, src |
|
2869 } |
|
2870 else |
|
2871 { |
|
2872 CleanupStack::PopAndDestroy(5, src); // gcContext, fbsDevice, deviceBitmap, mask, src |
|
2873 } |
|
2874 } |
|
2875 |
|
2876 /** |
|
2877 @SYMTestCaseID GRAPHICS-BITGDI-0095 |
|
2878 |
|
2879 @SYMDEF PDEF110934 |
|
2880 |
|
2881 @SYMTestCaseDesc Test that the bitmap is drawn correctly by testing |
|
2882 mask size less or greater than the bitmap size. Three optimized calls tested for this |
|
2883 CFbsBitGc::DoBitBltMaskedNonFlicker |
|
2884 CFbsBitGc::DoBitBltMaskedFlicker |
|
2885 CFbsBitGc::DoBitBltAlpha |
|
2886 |
|
2887 @SYMTestPriority High |
|
2888 |
|
2889 @SYMTestStatus Implemented |
|
2890 |
|
2891 @SYMTestActions Create compressed EColor64K bitmap and EGray2 mask and draw bitmap calling |
|
2892 CFbsBitGc::BitBltMasked with a screen device. The drawing is done in a loop |
|
2893 to simulate the scrolling effect as in a browser. |
|
2894 |
|
2895 @SYMTestExpectedResults All the stripes should pass the integrity check. |
|
2896 **/ |
|
2897 void CTDefect::TestDoBitBltMaskedSizeL() |
|
2898 { |
|
2899 TSize maskSize(96,48); |
|
2900 |
|
2901 // Tests DoBitBltMaskedFlicker for which mask height is less than the source bitmap height |
|
2902 TestDoBltMaskedL(EColor64K, EGray2, EColor16MU, TSize(96,96), EFalse, EFalse, &maskSize); |
|
2903 |
|
2904 if(CFbsDrawDevice::DisplayMode16M() != ENone) |
|
2905 { |
|
2906 // Tests DoBitBltMaskedNonFlicker for which mask height is less than the source bitmap height |
|
2907 TestDoBltMaskedL(EColor64K, EGray2, EColor16MU, TSize(96,96), ETrue, EFalse, &maskSize); |
|
2908 } |
|
2909 |
|
2910 // Tests DoBitBltAlpha for which mask height is less than the source bitmap height |
|
2911 TestDoBltMaskedL(EColor16MU, EGray256, EColor16MU, TSize(96,96), EFalse, EFalse, &maskSize); |
|
2912 |
|
2913 //Change the mask height and check the optimization for maximum height of the source bitmap |
|
2914 maskSize.SetSize(96,144); |
|
2915 // Tests DoBitBltMaskedFlicker for which mask height is greater than the source bitmap height |
|
2916 TestDoBltMaskedL(EColor64K, EGray2, EColor16MU, TSize(96,96), EFalse, EFalse, &maskSize); |
|
2917 |
|
2918 if(CFbsDrawDevice::DisplayMode16M() != ENone) |
|
2919 { |
|
2920 // Tests DoBitBltMaskedNonFlicker for which mask height is greater than the source bitmap height |
|
2921 TestDoBltMaskedL(EColor64K, EGray2, EColor16MU, TSize(96,96), ETrue, EFalse, &maskSize); |
|
2922 } |
|
2923 |
|
2924 // Tests DoBitBltAlpha for which mask height is greater than the source bitmap height |
|
2925 TestDoBltMaskedL(EColor16MU, EGray256, EColor16MU, TSize(96,96), EFalse, EFalse, &maskSize); |
|
2926 } |
|
2927 |
|
2928 TUint32 CTDefect::Color(const TRgb& aColor, const TDisplayMode& aDisplayMode) |
|
2929 { |
|
2930 switch (aDisplayMode) |
|
2931 { |
|
2932 case EGray2: |
|
2933 return aColor.Gray2(); |
|
2934 case EGray4: |
|
2935 return aColor.Gray4(); |
|
2936 case EGray16: |
|
2937 return aColor.Gray16(); |
|
2938 case EGray256: |
|
2939 return aColor.Gray256(); |
|
2940 case EColor16: |
|
2941 return aColor.Color16(); |
|
2942 case EColor256: |
|
2943 return aColor.Color256(); |
|
2944 case EColor64K: |
|
2945 return aColor.Color64K(); |
|
2946 case EColor16M: |
|
2947 return aColor.Color16M(); |
|
2948 case EColor16MU: |
|
2949 return aColor.Color16MU(); |
|
2950 case EColor16MA: |
|
2951 return aColor.Color16MA(); |
|
2952 case EColor16MAP: |
|
2953 return aColor.Color16MAP(); |
|
2954 default: |
|
2955 __ASSERT_DEBUG(EFalse, User::Invariant()); |
|
2956 return 0; |
|
2957 } |
|
2958 } |
|
2959 |
|
2960 /** |
|
2961 @SYMTestCaseID GRAPHICS-BITGDI-0102 |
|
2962 |
|
2963 @SYMDEF ExternalizeInternalizeCFbsBitGCExtraData |
|
2964 |
|
2965 @SYMTestCaseDesc Test externalize/internalize of shadow color in CFbsBitGc |
|
2966 |
|
2967 @SYMTestPriority Medium |
|
2968 |
|
2969 @SYMTestStatus Implemented |
|
2970 |
|
2971 @SYMTestActions Create CFbsBitGc and set the shadow color by calling SetShadowColor(). |
|
2972 Now - externalize it - internalize it - check the shadow color value matches the one that was set |
|
2973 before externalize/internalize. |
|
2974 |
|
2975 @SYMTestExpectedResults Shadow color value should be same after externalize/internalize. |
|
2976 |
|
2977 @SYMTestExpectedResults Test should perform graphics operations succesfully. |
|
2978 */ |
|
2979 |
|
2980 void CTDefect::ExternalizeInternalizeCFbsBitGCExtraData() |
|
2981 { |
|
2982 RFbsSession::Connect(); |
|
2983 |
|
2984 TInt err; |
|
2985 err = CreateScreenDeviceL(EColor64K); |
|
2986 if (err == KErrNotSupported) |
|
2987 err = CreateScreenDeviceL(EColor16MA); |
|
2988 if (err == KErrNotSupported) |
|
2989 err = CreateScreenDeviceL(EColor16MAP); |
|
2990 if (err == KErrNotSupported) |
|
2991 return; |
|
2992 User::LeaveIfError(err); |
|
2993 _LIT(KLog1,"Created %S Screen Device"); |
|
2994 INFO_PRINTF2(KLog1,&ColorModeName(iDevice->DisplayMode())); |
|
2995 iDevice->SetAutoUpdate(ETrue); |
|
2996 |
|
2997 CFbsBitGc* gc = NULL; |
|
2998 User::LeaveIfError(iDevice->CreateContext(gc)); |
|
2999 CleanupStack::PushL(gc); |
|
3000 |
|
3001 // before |
|
3002 const TRgb color = TRgb(10,20,30); |
|
3003 gc->SetShadowColor(color); |
|
3004 |
|
3005 // create buffer for save/restore |
|
3006 CBufFlat* buf = CBufFlat::NewL(256); |
|
3007 CleanupStack::PushL(buf); |
|
3008 |
|
3009 // save and then restore |
|
3010 RBufWriteStream ws(*buf,0); |
|
3011 gc->ExternalizeL(ws); |
|
3012 ws.Close(); |
|
3013 gc->SetShadowColor(TRgb(0,0,0)); |
|
3014 RBufReadStream rs(*buf,0); |
|
3015 gc->InternalizeL(rs); |
|
3016 |
|
3017 // after |
|
3018 TRgb shadowColor; |
|
3019 gc->GetShadowColor(shadowColor); |
|
3020 TEST(color == shadowColor); |
|
3021 rs.Close(); |
|
3022 |
|
3023 CleanupStack::PopAndDestroy(2,gc); |
|
3024 RFbsSession::Disconnect(); |
|
3025 } |
|
3026 |
|
3027 /** |
|
3028 @SYMTestCaseID GRAPHICS-BITGDI-0107 |
|
3029 |
|
3030 @SYMDEF DEF126160 Clipped scaled-down bitmaps drawn incorrectly using CFbsBitmap::DrawBitmap() |
|
3031 |
|
3032 @SYMTestCaseDesc Test bitmap scaling when drawn with a clip rect applied. |
|
3033 |
|
3034 @SYMTestPriority High |
|
3035 |
|
3036 @SYMTestStatus Implemented |
|
3037 |
|
3038 @SYMTestActions - Create a CFbsBitmap and draw three horozontal stripes to it. |
|
3039 - Draw the bitmap scaled down on the left of the screen using DrawBitmap(), and scaled down in the |
|
3040 same way but with a clip rect applied on the right of the screen. |
|
3041 - Compare what is drawn on the left with what is drawn on the right (in the appropraite clip rect area only). |
|
3042 - Repeat but with the bitmap scaled up. |
|
3043 - Repeat with no scaling. |
|
3044 |
|
3045 @SYMTestExpectedResults What is drawn on the left should match what is drawn on the right |
|
3046 (in the appropraite clip rect area only). |
|
3047 If this test was run without the fix for DEF126160, what is drawn clipped on the right when the bitmap is |
|
3048 scaled down would not match what is drawn on the left. |
|
3049 */ |
|
3050 void CTDefect::TestClippedScaledBitmapL() |
|
3051 { |
|
3052 const TDisplayMode KBitmapMode = EColor64K; |
|
3053 const TDisplayMode KDisplayMode[] = {EColor256, EColor4K, EColor16M, EColor16MU, EColor64K, |
|
3054 EGray256, EGray16, EGray4, EGray2, EColor16, EColor16MA, EColor16MAP}; |
|
3055 // Create a screen device and gc for drawing the test bitmap to |
|
3056 TInt ii = 0; |
|
3057 TInt err = KErrNotSupported; |
|
3058 CFbsScreenDevice* scrDev = NULL; |
|
3059 for(;(ii<TInt(sizeof(KDisplayMode)/sizeof(KDisplayMode[0]))) && (err == KErrNotSupported);++ii) |
|
3060 { |
|
3061 TRAP(err, scrDev = CFbsScreenDevice::NewL(0,KDisplayMode[ii])); |
|
3062 } |
|
3063 if (err != KErrNone) |
|
3064 { |
|
3065 _LIT(KLog,"Failed to create screen device %S return value %d"); |
|
3066 INFO_PRINTF3(KLog,&ColorModeName(KDisplayMode[ii]),err); |
|
3067 User::Leave(err); |
|
3068 } |
|
3069 else |
|
3070 { |
|
3071 _LIT(KLog,"Created Screen Device with mode %S"); |
|
3072 INFO_PRINTF2(KLog,&ColorModeName(KDisplayMode[ii])); |
|
3073 } |
|
3074 |
|
3075 User::LeaveIfNull(scrDev); |
|
3076 scrDev->SetAutoUpdate(EFalse); |
|
3077 CleanupStack::PushL(scrDev); |
|
3078 |
|
3079 // Set the bitmap size as one quarter of the screen |
|
3080 TSize bmpSize(scrDev->SizeInPixels().iWidth/2, scrDev->SizeInPixels().iHeight/2); |
|
3081 |
|
3082 CFbsBitGc* scrGc = NULL; |
|
3083 User::LeaveIfError(scrDev->CreateContext(scrGc)); |
|
3084 CleanupStack::PushL(scrGc); |
|
3085 |
|
3086 // Create the test bitmap |
|
3087 CFbsBitmap* bmp = new(ELeave) CFbsBitmap; |
|
3088 CleanupStack::PushL(bmp); |
|
3089 User::LeaveIfError(bmp->Create(bmpSize, KBitmapMode)); |
|
3090 |
|
3091 CFbsBitmapDevice* bmpDev = CFbsBitmapDevice::NewL(bmp); |
|
3092 User::LeaveIfNull(bmpDev); |
|
3093 CleanupStack::PushL(bmpDev); |
|
3094 |
|
3095 CFbsBitGc* bmpGc; |
|
3096 User::LeaveIfError(bmpDev->CreateContext(bmpGc)); |
|
3097 CleanupStack::PushL(bmpGc); |
|
3098 |
|
3099 // Draw a series of diagonal lines across the bitmap |
|
3100 const TInt KNumTestColors = 7; |
|
3101 const TRgb KTestColors[KNumTestColors] = {KRgbRed, KRgbBlue, KRgbGreen, KRgbYellow, KRgbMagenta, KRgbDarkGreen, KRgbDarkYellow}; |
|
3102 const TInt KPenSize = 20; |
|
3103 bmpGc->SetPenSize(TSize(KPenSize,KPenSize)); |
|
3104 for (TInt i = -KPenSize; i < bmpSize.iWidth+bmpSize.iHeight; i += KPenSize) |
|
3105 { |
|
3106 bmpGc->SetPenColor(KTestColors[i%KNumTestColors]); |
|
3107 bmpGc->DrawLine(TPoint(i,0), TPoint(0,i)); |
|
3108 } |
|
3109 |
|
3110 TRect lhsRect; |
|
3111 TRect rhsRect; |
|
3112 TRect lhsCompareRect; |
|
3113 TRect rhsClipRect; |
|
3114 scrGc->Clear(); |
|
3115 |
|
3116 // Scale down - this is the case that would fail without the fix for DEF126160 |
|
3117 INFO_PRINTF1(_L("- Scaling Down")); |
|
3118 lhsRect.SetRect(TPoint(0,0), TSize(bmpSize.iWidth, bmpSize.iHeight/2)); |
|
3119 rhsRect = lhsRect; |
|
3120 rhsRect.Move(scrDev->SizeInPixels().iWidth/2, 0); |
|
3121 lhsCompareRect.SetRect(TPoint(0,lhsRect.Height()/2), TSize(lhsRect.Width(), lhsRect.Height()/2)); |
|
3122 rhsClipRect = lhsCompareRect; |
|
3123 rhsClipRect.Move(scrDev->SizeInPixels().iWidth/2, 0); |
|
3124 scrGc->DrawBitmap(lhsRect, bmp); |
|
3125 scrGc->SetClippingRect(rhsClipRect); |
|
3126 scrGc->DrawBitmap(rhsRect, bmp); |
|
3127 scrDev->Update(); |
|
3128 TEST(scrDev->RectCompare(lhsCompareRect, *scrDev, rhsClipRect)); |
|
3129 |
|
3130 scrGc->CancelClippingRect(); |
|
3131 scrGc->Clear(); |
|
3132 |
|
3133 // Scale up |
|
3134 INFO_PRINTF1(_L("- Scaling Up")); |
|
3135 lhsRect.SetRect(TPoint(0,0), TSize(bmpSize.iWidth, bmpSize.iHeight*2)); |
|
3136 rhsRect = lhsRect; |
|
3137 rhsRect.Move(scrDev->SizeInPixels().iWidth/2, 0); |
|
3138 lhsCompareRect.SetRect(TPoint(0,lhsRect.Height()/2), TSize(lhsRect.Width(), lhsRect.Height()/2)); |
|
3139 rhsClipRect = lhsCompareRect; |
|
3140 rhsClipRect.Move(scrDev->SizeInPixels().iWidth/2, 0); |
|
3141 scrGc->DrawBitmap(lhsRect, bmp); |
|
3142 scrGc->SetClippingRect(rhsClipRect); |
|
3143 scrGc->DrawBitmap(rhsRect, bmp); |
|
3144 scrDev->Update(); |
|
3145 TEST(scrDev->RectCompare(lhsCompareRect, *scrDev, rhsClipRect)); |
|
3146 |
|
3147 scrGc->CancelClippingRect(); |
|
3148 scrGc->Clear(); |
|
3149 |
|
3150 // No scaling |
|
3151 INFO_PRINTF1(_L("- No Scaling")); |
|
3152 lhsRect.SetRect(TPoint(0,0), bmpSize); |
|
3153 rhsRect = lhsRect; |
|
3154 rhsRect.Move(scrDev->SizeInPixels().iWidth/2, 0); |
|
3155 lhsCompareRect.SetRect(TPoint(0,lhsRect.Height()/2), TSize(lhsRect.Width(), lhsRect.Height()/2)); |
|
3156 rhsClipRect = lhsCompareRect; |
|
3157 rhsClipRect.Move(scrDev->SizeInPixels().iWidth/2, 0); |
|
3158 scrGc->DrawBitmap(lhsRect, bmp); |
|
3159 scrGc->SetClippingRect(rhsClipRect); |
|
3160 scrGc->DrawBitmap(rhsRect, bmp); |
|
3161 scrDev->Update(); |
|
3162 TEST(scrDev->RectCompare(lhsCompareRect, *scrDev, rhsClipRect)); |
|
3163 |
|
3164 CleanupStack::PopAndDestroy(5, scrDev); |
|
3165 } |
|
3166 |
|
3167 /** |
|
3168 @SYMTestCaseID GRAPHICS-BITGDI-0109 |
|
3169 |
|
3170 @SYMDEF DEF128522 EndDataAccess() not called when CFbsBitGc::DrawBitmap() returns |
|
3171 |
|
3172 @SYMTestCaseDesc Test that EndDataAccess() is called correctly when a bitmap is drawn |
|
3173 using CFbsBitGc::DrawBitmap(const TPoint&, const CFbsBitmap*) with twips not set. |
|
3174 |
|
3175 @SYMTestPriority High |
|
3176 |
|
3177 @SYMTestStatus Implemented |
|
3178 |
|
3179 @SYMTestActions |
|
3180 - Create a CFbsBitmap. |
|
3181 - Draw using CFbsBitGc::DrawBitmap(const TPoint&, const CFbsBitmap*) without setting the twips. |
|
3182 - Call CFbsBitmap::DataAddress() on the bitmap, this should mark the bitmap |
|
3183 as volatile as DataAddress() was called outside a BeginDataAccess()/EndDataAccess() pair. |
|
3184 - Call CFbsBitmap::IsVolatile() and check the result. |
|
3185 |
|
3186 @SYMTestExpectedResults |
|
3187 CFbsBitmap::IsVolatile() should return ETrue |
|
3188 */ |
|
3189 void CTDefect::TestDrawBitmapTwipsNotSet() |
|
3190 { |
|
3191 const TDisplayMode KBitmapMode = EColor64K; |
|
3192 |
|
3193 // Create a screen device and gc for drawing the test bitmap to |
|
3194 const TDisplayMode KDisplayMode[] = {EColor256, EColor4K, EColor16M, EColor16MU, EColor64K, |
|
3195 EGray256, EGray16, EGray4, EGray2, EColor16, EColor16MA, EColor16MAP}; |
|
3196 // Create a screen device and gc for drawing the test bitmap to |
|
3197 TInt ii = 0; |
|
3198 TInt err = KErrNotSupported; |
|
3199 CFbsScreenDevice* scrDev = NULL; |
|
3200 for(;(ii<TInt(sizeof(KDisplayMode)/sizeof(KDisplayMode[0]))) && (err == KErrNotSupported);++ii) |
|
3201 { |
|
3202 TRAP(err, scrDev = CFbsScreenDevice::NewL(0,KDisplayMode[ii])); |
|
3203 } |
|
3204 if (err != KErrNone) |
|
3205 { |
|
3206 _LIT(KLog,"Failed to create screen device %S return value %d"); |
|
3207 INFO_PRINTF3(KLog,&ColorModeName(KDisplayMode[ii]),err); |
|
3208 User::Leave(err); |
|
3209 } |
|
3210 else |
|
3211 { |
|
3212 _LIT(KLog,"Created Screen Device with mode %S"); |
|
3213 INFO_PRINTF2(KLog,&ColorModeName(KDisplayMode[ii])); |
|
3214 } |
|
3215 |
|
3216 User::LeaveIfNull(scrDev); |
|
3217 CleanupStack::PushL(scrDev); |
|
3218 |
|
3219 CFbsBitGc* scrGc = NULL; |
|
3220 User::LeaveIfError(scrDev->CreateContext(scrGc)); |
|
3221 CleanupStack::PushL(scrGc); |
|
3222 |
|
3223 // Create a test bitmap |
|
3224 CFbsBitmap* bmp = new(ELeave) CFbsBitmap; |
|
3225 CleanupStack::PushL(bmp); |
|
3226 User::LeaveIfError(bmp->Create(TSize(100,100), KBitmapMode)); |
|
3227 |
|
3228 // Draw the bitmap, note that twips have not been set so that DrawBitmap() returns |
|
3229 // directly after the check for twips being set |
|
3230 scrGc->DrawBitmap(TPoint(0,0), bmp); |
|
3231 |
|
3232 // Get the data address of the bitmap. If EndDataAccess() was called correctly |
|
3233 // when DrawBitmap() returned, the bitmap will now be marked as volatile as DataAddress() |
|
3234 // has been called outside a BeginDataAccess()/EndDataAccess() pair. If the bitmap is not |
|
3235 // marked as volatile then EndDataAccess() was not called correctly in DrawBitmap() when |
|
3236 // it returned. |
|
3237 TUint32* data = bmp->DataAddress(); |
|
3238 TBool isVolatile = bmp->IsVolatile(); |
|
3239 TEST(isVolatile); |
|
3240 |
|
3241 CleanupStack::PopAndDestroy(3, scrDev); |
|
3242 } |
|
3243 |
|
3244 |
|
3245 /** |
|
3246 @SYMTestCaseID GRAPHICS-BITGDI-0119 |
|
3247 |
|
3248 @SYMDEF INC138992 |
|
3249 |
|
3250 @SYMTestCaseDesc Test CFbsBitGC:: DrawBitmapMasked() with compressed source and mask bitmaps, |
|
3251 where the target area is larger or smaller than source bitmap's size. |
|
3252 |
|
3253 @SYMTestPriority High |
|
3254 |
|
3255 @SYMTestStatus Implemented |
|
3256 |
|
3257 @SYMTestActions For each configuration: |
|
3258 Create a compressed source and a compressed mask bitmap. |
|
3259 Draw the bitmaps to the device, once with the target area smaller than the size of the source bitmap, |
|
3260 once with the target area larger than the source bitmap. |
|
3261 Compare the actual image drawn with that expected. |
|
3262 |
|
3263 All combinations of following configurations tested : |
|
3264 Mask with display modes EGray2 and EGray256 |
|
3265 Device with display modes EColor64K and EColor16MAP |
|
3266 Mask with sizes same as source bitmap and smaller than source bitmap |
|
3267 |
|
3268 @SYMTestExpectedResults Images drawn should be as expected. |
|
3269 */ |
|
3270 void CTDefect::TestDrawBitmapMaskedL() |
|
3271 { |
|
3272 // Mask size is same as source bitmap size. This covers same code paths as those using a larger mask size. |
|
3273 INFO_PRINTF1(_L(" - with EGray2 mask, EColor64K source and EColor64K display")); |
|
3274 TestDoDrawBitmapMaskedL(EColor64K, EGray2, EColor64K, TSize(96,48)); |
|
3275 |
|
3276 INFO_PRINTF1(_L(" - with EGray256 mask, EColor64K source and EColor64K display")); |
|
3277 TestDoDrawBitmapMaskedL(EColor64K, EGray256, EColor64K, TSize(96,48)); |
|
3278 |
|
3279 INFO_PRINTF1(_L(" - with EGray2 mask, EColor64K source and EColor16MAP display")); |
|
3280 TestDoDrawBitmapMaskedL(EColor64K, EGray2, EColor16MAP, TSize(96,48)); |
|
3281 |
|
3282 INFO_PRINTF1(_L(" - with EGray256 mask, EColor64K source and EColor16MAP display")); |
|
3283 TestDoDrawBitmapMaskedL(EColor64K, EGray256, EColor16MAP, TSize(96,48)); |
|
3284 |
|
3285 // Mask size is smaller than source bitmap size. |
|
3286 // This covers different code paths to above. |
|
3287 TSize maskSize(48,24); |
|
3288 |
|
3289 INFO_PRINTF1(_L(" - with small EGray2 mask, EColor64K source and EColor64K display")); |
|
3290 TestDoDrawBitmapMaskedL(EColor64K, EGray2, EColor64K, TSize(96,48), &maskSize); |
|
3291 |
|
3292 INFO_PRINTF1(_L(" - with small EGray256 mask, EColor64K source and EColor64K display")); |
|
3293 TestDoDrawBitmapMaskedL(EColor64K, EGray256, EColor64K, TSize(96,48), &maskSize); |
|
3294 |
|
3295 INFO_PRINTF1(_L(" - with small EGray2 mask, EColor64K source and EColor16MAP display")); |
|
3296 TestDoDrawBitmapMaskedL(EColor64K, EGray2, EColor16MAP, TSize(96,48), &maskSize); |
|
3297 |
|
3298 INFO_PRINTF1(_L(" - with small EGray256 mask, EColor64K source and EColor16MAP display")); |
|
3299 TestDoDrawBitmapMaskedL(EColor64K, EGray256, EColor16MAP, TSize(96,48), &maskSize); |
|
3300 } |
|
3301 |
|
3302 /** |
|
3303 Tests drawing masked bitmaps with both stretched (twice original size) and squashed (half original size) destination rectangles |
|
3304 */ |
|
3305 void CTDefect::TestDoDrawBitmapMaskedL(TDisplayMode aSrcDispMode, TDisplayMode aMaskDispMode, TDisplayMode aDeviceDispMode, TSize aPicSize, TSize* aMaskSize) |
|
3306 { |
|
3307 // create and initialise source and mask bitmap |
|
3308 CFbsBitmap* src = NULL; |
|
3309 CFbsBitmap* mask = NULL; |
|
3310 // Number of vertical changes to mask colour in a row |
|
3311 const TInt KNumMaskBars = 2; |
|
3312 // Height of each bar in pixels |
|
3313 const TInt KMaskBarHeight = 2; |
|
3314 |
|
3315 InitialiseSourceAndMaskLC(src, aSrcDispMode, mask, aMaskDispMode, aPicSize, KNumMaskBars, KMaskBarHeight, aMaskSize); |
|
3316 |
|
3317 TInt err; |
|
3318 CFbsScreenDevice* fbsDevice = NULL; |
|
3319 // create screen device |
|
3320 TRAP(err, fbsDevice = CFbsScreenDevice::NewL(KNullDesC, aDeviceDispMode)); |
|
3321 if (err == KErrNotSupported) |
|
3322 { |
|
3323 WARN_PRINTF1(_L("Display mode is not supported by scdv")); |
|
3324 CleanupStack::PopAndDestroy(2, src); |
|
3325 return; |
|
3326 } |
|
3327 CleanupStack::PushL(fbsDevice); |
|
3328 // create graphics context |
|
3329 CFbsBitGc* gcContext = NULL; |
|
3330 err = fbsDevice->CreateContext(gcContext); |
|
3331 TEST(err == KErrNone); |
|
3332 TEST(gcContext != NULL); |
|
3333 CleanupStack::PushL(gcContext); |
|
3334 gcContext->SetBrushColor(KRgbGreen); |
|
3335 |
|
3336 const TInt KNumScales = 2; |
|
3337 // Scale ratios for destination rects. |
|
3338 const TReal32 KScale[KNumScales] = {0.5, 2.0}; |
|
3339 |
|
3340 TInt barwidth = (aMaskSize ? aMaskSize->iWidth : aPicSize.iWidth)/KNumMaskBars; |
|
3341 TSize barSize(barwidth, aPicSize.iHeight); |
|
3342 |
|
3343 for (TInt ii = 0; ii < KNumScales; ++ii) |
|
3344 { |
|
3345 TSize scaledBarSize(barwidth*KScale[ii], aPicSize.iHeight*KScale[ii]); |
|
3346 TInt currentPattern = 1; //i.e. mask not inverted |
|
3347 TRect scaledDestRect(TPoint(0,0),scaledBarSize); |
|
3348 for(TInt x = 0; x < aPicSize.iWidth; x += barwidth) |
|
3349 { |
|
3350 gcContext->Clear(); |
|
3351 gcContext->DrawBitmapMasked(scaledDestRect,src,TRect(TPoint(x, 0), barSize), mask, EFalse); |
|
3352 fbsDevice->Update(); |
|
3353 CheckResults(fbsDevice, scaledBarSize.iWidth, scaledBarSize.iHeight, currentPattern, KMaskBarHeight*KScale[ii]); |
|
3354 currentPattern ^= 1; |
|
3355 } |
|
3356 } |
|
3357 |
|
3358 CleanupStack::PopAndDestroy(4, src); // gcContext, fbsDevice, mask, src |
|
3359 } |
|
3360 |
|
3361 //-------------- |
|
3362 __CONSTRUCT_STEP__(Defect) |
|
3363 |
|
3364 void CTDefectStep::TestSetupL() |
|
3365 { |
|
3366 TheFs.Connect(); |
|
3367 ::CopyDataFiles(); |
|
3368 } |
|
3369 |
|
3370 void CTDefectStep::TestClose() |
|
3371 { |
|
3372 ::DeleteDataFiles(); |
|
3373 TheFs.Close(); |
|
3374 } |