|
1 // Copyright (c) 2000-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 <graphicsaccelerator.h> |
|
17 #include "TAccelerator.h" |
|
18 #include <graphics/fbsdefs.h> |
|
19 |
|
20 class TAcceleratedBitmapSpecTest : public TAcceleratedBitmapSpec |
|
21 { |
|
22 // Provides public access to TAcceleratedBitmapSpec |
|
23 public: |
|
24 inline TAcceleratedBitmapSpecTest() : TAcceleratedBitmapSpec() {} |
|
25 inline TAcceleratedBitmapSpecTest(CFbsBitmap* aBitmap) : TAcceleratedBitmapSpec(aBitmap) {} |
|
26 inline TAcceleratedBitmapSpecTest(RHardwareBitmap aBitmap) : TAcceleratedBitmapSpec(aBitmap) {} |
|
27 // |
|
28 inline TInt GetInfo(TAcceleratedBitmapInfo& aInfo) const { return TAcceleratedBitmapSpec::GetInfo(aInfo); } |
|
29 inline void Lock(TBitmapLockCount& aCount) { TAcceleratedBitmapSpec::Lock(aCount); } |
|
30 inline void Lock(TBitmapLockCount& aCount,TAcceleratedBitmapInfo& aInfo) { TAcceleratedBitmapSpec::Lock(aCount,aInfo); } |
|
31 inline void Unlock(TBitmapLockCount& aCount) { TAcceleratedBitmapSpec::Unlock(aCount); } |
|
32 }; |
|
33 |
|
34 const TInt KNumDisplayModes = 13; |
|
35 static struct |
|
36 { |
|
37 TDisplayMode iMode; |
|
38 TBool iEnabled; |
|
39 TInt iPixelShift; |
|
40 } TestDisplayModes[KNumDisplayModes] = |
|
41 { |
|
42 {EGray2,EFalse,0}, |
|
43 {EGray4,EFalse,1}, |
|
44 {EGray16,EFalse,2}, |
|
45 {EGray256,EFalse,3}, |
|
46 {EColor16,EFalse,2}, |
|
47 {EColor256,EFalse,3}, |
|
48 {EColor64K,EFalse,4}, |
|
49 {EColor16M,EFalse,5}, |
|
50 {ERgb,EFalse,5}, |
|
51 {EColor4K,EFalse,4}, |
|
52 {EColor16MU,EFalse,5}, |
|
53 {EColor16MA,EFalse,5}, |
|
54 {EColor16MAP,EFalse,5} |
|
55 }; |
|
56 |
|
57 _LIT(KRam32BitmapOnZ, "z:\\system\\data\\32RAM.mbm"); |
|
58 _LIT(KRamC24BitmapOnZ, "z:\\system\\data\\24RAMC.mbm"); |
|
59 _LIT(KRomC24Bitmap, "z:\\system\\data\\24ROMC.mbm"); |
|
60 |
|
61 // |
|
62 // CTestBitmap |
|
63 // |
|
64 |
|
65 TInt CTestBitmap::ConstructL(TDisplayMode aDisplayMode,TSize aSize,TBool aHWBitmap) |
|
66 { |
|
67 Reset(); |
|
68 |
|
69 iBitmap = new CFbsBitmap; |
|
70 if(iBitmap==NULL) |
|
71 User::Panic(_L("Bitmap not created"),KErrGeneral); |
|
72 |
|
73 TInt ret; |
|
74 if(aHWBitmap) |
|
75 ret = iBitmap->CreateHardwareBitmap(aSize,aDisplayMode,TUid()); |
|
76 else |
|
77 ret = iBitmap->Create(aSize,aDisplayMode); |
|
78 |
|
79 if (ret == KErrNotSupported) |
|
80 { |
|
81 Reset(); |
|
82 return ret; |
|
83 } |
|
84 |
|
85 User::LeaveIfError(ret); |
|
86 |
|
87 TRAPD(err,iDevice = CFbsBitmapDevice::NewL(iBitmap)); |
|
88 if(err) |
|
89 User::Panic(_L("BitmapDevice not created"),err); |
|
90 |
|
91 err = iDevice->CreateContext(iGc); |
|
92 if(err) |
|
93 User::Panic(_L("BitmapDevice not created"),err); |
|
94 |
|
95 return KErrNone; |
|
96 } |
|
97 |
|
98 void CTestBitmap::Reset() |
|
99 { |
|
100 delete iGc; |
|
101 iGc = 0; |
|
102 delete iDevice; |
|
103 iDevice = 0; |
|
104 delete iBitmap; |
|
105 iBitmap = 0; |
|
106 } |
|
107 |
|
108 CTestBitmap::~CTestBitmap() |
|
109 { |
|
110 Reset(); |
|
111 } |
|
112 |
|
113 TBool CTestBitmap::Compare(CTestBitmap* aBitmap2) |
|
114 { |
|
115 TInt width=iBitmap->SizeInPixels().iWidth; |
|
116 TInt pitch = iBitmap->DataStride(); |
|
117 TInt height=iBitmap->SizeInPixels().iHeight; |
|
118 |
|
119 for(TInt yLoop=0;yLoop<height;yLoop++) |
|
120 { |
|
121 TInt offset=yLoop*pitch; |
|
122 TUint8* data1 = ((TUint8*)iBitmap->DataAddress())+offset; |
|
123 TUint8* data2 = ((TUint8*)aBitmap2->iBitmap->DataAddress())+offset; |
|
124 TUint8* dataLimit = data1 + CFbsBitmap::ScanLineLength(width, iBitmap->DisplayMode()); |
|
125 while(data1<dataLimit) |
|
126 { |
|
127 if(*(data1++)!=*(data2++)) |
|
128 { |
|
129 iBitmap->Save(_L("C:\\Compare1.mbm")); |
|
130 aBitmap2->iBitmap->Save(_L("C:\\Compare2.mbm")); |
|
131 return EFalse; |
|
132 } |
|
133 } |
|
134 } |
|
135 return(ETrue); |
|
136 } |
|
137 |
|
138 // |
|
139 // CTAccelerator |
|
140 // |
|
141 |
|
142 CTAccelerator::CTAccelerator(CTestStep* aStep): |
|
143 CTGraphicsBase(aStep), |
|
144 iRandomSeed(1), |
|
145 iGraphicsAccelerator1(0), |
|
146 iGraphicsAccelerator2(0), |
|
147 iHwScreenDevice(0), |
|
148 iScreenGc(0) |
|
149 { |
|
150 TInt i; |
|
151 for(i=0;i<9;i++) |
|
152 iFixedRegion.AddRect(TRect(i*16,i*8,i*16+32,i*8+32)); |
|
153 for(i=0;i<9;i++) |
|
154 iFixedRegion.AddRect(TRect(183-(i*16),i*8,199-(i*16),i*8+32)); |
|
155 |
|
156 iDefaultRegion.AddRect(TRect(0,0,199,99)); |
|
157 INFO_PRINTF1(_L("Graphics Accelerator Testing")); |
|
158 } |
|
159 |
|
160 void CTAccelerator::Cleanup() |
|
161 { |
|
162 delete iGraphicsAccelerator1; |
|
163 iGraphicsAccelerator1 = 0; |
|
164 delete iGraphicsAccelerator2; |
|
165 iGraphicsAccelerator2 = 0; |
|
166 if(iHwScreenDevice) |
|
167 { |
|
168 delete iHwScreenDevice; |
|
169 iHwScreenDevice = 0; |
|
170 } |
|
171 if(iScreenGc) |
|
172 { |
|
173 delete iScreenGc; |
|
174 iScreenGc = 0; |
|
175 } |
|
176 iBitmap1.Reset(); |
|
177 iBitmap2.Reset(); |
|
178 iBitmap3.Reset(); |
|
179 iBitmap4.Reset(); |
|
180 iBitmap5.Reset(); |
|
181 iBitmap6.Reset(); |
|
182 iBitmap7.Reset(); |
|
183 iTileBitmap.Reset(); |
|
184 iAlphaBitmap.Reset(); |
|
185 } |
|
186 |
|
187 TInt CTAccelerator::Random(TInt aMax) // aMax <= 0xFFFF |
|
188 { |
|
189 iRandomSeed *= 69069; |
|
190 TUint r = ((iRandomSeed>>16)*aMax)>>16; |
|
191 return r; |
|
192 } |
|
193 |
|
194 void CTAccelerator::RunTestCaseL(TInt aCurTestCase) |
|
195 { |
|
196 TInt i; |
|
197 ((CTAcceleratorStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); |
|
198 |
|
199 switch(aCurTestCase) |
|
200 { |
|
201 case 1: |
|
202 ((CTAcceleratorStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0021")); |
|
203 INFO_PRINTF1(_L("Testing TAcceleratedBitmapSpec with software bitmaps.")); |
|
204 for(i=0; i<KNumDisplayModes; i++) |
|
205 if (TestDisplayModes[i].iEnabled) |
|
206 { |
|
207 TestAcceleratedBitmapSpecL(TestDisplayModes[i].iMode,EFalse); |
|
208 } |
|
209 break; |
|
210 case 2: |
|
211 ((CTAcceleratorStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0022")); |
|
212 INFO_PRINTF1(_L("Testing graphics operations with software bitmaps.")); |
|
213 for(i=0; i<KNumDisplayModes; i++) |
|
214 if (TestDisplayModes[i].iEnabled) |
|
215 { |
|
216 TestGraphicsOperations(TestDisplayModes[i].iMode,EFalse); |
|
217 } |
|
218 break; |
|
219 case 3: |
|
220 ((CTAcceleratorStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0021")); |
|
221 INFO_PRINTF1(_L("Testing TAcceleratedBitmapSpec with hardware bitmaps.")); |
|
222 for(i=0; i<KNumDisplayModes; i++) |
|
223 if (TestDisplayModes[i].iEnabled) |
|
224 { |
|
225 TestAcceleratedBitmapSpecL(TestDisplayModes[i].iMode,ETrue); |
|
226 } |
|
227 break; |
|
228 case 4: |
|
229 ((CTAcceleratorStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0022")); |
|
230 INFO_PRINTF1(_L("Testing graphics operations with hardware bitmaps.")); |
|
231 for(i=0; i<KNumDisplayModes; i++) |
|
232 if (TestDisplayModes[i].iEnabled) |
|
233 { |
|
234 TestGraphicsOperations(TestDisplayModes[i].iMode,ETrue); |
|
235 } |
|
236 break; |
|
237 case 5: |
|
238 ((CTAcceleratorStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0023")); |
|
239 INFO_PRINTF1(_L("Testing graphics operations with hardware bitmap as screen.")); |
|
240 for(i=0; i<KNumDisplayModes; i++) |
|
241 if (TestDisplayModes[i].iEnabled) |
|
242 { |
|
243 TestGraphicsOperationsWithScreenL(TestDisplayModes[i].iMode,ETrue); |
|
244 } |
|
245 break; |
|
246 case 6: |
|
247 |
|
248 /** |
|
249 @SYMTestCaseID GRAPHICS-BITGDI-0112 |
|
250 */ |
|
251 ((CTAcceleratorStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0112")); |
|
252 INFO_PRINTF1(_L("Testing passing of compressed info to accelerator")); |
|
253 TestAcceleratorInfo(); |
|
254 break; |
|
255 case 7: |
|
256 /** |
|
257 @SYMTestCaseID GRAPHICS-BITGDI-0113 |
|
258 */ |
|
259 ((CTAcceleratorStep*)iStep)->SetTestStepID(_L("GRAPHICS-BITGDI-0113")); |
|
260 INFO_PRINTF1(_L("Testing GetInfo() with an extended bitmap")); |
|
261 TestAcceleratorInfoForExtendedBitmapL(); |
|
262 break; |
|
263 |
|
264 case 8: |
|
265 ((CTAcceleratorStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); |
|
266 ((CTAcceleratorStep*)iStep)->CloseTMSGraphicsStep(); |
|
267 TestComplete(); |
|
268 break; |
|
269 } |
|
270 ((CTAcceleratorStep*)iStep)->RecordTestResultL(); |
|
271 } |
|
272 |
|
273 const TSize TestBitmapSize = TSize(199,99); |
|
274 TSize TestScreenSize; |
|
275 const TSize TestBitmapSize1 = TSize(165,53); |
|
276 |
|
277 |
|
278 /** |
|
279 @SYMTestCaseID GRAPHICS-BITGDI-0021 |
|
280 @SYMCreationDate 21/11/2008 |
|
281 @SYMAuthor douglashetherington |
|
282 @SYMTestStatus 3. Released |
|
283 @SYMTestPriority High |
|
284 @SYMTestCaseDesc Checks that TAcceleratedBitmapSpec does not change the underlaying bitmaps data |
|
285 @SYMTestExpectedResults The bitmap data is not changed |
|
286 @SYMTestActions Creates a bitmap, puts it into a TAcceleratedBitmapSpec then checks the pixel data is unchanged |
|
287 @SYMDEF |
|
288 */ |
|
289 void CTAccelerator::TestAcceleratedBitmapSpecL(TDisplayMode aDisplayMode,TBool aHWBitmap) |
|
290 { |
|
291 TInt ret=0; |
|
292 |
|
293 INFO_PRINTF2(_L(" DisplayMode=%d"),aDisplayMode); |
|
294 |
|
295 // Create bitmap |
|
296 ret = iBitmap1.ConstructL(aDisplayMode,TestBitmapSize,aHWBitmap); |
|
297 INFO_PRINTF2(_L(" TestAcceleratedBitmapSpecL ret=%d"),ret); |
|
298 if(ret!=KErrNone) |
|
299 { |
|
300 WARN_PRINTF1(_L(" Not Supported.")); |
|
301 return; |
|
302 } |
|
303 |
|
304 TAcceleratedBitmapSpecTest bitmapSpec(iBitmap1.iBitmap); |
|
305 TAcceleratedBitmapInfo info; |
|
306 |
|
307 // Check correct size |
|
308 bitmapSpec.Lock(iBitmapLockCount); |
|
309 User::LeaveIfError(bitmapSpec.GetInfo(info)); |
|
310 TEST(info.iSize==iBitmap1.iBitmap->SizeInPixels()); |
|
311 INFO_PRINTF3(_L("Test Display Modes , Expected iPixelShift : %d, Actual iPixelShift: %d"),TestDisplayModes[aDisplayMode-1].iPixelShift,info.iPixelShift); |
|
312 TEST(info.iPixelShift == TestDisplayModes[aDisplayMode-1].iPixelShift); |
|
313 bitmapSpec.Unlock(iBitmapLockCount); |
|
314 |
|
315 TInt scanLineLength = iBitmap1.iBitmap->ScanLineLength(TestBitmapSize.iWidth,aDisplayMode); |
|
316 HBufC8* scanLineBuffer = HBufC8::NewMaxLC(scanLineLength); |
|
317 TPtr8 scanLine(scanLineBuffer->Des()); |
|
318 |
|
319 TInt y,x; |
|
320 |
|
321 // fill bitmap with test data |
|
322 for(y=info.iSize.iHeight-1; y>=0; y--) |
|
323 { |
|
324 TUint8* ptr = &(scanLine)[0]; |
|
325 TUint8* ptrLimit = ptr+scanLineLength; |
|
326 x = 42; |
|
327 while(ptr<ptrLimit) |
|
328 *(ptr++) = (TUint8)(y^(x++)); |
|
329 iBitmap1.iBitmap->SetScanLine(scanLine,y); |
|
330 } |
|
331 |
|
332 // use TAcceleratedBitmapSpec to check contents |
|
333 bitmapSpec.Lock(iBitmapLockCount,info); |
|
334 for(y=0; y<info.iSize.iHeight; y++) |
|
335 { |
|
336 TUint8* ptr = info.iAddress+y*info.iLinePitch; |
|
337 TUint8* ptrLimit = ptr+scanLineLength; |
|
338 x = 42; |
|
339 while(ptr<ptrLimit) |
|
340 if(*(ptr++) != (TUint8)(y^(x++))) |
|
341 { |
|
342 ERR_PRINTF2(_L("!!! Failed at compare A, line %d"),y); |
|
343 User::Leave(KErrGeneral); |
|
344 } |
|
345 } |
|
346 bitmapSpec.Unlock(iBitmapLockCount); |
|
347 |
|
348 // fill bitmap with test data (inverse of previous) |
|
349 for(y=info.iSize.iHeight-1; y>=0; y--) |
|
350 { |
|
351 TUint8* ptr = &(scanLine)[0]; |
|
352 TUint8* ptrLimit = ptr+scanLineLength; |
|
353 x = 42; |
|
354 while(ptr<ptrLimit) |
|
355 *(ptr++) = (TUint8)~(y^(x++)); |
|
356 iBitmap1.iBitmap->SetScanLine(scanLine,y); |
|
357 } |
|
358 |
|
359 // use TAcceleratedBitmapSpec to check contents |
|
360 bitmapSpec.Lock(iBitmapLockCount,info); |
|
361 for(y=0; y<info.iSize.iHeight; y++) |
|
362 { |
|
363 TUint8* ptr = info.iAddress+y*info.iLinePitch; |
|
364 TUint8* ptrLimit = ptr+scanLineLength; |
|
365 x = 42; |
|
366 while(ptr<ptrLimit) |
|
367 if(*(ptr++) != (TUint8)~(y^(x++))) |
|
368 { |
|
369 ERR_PRINTF2(_L("!!! Failed at compare B, line %d"),y); |
|
370 User::Leave(KErrGeneral); |
|
371 } |
|
372 } |
|
373 bitmapSpec.Unlock(iBitmapLockCount); |
|
374 |
|
375 // End |
|
376 CleanupStack::PopAndDestroy(); //scanLineBuffer |
|
377 |
|
378 Cleanup(); |
|
379 |
|
380 INFO_PRINTF1(_L(" OK")); |
|
381 } |
|
382 |
|
383 class CTestFbsDevice : public CFbsDevice |
|
384 { |
|
385 public: |
|
386 inline CGraphicsAccelerator* StealGraphicsAccelerator() |
|
387 { CGraphicsAccelerator* acc = iGraphicsAccelerator; iGraphicsAccelerator = 0; return acc; }; |
|
388 }; |
|
389 |
|
390 |
|
391 /** |
|
392 @SYMTestCaseID GRAPHICS-BITGDI-0022 |
|
393 @SYMCreationDate 21/11/2008 |
|
394 @SYMAuthor douglashetherington |
|
395 @SYMTestStatus 3. Released |
|
396 @SYMTestPriority High |
|
397 @SYMTestCaseDesc Tests various basic graphic operations |
|
398 @SYMTestExpectedResults Tests should perform graphics operations succesfully. |
|
399 @SYMTestActions Creates a number of bitmaps then uses them in various graphic operations |
|
400 @SYMDEF |
|
401 */ |
|
402 void CTAccelerator::TestGraphicsOperations(TDisplayMode aDisplayMode,TBool aHWBitmap) |
|
403 { |
|
404 TInt ret=0; |
|
405 |
|
406 INFO_PRINTF2(_L(" DisplayMode=%d"),aDisplayMode); |
|
407 TRAPD(errCode, ret = iBitmap1.ConstructL(aDisplayMode,TestBitmapSize,aHWBitmap)); |
|
408 if((ret!=KErrNone) || (errCode !=KErrNone) || (!iBitmap1.iDevice->GraphicsAccelerator())) |
|
409 { |
|
410 WARN_PRINTF1(_L(" Not Supported.")); |
|
411 return; |
|
412 } |
|
413 |
|
414 iGraphicsAccelerator1 = ((CTestFbsDevice*)iBitmap1.iDevice)->StealGraphicsAccelerator(); |
|
415 delete iGraphicsAccelerator1; |
|
416 iGraphicsAccelerator1 = 0; |
|
417 |
|
418 if(!iSubRegion.IsEmpty()) |
|
419 iSubRegion.Clear(); |
|
420 iSubRegion.AddRect(iBitmap1.iBitmap->SizeInPixels()); |
|
421 iSubRegion.SubRegion(iFixedRegion); |
|
422 iSubRegionPtr = &iSubRegion; |
|
423 |
|
424 TRAP(errCode, ret = iBitmap2.ConstructL(aDisplayMode,TestBitmapSize,aHWBitmap)); |
|
425 TEST(errCode== KErrNone); |
|
426 if(ret!=KErrNone) |
|
427 User::Panic(_L("Bitmap not created"),ret); |
|
428 |
|
429 TRAP(errCode, ret = iBitmap3.ConstructL(aDisplayMode,TestBitmapSize,aHWBitmap)); |
|
430 TEST(errCode== KErrNone); |
|
431 if(ret!=KErrNone) |
|
432 User::Panic(_L("Bitmap not created"),ret); |
|
433 |
|
434 iGraphicsAccelerator1 = ((CTestFbsDevice*)iBitmap3.iDevice)->StealGraphicsAccelerator(); |
|
435 |
|
436 TRAP(errCode, ret = iBitmap4.ConstructL(aDisplayMode,TestBitmapSize,aHWBitmap)); |
|
437 TEST(errCode== KErrNone); |
|
438 if(ret!=KErrNone) |
|
439 User::Panic(_L("Bitmap not created"),ret); |
|
440 |
|
441 TRAP(errCode, ret = iBitmap5.ConstructL(aDisplayMode,TestBitmapSize1,aHWBitmap)); |
|
442 TEST(errCode== KErrNone); |
|
443 if(ret!=KErrNone) |
|
444 User::Panic(_L("Bitmap not created"),ret); |
|
445 |
|
446 TRAP(errCode, ret = iBitmap6.ConstructL(aDisplayMode,TestBitmapSize,aHWBitmap)); |
|
447 TEST(errCode== KErrNone); |
|
448 if(ret!=KErrNone) |
|
449 User::Panic(_L("Bitmap not created"),ret); |
|
450 |
|
451 TRAP(errCode, ret = iBitmap7.ConstructL(aDisplayMode,TestBitmapSize,aHWBitmap)); |
|
452 TEST(errCode== KErrNone); |
|
453 if(ret!=KErrNone) |
|
454 User::Panic(_L("Bitmap not created"),ret); |
|
455 |
|
456 TRAP(errCode, ret = iBitmap8.ConstructL(aDisplayMode,TestBitmapSize,aHWBitmap)); |
|
457 TEST(errCode== KErrNone); |
|
458 if(ret!=KErrNone) |
|
459 User::Panic(_L("Bitmap not created"),ret); |
|
460 |
|
461 //BrushBitmap |
|
462 CFbsBitmap* iTile = new CFbsBitmap(); |
|
463 TEST(iTile!=NULL); |
|
464 ret = iTile->Load(_L("z:\\system\\data\\tile.mbm"),0,aHWBitmap); |
|
465 TEST(ret==KErrNone); |
|
466 |
|
467 TSize tileSize = iTile->SizeInPixels(); |
|
468 TDisplayMode tileDisplayMode = iTile->DisplayMode(); |
|
469 |
|
470 TRAP(errCode, ret = iTileBitmap.ConstructL(tileDisplayMode,tileSize,aHWBitmap)); |
|
471 TEST(errCode== KErrNone); |
|
472 if(ret== KErrNotSupported) |
|
473 { |
|
474 WARN_PRINTF1(_L(" Not Supported.")); |
|
475 delete iTile; |
|
476 iTile = NULL; |
|
477 return; |
|
478 } |
|
479 iTileBitmap.iGc->BitBlt(TPoint(0,0),iTile); |
|
480 delete iTile; |
|
481 iTile = NULL; |
|
482 |
|
483 //Alpha bitmap |
|
484 TRAP(errCode, ret = iAlphaBitmap.ConstructL(EGray256,TestBitmapSize,aHWBitmap)); |
|
485 TEST(errCode== KErrNone); |
|
486 if(ret!=KErrNone) |
|
487 User::Panic(_L("Bitmap not created"),ret); |
|
488 |
|
489 iGraphicsAccelerator2 = ((CTestFbsDevice*)iBitmap4.iDevice)->StealGraphicsAccelerator(); |
|
490 |
|
491 INFO_PRINTF1(_L("FilledRect")); |
|
492 TestFilledRect(); |
|
493 |
|
494 resetColorBitmaps(); |
|
495 |
|
496 INFO_PRINTF1(_L("FilledRectWithPattern ")); |
|
497 TestFilledRectWithPattern(); |
|
498 |
|
499 resetColorBitmaps(); |
|
500 |
|
501 INFO_PRINTF1(_L("InvertRect")); |
|
502 TestInvertRect(); |
|
503 |
|
504 resetColorBitmaps(); |
|
505 |
|
506 INFO_PRINTF1(_L("FadeRect ")); |
|
507 TestFadeRect(); |
|
508 |
|
509 resetColorBitmaps(); |
|
510 |
|
511 INFO_PRINTF1(_L("BitBlt ")); |
|
512 TestBitBlt(); |
|
513 |
|
514 resetColorBitmaps(); |
|
515 |
|
516 INFO_PRINTF1(_L("BitBltMasked ")); |
|
517 TestBitBltMasked(); |
|
518 |
|
519 resetColorBitmaps(); |
|
520 |
|
521 INFO_PRINTF1(_L("BitBltAlphaBitmap")); |
|
522 TestBitBltAlphaBitmap(); |
|
523 |
|
524 resetColorBitmaps(); |
|
525 |
|
526 INFO_PRINTF1(_L("AlphaBlendTwoBitmaps ")); |
|
527 TestAlphaBlendTwoBitmaps(); |
|
528 |
|
529 resetColorBitmaps(); |
|
530 |
|
531 INFO_PRINTF1(_L("AlphaBlendOneBitmap ")); |
|
532 TestAlphaBlendOneBitmap(); |
|
533 |
|
534 resetColorBitmaps(); |
|
535 |
|
536 Cleanup(); |
|
537 } |
|
538 |
|
539 |
|
540 /** |
|
541 @SYMTestCaseID GRAPHICS-BITGDI-0023 |
|
542 @SYMCreationDate 21/11/2008 |
|
543 @SYMAuthor douglashetherington |
|
544 @SYMTestStatus 3. Released |
|
545 @SYMTestPriority High |
|
546 @SYMTestCaseDesc Tests various basic graphic operations draw directly to the screen device |
|
547 @SYMTestExpectedResults Tests should perform graphics operations succesfully. |
|
548 @SYMTestActions Creates a number of bitmaps then uses them in various graphic operations drawing directly to the screen gc |
|
549 @SYMDEF |
|
550 */ |
|
551 void CTAccelerator::TestGraphicsOperationsWithScreenL(TDisplayMode aDisplayMode,TBool aHWBitmap) |
|
552 { |
|
553 TInt ret; |
|
554 |
|
555 INFO_PRINTF2(_L(" DisplayMode=%d."),aDisplayMode); |
|
556 |
|
557 ret = iBitmap1.ConstructL(aDisplayMode,TestBitmapSize,aHWBitmap); |
|
558 if((ret!=KErrNone) || (!iBitmap1.iDevice->GraphicsAccelerator())) |
|
559 { |
|
560 WARN_PRINTF1(_L(" Not Supported.")); |
|
561 return; |
|
562 } |
|
563 |
|
564 TRAPD(err,iHwScreenDevice = CFbsScreenDevice::NewL(_L(""),aDisplayMode)); |
|
565 if(err) |
|
566 User::Panic(_L("BitmapDevice not created"),err); |
|
567 iHwScreenDevice->ChangeScreenDevice(NULL); |
|
568 err = iHwScreenDevice->CreateContext(iScreenGc); |
|
569 if(err) |
|
570 User::Panic(_L("BitmapDevice not created"),err); |
|
571 |
|
572 TestScreenSize.SetSize(iHwScreenDevice->SizeInPixels().iWidth,iHwScreenDevice->SizeInPixels().iHeight); |
|
573 iDefaultScreenRegion.AddRect(TestScreenSize); |
|
574 |
|
575 iBitmap1.Reset(); |
|
576 iBitmap1.ConstructL(aDisplayMode,TestScreenSize,aHWBitmap); |
|
577 iGraphicsAccelerator1 = ((CTestFbsDevice*)iBitmap1.iDevice)->StealGraphicsAccelerator(); |
|
578 delete iGraphicsAccelerator1; |
|
579 iGraphicsAccelerator1 = 0; |
|
580 |
|
581 if(!iSubRegion.IsEmpty()) |
|
582 iSubRegion.Clear(); |
|
583 iSubRegion.AddRect(iBitmap1.iBitmap->SizeInPixels()); |
|
584 iSubRegion.SubRegion(iFixedRegion); |
|
585 iSubRegionPtr = &iSubRegion; |
|
586 |
|
587 ret = iBitmap2.ConstructL(aDisplayMode,TestScreenSize,aHWBitmap); |
|
588 if(ret!=KErrNone) |
|
589 User::Panic(_L("Bitmap not created"),ret); |
|
590 |
|
591 ret = iBitmap3.ConstructL(aDisplayMode,TestScreenSize,aHWBitmap); |
|
592 if(ret!=KErrNone) |
|
593 User::Panic(_L("Bitmap not created"),ret); |
|
594 |
|
595 iGraphicsAccelerator1 = ((CTestFbsDevice*)iBitmap3.iDevice)->StealGraphicsAccelerator(); |
|
596 |
|
597 ret = iBitmap4.ConstructL(aDisplayMode,TestScreenSize,aHWBitmap); |
|
598 if(ret!=KErrNone) |
|
599 User::Panic(_L("Bitmap not created"),ret); |
|
600 |
|
601 ret = iBitmap5.ConstructL(aDisplayMode,TestBitmapSize1,aHWBitmap); |
|
602 if(ret!=KErrNone) |
|
603 User::Panic(_L("Bitmap not created"),ret); |
|
604 |
|
605 ret = iBitmap6.ConstructL(aDisplayMode,TestScreenSize,aHWBitmap); |
|
606 if(ret!=KErrNone) |
|
607 User::Panic(_L("Bitmap not created"),ret); |
|
608 |
|
609 ret = iBitmap7.ConstructL(aDisplayMode,TestScreenSize,aHWBitmap); |
|
610 if(ret!=KErrNone) |
|
611 User::Panic(_L("Bitmap not created"),ret); |
|
612 |
|
613 //BrushBitmap |
|
614 CFbsBitmap* iTile = new CFbsBitmap(); |
|
615 TEST(iTile!=NULL); |
|
616 ret = iTile->Load(_L("z:\\system\\data\\tile.mbm"),0,aHWBitmap); |
|
617 TEST(ret==KErrNone); |
|
618 |
|
619 TSize tileSize = iTile->SizeInPixels(); |
|
620 TDisplayMode tileDisplayMode = iTile->DisplayMode(); |
|
621 |
|
622 ret= iTileBitmap.ConstructL(tileDisplayMode,tileSize,aHWBitmap); |
|
623 if(ret == KErrNotSupported) |
|
624 { |
|
625 WARN_PRINTF1(_L(" Not Supported.")); |
|
626 delete iTile; |
|
627 iTile = NULL; |
|
628 return; |
|
629 } |
|
630 iTileBitmap.iGc->BitBlt(TPoint(0,0),iTile); |
|
631 delete iTile; |
|
632 iTile = NULL; |
|
633 |
|
634 //Alpha bitmap |
|
635 ret = iAlphaBitmap.ConstructL(EGray256,TestBitmapSize,aHWBitmap); |
|
636 if(ret!=KErrNone) |
|
637 User::Panic(_L("Bitmap not created"),ret); |
|
638 |
|
639 iGraphicsAccelerator2 = ((CTestFbsDevice*)iBitmap4.iDevice)->StealGraphicsAccelerator(); |
|
640 resetColorBitmaps(); |
|
641 |
|
642 INFO_PRINTF1(_L("FilledRect in the screen")); |
|
643 TestScreenFilledRect(); |
|
644 |
|
645 resetColorBitmaps(); |
|
646 |
|
647 INFO_PRINTF1(_L("FilledRectWithPattern in the screen")); |
|
648 TestScreenFilledRectWithPattern(); |
|
649 |
|
650 resetColorBitmaps(); |
|
651 |
|
652 INFO_PRINTF1(_L("InvertRect in the screen")); |
|
653 TestScreenInvertRect(); |
|
654 |
|
655 resetColorBitmaps(); |
|
656 |
|
657 INFO_PRINTF1(_L("FadeRect in the screen")); |
|
658 TestScreenFadeRect(); |
|
659 |
|
660 resetColorBitmaps(); |
|
661 |
|
662 INFO_PRINTF1(_L("BitBlt in the screen")); |
|
663 TestScreenBitBlt(); |
|
664 |
|
665 resetColorBitmaps(); |
|
666 |
|
667 INFO_PRINTF1(_L("BitBltMasked in the screen")); |
|
668 TestScreenBitBltMasked(); |
|
669 |
|
670 resetColorBitmaps(); |
|
671 |
|
672 INFO_PRINTF1(_L("BitBltAlphaBitmap in the screen")); |
|
673 TestScreenBitBltAlphaBitmap(); |
|
674 |
|
675 resetColorBitmaps(); |
|
676 |
|
677 INFO_PRINTF1(_L("AlphaBlendTwoBitmaps in the screen")); |
|
678 TestScreenAlphaBlendTwoBitmaps(); |
|
679 |
|
680 resetColorBitmaps(); |
|
681 |
|
682 |
|
683 INFO_PRINTF1(_L("AlphaBlendOneBitmap in the screen")); |
|
684 TestScreenAlphaBlendOneBitmap(); |
|
685 |
|
686 resetColorBitmaps(); |
|
687 |
|
688 INFO_PRINTF1(_L("Rotating the screen")); |
|
689 TestScreenRotation(); |
|
690 |
|
691 resetColorBitmaps(); |
|
692 |
|
693 INFO_PRINTF1(_L("Changing user display mode")); |
|
694 TestUserDisplayMode(); |
|
695 |
|
696 resetColorBitmaps(); |
|
697 |
|
698 Cleanup(); |
|
699 } |
|
700 |
|
701 void CTAccelerator::TestAcceleratorInfo() |
|
702 { |
|
703 TInt errCode; |
|
704 TInt ret=0; |
|
705 |
|
706 iBitmap5.iBitmap=new CFbsBitmap(); |
|
707 TRAP(errCode, ret=iBitmap5.iBitmap->Load(KRam32BitmapOnZ,0)); |
|
708 TEST(errCode==KErrNone); |
|
709 TEST(ret==KErrNone); |
|
710 TAcceleratedBitmapSpec spec(iBitmap5.iBitmap); |
|
711 TAcceleratedBitmapInfo info; |
|
712 iBitmap5.iBitmap->LockHeap(); |
|
713 spec.GetInfo(info); |
|
714 iBitmap5.iBitmap->UnlockHeap(); |
|
715 TEST(info.iLinePitch==iBitmap5.iBitmap->Header().iSizeInPixels.iWidth*iBitmap5.iBitmap->Header().iBitsPerPixel/8); |
|
716 |
|
717 TRAP(errCode, ret=iBitmap5.iBitmap->Compress()); |
|
718 TEST(errCode==KErrNone); |
|
719 TEST(ret==KErrNone); |
|
720 iBitmap5.iBitmap->LockHeap(); |
|
721 spec.GetInfo(info); |
|
722 iBitmap5.iBitmap->UnlockHeap(); |
|
723 TEST(info.iLinePitch==-iBitmap5.iBitmap->Header().iCompression); |
|
724 |
|
725 TUint32* romAddress = NULL; |
|
726 if(CFbsBitmap::IsFileInRom(KRomC24Bitmap, romAddress)) |
|
727 { |
|
728 TRAP(errCode, ret=iBitmap5.iBitmap->Load(KRomC24Bitmap,0)); |
|
729 TEST(errCode==KErrNone); |
|
730 TEST(ret==KErrNone); |
|
731 iBitmap5.iBitmap->LockHeap(); |
|
732 spec.GetInfo(info); |
|
733 iBitmap5.iBitmap->UnlockHeap(); |
|
734 TEST(info.iLinePitch==-iBitmap5.iBitmap->Header().iCompression); |
|
735 } |
|
736 else |
|
737 { |
|
738 INFO_PRINTF2(_L("Skipping ROM bitmap test since file \"%S\" is reported to not be a ROM bitmap."), |
|
739 &KRomC24Bitmap); |
|
740 INFO_PRINTF1(_L("This should only occur on non-XIP ROMs, e.g. NAND ROMs, where ROM bitmaps aren't supported.")); |
|
741 } |
|
742 |
|
743 TRAP(errCode, ret=iBitmap5.iBitmap->LoadAndCompress(KRamC24BitmapOnZ,0)); |
|
744 TEST(errCode==KErrNone); |
|
745 TEST(ret==KErrNone); |
|
746 iBitmap5.iBitmap->LockHeap(); |
|
747 spec.GetInfo(info); |
|
748 iBitmap5.iBitmap->UnlockHeap(); |
|
749 TEST(info.iLinePitch==-iBitmap5.iBitmap->Header().iCompression); |
|
750 |
|
751 Cleanup(); |
|
752 } |
|
753 |
|
754 void CTAccelerator::TestAcceleratorInfoForExtendedBitmapL() |
|
755 { |
|
756 const TSize KSizeInPixels(64,65); |
|
757 const TDisplayMode KDisplayMode = EColor64K; |
|
758 const TUid KExtendedBitmapUid = {0x87654321}; |
|
759 const TUint8 KTestData[] = "Extended bitmap test data 123456"; |
|
760 const TInt KTestDataSize = sizeof(KTestData); |
|
761 |
|
762 CFbsBitmap* exBmp = new (ELeave) CFbsBitmap; |
|
763 CleanupStack::PushL(exBmp); |
|
764 TInt err = exBmp->CreateExtendedBitmap(KSizeInPixels, KDisplayMode, KExtendedBitmapUid, KTestData, KTestDataSize); |
|
765 TEST(err == KErrNone); |
|
766 |
|
767 TAcceleratedBitmapSpec exSpec(exBmp); |
|
768 TAcceleratedBitmapInfo info; |
|
769 exBmp->LockHeap(); |
|
770 err = exSpec.GetInfo(info); |
|
771 TEST(err == KErrNone); |
|
772 exBmp->UnlockHeap(); |
|
773 |
|
774 TEST(info.iDisplayMode == KDisplayMode); |
|
775 TEST(info.iSize == KSizeInPixels); |
|
776 TEST(info.iLinePitch == -EProprietaryCompression); |
|
777 TEST(info.iPixelShift == KExtendedBitmapUid.iUid); |
|
778 TEST(info.iDataSize == KTestDataSize); |
|
779 |
|
780 CleanupStack::PopAndDestroy(exBmp); |
|
781 } |
|
782 |
|
783 const TInt KNumTestFilledRect = 100; |
|
784 const TInt KNumTestInvertRect = 100; |
|
785 const TInt KNumTestBitBlt = 100; |
|
786 const TInt KNumTestFadeRect= 1000; |
|
787 const TInt KNumTestBitBltMasked= 100; |
|
788 const TInt KNumTestBitBltAlphaBitmap= 100; |
|
789 const TInt KNumTestAlphaBlendBitmaps= 100; |
|
790 |
|
791 void CTAccelerator::TestFilledRect() |
|
792 { |
|
793 TInt gopBufferSize = KNumTestFilledRect*sizeof(TGopFilledRect); |
|
794 TUint8* gopBuffer = new TUint8[gopBufferSize]; |
|
795 TPtr8 gopDes = TPtr8(gopBuffer,0,gopBufferSize); |
|
796 |
|
797 TRect bitmapRect(0,0,TestBitmapSize.iWidth,TestBitmapSize.iHeight); |
|
798 TRect rect; |
|
799 |
|
800 iFixedRegionPtr = &iFixedRegion; |
|
801 |
|
802 iBitmap1.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
803 iBitmap1.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
804 iBitmap1.iGc->SetClippingRegion(iFixedRegionPtr); |
|
805 |
|
806 iBitmap2.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
807 iBitmap2.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
808 iBitmap2.iGc->SetClippingRegion(iFixedRegionPtr); |
|
809 |
|
810 TRgb white; |
|
811 iBitmap3.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
812 iBitmap3.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
813 iBitmap3.iGc->SetBrushColor(white); |
|
814 iBitmap3.iGc->SetClippingRegion(iSubRegionPtr); |
|
815 |
|
816 iBitmap4.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
817 iBitmap4.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
818 iBitmap4.iGc->SetBrushColor(white); |
|
819 iBitmap4.iGc->SetClippingRegion(iSubRegionPtr); |
|
820 |
|
821 for(TInt n=0; n<100; n++) |
|
822 { |
|
823 rect.iTl.iX = Random(TestBitmapSize.iWidth+20)-10; |
|
824 rect.iTl.iY = Random(TestBitmapSize.iHeight+20)-10; |
|
825 rect.iBr.iX = rect.iTl.iX+1+Random(TestBitmapSize.iWidth+20); |
|
826 rect.iBr.iY = rect.iTl.iY+1+Random(TestBitmapSize.iHeight+20); |
|
827 |
|
828 |
|
829 TRgb colorRect(Random(256),Random(256),Random(256)); |
|
830 |
|
831 iBitmap1.iGc->SetBrushColor(colorRect); |
|
832 iBitmap1.iGc->DrawRect(rect); |
|
833 |
|
834 iBitmap2.iGc->SetBrushColor(colorRect); |
|
835 iBitmap2.iGc->DrawRect(rect); |
|
836 |
|
837 TEST(iBitmap1.Compare(&iBitmap2)); |
|
838 |
|
839 rect.Intersection(bitmapRect); |
|
840 if( (rect.iBr.iX>rect.iTl.iX) && (rect.iBr.iY>rect.iTl.iY)) |
|
841 { |
|
842 TGopFilledRect gop(rect,colorRect); |
|
843 gopDes.Append((TUint8*)&gop,sizeof(gop)); |
|
844 TInt error = iGraphicsAccelerator1->Operation(gop); |
|
845 if(error == KErrNotSupported) |
|
846 { |
|
847 delete gopBuffer; |
|
848 WARN_PRINTF1(_L(" Not Supported.")); |
|
849 return; |
|
850 } |
|
851 } |
|
852 iBitmap3.iGc->DrawRect(iBitmap3.iBitmap->SizeInPixels()); |
|
853 |
|
854 TEST(iBitmap2.Compare(&iBitmap3)); |
|
855 } |
|
856 |
|
857 iGraphicsAccelerator2->Operation(gopDes); |
|
858 iBitmap4.iGc->DrawRect(iBitmap4.iBitmap->SizeInPixels()); |
|
859 TEST(iBitmap3.Compare(&iBitmap4)); |
|
860 delete gopBuffer; |
|
861 } |
|
862 |
|
863 void CTAccelerator::TestFilledRectWithPattern() |
|
864 { |
|
865 TInt gopBufferSize = KNumTestInvertRect*sizeof(TGopFilledRectWithPattern); |
|
866 TUint8* gopBuffer = new TUint8[gopBufferSize]; |
|
867 TPtr8 gopDes = TPtr8(gopBuffer,0,gopBufferSize); |
|
868 |
|
869 TRect bitmapRect(0,0,TestBitmapSize.iWidth,TestBitmapSize.iHeight); |
|
870 TRect rect; |
|
871 |
|
872 iFixedRegionPtr = &iFixedRegion; |
|
873 |
|
874 iBitmap1.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
875 iBitmap1.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
876 iBitmap1.iGc->SetBrushStyle(CGraphicsContext::EPatternedBrush); |
|
877 iBitmap1.iGc->UseBrushPattern(iTileBitmap.iBitmap); |
|
878 iBitmap1.iGc->SetClippingRegion(iFixedRegionPtr); |
|
879 |
|
880 iBitmap2.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
881 iBitmap2.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
882 iBitmap2.iGc->SetBrushStyle(CGraphicsContext::EPatternedBrush); |
|
883 iBitmap2.iGc->UseBrushPattern(iTileBitmap.iBitmap); |
|
884 iBitmap2.iGc->SetClippingRegion(iFixedRegionPtr); |
|
885 |
|
886 TRgb white; |
|
887 iBitmap3.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
888 iBitmap3.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
889 iBitmap3.iGc->SetBrushColor(white); |
|
890 iBitmap3.iGc->SetClippingRegion(iSubRegionPtr); |
|
891 |
|
892 iBitmap4.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
893 iBitmap4.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
894 iBitmap4.iGc->SetBrushColor(white); |
|
895 iBitmap4.iGc->SetClippingRegion(iSubRegionPtr); |
|
896 |
|
897 TAcceleratedBitmapSpec patternBitmapSpec(iTileBitmap.iBitmap); |
|
898 TGopFillPattern gopFillPattern; |
|
899 gopFillPattern.iBitmap = patternBitmapSpec; |
|
900 |
|
901 for(TInt n=0; n<100; n++) |
|
902 { |
|
903 rect.iTl.iX = Random(TestBitmapSize.iWidth); |
|
904 rect.iTl.iY = Random(TestBitmapSize.iHeight); |
|
905 rect.iBr.iX = rect.iTl.iX+1+Random(TestBitmapSize.iWidth); |
|
906 rect.iBr.iY = rect.iTl.iY+1+Random(TestBitmapSize.iHeight); |
|
907 |
|
908 TPoint brushOrigin(Random(TestBitmapSize.iWidth -5),Random(TestBitmapSize.iHeight-5)); |
|
909 |
|
910 iBitmap1.iGc->SetBrushOrigin(brushOrigin); |
|
911 iBitmap1.iGc->DrawRect(rect); |
|
912 |
|
913 iBitmap2.iGc->SetBrushOrigin(brushOrigin); |
|
914 iBitmap2.iGc->DrawRect(rect); |
|
915 |
|
916 TEST(iBitmap1.Compare(&iBitmap2)); |
|
917 |
|
918 rect.Intersection(bitmapRect); |
|
919 if( (rect.iBr.iX>rect.iTl.iX) && (rect.iBr.iY>rect.iTl.iY)) |
|
920 { |
|
921 gopFillPattern.iOrigin = brushOrigin; |
|
922 TGopFilledRectWithPattern gop(rect,gopFillPattern); |
|
923 gopDes.Append((TUint8*)&gop,sizeof(gop)); |
|
924 TInt error = iGraphicsAccelerator1->Operation(gop); |
|
925 if(error == KErrNotSupported) |
|
926 { |
|
927 delete gopBuffer; |
|
928 WARN_PRINTF1(_L(" Not Supported.")); |
|
929 return; |
|
930 } |
|
931 } |
|
932 iBitmap3.iGc->DrawRect(iBitmap3.iBitmap->SizeInPixels()); |
|
933 TEST(iBitmap2.Compare(&iBitmap3)); |
|
934 } |
|
935 iGraphicsAccelerator2->Operation(gopDes); |
|
936 iBitmap4.iGc->DrawRect(iBitmap4.iBitmap->SizeInPixels()); |
|
937 TEST(iBitmap3.Compare(&iBitmap4)); |
|
938 iBitmap1.iGc->DiscardBrushPattern(); |
|
939 delete gopBuffer; |
|
940 } |
|
941 |
|
942 void CTAccelerator::TestInvertRect() |
|
943 { |
|
944 TInt gopBufferSize = KNumTestInvertRect*sizeof(TGopInvertRect); |
|
945 TUint8* gopBuffer = new TUint8[gopBufferSize]; |
|
946 TPtr8 gopDes = TPtr8(gopBuffer,0,gopBufferSize); |
|
947 |
|
948 TRect bitmapRect(0,0,TestBitmapSize.iWidth,TestBitmapSize.iHeight); |
|
949 TRect rect; |
|
950 |
|
951 iFixedRegionPtr = &iFixedRegion; |
|
952 |
|
953 iBitmap1.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
954 iBitmap1.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
955 iBitmap1.iGc->SetDrawMode(CGraphicsContext::EDrawModeNOTSCREEN); |
|
956 iBitmap1.iGc->SetClippingRegion(iFixedRegionPtr); |
|
957 |
|
958 iBitmap2.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
959 iBitmap2.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
960 iBitmap2.iGc->SetDrawMode(CGraphicsContext::EDrawModeNOTSCREEN); |
|
961 iBitmap2.iGc->SetClippingRegion(iFixedRegionPtr); |
|
962 |
|
963 TRgb white; |
|
964 iBitmap3.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
965 iBitmap3.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
966 iBitmap3.iGc->SetBrushColor(white); |
|
967 iBitmap3.iGc->SetClippingRegion(iSubRegionPtr); |
|
968 |
|
969 iBitmap4.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
970 iBitmap4.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
971 iBitmap4.iGc->SetBrushColor(white); |
|
972 iBitmap4.iGc->SetClippingRegion(iSubRegionPtr); |
|
973 |
|
974 for(TInt n=0; n<100; n++) |
|
975 { |
|
976 rect.iTl.iX = Random(TestBitmapSize.iWidth+20)-10; |
|
977 rect.iTl.iY = Random(TestBitmapSize.iHeight+20)-10; |
|
978 rect.iBr.iX = rect.iTl.iX+1+Random(TestBitmapSize.iWidth+20); |
|
979 rect.iBr.iY = rect.iTl.iY+1+Random(TestBitmapSize.iHeight+20); |
|
980 |
|
981 iBitmap1.iGc->DrawRect(rect); |
|
982 iBitmap2.iGc->DrawRect(rect); |
|
983 |
|
984 TEST(iBitmap1.Compare(&iBitmap2)); |
|
985 |
|
986 rect.Intersection(bitmapRect); |
|
987 if((rect.iBr.iX>rect.iTl.iX) && (rect.iBr.iY>rect.iTl.iY)) |
|
988 { |
|
989 TGopInvertRect gop(rect); |
|
990 gopDes.Append((TUint8*)&gop,sizeof(gop)); |
|
991 TInt error = iGraphicsAccelerator1->Operation(gop); |
|
992 if(error == KErrNotSupported) |
|
993 { |
|
994 delete gopBuffer; |
|
995 WARN_PRINTF1(_L(" Not Supported.")); |
|
996 return; |
|
997 } |
|
998 } |
|
999 iBitmap3.iGc->DrawRect(iBitmap3.iBitmap->SizeInPixels()); |
|
1000 TEST(iBitmap2.Compare(&iBitmap3)); |
|
1001 } |
|
1002 iGraphicsAccelerator2->Operation(gopDes); |
|
1003 iBitmap4.iGc->DrawRect(iBitmap4.iBitmap->SizeInPixels()); |
|
1004 TEST(iBitmap3.Compare(&iBitmap4)); |
|
1005 delete gopBuffer; |
|
1006 } |
|
1007 |
|
1008 void CTAccelerator::TestFadeRect() |
|
1009 { |
|
1010 TInt gopBufferSize = KNumTestFadeRect*sizeof(TGopFadeRect); |
|
1011 TUint8* gopBuffer = new TUint8[gopBufferSize]; |
|
1012 TPtr8 gopDes = TPtr8(gopBuffer,0,gopBufferSize); |
|
1013 |
|
1014 TRect bitmapRect(0,0,TestBitmapSize.iWidth,TestBitmapSize.iHeight); |
|
1015 TRect rect; |
|
1016 |
|
1017 iFixedRegionPtr = &iFixedRegion; |
|
1018 |
|
1019 iBitmap1.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1020 iBitmap1.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1021 iBitmap1.iGc->SetDrawMode(CGraphicsContext::EDrawModePEN); |
|
1022 iBitmap1.iGc->SetClippingRegion(iFixedRegionPtr); |
|
1023 |
|
1024 iBitmap2.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1025 iBitmap2.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1026 iBitmap2.iGc->SetDrawMode(CGraphicsContext::EDrawModePEN); |
|
1027 iBitmap2.iGc->SetClippingRegion(iFixedRegionPtr); |
|
1028 |
|
1029 for(TInt n=0; n<100; n++) |
|
1030 { |
|
1031 rect.iTl.iX = Random(TestBitmapSize.iWidth); |
|
1032 rect.iTl.iY = Random(TestBitmapSize.iHeight); |
|
1033 rect.iBr.iX = rect.iTl.iX+1+Random(TestBitmapSize.iWidth); |
|
1034 rect.iBr.iY = rect.iTl.iY+1+Random(TestBitmapSize.iHeight); |
|
1035 |
|
1036 TUint8 blackMap = (TUint8)Random(256); |
|
1037 TUint8 whiteMap = (TUint8)Random(256); |
|
1038 |
|
1039 RRegion region(rect); |
|
1040 |
|
1041 iBitmap1.iGc->SetFaded(ETrue); |
|
1042 iBitmap1.iGc->SetFadingParameters(blackMap,whiteMap); |
|
1043 iBitmap1.iGc->FadeArea((TRegion*)®ion); |
|
1044 |
|
1045 iBitmap2.iGc->SetFaded(ETrue); |
|
1046 iBitmap2.iGc->SetFadingParameters(blackMap,whiteMap); |
|
1047 iBitmap2.iGc->FadeArea((TRegion*)®ion); |
|
1048 |
|
1049 region.Close(); |
|
1050 |
|
1051 TEST(iBitmap1.Compare(&iBitmap2)); |
|
1052 |
|
1053 TGopFadeParams fadeParams; |
|
1054 fadeParams.iScale = whiteMap - blackMap + 1; |
|
1055 fadeParams.iOffset = blackMap; |
|
1056 rect.Intersection(bitmapRect); |
|
1057 |
|
1058 if( (rect.iBr.iX>rect.iTl.iX) && (rect.iBr.iY>rect.iTl.iY)) |
|
1059 { |
|
1060 TGopFadeRect gop(rect,fadeParams); |
|
1061 gopDes.Append((TUint8*)&gop,sizeof(gop)); |
|
1062 TInt error = iGraphicsAccelerator1->Operation(gop); |
|
1063 if(error == KErrNotSupported) |
|
1064 { |
|
1065 WARN_PRINTF1(_L(" Not Supported.")); |
|
1066 goto quitFade2; |
|
1067 } |
|
1068 } |
|
1069 TEST(iBitmap2.Compare(&iBitmap3)); |
|
1070 } |
|
1071 |
|
1072 iGraphicsAccelerator2->Operation(gopDes); |
|
1073 TEST(iBitmap3.Compare(&iBitmap4)); |
|
1074 quitFade2: |
|
1075 delete gopBuffer; |
|
1076 iBitmap1.iGc->SetFaded(EFalse); |
|
1077 iBitmap2.iGc->SetFaded(EFalse); |
|
1078 } |
|
1079 |
|
1080 void CTAccelerator::TestBitBlt() |
|
1081 { |
|
1082 TInt gopBufferSize = KNumTestBitBlt*sizeof(TGopBitBlt); |
|
1083 TUint8* gopBuffer = new TUint8[gopBufferSize]; |
|
1084 TPtr8 gopDes = TPtr8(gopBuffer,0,gopBufferSize); |
|
1085 |
|
1086 //dest bitmap has different size |
|
1087 TRect bitmapRect1(0,0,TestBitmapSize1.iWidth,TestBitmapSize1.iHeight); |
|
1088 |
|
1089 TRect rect; |
|
1090 iFixedRegionPtr = &iFixedRegion; |
|
1091 |
|
1092 iBitmap1.iGc->SetClippingRegion(iFixedRegionPtr); |
|
1093 iBitmap2.iGc->SetClippingRegion(iFixedRegionPtr); |
|
1094 |
|
1095 TRgb white; |
|
1096 iBitmap3.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1097 iBitmap3.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1098 iBitmap3.iGc->SetBrushColor(white); |
|
1099 iBitmap3.iGc->SetClippingRegion(iSubRegionPtr); |
|
1100 |
|
1101 iBitmap4.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1102 iBitmap4.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1103 iBitmap4.iGc->SetBrushColor(white); |
|
1104 iBitmap4.iGc->SetClippingRegion(iSubRegionPtr); |
|
1105 |
|
1106 TRgb color1(Random(256),Random(256),Random(256)); |
|
1107 |
|
1108 iBitmap5.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1109 iBitmap5.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1110 iBitmap5.iGc->SetBrushColor(color1); |
|
1111 iBitmap5.iGc->DrawRect(bitmapRect1); |
|
1112 |
|
1113 |
|
1114 for(TInt n=0; n<100; n++) |
|
1115 { |
|
1116 rect.iTl.iX = Random(TestBitmapSize1.iWidth); |
|
1117 rect.iTl.iY = Random(TestBitmapSize1.iHeight); |
|
1118 rect.iBr.iX = rect.iTl.iX+1+Random(TestBitmapSize1.iWidth); |
|
1119 rect.iBr.iY = rect.iTl.iY+1+Random(TestBitmapSize1.iHeight); |
|
1120 |
|
1121 TPoint pointDest(Random(TestBitmapSize.iWidth),Random(TestBitmapSize.iHeight)); |
|
1122 |
|
1123 //bitblt with GC |
|
1124 iBitmap1.iGc->BitBlt(pointDest,iBitmap5.iBitmap,rect); |
|
1125 iBitmap2.iGc->BitBlt(pointDest,iBitmap5.iBitmap,rect); |
|
1126 |
|
1127 TEST(iBitmap1.Compare(&iBitmap2)); |
|
1128 |
|
1129 rect.Intersection(bitmapRect1); |
|
1130 TSize maxSize=TestBitmapSize-pointDest; |
|
1131 if (rect.Width()>maxSize.iWidth) |
|
1132 rect.iBr.iX=rect.iTl.iX+maxSize.iWidth; |
|
1133 if (rect.Height()>maxSize.iHeight) |
|
1134 rect.iBr.iY=rect.iTl.iY+maxSize.iHeight; |
|
1135 if(rect.IsEmpty()) |
|
1136 continue; |
|
1137 |
|
1138 if( (rect.iBr.iX>rect.iTl.iX) && (rect.iBr.iY>rect.iTl.iY)) |
|
1139 { |
|
1140 TAcceleratedBitmapSpec bitmap5Spec(iBitmap5.iBitmap); |
|
1141 TGopBitBlt gopBitBlt(pointDest,bitmap5Spec,rect); |
|
1142 gopDes.Append((TUint8*)&gopBitBlt,sizeof(gopBitBlt)); |
|
1143 TInt error = iGraphicsAccelerator1->Operation(gopBitBlt); |
|
1144 if(error == KErrNotSupported) |
|
1145 { |
|
1146 delete gopBuffer; |
|
1147 WARN_PRINTF1(_L(" Not Supported.")); |
|
1148 return; |
|
1149 } |
|
1150 } |
|
1151 iBitmap3.iGc->DrawRect(iBitmap3.iBitmap->SizeInPixels()); |
|
1152 TEST(iBitmap2.Compare(&iBitmap3)); |
|
1153 } |
|
1154 iGraphicsAccelerator2->Operation(gopDes); |
|
1155 iBitmap4.iGc->DrawRect(iBitmap4.iBitmap->SizeInPixels()); |
|
1156 TEST(iBitmap3.Compare(&iBitmap4)); |
|
1157 delete gopBuffer; |
|
1158 } |
|
1159 |
|
1160 void CTAccelerator::TestBitBltMasked() |
|
1161 { |
|
1162 TInt gopBufferSize = KNumTestBitBltMasked*sizeof(TGopBitBltMasked); |
|
1163 TUint8* gopBuffer = new TUint8[gopBufferSize]; |
|
1164 TPtr8 gopDes = TPtr8(gopBuffer,0,gopBufferSize); |
|
1165 |
|
1166 TRect bitmapRect(0,0,TestBitmapSize.iWidth,TestBitmapSize.iHeight); |
|
1167 |
|
1168 TRect rect; |
|
1169 iFixedRegionPtr = &iFixedRegion; |
|
1170 |
|
1171 iBitmap1.iGc->SetClippingRegion(iFixedRegionPtr); |
|
1172 iBitmap2.iGc->SetClippingRegion(iFixedRegionPtr); |
|
1173 |
|
1174 TRgb white; |
|
1175 iBitmap3.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1176 iBitmap3.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1177 iBitmap3.iGc->SetBrushColor(white); |
|
1178 iBitmap3.iGc->SetClippingRegion(iSubRegionPtr); |
|
1179 |
|
1180 iBitmap4.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1181 iBitmap4.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1182 iBitmap4.iGc->SetBrushColor(white); |
|
1183 iBitmap4.iGc->SetClippingRegion(iSubRegionPtr); |
|
1184 |
|
1185 //Mask bitmap |
|
1186 iBitmap6.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1187 iBitmap6.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1188 |
|
1189 TRgb color1(Random(256),Random(256),Random(256)); |
|
1190 |
|
1191 //Source bitmap |
|
1192 iBitmap7.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1193 iBitmap7.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1194 iBitmap7.iGc->SetBrushColor(color1); |
|
1195 iBitmap7.iGc->DrawRect(bitmapRect); |
|
1196 iBitmap7.iGc->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
1197 |
|
1198 TAcceleratedBitmapSpec bitmap7Spec(iBitmap7.iBitmap); |
|
1199 TAcceleratedBitmapSpec bitmap6Spec(iBitmap6.iBitmap); |
|
1200 |
|
1201 TPoint dest; |
|
1202 TRect rectMask; |
|
1203 |
|
1204 //clear the mask bitmap with white |
|
1205 iBitmap6.iGc->SetBrushColor(TRgb(255,255,255)); |
|
1206 iBitmap6.iGc->DrawRect(bitmapRect); |
|
1207 |
|
1208 //Put randomly in the Bitmap Mask a numbers of black rects |
|
1209 iBitmap6.iGc->SetBrushColor(TRgb(0,0,0)); |
|
1210 |
|
1211 for(TInt n=0; n<10; n++) |
|
1212 { |
|
1213 rectMask.iTl.iX = Random(TestBitmapSize1.iWidth); |
|
1214 rectMask.iTl.iY = Random(TestBitmapSize1.iHeight); |
|
1215 rectMask.iBr.iX = rectMask.iTl.iX+1+Random(TestBitmapSize1.iWidth); |
|
1216 rectMask.iBr.iY = rectMask.iTl.iY+1+Random(TestBitmapSize1.iHeight); |
|
1217 iBitmap6.iGc->DrawRect(rectMask); |
|
1218 } |
|
1219 |
|
1220 for(TInt i=0; i<100; i++) |
|
1221 { |
|
1222 //random rect to blit |
|
1223 rect.iTl.iX = Random(TestBitmapSize1.iWidth); |
|
1224 rect.iTl.iY = Random(TestBitmapSize1.iHeight); |
|
1225 rect.iBr.iX = rect.iTl.iX+1+Random(TestBitmapSize1.iWidth); |
|
1226 rect.iBr.iY = rect.iTl.iY+1+Random(TestBitmapSize1.iHeight); |
|
1227 |
|
1228 //random point destination |
|
1229 dest.iX = Random(TestBitmapSize1.iWidth); |
|
1230 dest.iY = Random(TestBitmapSize1.iHeight); |
|
1231 |
|
1232 //do BitBltMasked with graphics contex |
|
1233 iBitmap1.iGc->BitBltMasked(dest,iBitmap7.iBitmap,rect,iBitmap6.iBitmap,ETrue); |
|
1234 iBitmap2.iGc->BitBltMasked(dest,iBitmap7.iBitmap,rect,iBitmap6.iBitmap,ETrue); |
|
1235 TEST(iBitmap1.Compare(&iBitmap2)); |
|
1236 |
|
1237 rect.Intersection(bitmapRect); |
|
1238 if(rect.IsEmpty()) |
|
1239 continue; |
|
1240 |
|
1241 if((rect.iBr.iX>rect.iTl.iX) && (rect.iBr.iY>rect.iTl.iY)) |
|
1242 { |
|
1243 TGopBitBltMasked gopBitBltMasked(dest,bitmap7Spec,rect,bitmap6Spec); |
|
1244 gopDes.Append((TUint8*)&gopBitBltMasked,sizeof(gopBitBltMasked)); |
|
1245 TInt error = iGraphicsAccelerator1->Operation(gopBitBltMasked); |
|
1246 if(error == KErrNotSupported) |
|
1247 { |
|
1248 delete gopBuffer; |
|
1249 WARN_PRINTF1(_L(" Not Supported.")); |
|
1250 return; |
|
1251 } |
|
1252 } |
|
1253 iBitmap3.iGc->DrawRect(iBitmap3.iBitmap->SizeInPixels()); |
|
1254 TEST(iBitmap2.Compare(&iBitmap3)); |
|
1255 } |
|
1256 iGraphicsAccelerator2->Operation(gopDes); |
|
1257 iBitmap4.iGc->DrawRect(iBitmap4.iBitmap->SizeInPixels()); |
|
1258 TEST(iBitmap3.Compare(&iBitmap4)); |
|
1259 delete gopBuffer; |
|
1260 } |
|
1261 |
|
1262 void CTAccelerator::TestBitBltAlphaBitmap() |
|
1263 { |
|
1264 TInt gopBufferSize = KNumTestBitBltAlphaBitmap*sizeof(TGopBitBltAlphaBitmap); |
|
1265 TUint8* gopBuffer = new TUint8[gopBufferSize]; |
|
1266 TPtr8 gopDes = TPtr8(gopBuffer,0,gopBufferSize); |
|
1267 |
|
1268 TRect bitmapRect(0,0,TestBitmapSize.iWidth,TestBitmapSize.iHeight); |
|
1269 |
|
1270 TRect rect; |
|
1271 iFixedRegionPtr = &iFixedRegion; |
|
1272 |
|
1273 iBitmap1.iGc->SetClippingRegion(iFixedRegionPtr); |
|
1274 iBitmap2.iGc->SetClippingRegion(iFixedRegionPtr); |
|
1275 |
|
1276 TRgb white; |
|
1277 iBitmap3.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1278 iBitmap3.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1279 iBitmap3.iGc->SetBrushColor(white); |
|
1280 iBitmap3.iGc->SetClippingRegion(iSubRegionPtr); |
|
1281 |
|
1282 iBitmap4.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1283 iBitmap4.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1284 iBitmap4.iGc->SetBrushColor(white); |
|
1285 iBitmap4.iGc->SetClippingRegion(iSubRegionPtr); |
|
1286 |
|
1287 TRgb color = TRgb(Random(256),Random(256),Random(256)); |
|
1288 |
|
1289 //Source bitmap |
|
1290 iBitmap7.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1291 iBitmap7.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1292 iBitmap7.iGc->SetBrushColor(color); |
|
1293 iBitmap7.iGc->DrawRect(bitmapRect); |
|
1294 iBitmap7.iGc->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
1295 |
|
1296 iAlphaBitmap.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1297 iAlphaBitmap.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1298 |
|
1299 //create 10 gray level for the alpha bitmap |
|
1300 for(TInt i=0; i<10;i++) |
|
1301 { |
|
1302 TRect tmpRect(0,10*i,200,10+10*i); |
|
1303 TInt index = 255-(20*i); |
|
1304 TRgb tmpRgb; |
|
1305 iAlphaBitmap.iGc->SetBrushColor(tmpRgb.Gray256(index)); |
|
1306 iAlphaBitmap.iGc->DrawRect(tmpRect); |
|
1307 } |
|
1308 |
|
1309 TAcceleratedBitmapSpec bitmap7Spec(iBitmap7.iBitmap); |
|
1310 TAcceleratedBitmapSpec alphaBitmapSpec(iAlphaBitmap.iBitmap); |
|
1311 |
|
1312 iAlphaBitmap.iGc->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
1313 |
|
1314 for(TInt n=0; n<100; n++) |
|
1315 { |
|
1316 rect.iTl.iX = Random(TestBitmapSize.iWidth); |
|
1317 rect.iTl.iY = Random(TestBitmapSize.iHeight); |
|
1318 rect.iBr.iX = rect.iTl.iX+1+Random(TestBitmapSize.iWidth); |
|
1319 rect.iBr.iY = rect.iTl.iY+1+Random(TestBitmapSize.iHeight); |
|
1320 |
|
1321 //Random destination point |
|
1322 TPoint pointDest(Random(TestBitmapSize.iWidth),Random(TestBitmapSize.iHeight)); |
|
1323 |
|
1324 //alpha blitting with Graphics Contex |
|
1325 iBitmap1.iGc->BitBltMasked(pointDest,iBitmap7.iBitmap,rect,iAlphaBitmap.iBitmap,ETrue); |
|
1326 iBitmap2.iGc->BitBltMasked(pointDest,iBitmap7.iBitmap,rect,iAlphaBitmap.iBitmap,ETrue); |
|
1327 |
|
1328 TEST(iBitmap1.Compare(&iBitmap2)); |
|
1329 |
|
1330 rect.Intersection(bitmapRect); |
|
1331 //alpha blitting with Graphics accelerator |
|
1332 TGopBitBltAlphaBitmap gopBitBltAlphaBitmap(pointDest,bitmap7Spec,rect,alphaBitmapSpec); |
|
1333 gopDes.Append((TUint8*)&gopBitBltAlphaBitmap,sizeof(gopBitBltAlphaBitmap)); |
|
1334 TInt error = iGraphicsAccelerator1->Operation(gopBitBltAlphaBitmap); |
|
1335 if(error == KErrNotSupported) |
|
1336 { |
|
1337 WARN_PRINTF1(_L(" Not Supported.")); |
|
1338 goto done; |
|
1339 } |
|
1340 iBitmap3.iGc->DrawRect(iBitmap3.iBitmap->SizeInPixels()); |
|
1341 TEST(iBitmap2.Compare(&iBitmap3)); |
|
1342 } |
|
1343 iGraphicsAccelerator2->Operation(gopDes); |
|
1344 iBitmap4.iGc->DrawRect(iBitmap4.iBitmap->SizeInPixels()); |
|
1345 TEST(iBitmap3.Compare(&iBitmap4)); |
|
1346 done: |
|
1347 delete gopBuffer; |
|
1348 } |
|
1349 |
|
1350 void CTAccelerator::TestAlphaBlendTwoBitmaps() |
|
1351 { |
|
1352 TInt gopBufferSize = KNumTestAlphaBlendBitmaps*sizeof(TGopAlphaBlendTwoBitmaps); |
|
1353 TUint8* gopBuffer = new TUint8[gopBufferSize]; |
|
1354 TPtr8 gopDes = TPtr8(gopBuffer,0,gopBufferSize); |
|
1355 |
|
1356 TRect bitmapRect(0,0,TestBitmapSize.iWidth,TestBitmapSize.iHeight); |
|
1357 |
|
1358 TRect rect; |
|
1359 iFixedRegionPtr = &iFixedRegion; |
|
1360 |
|
1361 iBitmap1.iGc->SetClippingRegion(iFixedRegionPtr); |
|
1362 iBitmap2.iGc->SetClippingRegion(iFixedRegionPtr); |
|
1363 |
|
1364 TRgb white; |
|
1365 iBitmap3.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1366 iBitmap3.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1367 iBitmap3.iGc->SetBrushColor(white); |
|
1368 iBitmap3.iGc->SetClippingRegion(iSubRegionPtr); |
|
1369 |
|
1370 iBitmap4.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1371 iBitmap4.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1372 iBitmap4.iGc->SetBrushColor(white); |
|
1373 iBitmap4.iGc->SetClippingRegion(iSubRegionPtr); |
|
1374 |
|
1375 TRgb color = TRgb(Random(256),Random(256),Random(256)); |
|
1376 |
|
1377 // First Source bitmap |
|
1378 iBitmap7.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1379 iBitmap7.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1380 iBitmap7.iGc->SetBrushColor(color); |
|
1381 iBitmap7.iGc->DrawRect(bitmapRect); |
|
1382 iBitmap7.iGc->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
1383 |
|
1384 // Get a new random color |
|
1385 color = TRgb(Random(256),Random(256),Random(256)); |
|
1386 |
|
1387 // Second Source bitmap |
|
1388 iBitmap8.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1389 iBitmap8.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1390 iBitmap8.iGc->SetBrushColor(color); |
|
1391 iBitmap8.iGc->DrawRect(bitmapRect); |
|
1392 iBitmap8.iGc->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
1393 |
|
1394 iAlphaBitmap.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1395 iAlphaBitmap.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1396 |
|
1397 //create 10 gray level for the alpha bitmap |
|
1398 for(TInt i=0; i<10;i++) |
|
1399 { |
|
1400 TRect tmpRect(0,10*i,200,10+10*i); |
|
1401 TInt index = 255-(20*i); |
|
1402 TRgb tmpRgb; |
|
1403 iAlphaBitmap.iGc->SetBrushColor(tmpRgb.Gray256(index)); |
|
1404 iAlphaBitmap.iGc->DrawRect(tmpRect); |
|
1405 } |
|
1406 |
|
1407 TAcceleratedBitmapSpec bitmap7Spec(iBitmap7.iBitmap); |
|
1408 TAcceleratedBitmapSpec bitmap8Spec(iBitmap8.iBitmap); |
|
1409 TAcceleratedBitmapSpec alphaBitmapSpec(iAlphaBitmap.iBitmap); |
|
1410 |
|
1411 iAlphaBitmap.iGc->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
1412 |
|
1413 for(TInt n=0; n<100; n++) |
|
1414 { |
|
1415 rect.iTl.iX = Random(TestBitmapSize.iWidth - 1); |
|
1416 rect.iTl.iY = Random(TestBitmapSize.iHeight - 1); |
|
1417 rect.iBr.iX = rect.iTl.iX+1+Random(TestBitmapSize.iWidth - rect.iTl.iX); |
|
1418 rect.iBr.iY = rect.iTl.iY+1+Random(TestBitmapSize.iHeight - rect.iTl.iY); |
|
1419 |
|
1420 TPoint pointDest(Random(TestBitmapSize.iWidth),Random(TestBitmapSize.iHeight)); |
|
1421 TPoint pointSource(Random(TestBitmapSize.iWidth),Random(TestBitmapSize.iHeight)); |
|
1422 TPoint pointAlpha(Random(TestBitmapSize.iWidth - rect.Width() - 1),Random(TestBitmapSize.iHeight - rect.Height() - 1)); |
|
1423 |
|
1424 //alpha blending Graphics Context - invalid parameter causes skip to next test |
|
1425 TInt rc = iBitmap1.iGc->AlphaBlendBitmaps(pointDest,iBitmap7.iBitmap,iBitmap8.iBitmap,rect,pointSource,iAlphaBitmap.iBitmap,pointAlpha); |
|
1426 if(rc!=KErrNone) |
|
1427 { |
|
1428 continue; |
|
1429 } |
|
1430 iBitmap2.iGc->AlphaBlendBitmaps(pointDest,iBitmap7.iBitmap,iBitmap8.iBitmap,rect,pointSource,iAlphaBitmap.iBitmap,pointAlpha); |
|
1431 TEST(iBitmap1.Compare(&iBitmap2)); |
|
1432 |
|
1433 rect.Intersection(bitmapRect); |
|
1434 //alpha blending with Graphics accelerator |
|
1435 TGopAlphaBlendTwoBitmaps gopAlphaBlendTwoBitmaps(pointDest,bitmap7Spec,bitmap8Spec,rect,pointSource,alphaBitmapSpec,pointAlpha); |
|
1436 gopDes.Append((TUint8*)&gopAlphaBlendTwoBitmaps,sizeof(gopAlphaBlendTwoBitmaps)); |
|
1437 TInt error = iGraphicsAccelerator1->Operation(gopAlphaBlendTwoBitmaps); |
|
1438 if(error == KErrNotSupported) |
|
1439 { |
|
1440 WARN_PRINTF1(_L(" Not Supported.")); |
|
1441 goto done; |
|
1442 } |
|
1443 iBitmap3.iGc->DrawRect(iBitmap3.iBitmap->SizeInPixels()); |
|
1444 TEST(iBitmap2.Compare(&iBitmap3)); |
|
1445 } |
|
1446 iGraphicsAccelerator2->Operation(gopDes); |
|
1447 iBitmap4.iGc->DrawRect(iBitmap4.iBitmap->SizeInPixels()); |
|
1448 TEST(iBitmap3.Compare(&iBitmap4)); |
|
1449 done: |
|
1450 delete gopBuffer; |
|
1451 } |
|
1452 |
|
1453 void CTAccelerator::TestAlphaBlendOneBitmap() |
|
1454 { |
|
1455 TInt gopBufferSize = KNumTestAlphaBlendBitmaps*sizeof(TGopAlphaBlendOneBitmap); |
|
1456 TUint8* gopBuffer = new TUint8[gopBufferSize]; |
|
1457 TPtr8 gopDes = TPtr8(gopBuffer,0,gopBufferSize); |
|
1458 |
|
1459 TRect bitmapRect(0,0,TestBitmapSize.iWidth,TestBitmapSize.iHeight); |
|
1460 |
|
1461 TRect rect; |
|
1462 iFixedRegionPtr = &iFixedRegion; |
|
1463 |
|
1464 iBitmap1.iGc->SetClippingRegion(iFixedRegionPtr); |
|
1465 iBitmap2.iGc->SetClippingRegion(iFixedRegionPtr); |
|
1466 |
|
1467 TRgb white; |
|
1468 iBitmap3.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1469 iBitmap3.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1470 iBitmap3.iGc->SetBrushColor(white); |
|
1471 iBitmap3.iGc->SetClippingRegion(iSubRegionPtr); |
|
1472 |
|
1473 iBitmap4.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1474 iBitmap4.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1475 iBitmap4.iGc->SetBrushColor(white); |
|
1476 iBitmap4.iGc->SetClippingRegion(iSubRegionPtr); |
|
1477 |
|
1478 TRgb color = TRgb(Random(256),Random(256),Random(256)); |
|
1479 |
|
1480 // First Source bitmap |
|
1481 iBitmap7.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1482 iBitmap7.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1483 iBitmap7.iGc->SetBrushColor(color); |
|
1484 iBitmap7.iGc->DrawRect(bitmapRect); |
|
1485 iBitmap7.iGc->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
1486 |
|
1487 // Get a new random color |
|
1488 color = TRgb(Random(256),Random(256),Random(256)); |
|
1489 |
|
1490 iAlphaBitmap.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1491 iAlphaBitmap.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1492 |
|
1493 //create 10 gray level for the alpha bitmap |
|
1494 for(TInt i=0; i<10;i++) |
|
1495 { |
|
1496 TRect tmpRect(0,10*i,200,10+10*i); |
|
1497 TInt index = 255-(20*i); |
|
1498 TRgb tmpRgb; |
|
1499 iAlphaBitmap.iGc->SetBrushColor(tmpRgb.Gray256(index)); |
|
1500 iAlphaBitmap.iGc->DrawRect(tmpRect); |
|
1501 } |
|
1502 |
|
1503 TAcceleratedBitmapSpec bitmap7Spec(iBitmap7.iBitmap); |
|
1504 TAcceleratedBitmapSpec alphaBitmapSpec(iAlphaBitmap.iBitmap); |
|
1505 |
|
1506 iAlphaBitmap.iGc->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
1507 |
|
1508 for(TInt n=0; n<100; n++) |
|
1509 { |
|
1510 rect.iTl.iX = Random(TestBitmapSize.iWidth - 1); |
|
1511 rect.iTl.iY = Random(TestBitmapSize.iHeight - 1); |
|
1512 rect.iBr.iX = rect.iTl.iX+1+Random(TestBitmapSize.iWidth - rect.iTl.iX); |
|
1513 rect.iBr.iY = rect.iTl.iY+1+Random(TestBitmapSize.iHeight - rect.iTl.iY); |
|
1514 |
|
1515 TPoint pointDest(Random(TestBitmapSize.iWidth),Random(TestBitmapSize.iHeight)); |
|
1516 TPoint pointAlpha(Random(TestBitmapSize.iWidth - rect.Width()),Random(TestBitmapSize.iHeight - rect.Height())); |
|
1517 |
|
1518 iBitmap1.iGc->DrawRect(iBitmap1.iBitmap->SizeInPixels()); |
|
1519 //alpha blending Graphics Context - wrong argument cause skip to next test |
|
1520 TInt rc = iBitmap1.iGc->AlphaBlendBitmaps(pointDest,iBitmap7.iBitmap,rect,iAlphaBitmap.iBitmap,pointAlpha); |
|
1521 if(rc!=KErrNone) |
|
1522 { |
|
1523 continue; |
|
1524 } |
|
1525 iBitmap2.iGc->AlphaBlendBitmaps(pointDest,iBitmap7.iBitmap,rect,iAlphaBitmap.iBitmap,pointAlpha); |
|
1526 TEST(iBitmap1.Compare(&iBitmap2)); |
|
1527 |
|
1528 rect.Intersection(bitmapRect); |
|
1529 //alpha blending with Graphics accelerator |
|
1530 TGopAlphaBlendOneBitmap gopAlphaBlendOneBitmap(pointDest,iBitmap7.iBitmap,rect,iAlphaBitmap.iBitmap,pointAlpha); |
|
1531 gopDes.Append((TUint8*)&gopAlphaBlendOneBitmap,sizeof(gopAlphaBlendOneBitmap)); |
|
1532 TInt error = iGraphicsAccelerator1->Operation(gopAlphaBlendOneBitmap); |
|
1533 if(error == KErrNotSupported) |
|
1534 { |
|
1535 WARN_PRINTF1(_L(" Not Supported.")); |
|
1536 goto done; |
|
1537 } |
|
1538 iBitmap3.iGc->DrawRect(iBitmap3.iBitmap->SizeInPixels()); |
|
1539 TEST(iBitmap2.Compare(&iBitmap3)); |
|
1540 } |
|
1541 iGraphicsAccelerator2->Operation(gopDes); |
|
1542 iBitmap4.iGc->DrawRect(iBitmap4.iBitmap->SizeInPixels()); |
|
1543 TEST(iBitmap3.Compare(&iBitmap4)); |
|
1544 done: |
|
1545 delete gopBuffer; |
|
1546 } |
|
1547 |
|
1548 void CTAccelerator::TestScreenFilledRect() |
|
1549 { |
|
1550 TInt gopBufferSize = KNumTestFilledRect*sizeof(TGopFilledRect); |
|
1551 TUint8* gopBuffer = new TUint8[gopBufferSize]; |
|
1552 TPtr8 gopDes = TPtr8(gopBuffer,0,gopBufferSize); |
|
1553 |
|
1554 TRect screenRect(0,0,TestScreenSize.iWidth,TestScreenSize.iHeight); |
|
1555 |
|
1556 TRect rect; |
|
1557 iFixedRegionPtr = &iFixedRegion; |
|
1558 |
|
1559 //used with GC |
|
1560 iBitmap1.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1561 iBitmap1.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1562 iBitmap1.iGc->SetClippingRegion(iFixedRegionPtr); |
|
1563 |
|
1564 iScreenGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1565 iScreenGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1566 iScreenGc->SetClippingRegion(iFixedRegionPtr); |
|
1567 |
|
1568 TRgb white; |
|
1569 iBitmap3.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1570 iBitmap3.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1571 iBitmap3.iGc->SetBrushColor(white); |
|
1572 iBitmap3.iGc->SetClippingRegion(iSubRegionPtr); |
|
1573 |
|
1574 iBitmap4.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1575 iBitmap4.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1576 iBitmap4.iGc->SetBrushColor(white); |
|
1577 iBitmap4.iGc->SetClippingRegion(iSubRegionPtr); |
|
1578 |
|
1579 for(TInt n=0; n<100; n++) |
|
1580 { |
|
1581 rect.iTl.iX = Random(TestScreenSize.iWidth+20)-10; |
|
1582 rect.iTl.iY = Random(TestScreenSize.iHeight+20)-10; |
|
1583 rect.iBr.iX = rect.iTl.iX+1+Random(TestScreenSize.iWidth+20); |
|
1584 rect.iBr.iY = rect.iTl.iY+1+Random(TestScreenSize.iHeight+20); |
|
1585 |
|
1586 TRgb colorRect(Random(256),Random(256),Random(256)); |
|
1587 |
|
1588 iBitmap1.iGc->SetBrushColor(colorRect); |
|
1589 iBitmap1.iGc->DrawRect(rect); |
|
1590 |
|
1591 iScreenGc->SetBrushColor(colorRect); |
|
1592 iScreenGc->DrawRect(rect); |
|
1593 |
|
1594 iBitmap2.iGc->BitBlt(TPoint(0,0),*iScreenGc,screenRect); |
|
1595 TEST(iBitmap1.Compare(&iBitmap2)); |
|
1596 |
|
1597 rect.Intersection(screenRect); |
|
1598 if( (rect.iBr.iX>rect.iTl.iX) && (rect.iBr.iY>rect.iTl.iY)) |
|
1599 { |
|
1600 TGopFilledRect gop(rect,colorRect); |
|
1601 gopDes.Append((TUint8*)&gop,sizeof(gop)); |
|
1602 TInt error = iGraphicsAccelerator1->Operation(gop); |
|
1603 if(error == KErrNotSupported) |
|
1604 { |
|
1605 delete gopBuffer; |
|
1606 WARN_PRINTF1(_L(" Not Supported.")); |
|
1607 return; |
|
1608 } |
|
1609 } |
|
1610 iBitmap3.iGc->DrawRect(iBitmap3.iBitmap->SizeInPixels()); |
|
1611 TEST(iBitmap2.Compare(&iBitmap3)); |
|
1612 } |
|
1613 iGraphicsAccelerator2->Operation(gopDes); |
|
1614 iBitmap4.iGc->DrawRect(iBitmap4.iBitmap->SizeInPixels()); |
|
1615 TEST(iBitmap3.Compare(&iBitmap4)); |
|
1616 delete gopBuffer; |
|
1617 } |
|
1618 |
|
1619 void CTAccelerator::TestScreenFilledRectWithPattern() |
|
1620 { |
|
1621 TInt gopBufferSize = KNumTestInvertRect*sizeof(TGopFilledRectWithPattern); |
|
1622 TUint8* gopBuffer = new TUint8[gopBufferSize]; |
|
1623 TPtr8 gopDes = TPtr8(gopBuffer,0,gopBufferSize); |
|
1624 |
|
1625 TRect screenRect(0,0,TestScreenSize.iWidth,TestScreenSize.iHeight); |
|
1626 |
|
1627 TRect rect; |
|
1628 iFixedRegionPtr = &iFixedRegion; |
|
1629 |
|
1630 //used with GC |
|
1631 iBitmap1.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1632 iBitmap1.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1633 iBitmap1.iGc->UseBrushPattern(iTileBitmap.iBitmap); |
|
1634 iBitmap1.iGc->SetBrushStyle(CGraphicsContext::EPatternedBrush); |
|
1635 iBitmap1.iGc->SetClippingRegion(iFixedRegionPtr); |
|
1636 |
|
1637 iScreenGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1638 iScreenGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1639 iScreenGc->UseBrushPattern(iTileBitmap.iBitmap); |
|
1640 iScreenGc->SetBrushStyle(CGraphicsContext::EPatternedBrush); |
|
1641 iScreenGc->SetClippingRegion(iFixedRegionPtr); |
|
1642 |
|
1643 TRgb white; |
|
1644 iBitmap3.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1645 iBitmap3.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1646 iBitmap3.iGc->SetBrushColor(white); |
|
1647 iBitmap3.iGc->SetClippingRegion(iSubRegionPtr); |
|
1648 |
|
1649 iBitmap4.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1650 iBitmap4.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1651 iBitmap4.iGc->SetBrushColor(white); |
|
1652 iBitmap4.iGc->SetClippingRegion(iSubRegionPtr); |
|
1653 |
|
1654 TAcceleratedBitmapSpec patternBitmapSpec(iTileBitmap.iBitmap); |
|
1655 TGopFillPattern gopFillPattern; |
|
1656 gopFillPattern.iBitmap = patternBitmapSpec; |
|
1657 |
|
1658 for(TInt n=0; n<100; n++) |
|
1659 { |
|
1660 rect.iTl.iX = Random(TestScreenSize.iWidth); |
|
1661 rect.iTl.iY = Random(TestScreenSize.iHeight); |
|
1662 rect.iBr.iX = rect.iTl.iX+1+Random(TestScreenSize.iWidth); |
|
1663 rect.iBr.iY = rect.iTl.iY+1+Random(TestScreenSize.iHeight); |
|
1664 |
|
1665 TPoint brushOrigin(Random(TestScreenSize.iWidth -5),Random(TestScreenSize.iHeight-5)); |
|
1666 |
|
1667 iBitmap1.iGc->SetBrushOrigin(brushOrigin); |
|
1668 iBitmap1.iGc->DrawRect(rect); |
|
1669 |
|
1670 iScreenGc->SetBrushOrigin(brushOrigin); |
|
1671 iScreenGc->DrawRect(rect); |
|
1672 |
|
1673 iBitmap2.iGc->BitBlt(TPoint(0,0),*iScreenGc,screenRect); |
|
1674 TEST(iBitmap1.Compare(&iBitmap2)); |
|
1675 |
|
1676 rect.Intersection(screenRect); |
|
1677 if( (rect.iBr.iX>rect.iTl.iX) && (rect.iBr.iY>rect.iTl.iY)) |
|
1678 { |
|
1679 gopFillPattern.iOrigin = brushOrigin; |
|
1680 TGopFilledRectWithPattern gop(rect,gopFillPattern); |
|
1681 gopDes.Append((TUint8*)&gop,sizeof(gop)); |
|
1682 TInt error = iGraphicsAccelerator1->Operation(gop); |
|
1683 if(error == KErrNotSupported) |
|
1684 { |
|
1685 delete gopBuffer; |
|
1686 WARN_PRINTF1(_L(" Not Supported.")); |
|
1687 return; |
|
1688 } |
|
1689 } |
|
1690 iBitmap3.iGc->DrawRect(iBitmap3.iBitmap->SizeInPixels()); |
|
1691 TEST(iBitmap2.Compare(&iBitmap3)); |
|
1692 } |
|
1693 |
|
1694 iGraphicsAccelerator2->Operation(gopDes); |
|
1695 iBitmap4.iGc->DrawRect(iBitmap4.iBitmap->SizeInPixels()); |
|
1696 TEST(iBitmap3.Compare(&iBitmap4)); |
|
1697 iBitmap1.iGc->DiscardBrushPattern(); |
|
1698 delete gopBuffer; |
|
1699 } |
|
1700 |
|
1701 void CTAccelerator::TestScreenInvertRect() |
|
1702 { |
|
1703 TInt gopBufferSize = KNumTestInvertRect*sizeof(TGopInvertRect); |
|
1704 TUint8* gopBuffer = new TUint8[gopBufferSize]; |
|
1705 TPtr8 gopDes = TPtr8(gopBuffer,0,gopBufferSize); |
|
1706 |
|
1707 TRect screenRect(0,0,TestScreenSize.iWidth,TestScreenSize.iHeight); |
|
1708 |
|
1709 TRect rect; |
|
1710 iFixedRegionPtr = &iFixedRegion; |
|
1711 |
|
1712 iBitmap1.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1713 iBitmap1.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1714 iBitmap1.iGc->SetDrawMode(CGraphicsContext::EDrawModeNOTSCREEN); |
|
1715 iBitmap1.iGc->SetClippingRegion(iFixedRegionPtr); |
|
1716 |
|
1717 iScreenGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1718 iScreenGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1719 iScreenGc->SetDrawMode(CGraphicsContext::EDrawModeNOTSCREEN); |
|
1720 iScreenGc->SetClippingRegion(iFixedRegionPtr); |
|
1721 |
|
1722 TRgb white; |
|
1723 iBitmap3.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1724 iBitmap3.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1725 iBitmap3.iGc->SetBrushColor(white); |
|
1726 iBitmap3.iGc->SetClippingRegion(iSubRegionPtr); |
|
1727 |
|
1728 iBitmap4.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1729 iBitmap4.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1730 iBitmap4.iGc->SetBrushColor(white); |
|
1731 iBitmap4.iGc->SetClippingRegion(iSubRegionPtr); |
|
1732 |
|
1733 for(TInt n=0; n<100; n++) |
|
1734 { |
|
1735 rect.iTl.iX = Random(TestScreenSize.iWidth+20)-10; |
|
1736 rect.iTl.iY = Random(TestScreenSize.iHeight+20)-10; |
|
1737 rect.iBr.iX = rect.iTl.iX+1+Random(TestScreenSize.iWidth+20); |
|
1738 rect.iBr.iY = rect.iTl.iY+1+Random(TestScreenSize.iHeight+20); |
|
1739 |
|
1740 iBitmap1.iGc->DrawRect(rect); |
|
1741 iScreenGc->DrawRect(rect); |
|
1742 |
|
1743 iBitmap2.iGc->BitBlt(TPoint(0,0),*iScreenGc,screenRect); |
|
1744 TEST(iBitmap1.Compare(&iBitmap2)); |
|
1745 |
|
1746 rect.Intersection(screenRect); |
|
1747 if((rect.iBr.iX>rect.iTl.iX) && (rect.iBr.iY>rect.iTl.iY)) |
|
1748 { |
|
1749 TGopInvertRect gop(rect); |
|
1750 gopDes.Append((TUint8*)&gop,sizeof(gop)); |
|
1751 TInt error = iGraphicsAccelerator1->Operation(gop); |
|
1752 if(error == KErrNotSupported) |
|
1753 { |
|
1754 delete gopBuffer; |
|
1755 WARN_PRINTF1(_L(" Not Supported.")); |
|
1756 return; |
|
1757 } |
|
1758 } |
|
1759 iBitmap3.iGc->DrawRect(iBitmap3.iBitmap->SizeInPixels()); |
|
1760 TEST(iBitmap2.Compare(&iBitmap3)); |
|
1761 } |
|
1762 iGraphicsAccelerator2->Operation(gopDes); |
|
1763 iBitmap4.iGc->DrawRect(iBitmap4.iBitmap->SizeInPixels()); |
|
1764 TEST(iBitmap3.Compare(&iBitmap4)); |
|
1765 delete gopBuffer; |
|
1766 } |
|
1767 |
|
1768 void CTAccelerator::TestScreenFadeRect() |
|
1769 { |
|
1770 TInt gopBufferSize = KNumTestFadeRect*sizeof(TGopFadeRect); |
|
1771 TUint8* gopBuffer = new TUint8[gopBufferSize]; |
|
1772 TPtr8 gopDes = TPtr8(gopBuffer,0,gopBufferSize); |
|
1773 |
|
1774 TRect screenRect(0,0,TestScreenSize.iWidth,TestScreenSize.iHeight); |
|
1775 |
|
1776 TRect rect; |
|
1777 iFixedRegionPtr = &iFixedRegion; |
|
1778 |
|
1779 iBitmap1.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1780 iBitmap1.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1781 iBitmap1.iGc->SetDrawMode(CGraphicsContext::EDrawModePEN); |
|
1782 iBitmap1.iGc->SetClippingRegion(iFixedRegionPtr); |
|
1783 |
|
1784 iScreenGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1785 iScreenGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1786 iScreenGc->SetDrawMode(CGraphicsContext::EDrawModePEN); |
|
1787 iScreenGc->SetClippingRegion(iFixedRegionPtr); |
|
1788 |
|
1789 for(TInt n=0; n<100; n++) |
|
1790 { |
|
1791 rect.iTl.iX = Random(TestScreenSize.iWidth); |
|
1792 rect.iTl.iY = Random(TestScreenSize.iHeight); |
|
1793 rect.iBr.iX = rect.iTl.iX+1+Random(TestScreenSize.iWidth); |
|
1794 rect.iBr.iY = rect.iTl.iY+1+Random(TestScreenSize.iHeight); |
|
1795 |
|
1796 TUint8 blackMap = (TUint8)Random(256); |
|
1797 TUint8 whiteMap = (TUint8)Random(256); |
|
1798 |
|
1799 RRegion region(rect); |
|
1800 |
|
1801 iBitmap1.iGc->SetFaded(ETrue); |
|
1802 iBitmap1.iGc->SetFadingParameters(blackMap,whiteMap); |
|
1803 iBitmap1.iGc->FadeArea((TRegion*)®ion); |
|
1804 |
|
1805 iScreenGc->SetFaded(ETrue); |
|
1806 iScreenGc->SetFadingParameters(blackMap,whiteMap); |
|
1807 iScreenGc->FadeArea((TRegion*)®ion); |
|
1808 |
|
1809 iBitmap2.iGc->BitBlt(TPoint(0,0),*iScreenGc,screenRect); |
|
1810 |
|
1811 region.Close(); |
|
1812 TEST(iBitmap1.Compare(&iBitmap2)); |
|
1813 |
|
1814 TGopFadeParams fadeParams; |
|
1815 fadeParams.iScale = whiteMap - blackMap + 1; |
|
1816 fadeParams.iOffset = blackMap; |
|
1817 rect.Intersection(screenRect); |
|
1818 |
|
1819 if( (rect.iBr.iX>rect.iTl.iX) && (rect.iBr.iY>rect.iTl.iY)) |
|
1820 { |
|
1821 TGopFadeRect gop(rect,fadeParams); |
|
1822 gopDes.Append((TUint8*)&gop,sizeof(gop)); |
|
1823 TInt error = iGraphicsAccelerator1->Operation(gop); |
|
1824 if(error == KErrNotSupported) |
|
1825 { |
|
1826 WARN_PRINTF1(_L(" Not Supported.")); |
|
1827 goto quitFade; |
|
1828 } |
|
1829 } |
|
1830 TEST(iBitmap2.Compare(&iBitmap3)); |
|
1831 } |
|
1832 iGraphicsAccelerator2->Operation(gopDes); |
|
1833 TEST(iBitmap3.Compare(&iBitmap4)); |
|
1834 quitFade: |
|
1835 delete gopBuffer; |
|
1836 iBitmap1.iGc->SetFaded(EFalse); |
|
1837 iScreenGc->SetFaded(EFalse); |
|
1838 } |
|
1839 |
|
1840 void CTAccelerator::TestScreenBitBlt() |
|
1841 { |
|
1842 TInt gopBufferSize = KNumTestBitBlt*sizeof(TGopBitBlt); |
|
1843 TUint8* gopBuffer = new TUint8[gopBufferSize]; |
|
1844 TPtr8 gopDes = TPtr8(gopBuffer,0,gopBufferSize); |
|
1845 |
|
1846 TRect screenRect(0,0,TestScreenSize.iWidth,TestScreenSize.iHeight); |
|
1847 //dest bitmap has different size |
|
1848 TRect bitmapRect1(0,0,TestBitmapSize1.iWidth,TestBitmapSize1.iHeight); |
|
1849 |
|
1850 TRect rect; |
|
1851 iFixedRegionPtr = &iFixedRegion; |
|
1852 |
|
1853 iBitmap1.iGc->SetClippingRegion(iFixedRegionPtr); |
|
1854 iScreenGc->SetClippingRegion(iFixedRegionPtr); |
|
1855 |
|
1856 TRgb white; |
|
1857 iBitmap3.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1858 iBitmap3.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1859 iBitmap3.iGc->SetBrushColor(white); |
|
1860 iBitmap3.iGc->SetClippingRegion(iSubRegionPtr); |
|
1861 |
|
1862 iBitmap4.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1863 iBitmap4.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1864 iBitmap4.iGc->SetBrushColor(white); |
|
1865 iBitmap4.iGc->SetClippingRegion(iSubRegionPtr); |
|
1866 |
|
1867 TRgb color1(Random(256),Random(256),Random(256)); |
|
1868 |
|
1869 iBitmap5.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1870 iBitmap5.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1871 iBitmap5.iGc->SetBrushColor(color1); |
|
1872 iBitmap5.iGc->DrawRect(bitmapRect1); |
|
1873 |
|
1874 |
|
1875 for(TInt n=0; n<100; n++) |
|
1876 { |
|
1877 rect.iTl.iX = Random(TestBitmapSize1.iWidth); |
|
1878 rect.iTl.iY = Random(TestBitmapSize1.iHeight); |
|
1879 rect.iBr.iX = rect.iTl.iX+1+Random(TestBitmapSize1.iWidth); |
|
1880 rect.iBr.iY = rect.iTl.iY+1+Random(TestBitmapSize1.iHeight); |
|
1881 |
|
1882 TPoint pointDest(Random(TestScreenSize.iWidth),Random(TestScreenSize.iHeight)); |
|
1883 |
|
1884 //bitblt with GC |
|
1885 iBitmap1.iGc->BitBlt(pointDest,iBitmap5.iBitmap,rect); |
|
1886 iScreenGc->BitBlt(pointDest,iBitmap5.iBitmap,rect); |
|
1887 |
|
1888 iBitmap2.iGc->BitBlt(TPoint(0,0),*iScreenGc,screenRect); |
|
1889 TEST(iBitmap1.Compare(&iBitmap2)); |
|
1890 |
|
1891 TInt extraWidth=(pointDest.iX+rect.Width())-TestScreenSize.iWidth; |
|
1892 if (extraWidth>0) |
|
1893 rect.iBr.iX-=extraWidth; |
|
1894 TInt extraHeight=(pointDest.iY+rect.Height())-TestScreenSize.iHeight; |
|
1895 if (extraHeight>0) |
|
1896 rect.iBr.iY-=extraHeight; |
|
1897 rect.Intersection(bitmapRect1); |
|
1898 TSize maxSize=TestBitmapSize-pointDest; |
|
1899 if (rect.Width()>maxSize.iWidth) |
|
1900 rect.iBr.iX=rect.iTl.iX+maxSize.iWidth; |
|
1901 if (rect.Height()>maxSize.iHeight) |
|
1902 rect.iBr.iY=rect.iTl.iY+maxSize.iHeight; |
|
1903 if(rect.IsEmpty()) |
|
1904 continue; |
|
1905 |
|
1906 if( (rect.iBr.iX>rect.iTl.iX) && (rect.iBr.iY>rect.iTl.iY)) |
|
1907 { |
|
1908 TAcceleratedBitmapSpec bitmap5Spec(iBitmap5.iBitmap); |
|
1909 TGopBitBlt gopBitBlt(pointDest,bitmap5Spec,rect); |
|
1910 gopDes.Append((TUint8*)&gopBitBlt,sizeof(gopBitBlt)); |
|
1911 TInt error = iGraphicsAccelerator1->Operation(gopBitBlt); |
|
1912 if(error == KErrNotSupported) |
|
1913 { |
|
1914 delete gopBuffer; |
|
1915 WARN_PRINTF1(_L(" Not Supported.")); |
|
1916 return; |
|
1917 } |
|
1918 } |
|
1919 iBitmap3.iGc->DrawRect(iBitmap3.iBitmap->SizeInPixels()); |
|
1920 TEST(iBitmap2.Compare(&iBitmap3)); |
|
1921 } |
|
1922 iGraphicsAccelerator2->Operation(gopDes); |
|
1923 iBitmap4.iGc->DrawRect(iBitmap4.iBitmap->SizeInPixels()); |
|
1924 TEST(iBitmap3.Compare(&iBitmap4)); |
|
1925 delete gopBuffer; |
|
1926 } |
|
1927 |
|
1928 void CTAccelerator::TestScreenBitBltMasked() |
|
1929 { |
|
1930 TInt gopBufferSize = KNumTestBitBltMasked*sizeof(TGopBitBltMasked); |
|
1931 TUint8* gopBuffer = new TUint8[gopBufferSize]; |
|
1932 TPtr8 gopDes = TPtr8(gopBuffer,0,gopBufferSize); |
|
1933 |
|
1934 TRect screenRect(0,0,TestScreenSize.iWidth,TestScreenSize.iHeight); |
|
1935 |
|
1936 TRect rect; |
|
1937 iFixedRegionPtr = &iFixedRegion; |
|
1938 |
|
1939 iBitmap1.iGc->SetClippingRegion(iFixedRegionPtr); |
|
1940 iScreenGc->SetClippingRegion(iFixedRegionPtr); |
|
1941 |
|
1942 TRgb white; |
|
1943 iBitmap3.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1944 iBitmap3.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1945 iBitmap3.iGc->SetBrushColor(white); |
|
1946 iBitmap3.iGc->SetClippingRegion(iSubRegionPtr); |
|
1947 |
|
1948 iBitmap4.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1949 iBitmap4.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1950 iBitmap4.iGc->SetBrushColor(white); |
|
1951 iBitmap4.iGc->SetClippingRegion(iSubRegionPtr); |
|
1952 |
|
1953 //Mask bitmap |
|
1954 iBitmap6.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1955 iBitmap6.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1956 |
|
1957 TRgb color1(Random(256),Random(256),Random(256)); |
|
1958 |
|
1959 //Source bitmap |
|
1960 iBitmap7.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
1961 iBitmap7.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1962 iBitmap7.iGc->SetBrushColor(color1); |
|
1963 iBitmap7.iGc->DrawRect(iBitmap7.iBitmap->SizeInPixels()); |
|
1964 iBitmap7.iGc->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
1965 |
|
1966 TAcceleratedBitmapSpec bitmap7Spec(iBitmap7.iBitmap); |
|
1967 TAcceleratedBitmapSpec bitmap6Spec(iBitmap6.iBitmap); |
|
1968 |
|
1969 TPoint dest; |
|
1970 TRect rectMask; |
|
1971 |
|
1972 //Put randomly in the Bitmap Mask a numbers of black rects |
|
1973 iBitmap6.iGc->SetBrushColor(TRgb(0,0,0)); |
|
1974 |
|
1975 for(TInt n=0; n<3; n++) |
|
1976 { |
|
1977 rectMask.iTl.iX = Random(TestScreenSize.iWidth); |
|
1978 rectMask.iTl.iY = Random(TestScreenSize.iHeight); |
|
1979 rectMask.iBr.iX = rectMask.iTl.iX+1+Random(TestScreenSize.iWidth); |
|
1980 rectMask.iBr.iY = rectMask.iTl.iY+1+Random(TestScreenSize.iHeight); |
|
1981 iBitmap6.iGc->DrawRect(rectMask); |
|
1982 } |
|
1983 |
|
1984 for(TInt i=0; i<100; i++) |
|
1985 { |
|
1986 //random rect to blit |
|
1987 rect.iTl.iX = Random(TestScreenSize.iWidth); |
|
1988 rect.iTl.iY = Random(TestScreenSize.iHeight); |
|
1989 rect.iBr.iX = rect.iTl.iX+1+Random(TestScreenSize.iWidth); |
|
1990 rect.iBr.iY = rect.iTl.iY+1+Random(TestScreenSize.iHeight); |
|
1991 |
|
1992 //random point destination |
|
1993 dest.iX = Random(TestScreenSize.iWidth); |
|
1994 dest.iY = Random(TestScreenSize.iHeight); |
|
1995 |
|
1996 iBitmap1.iGc->BitBltMasked(dest,iBitmap7.iBitmap,rect,iBitmap6.iBitmap,ETrue); |
|
1997 iScreenGc->BitBltMasked(dest,iBitmap7.iBitmap,rect,iBitmap6.iBitmap,ETrue); |
|
1998 iBitmap2.iGc->BitBlt(TPoint(0,0),*iScreenGc,screenRect); |
|
1999 TEST(iBitmap1.Compare(&iBitmap2)); |
|
2000 |
|
2001 rect.Intersection(screenRect); |
|
2002 if(rect.IsEmpty()) |
|
2003 continue; |
|
2004 |
|
2005 if((rect.iBr.iX>rect.iTl.iX) && (rect.iBr.iY>rect.iTl.iY)) |
|
2006 { |
|
2007 TGopBitBltMasked gopBitBltMasked(dest,bitmap7Spec,rect,bitmap6Spec); |
|
2008 gopDes.Append((TUint8*)&gopBitBltMasked,sizeof(gopBitBltMasked)); |
|
2009 TInt error = iGraphicsAccelerator1->Operation(gopBitBltMasked); |
|
2010 if(error == KErrNotSupported) |
|
2011 { |
|
2012 delete gopBuffer; |
|
2013 WARN_PRINTF1(_L(" Not Supported.")); |
|
2014 return; |
|
2015 } |
|
2016 } |
|
2017 iBitmap3.iGc->DrawRect(iBitmap3.iBitmap->SizeInPixels()); |
|
2018 TEST(iBitmap2.Compare(&iBitmap3)); |
|
2019 } |
|
2020 iGraphicsAccelerator2->Operation(gopDes); |
|
2021 iBitmap4.iGc->DrawRect(iBitmap4.iBitmap->SizeInPixels()); |
|
2022 TEST(iBitmap3.Compare(&iBitmap4)); |
|
2023 delete gopBuffer; |
|
2024 } |
|
2025 |
|
2026 void CTAccelerator::TestScreenBitBltAlphaBitmap() |
|
2027 { |
|
2028 TInt gopBufferSize = KNumTestBitBltAlphaBitmap*sizeof(TGopBitBltAlphaBitmap); |
|
2029 TUint8* gopBuffer = new TUint8[gopBufferSize]; |
|
2030 TPtr8 gopDes = TPtr8(gopBuffer,0,gopBufferSize); |
|
2031 |
|
2032 TRect screenRect(0,0,TestScreenSize.iWidth,TestScreenSize.iHeight); |
|
2033 |
|
2034 TRect rect; |
|
2035 iFixedRegionPtr = &iFixedRegion; |
|
2036 |
|
2037 iBitmap1.iGc->SetClippingRegion(iFixedRegionPtr); |
|
2038 iScreenGc->SetClippingRegion(iFixedRegionPtr); |
|
2039 |
|
2040 TRgb white; |
|
2041 iBitmap3.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
2042 iBitmap3.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
2043 iBitmap3.iGc->SetBrushColor(white); |
|
2044 iBitmap3.iGc->SetClippingRegion(iSubRegionPtr); |
|
2045 |
|
2046 iBitmap4.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
2047 iBitmap4.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
2048 iBitmap4.iGc->SetBrushColor(white); |
|
2049 iBitmap4.iGc->SetClippingRegion(iSubRegionPtr); |
|
2050 |
|
2051 TRgb color = TRgb(Random(256),Random(256),Random(256)); |
|
2052 |
|
2053 //Source bitmap |
|
2054 iBitmap7.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
2055 iBitmap7.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
2056 iBitmap7.iGc->SetBrushColor(color); |
|
2057 iBitmap7.iGc->DrawRect(iBitmap7.iBitmap->SizeInPixels()); |
|
2058 iBitmap7.iGc->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2059 |
|
2060 |
|
2061 iAlphaBitmap.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
2062 iAlphaBitmap.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
2063 |
|
2064 |
|
2065 //create 10 gray level for the alpha bitmap |
|
2066 for(TInt i=0; i<10;i++) |
|
2067 { |
|
2068 TRect tmpRect(0,10*i,200,10+10*i); |
|
2069 TInt index = 255-(20*i); |
|
2070 TRgb tmpRgb; |
|
2071 iAlphaBitmap.iGc->SetBrushColor(tmpRgb.Gray256(index)); |
|
2072 iAlphaBitmap.iGc->DrawRect(tmpRect); |
|
2073 } |
|
2074 |
|
2075 TAcceleratedBitmapSpec bitmap7Spec(iBitmap7.iBitmap); |
|
2076 TAcceleratedBitmapSpec alphaBitmapSpec(iAlphaBitmap.iBitmap); |
|
2077 |
|
2078 iAlphaBitmap.iGc->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2079 |
|
2080 for(TInt n=0; n<100; n++) |
|
2081 { |
|
2082 rect.iTl.iX = Random(TestBitmapSize.iWidth); |
|
2083 rect.iTl.iY = Random(TestBitmapSize.iHeight); |
|
2084 rect.iBr.iX = rect.iTl.iX+1+Random(TestBitmapSize.iWidth); |
|
2085 rect.iBr.iY = rect.iTl.iY+1+Random(TestBitmapSize.iHeight); |
|
2086 |
|
2087 //Random destination point |
|
2088 TPoint pointDest(Random(TestScreenSize.iWidth),Random(TestScreenSize.iHeight)); |
|
2089 |
|
2090 //alpha blitting with Graphics Contex |
|
2091 iBitmap1.iGc->BitBltMasked(pointDest,iBitmap7.iBitmap,rect,iAlphaBitmap.iBitmap,ETrue); |
|
2092 iScreenGc->BitBltMasked(pointDest,iBitmap7.iBitmap,rect,iAlphaBitmap.iBitmap,ETrue); |
|
2093 iBitmap2.iGc->BitBlt(TPoint(0,0),*iScreenGc,screenRect); |
|
2094 |
|
2095 TEST(iBitmap1.Compare(&iBitmap2)); |
|
2096 |
|
2097 rect.Intersection(screenRect); |
|
2098 //alpha blitting with Graphics accelerator |
|
2099 TGopBitBltAlphaBitmap gopBitBltAlphaBitmap(pointDest,bitmap7Spec,rect,alphaBitmapSpec); |
|
2100 gopDes.Append((TUint8*)&gopBitBltAlphaBitmap,sizeof(gopBitBltAlphaBitmap)); |
|
2101 TInt error = iGraphicsAccelerator1->Operation(gopBitBltAlphaBitmap); |
|
2102 if(error == KErrNotSupported) |
|
2103 { |
|
2104 WARN_PRINTF1(_L(" Not Supported.")); |
|
2105 goto done; |
|
2106 } |
|
2107 iBitmap3.iGc->DrawRect(iBitmap3.iBitmap->SizeInPixels()); |
|
2108 TEST(iBitmap2.Compare(&iBitmap3)); |
|
2109 } |
|
2110 iGraphicsAccelerator2->Operation(gopDes); |
|
2111 iBitmap4.iGc->DrawRect(iBitmap4.iBitmap->SizeInPixels()); |
|
2112 TEST(iBitmap3.Compare(&iBitmap4)); |
|
2113 done: |
|
2114 delete gopBuffer; |
|
2115 } |
|
2116 |
|
2117 void CTAccelerator::TestScreenAlphaBlendTwoBitmaps() |
|
2118 { |
|
2119 TRect screenRect(0,0,TestBitmapSize.iWidth,TestBitmapSize.iHeight); |
|
2120 |
|
2121 TRect rect; |
|
2122 iFixedRegionPtr = &iFixedRegion; |
|
2123 |
|
2124 iBitmap1.iGc->SetClippingRegion(iFixedRegionPtr); |
|
2125 iBitmap2.iGc->SetClippingRegion(iFixedRegionPtr); |
|
2126 |
|
2127 TRgb color = TRgb(Random(256),Random(256),Random(256)); |
|
2128 |
|
2129 // First Source bitmap |
|
2130 iBitmap7.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
2131 iBitmap7.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
2132 iBitmap7.iGc->SetBrushColor(color); |
|
2133 iBitmap7.iGc->DrawRect(screenRect); |
|
2134 iBitmap7.iGc->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2135 |
|
2136 // Get a new random color |
|
2137 color = TRgb(Random(256),Random(256),Random(256)); |
|
2138 |
|
2139 // Second Source bitmap |
|
2140 iBitmap8.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
2141 iBitmap8.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
2142 iBitmap8.iGc->SetBrushColor(color); |
|
2143 iBitmap8.iGc->DrawRect(screenRect); |
|
2144 iBitmap8.iGc->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2145 |
|
2146 iAlphaBitmap.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
2147 iAlphaBitmap.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
2148 |
|
2149 //create 10 gray level for the alpha bitmap |
|
2150 for(TInt i=0; i<10;i++) |
|
2151 { |
|
2152 TRect tmpRect(0,10*i,200,10+10*i); |
|
2153 TInt index = 255-(20*i); |
|
2154 TRgb tmpRgb; |
|
2155 iAlphaBitmap.iGc->SetBrushColor(tmpRgb.Gray256(index)); |
|
2156 iAlphaBitmap.iGc->DrawRect(tmpRect); |
|
2157 } |
|
2158 |
|
2159 TAcceleratedBitmapSpec bitmap7Spec(iBitmap7.iBitmap); |
|
2160 TAcceleratedBitmapSpec bitmap8Spec(iBitmap8.iBitmap); |
|
2161 TAcceleratedBitmapSpec alphaBitmapSpec(iAlphaBitmap.iBitmap); |
|
2162 |
|
2163 iAlphaBitmap.iGc->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2164 |
|
2165 for(TInt n=0; n<100; n++) |
|
2166 { |
|
2167 rect.iTl.iX = Random(TestBitmapSize.iWidth - 1); |
|
2168 rect.iTl.iY = Random(TestBitmapSize.iHeight - 1); |
|
2169 rect.iBr.iX = rect.iTl.iX+1+Random(TestBitmapSize.iWidth - rect.iTl.iX); |
|
2170 rect.iBr.iY = rect.iTl.iY+1+Random(TestBitmapSize.iHeight - rect.iTl.iY); |
|
2171 |
|
2172 TPoint pointDest(Random(TestBitmapSize.iWidth),Random(TestBitmapSize.iHeight)); |
|
2173 TPoint pointSource(Random(TestBitmapSize.iWidth),Random(TestBitmapSize.iHeight)); |
|
2174 TPoint pointAlpha(Random(TestBitmapSize.iWidth - rect.Width()),Random(TestBitmapSize.iHeight - rect.Height())); |
|
2175 |
|
2176 //alpha blending Graphics Context - wrong argument cause skip to next test |
|
2177 TInt error = iBitmap1.iGc->AlphaBlendBitmaps(pointDest,iBitmap7.iBitmap,iBitmap8.iBitmap,rect,pointSource,iAlphaBitmap.iBitmap,pointAlpha); |
|
2178 // AlphaBlendBitmaps can return KErrArgument based on the input data - in that case, continue |
|
2179 if(error!=KErrNone) |
|
2180 { |
|
2181 continue; |
|
2182 } |
|
2183 iScreenGc->AlphaBlendBitmaps(pointDest,iBitmap7.iBitmap,iBitmap8.iBitmap,rect,pointSource,iAlphaBitmap.iBitmap,pointAlpha); |
|
2184 iBitmap2.iGc->BitBlt(TPoint(0,0),*iScreenGc,screenRect); |
|
2185 TEST(iBitmap1.Compare(&iBitmap2)); |
|
2186 } |
|
2187 } |
|
2188 |
|
2189 void CTAccelerator::TestScreenAlphaBlendOneBitmap() |
|
2190 { |
|
2191 TRect screenRect(0,0,TestBitmapSize.iWidth,TestBitmapSize.iHeight); |
|
2192 |
|
2193 TRect rect; |
|
2194 iFixedRegionPtr = &iFixedRegion; |
|
2195 |
|
2196 iBitmap1.iGc->SetClippingRegion(iFixedRegionPtr); |
|
2197 iBitmap2.iGc->SetClippingRegion(iFixedRegionPtr); |
|
2198 |
|
2199 TRgb color = TRgb(Random(256),Random(256),Random(256)); |
|
2200 |
|
2201 // First Source bitmap |
|
2202 iBitmap7.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
2203 iBitmap7.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
2204 iBitmap7.iGc->SetBrushColor(color); |
|
2205 iBitmap7.iGc->DrawRect(screenRect); |
|
2206 iBitmap7.iGc->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2207 |
|
2208 // Get a new random color |
|
2209 color = TRgb(Random(256),Random(256),Random(256)); |
|
2210 |
|
2211 iAlphaBitmap.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
2212 iAlphaBitmap.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
2213 |
|
2214 //create 10 gray level for the alpha bitmap |
|
2215 for(TInt i=0; i<10;i++) |
|
2216 { |
|
2217 TRect tmpRect(0,10*i,200,10+10*i); |
|
2218 TInt index = 255-(20*i); |
|
2219 TRgb tmpRgb; |
|
2220 iAlphaBitmap.iGc->SetBrushColor(tmpRgb.Gray256(index)); |
|
2221 iAlphaBitmap.iGc->DrawRect(tmpRect); |
|
2222 } |
|
2223 |
|
2224 TAcceleratedBitmapSpec bitmap7Spec(iBitmap7.iBitmap); |
|
2225 TAcceleratedBitmapSpec alphaBitmapSpec(iAlphaBitmap.iBitmap); |
|
2226 |
|
2227 iAlphaBitmap.iGc->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2228 |
|
2229 for(TInt n=0; n<100; n++) |
|
2230 { |
|
2231 if(n==0) continue; |
|
2232 rect.iTl.iX = Random(TestBitmapSize.iWidth - 1); |
|
2233 rect.iTl.iY = Random(TestBitmapSize.iHeight - 1); |
|
2234 rect.iBr.iX = rect.iTl.iX+1+Random(TestBitmapSize.iWidth - rect.iTl.iX); |
|
2235 rect.iBr.iY = rect.iTl.iY+1+Random(TestBitmapSize.iHeight - rect.iTl.iY); |
|
2236 |
|
2237 TPoint pointDest(Random(TestBitmapSize.iWidth),Random(TestBitmapSize.iHeight)); |
|
2238 TPoint pointAlpha(Random(TestBitmapSize.iWidth - rect.Width() - 1),Random(TestBitmapSize.iHeight - rect.Height() - 1)); |
|
2239 |
|
2240 //alpha blending Graphics Context - wrong argument cause skip to next test |
|
2241 TInt rc = iBitmap1.iGc->AlphaBlendBitmaps(pointDest,iBitmap7.iBitmap,rect,iAlphaBitmap.iBitmap,pointAlpha); |
|
2242 if(rc!=KErrNone) |
|
2243 { |
|
2244 continue; |
|
2245 } |
|
2246 iScreenGc->AlphaBlendBitmaps(pointDest,iBitmap7.iBitmap,rect,iAlphaBitmap.iBitmap,pointAlpha); |
|
2247 iBitmap2.iGc->BitBlt(TPoint(0,0),*iScreenGc,screenRect); |
|
2248 TEST(iBitmap1.Compare(&iBitmap2)); |
|
2249 } |
|
2250 } |
|
2251 |
|
2252 void CTAccelerator::resetColorBitmaps() |
|
2253 { |
|
2254 TRgb color; |
|
2255 iFixedRegionPtr = &iDefaultRegion; |
|
2256 |
|
2257 if(iHwScreenDevice) |
|
2258 { |
|
2259 iFixedRegionPtr = &iDefaultScreenRegion; |
|
2260 iScreenGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
2261 iScreenGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
2262 iScreenGc->SetDrawMode(CGraphicsContext::EDrawModePEN); |
|
2263 iScreenGc->SetClippingRegion(iFixedRegionPtr); |
|
2264 iScreenGc->SetBrushColor(color); |
|
2265 iScreenGc->DrawRect(TestScreenSize); |
|
2266 iScreenGc->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2267 } |
|
2268 |
|
2269 iBitmap1.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
2270 iBitmap1.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
2271 iBitmap1.iGc->SetDrawMode(CGraphicsContext::EDrawModePEN); |
|
2272 iBitmap1.iGc->SetClippingRegion(iFixedRegionPtr); |
|
2273 iBitmap1.iGc->SetBrushColor(color); |
|
2274 TRect rect1(iBitmap1.iBitmap->SizeInPixels()); |
|
2275 iBitmap1.iGc->DrawRect(rect1); |
|
2276 iBitmap1.iGc->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2277 |
|
2278 iBitmap2.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
2279 iBitmap2.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
2280 iBitmap2.iGc->SetDrawMode(CGraphicsContext::EDrawModePEN); |
|
2281 iBitmap2.iGc->SetClippingRegion(iFixedRegionPtr); |
|
2282 iBitmap2.iGc->SetBrushColor(color); |
|
2283 TRect rect2(iBitmap2.iBitmap->SizeInPixels()); |
|
2284 iBitmap2.iGc->DrawRect(rect2); |
|
2285 iBitmap2.iGc->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2286 |
|
2287 //GA1 |
|
2288 iBitmap3.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
2289 iBitmap3.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
2290 iBitmap3.iGc->SetDrawMode(CGraphicsContext::EDrawModePEN); |
|
2291 iBitmap3.iGc->SetClippingRegion(iFixedRegionPtr); |
|
2292 iBitmap3.iGc->SetBrushColor(color); |
|
2293 TRect rect3(iBitmap3.iBitmap->SizeInPixels()); |
|
2294 iBitmap3.iGc->DrawRect(rect3); |
|
2295 iBitmap3.iGc->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2296 |
|
2297 //GA2 |
|
2298 iBitmap4.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
2299 iBitmap4.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
2300 iBitmap4.iGc->SetDrawMode(CGraphicsContext::EDrawModePEN); |
|
2301 iBitmap4.iGc->SetClippingRegion(iFixedRegionPtr); |
|
2302 iBitmap4.iGc->SetBrushColor(color); |
|
2303 TRect rect4(iBitmap4.iBitmap->SizeInPixels()); |
|
2304 iBitmap4.iGc->DrawRect(rect4); |
|
2305 iBitmap4.iGc->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2306 |
|
2307 iBitmap5.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
2308 iBitmap5.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
2309 iBitmap5.iGc->SetDrawMode(CGraphicsContext::EDrawModePEN); |
|
2310 iBitmap5.iGc->SetBrushColor(color); |
|
2311 TRect rect5(iBitmap5.iBitmap->SizeInPixels()); |
|
2312 iBitmap5.iGc->DrawRect(rect5); |
|
2313 iBitmap5.iGc->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2314 |
|
2315 iBitmap6.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
2316 iBitmap6.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
2317 iBitmap6.iGc->SetDrawMode(CGraphicsContext::EDrawModePEN); |
|
2318 iBitmap6.iGc->SetBrushColor(color); |
|
2319 TRect rect6(iBitmap6.iBitmap->SizeInPixels()); |
|
2320 iBitmap6.iGc->DrawRect(rect6); |
|
2321 iBitmap6.iGc->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2322 |
|
2323 iBitmap7.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
2324 iBitmap7.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
2325 iBitmap7.iGc->SetDrawMode(CGraphicsContext::EDrawModePEN); |
|
2326 iBitmap7.iGc->SetBrushColor(color); |
|
2327 TRect rect7(iBitmap7.iBitmap->SizeInPixels()); |
|
2328 iBitmap7.iGc->DrawRect(rect7); |
|
2329 iBitmap7.iGc->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2330 |
|
2331 iBitmap8.iGc->SetPenStyle(CGraphicsContext::ENullPen); |
|
2332 iBitmap8.iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
2333 iBitmap8.iGc->SetDrawMode(CGraphicsContext::EDrawModePEN); |
|
2334 iBitmap8.iGc->SetBrushColor(color); |
|
2335 TRect rect8(iBitmap8.iBitmap->SizeInPixels()); |
|
2336 iBitmap8.iGc->DrawRect(rect8); |
|
2337 iBitmap8.iGc->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2338 } |
|
2339 |
|
2340 void CTAccelerator::TestScreenRotation() |
|
2341 { |
|
2342 // Checks that clearing a rotated screen doesn't blow-up |
|
2343 iScreenGc->SetOrientation(CFbsBitGc::EGraphicsOrientationRotated90); |
|
2344 |
|
2345 iScreenGc->Reset(); |
|
2346 // fill screen using graphics accelerator |
|
2347 iScreenGc->SetBrushStyle(CFbsBitGc::ESolidBrush); |
|
2348 iScreenGc->SetPenStyle(CFbsBitGc::ENullPen); |
|
2349 iScreenGc->DrawRect(TRect(0,0,KMaxTInt/2,KMaxTInt/2)); |
|
2350 |
|
2351 // restore orientation |
|
2352 iScreenGc->SetOrientation(CFbsBitGc::EGraphicsOrientationNormal); |
|
2353 iScreenGc->Reset(); |
|
2354 } |
|
2355 |
|
2356 void CTAccelerator::TestUserDisplayMode() |
|
2357 { |
|
2358 iScreenGc->Reset(); |
|
2359 // Change to Gray4 mode |
|
2360 iScreenGc->SetUserDisplayMode(EGray4); |
|
2361 // fill screen using graphics accelerator |
|
2362 iScreenGc->SetBrushStyle(CFbsBitGc::ESolidBrush); |
|
2363 iScreenGc->SetBrushColor(TRgb(0x44,0x44,0x44)); // should get 'rounded up' to 0x55,0x55,0x55 when drawn |
|
2364 iScreenGc->SetPenStyle(CFbsBitGc::ENullPen); |
|
2365 iScreenGc->DrawRect(TRect(0,0,KMaxTInt/2,KMaxTInt/2)); |
|
2366 |
|
2367 TRgb pixel; |
|
2368 iHwScreenDevice->GetPixel(pixel,TPoint(0,0)); |
|
2369 TRgb checkValue(0x555555,0xff); |
|
2370 if (iHwScreenDevice->DisplayMode()==EColor64K) |
|
2371 checkValue=TRgb::Color64K(checkValue.Color64K()); |
|
2372 TEST(pixel==checkValue); // check pixel color is that of a Gray4 one |
|
2373 |
|
2374 // Restore user display mode |
|
2375 iScreenGc->Reset(); |
|
2376 } |
|
2377 |
|
2378 static void CheckDisplayMode() |
|
2379 { |
|
2380 TInt i; |
|
2381 for(i=0; i<KNumDisplayModes; ++i) |
|
2382 { |
|
2383 TDisplayMode mode = TestDisplayModes[i].iMode; |
|
2384 CFbsScreenDevice* device = NULL; |
|
2385 TInt err = KErrNone; |
|
2386 TRAP(err, device = CFbsScreenDevice::NewL(_L("scdv"), mode)); |
|
2387 if (err == KErrNone) |
|
2388 { |
|
2389 TestDisplayModes[i].iEnabled = ETrue; |
|
2390 delete device; |
|
2391 } |
|
2392 } |
|
2393 } |
|
2394 |
|
2395 //-------------- |
|
2396 __CONSTRUCT_STEP__(Accelerator) |
|
2397 |
|
2398 void CTAcceleratorStep::TestSetupL() |
|
2399 { |
|
2400 FbsStartup(); |
|
2401 User::LeaveIfError(RFbsSession::Connect()); |
|
2402 |
|
2403 CheckDisplayMode(); |
|
2404 } |
|
2405 |
|
2406 void CTAcceleratorStep::TestClose() |
|
2407 { |
|
2408 RFbsSession::Disconnect(); |
|
2409 } |
|
2410 |
|
2411 |
|
2412 |
|
2413 |
|
2414 |