sl@0
|
1 |
// Copyright (c) 2004-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 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include <e32math.h>
|
sl@0
|
17 |
#include <hal.h>
|
sl@0
|
18 |
#include <bitdraw.h>
|
sl@0
|
19 |
#include <bitdrawscaling.h>
|
sl@0
|
20 |
#include <bitdraworigin.h>
|
sl@0
|
21 |
#include <bitdrawinterfaceid.h>
|
sl@0
|
22 |
#include <graphics/gdi/gdiconsts.h>
|
sl@0
|
23 |
#include "TScdvScaling.h"
|
sl@0
|
24 |
|
sl@0
|
25 |
|
sl@0
|
26 |
|
sl@0
|
27 |
//Test line properties:
|
sl@0
|
28 |
//[iX, iY] - the starting point of the line
|
sl@0
|
29 |
//iLength - line length
|
sl@0
|
30 |
struct TLineProps
|
sl@0
|
31 |
{
|
sl@0
|
32 |
TInt iX;
|
sl@0
|
33 |
TInt iY;
|
sl@0
|
34 |
TInt iLength;
|
sl@0
|
35 |
};
|
sl@0
|
36 |
//
|
sl@0
|
37 |
//Constants
|
sl@0
|
38 |
//
|
sl@0
|
39 |
//This structure defines [TDrawMode <-> clear screen color value] relation
|
sl@0
|
40 |
//When the test uses KDrawMode[i].iDrawMode, then the screen will be cleared using
|
sl@0
|
41 |
//KDrawMode[i].iClearColorVal value
|
sl@0
|
42 |
struct TDrawModeProps
|
sl@0
|
43 |
{
|
sl@0
|
44 |
CGraphicsContext::TDrawMode iDrawMode;
|
sl@0
|
45 |
// keep the color value 8-bit in both EColor256 and EColor64K, special care need
|
sl@0
|
46 |
// to be done when filling the buffer, e.g color=0x55
|
sl@0
|
47 |
// in EColor256 clearing means filling 0x55 0x55 0x55 etc, but
|
sl@0
|
48 |
// in EColor64K it has to be 0x0055 0x0055 0x0055 etc
|
sl@0
|
49 |
TUint8 iClearColorVal;
|
sl@0
|
50 |
};
|
sl@0
|
51 |
const TDrawModeProps KDrawMode[] =
|
sl@0
|
52 |
{
|
sl@0
|
53 |
{CGraphicsContext::EDrawModePEN, 0xFF},
|
sl@0
|
54 |
{CGraphicsContext::EDrawModeAND, 0x37},
|
sl@0
|
55 |
{CGraphicsContext::EDrawModeXOR, 0x38},
|
sl@0
|
56 |
{CGraphicsContext::EDrawModeOR, 0xB1},
|
sl@0
|
57 |
{CGraphicsContext::EDrawModeNOTSCREEN, 0xC0},
|
sl@0
|
58 |
{CGraphicsContext::EDrawModeNOTPEN, 0x1D}
|
sl@0
|
59 |
};
|
sl@0
|
60 |
const TInt KDrawModesCnt = sizeof(KDrawMode) / sizeof(KDrawMode[0]);
|
sl@0
|
61 |
//Shadow/Fade modes
|
sl@0
|
62 |
const CFbsDrawDevice::TShadowMode KShadowMode[] =
|
sl@0
|
63 |
{
|
sl@0
|
64 |
CFbsDrawDevice::EShadow,
|
sl@0
|
65 |
CFbsDrawDevice::EFade,
|
sl@0
|
66 |
CFbsDrawDevice::EShadowFade
|
sl@0
|
67 |
};
|
sl@0
|
68 |
const TInt KShadowModesCnt = sizeof(KShadowMode) / sizeof(KShadowMode[0]);
|
sl@0
|
69 |
//Test pixel color value
|
sl@0
|
70 |
const TUint8 KTestColorVal = 0x55;
|
sl@0
|
71 |
//All possible orientations
|
sl@0
|
72 |
const CFbsDrawDevice::TOrientation KOrientation[] =
|
sl@0
|
73 |
{
|
sl@0
|
74 |
CFbsDrawDevice::EOrientationNormal,
|
sl@0
|
75 |
CFbsDrawDevice::EOrientationRotated90,
|
sl@0
|
76 |
CFbsDrawDevice::EOrientationRotated180,
|
sl@0
|
77 |
CFbsDrawDevice::EOrientationRotated270
|
sl@0
|
78 |
};
|
sl@0
|
79 |
const TInt KOrientationsCnt = sizeof(KOrientation) / sizeof(KOrientation[0]);
|
sl@0
|
80 |
//Width and Height of legacy application screen
|
sl@0
|
81 |
const TInt KLegacyAppSizeWidth = 60;
|
sl@0
|
82 |
const TInt KLegacyAppSizeHeight = 40;
|
sl@0
|
83 |
//Scaling factors: X and Y
|
sl@0
|
84 |
const TInt KScalingFactorX = 3;
|
sl@0
|
85 |
const TInt KScalingFactorY = 2;
|
sl@0
|
86 |
const TInt KMaxScalingFactor = 3; //Max of previous 2 values
|
sl@0
|
87 |
|
sl@0
|
88 |
//
|
sl@0
|
89 |
//Declarations
|
sl@0
|
90 |
//
|
sl@0
|
91 |
GLDEF_C TInt ByteSize(TDisplayMode aDisplayMode,TInt aWidth)
|
sl@0
|
92 |
{
|
sl@0
|
93 |
TInt wordSize=aWidth;
|
sl@0
|
94 |
switch(aDisplayMode)
|
sl@0
|
95 |
{
|
sl@0
|
96 |
case EGray2:
|
sl@0
|
97 |
wordSize = (wordSize + 31) / 32;
|
sl@0
|
98 |
break;
|
sl@0
|
99 |
case EGray4:
|
sl@0
|
100 |
wordSize = (wordSize + 15) / 16;
|
sl@0
|
101 |
break;
|
sl@0
|
102 |
case EGray16:
|
sl@0
|
103 |
case EColor16:
|
sl@0
|
104 |
wordSize = (wordSize + 7) / 8;
|
sl@0
|
105 |
break;
|
sl@0
|
106 |
case EGray256:
|
sl@0
|
107 |
case EColor256:
|
sl@0
|
108 |
wordSize = (wordSize + 3) / 4;
|
sl@0
|
109 |
break;
|
sl@0
|
110 |
case EColor4K:
|
sl@0
|
111 |
case EColor64K:
|
sl@0
|
112 |
wordSize = (wordSize + 1) / 2;
|
sl@0
|
113 |
break;
|
sl@0
|
114 |
case EColor16M:
|
sl@0
|
115 |
wordSize = ((wordSize + 3) / 4) * 3;
|
sl@0
|
116 |
break;
|
sl@0
|
117 |
case EColor16MU:
|
sl@0
|
118 |
case EColor16MA:
|
sl@0
|
119 |
//Doesn't need changing
|
sl@0
|
120 |
break;
|
sl@0
|
121 |
default:
|
sl@0
|
122 |
break;
|
sl@0
|
123 |
};
|
sl@0
|
124 |
return wordSize * 4;
|
sl@0
|
125 |
}
|
sl@0
|
126 |
|
sl@0
|
127 |
static inline TInt ByteSize(TDisplayMode aDisplayMode, TSize aSize)
|
sl@0
|
128 |
{
|
sl@0
|
129 |
return ByteSize(aDisplayMode,aSize.iWidth) * aSize.iHeight;
|
sl@0
|
130 |
}
|
sl@0
|
131 |
|
sl@0
|
132 |
template <class TPixelType>
|
sl@0
|
133 |
inline void MemFill(TPixelType* aBuffer, TInt aSize, TPixelType aValue)
|
sl@0
|
134 |
{
|
sl@0
|
135 |
TPixelType* p = aBuffer;
|
sl@0
|
136 |
TInt i = 0;
|
sl@0
|
137 |
while (i++<aSize)
|
sl@0
|
138 |
*p++ = aValue;
|
sl@0
|
139 |
}
|
sl@0
|
140 |
|
sl@0
|
141 |
//Generic test class for both Color256 and Color64K
|
sl@0
|
142 |
template <class TPixelType> class CTScaling: public CTGraphicsBase
|
sl@0
|
143 |
{
|
sl@0
|
144 |
public:
|
sl@0
|
145 |
CTScaling(CTestStep *aTest, TDisplayMode aDisplayMode);
|
sl@0
|
146 |
~CTScaling();
|
sl@0
|
147 |
void RunTestCaseL(TInt aCurTestCase);
|
sl@0
|
148 |
private:
|
sl@0
|
149 |
void ConstructL();
|
sl@0
|
150 |
void CreateScreenDeviceL();
|
sl@0
|
151 |
void SetScalingSettings(const TPoint& aOrigin, TInt aFx, TInt aFy, TInt aDivX, TInt aDivY);
|
sl@0
|
152 |
void CheckLine(const TLineProps& aLineProps, const TPoint& aOrg, const TDrawModeProps& aDrawModeProps, TPixelType aClearColorValue);
|
sl@0
|
153 |
void CheckWriteRgbMulti(const TRect& aRcProps, const TPoint& aOrg, const TDrawModeProps& aDrawModeProps, TPixelType aClearColorValue);
|
sl@0
|
154 |
void CheckRgbAlphaLine(const TLineProps& aLineProps, const TPoint& aOrg, TPixelType aClearColorValue);
|
sl@0
|
155 |
void CheckRect(const TRect& aRc, const TPoint& aOrg, TPixelType aClearColorValue);
|
sl@0
|
156 |
void WriteLine();
|
sl@0
|
157 |
void ClearScreen(const TDrawModeProps& aDrawModeProps);
|
sl@0
|
158 |
void SetTestData();
|
sl@0
|
159 |
void CheckChangedPixels(TInt aChangedPixelsCnt, TPixelType aClearColorVal);
|
sl@0
|
160 |
void CheckWriteBinary(const TPoint& aPt, const TPoint& aOrg, TPixelType aClearColorValue, TInt aLength, TInt aHeight);
|
sl@0
|
161 |
void CheckVertLine(const TLineProps& aLineProps, const TPoint& aOrg, TPixelType aClearColorValue);
|
sl@0
|
162 |
void WriteRgb();
|
sl@0
|
163 |
void WriteRgbMulti();
|
sl@0
|
164 |
void WriteRgbAlphaLine();
|
sl@0
|
165 |
void WriteBinary();
|
sl@0
|
166 |
void WriteBinaryLineVertical();
|
sl@0
|
167 |
void WriteBinaryLine();
|
sl@0
|
168 |
void WriteRgbAlphaMulti();
|
sl@0
|
169 |
void ShadowArea();
|
sl@0
|
170 |
void WriteRgbAlphaLine2();
|
sl@0
|
171 |
void TestScalingSettingsInterface();
|
sl@0
|
172 |
void PerformanceTest();
|
sl@0
|
173 |
private:
|
sl@0
|
174 |
//Test data array
|
sl@0
|
175 |
TPixelType iTestData[KLegacyAppSizeWidth];
|
sl@0
|
176 |
//The device used in the tests
|
sl@0
|
177 |
CFbsDrawDevice* iDrawDevice;
|
sl@0
|
178 |
//Width and Height of the screen
|
sl@0
|
179 |
TSize iPhysSize;
|
sl@0
|
180 |
//The test allocates block of memory for a screen with PhysSize size
|
sl@0
|
181 |
//mode. iBits will point to the allocated memory block.
|
sl@0
|
182 |
TPixelType* iBits;
|
sl@0
|
183 |
TDisplayMode iDisplayMode;
|
sl@0
|
184 |
//The scaling interface
|
sl@0
|
185 |
MScalingSettings* iScalingSettings;
|
sl@0
|
186 |
//The origin interface
|
sl@0
|
187 |
MDrawDeviceOrigin* iOriginInterface;
|
sl@0
|
188 |
TInt iCurOrientation;
|
sl@0
|
189 |
TInt iScalingFactorX;
|
sl@0
|
190 |
TInt iScalingFactorY;
|
sl@0
|
191 |
};
|
sl@0
|
192 |
typedef CTScaling<TUint8> CTestNone;
|
sl@0
|
193 |
typedef CTScaling<TUint8> CTestColor256;
|
sl@0
|
194 |
typedef CTScaling<TUint16> CTestColor64K;
|
sl@0
|
195 |
|
sl@0
|
196 |
|
sl@0
|
197 |
|
sl@0
|
198 |
//
|
sl@0
|
199 |
//Test code
|
sl@0
|
200 |
//
|
sl@0
|
201 |
/*template <class TPixelType>
|
sl@0
|
202 |
CTScaling<TPixelType>* CTScaling<TPixelType>::NewL(TDisplayMode aDisplayMode)
|
sl@0
|
203 |
{
|
sl@0
|
204 |
CTScaling<TPixelType>* self = new (ELeave) CTScaling<TPixelType>;
|
sl@0
|
205 |
CleanupStack::PushL(self);
|
sl@0
|
206 |
self->ConstructL(aDisplayMode);
|
sl@0
|
207 |
CleanupStack::Pop(self);
|
sl@0
|
208 |
return self;
|
sl@0
|
209 |
}
|
sl@0
|
210 |
*/
|
sl@0
|
211 |
|
sl@0
|
212 |
template <class TPixelType>
|
sl@0
|
213 |
CTScaling<TPixelType>::CTScaling(CTestStep *aTest, TDisplayMode aDisplayMode) :
|
sl@0
|
214 |
CTGraphicsBase(aTest),
|
sl@0
|
215 |
iDisplayMode(aDisplayMode)
|
sl@0
|
216 |
{
|
sl@0
|
217 |
INFO_PRINTF1(_L("Scaling tests"));
|
sl@0
|
218 |
}
|
sl@0
|
219 |
|
sl@0
|
220 |
|
sl@0
|
221 |
template <class TPixelType>
|
sl@0
|
222 |
void CTScaling<TPixelType>::ConstructL()
|
sl@0
|
223 |
{
|
sl@0
|
224 |
CreateScreenDeviceL();
|
sl@0
|
225 |
}
|
sl@0
|
226 |
|
sl@0
|
227 |
template <class TPixelType>
|
sl@0
|
228 |
CTScaling<TPixelType>::~CTScaling()
|
sl@0
|
229 |
{
|
sl@0
|
230 |
((CTScalingStep*)iStep)->CloseTMSGraphicsStep();
|
sl@0
|
231 |
delete[] iBits;
|
sl@0
|
232 |
delete iDrawDevice;
|
sl@0
|
233 |
}
|
sl@0
|
234 |
|
sl@0
|
235 |
template <class TPixelType>
|
sl@0
|
236 |
void CTScaling<TPixelType>::SetScalingSettings(const TPoint& aOrigin, TInt aFx, TInt aFy, TInt aDivX, TInt aDivY)
|
sl@0
|
237 |
{
|
sl@0
|
238 |
TEST(iDrawDevice != NULL);
|
sl@0
|
239 |
if(!iScalingSettings)
|
sl@0
|
240 |
{
|
sl@0
|
241 |
TInt err = iDrawDevice->GetInterface(KScalingSettingsInterfaceID,
|
sl@0
|
242 |
reinterpret_cast <TAny*&> (iScalingSettings));
|
sl@0
|
243 |
TEST2(err, KErrNone);
|
sl@0
|
244 |
}
|
sl@0
|
245 |
TEST(iScalingSettings != NULL);
|
sl@0
|
246 |
TInt err = iScalingSettings->Set(aFx, aFy, aDivX, aDivY);
|
sl@0
|
247 |
TEST2(err, KErrNone);
|
sl@0
|
248 |
if(!iOriginInterface)
|
sl@0
|
249 |
{
|
sl@0
|
250 |
TInt err = iDrawDevice->GetInterface(KDrawDeviceOriginInterfaceID,
|
sl@0
|
251 |
reinterpret_cast <TAny*&> (iOriginInterface));
|
sl@0
|
252 |
TEST2(err, KErrNone);
|
sl@0
|
253 |
}
|
sl@0
|
254 |
TEST(iOriginInterface != NULL);
|
sl@0
|
255 |
err = iOriginInterface->Set(aOrigin);
|
sl@0
|
256 |
TEST2(err, KErrNone);
|
sl@0
|
257 |
}
|
sl@0
|
258 |
|
sl@0
|
259 |
//Clears the screen initializing each screen pixel with aDrawModeProps.iClearColorVal value
|
sl@0
|
260 |
template <class TPixelType>
|
sl@0
|
261 |
void CTScaling<TPixelType>::ClearScreen(const TDrawModeProps& aDrawModeProps)
|
sl@0
|
262 |
{
|
sl@0
|
263 |
::MemFill(iBits, ::ByteSize(EColor256, iPhysSize), TPixelType(aDrawModeProps.iClearColorVal));
|
sl@0
|
264 |
}
|
sl@0
|
265 |
|
sl@0
|
266 |
//Initializes iTestData array with KTestColorVal value
|
sl@0
|
267 |
template <class TPixelType>
|
sl@0
|
268 |
void CTScaling<TPixelType>::SetTestData()
|
sl@0
|
269 |
{
|
sl@0
|
270 |
::MemFill(iTestData, KLegacyAppSizeWidth, TPixelType(KTestColorVal));
|
sl@0
|
271 |
}
|
sl@0
|
272 |
|
sl@0
|
273 |
template <class TPixelType>
|
sl@0
|
274 |
void CTScaling<TPixelType>::CheckChangedPixels(TInt aChangedPixelsCnt, TPixelType aClearColorVal)
|
sl@0
|
275 |
{
|
sl@0
|
276 |
const TInt KByteSize = ::ByteSize(EColor256, iPhysSize);
|
sl@0
|
277 |
TInt changedPixelsCnt = 0;
|
sl@0
|
278 |
for(TInt ii=0;ii<KByteSize;++ii)
|
sl@0
|
279 |
{
|
sl@0
|
280 |
if(iBits[ii]!=aClearColorVal)
|
sl@0
|
281 |
{
|
sl@0
|
282 |
++changedPixelsCnt;
|
sl@0
|
283 |
}
|
sl@0
|
284 |
}
|
sl@0
|
285 |
TEST(changedPixelsCnt == aChangedPixelsCnt);
|
sl@0
|
286 |
if (changedPixelsCnt!=aChangedPixelsCnt)
|
sl@0
|
287 |
{
|
sl@0
|
288 |
_LIT(KLog,"Wrong number of changed pixels, expected=%d, actual=%d, color=0x%x");
|
sl@0
|
289 |
INFO_PRINTF4(KLog,aChangedPixelsCnt,changedPixelsCnt,aClearColorVal);
|
sl@0
|
290 |
}
|
sl@0
|
291 |
}
|
sl@0
|
292 |
|
sl@0
|
293 |
//Checks a set of horisontal lines , which starting point is
|
sl@0
|
294 |
//[aOrg.iX + aLineProps.iX * iScalingFactorX, aOrg.iY + aLineProps.iY * iScalingFactorY]
|
sl@0
|
295 |
//and length is aLineProps.iLength * iScalingFactorX. For each nexh line y-coordinate
|
sl@0
|
296 |
//is incremented by 1.
|
sl@0
|
297 |
//The screen lines pixel values are tested against aClearColorValue value.
|
sl@0
|
298 |
//Then the screen is testsed pixel by pixel that nothing is written outside the tested lines.
|
sl@0
|
299 |
template <class TPixelType>
|
sl@0
|
300 |
void CTScaling<TPixelType>::CheckLine(const TLineProps& aLineProps,
|
sl@0
|
301 |
const TPoint& aOrg,
|
sl@0
|
302 |
const TDrawModeProps& aDrawModeProps,
|
sl@0
|
303 |
TPixelType aClearColorValue)
|
sl@0
|
304 |
{
|
sl@0
|
305 |
TPixelType data[KLegacyAppSizeWidth * KMaxScalingFactor];
|
sl@0
|
306 |
TInt ii;
|
sl@0
|
307 |
for(ii=0;ii<iScalingFactorY;++ii)
|
sl@0
|
308 |
{
|
sl@0
|
309 |
Mem::Fill(data, sizeof(data), 0x00);
|
sl@0
|
310 |
iDrawDevice->ReadLine(aOrg.iX + aLineProps.iX * iScalingFactorX,
|
sl@0
|
311 |
aOrg.iY + aLineProps.iY * iScalingFactorY + ii,
|
sl@0
|
312 |
aLineProps.iLength * iScalingFactorX,
|
sl@0
|
313 |
data,
|
sl@0
|
314 |
iDisplayMode);
|
sl@0
|
315 |
const TInt length=aLineProps.iLength*iScalingFactorX;
|
sl@0
|
316 |
TInt firstErr=length;
|
sl@0
|
317 |
TInt numErrs=0;
|
sl@0
|
318 |
for(TInt jj=0;jj<length;++jj)
|
sl@0
|
319 |
{
|
sl@0
|
320 |
//TEST(data[jj]!=aClearColorValue);
|
sl@0
|
321 |
if (data[jj]==aClearColorValue)
|
sl@0
|
322 |
{
|
sl@0
|
323 |
++numErrs;
|
sl@0
|
324 |
if (jj<firstErr)
|
sl@0
|
325 |
firstErr=jj;
|
sl@0
|
326 |
}
|
sl@0
|
327 |
}
|
sl@0
|
328 |
TEST(numErrs==0);
|
sl@0
|
329 |
if (numErrs>0)
|
sl@0
|
330 |
{
|
sl@0
|
331 |
_LIT(KLog,"Line %d (of %d) of length %d has %d errors first one at %d, ClearCol=0x%x");
|
sl@0
|
332 |
INFO_PRINTF7(KLog,ii,iScalingFactorY,length,numErrs,firstErr,aClearColorValue);
|
sl@0
|
333 |
}
|
sl@0
|
334 |
}
|
sl@0
|
335 |
TInt changedPixelsCnt = iScalingFactorY * aLineProps.iLength * iScalingFactorX;
|
sl@0
|
336 |
CheckChangedPixels(changedPixelsCnt, aDrawModeProps.iClearColorVal);
|
sl@0
|
337 |
}
|
sl@0
|
338 |
|
sl@0
|
339 |
//Checks the rectangle filled using CFbsScreenDevice::WriteRgbMulti.
|
sl@0
|
340 |
//The screen lines pixel values are tested against aClearColorValue value.
|
sl@0
|
341 |
//Then the screen is testsed pixel by pixel that nothing is written outside the tested rectangle.
|
sl@0
|
342 |
template <class TPixelType>
|
sl@0
|
343 |
void CTScaling<TPixelType>::CheckWriteRgbMulti(const TRect& aRcProps,
|
sl@0
|
344 |
const TPoint& aOrg,
|
sl@0
|
345 |
const TDrawModeProps& aDrawModeProps,
|
sl@0
|
346 |
TPixelType aClearColorValue)
|
sl@0
|
347 |
{
|
sl@0
|
348 |
TPixelType data[KLegacyAppSizeWidth * KMaxScalingFactor];
|
sl@0
|
349 |
TInt ii;
|
sl@0
|
350 |
TInt xx = aOrg.iX + aRcProps.iTl.iX * iScalingFactorX;
|
sl@0
|
351 |
TInt yy = aOrg.iY + aRcProps.iTl.iY * iScalingFactorY;
|
sl@0
|
352 |
for(ii=0;ii<(iScalingFactorY * aRcProps.Height());++ii)
|
sl@0
|
353 |
{
|
sl@0
|
354 |
Mem::Fill(data, sizeof(data), 0x00);
|
sl@0
|
355 |
iDrawDevice->ReadLine(xx, yy+ii, aRcProps.Width()*iScalingFactorX, data, iDisplayMode);
|
sl@0
|
356 |
const TInt width=aRcProps.Width()*iScalingFactorX;
|
sl@0
|
357 |
TInt firstErr=width;
|
sl@0
|
358 |
TInt numErrs=0;
|
sl@0
|
359 |
for(TInt jj=0;jj<width;++jj)
|
sl@0
|
360 |
{
|
sl@0
|
361 |
//TEST(data[jj]!=aClearColorValue);
|
sl@0
|
362 |
if (data[jj]==aClearColorValue)
|
sl@0
|
363 |
{
|
sl@0
|
364 |
++numErrs;
|
sl@0
|
365 |
if (jj<firstErr)
|
sl@0
|
366 |
firstErr=jj;
|
sl@0
|
367 |
}
|
sl@0
|
368 |
}
|
sl@0
|
369 |
TEST(numErrs==0);
|
sl@0
|
370 |
if (numErrs>0)
|
sl@0
|
371 |
{
|
sl@0
|
372 |
_LIT(KLog,"Line %d of width %d has %d errors first one at %d, ClearCol=0x%x");
|
sl@0
|
373 |
INFO_PRINTF6(KLog,ii,width,numErrs,firstErr,aClearColorValue);
|
sl@0
|
374 |
}
|
sl@0
|
375 |
}
|
sl@0
|
376 |
TInt changedPixelsCnt = iScalingFactorY * aRcProps.Width() * aRcProps.Height() * iScalingFactorX;
|
sl@0
|
377 |
CheckChangedPixels(changedPixelsCnt, aDrawModeProps.iClearColorVal);
|
sl@0
|
378 |
}
|
sl@0
|
379 |
|
sl@0
|
380 |
//Checks a set of horisontal lines , which starting point is
|
sl@0
|
381 |
//[aOrg.iX + aLineProps.iX * iScalingFactorX, aOrg.iY + aLineProps.iY * iScalingFactorY]
|
sl@0
|
382 |
//and length is aLineProps.iLength * iScalingFactorX. For each nexh line y-coordinate
|
sl@0
|
383 |
//is incremented by 1.
|
sl@0
|
384 |
//The screen lines pixel values are tested against aClearColorValue value.
|
sl@0
|
385 |
//Then the screen is testsed pixel by pixel that nothing is written outside the tested lines.
|
sl@0
|
386 |
template <class TPixelType>
|
sl@0
|
387 |
void CTScaling<TPixelType>::CheckRgbAlphaLine(const TLineProps& aLineProps,
|
sl@0
|
388 |
const TPoint& aOrg,
|
sl@0
|
389 |
TPixelType aClearColorValue)
|
sl@0
|
390 |
{
|
sl@0
|
391 |
TPixelType data[KLegacyAppSizeWidth * KMaxScalingFactor];
|
sl@0
|
392 |
for(TInt ii=0;ii<iScalingFactorY;++ii)
|
sl@0
|
393 |
{
|
sl@0
|
394 |
Mem::Fill(data, sizeof(data), 0x00);
|
sl@0
|
395 |
iDrawDevice->ReadLine(aOrg.iX + aLineProps.iX * iScalingFactorX,
|
sl@0
|
396 |
aOrg.iY + aLineProps.iY * iScalingFactorY + ii,
|
sl@0
|
397 |
aLineProps.iLength * iScalingFactorX,
|
sl@0
|
398 |
data,
|
sl@0
|
399 |
iDisplayMode);
|
sl@0
|
400 |
const TInt length=aLineProps.iLength*iScalingFactorX;
|
sl@0
|
401 |
TInt firstErr=length;
|
sl@0
|
402 |
TInt numErrs=0;
|
sl@0
|
403 |
for(TInt jj=0;jj<(aLineProps.iLength * iScalingFactorX);++jj)
|
sl@0
|
404 |
{
|
sl@0
|
405 |
//TEST(data[jj]!=aClearColorValue);
|
sl@0
|
406 |
if (data[jj]==aClearColorValue)
|
sl@0
|
407 |
{
|
sl@0
|
408 |
++numErrs;
|
sl@0
|
409 |
if (jj<firstErr)
|
sl@0
|
410 |
firstErr=jj;
|
sl@0
|
411 |
}
|
sl@0
|
412 |
}
|
sl@0
|
413 |
TEST(numErrs==0);
|
sl@0
|
414 |
if (numErrs>0)
|
sl@0
|
415 |
{
|
sl@0
|
416 |
_LIT(KLog,"Line %d of length %d has %d errors first one at %d, ClearCol=0x%x");
|
sl@0
|
417 |
INFO_PRINTF6(KLog,ii,length,numErrs,firstErr,aClearColorValue);
|
sl@0
|
418 |
}
|
sl@0
|
419 |
}
|
sl@0
|
420 |
TInt changedPixelsCnt = iScalingFactorY * aLineProps.iLength * iScalingFactorX;
|
sl@0
|
421 |
CheckChangedPixels(changedPixelsCnt, aClearColorValue);
|
sl@0
|
422 |
}
|
sl@0
|
423 |
|
sl@0
|
424 |
//Checks the rectangle filled using CFbsScreenDevice::WriteBinary.
|
sl@0
|
425 |
//The screen lines pixel values are tested against aClearColorValue value.
|
sl@0
|
426 |
//Then the screen is testsed pixel by pixel that nothing is written outside the tested rectangle.
|
sl@0
|
427 |
template <class TPixelType>
|
sl@0
|
428 |
void CTScaling<TPixelType>::CheckWriteBinary(const TPoint& aPt,
|
sl@0
|
429 |
const TPoint& aOrg,
|
sl@0
|
430 |
TPixelType aClearColorValue,
|
sl@0
|
431 |
TInt aLength, TInt aHeight)
|
sl@0
|
432 |
{
|
sl@0
|
433 |
TPixelType data[KLegacyAppSizeWidth * KMaxScalingFactor];
|
sl@0
|
434 |
TInt ii;
|
sl@0
|
435 |
TInt xx = aOrg.iX + aPt.iX * iScalingFactorX;
|
sl@0
|
436 |
TInt yy = aOrg.iY + aPt.iY * iScalingFactorY;
|
sl@0
|
437 |
for(ii=0;ii<(iScalingFactorY * aHeight);++ii)
|
sl@0
|
438 |
{
|
sl@0
|
439 |
Mem::Fill(data, sizeof(data), 0x00);
|
sl@0
|
440 |
iDrawDevice->ReadLine(xx, yy + ii, aLength * iScalingFactorX, data, iDisplayMode);
|
sl@0
|
441 |
const TInt length=aLength*iScalingFactorX;
|
sl@0
|
442 |
TInt firstErr=length;
|
sl@0
|
443 |
TInt numErrs=0;
|
sl@0
|
444 |
for(TInt jj=0;jj<length;++jj)
|
sl@0
|
445 |
{
|
sl@0
|
446 |
//TEST(data[jj] != aClearColorValue);
|
sl@0
|
447 |
if (data[jj]==aClearColorValue)
|
sl@0
|
448 |
{
|
sl@0
|
449 |
++numErrs;
|
sl@0
|
450 |
if (jj<firstErr)
|
sl@0
|
451 |
firstErr=jj;
|
sl@0
|
452 |
}
|
sl@0
|
453 |
}
|
sl@0
|
454 |
TEST(numErrs==0);
|
sl@0
|
455 |
if (numErrs>0)
|
sl@0
|
456 |
{
|
sl@0
|
457 |
_LIT(KLog,"Line %d of length %d has %d errors first one at %d, ClearCol=0x%x");
|
sl@0
|
458 |
INFO_PRINTF6(KLog,ii,length,numErrs,firstErr,aClearColorValue);
|
sl@0
|
459 |
}
|
sl@0
|
460 |
}
|
sl@0
|
461 |
TInt changedPixelsCnt = iScalingFactorY * aLength * aHeight * iScalingFactorX;
|
sl@0
|
462 |
CheckChangedPixels(changedPixelsCnt, aClearColorValue);
|
sl@0
|
463 |
}
|
sl@0
|
464 |
|
sl@0
|
465 |
//Checks a set of vertical lines , which starting point is
|
sl@0
|
466 |
//[aOrg.iX + aLineProps.iX * iScalingFactorX, aOrg.iY + aLineProps.iY * iScalingFactorY]
|
sl@0
|
467 |
//and length is aLineProps.iLength * iScalingFactorX. For each nexh line y-coordinate
|
sl@0
|
468 |
//is incremented by 1.
|
sl@0
|
469 |
//The screen lines pixel values are tested against aClearColorValue value.
|
sl@0
|
470 |
//Then the screen is testsed pixel by pixel that nothing is written outside the tested lines.
|
sl@0
|
471 |
template <class TPixelType>
|
sl@0
|
472 |
void CTScaling<TPixelType>::CheckVertLine(const TLineProps& aLineProps, const TPoint& aOrg, TPixelType aClearColorValue)
|
sl@0
|
473 |
{
|
sl@0
|
474 |
TInt x = aOrg.iX + aLineProps.iX * iScalingFactorX;
|
sl@0
|
475 |
TInt y = aOrg.iY + aLineProps.iY * iScalingFactorY;
|
sl@0
|
476 |
for(TInt i=0;i<iScalingFactorX;++i)
|
sl@0
|
477 |
{
|
sl@0
|
478 |
for(TInt j=0;j<(aLineProps.iLength * iScalingFactorY);++j)
|
sl@0
|
479 |
{
|
sl@0
|
480 |
TRgb val = iDrawDevice->ReadPixel(x + i, y + j);
|
sl@0
|
481 |
switch (iDisplayMode)
|
sl@0
|
482 |
{
|
sl@0
|
483 |
case EColor64K:
|
sl@0
|
484 |
TEST(val.Color64K() != aClearColorValue);
|
sl@0
|
485 |
break;
|
sl@0
|
486 |
|
sl@0
|
487 |
case EColor256:
|
sl@0
|
488 |
TEST(val.Color256() != aClearColorValue);
|
sl@0
|
489 |
break;
|
sl@0
|
490 |
|
sl@0
|
491 |
default:
|
sl@0
|
492 |
TEST(EFalse);
|
sl@0
|
493 |
}
|
sl@0
|
494 |
}
|
sl@0
|
495 |
}
|
sl@0
|
496 |
TInt changedPixelsCnt = iScalingFactorX * aLineProps.iLength * iScalingFactorY;
|
sl@0
|
497 |
CheckChangedPixels(changedPixelsCnt, aClearColorValue);
|
sl@0
|
498 |
}
|
sl@0
|
499 |
|
sl@0
|
500 |
//Checks the rectangle filled using CFbsScreenDevice::ShadowArea
|
sl@0
|
501 |
//The screen lines pixel values are tested against aClearColorValue value.
|
sl@0
|
502 |
//Then the screen is testsed pixel by pixel that nothing is written outside the tested rectangle.
|
sl@0
|
503 |
template <class TPixelType>
|
sl@0
|
504 |
void CTScaling<TPixelType>::CheckRect(const TRect& aRc, const TPoint& aOrg, TPixelType aClearColorValue)
|
sl@0
|
505 |
{
|
sl@0
|
506 |
TPixelType data[KLegacyAppSizeWidth * KMaxScalingFactor];
|
sl@0
|
507 |
TInt i;
|
sl@0
|
508 |
TInt x = aOrg.iX + aRc.iTl.iX * iScalingFactorX;
|
sl@0
|
509 |
TInt y = aOrg.iY + aRc.iTl.iY * iScalingFactorY;
|
sl@0
|
510 |
for(i=0;i<(iScalingFactorY * aRc.Height());++i)
|
sl@0
|
511 |
{
|
sl@0
|
512 |
Mem::Fill(data, sizeof(data), 0x00);
|
sl@0
|
513 |
iDrawDevice->ReadLine(x, y + i, aRc.Width() * iScalingFactorX, data, iDisplayMode);
|
sl@0
|
514 |
for(TInt j=0;j<(aRc.Width() * iScalingFactorX);++j)
|
sl@0
|
515 |
{
|
sl@0
|
516 |
TEST(data[j] != aClearColorValue);
|
sl@0
|
517 |
}
|
sl@0
|
518 |
}
|
sl@0
|
519 |
TInt changedPixelsCnt = iScalingFactorY * aRc.Width() * aRc.Height() * iScalingFactorX;
|
sl@0
|
520 |
CheckChangedPixels(changedPixelsCnt, aClearColorValue);
|
sl@0
|
521 |
}
|
sl@0
|
522 |
|
sl@0
|
523 |
//CFbsScreenDevice::WriteLine() and CFbsScreenDevice::ReadLine() test.
|
sl@0
|
524 |
//(Set of test lines) X (Set of origins) X (Set of drawing modes) number of test cases.
|
sl@0
|
525 |
template <class TPixelType>
|
sl@0
|
526 |
void CTScaling<TPixelType>::WriteLine()
|
sl@0
|
527 |
{
|
sl@0
|
528 |
INFO_PRINTF1(_L("CFbsDrawDevice::WriteLine"));
|
sl@0
|
529 |
|
sl@0
|
530 |
TLineProps lineProps[] =
|
sl@0
|
531 |
{
|
sl@0
|
532 |
{0, 0, KLegacyAppSizeWidth - 1},
|
sl@0
|
533 |
{0, KLegacyAppSizeHeight - 1, KLegacyAppSizeWidth - 1},
|
sl@0
|
534 |
{10, 20, KLegacyAppSizeWidth / 2},
|
sl@0
|
535 |
{-2, -5, 20},
|
sl@0
|
536 |
{-3, 1, 21},
|
sl@0
|
537 |
{2, -2, 11},
|
sl@0
|
538 |
{0, -4, 31},
|
sl@0
|
539 |
{-1, 11, 11}
|
sl@0
|
540 |
};
|
sl@0
|
541 |
const TInt KLinesCnt = sizeof(lineProps) / sizeof(lineProps[0]);
|
sl@0
|
542 |
TPoint ptOrg[] =
|
sl@0
|
543 |
{
|
sl@0
|
544 |
TPoint(13, 21),
|
sl@0
|
545 |
TPoint(10, 17)
|
sl@0
|
546 |
};
|
sl@0
|
547 |
const TInt KOriginsCnt = sizeof(ptOrg) / sizeof(ptOrg[0]);
|
sl@0
|
548 |
for(TInt ll=0;ll<KOriginsCnt;++ll)
|
sl@0
|
549 |
{
|
sl@0
|
550 |
for(TInt line=0;line<KLinesCnt;++line)
|
sl@0
|
551 |
{
|
sl@0
|
552 |
for(TInt kk=0;kk<KDrawModesCnt;++kk)
|
sl@0
|
553 |
{
|
sl@0
|
554 |
ClearScreen(KDrawMode[kk]);
|
sl@0
|
555 |
SetTestData();
|
sl@0
|
556 |
SetScalingSettings(ptOrg[ll], KScalingFactorX, KScalingFactorY, 1, 1);
|
sl@0
|
557 |
iDrawDevice->WriteLine(lineProps[line].iX, lineProps[line].iY,
|
sl@0
|
558 |
lineProps[line].iLength,
|
sl@0
|
559 |
reinterpret_cast <TUint32*> (iTestData),
|
sl@0
|
560 |
KDrawMode[kk].iDrawMode);
|
sl@0
|
561 |
if(KDrawMode[kk].iDrawMode == CGraphicsContext::EDrawModePEN)
|
sl@0
|
562 |
{
|
sl@0
|
563 |
TPixelType writtenData[KLegacyAppSizeWidth];
|
sl@0
|
564 |
Mem::FillZ(writtenData, sizeof(writtenData));
|
sl@0
|
565 |
iDrawDevice->ReadLine(lineProps[line].iX, lineProps[line].iY,
|
sl@0
|
566 |
lineProps[line].iLength,
|
sl@0
|
567 |
writtenData, iDisplayMode);
|
sl@0
|
568 |
for(TInt ii=0;ii<lineProps[line].iLength;++ii)
|
sl@0
|
569 |
{
|
sl@0
|
570 |
TEST(writtenData[ii] == iTestData[ii]);
|
sl@0
|
571 |
}
|
sl@0
|
572 |
}
|
sl@0
|
573 |
SetScalingSettings(TPoint(), 1, 1, 1, 1);
|
sl@0
|
574 |
CheckLine(lineProps[line], ptOrg[ll], KDrawMode[kk], KDrawMode[kk].iClearColorVal);
|
sl@0
|
575 |
}
|
sl@0
|
576 |
}
|
sl@0
|
577 |
}
|
sl@0
|
578 |
}
|
sl@0
|
579 |
|
sl@0
|
580 |
//CFbsScreenDevice::WriteRgb() and CFbsScreenDevice::ReadPixel() test.
|
sl@0
|
581 |
//(Set of test points) X (Set of origins) X (Set of drawing modes) number of test cases.
|
sl@0
|
582 |
template <class TPixelType>
|
sl@0
|
583 |
void CTScaling<TPixelType>::WriteRgb()
|
sl@0
|
584 |
{
|
sl@0
|
585 |
INFO_PRINTF1(_L("CFbsDrawDevice::WriteRgb"));
|
sl@0
|
586 |
|
sl@0
|
587 |
TPoint pt[] =
|
sl@0
|
588 |
{
|
sl@0
|
589 |
TPoint(0, 0),
|
sl@0
|
590 |
TPoint(KLegacyAppSizeWidth - 1, 0),
|
sl@0
|
591 |
TPoint(0, KLegacyAppSizeHeight - 1),
|
sl@0
|
592 |
TPoint(KLegacyAppSizeWidth - 1, KLegacyAppSizeHeight - 1),
|
sl@0
|
593 |
TPoint(KLegacyAppSizeWidth / 2, KLegacyAppSizeHeight / 2),
|
sl@0
|
594 |
TPoint(-2, -3),
|
sl@0
|
595 |
TPoint(0, -1),
|
sl@0
|
596 |
TPoint(-3, 0)
|
sl@0
|
597 |
};
|
sl@0
|
598 |
const TInt KPointsCnt = sizeof(pt) / sizeof(pt[0]);
|
sl@0
|
599 |
TPoint ptOrg[] =
|
sl@0
|
600 |
{
|
sl@0
|
601 |
TPoint(9, 22),
|
sl@0
|
602 |
TPoint(17, 11)
|
sl@0
|
603 |
};
|
sl@0
|
604 |
const TInt KOriginsCnt = sizeof(ptOrg) / sizeof(ptOrg[0]);
|
sl@0
|
605 |
for(TInt l=0;l<KOriginsCnt;++l)
|
sl@0
|
606 |
{
|
sl@0
|
607 |
for(TInt i=0;i<KPointsCnt;++i)
|
sl@0
|
608 |
{
|
sl@0
|
609 |
for(TInt k=0;k<KDrawModesCnt;++k)
|
sl@0
|
610 |
{
|
sl@0
|
611 |
ClearScreen(KDrawMode[k]);
|
sl@0
|
612 |
SetScalingSettings(ptOrg[l], KScalingFactorX, KScalingFactorY, 1, 1);
|
sl@0
|
613 |
TRgb val(KTestColorVal);
|
sl@0
|
614 |
iDrawDevice->WriteRgb(pt[i].iX, pt[i].iY, val, KDrawMode[k].iDrawMode);
|
sl@0
|
615 |
if(KDrawMode[k].iDrawMode == CGraphicsContext::EDrawModePEN)
|
sl@0
|
616 |
{
|
sl@0
|
617 |
TRgb writtenVal = iDrawDevice->ReadPixel(pt[i].iX, pt[i].iY);
|
sl@0
|
618 |
switch (iDisplayMode)
|
sl@0
|
619 |
{
|
sl@0
|
620 |
case EColor64K:
|
sl@0
|
621 |
TEST(writtenVal == TRgb::Color64K(val.Color64K()));
|
sl@0
|
622 |
break;
|
sl@0
|
623 |
|
sl@0
|
624 |
case EColor256:
|
sl@0
|
625 |
TEST(writtenVal == val);
|
sl@0
|
626 |
break;
|
sl@0
|
627 |
|
sl@0
|
628 |
default:
|
sl@0
|
629 |
TEST(EFalse);
|
sl@0
|
630 |
}
|
sl@0
|
631 |
}
|
sl@0
|
632 |
SetScalingSettings(TPoint(0, 0), 1, 1, 1, 1);
|
sl@0
|
633 |
TLineProps props;
|
sl@0
|
634 |
props.iX = pt[i].iX;
|
sl@0
|
635 |
props.iY = pt[i].iY;
|
sl@0
|
636 |
props.iLength = 1;
|
sl@0
|
637 |
CheckLine(props, ptOrg[l], KDrawMode[k], KDrawMode[k].iClearColorVal);
|
sl@0
|
638 |
}
|
sl@0
|
639 |
}
|
sl@0
|
640 |
}
|
sl@0
|
641 |
}
|
sl@0
|
642 |
|
sl@0
|
643 |
//CFbsScreenDevice::WriteRgbMulti() test.
|
sl@0
|
644 |
template <class TPixelType>
|
sl@0
|
645 |
void CTScaling<TPixelType>::WriteRgbMulti()
|
sl@0
|
646 |
{
|
sl@0
|
647 |
INFO_PRINTF1(_L("CFbsDrawDevice::WriteRgbMulti"));
|
sl@0
|
648 |
|
sl@0
|
649 |
TRect rcProps[] =
|
sl@0
|
650 |
{
|
sl@0
|
651 |
TRect(TPoint(0, 0), TSize(KLegacyAppSizeWidth - 1, KLegacyAppSizeHeight - 1)),
|
sl@0
|
652 |
TRect(TPoint(17, 11), TSize(KLegacyAppSizeWidth / 2, KLegacyAppSizeHeight / 2)),
|
sl@0
|
653 |
TRect(TPoint(-1, -4), TSize(31, 12)),
|
sl@0
|
654 |
TRect(TPoint(-3, -1), TSize(11, 11)),
|
sl@0
|
655 |
TRect(TPoint(0, -2), TSize(6, 17))
|
sl@0
|
656 |
};
|
sl@0
|
657 |
const TInt KRcCnt = sizeof(rcProps) / sizeof(rcProps[0]);
|
sl@0
|
658 |
TPoint ptOrg[] =
|
sl@0
|
659 |
{
|
sl@0
|
660 |
TPoint(21, 29),
|
sl@0
|
661 |
TPoint(12, 14)
|
sl@0
|
662 |
};
|
sl@0
|
663 |
const TInt KOriginsCnt = sizeof(ptOrg) / sizeof(ptOrg[0]);
|
sl@0
|
664 |
for(TInt l=0;l<KOriginsCnt;++l)
|
sl@0
|
665 |
{
|
sl@0
|
666 |
for(TInt i=0;i<KRcCnt;++i)
|
sl@0
|
667 |
{
|
sl@0
|
668 |
for(TInt k=0;k<KDrawModesCnt;++k)
|
sl@0
|
669 |
{
|
sl@0
|
670 |
ClearScreen(KDrawMode[k]);
|
sl@0
|
671 |
SetTestData();
|
sl@0
|
672 |
SetScalingSettings(ptOrg[l], KScalingFactorX, KScalingFactorY, 1, 1);
|
sl@0
|
673 |
TRgb val(KTestColorVal);
|
sl@0
|
674 |
iDrawDevice->WriteRgbMulti(rcProps[i].iTl.iX, rcProps[i].iTl.iY,
|
sl@0
|
675 |
rcProps[i].Width(), rcProps[i].Height(),
|
sl@0
|
676 |
val,
|
sl@0
|
677 |
KDrawMode[k].iDrawMode);
|
sl@0
|
678 |
SetScalingSettings(TPoint(0, 0), 1, 1, 1, 1);
|
sl@0
|
679 |
CheckWriteRgbMulti(rcProps[i], ptOrg[l], KDrawMode[k], KDrawMode[k].iClearColorVal);
|
sl@0
|
680 |
}
|
sl@0
|
681 |
}
|
sl@0
|
682 |
}
|
sl@0
|
683 |
}
|
sl@0
|
684 |
|
sl@0
|
685 |
//CFbsScreenDevice::WriteRgbAlphaLine() test.
|
sl@0
|
686 |
//(Set of test lines) X (Set of origins) X (Set of drawing modes) number of test cases.
|
sl@0
|
687 |
template <class TPixelType>
|
sl@0
|
688 |
void CTScaling<TPixelType>::WriteRgbAlphaLine()
|
sl@0
|
689 |
{
|
sl@0
|
690 |
INFO_PRINTF1(_L("CFbsDrawDevice::WriteRgbAlphaLine"));
|
sl@0
|
691 |
|
sl@0
|
692 |
TLineProps lineProps[] =
|
sl@0
|
693 |
{
|
sl@0
|
694 |
{0, 0, KLegacyAppSizeWidth - 1},
|
sl@0
|
695 |
{0, KLegacyAppSizeHeight - 1, KLegacyAppSizeWidth - 1},
|
sl@0
|
696 |
{17, 3, KLegacyAppSizeWidth / 2},
|
sl@0
|
697 |
{-1, -2, 11},
|
sl@0
|
698 |
{-4, -5, 1},
|
sl@0
|
699 |
{0, -1, 3},
|
sl@0
|
700 |
{1, -3, 7}
|
sl@0
|
701 |
};
|
sl@0
|
702 |
const TInt KLinesCnt = sizeof(lineProps) / sizeof(lineProps[0]);
|
sl@0
|
703 |
TPoint ptOrg[] =
|
sl@0
|
704 |
{
|
sl@0
|
705 |
TPoint(19, 17),
|
sl@0
|
706 |
TPoint(29, 25)
|
sl@0
|
707 |
};
|
sl@0
|
708 |
const TInt KOriginsCnt = sizeof(ptOrg) / sizeof(ptOrg[0]);
|
sl@0
|
709 |
for(TInt l=0;l<KOriginsCnt;++l)
|
sl@0
|
710 |
{
|
sl@0
|
711 |
for(TInt i=0;i<KLinesCnt;++i)
|
sl@0
|
712 |
{
|
sl@0
|
713 |
for(TInt k=0;k<KDrawModesCnt;++k)
|
sl@0
|
714 |
{
|
sl@0
|
715 |
ClearScreen(KDrawMode[k]);
|
sl@0
|
716 |
SetScalingSettings(ptOrg[l], KScalingFactorX, KScalingFactorY, 1, 1);
|
sl@0
|
717 |
TUint8 rgbBuff[KLegacyAppSizeWidth * 3];
|
sl@0
|
718 |
Mem::Fill(rgbBuff, sizeof(rgbBuff), KTestColorVal);
|
sl@0
|
719 |
TUint8 maskBuff[KLegacyAppSizeWidth];
|
sl@0
|
720 |
TUint8 maskChar = 0xF1;
|
sl@0
|
721 |
Mem::Fill(maskBuff, sizeof(maskBuff), maskChar);
|
sl@0
|
722 |
iDrawDevice->WriteRgbAlphaLine(lineProps[i].iX, lineProps[i].iY,
|
sl@0
|
723 |
lineProps[i].iLength, rgbBuff, maskBuff, CGraphicsContext::EDrawModePEN);
|
sl@0
|
724 |
SetScalingSettings(TPoint(0, 0), 1, 1, 1, 1);
|
sl@0
|
725 |
CheckRgbAlphaLine(lineProps[i], ptOrg[l], KDrawMode[k].iClearColorVal);
|
sl@0
|
726 |
}
|
sl@0
|
727 |
}
|
sl@0
|
728 |
}
|
sl@0
|
729 |
}
|
sl@0
|
730 |
|
sl@0
|
731 |
//CFbsScreenDevice::WriteBinary() test.
|
sl@0
|
732 |
template <class TPixelType>
|
sl@0
|
733 |
void CTScaling<TPixelType>::WriteBinary()
|
sl@0
|
734 |
{
|
sl@0
|
735 |
INFO_PRINTF1(_L("CFbsDrawDevice::WriteBinary"));
|
sl@0
|
736 |
|
sl@0
|
737 |
TPoint pt[] =
|
sl@0
|
738 |
{
|
sl@0
|
739 |
TPoint(0, 0),
|
sl@0
|
740 |
TPoint(27, 19),
|
sl@0
|
741 |
TPoint(-4, -4),
|
sl@0
|
742 |
TPoint(-1, -2),
|
sl@0
|
743 |
TPoint(-1, -2),
|
sl@0
|
744 |
TPoint(5, -5),
|
sl@0
|
745 |
TPoint(-5, 0)
|
sl@0
|
746 |
};
|
sl@0
|
747 |
const TInt KPtCnt = sizeof(pt) / sizeof(pt[0]);
|
sl@0
|
748 |
TPoint ptOrg[] =
|
sl@0
|
749 |
{
|
sl@0
|
750 |
TPoint(19, 24),
|
sl@0
|
751 |
TPoint(29, 26)
|
sl@0
|
752 |
};
|
sl@0
|
753 |
const TInt KOriginsCnt = sizeof(ptOrg) / sizeof(ptOrg[0]);
|
sl@0
|
754 |
for(TInt l=0;l<KOriginsCnt;++l)
|
sl@0
|
755 |
{
|
sl@0
|
756 |
for(TInt i=0;i<KPtCnt;++i)
|
sl@0
|
757 |
{
|
sl@0
|
758 |
for(TInt k=0;k<KDrawModesCnt;++k)
|
sl@0
|
759 |
{
|
sl@0
|
760 |
ClearScreen(KDrawMode[k]);
|
sl@0
|
761 |
SetTestData();
|
sl@0
|
762 |
SetScalingSettings(ptOrg[l], KScalingFactorX, KScalingFactorY, 1, 1);
|
sl@0
|
763 |
const TInt KHeight = 5;
|
sl@0
|
764 |
const TInt KLength = 11;
|
sl@0
|
765 |
TUint32 buff[KHeight];
|
sl@0
|
766 |
TUint32 buffChar = 0xFFFFFFFF;
|
sl@0
|
767 |
for(TInt ooo=0;ooo<KHeight;++ooo)
|
sl@0
|
768 |
{
|
sl@0
|
769 |
buff[ooo] = buffChar;
|
sl@0
|
770 |
}
|
sl@0
|
771 |
TRgb val(KTestColorVal);
|
sl@0
|
772 |
iDrawDevice->WriteBinary(pt[i].iX, pt[i].iY, buff, KLength, KHeight,
|
sl@0
|
773 |
val, KDrawMode[k].iDrawMode);
|
sl@0
|
774 |
SetScalingSettings(TPoint(0, 0), 1, 1, 1, 1);
|
sl@0
|
775 |
CheckWriteBinary(pt[i], ptOrg[l], KDrawMode[k].iClearColorVal, KLength, KHeight);
|
sl@0
|
776 |
}
|
sl@0
|
777 |
}
|
sl@0
|
778 |
}
|
sl@0
|
779 |
}
|
sl@0
|
780 |
|
sl@0
|
781 |
//CFbsScreenDevice::WriteBinaryLineVertical() test.
|
sl@0
|
782 |
template <class TPixelType>
|
sl@0
|
783 |
void CTScaling<TPixelType>::WriteBinaryLineVertical()
|
sl@0
|
784 |
{
|
sl@0
|
785 |
INFO_PRINTF1(_L("CFbsDrawDevice::WriteBinaryLineVertical"));
|
sl@0
|
786 |
|
sl@0
|
787 |
TLineProps lineProps[] =
|
sl@0
|
788 |
{
|
sl@0
|
789 |
{0, 0, KLegacyAppSizeHeight - 1},
|
sl@0
|
790 |
{KLegacyAppSizeWidth - 1, 0, KLegacyAppSizeHeight - 1},
|
sl@0
|
791 |
{17, 3, 23},
|
sl@0
|
792 |
{-2, -5, 10},
|
sl@0
|
793 |
{-6, 24, 11},
|
sl@0
|
794 |
{18, -6, 12},
|
sl@0
|
795 |
{0, -3, 13},
|
sl@0
|
796 |
{-1, 0, 14}
|
sl@0
|
797 |
};
|
sl@0
|
798 |
const TInt KLinesCnt = sizeof(lineProps) / sizeof(lineProps[0]);
|
sl@0
|
799 |
TPoint ptOrg[] =
|
sl@0
|
800 |
{
|
sl@0
|
801 |
TPoint(22, 22),
|
sl@0
|
802 |
TPoint(19, 20)
|
sl@0
|
803 |
};
|
sl@0
|
804 |
const TInt KOriginsCnt = sizeof(ptOrg) / sizeof(ptOrg[0]);
|
sl@0
|
805 |
for(TInt l=0;l<KOriginsCnt;++l)
|
sl@0
|
806 |
{
|
sl@0
|
807 |
for(TInt i=0;i<KLinesCnt;++i)
|
sl@0
|
808 |
{
|
sl@0
|
809 |
for(TInt k=0;k<KDrawModesCnt;++k)
|
sl@0
|
810 |
{
|
sl@0
|
811 |
ClearScreen(KDrawMode[k]);
|
sl@0
|
812 |
SetTestData();
|
sl@0
|
813 |
SetScalingSettings(ptOrg[l], KScalingFactorX, KScalingFactorY, 1, 1);
|
sl@0
|
814 |
const TInt KLength = 30;
|
sl@0
|
815 |
TUint32 buff[KLength];
|
sl@0
|
816 |
TUint32 buffChar = 0xFFFFFFFF;
|
sl@0
|
817 |
for(TInt ooo=0;ooo<KLength;++ooo)
|
sl@0
|
818 |
{
|
sl@0
|
819 |
buff[ooo] = buffChar;
|
sl@0
|
820 |
}
|
sl@0
|
821 |
TRgb val(KTestColorVal);
|
sl@0
|
822 |
iDrawDevice->WriteBinaryLineVertical(lineProps[i].iX, lineProps[i].iY,
|
sl@0
|
823 |
buff, lineProps[i].iLength, val,
|
sl@0
|
824 |
KDrawMode[k].iDrawMode, EFalse);
|
sl@0
|
825 |
SetScalingSettings(TPoint(0, 0), 1, 1, 1, 1);
|
sl@0
|
826 |
CheckVertLine(lineProps[i], ptOrg[l], KDrawMode[k].iClearColorVal);
|
sl@0
|
827 |
}
|
sl@0
|
828 |
}
|
sl@0
|
829 |
}
|
sl@0
|
830 |
}
|
sl@0
|
831 |
|
sl@0
|
832 |
//CFbsScreenDevice::WriteBinaryLine() test.
|
sl@0
|
833 |
template <class TPixelType>
|
sl@0
|
834 |
void CTScaling<TPixelType>::WriteBinaryLine()
|
sl@0
|
835 |
{
|
sl@0
|
836 |
INFO_PRINTF1(_L("CFbsDrawDevice::WriteBinaryLiine"));
|
sl@0
|
837 |
|
sl@0
|
838 |
TPoint pt[] =
|
sl@0
|
839 |
{
|
sl@0
|
840 |
TPoint(0, 0),
|
sl@0
|
841 |
TPoint(1, 7),
|
sl@0
|
842 |
TPoint(18, -8),
|
sl@0
|
843 |
TPoint(-7, 26),
|
sl@0
|
844 |
TPoint(-4, -7),
|
sl@0
|
845 |
TPoint(0, -2),
|
sl@0
|
846 |
TPoint(34, -1),
|
sl@0
|
847 |
TPoint(-1, 17)
|
sl@0
|
848 |
};
|
sl@0
|
849 |
const TInt KPtCnt = sizeof(pt) / sizeof(pt[0]);
|
sl@0
|
850 |
TPoint ptOrg[] =
|
sl@0
|
851 |
{
|
sl@0
|
852 |
TPoint(21, 35),
|
sl@0
|
853 |
TPoint(40, 28)
|
sl@0
|
854 |
};
|
sl@0
|
855 |
const TInt KOriginsCnt = sizeof(ptOrg) / sizeof(ptOrg[0]);
|
sl@0
|
856 |
for(TInt l=0;l<KOriginsCnt;++l)
|
sl@0
|
857 |
{
|
sl@0
|
858 |
for(TInt i=0;i<KPtCnt;++i)
|
sl@0
|
859 |
{
|
sl@0
|
860 |
for(TInt k=0;k<KDrawModesCnt;++k)
|
sl@0
|
861 |
{
|
sl@0
|
862 |
ClearScreen(KDrawMode[k]);
|
sl@0
|
863 |
SetTestData();
|
sl@0
|
864 |
SetScalingSettings(ptOrg[l], KScalingFactorX, KScalingFactorY, 1, 1);
|
sl@0
|
865 |
const TInt KHeight = 1;
|
sl@0
|
866 |
const TInt KLength = 11;
|
sl@0
|
867 |
TUint32 buff[KHeight];
|
sl@0
|
868 |
TUint32 buffChar = 0xFFFFFFFF;
|
sl@0
|
869 |
for(TInt ooo=0;ooo<KHeight;++ooo)
|
sl@0
|
870 |
{
|
sl@0
|
871 |
buff[ooo] = buffChar;
|
sl@0
|
872 |
}
|
sl@0
|
873 |
TRgb val(KTestColorVal);
|
sl@0
|
874 |
iDrawDevice->WriteBinaryLine(pt[i].iX, pt[i].iY, buff, KLength,
|
sl@0
|
875 |
val, KDrawMode[k].iDrawMode);
|
sl@0
|
876 |
SetScalingSettings(TPoint(0, 0), 1, 1, 1, 1);
|
sl@0
|
877 |
CheckWriteBinary(pt[i], ptOrg[l], KDrawMode[k].iClearColorVal, KLength, KHeight);
|
sl@0
|
878 |
}
|
sl@0
|
879 |
}
|
sl@0
|
880 |
}
|
sl@0
|
881 |
}
|
sl@0
|
882 |
|
sl@0
|
883 |
//CFbsScreenDevice::WriteRgbAlphaMulti() test.
|
sl@0
|
884 |
template <class TPixelType>
|
sl@0
|
885 |
void CTScaling<TPixelType>::WriteRgbAlphaMulti()
|
sl@0
|
886 |
{
|
sl@0
|
887 |
INFO_PRINTF1(_L("CFbsDrawDevice::WriteRgbAlphaMulti"));
|
sl@0
|
888 |
|
sl@0
|
889 |
TLineProps lineProps[] =
|
sl@0
|
890 |
{
|
sl@0
|
891 |
{0, 0, KLegacyAppSizeWidth - 1},
|
sl@0
|
892 |
{0, KLegacyAppSizeHeight - 1, KLegacyAppSizeWidth - 1},
|
sl@0
|
893 |
{17, 3, KLegacyAppSizeWidth / 2},
|
sl@0
|
894 |
{-8, -8, 11},
|
sl@0
|
895 |
{-3, 15, 12},
|
sl@0
|
896 |
{29, -4, 13},
|
sl@0
|
897 |
{0, -3, 14},
|
sl@0
|
898 |
{-5, 0, 15}
|
sl@0
|
899 |
};
|
sl@0
|
900 |
const TInt KLinesCnt = sizeof(lineProps) / sizeof(lineProps[0]);
|
sl@0
|
901 |
TPoint ptOrg[] =
|
sl@0
|
902 |
{
|
sl@0
|
903 |
TPoint(24, 17),
|
sl@0
|
904 |
TPoint(27, 20)
|
sl@0
|
905 |
};
|
sl@0
|
906 |
const TInt KOriginsCnt = sizeof(ptOrg) / sizeof(ptOrg[0]);
|
sl@0
|
907 |
for(TInt l=0;l<KOriginsCnt;++l)
|
sl@0
|
908 |
{
|
sl@0
|
909 |
for(TInt i=0;i<KLinesCnt;++i)
|
sl@0
|
910 |
{
|
sl@0
|
911 |
for(TInt k=0;k<KDrawModesCnt;++k)
|
sl@0
|
912 |
{
|
sl@0
|
913 |
ClearScreen(KDrawMode[k]);
|
sl@0
|
914 |
SetTestData();
|
sl@0
|
915 |
SetScalingSettings(ptOrg[l], KScalingFactorX, KScalingFactorY, 1, 1);
|
sl@0
|
916 |
TUint8 maskBuff[KLegacyAppSizeWidth];
|
sl@0
|
917 |
TUint8 maskChar = 0xF1;
|
sl@0
|
918 |
Mem::Fill(maskBuff, sizeof(maskBuff), maskChar);
|
sl@0
|
919 |
TRgb val(KTestColorVal);
|
sl@0
|
920 |
iDrawDevice->WriteRgbAlphaMulti(lineProps[i].iX, lineProps[i].iY,
|
sl@0
|
921 |
lineProps[i].iLength, val, maskBuff);
|
sl@0
|
922 |
SetScalingSettings(TPoint(0, 0), 1, 1, 1, 1);
|
sl@0
|
923 |
CheckRgbAlphaLine(lineProps[i], ptOrg[l], KDrawMode[k].iClearColorVal);
|
sl@0
|
924 |
}
|
sl@0
|
925 |
}
|
sl@0
|
926 |
}
|
sl@0
|
927 |
}
|
sl@0
|
928 |
|
sl@0
|
929 |
//CFbsScreenDevice::ShadowArea() test.
|
sl@0
|
930 |
template <class TPixelType>
|
sl@0
|
931 |
void CTScaling<TPixelType>::ShadowArea()
|
sl@0
|
932 |
{
|
sl@0
|
933 |
INFO_PRINTF1(_L("CFbsDrawDevice::ShadowArea"));
|
sl@0
|
934 |
|
sl@0
|
935 |
TRect rcProps[] =
|
sl@0
|
936 |
{
|
sl@0
|
937 |
TRect(TPoint(0, 0), TSize(KLegacyAppSizeWidth - 1, KLegacyAppSizeHeight - 1)),
|
sl@0
|
938 |
TRect(TPoint(17, 11), TSize(KLegacyAppSizeWidth / 2, KLegacyAppSizeHeight / 2)),
|
sl@0
|
939 |
TRect(TPoint(-1, -1), TSize(1, 1)),
|
sl@0
|
940 |
TRect(TPoint(-4, -5), TSize(11, 8)),
|
sl@0
|
941 |
TRect(TPoint(0, -6), TSize(3, 23)),
|
sl@0
|
942 |
TRect(TPoint(-7, 0), TSize(24, 2)),
|
sl@0
|
943 |
TRect(TPoint(5, -2), TSize(8, 9)),
|
sl@0
|
944 |
TRect(TPoint(-4, 16), TSize(11, 8))
|
sl@0
|
945 |
};
|
sl@0
|
946 |
const TInt KRcCnt = sizeof(rcProps) / sizeof(rcProps[0]);
|
sl@0
|
947 |
TPoint ptOrg[] =
|
sl@0
|
948 |
{
|
sl@0
|
949 |
TPoint(25, 24),
|
sl@0
|
950 |
TPoint(31, 29)
|
sl@0
|
951 |
};
|
sl@0
|
952 |
const TInt KOriginsCnt = sizeof(ptOrg) / sizeof(ptOrg[0]);
|
sl@0
|
953 |
for(TInt l=0;l<KOriginsCnt;++l)
|
sl@0
|
954 |
{
|
sl@0
|
955 |
for(TInt i=0;i<KRcCnt;++i)
|
sl@0
|
956 |
{
|
sl@0
|
957 |
for(TInt k=0;k<KDrawModesCnt;++k)
|
sl@0
|
958 |
{
|
sl@0
|
959 |
TDrawModeProps drawModeProps(KDrawMode[k]);
|
sl@0
|
960 |
--drawModeProps.iClearColorVal;//I want to avoid "255" clear color value.
|
sl@0
|
961 |
for(TInt m=0;m<KShadowModesCnt;++m)
|
sl@0
|
962 |
{
|
sl@0
|
963 |
iDrawDevice->SetShadowMode(KShadowMode[m]);
|
sl@0
|
964 |
ClearScreen(drawModeProps);
|
sl@0
|
965 |
SetTestData();
|
sl@0
|
966 |
SetScalingSettings(ptOrg[l], KScalingFactorX, KScalingFactorY, 1, 1);
|
sl@0
|
967 |
iDrawDevice->ShadowArea(rcProps[i]);
|
sl@0
|
968 |
SetScalingSettings(TPoint(0, 0), 1, 1, 1, 1);
|
sl@0
|
969 |
CheckRect(rcProps[i], ptOrg[l], drawModeProps.iClearColorVal);
|
sl@0
|
970 |
}
|
sl@0
|
971 |
}
|
sl@0
|
972 |
}
|
sl@0
|
973 |
}
|
sl@0
|
974 |
iDrawDevice->SetShadowMode(CFbsDrawDevice::ENoShadow);
|
sl@0
|
975 |
}
|
sl@0
|
976 |
|
sl@0
|
977 |
//CFbsScreenDevice::WriteRgbAlphaLine() test.
|
sl@0
|
978 |
template <class TPixelType>
|
sl@0
|
979 |
void CTScaling<TPixelType>::WriteRgbAlphaLine2()
|
sl@0
|
980 |
{
|
sl@0
|
981 |
INFO_PRINTF1(_L("CFbsDrawDevice::WriteRgbAlphaLine-2"));
|
sl@0
|
982 |
|
sl@0
|
983 |
TLineProps lineProps[] =
|
sl@0
|
984 |
{
|
sl@0
|
985 |
{0, 0, KLegacyAppSizeWidth - 1},
|
sl@0
|
986 |
{0, KLegacyAppSizeHeight - 1, KLegacyAppSizeWidth - 1},
|
sl@0
|
987 |
{17, 3, KLegacyAppSizeWidth / 2},
|
sl@0
|
988 |
{-1, -7, 11},
|
sl@0
|
989 |
{0, -5, 12},
|
sl@0
|
990 |
{-3, 0, 13},
|
sl@0
|
991 |
{15, -7, 14},
|
sl@0
|
992 |
{-1, -7, 15},
|
sl@0
|
993 |
{-1, -7, 16}
|
sl@0
|
994 |
};
|
sl@0
|
995 |
const TInt KLinesCnt = sizeof(lineProps) / sizeof(lineProps[0]);
|
sl@0
|
996 |
TPoint ptOrg[] =
|
sl@0
|
997 |
{
|
sl@0
|
998 |
TPoint(18, 28),
|
sl@0
|
999 |
TPoint(15, 15)
|
sl@0
|
1000 |
};
|
sl@0
|
1001 |
const TInt KOriginsCnt = sizeof(ptOrg) / sizeof(ptOrg[0]);
|
sl@0
|
1002 |
for(TInt l=0;l<KOriginsCnt;++l)
|
sl@0
|
1003 |
{
|
sl@0
|
1004 |
for(TInt i=0;i<KLinesCnt;++i)
|
sl@0
|
1005 |
{
|
sl@0
|
1006 |
for(TInt k=0;k<KDrawModesCnt;++k)
|
sl@0
|
1007 |
{
|
sl@0
|
1008 |
ClearScreen(KDrawMode[k]);
|
sl@0
|
1009 |
SetTestData();
|
sl@0
|
1010 |
SetScalingSettings(ptOrg[l], KScalingFactorX, KScalingFactorY, 1, 1);
|
sl@0
|
1011 |
TUint8 rgbBuff1[KLegacyAppSizeWidth * 3];
|
sl@0
|
1012 |
TUint8 rgbBuff2[KLegacyAppSizeWidth * 3];
|
sl@0
|
1013 |
Mem::Fill(rgbBuff1, sizeof(rgbBuff1), KTestColorVal - 15);
|
sl@0
|
1014 |
Mem::Fill(rgbBuff2, sizeof(rgbBuff2), KTestColorVal + 22);
|
sl@0
|
1015 |
TUint8 maskBuff[KLegacyAppSizeWidth];
|
sl@0
|
1016 |
TUint8 maskChar = 0xF1;
|
sl@0
|
1017 |
Mem::Fill(maskBuff, sizeof(maskBuff), maskChar);
|
sl@0
|
1018 |
iDrawDevice->WriteRgbAlphaLine(lineProps[i].iX, lineProps[i].iY,
|
sl@0
|
1019 |
lineProps[i].iLength, rgbBuff1, rgbBuff2, maskBuff,
|
sl@0
|
1020 |
KDrawMode[k].iDrawMode);
|
sl@0
|
1021 |
SetScalingSettings(TPoint(0, 0), 1, 1, 1, 1);
|
sl@0
|
1022 |
CheckRgbAlphaLine(lineProps[i], ptOrg[l], KDrawMode[k].iClearColorVal);
|
sl@0
|
1023 |
}
|
sl@0
|
1024 |
}
|
sl@0
|
1025 |
}
|
sl@0
|
1026 |
}
|
sl@0
|
1027 |
|
sl@0
|
1028 |
template <class TPixelType>
|
sl@0
|
1029 |
void CTScaling<TPixelType>::TestScalingSettingsInterface()
|
sl@0
|
1030 |
{
|
sl@0
|
1031 |
INFO_PRINTF1(_L("MScalingSettings functionality test"));
|
sl@0
|
1032 |
TEST(iDrawDevice != NULL);
|
sl@0
|
1033 |
|
sl@0
|
1034 |
MScalingSettings* scalingSettings = NULL;
|
sl@0
|
1035 |
TInt err = iDrawDevice->GetInterface(KScalingSettingsInterfaceID,
|
sl@0
|
1036 |
reinterpret_cast <TAny*&> (scalingSettings));
|
sl@0
|
1037 |
TEST2(err, KErrNone);
|
sl@0
|
1038 |
TEST(scalingSettings != NULL);
|
sl@0
|
1039 |
|
sl@0
|
1040 |
TEST(scalingSettings->IsScalingOff());
|
sl@0
|
1041 |
|
sl@0
|
1042 |
const TInt factorXIn = 10, factorYIn = 13, divisorXIn = 1, divisorYIn = 1;
|
sl@0
|
1043 |
TInt factorXOut = -1, factorYOut = -1, divisorXOut = -1, divisorYOut = -1;
|
sl@0
|
1044 |
|
sl@0
|
1045 |
err = scalingSettings->Set(factorXIn, factorYIn, divisorXIn, divisorYIn);
|
sl@0
|
1046 |
TEST2(err, KErrNone);
|
sl@0
|
1047 |
TEST(!scalingSettings->IsScalingOff());
|
sl@0
|
1048 |
scalingSettings->Get(factorXOut, factorYOut, divisorXOut, divisorYOut);
|
sl@0
|
1049 |
|
sl@0
|
1050 |
TEST(factorXOut == factorXOut);
|
sl@0
|
1051 |
TEST(factorYIn == factorYOut);
|
sl@0
|
1052 |
TEST(divisorXIn == divisorXOut);
|
sl@0
|
1053 |
TEST(divisorYIn == divisorYOut);
|
sl@0
|
1054 |
|
sl@0
|
1055 |
MDrawDeviceOrigin* originInterface = NULL;
|
sl@0
|
1056 |
err = iDrawDevice->GetInterface(KDrawDeviceOriginInterfaceID,
|
sl@0
|
1057 |
reinterpret_cast <TAny*&> (originInterface));
|
sl@0
|
1058 |
TEST2(err, KErrNone);
|
sl@0
|
1059 |
TEST(originInterface != NULL);
|
sl@0
|
1060 |
|
sl@0
|
1061 |
const TPoint ptOriginIn(20, 45);
|
sl@0
|
1062 |
TPoint ptOriginOut;
|
sl@0
|
1063 |
err = originInterface->Set(ptOriginIn);
|
sl@0
|
1064 |
TEST2(err, KErrNone);
|
sl@0
|
1065 |
originInterface->Get(ptOriginOut);
|
sl@0
|
1066 |
TEST(ptOriginIn == ptOriginOut);
|
sl@0
|
1067 |
|
sl@0
|
1068 |
SetScalingSettings(TPoint(0, 0), 1, 1, 1, 1);
|
sl@0
|
1069 |
}
|
sl@0
|
1070 |
|
sl@0
|
1071 |
//Creates screen device and initializes ::DrawDevice global variable.
|
sl@0
|
1072 |
template <class TPixelType>
|
sl@0
|
1073 |
void CTScaling<TPixelType>::CreateScreenDeviceL()
|
sl@0
|
1074 |
{
|
sl@0
|
1075 |
if (iDisplayMode == ENone)
|
sl@0
|
1076 |
return;
|
sl@0
|
1077 |
|
sl@0
|
1078 |
TInt address = NULL;
|
sl@0
|
1079 |
User::LeaveIfError(HAL::Get(KDefaultScreenNo, HALData::EDisplayMemoryAddress,address));
|
sl@0
|
1080 |
User::LeaveIfError(HAL::Get(KDefaultScreenNo, HALData::EDisplayXPixels, iPhysSize.iWidth));
|
sl@0
|
1081 |
User::LeaveIfError(HAL::Get(KDefaultScreenNo, HALData::EDisplayYPixels, iPhysSize.iHeight));
|
sl@0
|
1082 |
__ASSERT_DEBUG(iPhysSize.iWidth > 0 && iPhysSize.iHeight > 0 && address != NULL, User::Invariant());
|
sl@0
|
1083 |
|
sl@0
|
1084 |
TPckgBuf<TScreenInfoV01> info;
|
sl@0
|
1085 |
info().iScreenAddressValid = ETrue;
|
sl@0
|
1086 |
info().iScreenAddress = reinterpret_cast <void*> (address);
|
sl@0
|
1087 |
info().iScreenSize = iPhysSize;
|
sl@0
|
1088 |
|
sl@0
|
1089 |
iDrawDevice = CFbsDrawDevice::NewScreenDeviceL(info(), iDisplayMode);
|
sl@0
|
1090 |
TestScalingSettingsInterface();
|
sl@0
|
1091 |
iBits = new (ELeave) TPixelType[::ByteSize(EColor256, iPhysSize)];
|
sl@0
|
1092 |
iDrawDevice->SetUserDisplayMode(iDisplayMode);
|
sl@0
|
1093 |
iDrawDevice->SetAutoUpdate(EFalse);
|
sl@0
|
1094 |
iDrawDevice->SetBits(iBits);
|
sl@0
|
1095 |
|
sl@0
|
1096 |
|
sl@0
|
1097 |
}
|
sl@0
|
1098 |
|
sl@0
|
1099 |
template <class TPixelType>
|
sl@0
|
1100 |
void CTScaling<TPixelType>::PerformanceTest()
|
sl@0
|
1101 |
{
|
sl@0
|
1102 |
INFO_PRINTF1(_L("CFbsDrawDevice, scaling - WriteRgb() performance test"));
|
sl@0
|
1103 |
|
sl@0
|
1104 |
const TInt KDrawingsCnt = 1000000;
|
sl@0
|
1105 |
TInt i, x, y;
|
sl@0
|
1106 |
|
sl@0
|
1107 |
TUint time1 = User::TickCount();
|
sl@0
|
1108 |
x = y = 0;
|
sl@0
|
1109 |
for(i=0;i<KDrawingsCnt;i++)
|
sl@0
|
1110 |
{
|
sl@0
|
1111 |
if(++x > 50)
|
sl@0
|
1112 |
{
|
sl@0
|
1113 |
x = 0;
|
sl@0
|
1114 |
if(++y > 50)
|
sl@0
|
1115 |
{
|
sl@0
|
1116 |
y = 0;
|
sl@0
|
1117 |
}
|
sl@0
|
1118 |
}
|
sl@0
|
1119 |
TRgb val(0x11, 0x12, i);
|
sl@0
|
1120 |
iDrawDevice->WriteRgb(x, y, val, CGraphicsContext::EDrawModePEN);
|
sl@0
|
1121 |
}
|
sl@0
|
1122 |
time1 = User::TickCount() - time1;
|
sl@0
|
1123 |
|
sl@0
|
1124 |
TPoint ptOrigin(5, 3);
|
sl@0
|
1125 |
SetScalingSettings(ptOrigin, KScalingFactorX, KScalingFactorY, 1, 1);
|
sl@0
|
1126 |
|
sl@0
|
1127 |
TUint time2 = User::TickCount();
|
sl@0
|
1128 |
x = y = 0;
|
sl@0
|
1129 |
for(i=0;i<KDrawingsCnt;i++)
|
sl@0
|
1130 |
{
|
sl@0
|
1131 |
if(++x > 50)
|
sl@0
|
1132 |
{
|
sl@0
|
1133 |
x = 0;
|
sl@0
|
1134 |
if(++y > 50)
|
sl@0
|
1135 |
{
|
sl@0
|
1136 |
y = 0;
|
sl@0
|
1137 |
}
|
sl@0
|
1138 |
}
|
sl@0
|
1139 |
TRgb val(0x11, 0x12, i);
|
sl@0
|
1140 |
iDrawDevice->WriteRgb(x, y, val, CGraphicsContext::EDrawModePEN);
|
sl@0
|
1141 |
}
|
sl@0
|
1142 |
time2 = User::TickCount() - time2;
|
sl@0
|
1143 |
|
sl@0
|
1144 |
SetScalingSettings(TPoint(0, 0), 1, 1, 1, 1);
|
sl@0
|
1145 |
|
sl@0
|
1146 |
RDebug::Print(_L("Non-scaled device, time=%d\r\n"), time1);
|
sl@0
|
1147 |
RDebug::Print(_L("Scaled device, time=%d\r\n"), time2);
|
sl@0
|
1148 |
}
|
sl@0
|
1149 |
|
sl@0
|
1150 |
template <class TPixelType>
|
sl@0
|
1151 |
void CTScaling<TPixelType>::RunTestCaseL(TInt aCurTestCase)
|
sl@0
|
1152 |
{
|
sl@0
|
1153 |
// EColor64K and EColor256 is not supported, stop the test
|
sl@0
|
1154 |
if (iDisplayMode == ENone)
|
sl@0
|
1155 |
{
|
sl@0
|
1156 |
INFO_PRINTF1(_L("EColor64K and EColor256 are not supported, The test is not run"));
|
sl@0
|
1157 |
TestComplete();
|
sl@0
|
1158 |
}
|
sl@0
|
1159 |
|
sl@0
|
1160 |
else
|
sl@0
|
1161 |
{
|
sl@0
|
1162 |
((CTScalingStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
|
sl@0
|
1163 |
switch(aCurTestCase)
|
sl@0
|
1164 |
{
|
sl@0
|
1165 |
case 1:
|
sl@0
|
1166 |
{
|
sl@0
|
1167 |
if(iCurOrientation >= KOrientationsCnt)
|
sl@0
|
1168 |
{
|
sl@0
|
1169 |
((CTScalingStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
|
sl@0
|
1170 |
TestComplete();
|
sl@0
|
1171 |
}
|
sl@0
|
1172 |
else
|
sl@0
|
1173 |
{
|
sl@0
|
1174 |
((CTScalingStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
|
sl@0
|
1175 |
if (iCurOrientation==CFbsDrawDevice::EOrientationRotated90 || iCurOrientation==CFbsDrawDevice::EOrientationRotated270)
|
sl@0
|
1176 |
{
|
sl@0
|
1177 |
iScalingFactorX=KScalingFactorY;
|
sl@0
|
1178 |
iScalingFactorY=KScalingFactorX;
|
sl@0
|
1179 |
}
|
sl@0
|
1180 |
else
|
sl@0
|
1181 |
{
|
sl@0
|
1182 |
iScalingFactorX=KScalingFactorX;
|
sl@0
|
1183 |
iScalingFactorY=KScalingFactorY;
|
sl@0
|
1184 |
}
|
sl@0
|
1185 |
INFO_PRINTF3(_L("Set scalling %d,%d"),iScalingFactorX,iScalingFactorY);
|
sl@0
|
1186 |
if(iDrawDevice->SetOrientation(KOrientation[iCurOrientation]))
|
sl@0
|
1187 |
{
|
sl@0
|
1188 |
INFO_PRINTF2(_L("Set orientation: ===EOrientation%S==="),&RotationName(iCurOrientation));
|
sl@0
|
1189 |
}
|
sl@0
|
1190 |
else
|
sl@0
|
1191 |
{
|
sl@0
|
1192 |
INFO_PRINTF2(_L("Failed to set orientation: ===EOrientation%S==="),&RotationName(iCurOrientation));
|
sl@0
|
1193 |
ResetCounter();
|
sl@0
|
1194 |
}
|
sl@0
|
1195 |
iCurOrientation++;
|
sl@0
|
1196 |
}
|
sl@0
|
1197 |
}
|
sl@0
|
1198 |
break;
|
sl@0
|
1199 |
case 2:
|
sl@0
|
1200 |
/**
|
sl@0
|
1201 |
@SYMTestCaseID GRAPHICS-SCREENDRIVER-0022
|
sl@0
|
1202 |
*/
|
sl@0
|
1203 |
((CTScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0022"));
|
sl@0
|
1204 |
WriteLine();
|
sl@0
|
1205 |
break;
|
sl@0
|
1206 |
case 3:
|
sl@0
|
1207 |
/**
|
sl@0
|
1208 |
@SYMTestCaseID GRAPHICS-SCREENDRIVER-0023
|
sl@0
|
1209 |
*/
|
sl@0
|
1210 |
((CTScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0023"));
|
sl@0
|
1211 |
WriteRgb();
|
sl@0
|
1212 |
break;
|
sl@0
|
1213 |
case 4:
|
sl@0
|
1214 |
/**
|
sl@0
|
1215 |
@SYMTestCaseID GRAPHICS-SCREENDRIVER-0024
|
sl@0
|
1216 |
*/
|
sl@0
|
1217 |
((CTScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0024"));
|
sl@0
|
1218 |
WriteRgbMulti();
|
sl@0
|
1219 |
break;
|
sl@0
|
1220 |
case 5:
|
sl@0
|
1221 |
/**
|
sl@0
|
1222 |
@SYMTestCaseID GRAPHICS-SCREENDRIVER-0025
|
sl@0
|
1223 |
*/
|
sl@0
|
1224 |
((CTScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0025"));
|
sl@0
|
1225 |
WriteRgbAlphaLine();
|
sl@0
|
1226 |
break;
|
sl@0
|
1227 |
case 6:
|
sl@0
|
1228 |
/**
|
sl@0
|
1229 |
@SYMTestCaseID GRAPHICS-SCREENDRIVER-0026
|
sl@0
|
1230 |
*/
|
sl@0
|
1231 |
((CTScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0026"));
|
sl@0
|
1232 |
WriteBinary();
|
sl@0
|
1233 |
break;
|
sl@0
|
1234 |
case 7:
|
sl@0
|
1235 |
/**
|
sl@0
|
1236 |
@SYMTestCaseID GRAPHICS-SCREENDRIVER-0027
|
sl@0
|
1237 |
*/
|
sl@0
|
1238 |
((CTScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0027"));
|
sl@0
|
1239 |
WriteBinaryLineVertical();
|
sl@0
|
1240 |
break;
|
sl@0
|
1241 |
case 8:
|
sl@0
|
1242 |
/**
|
sl@0
|
1243 |
@SYMTestCaseID GRAPHICS-SCREENDRIVER-0028
|
sl@0
|
1244 |
*/
|
sl@0
|
1245 |
((CTScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0028"));
|
sl@0
|
1246 |
WriteBinaryLine();
|
sl@0
|
1247 |
break;
|
sl@0
|
1248 |
case 9:
|
sl@0
|
1249 |
/**
|
sl@0
|
1250 |
@SYMTestCaseID GRAPHICS-SCREENDRIVER-0029
|
sl@0
|
1251 |
*/
|
sl@0
|
1252 |
((CTScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0029"));
|
sl@0
|
1253 |
WriteRgbAlphaMulti();
|
sl@0
|
1254 |
break;
|
sl@0
|
1255 |
case 10:
|
sl@0
|
1256 |
/**
|
sl@0
|
1257 |
@SYMTestCaseID GRAPHICS-SCREENDRIVER-0030
|
sl@0
|
1258 |
*/
|
sl@0
|
1259 |
((CTScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0030"));
|
sl@0
|
1260 |
ShadowArea();
|
sl@0
|
1261 |
break;
|
sl@0
|
1262 |
case 11:
|
sl@0
|
1263 |
/**
|
sl@0
|
1264 |
@SYMTestCaseID GRAPHICS-SCREENDRIVER-0031
|
sl@0
|
1265 |
*/
|
sl@0
|
1266 |
((CTScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0031"));
|
sl@0
|
1267 |
WriteRgbAlphaLine2();
|
sl@0
|
1268 |
break;
|
sl@0
|
1269 |
case 12:
|
sl@0
|
1270 |
/**
|
sl@0
|
1271 |
@SYMTestCaseID GRAPHICS-SCREENDRIVER-0032
|
sl@0
|
1272 |
*/
|
sl@0
|
1273 |
((CTScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0032"));
|
sl@0
|
1274 |
PerformanceTest();
|
sl@0
|
1275 |
break;
|
sl@0
|
1276 |
case 13:
|
sl@0
|
1277 |
((CTScalingStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
|
sl@0
|
1278 |
ResetCounter();
|
sl@0
|
1279 |
break;
|
sl@0
|
1280 |
}
|
sl@0
|
1281 |
((CTScalingStep*)iStep)->RecordTestResultL();
|
sl@0
|
1282 |
}
|
sl@0
|
1283 |
}
|
sl@0
|
1284 |
|
sl@0
|
1285 |
static TDisplayMode GetDisplayModeL()
|
sl@0
|
1286 |
{
|
sl@0
|
1287 |
TDisplayMode mode = EColor64K;
|
sl@0
|
1288 |
CFbsDrawDevice* device = NULL;
|
sl@0
|
1289 |
TRAPD(err, device = CFbsDrawDevice::NewScreenDeviceL(KDefaultScreenNo, mode));
|
sl@0
|
1290 |
if (err!=KErrNone)
|
sl@0
|
1291 |
{
|
sl@0
|
1292 |
mode = EColor256;
|
sl@0
|
1293 |
TRAPD(err, device = CFbsDrawDevice::NewScreenDeviceL(KDefaultScreenNo, mode));
|
sl@0
|
1294 |
|
sl@0
|
1295 |
if (err == KErrNotSupported)
|
sl@0
|
1296 |
{
|
sl@0
|
1297 |
return ENone;
|
sl@0
|
1298 |
}
|
sl@0
|
1299 |
}
|
sl@0
|
1300 |
delete device;
|
sl@0
|
1301 |
return mode;
|
sl@0
|
1302 |
}
|
sl@0
|
1303 |
|
sl@0
|
1304 |
//---------------
|
sl@0
|
1305 |
CTScalingStep::CTScalingStep()
|
sl@0
|
1306 |
{
|
sl@0
|
1307 |
SetTestStepName(KTScalingStep);
|
sl@0
|
1308 |
}
|
sl@0
|
1309 |
|
sl@0
|
1310 |
CTGraphicsBase* CTScalingStep::CreateTestL()
|
sl@0
|
1311 |
{
|
sl@0
|
1312 |
CTGraphicsBase* theTest = NULL;
|
sl@0
|
1313 |
switch (GetDisplayModeL())
|
sl@0
|
1314 |
{
|
sl@0
|
1315 |
case EColor64K:
|
sl@0
|
1316 |
{
|
sl@0
|
1317 |
INFO_PRINTF1(_L("Scaling - EColor64K"));
|
sl@0
|
1318 |
theTest = new (ELeave) CTestColor64K(this, EColor64K);
|
sl@0
|
1319 |
}
|
sl@0
|
1320 |
break;
|
sl@0
|
1321 |
|
sl@0
|
1322 |
case EColor256:
|
sl@0
|
1323 |
{
|
sl@0
|
1324 |
INFO_PRINTF1(_L("Scaling - EColor256"));
|
sl@0
|
1325 |
theTest = new (ELeave) CTestColor256(this, EColor256);
|
sl@0
|
1326 |
}
|
sl@0
|
1327 |
break;
|
sl@0
|
1328 |
|
sl@0
|
1329 |
default:
|
sl@0
|
1330 |
INFO_PRINTF1(_L("EColor64K and EColor256 are not supported"));
|
sl@0
|
1331 |
theTest = new (ELeave) CTestNone(this, ENone);
|
sl@0
|
1332 |
}
|
sl@0
|
1333 |
return theTest;
|
sl@0
|
1334 |
}
|
sl@0
|
1335 |
|
sl@0
|
1336 |
void CTScalingStep::TestSetupL()
|
sl@0
|
1337 |
{
|
sl@0
|
1338 |
TInt temp = 0;
|
sl@0
|
1339 |
HAL::Get(KDefaultScreenNo, HALData::EDisplayColors, temp);//force HAL memory allocation
|
sl@0
|
1340 |
|
sl@0
|
1341 |
}
|