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