|
1 // Copyright (c) 1997-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 // Test wrapper to bitgdi component of graphics. |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @test |
|
21 @internalComponent - Internal Symbian test code |
|
22 */ |
|
23 #include <tgdi.mbg> |
|
24 |
|
25 #include "TGDI.H" |
|
26 #include "TBMP.H" |
|
27 #include <bitdev.h> |
|
28 |
|
29 #define MAXCOLORS 255 |
|
30 |
|
31 _LIT(KT23BitmapFileName,"z:\\system\\data\\tgdi.mbm"); |
|
32 |
|
33 // TestGdi methods |
|
34 |
|
35 EXPORT_C TestGdi::TestGdi(): |
|
36 iDev(NULL), |
|
37 iCon(NULL), |
|
38 iSize(0,0), |
|
39 iSection(NULL) |
|
40 {} |
|
41 |
|
42 // This function is modified. contents are moved to below function |
|
43 EXPORT_C void TestGdi::Construct(CBitmapDevice* aDevice,CFbsBitGc* aContext,TDes& aFailureSection) |
|
44 { |
|
45 TRAP_IGNORE(ConstructL(aDevice, aContext, aFailureSection)); |
|
46 } |
|
47 |
|
48 // This is additional function with suffix L |
|
49 EXPORT_C void TestGdi::ConstructL(CBitmapDevice* aDevice,CFbsBitGc* aContext,TDes& aFailureSection) |
|
50 { |
|
51 __ASSERT_ALWAYS(aFailureSection.MaxLength() == KFailureSectionNameBufferLength,User::Panic(_L("TGDI"),KErrBadDescriptor)); |
|
52 |
|
53 iDev = aDevice; |
|
54 iCon = aContext; |
|
55 iSize = iDev->SizeInPixels(); |
|
56 iSection = &aFailureSection; |
|
57 |
|
58 iCon->SetPenSize(TSize(1,1)); |
|
59 iCon->SetDrawMode(CGraphicsContext::EDrawModePEN); |
|
60 iCon->SetPenColor(KRgbBlack); |
|
61 iCon->SetPenStyle(CGraphicsContext::ESolidPen); |
|
62 iCon->SetBrushColor(KRgbBlack); |
|
63 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
64 |
|
65 iRect.iTl.iX=iSize.iWidth/3; |
|
66 iRect.iTl.iY=iSize.iHeight/3; |
|
67 iRect.iBr.iX=iSize.iWidth*2/3; |
|
68 iRect.iBr.iY=iSize.iHeight*2/3; |
|
69 iBitmapWidth=50; |
|
70 iBitmapHeight=87; |
|
71 iZeroRect.SetRect(iRect.iTl,iRect.iTl); |
|
72 iUnitRect.SetRect(iRect.iTl,iRect.iTl+TPoint(1,1)); |
|
73 iUnNormRect.iTl=iRect.iBr; |
|
74 iUnNormRect.iBr=iRect.iTl; |
|
75 iLargeRect.SetRect(-iSize.iWidth,-iSize.iHeight,iSize.iWidth*2,iSize.iHeight*2); |
|
76 iCentredRect.iTl=TPoint(0,0)-iRect.iTl; |
|
77 iCentredRect.iBr=iRect.iTl; |
|
78 for(TInt count=0;count<8;count++) |
|
79 iOffScreenRects[count]=iRect; |
|
80 iOffScreenRects[0].Move(-iSize.iWidth,-iSize.iHeight); |
|
81 iOffScreenRects[1].Move(0,-iSize.iHeight); |
|
82 iOffScreenRects[2].Move(iSize.iWidth,-iSize.iHeight); |
|
83 iOffScreenRects[3].Move(iSize.iWidth,0); |
|
84 iOffScreenRects[4].Move(iSize.iWidth,iSize.iHeight); |
|
85 iOffScreenRects[5].Move(0,iSize.iHeight); |
|
86 iOffScreenRects[6].Move(-iSize.iWidth,iSize.iHeight); |
|
87 iOffScreenRects[7].Move(-iSize.iWidth,0); |
|
88 |
|
89 TInt ret = iBitmap.Load(_L("z:\\system\\data\\tbmp.mbm"),EMbmTbmpTgdigen,EFalse); |
|
90 User::LeaveIfError(ret); |
|
91 |
|
92 ret = iBitmap2.Load(_L("z:\\system\\data\\tbmp.mbm"),EMbmTbmpTblank,EFalse); |
|
93 User::LeaveIfError(ret); |
|
94 } |
|
95 |
|
96 EXPORT_C TBool TestGdi::Test() |
|
97 { |
|
98 // Get FBSERV to create its long lived objects to avoid trigering memory leaks. |
|
99 CFbsBitmap* srcBmp = new CFbsBitmap; |
|
100 if (srcBmp==NULL || srcBmp->Create(iSize,EColor16MU)!=KErrNone) |
|
101 { |
|
102 return EFalse; |
|
103 } |
|
104 delete srcBmp; |
|
105 |
|
106 CFbsBitmap* t23SrcBmp = new (ELeave) CFbsBitmap(); |
|
107 TInt ret = t23SrcBmp->Load(KT23BitmapFileName,EMbmTgdiDef064071_sourcebitmap); |
|
108 delete t23SrcBmp; |
|
109 if(ret != KErrNone) |
|
110 { |
|
111 return EFalse; |
|
112 } |
|
113 |
|
114 TRAPD(err,DoTestL()); |
|
115 if (err != KErrNone) |
|
116 iSection->AppendFormat(_L(", error %d"), err); |
|
117 |
|
118 iBitmap.Reset(); |
|
119 iBitmap2.Reset(); |
|
120 |
|
121 return err == KErrNone; |
|
122 } |
|
123 |
|
124 void TestGdi::DoTestL() |
|
125 { |
|
126 *iSection = _L("Testing graphics functions"); |
|
127 CheckL(iSize!=TSize(0,0)); |
|
128 Clear(); |
|
129 TRgb col; |
|
130 iDev->GetPixel(col,TPoint(iSize.iWidth/2,iSize.iHeight/2)); |
|
131 CheckL(col==KRgbWhite); |
|
132 iCon->Plot(iRect.iTl); |
|
133 CheckPlotL(iRect.iTl); |
|
134 Clear(); |
|
135 CheckClearL(); |
|
136 /** |
|
137 @SYMTestCaseID GRAPHICS-TestGdi-0001 |
|
138 */ |
|
139 SetTestStepID(_L("GRAPHICS-TestGdi-0001")); |
|
140 DoArcL(); |
|
141 RecordTestResultL(); |
|
142 /** |
|
143 @SYMTestCaseID GRAPHICS-TestGdi-0002 |
|
144 */ |
|
145 SetTestStepID(_L("GRAPHICS-TestGdi-0002")); |
|
146 DoEllipseL(); |
|
147 RecordTestResultL(); |
|
148 /** |
|
149 @SYMTestCaseID GRAPHICS-TestGdi-0003 |
|
150 */ |
|
151 SetTestStepID(_L("GRAPHICS-TestGdi-0003")); |
|
152 DoRoundRectL(); |
|
153 RecordTestResultL(); |
|
154 /** |
|
155 @SYMTestCaseID GRAPHICS-TestGdi-0004 |
|
156 */ |
|
157 SetTestStepID(_L("GRAPHICS-TestGdi-0004")); |
|
158 DoPieL(); |
|
159 RecordTestResultL(); |
|
160 /** |
|
161 @SYMTestCaseID GRAPHICS-TestGdi-0005 |
|
162 */ |
|
163 SetTestStepID(_L("GRAPHICS-TestGdi-0005")); |
|
164 DoModeL(); |
|
165 RecordTestResultL(); |
|
166 /** |
|
167 @SYMTestCaseID GRAPHICS-TestGdi-0006 |
|
168 */ |
|
169 SetTestStepID(_L("GRAPHICS-TestGdi-0006")); |
|
170 DoColorL(); |
|
171 RecordTestResultL(); |
|
172 /** |
|
173 @SYMTestCaseID GRAPHICS-TestGdi-0007 |
|
174 */ |
|
175 SetTestStepID(_L("GRAPHICS-TestGdi-0007")); |
|
176 DoLineL(); |
|
177 RecordTestResultL(); |
|
178 /** |
|
179 @SYMTestCaseID GRAPHICS-TestGdi-0008 |
|
180 */ |
|
181 SetTestStepID(_L("GRAPHICS-TestGdi-0008")); |
|
182 DoWideLineL(); |
|
183 RecordTestResultL(); |
|
184 /** |
|
185 @SYMTestCaseID GRAPHICS-TestGdi-0009 |
|
186 */ |
|
187 SetTestStepID(_L("GRAPHICS-TestGdi-0009")); |
|
188 DoRectL(); |
|
189 RecordTestResultL(); |
|
190 /** |
|
191 @SYMTestCaseID GRAPHICS-TestGdi-0010 |
|
192 */ |
|
193 SetTestStepID(_L("GRAPHICS-TestGdi-0010")); |
|
194 DoPolygonArrayL(); |
|
195 RecordTestResultL(); |
|
196 /** |
|
197 @SYMTestCaseID GRAPHICS-TestGdi-0011 |
|
198 */ |
|
199 SetTestStepID(_L("GRAPHICS-TestGdi-0011")); |
|
200 DoPolygonPtrL(); |
|
201 RecordTestResultL(); |
|
202 /** |
|
203 @SYMTestCaseID GRAPHICS-TestGdi-0012 |
|
204 */ |
|
205 SetTestStepID(_L("GRAPHICS-TestGdi-0012")); |
|
206 DoPolygonPtr0(); |
|
207 RecordTestResultL(); |
|
208 /** |
|
209 @SYMTestCaseID GRAPHICS-TestGdi-0013 |
|
210 */ |
|
211 SetTestStepID(_L("GRAPHICS-TestGdi-0013")); |
|
212 DoText(); |
|
213 RecordTestResultL(); |
|
214 /** |
|
215 @SYMTestCaseID GRAPHICS-TestGdi-0014 |
|
216 */ |
|
217 SetTestStepID(_L("GRAPHICS-TestGdi-0014")); |
|
218 DoPaintL(); |
|
219 RecordTestResultL(); |
|
220 /** |
|
221 @SYMTestCaseID GRAPHICS-TestGdi-0015 |
|
222 */ |
|
223 SetTestStepID(_L("GRAPHICS-TestGdi-0015")); |
|
224 DoCopyL(); |
|
225 RecordTestResultL(); |
|
226 /** |
|
227 @SYMTestCaseID GRAPHICS-TestGdi-0016 |
|
228 */ |
|
229 SetTestStepID(_L("GRAPHICS-TestGdi-0016")); |
|
230 DoBltL(); |
|
231 RecordTestResultL(); |
|
232 /** |
|
233 @SYMTestCaseID GRAPHICS-TestGdi-0017 |
|
234 */ |
|
235 SetTestStepID(_L("GRAPHICS-TestGdi-0017")); |
|
236 DoBltMaskedL(); |
|
237 RecordTestResultL(); |
|
238 /** |
|
239 @SYMTestCaseID GRAPHICS-TestGdi-0018 |
|
240 */ |
|
241 SetTestStepID(_L("GRAPHICS-TestGdi-0018")); |
|
242 DoShadowL(); |
|
243 RecordTestResultL(); |
|
244 /** |
|
245 @SYMTestCaseID GRAPHICS-TestGdi-0019 |
|
246 */ |
|
247 SetTestStepID(_L("GRAPHICS-TestGdi-0019")); |
|
248 DoFadeL(); |
|
249 RecordTestResultL(); |
|
250 /** |
|
251 @SYMTestCaseID GRAPHICS-TestGdi-0020 |
|
252 */ |
|
253 SetTestStepID(_L("GRAPHICS-TestGdi-0020")); |
|
254 DoDrawBitmapSemiTransparentMaskedL(); |
|
255 RecordTestResultL(); |
|
256 // If DoDrawBitmapMaskedL causes a User Panic 21, it might be a positive failure of case #24. |
|
257 SetTestStepID(_L("GRAPHICS-TestGdi-DoDrawBitmapMaskedL-0001")); |
|
258 DoDrawBitmapMaskedL(ETrue); |
|
259 RecordTestResultL(); |
|
260 SetTestStepID(_L("GRAPHICS-TestGdi-DoDrawBitmapMaskedL-0001")); |
|
261 DoDrawBitmapMaskedL(EFalse); |
|
262 RecordTestResultL(); |
|
263 //test bitmap width 52 (wordalignable) |
|
264 iBitmapWidth=52; |
|
265 /** |
|
266 @SYMTestCaseID GRAPHICS-TestGdi-0021 |
|
267 */ |
|
268 SetTestStepID(_L("GRAPHICS-TestGdi-0021")); |
|
269 DoBltL(); |
|
270 RecordTestResultL(); |
|
271 /** |
|
272 @SYMTestCaseID GRAPHICS-TestGdi-0022 |
|
273 */ |
|
274 SetTestStepID(_L("GRAPHICS-TestGdi-0022")); |
|
275 DoBltMaskedL(); |
|
276 RecordTestResultL(); |
|
277 SetTestStepID(_L("GRAPHICS-TestGdi-DoDrawBitmapMaskedL-0001")); |
|
278 DoDrawBitmapMaskedL(ETrue); |
|
279 RecordTestResultL(); |
|
280 SetTestStepID(_L("GRAPHICS-TestGdi-DoDrawBitmapMaskedL-0001")); |
|
281 DoDrawBitmapMaskedL(EFalse); |
|
282 RecordTestResultL(); |
|
283 //test with compressed bitmaps |
|
284 /** |
|
285 @SYMTestCaseID GRAPHICS-TestGdi-0023 |
|
286 */ |
|
287 SetTestStepID(_L("GRAPHICS-TestGdi-0023")); |
|
288 DoBltCompressedL(); |
|
289 RecordTestResultL(); |
|
290 /** |
|
291 @SYMTestCaseID GRAPHICS-TestGdi-0024 |
|
292 */ |
|
293 SetTestStepID(_L("GRAPHICS-TestGdi-0024")); |
|
294 DoBoxTextVertical(); |
|
295 RecordTestResultL(); |
|
296 } |
|
297 |
|
298 void TestGdi::CheckL(TBool aValue) |
|
299 { |
|
300 if (!aValue) |
|
301 User::Leave(KErrGeneral); |
|
302 } |
|
303 |
|
304 void TestGdi::Clear() |
|
305 { |
|
306 iCon->SetDrawMode(CGraphicsContext::EDrawModePEN); |
|
307 iCon->SetPenStyle(CGraphicsContext::ENullPen); |
|
308 iCon->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
309 iCon->SetBrushColor(KRgbWhite); |
|
310 iCon->DrawRect(TRect(TPoint(0,0),iSize)); |
|
311 iCon->SetPenStyle(CGraphicsContext::ESolidPen); |
|
312 iCon->SetPenColor(KRgbBlack); |
|
313 iCon->SetBrushColor(KRgbBlack); |
|
314 } |
|
315 |
|
316 LOCAL_C void FreeAlloc(TAny* aPtr) |
|
317 { |
|
318 TRgb* scanline = reinterpret_cast <TRgb*> (aPtr); |
|
319 User::Free(scanline); |
|
320 } |
|
321 |
|
322 void TestGdi::ScanAreaL(TInt x,TInt y,TInt length,TInt height,TRgb Color) |
|
323 { |
|
324 if(x>iSize.iWidth) |
|
325 return; |
|
326 if(x<0) |
|
327 { |
|
328 length=length+x; |
|
329 x=0; |
|
330 } |
|
331 if(x+length>iSize.iWidth) |
|
332 length=iSize.iWidth-x; |
|
333 if(length<=0) |
|
334 return; |
|
335 TRgb* scanline=(TRgb*)User::Alloc(sizeof(TRgb)*length); |
|
336 CleanupStack::PushL(TCleanupItem(FreeAlloc, scanline)); |
|
337 TPtr8 scln((TUint8*)scanline,length*sizeof(TRgb)); |
|
338 for(TInt row=0;row<height;row++) |
|
339 { |
|
340 if(y+row>=0 && y+row<iSize.iHeight) |
|
341 { |
|
342 iDev->GetScanLine(scln,TPoint(x,y+row),length,ERgb); |
|
343 for(TInt index=0;index<length;index++) |
|
344 { |
|
345 CheckL(scanline[index] == Color); |
|
346 } |
|
347 |
|
348 } |
|
349 } |
|
350 for(TInt i=0;i<height;i++) |
|
351 { |
|
352 scanline[i].~TRgb(); |
|
353 } |
|
354 CleanupStack::PopAndDestroy(scanline); |
|
355 } |
|
356 |
|
357 void TestGdi::CheckClearL() |
|
358 { |
|
359 TInt quarht=iSize.iHeight>>2; |
|
360 TInt halfht=iSize.iHeight>>1; |
|
361 TInt thrqht=quarht+halfht; |
|
362 ScanAreaL(0,0,iSize.iWidth,1,KRgbWhite); |
|
363 ScanAreaL(0,quarht,iSize.iWidth,quarht+1,KRgbWhite); |
|
364 ScanAreaL(0,halfht,iSize.iWidth,halfht+1,KRgbWhite); |
|
365 ScanAreaL(0,thrqht,iSize.iWidth,thrqht+1,KRgbWhite); |
|
366 ScanAreaL(0,iSize.iHeight-1,iSize.iWidth,iSize.iHeight,KRgbWhite); |
|
367 ScanAreaL(iRect.iTl.iX,iRect.iTl.iY,1,1,KRgbWhite); |
|
368 } |
|
369 |
|
370 void TestGdi::CheckPlotL(const TPoint& pt) |
|
371 { |
|
372 ScanAreaL(pt.iX,pt.iY,1,1,KRgbBlack); |
|
373 ScanAreaL(pt.iX-1,pt.iY-1,3,1,KRgbWhite); |
|
374 ScanAreaL(pt.iX-1,pt.iY+1,3,1,KRgbWhite); |
|
375 ScanAreaL(pt.iX-1,pt.iY,1,1,KRgbWhite); |
|
376 ScanAreaL(pt.iX+1,pt.iY,1,1,KRgbWhite); |
|
377 Clear(); |
|
378 } |
|
379 |
|
380 void TestGdi::CheckRectInsideL(const TRect& rect) |
|
381 { |
|
382 ScanAreaL(rect.iTl.iX,rect.iTl.iY,rect.iBr.iX-rect.iTl.iX,1,KRgbBlack); |
|
383 ScanAreaL(rect.iTl.iX,rect.iBr.iY-1,rect.iBr.iX-rect.iTl.iX,1,KRgbBlack); |
|
384 } |
|
385 |
|
386 void TestGdi::CheckRectOutsideL(const TRect& rect) |
|
387 { |
|
388 ScanAreaL(rect.iTl.iX-1,rect.iTl.iY-1,rect.iBr.iX-rect.iTl.iX,1,KRgbWhite); |
|
389 ScanAreaL(rect.iTl.iX-1,rect.iBr.iY,rect.iBr.iX-rect.iTl.iX+1,1,KRgbWhite); |
|
390 } |
|
391 |
|
392 void TestGdi::CheckQuadOutsideL(const TRect& rect) |
|
393 { |
|
394 ScanAreaL(rect.iTl.iX-1,rect.iTl.iY-6,rect.iBr.iX-rect.iTl.iX+1,1,KRgbWhite); |
|
395 ScanAreaL(rect.iTl.iX-1,rect.iBr.iY-5,rect.iBr.iX-rect.iTl.iX+1,1,KRgbWhite); |
|
396 } |
|
397 |
|
398 void TestGdi::CheckQuadInsideL(const TRect& rect) |
|
399 { |
|
400 if(rect.iBr.iX-rect.iTl.iX-11>0) |
|
401 ScanAreaL(rect.iTl.iX+5,(rect.iTl.iY+rect.iBr.iY)/2,rect.iBr.iX-rect.iTl.iX-11,1,KRgbBlack); |
|
402 } |
|
403 |
|
404 void TestGdi::DoModeL() |
|
405 { |
|
406 if(iDev->DisplayMode()==EGray2) return; |
|
407 *iSection = _L("Drawing mode"); |
|
408 Clear(); |
|
409 iCon->Plot(iRect.iTl); |
|
410 CheckPlotL(iRect.iTl); |
|
411 |
|
412 iCon->SetDrawMode(CGraphicsContext::EDrawModeNOTPEN); |
|
413 iCon->SetPenColor(KRgbWhite); |
|
414 iCon->Plot(iRect.iTl); |
|
415 CheckPlotL(iRect.iTl); |
|
416 |
|
417 iCon->SetPenColor(KRgbDarkGray); |
|
418 iCon->Plot(iRect.iTl); |
|
419 iCon->SetDrawMode(CGraphicsContext::EDrawModeAND); |
|
420 iCon->SetPenColor(KRgbGray); |
|
421 iCon->Plot(iRect.iTl); |
|
422 CheckPlotL(iRect.iTl); |
|
423 |
|
424 iCon->SetPenColor(KRgbGray); |
|
425 iCon->Plot(iRect.iTl); |
|
426 iCon->SetDrawMode(CGraphicsContext::EDrawModeANDNOT); |
|
427 iCon->SetPenColor(KRgbGray); |
|
428 iCon->Plot(iRect.iTl); |
|
429 CheckPlotL(iRect.iTl); |
|
430 |
|
431 iCon->Plot(iRect.iTl); |
|
432 iCon->SetDrawMode(CGraphicsContext::EDrawModeOR); |
|
433 iCon->Plot(iRect.iTl); |
|
434 CheckPlotL(iRect.iTl); |
|
435 |
|
436 iCon->Plot(iRect.iTl); |
|
437 iCon->SetDrawMode(CGraphicsContext::EDrawModeORNOT); |
|
438 iCon->SetPenColor(KRgbWhite); |
|
439 iCon->Plot(iRect.iTl); |
|
440 CheckPlotL(iRect.iTl); |
|
441 |
|
442 iCon->SetPenColor(KRgbGray); |
|
443 iCon->Plot(iRect.iTl); |
|
444 iCon->SetDrawMode(CGraphicsContext::EDrawModeXOR); |
|
445 iCon->SetPenColor(KRgbGray); |
|
446 iCon->Plot(iRect.iTl); |
|
447 CheckPlotL(iRect.iTl); |
|
448 |
|
449 iCon->SetPenColor(KRgbDarkGray); |
|
450 iCon->Plot(iRect.iTl); |
|
451 iCon->SetDrawMode(CGraphicsContext::EDrawModeNOTXOR); |
|
452 iCon->SetPenColor(KRgbGray); |
|
453 iCon->Plot(iRect.iTl); |
|
454 CheckPlotL(iRect.iTl); |
|
455 |
|
456 iCon->SetDrawMode(CGraphicsContext::EDrawModeNOTSCREEN); |
|
457 iCon->Plot(iRect.iTl); |
|
458 CheckPlotL(iRect.iTl); |
|
459 |
|
460 iCon->SetDrawMode(CGraphicsContext::EDrawModeNOTAND); |
|
461 iCon->SetPenColor(KRgbWhite); |
|
462 iCon->Plot(iRect.iTl); |
|
463 CheckPlotL(iRect.iTl); |
|
464 |
|
465 iCon->Plot(iRect.iTl); |
|
466 iCon->SetDrawMode(CGraphicsContext::EDrawModeNOTANDNOT); |
|
467 iCon->SetPenColor(KRgbWhite); |
|
468 iCon->Plot(iRect.iTl); |
|
469 CheckPlotL(iRect.iTl); |
|
470 |
|
471 iCon->SetDrawMode(CGraphicsContext::EDrawModeNOTOR); |
|
472 iCon->SetPenColor(KRgbBlack); |
|
473 iCon->Plot(iRect.iTl); |
|
474 CheckPlotL(iRect.iTl); |
|
475 |
|
476 iCon->SetDrawMode(CGraphicsContext::EDrawModeNOTORNOT); |
|
477 iCon->SetPenColor(KRgbWhite); |
|
478 iCon->Plot(iRect.iTl); |
|
479 CheckPlotL(iRect.iTl); |
|
480 } |
|
481 |
|
482 void TestGdi::DoColorL() |
|
483 { |
|
484 *iSection = _L("Colors"); |
|
485 Clear(); |
|
486 for(TInt count=0;count<256;count++) |
|
487 { |
|
488 iCon->SetPenColor(TRgb::Gray256(count)); |
|
489 iCon->Plot(iRect.iTl); |
|
490 TRgb screencolor; |
|
491 iDev->GetPixel(screencolor,iRect.iTl); |
|
492 switch(iDev->DisplayMode()) |
|
493 { |
|
494 case EGray2: |
|
495 CheckL(screencolor.Gray2()==count>>7); |
|
496 break; |
|
497 case EGray4: |
|
498 CheckL(Abs(screencolor.Gray4()-(count>>6))<2); |
|
499 break; |
|
500 case EGray16: |
|
501 if(screencolor.Gray16()!=(count>>4)) |
|
502 CheckL(Abs(screencolor.Gray4()-(count>>6))<2); |
|
503 break; |
|
504 case EGray256: |
|
505 CheckL(screencolor.Gray256()==count); |
|
506 break; |
|
507 default: |
|
508 break; |
|
509 } |
|
510 iCon->SetPenColor(KRgbWhite); |
|
511 iCon->Plot(iRect.iTl); |
|
512 iDev->GetPixel(screencolor,iRect.iTl); |
|
513 CheckL(screencolor==KRgbWhite); |
|
514 } |
|
515 } |
|
516 |
|
517 void TestGdi::DoLineL() |
|
518 { |
|
519 *iSection = _L("Line drawing"); |
|
520 Clear(); |
|
521 iCon->DrawLine(iRect.iTl,iRect.iTl); |
|
522 iCon->DrawLine(iRect.iTl,iRect.iTl+TPoint(1,1)); |
|
523 CheckPlotL(iRect.iTl); |
|
524 Clear(); |
|
525 iCon->DrawLine(iRect.iTl,TPoint(iRect.iBr.iX,iRect.iTl.iY)); |
|
526 CheckRectInsideL(TRect(iRect.iTl,TPoint(iRect.iBr.iX,iRect.iTl.iY+1))); |
|
527 CheckRectOutsideL(TRect(iRect.iTl,TPoint(iRect.iBr.iX,iRect.iTl.iY+1))); |
|
528 Clear(); |
|
529 iCon->DrawLine(TPoint(-iRect.iTl.iX,iRect.iTl.iY),TPoint(iRect.iBr.iX*2,iRect.iTl.iY)); |
|
530 CheckRectInsideL(TRect(-iRect.iTl.iX,iRect.iTl.iY,iRect.iBr.iX*2,iRect.iTl.iY+1)); |
|
531 CheckRectOutsideL(TRect(-iRect.iTl.iX,iRect.iTl.iY,iRect.iBr.iX*2,iRect.iTl.iY+1)); |
|
532 Clear(); |
|
533 TInt y=iRect.iTl.iY; |
|
534 for(;y<iRect.iBr.iY;y++) |
|
535 iCon->DrawLine(TPoint(iRect.iTl.iX,y),TPoint(iRect.iBr.iX,y)); |
|
536 CheckRectInsideL(iRect); |
|
537 CheckRectOutsideL(iRect); |
|
538 Clear(); |
|
539 for(TInt count=0;count<8;count++) |
|
540 for(y=iOffScreenRects[count].iBr.iY;y<iOffScreenRects[count].iTl.iY;y++) |
|
541 iCon->DrawLine(TPoint(iOffScreenRects[count].iTl.iX,y),TPoint(iOffScreenRects[count].iBr.iX,y)); |
|
542 CheckClearL(); |
|
543 iCon->SetPenSize(TSize(100,100)); |
|
544 iCon->DrawLine(TPoint(iRect.iTl.iX,iRect.iTl.iY),TPoint(iRect.iBr.iX,iRect.iTl.iY)); |
|
545 CheckRectInsideL(TRect(iRect.iTl.iX+50,iRect.iTl.iY-49,iRect.iBr.iX-50,iRect.iTl.iY+50)); |
|
546 CheckRectOutsideL(TRect(iRect.iTl.iX,iRect.iTl.iY-49,iRect.iBr.iX,iRect.iTl.iY+51)); |
|
547 Clear(); |
|
548 iCon->DrawLine(TPoint(-iRect.iTl.iX,iRect.iTl.iY),TPoint(iRect.iBr.iX*2,iRect.iTl.iY)); |
|
549 CheckRectInsideL(TRect(-iRect.iTl.iX,iRect.iTl.iY-49,iRect.iBr.iX*2,iRect.iTl.iY+50)); |
|
550 CheckRectOutsideL(TRect(-iRect.iTl.iX,iRect.iTl.iY-49,iRect.iBr.iX*2,iRect.iTl.iY+51)); |
|
551 Clear(); |
|
552 iCon->SetPenSize(TSize(1,1)); |
|
553 } |
|
554 |
|
555 void TestGdi::DoWideLineL() |
|
556 { |
|
557 *iSection = _L("Wide Line drawing"); |
|
558 |
|
559 Clear(); |
|
560 iCon->SetPenStyle(CFbsBitGc::ESolidPen); |
|
561 iCon->SetPenColor(KRgbBlack); |
|
562 iCon->SetPenSize(TSize(4,4)); |
|
563 TPoint pos(-24,10); |
|
564 TSize size(288,216); |
|
565 |
|
566 // Black arrow, pointing up. |
|
567 TPoint midLeft(pos.iX, size.iHeight / 2 + pos.iY); |
|
568 TPoint midTop(pos.iX + size.iWidth / 2, pos.iY); |
|
569 TPoint midRight(size.iWidth, size.iHeight / 2 + pos.iY); |
|
570 TPoint midBottom(pos.iX + size.iWidth / 2, size.iHeight); |
|
571 iCon->DrawLine(midLeft, midTop); |
|
572 iCon->DrawLine(midTop, midRight); |
|
573 iCon->DrawLine(midTop, midBottom); |
|
574 |
|
575 // Check halfway along left side of arrowhead |
|
576 TPoint checkPt(midLeft); |
|
577 checkPt += midTop; |
|
578 checkPt.iX /= 2; |
|
579 checkPt.iY /= 2; |
|
580 TRgb pixel; |
|
581 iDev->GetPixel(pixel, checkPt); |
|
582 if (pixel.Internal() != KRgbBlack.Internal()) |
|
583 { |
|
584 User::Panic(_L("Line not found!"), 1); |
|
585 } |
|
586 |
|
587 Clear(); |
|
588 iCon->SetPenSize(TSize(1,1)); |
|
589 } |
|
590 |
|
591 void TestGdi::DoArcL() |
|
592 { |
|
593 *iSection = _L("Arcs"); |
|
594 Clear(); |
|
595 iCon->DrawArc(iRect,iRect.iTl,iRect.iTl); |
|
596 CheckRectOutsideL(iRect); |
|
597 Clear(); |
|
598 iCon->DrawArc(iLargeRect,iRect.iTl,iRect.iTl); |
|
599 iCon->DrawArc(iUnNormRect,iRect.iTl,iRect.iTl); |
|
600 CheckClearL(); |
|
601 iCon->DrawArc(iCentredRect,iCentredRect.iTl,iCentredRect.iTl); |
|
602 Clear(); |
|
603 TInt count=0; |
|
604 for(;count<8;count++) |
|
605 iCon->DrawArc(iOffScreenRects[count],iOffScreenRects[count].iTl,iOffScreenRects[count].iTl); |
|
606 CheckClearL(); |
|
607 #include "TGDIGEN.H" |
|
608 for(count=0;count<numellipses;count++) |
|
609 iCon->DrawArc(ellrect[count],ellrect[count].iTl,ellrect[count].iTl); |
|
610 TSize size=iBitmap.SizeInPixels(); |
|
611 if(size.iWidth>iSize.iWidth) |
|
612 size.iWidth=iSize.iWidth; |
|
613 if(size.iHeight>iSize.iHeight) |
|
614 size.iHeight=iSize.iHeight; |
|
615 for(TInt yy=0;yy<size.iHeight>>1;yy++) |
|
616 { |
|
617 for(TInt xx=0;xx<size.iWidth>>1;xx++) |
|
618 { |
|
619 TPoint pt(xx,yy); |
|
620 TRgb bmprgb,scrrgb; |
|
621 iBitmap.GetPixel(bmprgb,pt); |
|
622 iDev->GetPixel(scrrgb,pt); |
|
623 if(bmprgb==KRgbBlack) |
|
624 CheckL(scrrgb==KRgbBlack); |
|
625 } |
|
626 } |
|
627 } |
|
628 |
|
629 void TestGdi::DoRectL() |
|
630 { |
|
631 *iSection = _L("Rectangles"); |
|
632 Clear(); |
|
633 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
634 iCon->DrawRect(iRect); |
|
635 CheckRectOutsideL(iRect); |
|
636 Clear(); |
|
637 iCon->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
638 iCon->DrawRect(iRect); |
|
639 CheckRectInsideL(iRect); |
|
640 CheckRectOutsideL(iRect); |
|
641 CheckQuadInsideL(iRect); |
|
642 Clear(); |
|
643 iCon->SetPenStyle(CGraphicsContext::ENullPen); |
|
644 iCon->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
645 iCon->DrawRect(iRect); |
|
646 CheckRectInsideL(iRect); |
|
647 CheckRectOutsideL(iRect); |
|
648 CheckQuadInsideL(iRect); |
|
649 Clear(); |
|
650 iCon->DrawRect(iUnitRect); |
|
651 CheckPlotL(iUnitRect.iTl); |
|
652 Clear(); |
|
653 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
654 iCon->DrawRect(iUnitRect); |
|
655 CheckPlotL(iUnitRect.iTl); |
|
656 Clear(); |
|
657 iCon->SetPenStyle(CGraphicsContext::ENullPen); |
|
658 iCon->DrawRect(iUnitRect); |
|
659 CheckPlotL(iUnitRect.iTl); |
|
660 Clear(); |
|
661 iCon->DrawRect(iCentredRect); |
|
662 CheckRectInsideL(iCentredRect); |
|
663 CheckRectOutsideL(iCentredRect); |
|
664 Clear(); |
|
665 iCon->DrawRect(iZeroRect); |
|
666 iCon->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
667 iCon->DrawRect(iZeroRect); |
|
668 iCon->DrawRect(iUnNormRect); |
|
669 for(TInt count=0;count<8;count++) |
|
670 iCon->DrawRect(iOffScreenRects[count]); |
|
671 CheckClearL(); |
|
672 iCon->DrawRect(TRect(iRect.iTl.iX/2,iRect.iTl.iY,iRect.iTl.iX,iRect.iBr.iY)); |
|
673 iCon->CopyRect(TPoint(iSize.iWidth/2,iSize.iHeight/6),TRect(iRect.iTl.iX/2,iRect.iTl.iY,iRect.iTl.iX,iRect.iBr.iY)); |
|
674 CheckRectInsideL(TRect(iRect.iTl.iX/2+iSize.iWidth/2,iRect.iTl.iY+iSize.iHeight/6,iRect.iTl.iX+iSize.iWidth/2,iRect.iBr.iY+iSize.iHeight/6)); |
|
675 CheckRectOutsideL(TRect(iRect.iTl.iX/2+iSize.iWidth/2,iRect.iTl.iY+iSize.iHeight/6,iRect.iTl.iX+iSize.iWidth/2,iRect.iBr.iY+iSize.iHeight/6)); |
|
676 Clear(); |
|
677 } |
|
678 |
|
679 void TestGdi::DoEllipseL() |
|
680 { |
|
681 *iSection = _L("Ellipses"); |
|
682 Clear(); |
|
683 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
684 iCon->DrawEllipse(iRect); |
|
685 CheckRectOutsideL(iRect); |
|
686 Clear(); |
|
687 iCon->DrawEllipse(iRect); |
|
688 CheckRectOutsideL(iRect); |
|
689 CheckQuadInsideL(iRect); |
|
690 Clear(); |
|
691 iCon->SetPenStyle(CGraphicsContext::ENullPen); |
|
692 iCon->DrawEllipse(iRect); |
|
693 CheckRectOutsideL(iRect); |
|
694 CheckQuadInsideL(iRect); |
|
695 Clear(); |
|
696 iCon->DrawEllipse(iLargeRect); |
|
697 CheckQuadInsideL(iRect); |
|
698 Clear(); |
|
699 iCon->DrawEllipse(iCentredRect); |
|
700 CheckQuadInsideL(iCentredRect); |
|
701 CheckRectOutsideL(iCentredRect); |
|
702 Clear(); |
|
703 iCon->DrawEllipse(iUnNormRect); |
|
704 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
705 iCon->DrawEllipse(iLargeRect); |
|
706 TInt count=0; |
|
707 for(;count<8;count++) |
|
708 iCon->DrawEllipse(iOffScreenRects[count]); |
|
709 CheckClearL(); |
|
710 #include "TGDIGEN.H" |
|
711 for(count=0;count<numellipses;count++) |
|
712 iCon->DrawEllipse(ellrect[count]); |
|
713 TSize size=iBitmap.SizeInPixels(); |
|
714 if(size.iWidth>iSize.iWidth) |
|
715 size.iWidth=iSize.iWidth; |
|
716 if(size.iHeight>iSize.iHeight) |
|
717 size.iHeight=iSize.iHeight; |
|
718 for(TInt yy=0;yy<size.iHeight>>1;yy++) |
|
719 { |
|
720 for(TInt xx=0;xx<size.iWidth>>1;xx++) |
|
721 { |
|
722 TPoint pt(xx,yy); |
|
723 TRgb bmprgb,scrrgb; |
|
724 iBitmap.GetPixel(bmprgb,pt); |
|
725 iDev->GetPixel(scrrgb,pt); |
|
726 if(bmprgb==KRgbBlack) |
|
727 CheckL(scrrgb==KRgbBlack); |
|
728 } |
|
729 } |
|
730 } |
|
731 |
|
732 void TestGdi::DoPieL() |
|
733 { |
|
734 *iSection = _L("Pie segments"); |
|
735 Clear(); |
|
736 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
737 iCon->DrawPie(iRect,iRect.iTl,iRect.iTl); |
|
738 CheckRectOutsideL(iRect); |
|
739 Clear(); |
|
740 iCon->DrawPie(iRect,iRect.iTl,iRect.iTl); |
|
741 CheckRectOutsideL(iRect); |
|
742 CheckQuadInsideL(iRect); |
|
743 Clear(); |
|
744 iCon->SetPenStyle(CGraphicsContext::ENullPen); |
|
745 iCon->DrawPie(iRect,iRect.iTl,iRect.iTl); |
|
746 CheckRectOutsideL(iRect); |
|
747 CheckQuadInsideL(iRect); |
|
748 Clear(); |
|
749 iCon->DrawPie(iLargeRect,iRect.iTl,iRect.iTl); |
|
750 CheckQuadInsideL(iRect); |
|
751 Clear(); |
|
752 iCon->DrawPie(iCentredRect,iCentredRect.iTl,iCentredRect.iTl); |
|
753 CheckQuadInsideL(iCentredRect); |
|
754 CheckRectOutsideL(iCentredRect); |
|
755 Clear(); |
|
756 iCon->DrawPie(iUnNormRect,iRect.iTl,iRect.iTl); |
|
757 TInt count=0; |
|
758 for(;count<8;count++) |
|
759 iCon->DrawPie(iOffScreenRects[count],iOffScreenRects[count].iTl,iOffScreenRects[count].iTl); |
|
760 CheckClearL(); |
|
761 #include "TGDIGEN.H" |
|
762 for(count=0;count<numellipses;count++) |
|
763 iCon->DrawPie(ellrect[count],ellrect[count].iTl,ellrect[count].iTl); |
|
764 TSize size=iBitmap.SizeInPixels(); |
|
765 if(size.iWidth>iSize.iWidth) |
|
766 size.iWidth=iSize.iWidth; |
|
767 if(size.iHeight>iSize.iHeight) |
|
768 size.iHeight=iSize.iHeight; |
|
769 for(TInt yy=0;yy<size.iHeight>>1;yy++) |
|
770 { |
|
771 for(TInt xx=0;xx<size.iWidth>>1;xx++) |
|
772 { |
|
773 TPoint pt(xx,yy); |
|
774 TRgb bmprgb,scrrgb; |
|
775 iBitmap.GetPixel(bmprgb,pt); |
|
776 iDev->GetPixel(scrrgb,pt); |
|
777 if(bmprgb==KRgbBlack) |
|
778 CheckL(scrrgb==KRgbBlack); |
|
779 } |
|
780 } |
|
781 } |
|
782 |
|
783 void TestGdi::DoRoundRectL() |
|
784 { |
|
785 *iSection = _L("RoundRects"); |
|
786 TSize rrsize(20,10); |
|
787 Clear(); |
|
788 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
789 iCon->DrawRoundRect(iRect,rrsize); |
|
790 CheckRectOutsideL(iRect); |
|
791 Clear(); |
|
792 iCon->DrawRoundRect(iRect,rrsize); |
|
793 CheckRectOutsideL(iRect); |
|
794 CheckQuadInsideL(iRect); |
|
795 Clear(); |
|
796 iCon->SetPenStyle(CGraphicsContext::ENullPen); |
|
797 iCon->DrawRoundRect(iRect,rrsize); |
|
798 CheckRectOutsideL(iRect); |
|
799 CheckQuadInsideL(iRect); |
|
800 Clear(); |
|
801 iCon->DrawRoundRect(iLargeRect,rrsize); |
|
802 CheckQuadInsideL(iRect); |
|
803 Clear(); |
|
804 iCon->DrawRoundRect(iCentredRect,rrsize); |
|
805 CheckQuadInsideL(iCentredRect); |
|
806 CheckRectOutsideL(iCentredRect); |
|
807 Clear(); |
|
808 iCon->DrawRoundRect(iUnNormRect,rrsize); |
|
809 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
810 iCon->DrawRoundRect(iLargeRect,rrsize); |
|
811 TInt count=0; |
|
812 for(;count<8;count++) |
|
813 iCon->DrawRoundRect(iOffScreenRects[count],rrsize); |
|
814 CheckClearL(); |
|
815 #include "TGDIGEN.H" |
|
816 for(count=0;count<numellipses;count++) |
|
817 iCon->DrawRoundRect(ellrect[count],TSize((ellrect[count].iBr.iX-ellrect[count].iTl.iX)>>1,(ellrect[count].iBr.iY-ellrect[count].iTl.iY)>>1)); |
|
818 TSize size=iBitmap.SizeInPixels(); |
|
819 if(size.iWidth>iSize.iWidth) |
|
820 size.iWidth=iSize.iWidth; |
|
821 if(size.iHeight>iSize.iHeight) |
|
822 size.iHeight=iSize.iHeight; |
|
823 for(TInt yy=0;yy<size.iHeight>>1;yy++) |
|
824 { |
|
825 for(TInt xx=0;xx<size.iWidth>>1;xx++) |
|
826 { |
|
827 TPoint pt(xx,yy); |
|
828 TRgb bmprgb,scrrgb; |
|
829 iDev->GetPixel(scrrgb,pt); |
|
830 pt.iY+=size.iHeight>>1; |
|
831 iBitmap.GetPixel(bmprgb,pt); |
|
832 if(bmprgb==KRgbBlack) |
|
833 CheckL(scrrgb==KRgbBlack); |
|
834 } |
|
835 } |
|
836 } |
|
837 |
|
838 void TestGdi::DoPolygonArrayL() |
|
839 { |
|
840 *iSection = _L("Polygon array"); |
|
841 |
|
842 CArrayFixFlat<TPoint>* poly=new CArrayFixFlat<TPoint>(4); |
|
843 poly->AppendL(iRect.iTl); |
|
844 TPoint temp(iRect.iBr.iX-1,iRect.iTl.iY); |
|
845 poly->AppendL(temp); |
|
846 temp.SetXY(iRect.iBr.iX-1,iRect.iBr.iY-1); |
|
847 poly->AppendL(temp); |
|
848 temp.SetXY(iRect.iTl.iX,iRect.iBr.iY-1); |
|
849 poly->AppendL(temp); |
|
850 Clear(); |
|
851 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
852 iCon->DrawPolygon(poly); |
|
853 CheckRectOutsideL(iRect); |
|
854 Clear(); |
|
855 iCon->DrawPolygon(poly); |
|
856 CheckRectOutsideL(iRect); |
|
857 CheckQuadInsideL(iRect); |
|
858 Clear(); |
|
859 iCon->SetPenStyle(CGraphicsContext::ENullPen); |
|
860 iCon->DrawPolygon(poly); |
|
861 delete poly; |
|
862 CheckRectOutsideL(iRect); |
|
863 CheckQuadInsideL(iRect); |
|
864 Clear(); |
|
865 |
|
866 poly=new CArrayFixFlat<TPoint>(4); |
|
867 poly->AppendL(iLargeRect.iTl); |
|
868 temp.SetXY(iLargeRect.iBr.iX-1,iLargeRect.iTl.iY); |
|
869 poly->AppendL(temp); |
|
870 temp.SetXY(iLargeRect.iBr.iX-1,iLargeRect.iBr.iY-1); |
|
871 poly->AppendL(temp); |
|
872 temp.SetXY(iLargeRect.iTl.iX,iLargeRect.iBr.iY-1); |
|
873 poly->AppendL(temp); |
|
874 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
875 iCon->DrawPolygon(poly); |
|
876 CheckClearL(); |
|
877 Clear(); |
|
878 iCon->DrawPolygon(poly); |
|
879 delete poly; |
|
880 CheckQuadInsideL(iRect); |
|
881 Clear(); |
|
882 |
|
883 poly=new CArrayFixFlat<TPoint>(4); |
|
884 temp.SetXY(iUnNormRect.iTl.iX-1,iUnNormRect.iTl.iY-1); |
|
885 poly->AppendL(temp); |
|
886 temp.SetXY(iUnNormRect.iBr.iX,iUnNormRect.iTl.iY-1); |
|
887 poly->AppendL(temp); |
|
888 poly->AppendL(iUnNormRect.iBr); |
|
889 temp.SetXY(iUnNormRect.iTl.iX-1,iUnNormRect.iBr.iY); |
|
890 poly->AppendL(temp); |
|
891 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
892 iCon->DrawPolygon(poly); |
|
893 CheckRectOutsideL(iRect); |
|
894 Clear(); |
|
895 iCon->DrawPolygon(poly); |
|
896 delete poly; |
|
897 CheckRectOutsideL(iRect); |
|
898 CheckQuadInsideL(iRect); |
|
899 Clear(); |
|
900 |
|
901 poly=new CArrayFixFlat<TPoint>(4); |
|
902 poly->AppendL(iCentredRect.iTl); |
|
903 temp.SetXY(iCentredRect.iBr.iX-1,iCentredRect.iTl.iY); |
|
904 poly->AppendL(temp); |
|
905 temp.SetXY(iCentredRect.iBr.iX-1,iCentredRect.iBr.iY-1); |
|
906 poly->AppendL(temp); |
|
907 temp.SetXY(iCentredRect.iTl.iX,iCentredRect.iBr.iY-1); |
|
908 poly->AppendL(temp); |
|
909 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
910 iCon->DrawPolygon(poly); |
|
911 CheckRectOutsideL(iCentredRect); |
|
912 Clear(); |
|
913 iCon->DrawPolygon(poly); |
|
914 delete poly; |
|
915 CheckRectOutsideL(iCentredRect); |
|
916 CheckQuadInsideL(iCentredRect); |
|
917 Clear(); |
|
918 |
|
919 for(TInt count=0;count<8;count++) |
|
920 { |
|
921 poly=new CArrayFixFlat<TPoint>(4); |
|
922 poly->AppendL(iOffScreenRects[count].iTl); |
|
923 temp.SetXY(iOffScreenRects[count].iBr.iX,iOffScreenRects[count].iTl.iY); |
|
924 poly->AppendL(temp); |
|
925 poly->AppendL(iOffScreenRects[count].iBr); |
|
926 temp.SetXY(iOffScreenRects[count].iTl.iX,iOffScreenRects[count].iBr.iY); |
|
927 poly->AppendL(temp); |
|
928 iCon->DrawPolygon(poly); |
|
929 delete poly; |
|
930 } |
|
931 |
|
932 poly=new CArrayFixFlat<TPoint>(4); |
|
933 const TInt offset = 10000; |
|
934 const TInt size = 50; |
|
935 TRect ppRect(0,0,size + 1,size + 1); |
|
936 TPoint pp(offset,offset); |
|
937 poly->AppendL(pp); |
|
938 pp.iX += size; |
|
939 poly->AppendL(pp); |
|
940 pp.iY += size; |
|
941 poly->AppendL(pp); |
|
942 pp.iX -= size; |
|
943 poly->AppendL(pp); |
|
944 Clear(); |
|
945 iCon->SetOrigin(TPoint(-offset,-offset)); |
|
946 iCon->DrawPolygon(poly); |
|
947 iCon->SetOrigin(TPoint(0,0)); |
|
948 delete poly; |
|
949 CheckRectOutsideL(ppRect); |
|
950 CheckQuadInsideL(ppRect); |
|
951 Clear(); |
|
952 |
|
953 CheckClearL(); |
|
954 } |
|
955 |
|
956 void TestGdi::DoPolygonPtr0() |
|
957 { |
|
958 *iSection = _L("Polygon ptr 0 points"); |
|
959 |
|
960 TPoint poly[4]; |
|
961 poly[0] = iRect.iTl; |
|
962 poly[1].SetXY(iRect.iBr.iX-1,iRect.iTl.iY); |
|
963 poly[2].SetXY(iRect.iBr.iX-1,iRect.iBr.iY-1); |
|
964 poly[3].SetXY(iRect.iTl.iX,iRect.iBr.iY-1); |
|
965 Clear(); |
|
966 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
967 iCon->DrawPolygon(poly,0); |
|
968 iCon->DrawPolygon(poly,0); |
|
969 iCon->SetPenStyle(CGraphicsContext::ENullPen); |
|
970 iCon->DrawPolygon(poly,0); |
|
971 |
|
972 poly[0] = iLargeRect.iTl; |
|
973 poly[1].SetXY(iLargeRect.iBr.iX-1,iLargeRect.iTl.iY); |
|
974 poly[2].SetXY(iLargeRect.iBr.iX-1,iLargeRect.iBr.iY-1); |
|
975 poly[3].SetXY(iLargeRect.iTl.iX,iLargeRect.iBr.iY-1); |
|
976 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
977 iCon->DrawPolygon(poly,0); |
|
978 iCon->DrawPolygon(poly,0); |
|
979 |
|
980 poly[0].SetXY(iUnNormRect.iTl.iX-1,iUnNormRect.iTl.iY-1); |
|
981 poly[1].SetXY(iUnNormRect.iBr.iX,iUnNormRect.iTl.iY-1); |
|
982 poly[2] = iUnNormRect.iBr; |
|
983 poly[3].SetXY(iUnNormRect.iTl.iX-1,iUnNormRect.iBr.iY); |
|
984 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
985 iCon->DrawPolygon(poly,0); |
|
986 iCon->DrawPolygon(poly,0); |
|
987 |
|
988 poly[0] = iCentredRect.iTl; |
|
989 poly[1].SetXY(iCentredRect.iBr.iX-1,iCentredRect.iTl.iY); |
|
990 poly[2].SetXY(iCentredRect.iBr.iX-1,iCentredRect.iBr.iY-1); |
|
991 poly[3].SetXY(iCentredRect.iTl.iX,iCentredRect.iBr.iY-1); |
|
992 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
993 iCon->DrawPolygon(poly,0); |
|
994 iCon->DrawPolygon(poly,0); |
|
995 |
|
996 for(TInt count=0;count<8;count++) |
|
997 { |
|
998 poly[0] = iOffScreenRects[count].iTl; |
|
999 poly[1].SetXY(iOffScreenRects[count].iBr.iX,iOffScreenRects[count].iTl.iY); |
|
1000 poly[2] = iOffScreenRects[count].iBr; |
|
1001 poly[3].SetXY(iOffScreenRects[count].iTl.iX,iOffScreenRects[count].iBr.iY); |
|
1002 iCon->DrawPolygon(poly,0); |
|
1003 } |
|
1004 |
|
1005 const TInt offset = 10000; |
|
1006 const TInt size = 50; |
|
1007 TPoint pp(offset,offset); |
|
1008 poly[0] = pp; |
|
1009 pp.iX += size; |
|
1010 poly[1] = pp; |
|
1011 pp.iY += size; |
|
1012 poly[2] = pp; |
|
1013 pp.iX -= size; |
|
1014 poly[3] = pp; |
|
1015 iCon->SetOrigin(TPoint(-offset,-offset)); |
|
1016 iCon->DrawPolygon(poly,0); |
|
1017 iCon->SetOrigin(TPoint(0,0)); |
|
1018 |
|
1019 poly[0] = iRect.iTl; |
|
1020 poly[1].SetXY(iRect.iBr.iX-1,iRect.iTl.iY); |
|
1021 poly[2].SetXY(iRect.iBr.iX-1,iRect.iBr.iY-1); |
|
1022 poly[3].SetXY(iRect.iTl.iX,iRect.iBr.iY-1); |
|
1023 iCon->DrawPolygon(NULL,4); |
|
1024 iCon->DrawPolygon(poly,0); |
|
1025 iCon->DrawPolygon(NULL,0); |
|
1026 TPoint *ptr=(TPoint *)0x1111; |
|
1027 iCon->DrawPolygon(ptr,0); |
|
1028 iCon->DrawPolygon(NULL,4,CGraphicsContext::EWinding ); |
|
1029 iCon->DrawPolygon(poly,0,CGraphicsContext::EWinding ); |
|
1030 iCon->DrawPolygon(NULL,0,CGraphicsContext::EWinding ); |
|
1031 iCon->DrawPolygon(ptr,0,CGraphicsContext::EWinding ); |
|
1032 } |
|
1033 |
|
1034 void TestGdi::DoPolygonPtrL() |
|
1035 { |
|
1036 *iSection = _L("Polygon ptr"); |
|
1037 |
|
1038 TPoint poly[4]; |
|
1039 poly[0] = iRect.iTl; |
|
1040 poly[1].SetXY(iRect.iBr.iX-1,iRect.iTl.iY); |
|
1041 poly[2].SetXY(iRect.iBr.iX-1,iRect.iBr.iY-1); |
|
1042 poly[3].SetXY(iRect.iTl.iX,iRect.iBr.iY-1); |
|
1043 Clear(); |
|
1044 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
1045 iCon->DrawPolygon(poly,4); |
|
1046 CheckRectOutsideL(iRect); |
|
1047 Clear(); |
|
1048 iCon->DrawPolygon(poly,4); |
|
1049 CheckRectOutsideL(iRect); |
|
1050 CheckQuadInsideL(iRect); |
|
1051 Clear(); |
|
1052 iCon->SetPenStyle(CGraphicsContext::ENullPen); |
|
1053 iCon->DrawPolygon(poly,4); |
|
1054 CheckRectOutsideL(iRect); |
|
1055 CheckQuadInsideL(iRect); |
|
1056 Clear(); |
|
1057 |
|
1058 poly[0] = iLargeRect.iTl; |
|
1059 poly[1].SetXY(iLargeRect.iBr.iX-1,iLargeRect.iTl.iY); |
|
1060 poly[2].SetXY(iLargeRect.iBr.iX-1,iLargeRect.iBr.iY-1); |
|
1061 poly[3].SetXY(iLargeRect.iTl.iX,iLargeRect.iBr.iY-1); |
|
1062 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
1063 iCon->DrawPolygon(poly,4); |
|
1064 CheckClearL(); |
|
1065 Clear(); |
|
1066 iCon->DrawPolygon(poly,4); |
|
1067 CheckQuadInsideL(iRect); |
|
1068 Clear(); |
|
1069 |
|
1070 poly[0].SetXY(iUnNormRect.iTl.iX-1,iUnNormRect.iTl.iY-1); |
|
1071 poly[1].SetXY(iUnNormRect.iBr.iX,iUnNormRect.iTl.iY-1); |
|
1072 poly[2] = iUnNormRect.iBr; |
|
1073 poly[3].SetXY(iUnNormRect.iTl.iX-1,iUnNormRect.iBr.iY); |
|
1074 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
1075 iCon->DrawPolygon(poly,4); |
|
1076 CheckRectOutsideL(iRect); |
|
1077 Clear(); |
|
1078 iCon->DrawPolygon(poly,4); |
|
1079 CheckRectOutsideL(iRect); |
|
1080 CheckQuadInsideL(iRect); |
|
1081 Clear(); |
|
1082 |
|
1083 poly[0] = iCentredRect.iTl; |
|
1084 poly[1].SetXY(iCentredRect.iBr.iX-1,iCentredRect.iTl.iY); |
|
1085 poly[2].SetXY(iCentredRect.iBr.iX-1,iCentredRect.iBr.iY-1); |
|
1086 poly[3].SetXY(iCentredRect.iTl.iX,iCentredRect.iBr.iY-1); |
|
1087 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
1088 iCon->DrawPolygon(poly,4); |
|
1089 CheckRectOutsideL(iCentredRect); |
|
1090 Clear(); |
|
1091 iCon->DrawPolygon(poly,4); |
|
1092 CheckRectOutsideL(iCentredRect); |
|
1093 CheckQuadInsideL(iCentredRect); |
|
1094 Clear(); |
|
1095 |
|
1096 for(TInt count=0;count<8;count++) |
|
1097 { |
|
1098 poly[0] = iOffScreenRects[count].iTl; |
|
1099 poly[1].SetXY(iOffScreenRects[count].iBr.iX,iOffScreenRects[count].iTl.iY); |
|
1100 poly[2] = iOffScreenRects[count].iBr; |
|
1101 poly[3].SetXY(iOffScreenRects[count].iTl.iX,iOffScreenRects[count].iBr.iY); |
|
1102 iCon->DrawPolygon(poly,4); |
|
1103 } |
|
1104 |
|
1105 const TInt offset = 10000; |
|
1106 const TInt size = 50; |
|
1107 TRect ppRect(0,0,size + 1,size + 1); |
|
1108 TPoint pp(offset,offset); |
|
1109 poly[0] = pp; |
|
1110 pp.iX += size; |
|
1111 poly[1] = pp; |
|
1112 pp.iY += size; |
|
1113 poly[2] = pp; |
|
1114 pp.iX -= size; |
|
1115 poly[3] = pp; |
|
1116 Clear(); |
|
1117 iCon->SetOrigin(TPoint(-offset,-offset)); |
|
1118 iCon->DrawPolygon(poly,4); |
|
1119 iCon->SetOrigin(TPoint(0,0)); |
|
1120 CheckRectOutsideL(ppRect); |
|
1121 CheckQuadInsideL(ppRect); |
|
1122 Clear(); |
|
1123 |
|
1124 poly[0] = iRect.iTl; |
|
1125 poly[1].SetXY(iRect.iBr.iX-1,iRect.iTl.iY); |
|
1126 poly[2].SetXY(iRect.iBr.iX-1,iRect.iBr.iY-1); |
|
1127 poly[3].SetXY(iRect.iTl.iX,iRect.iBr.iY-1); |
|
1128 iCon->DrawPolygon(NULL,4); |
|
1129 Clear(); |
|
1130 iCon->DrawPolygon(poly,0); |
|
1131 Clear(); |
|
1132 iCon->DrawPolygon(NULL,0); |
|
1133 Clear(); |
|
1134 TPoint *ptr=(TPoint *)0x1111; |
|
1135 iCon->DrawPolygon(ptr,0); |
|
1136 Clear(); |
|
1137 iCon->DrawPolygon(NULL,4,CGraphicsContext::EWinding ); |
|
1138 Clear(); |
|
1139 iCon->DrawPolygon(poly,0,CGraphicsContext::EWinding ); |
|
1140 Clear(); |
|
1141 iCon->DrawPolygon(NULL,0,CGraphicsContext::EWinding ); |
|
1142 Clear(); |
|
1143 iCon->DrawPolygon(ptr,0,CGraphicsContext::EWinding ); |
|
1144 Clear(); |
|
1145 |
|
1146 CheckClearL(); |
|
1147 } |
|
1148 |
|
1149 void TestGdi::DoText() |
|
1150 { |
|
1151 *iSection = _L("Text"); |
|
1152 Clear(); |
|
1153 iCon->DrawText(_L("Text printing..."),TPoint(0,iRect.iTl.iY)); |
|
1154 iCon->DrawText(_L("Text printing..."),TPoint(0,iRect.iBr.iY)); |
|
1155 Clear(); |
|
1156 iCon->DrawText(_L("Out of bounds checking"),TPoint(-50,iRect.iBr.iY>>1)); |
|
1157 iCon->DrawText(_L("Out of bounds checking"),TPoint(0,0)); |
|
1158 iCon->DrawText(_L("Out of bounds checking"),TPoint(0,iRect.iBr.iY)); |
|
1159 iCon->DrawText(_L("Out of bounds checking"),TPoint(iRect.iBr.iX,iRect.iBr.iY>>1)); |
|
1160 } |
|
1161 |
|
1162 void TestGdi::DoBoxTextVertical() |
|
1163 { |
|
1164 Clear(); |
|
1165 |
|
1166 // Creates a font large enough to notice the text on screen |
|
1167 _LIT(KMyFontName,"Swiss"); |
|
1168 CFont* myFont = NULL; |
|
1169 TFontSpec myFontSpec(KMyFontName,15); |
|
1170 User::LeaveIfError(iDev->GetNearestFontInPixels(myFont,myFontSpec)); |
|
1171 iCon->UseFont(myFont); |
|
1172 |
|
1173 TInt boxWidth = iSize.iWidth/4; |
|
1174 TInt boxHeightOffset = iSize.iHeight-5; |
|
1175 |
|
1176 TRect box1 (5, 5, boxWidth-5, boxHeightOffset); |
|
1177 TRect box2 (boxWidth+5, 5, 2*boxWidth-5, boxHeightOffset); |
|
1178 TRect box3 (2*boxWidth+5, 5, 3*boxWidth-5, boxHeightOffset); |
|
1179 TRect box4 (3*boxWidth+5, 5, iSize.iWidth-25-2*myFont->HeightInPixels(), boxHeightOffset); |
|
1180 TRect box5 (iSize.iWidth-15-2*myFont->HeightInPixels(), 5, iSize.iWidth-15-myFont->HeightInPixels(), boxHeightOffset); |
|
1181 TRect box6 (iSize.iWidth-5-myFont->HeightInPixels(), 5, iSize.iWidth-5, boxHeightOffset); |
|
1182 |
|
1183 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
1184 iCon->SetPenStyle(CGraphicsContext::ESolidPen); |
|
1185 iCon->DrawRect(box1); |
|
1186 iCon->DrawRect(box2); |
|
1187 iCon->DrawRect(box3); |
|
1188 iCon->DrawRect(box4); |
|
1189 iCon->DrawRect(box5); |
|
1190 iCon->DrawRect(box6); |
|
1191 |
|
1192 /* Text drawn when baseline = font ascent. |
|
1193 Expected result: The top of the text will be aligned with the borders of the |
|
1194 box. |
|
1195 */ |
|
1196 // Upper right corner of the box |
|
1197 iCon->SetPenColor(KRgbRed); |
|
1198 iCon->DrawTextVertical(_L("Testing"), box1, myFont->AscentInPixels() , EFalse, CGraphicsContext::ELeft); |
|
1199 // Lower right corner of the box |
|
1200 iCon->SetPenColor(KRgbBlue); |
|
1201 iCon->DrawTextVertical(_L("Testing"), box1, myFont->AscentInPixels() , EFalse, CGraphicsContext::ERight); |
|
1202 // Upper left corner of the box |
|
1203 iCon->SetPenColor(KRgbGreen); |
|
1204 iCon->DrawTextVertical(_L("Testing"), box1, myFont->AscentInPixels() , ETrue, CGraphicsContext::ERight); |
|
1205 // Lower right corner of the box |
|
1206 iCon->SetPenColor(KRgbBlack); |
|
1207 iCon->DrawTextVertical(_L("Testing"), box1, myFont->AscentInPixels() , ETrue, CGraphicsContext::ELeft); |
|
1208 |
|
1209 /* Text drawn when baseline = 0. |
|
1210 Expected result: The text will be hidden in this case as it is drawn outside |
|
1211 the borders of the box. Only the parts in the font descent will be shown. |
|
1212 */ |
|
1213 iCon->SetPenColor(KRgbRed); |
|
1214 iCon->DrawTextVertical(_L("Testing"), box2, 0, EFalse, CGraphicsContext::ELeft); |
|
1215 iCon->SetPenColor(KRgbBlue); |
|
1216 iCon->DrawTextVertical(_L("Testing"), box2, 0, EFalse, CGraphicsContext::ERight); |
|
1217 iCon->SetPenColor(KRgbGreen); |
|
1218 iCon->DrawTextVertical(_L("Testing"), box2, 0, ETrue, CGraphicsContext::ERight); |
|
1219 iCon->SetPenColor(KRgbBlack); |
|
1220 iCon->DrawTextVertical(_L("Testing"), box2, 0, ETrue, CGraphicsContext::ELeft); |
|
1221 |
|
1222 /* Text drawn when baseline = box width. |
|
1223 Expected results: Text will be drawn on the side of the opposite edge and its |
|
1224 descent part will be hidden. |
|
1225 */ |
|
1226 iCon->SetPenColor(KRgbRed); |
|
1227 iCon->DrawTextVertical(_L("Testing"), box3, box3.Width(), EFalse, CGraphicsContext::ELeft); |
|
1228 iCon->SetPenColor(KRgbBlue); |
|
1229 iCon->DrawTextVertical(_L("Testing"), box3, box3.Width(), EFalse, CGraphicsContext::ERight); |
|
1230 iCon->SetPenColor(KRgbGreen); |
|
1231 iCon->DrawTextVertical(_L("Testing"), box3, box3.Width(), ETrue, CGraphicsContext::ERight); |
|
1232 iCon->SetPenColor(KRgbBlack); |
|
1233 iCon->DrawTextVertical(_L("Testing"), box3, box3.Width(), ETrue, CGraphicsContext::ELeft); |
|
1234 |
|
1235 /* Text drawn when baseline = box width + font ascent. |
|
1236 Expected result: text will not be shown at all as it lies outside the box totally. |
|
1237 */ |
|
1238 iCon->SetPenColor(KRgbRed); |
|
1239 iCon->DrawTextVertical(_L("Testing"), box4, box4.Width() + myFont->AscentInPixels(), EFalse, CGraphicsContext::ELeft); |
|
1240 iCon->SetPenColor(KRgbBlue); |
|
1241 iCon->DrawTextVertical(_L("Testing"), box4, box4.Width() + myFont->AscentInPixels(), EFalse, CGraphicsContext::ERight); |
|
1242 iCon->SetPenColor(KRgbGreen); |
|
1243 iCon->DrawTextVertical(_L("Testing"), box4, box4.Width() + myFont->AscentInPixels(), ETrue, CGraphicsContext::ERight); |
|
1244 iCon->SetPenColor(KRgbBlack); |
|
1245 iCon->DrawTextVertical(_L("Testing"), box4, box4.Width() + myFont->AscentInPixels(), ETrue, CGraphicsContext::ELeft); |
|
1246 |
|
1247 /* Text drawn when baseline = font ascent while the width of teh box = font height |
|
1248 Expected result: text will be aligned in the center of the box |
|
1249 */ |
|
1250 iCon->SetPenColor(KRgbRed); |
|
1251 iCon->DrawTextVertical(_L("Testing"), box5, myFont->AscentInPixels(), EFalse, CGraphicsContext::ELeft); |
|
1252 iCon->SetPenColor(KRgbBlack); |
|
1253 iCon->DrawTextVertical(_L("Testing"), box5, myFont->AscentInPixels(), EFalse, CGraphicsContext::ERight); |
|
1254 iCon->SetPenColor(KRgbRed); |
|
1255 iCon->DrawTextVertical(_L("Testing"), box6, myFont->AscentInPixels(), ETrue, CGraphicsContext::ELeft); |
|
1256 iCon->SetPenColor(KRgbBlack); |
|
1257 iCon->DrawTextVertical(_L("Testing"), box6, myFont->AscentInPixels(), ETrue, CGraphicsContext::ERight); |
|
1258 |
|
1259 iCon->DiscardFont(); |
|
1260 iDev->ReleaseFont(myFont); |
|
1261 } |
|
1262 |
|
1263 void TestGdi::DoPaintL() |
|
1264 { |
|
1265 *iSection = _L("Painting"); |
|
1266 Clear(); |
|
1267 iCon->SetBrushStyle(CGraphicsContext::EPatternedBrush); |
|
1268 iCon->DrawRect(iRect); |
|
1269 CheckRectInsideL(iRect); |
|
1270 CheckRectOutsideL(iRect); |
|
1271 Clear(); |
|
1272 iCon->SetBrushStyle(CGraphicsContext::EPatternedBrush); |
|
1273 iCon->DrawRect(iCentredRect); |
|
1274 CheckRectInsideL(iCentredRect); |
|
1275 CheckRectOutsideL(iCentredRect); |
|
1276 Clear(); |
|
1277 iCon->SetBrushStyle(CGraphicsContext::EPatternedBrush); |
|
1278 for(TInt count=0;count<8;count++) |
|
1279 iCon->DrawRect(iOffScreenRects[count]); |
|
1280 CheckClearL(); |
|
1281 iCon->SetBrushStyle(CGraphicsContext::EPatternedBrush); |
|
1282 iCon->DrawEllipse(iRect); |
|
1283 CheckRectOutsideL(iRect); |
|
1284 CheckQuadInsideL(iRect); |
|
1285 Clear(); |
|
1286 iCon->SetBrushStyle(CGraphicsContext::EPatternedBrush); |
|
1287 iCon->DrawRoundRect(iRect,TSize(20,10)); |
|
1288 CheckRectOutsideL(iRect); |
|
1289 CheckQuadInsideL(iRect); |
|
1290 Clear(); |
|
1291 iCon->SetBrushStyle(CGraphicsContext::EPatternedBrush); |
|
1292 iCon->DrawRect(iLargeRect); |
|
1293 CheckRectInsideL(TRect(TPoint(0,0),iSize)); |
|
1294 CheckQuadInsideL(TRect(TPoint(0,0),iSize)); |
|
1295 Clear(); |
|
1296 iCon->SetBrushStyle(CGraphicsContext::EPatternedBrush); |
|
1297 iCon->DrawEllipse(iLargeRect); |
|
1298 CheckQuadInsideL(TRect(TPoint(0,0),iSize)); |
|
1299 Clear(); |
|
1300 iCon->SetBrushStyle(CGraphicsContext::EPatternedBrush); |
|
1301 iCon->DrawRoundRect(iLargeRect,TSize(20,10)); |
|
1302 CheckQuadInsideL(TRect(TPoint(0,0),iSize)); |
|
1303 Clear(); |
|
1304 } |
|
1305 |
|
1306 void TestGdi::DoCopyL() |
|
1307 { |
|
1308 *iSection = _L("Copying"); |
|
1309 Clear(); |
|
1310 TInt a=iSize.iWidth; |
|
1311 TInt b=iSize.iHeight; |
|
1312 TInt c=a>>1; |
|
1313 TInt d=b>>1; |
|
1314 iCon->CopyRect(TPoint(-100,-100),TRect(-100,-100,-50,-50)); |
|
1315 iCon->CopyRect(TPoint(100,100),TRect(-100,-100,-50,-50)); |
|
1316 iCon->CopyRect(TPoint(100,100),TRect(-50,-50,50,50)); |
|
1317 iCon->CopyRect(TPoint(-100,-100),TRect(-50,-50,50,50)); |
|
1318 iCon->CopyRect(TPoint(-50,-50),TRect(0,0,50,50)); |
|
1319 iCon->CopyRect(TPoint(1000,1000),TRect(0,0,50,50)); |
|
1320 Clear(); |
|
1321 |
|
1322 iCon->SetPenStyle(CGraphicsContext::ENullPen); |
|
1323 iCon->SetBrushStyle(CGraphicsContext::EPatternedBrush); |
|
1324 TRect center(c-10,d-10,c+10,d+10); |
|
1325 iCon->DrawRect(center); |
|
1326 iCon->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1327 |
|
1328 iCon->CopyRect(TPoint(0,-25),center); |
|
1329 iCon->CopyRect(TPoint(25,-25),center); |
|
1330 iCon->CopyRect(TPoint(25,0),center); |
|
1331 iCon->CopyRect(TPoint(25,25),center); |
|
1332 iCon->CopyRect(TPoint(0,25),center); |
|
1333 iCon->CopyRect(TPoint(-25,25),center); |
|
1334 iCon->CopyRect(TPoint(-25,0),center); |
|
1335 iCon->CopyRect(TPoint(-25,-25),center); |
|
1336 |
|
1337 for(TInt y=0;y<20;y++) |
|
1338 for(TInt x=0;x<20;x++) |
|
1339 { |
|
1340 TRgb pelcol; |
|
1341 iDev->GetPixel(pelcol,TPoint(c-10+x,d-10+y)); // centre |
|
1342 TRgb samplecol; |
|
1343 iDev->GetPixel(samplecol,TPoint(c-10+x,d-35+y)); // top |
|
1344 CheckL(samplecol==pelcol); |
|
1345 iDev->GetPixel(samplecol,TPoint(c+15+x,d-35+y)); // top right |
|
1346 CheckL(samplecol==pelcol); |
|
1347 iDev->GetPixel(samplecol,TPoint(c+15+x,d-10+y)); // right |
|
1348 CheckL(samplecol==pelcol); |
|
1349 iDev->GetPixel(samplecol,TPoint(c+15+x,d+15+y)); // bottom right |
|
1350 CheckL(samplecol==pelcol); |
|
1351 iDev->GetPixel(samplecol,TPoint(c-10+x,d+15+y)); // bottom |
|
1352 CheckL(samplecol==pelcol); |
|
1353 iDev->GetPixel(samplecol,TPoint(c-35+x,d+15+y)); // bottom left |
|
1354 CheckL(samplecol==pelcol); |
|
1355 iDev->GetPixel(samplecol,TPoint(c-35+x,d-10+y)); // left |
|
1356 CheckL(samplecol==pelcol); |
|
1357 iDev->GetPixel(samplecol,TPoint(c-35+x,d-35+y)); // top left |
|
1358 CheckL(samplecol==pelcol); |
|
1359 } |
|
1360 Clear(); |
|
1361 } |
|
1362 |
|
1363 void TestGdi::DoBltL() |
|
1364 { |
|
1365 *iSection = _L("BitBlt"); |
|
1366 TRect sample(0,0,8,8); |
|
1367 Clear(); |
|
1368 TInt a=iSize.iWidth; |
|
1369 TInt b=iSize.iHeight; |
|
1370 TInt c=a>>1; |
|
1371 TInt d=b>>1; |
|
1372 iCon->BitBlt(TPoint(20,20),&iBitmap2,sample); |
|
1373 iCon->BitBlt(TPoint(c-20,20),&iBitmap2,sample); |
|
1374 iCon->BitBlt(TPoint(a-20,20),&iBitmap2,sample); |
|
1375 iCon->BitBlt(TPoint(a-20,d-20),&iBitmap2,sample); |
|
1376 iCon->BitBlt(TPoint(a-20,b-20),&iBitmap2,sample); |
|
1377 iCon->BitBlt(TPoint(c-20,b-20),&iBitmap2,sample); |
|
1378 iCon->BitBlt(TPoint(20,b-20),&iBitmap2,sample); |
|
1379 iCon->BitBlt(TPoint(20,d-20),&iBitmap2,sample); |
|
1380 iCon->SetBrushOrigin(TPoint(c-20,d-20)); |
|
1381 iCon->DrawRect(TRect(c-20,d-20,c+20,d+20)); |
|
1382 for(TInt y=0;y<8;y++) |
|
1383 for(TInt x=0;x<8;x++) |
|
1384 { |
|
1385 TRgb pelcol,samplecol; |
|
1386 iDev->GetPixel(pelcol,TPoint(c-20+x,d-20+y)); |
|
1387 iDev->GetPixel(samplecol,TPoint(20+x,20+y)); |
|
1388 CheckL(samplecol==pelcol); |
|
1389 iDev->GetPixel(samplecol,TPoint(c-20+x,20+y)); |
|
1390 CheckL(samplecol==pelcol); |
|
1391 iDev->GetPixel(samplecol,TPoint(a-20+x,20+y)); |
|
1392 CheckL(samplecol==pelcol); |
|
1393 iDev->GetPixel(samplecol,TPoint(a-20+x,d-20+y)); |
|
1394 CheckL(samplecol==pelcol); |
|
1395 iDev->GetPixel(samplecol,TPoint(a-20+x,b-20+y)); |
|
1396 CheckL(samplecol==pelcol); |
|
1397 iDev->GetPixel(samplecol,TPoint(c-20+x,b-20+y)); |
|
1398 CheckL(samplecol==pelcol); |
|
1399 iDev->GetPixel(samplecol,TPoint(20+x,b-20+y)); |
|
1400 CheckL(samplecol==pelcol); |
|
1401 iDev->GetPixel(samplecol,TPoint(20+x,d-20+y)); |
|
1402 CheckL(samplecol==pelcol); |
|
1403 } |
|
1404 Clear(); |
|
1405 for(TInt count=0;count<8;count++) |
|
1406 iCon->BitBlt(iOffScreenRects[count].iTl,&iBitmap2,sample); |
|
1407 CheckClearL(); |
|
1408 } |
|
1409 |
|
1410 void TestGdi::DoBltMaskedL() |
|
1411 { |
|
1412 *iSection = _L("BitBltMasked"); |
|
1413 TSize bmpsize(iBitmap.SizeInPixels()); |
|
1414 TRect bmprect(bmpsize); |
|
1415 TInt x,y; |
|
1416 TRgb bmpcol,samplecol; |
|
1417 |
|
1418 iCon->SetPenStyle(CGraphicsContext::ENullPen); |
|
1419 iCon->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1420 iCon->SetBrushColor(KRgbBlack); |
|
1421 iCon->Clear(); |
|
1422 iCon->BitBltMasked(TPoint(0,0),&iBitmap,bmprect,&iBitmap,ETrue); |
|
1423 for(y=0;y<bmprect.iBr.iY;y++) |
|
1424 { |
|
1425 for(x=0;x<bmprect.iBr.iX;x++) |
|
1426 { |
|
1427 iBitmap.GetPixel(bmpcol,TPoint(x,y)); |
|
1428 iDev->GetPixel(samplecol,TPoint(x,y)); |
|
1429 if(bmpcol.Gray2()) |
|
1430 CheckL(samplecol.Gray2()==0); |
|
1431 else |
|
1432 CheckL(samplecol.Gray2()==bmpcol.Gray2()); |
|
1433 } |
|
1434 } |
|
1435 iCon->Clear(); |
|
1436 iCon->BitBltMasked(TPoint(0,0),&iBitmap,bmprect,&iBitmap,EFalse); |
|
1437 for(y=0;y<bmprect.iBr.iY;y++) |
|
1438 { |
|
1439 for(x=0;x<bmprect.iBr.iX;x++) |
|
1440 { |
|
1441 iBitmap.GetPixel(bmpcol,TPoint(x,y)); |
|
1442 iDev->GetPixel(samplecol,TPoint(x,y)); |
|
1443 if(bmpcol.Gray2()) |
|
1444 CheckL(samplecol.Gray2()==bmpcol.Gray2()); |
|
1445 else |
|
1446 CheckL(samplecol.Gray2()==0); |
|
1447 } |
|
1448 } |
|
1449 iCon->SetBrushColor(KRgbWhite); |
|
1450 iCon->Clear(); |
|
1451 iCon->BitBltMasked(TPoint(0,0),&iBitmap,bmprect,&iBitmap,ETrue); |
|
1452 for(y=0;y<bmprect.iBr.iY;y++) |
|
1453 { |
|
1454 for(x=0;x<bmprect.iBr.iX;x++) |
|
1455 { |
|
1456 iBitmap.GetPixel(bmpcol,TPoint(x,y)); |
|
1457 iDev->GetPixel(samplecol,TPoint(x,y)); |
|
1458 if(bmpcol.Gray2()) |
|
1459 CheckL(samplecol.Gray2()==1); |
|
1460 else |
|
1461 CheckL(samplecol.Gray2()==bmpcol.Gray2()); |
|
1462 } |
|
1463 } |
|
1464 iCon->Clear(); |
|
1465 iCon->BitBltMasked(TPoint(0,0),&iBitmap,bmprect,&iBitmap,EFalse); |
|
1466 for(y=0;y<bmprect.iBr.iY;y++) |
|
1467 { |
|
1468 for(x=0;x<bmprect.iBr.iX;x++) |
|
1469 { |
|
1470 iBitmap.GetPixel(bmpcol,TPoint(x,y)); |
|
1471 iDev->GetPixel(samplecol,TPoint(x,y)); |
|
1472 if(bmpcol.Gray2()) |
|
1473 CheckL(samplecol.Gray2()==bmpcol.Gray2()); |
|
1474 else |
|
1475 CheckL(samplecol.Gray2()==1); |
|
1476 } |
|
1477 } |
|
1478 Clear(); |
|
1479 CheckClearL(); |
|
1480 TPoint offscreenpoint(0,iSize.iHeight<<1); |
|
1481 iCon->BitBltMasked(offscreenpoint,&iBitmap,bmprect,&iBitmap,EFalse); |
|
1482 iCon->BitBltMasked(offscreenpoint,&iBitmap,bmprect,&iBitmap,ETrue); |
|
1483 offscreenpoint.iX-=(bmpsize.iWidth<<1); |
|
1484 iCon->BitBltMasked(offscreenpoint,&iBitmap,bmprect,&iBitmap,EFalse); |
|
1485 iCon->BitBltMasked(offscreenpoint,&iBitmap,bmprect,&iBitmap,ETrue); |
|
1486 offscreenpoint.iX=(iSize.iWidth<<1); |
|
1487 iCon->BitBltMasked(offscreenpoint,&iBitmap,bmprect,&iBitmap,EFalse); |
|
1488 iCon->BitBltMasked(offscreenpoint,&iBitmap,bmprect,&iBitmap,ETrue); |
|
1489 offscreenpoint.SetXY(0,-(bmpsize.iHeight<<1)); |
|
1490 iCon->BitBltMasked(offscreenpoint,&iBitmap,bmprect,&iBitmap,EFalse); |
|
1491 iCon->BitBltMasked(offscreenpoint,&iBitmap,bmprect,&iBitmap,ETrue); |
|
1492 offscreenpoint.iX-=(bmpsize.iWidth<<1); |
|
1493 iCon->BitBltMasked(offscreenpoint,&iBitmap,bmprect,&iBitmap,EFalse); |
|
1494 iCon->BitBltMasked(offscreenpoint,&iBitmap,bmprect,&iBitmap,ETrue); |
|
1495 offscreenpoint.iX=(iSize.iWidth<<1); |
|
1496 iCon->BitBltMasked(offscreenpoint,&iBitmap,bmprect,&iBitmap,EFalse); |
|
1497 iCon->BitBltMasked(offscreenpoint,&iBitmap,bmprect,&iBitmap,ETrue); |
|
1498 offscreenpoint.SetXY(0,0); |
|
1499 offscreenpoint.iX-=(bmpsize.iWidth<<1); |
|
1500 iCon->BitBltMasked(offscreenpoint,&iBitmap,bmprect,&iBitmap,EFalse); |
|
1501 iCon->BitBltMasked(offscreenpoint,&iBitmap,bmprect,&iBitmap,ETrue); |
|
1502 offscreenpoint.iX=(iSize.iWidth<<1); |
|
1503 iCon->BitBltMasked(offscreenpoint,&iBitmap,bmprect,&iBitmap,EFalse); |
|
1504 iCon->BitBltMasked(offscreenpoint,&iBitmap,bmprect,&iBitmap,ETrue); |
|
1505 CheckClearL(); |
|
1506 } |
|
1507 |
|
1508 void TestGdi::DoBltCompressedL() |
|
1509 { |
|
1510 //NOTE: max assumed screen size is 100x100 the same as EMbmTgdiDrawbitmap |
|
1511 |
|
1512 *iSection = _L("DoBltCompressedL"); |
|
1513 CFbsBitmap bitmap; |
|
1514 TInt ret = bitmap.Load(_L("z:\\system\\data\\tgdi.mbm"),EMbmTgdiDrawbitmap,EFalse); |
|
1515 CFbsBitmap compressedBitmap; |
|
1516 ret = compressedBitmap.LoadAndCompress(_L("z:\\system\\data\\tgdi.mbm"),EMbmTgdiDrawbitmap,EFalse); |
|
1517 User::LeaveIfError(ret); |
|
1518 |
|
1519 //bitblt |
|
1520 *iSection = _L("DoBltCompressedL - bitblt first part of lines"); |
|
1521 Clear(); |
|
1522 TInt startx=20; |
|
1523 TInt starty=20; |
|
1524 TInt width=iSize.iWidth; |
|
1525 TInt height=iSize.iHeight; |
|
1526 TInt repeatx=width>>1; |
|
1527 TInt repeaty=height>>1; |
|
1528 TRect sample1(startx,0,repeatx-2*startx,repeaty); |
|
1529 TRgb pelcol,samplecol; |
|
1530 iCon->BitBlt(TPoint(startx,starty),&bitmap,sample1); |
|
1531 iCon->BitBlt(TPoint(repeatx-startx,starty),&compressedBitmap,sample1); |
|
1532 for(TInt y=0;y<repeaty;y++) |
|
1533 { |
|
1534 for(TInt x=startx;x<repeatx-2*startx;x++) |
|
1535 { |
|
1536 iDev->GetPixel(pelcol,TPoint(repeatx-startx+x,starty+y)); |
|
1537 iDev->GetPixel(samplecol,TPoint(startx+x,starty+y)); |
|
1538 CheckL(samplecol==pelcol); |
|
1539 } |
|
1540 } |
|
1541 *iSection = _L("DoBltCompressedL - bitblt multiple complete lines - columns"); |
|
1542 Clear(); |
|
1543 TRect sample2(0,0,bitmap.SizeInPixels().iWidth,50); |
|
1544 iCon->BitBlt(TPoint(0,0),&bitmap,sample2); |
|
1545 iCon->BitBlt(TPoint(0,50),&compressedBitmap,sample2); |
|
1546 for(TInt y=0;y<50;y++) |
|
1547 { |
|
1548 for(TInt x=0;x<bitmap.SizeInPixels().iWidth;x++) |
|
1549 { |
|
1550 iDev->GetPixel(pelcol,TPoint(x,y)); |
|
1551 iDev->GetPixel(samplecol,TPoint(x,50+y)); |
|
1552 CheckL(samplecol==pelcol); |
|
1553 } |
|
1554 } |
|
1555 |
|
1556 *iSection = _L("DoBltCompressedL - bitblt final part of lines"); |
|
1557 Clear(); |
|
1558 TRect sample3(0,0,50,100); |
|
1559 iCon->BitBlt(TPoint(0,0),&bitmap,sample3); |
|
1560 iCon->BitBlt(TPoint(50,0),&compressedBitmap,sample3); |
|
1561 for(TInt y=0;y<100;y++) |
|
1562 { |
|
1563 for(TInt x=0;x<50;x++) |
|
1564 { |
|
1565 iDev->GetPixel(pelcol,TPoint(x,y)); |
|
1566 iDev->GetPixel(samplecol,TPoint(50+x,y)); |
|
1567 CheckL(samplecol==pelcol); |
|
1568 } |
|
1569 } |
|
1570 |
|
1571 *iSection = _L("DoBltCompressedL - bitbltmasked flickerv2"); |
|
1572 Clear(); |
|
1573 TRect sample4(0,0,50,100); |
|
1574 // Due to inconsistent handling of solid brushes between different colour modes, the |
|
1575 // screen or a bitmap, accelerated or non-accelerated do this test with a null brush. |
|
1576 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
1577 iCon->BitBltMasked(TPoint(0,0),&bitmap,sample4,&iBitmap,ETrue); |
|
1578 iCon->BitBltMasked(TPoint(50,0),&compressedBitmap,sample4,&iBitmap,ETrue); |
|
1579 for(TInt y=0;y<100;y++) |
|
1580 { |
|
1581 for(TInt x=0;x<50;x++) |
|
1582 { |
|
1583 iDev->GetPixel(pelcol,TPoint(x,y)); |
|
1584 iDev->GetPixel(samplecol,TPoint(50+x,y)); |
|
1585 CheckL(samplecol==pelcol); |
|
1586 } |
|
1587 } |
|
1588 |
|
1589 *iSection = _L("DoBltCompressedL - bitbltmasked needbitmaps of same mode"); |
|
1590 Clear(); |
|
1591 TRect sample5(0,0,50,100); |
|
1592 iCon->BitBltMasked(TPoint(0,0),&bitmap,sample5,&compressedBitmap,ETrue); |
|
1593 iCon->BitBltMasked(TPoint(50,0),&compressedBitmap,sample5,&bitmap,ETrue); |
|
1594 for(TInt y=0;y<100;y++) |
|
1595 { |
|
1596 for(TInt x=0;x<50;x++) |
|
1597 { |
|
1598 iDev->GetPixel(pelcol,TPoint(x,y)); |
|
1599 iDev->GetPixel(samplecol,TPoint(50+x,y)); |
|
1600 CheckL(samplecol==pelcol); |
|
1601 } |
|
1602 } |
|
1603 |
|
1604 *iSection = _L("DoBltCompressedL - bitbltmasked same bitmap as mask"); |
|
1605 Clear(); |
|
1606 TRect target6(0,0,50,100); |
|
1607 TRect sample6(0,0,50,100); |
|
1608 iCon->DrawBitmapMasked(target6,&bitmap,sample6,&bitmap,ETrue); |
|
1609 target6.Move(50,0); |
|
1610 iCon->DrawBitmapMasked(target6,&compressedBitmap,sample6,&compressedBitmap,ETrue); |
|
1611 for(TInt y=0;y<100;y++) |
|
1612 { |
|
1613 for(TInt x=0;x<50;x++) |
|
1614 { |
|
1615 iDev->GetPixel(pelcol,TPoint(x,y)); |
|
1616 iDev->GetPixel(samplecol,TPoint(50+x,y)); |
|
1617 CheckL(samplecol==pelcol); |
|
1618 } |
|
1619 } |
|
1620 } |
|
1621 |
|
1622 void TestGdi::DoShadowL() |
|
1623 { |
|
1624 *iSection = _L("Shadow"); |
|
1625 iCon->SetPenStyle(CGraphicsContext::ENullPen); |
|
1626 iCon->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1627 TInt halfwidth=iSize.iWidth>>1; |
|
1628 TRect lhs(TSize(halfwidth,iSize.iHeight)); |
|
1629 TRect rhs(TPoint(halfwidth,0),TSize(iSize.iWidth,iSize.iHeight)); |
|
1630 TRegionFix<1> area(lhs); |
|
1631 TPoint lhspt(halfwidth>>1,iSize.iHeight>>1); |
|
1632 TPoint rhspt(halfwidth+(halfwidth>>1),iSize.iHeight>>1); |
|
1633 TRgb lhsrgb,rhsrgb; |
|
1634 |
|
1635 for (TInt count = 0; count < 32; count++) |
|
1636 { |
|
1637 TRgb brushColor; |
|
1638 if (count < 16) |
|
1639 brushColor = TRgb::Gray16(count); |
|
1640 else |
|
1641 brushColor = TRgb::Color16(count - 16); |
|
1642 |
|
1643 iCon->DrawRect(lhs); |
|
1644 iCon->ShadowArea(&area); |
|
1645 iCon->SetShadowMode(ETrue); |
|
1646 iCon->DrawRect(rhs); |
|
1647 iDev->GetPixel(lhsrgb,lhspt); |
|
1648 iDev->GetPixel(rhsrgb,rhspt); |
|
1649 CheckL(lhsrgb==rhsrgb); |
|
1650 iCon->SetShadowMode(EFalse); |
|
1651 } |
|
1652 Clear(); |
|
1653 } |
|
1654 |
|
1655 /** |
|
1656 Auxiliary Fn to check the Pixel values |
|
1657 |
|
1658 This method checks the pixel values with respective calculated values based on the call |
|
1659 from DoDrawBitmapMaskedL |
|
1660 |
|
1661 */ |
|
1662 void TestGdi::CheckMaskedResultsL(CFbsBitmap* aBgBmp,CFbsBitmap* aSrcBmp,CFbsBitmap* aMaskBmp,TRect& aTarRect,TBool aInvertMask,TBool aAlphaBlend, TBool aSemiTransparentMask/*=EFalse*/) |
|
1663 { |
|
1664 TInt width=0; |
|
1665 TInt height=0; |
|
1666 TInt rowIndex=0; |
|
1667 TInt colIndex=0; |
|
1668 width=aTarRect.Width(); |
|
1669 height=aTarRect.Height(); |
|
1670 // Check the size of the target rectangle is negative or zero |
|
1671 if (width<0 || !width || height<0 || !height) |
|
1672 { |
|
1673 return; |
|
1674 } |
|
1675 // Check the size of the target rectangle falls out side the display screen size |
|
1676 if (width>iSize.iWidth) |
|
1677 { |
|
1678 width=iSize.iWidth; |
|
1679 } |
|
1680 if (height>iSize.iHeight) |
|
1681 { |
|
1682 height=iSize.iHeight; |
|
1683 } |
|
1684 // Rectangle used locally and it starts top left corner.(0,0) |
|
1685 TRect rect(0,0,width,height); |
|
1686 TSize size(rect.Size()); |
|
1687 TDisplayMode devDisplayMode=iDev->DisplayMode(); |
|
1688 //Create background bitmap with the size equal to target rectangle |
|
1689 CFbsBitmap* backgroundBmp = new (ELeave) CFbsBitmap; |
|
1690 CleanupStack::PushL(backgroundBmp); |
|
1691 User::LeaveIfError(backgroundBmp->Create(size,devDisplayMode)); |
|
1692 //Create src bitmap with the size equal to target rectangle |
|
1693 CFbsBitmap* srcBmp = new (ELeave) CFbsBitmap; |
|
1694 CleanupStack::PushL(srcBmp); |
|
1695 User::LeaveIfError(srcBmp->Create(size,iDev->DisplayMode())); |
|
1696 //Create mask bitmap with the size equal to target rectangle |
|
1697 CFbsBitmap* maskBmp = new (ELeave) CFbsBitmap; |
|
1698 CleanupStack::PushL(maskBmp); |
|
1699 TDisplayMode maskDisplayMode; |
|
1700 if (aSrcBmp==aMaskBmp) // When the source and target are same |
|
1701 { |
|
1702 maskDisplayMode=devDisplayMode; |
|
1703 } |
|
1704 else if (aAlphaBlend) // display mode based on the aAlphablend flag |
|
1705 { |
|
1706 maskDisplayMode=EGray256; |
|
1707 } |
|
1708 else |
|
1709 { |
|
1710 maskDisplayMode=aMaskBmp->DisplayMode(); |
|
1711 } |
|
1712 User::LeaveIfError(maskBmp->Create(size,maskDisplayMode)); |
|
1713 //Creating bitmap device for calculation and comparison |
|
1714 CFbsBitmapDevice *bgDevice=CFbsBitmapDevice::NewL(backgroundBmp); |
|
1715 CleanupStack::PushL(bgDevice); |
|
1716 CFbsBitGc* bgGc=NULL; |
|
1717 User::LeaveIfError(bgDevice->CreateContext(bgGc)); |
|
1718 CleanupStack::PushL(bgGc); |
|
1719 if (width==iBitmapWidth && height==iBitmapHeight || aTarRect.Width()<=iSize.iWidth && aTarRect.Height()<=iSize.iHeight) |
|
1720 { |
|
1721 bgGc->DrawBitmap(rect,aBgBmp); |
|
1722 } |
|
1723 else |
|
1724 { |
|
1725 bgGc->DrawBitmap(aTarRect,aBgBmp); |
|
1726 } |
|
1727 CFbsBitmapDevice* maskDevice=CFbsBitmapDevice::NewL(maskBmp); //For masked bitmap |
|
1728 CleanupStack::PushL(maskDevice); |
|
1729 CFbsBitGc* maskGc=NULL; |
|
1730 User::LeaveIfError(maskDevice->CreateContext(maskGc)); |
|
1731 CleanupStack::PushL(maskGc); |
|
1732 if (width==iBitmapWidth && height==iBitmapHeight || aTarRect.Width()<=iSize.iWidth && aTarRect.Height()<=iSize.iHeight) |
|
1733 { |
|
1734 maskGc->DrawBitmap(rect,aMaskBmp); |
|
1735 } |
|
1736 else |
|
1737 { |
|
1738 maskGc->DrawBitmap(aTarRect,aMaskBmp); |
|
1739 } |
|
1740 CFbsBitmapDevice* srcDevice=CFbsBitmapDevice::NewL(srcBmp); //For source bitmap |
|
1741 CleanupStack::PushL(srcDevice); |
|
1742 CFbsBitGc* srcGc=NULL; |
|
1743 User::LeaveIfError(srcDevice->CreateContext(srcGc)); |
|
1744 CleanupStack::PushL(srcGc); |
|
1745 if (width==iBitmapWidth && height==iBitmapHeight || aTarRect.Width()<=iSize.iWidth && aTarRect.Height()<=iSize.iHeight) |
|
1746 { |
|
1747 srcGc->DrawBitmap(rect,aSrcBmp); |
|
1748 } |
|
1749 else |
|
1750 { |
|
1751 srcGc->DrawBitmap(aTarRect,aSrcBmp); |
|
1752 } |
|
1753 |
|
1754 for (rowIndex=0;rowIndex<height;++rowIndex) |
|
1755 { |
|
1756 TInt redinversemask=0; |
|
1757 TInt redmaskvalue=0; |
|
1758 TInt greeninversemask=0; |
|
1759 TInt greenmaskvalue=0; |
|
1760 TInt blueinversemask=0; |
|
1761 TInt bluemaskvalue=0; |
|
1762 TRgb bmpcol; |
|
1763 TRgb samplecol; |
|
1764 TRgb maskcol; |
|
1765 for (colIndex=0;colIndex<width;++colIndex) |
|
1766 { |
|
1767 srcDevice->GetPixel(bmpcol,TPoint(colIndex,rowIndex)); |
|
1768 iDev->GetPixel(samplecol,aTarRect.iTl+TPoint(colIndex,rowIndex)); |
|
1769 TRgb backgroundcolor; |
|
1770 bgDevice->GetPixel(backgroundcolor,TPoint(colIndex,rowIndex)); |
|
1771 maskDevice->GetPixel(maskcol,TPoint(colIndex,rowIndex)); |
|
1772 if (aInvertMask && (maskDisplayMode!=EGray256 || aAlphaBlend)) |
|
1773 { |
|
1774 redinversemask=maskcol.Red(); // green and blue should have the same value for gray-scale bitmap |
|
1775 redmaskvalue=MAXCOLORS-redinversemask; |
|
1776 blueinversemask=maskcol.Blue(); |
|
1777 bluemaskvalue=MAXCOLORS-blueinversemask; |
|
1778 greeninversemask=maskcol.Green(); |
|
1779 greenmaskvalue=MAXCOLORS-greeninversemask; |
|
1780 } |
|
1781 else |
|
1782 { |
|
1783 redmaskvalue=maskcol.Red(); |
|
1784 redinversemask=MAXCOLORS-redmaskvalue; |
|
1785 bluemaskvalue=maskcol.Blue(); |
|
1786 blueinversemask=MAXCOLORS-bluemaskvalue; |
|
1787 greenmaskvalue=maskcol.Green(); |
|
1788 greeninversemask=MAXCOLORS-greenmaskvalue; |
|
1789 } |
|
1790 TInt red; |
|
1791 TInt green; |
|
1792 TInt blue; |
|
1793 if (aSemiTransparentMask && devDisplayMode!=EGray256) |
|
1794 { |
|
1795 if (devDisplayMode==EColor64K || devDisplayMode==EColor256 || devDisplayMode==EColor4K || devDisplayMode==EColor16M || aInvertMask) |
|
1796 { |
|
1797 red=(bmpcol.Red()*redmaskvalue+backgroundcolor.Red()*redinversemask)>>8; |
|
1798 green=(bmpcol.Green()*greenmaskvalue+backgroundcolor.Green()*greeninversemask)>>8; |
|
1799 blue=(bmpcol.Blue()*bluemaskvalue+backgroundcolor.Blue()*blueinversemask)>>8; |
|
1800 } |
|
1801 else |
|
1802 { |
|
1803 red=(bmpcol.Red()*(redmaskvalue+1))>>8; |
|
1804 red+=(backgroundcolor.Red()*(redinversemask+1))>>8; |
|
1805 green=(bmpcol.Green()*(greenmaskvalue+1))>>8; |
|
1806 green+=(backgroundcolor.Green()*(greeninversemask+1))>>8; |
|
1807 blue=(bmpcol.Blue()*(bluemaskvalue+1))>>8; |
|
1808 blue+=(backgroundcolor.Blue()*(blueinversemask+1))>>8; |
|
1809 } |
|
1810 } |
|
1811 else |
|
1812 { |
|
1813 red=((bmpcol.Red()*redmaskvalue)+(backgroundcolor.Red()*redinversemask)); |
|
1814 green=((bmpcol.Green()*greenmaskvalue)+(backgroundcolor.Green()*greeninversemask)); |
|
1815 blue=((bmpcol.Blue()*bluemaskvalue)+(backgroundcolor.Blue()*blueinversemask)); |
|
1816 red = red / MAXCOLORS; |
|
1817 green = green / MAXCOLORS; |
|
1818 blue = blue / MAXCOLORS; |
|
1819 } |
|
1820 |
|
1821 TRgb rgb(red,green,blue); |
|
1822 TRgb resultantColor; |
|
1823 TUint index; |
|
1824 switch(devDisplayMode) |
|
1825 { |
|
1826 case EGray2: |
|
1827 { |
|
1828 index = TRgb::Gray2(blue).Gray2(); |
|
1829 resultantColor = TRgb::Gray2(index); |
|
1830 break; |
|
1831 } |
|
1832 case EGray256: |
|
1833 { |
|
1834 index = rgb.Gray256(); |
|
1835 resultantColor = TRgb::Gray256(index); |
|
1836 break; |
|
1837 } |
|
1838 case EColor256: |
|
1839 { |
|
1840 index = rgb.Color256(); |
|
1841 resultantColor = TRgb::Color256(index); |
|
1842 break; |
|
1843 } |
|
1844 case EColor4K: |
|
1845 { |
|
1846 index = rgb.Color4K(); |
|
1847 resultantColor = TRgb::Color4K(index); |
|
1848 break; |
|
1849 } |
|
1850 case EColor64K: |
|
1851 { |
|
1852 index = rgb.Color64K(); |
|
1853 resultantColor = TRgb::Color64K(index); |
|
1854 break; |
|
1855 } |
|
1856 case EColor16M: |
|
1857 { |
|
1858 index = rgb.Color16M(); |
|
1859 resultantColor = TRgb::Color16M(index); |
|
1860 break; |
|
1861 } |
|
1862 case EColor16MU: |
|
1863 { |
|
1864 index = rgb.Color16MU(); |
|
1865 resultantColor = TRgb::Color16MU(index); |
|
1866 break; |
|
1867 } |
|
1868 } |
|
1869 CheckL(samplecol.Red()==resultantColor.Red()); |
|
1870 CheckL(samplecol.Green()==resultantColor.Green()); |
|
1871 CheckL(samplecol.Blue()==resultantColor.Blue()); |
|
1872 } |
|
1873 } |
|
1874 CleanupStack::PopAndDestroy(9,backgroundBmp); |
|
1875 } |
|
1876 |
|
1877 /** |
|
1878 @SYMTestCaseID GRAPHICS-TestGdi-DoDrawBitmapMaskedL-0001 |
|
1879 |
|
1880 @SYMPREQ 642 |
|
1881 |
|
1882 @SYMREQ |
|
1883 |
|
1884 @SYMTestCaseDesc Test DrawMaskedBitmap (Transperency Stretched Bitmap).\n |
|
1885 Automated Tests to test DrawBitmapMasked with different display modes. |
|
1886 |
|
1887 @SYMTestPriority High |
|
1888 |
|
1889 @SYMTestStatus Implemented |
|
1890 |
|
1891 @SYMTestActions Creates bitmaps programmatically and calls API DrawBitmapMasked() with respective parameters |
|
1892 Drawn pixels value with calculated pixels and verified using CheckL(), All the test cases specified in \n |
|
1893 test specifications are implemented(22 test cases). |
|
1894 |
|
1895 @SYMTestExpectedResults KErrNone |
|
1896 |
|
1897 */ |
|
1898 void TestGdi::DoDrawBitmapMaskedL(TBool aColorMask) |
|
1899 { |
|
1900 _LIT(KBitmapMasked,"DrawBitmapMasked - Test Case "); |
|
1901 *iSection = KBitmapMasked; |
|
1902 TInt rowIndex; |
|
1903 TInt colIndex; |
|
1904 TSize rectSize(iBitmapWidth,iBitmapHeight); |
|
1905 TRect srcRect; |
|
1906 TRect tarRect; |
|
1907 |
|
1908 CFbsBitmap* backgroundBmp = new (ELeave) CFbsBitmap; |
|
1909 CleanupStack::PushL(backgroundBmp); |
|
1910 User::LeaveIfError(backgroundBmp->Create(rectSize,iDev->DisplayMode())); |
|
1911 srcRect.SetSize(rectSize); |
|
1912 TBitmapUtil bmpUtil(backgroundBmp); |
|
1913 bmpUtil.Begin(TPoint(0,0)); |
|
1914 for (rowIndex=0;rowIndex<iBitmapHeight;++rowIndex) |
|
1915 { |
|
1916 TInt red=0; |
|
1917 TInt blue=255; |
|
1918 if(iDev->DisplayMode()==EGray2) |
|
1919 { |
|
1920 blue=0; |
|
1921 } |
|
1922 TInt green=0; |
|
1923 bmpUtil.SetPos(TPoint(0,rowIndex)); |
|
1924 for (colIndex=0;colIndex<iBitmapWidth;++colIndex) |
|
1925 { |
|
1926 TRgb rgb(red,green,blue); |
|
1927 switch(iDev->DisplayMode()) |
|
1928 { |
|
1929 case EGray2: |
|
1930 { |
|
1931 bmpUtil.SetPixel(TRgb::Gray2(blue).Gray2()); |
|
1932 bmpUtil.IncXPos(); |
|
1933 if (colIndex%4==0) |
|
1934 { |
|
1935 blue=255-blue; |
|
1936 } |
|
1937 continue; |
|
1938 } |
|
1939 case EGray256: |
|
1940 { |
|
1941 bmpUtil.SetPixel(rgb.Gray256()); |
|
1942 break; |
|
1943 } |
|
1944 case EColor256: |
|
1945 { |
|
1946 bmpUtil.SetPixel(rgb.Color256()); |
|
1947 break; |
|
1948 } |
|
1949 case EColor4K: |
|
1950 { |
|
1951 bmpUtil.SetPixel(rgb.Color4K()); |
|
1952 break; |
|
1953 } |
|
1954 case EColor64K: |
|
1955 { |
|
1956 bmpUtil.SetPixel(rgb.Color64K()); |
|
1957 break; |
|
1958 } |
|
1959 case EColor16M: |
|
1960 { |
|
1961 bmpUtil.SetPixel(rgb.Color16M()); |
|
1962 break; |
|
1963 } |
|
1964 case EColor16MU: |
|
1965 { |
|
1966 bmpUtil.SetPixel(rgb.Color16MU()); |
|
1967 break; |
|
1968 } |
|
1969 } |
|
1970 bmpUtil.IncXPos(); |
|
1971 red+=10; |
|
1972 blue-=30; |
|
1973 green+=20; |
|
1974 if(red > 255) |
|
1975 { |
|
1976 red-=255; |
|
1977 green+=1; |
|
1978 } |
|
1979 if(green > 255) |
|
1980 { |
|
1981 green-=255; |
|
1982 blue-=1; |
|
1983 } |
|
1984 if(blue < 0) |
|
1985 { |
|
1986 blue+=255; |
|
1987 } |
|
1988 } |
|
1989 } |
|
1990 bmpUtil.End(); |
|
1991 //Create source bitmap with various color scale |
|
1992 CFbsBitmap* srcBmp = new (ELeave) CFbsBitmap; |
|
1993 CleanupStack::PushL(srcBmp); |
|
1994 User::LeaveIfError(srcBmp->Create(rectSize,iDev->DisplayMode())); |
|
1995 TBitmapUtil bmpUtil1(srcBmp); |
|
1996 bmpUtil1.Begin(TPoint(0,0)); |
|
1997 TInt gray2=0; |
|
1998 for (rowIndex=0;rowIndex<iBitmapHeight;++rowIndex) |
|
1999 { |
|
2000 TInt red=255; |
|
2001 TInt blue=0; |
|
2002 TInt green=255; |
|
2003 bmpUtil1.SetPos(TPoint(0,rowIndex)); |
|
2004 gray2=!gray2?0:255; |
|
2005 for (colIndex=0;colIndex<iBitmapWidth;++colIndex) |
|
2006 { |
|
2007 TRgb rgb(red,green,blue); |
|
2008 switch(iDev->DisplayMode()) |
|
2009 { |
|
2010 case EGray2: |
|
2011 { |
|
2012 bmpUtil1.SetPixel(TRgb::Gray2(gray2).Gray2()); |
|
2013 bmpUtil1.IncXPos(); |
|
2014 red=0; |
|
2015 green=0; |
|
2016 blue=!blue?255:0; |
|
2017 continue; |
|
2018 } |
|
2019 case EGray256: |
|
2020 { |
|
2021 bmpUtil1.SetPixel(rgb.Gray256()); |
|
2022 break; |
|
2023 } |
|
2024 case EColor256: |
|
2025 { |
|
2026 bmpUtil1.SetPixel(rgb.Color256()); |
|
2027 break; |
|
2028 } |
|
2029 case EColor4K: |
|
2030 { |
|
2031 bmpUtil1.SetPixel(rgb.Color4K()); |
|
2032 break; |
|
2033 } |
|
2034 case EColor64K: |
|
2035 { |
|
2036 bmpUtil1.SetPixel(rgb.Color64K()); |
|
2037 break; |
|
2038 } |
|
2039 case EColor16M: |
|
2040 { |
|
2041 bmpUtil1.SetPixel(rgb.Color16M()); |
|
2042 break; |
|
2043 } |
|
2044 case EColor16MU: |
|
2045 { |
|
2046 bmpUtil1.SetPixel(rgb.Color16MU()); |
|
2047 break; |
|
2048 } |
|
2049 } |
|
2050 bmpUtil1.IncXPos(); |
|
2051 red-=10; |
|
2052 blue+=10; |
|
2053 green-=10; |
|
2054 if(red <= 0) |
|
2055 { |
|
2056 red+=255; |
|
2057 } |
|
2058 if(blue >= 255) |
|
2059 { |
|
2060 blue-=255; |
|
2061 } |
|
2062 if(green <= 0) |
|
2063 { |
|
2064 green+=255; |
|
2065 } |
|
2066 } |
|
2067 } |
|
2068 bmpUtil1.End(); |
|
2069 //Masked bitmap with various color scale |
|
2070 CFbsBitmap* maskBmp = new (ELeave) CFbsBitmap; |
|
2071 CleanupStack::PushL(maskBmp); |
|
2072 TBitmapUtil bmpUtil2(maskBmp); |
|
2073 if(iDev->DisplayMode() == EGray2) |
|
2074 { |
|
2075 User::LeaveIfError(maskBmp->Create(rectSize,EGray2)); |
|
2076 bmpUtil2.Begin(TPoint(0,0)); |
|
2077 for (rowIndex=0;rowIndex<iBitmapHeight;++rowIndex) |
|
2078 { |
|
2079 bmpUtil2.SetPos(TPoint(0,rowIndex)); |
|
2080 TInt blue=0; |
|
2081 for(colIndex=0;colIndex<iBitmapWidth;++colIndex) |
|
2082 { |
|
2083 bmpUtil2.SetPixel(blue); |
|
2084 bmpUtil2.IncXPos(); |
|
2085 blue=!blue?255:0; |
|
2086 } |
|
2087 } |
|
2088 bmpUtil2.End(); |
|
2089 } |
|
2090 else |
|
2091 { |
|
2092 User::LeaveIfError(maskBmp->Create(rectSize,aColorMask?EColor256:EGray256)); |
|
2093 bmpUtil2.Begin(TPoint(0,0)); |
|
2094 for (rowIndex=0;rowIndex<iBitmapHeight;++rowIndex) |
|
2095 { |
|
2096 bmpUtil2.SetPos(TPoint(0,rowIndex)); |
|
2097 TInt red=0; |
|
2098 TInt blue=0; |
|
2099 TInt green=0; |
|
2100 for(colIndex=0;colIndex<iBitmapWidth;++colIndex) |
|
2101 { |
|
2102 TRgb rgb(red,green,blue); |
|
2103 bmpUtil2.SetPixel(rgb.Color256()); |
|
2104 bmpUtil2.IncXPos(); |
|
2105 red=!red?255:0; |
|
2106 blue=!blue?255:0; |
|
2107 green=!green?255:0; |
|
2108 } |
|
2109 } |
|
2110 bmpUtil2.End(); |
|
2111 } |
|
2112 |
|
2113 //Masked bitmap with various gray scale (For Alphablending) |
|
2114 CFbsBitmap* maskblendBmp = new (ELeave) CFbsBitmap; |
|
2115 CleanupStack::PushL(maskblendBmp); |
|
2116 if(iDev->DisplayMode() == EGray2) |
|
2117 { |
|
2118 User::LeaveIfError(maskblendBmp->Create(rectSize,EGray2)); |
|
2119 TBitmapUtil bmpUtil3(maskblendBmp); |
|
2120 bmpUtil3.Begin(TPoint(0,0)); |
|
2121 TInt blue=0; |
|
2122 for (rowIndex=0;rowIndex<iBitmapHeight;++rowIndex) |
|
2123 { |
|
2124 bmpUtil3.SetPos(TPoint(0,rowIndex)); |
|
2125 blue=0; |
|
2126 for(colIndex=0;colIndex<iBitmapWidth;++colIndex) |
|
2127 { |
|
2128 bmpUtil3.SetPixel(blue); |
|
2129 bmpUtil3.IncXPos(); |
|
2130 blue=!blue?255:0; |
|
2131 } |
|
2132 } |
|
2133 bmpUtil3.End(); |
|
2134 } |
|
2135 else |
|
2136 { |
|
2137 User::LeaveIfError(maskblendBmp->Create(rectSize,EGray256)); |
|
2138 TBitmapUtil bmpUtil3(maskblendBmp); |
|
2139 bmpUtil3.Begin(TPoint(0,0)); |
|
2140 for (rowIndex=0;rowIndex<iBitmapHeight;++rowIndex) |
|
2141 { |
|
2142 bmpUtil3.SetPos(TPoint(0,rowIndex)); |
|
2143 TInt red=0; |
|
2144 TInt blue=0; |
|
2145 TInt green=0; |
|
2146 for(colIndex=0;colIndex<iBitmapWidth;++colIndex) |
|
2147 { |
|
2148 TRgb rgb(red,green,blue); |
|
2149 bmpUtil3.SetPixel(rgb.Gray256()); |
|
2150 bmpUtil3.IncXPos(); |
|
2151 red=!red?255:0; |
|
2152 blue=!blue?255:0; |
|
2153 green=!green?255:0; |
|
2154 } |
|
2155 } |
|
2156 bmpUtil3.End(); |
|
2157 } |
|
2158 /** |
|
2159 Test Cases 1 to 10 (AlphaBlending) |
|
2160 |
|
2161 Test Case # 1 |
|
2162 |
|
2163 Desc : Test the functionality of DrawBitmapMasked() without |
|
2164 Stretching or compressing and with a normal mask. |
|
2165 */ |
|
2166 iSection->AppendNum(1); |
|
2167 iCon->DrawBitmap(srcRect,backgroundBmp,srcRect); |
|
2168 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2169 iCon->DrawBitmapMasked(srcRect,srcBmp,srcRect,maskblendBmp,EFalse); |
|
2170 CheckMaskedResultsL(backgroundBmp,srcBmp,maskblendBmp,srcRect,EFalse,ETrue); |
|
2171 /** |
|
2172 Test Case # 2 |
|
2173 |
|
2174 Desc : To test the functionality of DrawBitmapMasked() |
|
2175 when it stretches the bitmap and with a normal mask. |
|
2176 */ |
|
2177 iSection->Delete(iSection->Length() - 1, 1); |
|
2178 iSection->AppendNum(2); |
|
2179 iCon->Clear(); |
|
2180 tarRect.iTl.SetXY(0,0); |
|
2181 tarRect.SetWidth(iBitmapWidth*2); |
|
2182 tarRect.SetHeight(iBitmapHeight*2); |
|
2183 if (iDev->SizeInPixels().iWidth>=tarRect.Width() && iDev->SizeInPixels().iHeight>=tarRect.Height()) |
|
2184 { |
|
2185 iCon->DrawBitmap(tarRect,backgroundBmp); |
|
2186 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2187 iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskblendBmp,EFalse); |
|
2188 CheckMaskedResultsL(backgroundBmp,srcBmp,maskblendBmp,tarRect,EFalse,ETrue); |
|
2189 } |
|
2190 /** |
|
2191 Test Case # 3 |
|
2192 |
|
2193 Desc : To test the functionality of DrawBitmapMasked() |
|
2194 when it compresses the bitmap and with a normal mask. |
|
2195 */ |
|
2196 iSection->Delete(iSection->Length() - 1, 1); |
|
2197 iSection->AppendNum(3); |
|
2198 iCon->Clear(); |
|
2199 tarRect.iTl.SetXY(0,0); |
|
2200 tarRect.SetWidth(iBitmapWidth/2); |
|
2201 tarRect.SetHeight(iBitmapHeight/2); |
|
2202 iCon->DrawBitmap(tarRect,backgroundBmp); |
|
2203 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2204 iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskblendBmp,EFalse); |
|
2205 CheckMaskedResultsL(backgroundBmp,srcBmp,maskblendBmp,tarRect,EFalse,ETrue); |
|
2206 /** |
|
2207 Test Case # 4 |
|
2208 |
|
2209 Desc : To test the functionality of DrawBitmapMasked() with Destination Rectangle as zero. |
|
2210 */ |
|
2211 iSection->Delete(iSection->Length() - 1, 1); |
|
2212 iSection->AppendNum(4); |
|
2213 iCon->Clear(); |
|
2214 tarRect.iTl.SetXY(0,0); |
|
2215 tarRect.SetWidth(0); |
|
2216 tarRect.SetHeight(0); |
|
2217 iCon->DrawBitmap(tarRect,backgroundBmp); |
|
2218 iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskblendBmp,EFalse); |
|
2219 CheckMaskedResultsL(backgroundBmp,srcBmp,maskblendBmp,tarRect,EFalse,ETrue); |
|
2220 /** |
|
2221 Test Case # 5 |
|
2222 |
|
2223 Desc : To test the functionality of DrawBitmapMasked() |
|
2224 with destination rectangle large in size. (more than test screen size) |
|
2225 */ |
|
2226 iSection->Delete(iSection->Length() - 1, 1); |
|
2227 iSection->AppendNum(5); |
|
2228 iCon->Clear(); |
|
2229 tarRect.iTl.SetXY(0,0); |
|
2230 tarRect.SetWidth(iBitmapWidth*5); |
|
2231 tarRect.SetHeight(iBitmapHeight*4); |
|
2232 iCon->DrawBitmap(tarRect,backgroundBmp); |
|
2233 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2234 iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskblendBmp,EFalse); |
|
2235 CheckMaskedResultsL(backgroundBmp,srcBmp,maskblendBmp,tarRect,EFalse,ETrue); |
|
2236 /** |
|
2237 Test Case # 6 |
|
2238 |
|
2239 Desc : To test the functionality of DrawBitmapMasked() |
|
2240 passing the target rectangle targeted to right top corner of the screen. |
|
2241 */ |
|
2242 iSection->Delete(iSection->Length() - 1, 1); |
|
2243 iSection->AppendNum(6); |
|
2244 iCon->Clear(); |
|
2245 tarRect.iTl.SetXY(0,0); |
|
2246 tarRect.SetWidth(iBitmapWidth); |
|
2247 tarRect.SetHeight(iBitmapHeight); |
|
2248 tarRect.Move(iSize.iWidth-iBitmapWidth,0); |
|
2249 iCon->DrawBitmap(tarRect,backgroundBmp); |
|
2250 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2251 iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskblendBmp,EFalse); |
|
2252 CheckMaskedResultsL(backgroundBmp,srcBmp,maskblendBmp,tarRect,EFalse,ETrue); |
|
2253 /** |
|
2254 Test Case # 7 |
|
2255 |
|
2256 Desc : To test the functionality of DrawBitmapMasked() |
|
2257 passing the target rectangle targeted to bottom left corner of the screen. |
|
2258 */ |
|
2259 iSection->Delete(iSection->Length() - 1, 1); |
|
2260 iSection->AppendNum(7); |
|
2261 iCon->Clear(); |
|
2262 tarRect.iTl.SetXY(0,0); // Restoring rectangle back to the original position |
|
2263 tarRect.SetWidth(iBitmapWidth); |
|
2264 tarRect.SetHeight(iBitmapHeight); |
|
2265 tarRect.Move(0,(iSize.iHeight-iBitmapHeight)); |
|
2266 iCon->DrawBitmap(tarRect,backgroundBmp); |
|
2267 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2268 iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskblendBmp,EFalse); |
|
2269 CheckMaskedResultsL(backgroundBmp,srcBmp,maskblendBmp,tarRect,EFalse,ETrue); |
|
2270 /** |
|
2271 Test Case # 8 |
|
2272 |
|
2273 Desc : To test the functionality of DrawBitmapMasked() |
|
2274 passing the target rectangle targeted to bottom right corner of the screen |
|
2275 */ |
|
2276 iSection->Delete(iSection->Length() - 1, 1); |
|
2277 iSection->AppendNum(8); |
|
2278 iCon->Clear(); |
|
2279 tarRect.iTl.SetXY(0,0); // Restoring rectangle back to the original position |
|
2280 tarRect.SetWidth(iBitmapWidth); |
|
2281 tarRect.SetHeight(iBitmapHeight); |
|
2282 tarRect.Move((iSize.iWidth-iBitmapWidth),(iSize.iHeight-iBitmapHeight)); |
|
2283 iCon->DrawBitmap(tarRect,backgroundBmp); |
|
2284 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2285 iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskblendBmp,EFalse); |
|
2286 CheckMaskedResultsL(backgroundBmp,srcBmp,maskblendBmp,tarRect,EFalse,ETrue); |
|
2287 /** |
|
2288 Test Case # 9 |
|
2289 |
|
2290 Desc : To test the functionality of DrawBitmapMasked() |
|
2291 passing the target rectangle has negative coordinates |
|
2292 */ |
|
2293 iSection->Delete(iSection->Length() - 1, 1); |
|
2294 iSection->AppendNum(9); |
|
2295 iCon->Clear(); |
|
2296 tarRect.iTl.SetXY(0,0); // Restoring rectangle back to the original position |
|
2297 tarRect.SetWidth(-iBitmapWidth); |
|
2298 tarRect.SetHeight(-iBitmapHeight); |
|
2299 iCon->DrawBitmap(tarRect,backgroundBmp); |
|
2300 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2301 iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskblendBmp,EFalse); |
|
2302 CheckMaskedResultsL(backgroundBmp,srcBmp,maskblendBmp,tarRect,EFalse,ETrue); |
|
2303 /** |
|
2304 Test Case # 10 |
|
2305 |
|
2306 Desc : To test the functionality of DrawBitmapMasked() |
|
2307 passing the same bitmap for both the source and mask |
|
2308 */ |
|
2309 if (iDev->DisplayMode()==EGray2 || iDev->DisplayMode()==EGray4 || iDev->DisplayMode()==EGray16) |
|
2310 { |
|
2311 iSection->Delete(iSection->Length() - 1, 1); |
|
2312 iSection->AppendNum(10); |
|
2313 iCon->Clear(); |
|
2314 tarRect.iTl.SetXY(0,0); // Restoring rectangle back to the original position |
|
2315 tarRect.SetWidth(iBitmapWidth); |
|
2316 tarRect.SetHeight(iBitmapHeight); |
|
2317 iCon->DrawBitmap(tarRect,backgroundBmp); |
|
2318 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2319 iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,srcBmp,EFalse); |
|
2320 CheckMaskedResultsL(backgroundBmp,srcBmp,srcBmp,tarRect,EFalse,EFalse); |
|
2321 } |
|
2322 /** |
|
2323 Test Cases: 11 - 22 (BitBltMasked) |
|
2324 |
|
2325 Test Case # 11 |
|
2326 |
|
2327 Desc : Test the functionality of DrawBitmapMasked() without |
|
2328 Stretching or compressing and with a normal mask. |
|
2329 */ |
|
2330 iSection->Delete(iSection->Length() - 2, 2); |
|
2331 iSection->AppendNum(11); |
|
2332 iCon->Clear(); |
|
2333 tarRect.iTl.SetXY(0,0); |
|
2334 tarRect.SetWidth(iBitmapWidth); |
|
2335 tarRect.SetHeight(iBitmapHeight); |
|
2336 iCon->DrawBitmap(srcRect,backgroundBmp,srcRect); |
|
2337 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2338 iCon->DrawBitmapMasked(srcRect,srcBmp,srcRect,maskBmp,EFalse); |
|
2339 CheckMaskedResultsL(backgroundBmp,srcBmp,maskBmp,srcRect,EFalse,EFalse); |
|
2340 // Test Case # 12 with a reverse mask. |
|
2341 iSection->Delete(iSection->Length() - 2, 2); |
|
2342 iSection->AppendNum(12); |
|
2343 iCon->Clear(); |
|
2344 iCon->DrawBitmap(tarRect,backgroundBmp); |
|
2345 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2346 iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskBmp,ETrue); |
|
2347 CheckMaskedResultsL(backgroundBmp,srcBmp,maskBmp,tarRect,ETrue,EFalse); |
|
2348 /** |
|
2349 Test Case # 13 |
|
2350 |
|
2351 Desc : To test the functionality of DrawBitmapMasked() |
|
2352 when it stretches the bitmap and with a normal mask. |
|
2353 */ |
|
2354 iSection->Delete(iSection->Length() - 2, 2); |
|
2355 iSection->AppendNum(13); |
|
2356 iCon->Clear(); |
|
2357 tarRect.iTl.SetXY(0,0); |
|
2358 tarRect.SetWidth(Min(iBitmapWidth*2,iSize.iWidth)); |
|
2359 tarRect.SetHeight(Min(iBitmapHeight*2,iSize.iHeight)); |
|
2360 if (iDev->SizeInPixels().iWidth>=tarRect.Width() && iDev->SizeInPixels().iHeight>=tarRect.Height()) |
|
2361 { |
|
2362 iCon->DrawBitmap(tarRect,backgroundBmp); |
|
2363 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2364 iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskBmp,EFalse); |
|
2365 CheckMaskedResultsL(backgroundBmp,srcBmp,maskBmp,tarRect,EFalse,EFalse); |
|
2366 } |
|
2367 // Test Case # 14 with a reverse mask. |
|
2368 if (iDev->SizeInPixels().iWidth>=tarRect.Width() && iDev->SizeInPixels().iHeight>=tarRect.Height()) |
|
2369 { |
|
2370 iSection->Delete(iSection->Length() - 2, 2); |
|
2371 iSection->AppendNum(14); |
|
2372 iCon->Clear(); |
|
2373 iCon->DrawBitmap(tarRect,backgroundBmp); |
|
2374 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2375 iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskBmp,ETrue); |
|
2376 CheckMaskedResultsL(backgroundBmp,srcBmp,maskBmp,tarRect,ETrue,EFalse); |
|
2377 } |
|
2378 /** |
|
2379 Test Case # 15 |
|
2380 |
|
2381 Desc : To test the functionality of DrawBitmapMasked() |
|
2382 when it compresses the bitmap and with a normal mask. |
|
2383 */ |
|
2384 iSection->Delete(iSection->Length() - 2, 2); |
|
2385 iSection->AppendNum(15); |
|
2386 iCon->Clear(); |
|
2387 tarRect.iTl.SetXY(0,0); |
|
2388 tarRect.SetWidth(iBitmapWidth/2); |
|
2389 tarRect.SetHeight(iBitmapHeight/2); |
|
2390 iCon->DrawBitmap(tarRect,backgroundBmp); |
|
2391 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2392 iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskBmp,EFalse); |
|
2393 CheckMaskedResultsL(backgroundBmp,srcBmp,maskBmp,tarRect,EFalse,EFalse); |
|
2394 // Test Case # 16 with a reverse mask. |
|
2395 iSection->Delete(iSection->Length() - 2, 2); |
|
2396 iSection->AppendNum(16); |
|
2397 iCon->Clear(); |
|
2398 iCon->DrawBitmap(tarRect,backgroundBmp); |
|
2399 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2400 iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskBmp,ETrue); |
|
2401 CheckMaskedResultsL(backgroundBmp,srcBmp,maskBmp,tarRect,ETrue,EFalse); |
|
2402 /** |
|
2403 Test Case # 17 |
|
2404 |
|
2405 Desc : To test the functionality of DrawBitmapMasked() |
|
2406 with destination rectangle large in size. (more than test screen size) |
|
2407 */ |
|
2408 iSection->Delete(iSection->Length() - 2, 2); |
|
2409 iSection->AppendNum(17); |
|
2410 iCon->Clear(); |
|
2411 tarRect.iTl.SetXY(0,0); |
|
2412 tarRect.SetWidth(iBitmapWidth*5); |
|
2413 tarRect.SetHeight(iBitmapHeight*4); |
|
2414 iCon->DrawBitmap(tarRect,backgroundBmp); |
|
2415 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2416 iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskBmp,EFalse); |
|
2417 CheckMaskedResultsL(backgroundBmp,srcBmp,maskBmp,tarRect,EFalse,EFalse); |
|
2418 // Test Case # 18 with a reverse mask. |
|
2419 iSection->Delete(iSection->Length() - 2, 2); |
|
2420 iSection->AppendNum(18); |
|
2421 iCon->Clear(); |
|
2422 iCon->DrawBitmap(tarRect,backgroundBmp); |
|
2423 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2424 iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskBmp,ETrue); |
|
2425 CheckMaskedResultsL(backgroundBmp,srcBmp,maskBmp,tarRect,ETrue,EFalse); |
|
2426 /** |
|
2427 Test Case # 19 |
|
2428 |
|
2429 Desc : To test the functionality of DrawBitmapMasked() |
|
2430 passing the target rectangle targeted to right top corner of the screen. |
|
2431 */ |
|
2432 iSection->Delete(iSection->Length() - 2, 2); |
|
2433 iSection->AppendNum(19); |
|
2434 iCon->Clear(); |
|
2435 tarRect.iTl.SetXY(0,0); |
|
2436 tarRect.SetWidth(iBitmapWidth); |
|
2437 tarRect.SetHeight(iBitmapHeight); |
|
2438 tarRect.Move(iSize.iWidth-iBitmapWidth,0); |
|
2439 iCon->DrawBitmap(tarRect,backgroundBmp); |
|
2440 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2441 iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskBmp,EFalse); |
|
2442 CheckMaskedResultsL(backgroundBmp,srcBmp,maskBmp,tarRect,EFalse,EFalse); |
|
2443 // Test Case # 20 with a reverse mask. |
|
2444 iSection->Delete(iSection->Length() - 2, 2); |
|
2445 iSection->AppendNum(20); |
|
2446 iCon->Clear(); |
|
2447 iCon->DrawBitmap(tarRect,backgroundBmp); |
|
2448 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2449 iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskBmp,ETrue); |
|
2450 CheckMaskedResultsL(backgroundBmp,srcBmp,maskBmp,tarRect,ETrue,EFalse); |
|
2451 /** |
|
2452 Test Case # 21 |
|
2453 |
|
2454 Desc : To test the functionality of DrawBitmapMasked() |
|
2455 passing the target rectangle targeted to bottom right corner of the screen |
|
2456 */ |
|
2457 iSection->Delete(iSection->Length() - 2, 2); |
|
2458 iSection->AppendNum(21); |
|
2459 iCon->Clear(); |
|
2460 tarRect.iTl.SetXY(0,0); // Restoring rectangle back to the original position |
|
2461 tarRect.SetWidth(iBitmapWidth); |
|
2462 tarRect.SetHeight(iBitmapHeight); |
|
2463 tarRect.Move((iSize.iWidth-iBitmapWidth),(iSize.iHeight-iBitmapHeight)); |
|
2464 iCon->DrawBitmap(tarRect,backgroundBmp); |
|
2465 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2466 iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskBmp,EFalse); |
|
2467 CheckMaskedResultsL(backgroundBmp,srcBmp,maskBmp,tarRect,EFalse,EFalse); |
|
2468 // Test Case # 22 with a reverse mask. |
|
2469 iSection->Delete(iSection->Length() - 2, 2); |
|
2470 iSection->AppendNum(22); |
|
2471 iCon->Clear(); |
|
2472 iCon->DrawBitmap(tarRect,backgroundBmp); |
|
2473 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2474 iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskBmp,ETrue); |
|
2475 CheckMaskedResultsL(backgroundBmp,srcBmp,maskBmp,tarRect,ETrue,EFalse); |
|
2476 |
|
2477 /** |
|
2478 Test Case # 23 |
|
2479 |
|
2480 Desc: To ensure that DEF064071 is fixed. Test that drawing a scaled |
|
2481 bitmap with a tiled mask gives the correct result. |
|
2482 */ |
|
2483 if(iSize.iWidth > 100 && iDev->DisplayMode() > EGray4) |
|
2484 // Only do this test for screen devices |
|
2485 { |
|
2486 iSection->Delete(iSection->Length() - 2, 2); |
|
2487 iSection->AppendNum(23); |
|
2488 Clear(); |
|
2489 iCon->Clear(); |
|
2490 // We need a bigger rect than the rect in other tests |
|
2491 TRect t23Rect(TSize(150,150)); |
|
2492 // Open source bitmap and mask |
|
2493 CFbsBitmap* t23SrcBmp = new (ELeave) CFbsBitmap(); |
|
2494 CleanupStack::PushL(t23SrcBmp); |
|
2495 User::LeaveIfError(t23SrcBmp->Load(KT23BitmapFileName,EMbmTgdiDef064071_sourcebitmap)); |
|
2496 CFbsBitmap* t23SrcBmpMask = new (ELeave) CFbsBitmap(); |
|
2497 CleanupStack::PushL(t23SrcBmpMask); |
|
2498 User::LeaveIfError(t23SrcBmpMask->Load(KT23BitmapFileName,EMbmTgdiDef064071_sourcebitmapmask)); |
|
2499 |
|
2500 // Open bitmap that contains the expected result |
|
2501 CFbsBitmap* t23ExpectedBmp = new (ELeave) CFbsBitmap(); |
|
2502 CleanupStack::PushL(t23ExpectedBmp); |
|
2503 switch(iDev->DisplayMode()) |
|
2504 { |
|
2505 case EGray16: |
|
2506 User::LeaveIfError(t23ExpectedBmp->Load(KT23BitmapFileName,EMbmTgdiDef064071_expected_egray16)); |
|
2507 break; |
|
2508 case EGray256: |
|
2509 User::LeaveIfError(t23ExpectedBmp->Load(KT23BitmapFileName,EMbmTgdiDef064071_expected_egray256)); |
|
2510 break; |
|
2511 case EColor16: |
|
2512 User::LeaveIfError(t23ExpectedBmp->Load(KT23BitmapFileName,EMbmTgdiDef064071_expected_ecolor16)); |
|
2513 break; |
|
2514 case EColor256: |
|
2515 User::LeaveIfError(t23ExpectedBmp->Load(KT23BitmapFileName,EMbmTgdiDef064071_expected_ecolor256)); |
|
2516 break; |
|
2517 case EColor4K: |
|
2518 User::LeaveIfError(t23ExpectedBmp->Load(KT23BitmapFileName,EMbmTgdiDef064071_expected_ecolor4k)); |
|
2519 break; |
|
2520 case EColor64K: |
|
2521 User::LeaveIfError(t23ExpectedBmp->Load(KT23BitmapFileName,EMbmTgdiDef064071_expected_ecolor64k)); |
|
2522 break; |
|
2523 case EColor16M: |
|
2524 User::LeaveIfError(t23ExpectedBmp->Load(KT23BitmapFileName,EMbmTgdiDef064071_expected_ecolor16m)); |
|
2525 break; |
|
2526 case EColor16MU: |
|
2527 User::LeaveIfError(t23ExpectedBmp->Load(KT23BitmapFileName,EMbmTgdiDef064071_expected_ecolor16mu)); |
|
2528 break; |
|
2529 } |
|
2530 |
|
2531 // Draw masked bitmap to screen |
|
2532 iCon->DrawBitmapMasked(t23Rect,t23SrcBmp,t23SrcBmp->SizeInPixels(),t23SrcBmpMask,ETrue); |
|
2533 TRect miniTarRect(20,20,80,80); |
|
2534 // Draw small version of the bitmap |
|
2535 iCon->DrawBitmapMasked(miniTarRect,t23SrcBmp,t23SrcBmp->SizeInPixels(),t23SrcBmpMask,ETrue); |
|
2536 // Set the clipping region to draw either side of the small bitmap that we've just drawn |
|
2537 TRegionFix<2> t23Region; |
|
2538 t23Region.AddRect(TRect(t23Rect.iTl.iX,miniTarRect.iTl.iY, |
|
2539 miniTarRect.iTl.iX,miniTarRect.iBr.iY)); |
|
2540 t23Region.AddRect(TRect(miniTarRect.iBr.iX,miniTarRect.iTl.iY, |
|
2541 t23Rect.iBr.iX,miniTarRect.iBr.iY)); |
|
2542 iCon->SetClippingRegion(&t23Region); |
|
2543 iCon->Clear(); |
|
2544 iCon->DrawBitmapMasked(t23Rect,t23SrcBmp,t23SrcBmp->SizeInPixels(),t23SrcBmpMask,ETrue); |
|
2545 iCon->SetClippingRect(iDev->SizeInPixels()); |
|
2546 |
|
2547 // Compare pixels on device with those from the expected bitmap |
|
2548 TPoint pixel; |
|
2549 TRgb deviceRgb; |
|
2550 TRgb expectedRgb; |
|
2551 TSize t23RectSize(t23Rect.Size()); |
|
2552 CheckL(t23ExpectedBmp->SizeInPixels() == t23RectSize); |
|
2553 for(pixel.iY = t23Rect.iTl.iY; pixel.iY < t23RectSize.iHeight; ++pixel.iY) |
|
2554 { |
|
2555 for(pixel.iX = t23Rect.iTl.iX; pixel.iX < t23RectSize.iWidth; ++pixel.iX) |
|
2556 { |
|
2557 iDev->GetPixel(deviceRgb,pixel); |
|
2558 t23ExpectedBmp->GetPixel(expectedRgb,pixel); |
|
2559 CheckL(deviceRgb == expectedRgb); |
|
2560 } |
|
2561 } |
|
2562 iCon->CancelClippingRect(); |
|
2563 iCon->CancelClippingRegion(); |
|
2564 |
|
2565 CleanupStack::PopAndDestroy(t23ExpectedBmp); |
|
2566 CleanupStack::PopAndDestroy(t23SrcBmpMask); |
|
2567 CleanupStack::PopAndDestroy(t23SrcBmp); |
|
2568 } |
|
2569 |
|
2570 /** |
|
2571 Test Case # 24 (PDEF118404, INC115741) |
|
2572 |
|
2573 Desc : To test the functionality of DrawBitmapMasked() |
|
2574 with destination rectangle multiple of 256. |
|
2575 INC115741 issue with boundary conditions. CFbsBitGc::DoDrawBitmapMasked has KScanLineLength = 256. |
|
2576 Tests fix for PDEF118404. If fix is not present, this test will fail with User Panic 21. |
|
2577 */ |
|
2578 iSection->Delete(iSection->Length() - 2, 2); |
|
2579 iSection->AppendNum(24); |
|
2580 iCon->Clear(); |
|
2581 iCon->DrawBitmap(tarRect,backgroundBmp); |
|
2582 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2583 |
|
2584 // This constant is associated to the value used in CFbsBitGc::DoDrawBitmapMasked. |
|
2585 // If that value is changed, then this one must be updated as well otherwise the test will no longer be valid. |
|
2586 const TInt KScanLineLength = 256; |
|
2587 |
|
2588 tarRect.iTl.SetXY(0,0); |
|
2589 tarRect.SetHeight(2); |
|
2590 for (TInt ii = 1; ii < 5; ++ii) |
|
2591 { |
|
2592 tarRect.SetWidth(KScanLineLength * ii); |
|
2593 iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskblendBmp,EFalse); |
|
2594 } |
|
2595 |
|
2596 CleanupStack::PopAndDestroy(4,backgroundBmp); |
|
2597 } |
|
2598 |
|
2599 // Used to fill the bitmap with a given color for the current display mode. |
|
2600 void TestGdi::FillBitmap(CFbsBitmap* aBitmap, TRgb aRgb) |
|
2601 { |
|
2602 TBitmapUtil bmpUtil(aBitmap); |
|
2603 bmpUtil.Begin(TPoint(0,0)); |
|
2604 for (TInt rowIndex=0;rowIndex<iBitmapHeight;++rowIndex) |
|
2605 { |
|
2606 bmpUtil.SetPos(TPoint(0,rowIndex)); |
|
2607 for (TInt colIndex=0;colIndex<iBitmapWidth;++colIndex) |
|
2608 { |
|
2609 switch(iDev->DisplayMode()) |
|
2610 { |
|
2611 case EGray2: |
|
2612 { |
|
2613 bmpUtil.SetPixel(TRgb::Gray2(aRgb.Blue()).Gray2()); |
|
2614 break; |
|
2615 } |
|
2616 case EGray256: |
|
2617 { |
|
2618 bmpUtil.SetPixel(aRgb.Gray256()); |
|
2619 break; |
|
2620 } |
|
2621 case EColor256: |
|
2622 { |
|
2623 bmpUtil.SetPixel(aRgb.Color256()); |
|
2624 break; |
|
2625 } |
|
2626 case EColor4K: |
|
2627 { |
|
2628 bmpUtil.SetPixel(aRgb.Color4K()); |
|
2629 break; |
|
2630 } |
|
2631 case EColor64K: |
|
2632 { |
|
2633 bmpUtil.SetPixel(aRgb.Color64K()); |
|
2634 break; |
|
2635 } |
|
2636 case EColor16M: |
|
2637 { |
|
2638 bmpUtil.SetPixel(aRgb.Color16M()); |
|
2639 break; |
|
2640 } |
|
2641 case EColor16MU: |
|
2642 { |
|
2643 bmpUtil.SetPixel(aRgb.Color16MU()); |
|
2644 break; |
|
2645 } |
|
2646 } |
|
2647 bmpUtil.IncXPos(); |
|
2648 } |
|
2649 } |
|
2650 bmpUtil.End(); |
|
2651 } |
|
2652 |
|
2653 /** |
|
2654 This test function is added to reproduce the defect INC097853 |
|
2655 (CFbsBitGc::DoDrawBitmapMasked function) in which it |
|
2656 was drawing the first scanline twice. |
|
2657 The steps to reproduce the defect are: |
|
2658 1) Create a Black Background bitmap |
|
2659 2) Create a White Source Bitmap and |
|
2660 3) Create a Gray Masked Bitmap (50% white). |
|
2661 4) Call the function DrawBitmap to draw the Background bitmap |
|
2662 5) Call the function DrawBitmapMasked to draw the Source bitmap with Masked Bitmap |
|
2663 6) Store the screen into a bitmap |
|
2664 */ |
|
2665 void TestGdi::DoDrawBitmapSemiTransparentMaskedL() |
|
2666 { |
|
2667 Clear(); |
|
2668 iCon->Clear(); |
|
2669 _LIT(KBitmapMasked,"DrawBitmapSemiTransparentMasked"); |
|
2670 *iSection = KBitmapMasked; |
|
2671 TInt rowIndex; |
|
2672 TInt colIndex; |
|
2673 TSize rectSize(iBitmapWidth,iBitmapHeight); |
|
2674 TRect srcRect; |
|
2675 TRect tarRect; |
|
2676 |
|
2677 // Create a Black background bitmap |
|
2678 CFbsBitmap* backgroundBmp = new (ELeave) CFbsBitmap; |
|
2679 CleanupStack::PushL(backgroundBmp); |
|
2680 User::LeaveIfError(backgroundBmp->Create(rectSize,iDev->DisplayMode())); |
|
2681 srcRect.SetSize(rectSize); |
|
2682 FillBitmap(backgroundBmp, KRgbBlack); |
|
2683 |
|
2684 //Create a White source bitmap |
|
2685 CFbsBitmap* srcBmp = new (ELeave) CFbsBitmap; |
|
2686 CleanupStack::PushL(srcBmp); |
|
2687 User::LeaveIfError(srcBmp->Create(rectSize,iDev->DisplayMode())); |
|
2688 FillBitmap(srcBmp, KRgbWhite); |
|
2689 |
|
2690 //Create a semi transparent Masked bitmap |
|
2691 CFbsBitmap* maskblendBmp = new (ELeave) CFbsBitmap; |
|
2692 CleanupStack::PushL(maskblendBmp); |
|
2693 |
|
2694 if(iDev->DisplayMode() == EGray2) |
|
2695 { |
|
2696 User::LeaveIfError(maskblendBmp->Create(rectSize,EGray2)); |
|
2697 TBitmapUtil bmpUtil(maskblendBmp); |
|
2698 bmpUtil.Begin(TPoint(0,0)); |
|
2699 for (rowIndex=0;rowIndex<iBitmapHeight;++rowIndex) |
|
2700 { |
|
2701 bmpUtil.SetPos(TPoint(0,rowIndex)); |
|
2702 for(colIndex=0;colIndex<iBitmapWidth;++colIndex) |
|
2703 { |
|
2704 bmpUtil.SetPixel(128); |
|
2705 bmpUtil.IncXPos(); |
|
2706 } |
|
2707 } |
|
2708 bmpUtil.End(); |
|
2709 } |
|
2710 else |
|
2711 { |
|
2712 User::LeaveIfError(maskblendBmp->Create(rectSize,EGray256)); |
|
2713 TRgb rgb(128,128,128); |
|
2714 TBitmapUtil bmpUtil(maskblendBmp); |
|
2715 bmpUtil.Begin(TPoint(0,0)); |
|
2716 for (rowIndex=0;rowIndex<iBitmapHeight;++rowIndex) |
|
2717 { |
|
2718 bmpUtil.SetPos(TPoint(0,rowIndex)); |
|
2719 for(colIndex=0;colIndex<iBitmapWidth;++colIndex) |
|
2720 { |
|
2721 bmpUtil.SetPixel(rgb.Gray256()); |
|
2722 bmpUtil.IncXPos(); |
|
2723 } |
|
2724 } |
|
2725 bmpUtil.End(); |
|
2726 } |
|
2727 |
|
2728 tarRect.iTl.SetXY(0,0); |
|
2729 tarRect.SetWidth(iBitmapWidth*2); |
|
2730 tarRect.SetHeight(iBitmapHeight*2); |
|
2731 if (iDev->SizeInPixels().iWidth>=tarRect.Width() && iDev->SizeInPixels().iHeight>=tarRect.Height()) |
|
2732 { |
|
2733 iCon->DrawBitmap(tarRect,backgroundBmp); |
|
2734 iCon->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
2735 iCon->DrawBitmapMasked(tarRect,srcBmp,srcRect,maskblendBmp,EFalse); |
|
2736 |
|
2737 CheckMaskedResultsL(backgroundBmp,srcBmp,maskblendBmp,tarRect,EFalse,ETrue, ETrue); |
|
2738 } |
|
2739 |
|
2740 CleanupStack::PopAndDestroy(3,backgroundBmp); |
|
2741 } |
|
2742 |
|
2743 void TestGdi::DoFadeL() |
|
2744 { |
|
2745 *iSection = _L("Fade"); |
|
2746 iCon->SetPenStyle(CGraphicsContext::ENullPen); |
|
2747 iCon->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
2748 TInt halfwidth=iSize.iWidth>>1; |
|
2749 TRect lhs(TSize(halfwidth,iSize.iHeight)); |
|
2750 TRect rhs(TPoint(halfwidth,0),TSize(iSize.iWidth,iSize.iHeight)); |
|
2751 TRegionFix<1> area(lhs); |
|
2752 TPoint lhspt(halfwidth>>1,iSize.iHeight>>1); |
|
2753 TPoint rhspt(halfwidth+(halfwidth>>1),iSize.iHeight>>1); |
|
2754 TRgb lhsrgb,rhsrgb; |
|
2755 |
|
2756 for(TInt count=0;count<32;count++) |
|
2757 { |
|
2758 TRgb brushColor; |
|
2759 if (count < 16) |
|
2760 brushColor = TRgb::Gray16(count); |
|
2761 else |
|
2762 brushColor = TRgb::Color16(count - 16); |
|
2763 |
|
2764 if (iDev->DisplayMode() == EGray4) |
|
2765 { |
|
2766 brushColor = TRgb::Gray4(brushColor.Gray4()); |
|
2767 iCon->SetFadingParameters(255,0); |
|
2768 } |
|
2769 |
|
2770 iCon->SetBrushColor(brushColor); |
|
2771 iCon->DrawRect(lhs); |
|
2772 iCon->FadeArea(&area); |
|
2773 iCon->SetFadeMode(ETrue); |
|
2774 iCon->DrawRect(rhs); |
|
2775 iDev->GetPixel(lhsrgb,lhspt); |
|
2776 iDev->GetPixel(rhsrgb,rhspt); |
|
2777 CheckL(lhsrgb==rhsrgb); |
|
2778 iCon->SetFadeMode(EFalse); |
|
2779 } |
|
2780 Clear(); |
|
2781 } |
|
2782 |