Update contrib.
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 #include <bitdrawscaling.h>
20 #include <bitdraworigin.h>
21 #include <bitdrawinterfaceid.h>
22 #include <graphics/gdi/gdiconsts.h>
23 #include "TScdvScaling.h"
27 //Test line properties:
28 //[iX, iY] - the starting point of the line
29 //iLength - line length
39 //This structure defines [TDrawMode <-> clear screen color value] relation
40 //When the test uses KDrawMode[i].iDrawMode, then the screen will be cleared using
41 //KDrawMode[i].iClearColorVal value
44 CGraphicsContext::TDrawMode iDrawMode;
45 // keep the color value 8-bit in both EColor256 and EColor64K, special care need
46 // to be done when filling the buffer, e.g color=0x55
47 // in EColor256 clearing means filling 0x55 0x55 0x55 etc, but
48 // in EColor64K it has to be 0x0055 0x0055 0x0055 etc
49 TUint8 iClearColorVal;
51 const TDrawModeProps KDrawMode[] =
53 {CGraphicsContext::EDrawModePEN, 0xFF},
54 {CGraphicsContext::EDrawModeAND, 0x37},
55 {CGraphicsContext::EDrawModeXOR, 0x38},
56 {CGraphicsContext::EDrawModeOR, 0xB1},
57 {CGraphicsContext::EDrawModeNOTSCREEN, 0xC0},
58 {CGraphicsContext::EDrawModeNOTPEN, 0x1D}
60 const TInt KDrawModesCnt = sizeof(KDrawMode) / sizeof(KDrawMode[0]);
62 const CFbsDrawDevice::TShadowMode KShadowMode[] =
64 CFbsDrawDevice::EShadow,
65 CFbsDrawDevice::EFade,
66 CFbsDrawDevice::EShadowFade
68 const TInt KShadowModesCnt = sizeof(KShadowMode) / sizeof(KShadowMode[0]);
69 //Test pixel color value
70 const TUint8 KTestColorVal = 0x55;
71 //All possible orientations
72 const CFbsDrawDevice::TOrientation KOrientation[] =
74 CFbsDrawDevice::EOrientationNormal,
75 CFbsDrawDevice::EOrientationRotated90,
76 CFbsDrawDevice::EOrientationRotated180,
77 CFbsDrawDevice::EOrientationRotated270
79 const TInt KOrientationsCnt = sizeof(KOrientation) / sizeof(KOrientation[0]);
80 //Width and Height of legacy application screen
81 const TInt KLegacyAppSizeWidth = 60;
82 const TInt KLegacyAppSizeHeight = 40;
83 //Scaling factors: X and Y
84 const TInt KScalingFactorX = 3;
85 const TInt KScalingFactorY = 2;
86 const TInt KMaxScalingFactor = 3; //Max of previous 2 values
91 GLDEF_C TInt ByteSize(TDisplayMode aDisplayMode,TInt aWidth)
97 wordSize = (wordSize + 31) / 32;
100 wordSize = (wordSize + 15) / 16;
104 wordSize = (wordSize + 7) / 8;
108 wordSize = (wordSize + 3) / 4;
112 wordSize = (wordSize + 1) / 2;
115 wordSize = ((wordSize + 3) / 4) * 3;
119 //Doesn't need changing
127 static inline TInt ByteSize(TDisplayMode aDisplayMode, TSize aSize)
129 return ByteSize(aDisplayMode,aSize.iWidth) * aSize.iHeight;
132 template <class TPixelType>
133 inline void MemFill(TPixelType* aBuffer, TInt aSize, TPixelType aValue)
135 TPixelType* p = aBuffer;
141 //Generic test class for both Color256 and Color64K
142 template <class TPixelType> class CTScaling: public CTGraphicsBase
145 CTScaling(CTestStep *aTest, TDisplayMode aDisplayMode);
147 void RunTestCaseL(TInt aCurTestCase);
150 void CreateScreenDeviceL();
151 void SetScalingSettings(const TPoint& aOrigin, TInt aFx, TInt aFy, TInt aDivX, TInt aDivY);
152 void CheckLine(const TLineProps& aLineProps, const TPoint& aOrg, const TDrawModeProps& aDrawModeProps, TPixelType aClearColorValue);
153 void CheckWriteRgbMulti(const TRect& aRcProps, const TPoint& aOrg, const TDrawModeProps& aDrawModeProps, TPixelType aClearColorValue);
154 void CheckRgbAlphaLine(const TLineProps& aLineProps, const TPoint& aOrg, TPixelType aClearColorValue);
155 void CheckRect(const TRect& aRc, const TPoint& aOrg, TPixelType aClearColorValue);
157 void ClearScreen(const TDrawModeProps& aDrawModeProps);
159 void CheckChangedPixels(TInt aChangedPixelsCnt, TPixelType aClearColorVal);
160 void CheckWriteBinary(const TPoint& aPt, const TPoint& aOrg, TPixelType aClearColorValue, TInt aLength, TInt aHeight);
161 void CheckVertLine(const TLineProps& aLineProps, const TPoint& aOrg, TPixelType aClearColorValue);
163 void WriteRgbMulti();
164 void WriteRgbAlphaLine();
166 void WriteBinaryLineVertical();
167 void WriteBinaryLine();
168 void WriteRgbAlphaMulti();
170 void WriteRgbAlphaLine2();
171 void TestScalingSettingsInterface();
172 void PerformanceTest();
175 TPixelType iTestData[KLegacyAppSizeWidth];
176 //The device used in the tests
177 CFbsDrawDevice* iDrawDevice;
178 //Width and Height of the screen
180 //The test allocates block of memory for a screen with PhysSize size
181 //mode. iBits will point to the allocated memory block.
183 TDisplayMode iDisplayMode;
184 //The scaling interface
185 MScalingSettings* iScalingSettings;
186 //The origin interface
187 MDrawDeviceOrigin* iOriginInterface;
188 TInt iCurOrientation;
189 TInt iScalingFactorX;
190 TInt iScalingFactorY;
192 typedef CTScaling<TUint8> CTestNone;
193 typedef CTScaling<TUint8> CTestColor256;
194 typedef CTScaling<TUint16> CTestColor64K;
201 /*template <class TPixelType>
202 CTScaling<TPixelType>* CTScaling<TPixelType>::NewL(TDisplayMode aDisplayMode)
204 CTScaling<TPixelType>* self = new (ELeave) CTScaling<TPixelType>;
205 CleanupStack::PushL(self);
206 self->ConstructL(aDisplayMode);
207 CleanupStack::Pop(self);
212 template <class TPixelType>
213 CTScaling<TPixelType>::CTScaling(CTestStep *aTest, TDisplayMode aDisplayMode) :
214 CTGraphicsBase(aTest),
215 iDisplayMode(aDisplayMode)
217 INFO_PRINTF1(_L("Scaling tests"));
221 template <class TPixelType>
222 void CTScaling<TPixelType>::ConstructL()
224 CreateScreenDeviceL();
227 template <class TPixelType>
228 CTScaling<TPixelType>::~CTScaling()
230 ((CTScalingStep*)iStep)->CloseTMSGraphicsStep();
235 template <class TPixelType>
236 void CTScaling<TPixelType>::SetScalingSettings(const TPoint& aOrigin, TInt aFx, TInt aFy, TInt aDivX, TInt aDivY)
238 TEST(iDrawDevice != NULL);
239 if(!iScalingSettings)
241 TInt err = iDrawDevice->GetInterface(KScalingSettingsInterfaceID,
242 reinterpret_cast <TAny*&> (iScalingSettings));
243 TEST2(err, KErrNone);
245 TEST(iScalingSettings != NULL);
246 TInt err = iScalingSettings->Set(aFx, aFy, aDivX, aDivY);
247 TEST2(err, KErrNone);
248 if(!iOriginInterface)
250 TInt err = iDrawDevice->GetInterface(KDrawDeviceOriginInterfaceID,
251 reinterpret_cast <TAny*&> (iOriginInterface));
252 TEST2(err, KErrNone);
254 TEST(iOriginInterface != NULL);
255 err = iOriginInterface->Set(aOrigin);
256 TEST2(err, KErrNone);
259 //Clears the screen initializing each screen pixel with aDrawModeProps.iClearColorVal value
260 template <class TPixelType>
261 void CTScaling<TPixelType>::ClearScreen(const TDrawModeProps& aDrawModeProps)
263 ::MemFill(iBits, ::ByteSize(EColor256, iPhysSize), TPixelType(aDrawModeProps.iClearColorVal));
266 //Initializes iTestData array with KTestColorVal value
267 template <class TPixelType>
268 void CTScaling<TPixelType>::SetTestData()
270 ::MemFill(iTestData, KLegacyAppSizeWidth, TPixelType(KTestColorVal));
273 template <class TPixelType>
274 void CTScaling<TPixelType>::CheckChangedPixels(TInt aChangedPixelsCnt, TPixelType aClearColorVal)
276 const TInt KByteSize = ::ByteSize(EColor256, iPhysSize);
277 TInt changedPixelsCnt = 0;
278 for(TInt ii=0;ii<KByteSize;++ii)
280 if(iBits[ii]!=aClearColorVal)
285 TEST(changedPixelsCnt == aChangedPixelsCnt);
286 if (changedPixelsCnt!=aChangedPixelsCnt)
288 _LIT(KLog,"Wrong number of changed pixels, expected=%d, actual=%d, color=0x%x");
289 INFO_PRINTF4(KLog,aChangedPixelsCnt,changedPixelsCnt,aClearColorVal);
293 //Checks a set of horisontal lines , which starting point is
294 //[aOrg.iX + aLineProps.iX * iScalingFactorX, aOrg.iY + aLineProps.iY * iScalingFactorY]
295 //and length is aLineProps.iLength * iScalingFactorX. For each nexh line y-coordinate
296 //is incremented by 1.
297 //The screen lines pixel values are tested against aClearColorValue value.
298 //Then the screen is testsed pixel by pixel that nothing is written outside the tested lines.
299 template <class TPixelType>
300 void CTScaling<TPixelType>::CheckLine(const TLineProps& aLineProps,
302 const TDrawModeProps& aDrawModeProps,
303 TPixelType aClearColorValue)
305 TPixelType data[KLegacyAppSizeWidth * KMaxScalingFactor];
307 for(ii=0;ii<iScalingFactorY;++ii)
309 Mem::Fill(data, sizeof(data), 0x00);
310 iDrawDevice->ReadLine(aOrg.iX + aLineProps.iX * iScalingFactorX,
311 aOrg.iY + aLineProps.iY * iScalingFactorY + ii,
312 aLineProps.iLength * iScalingFactorX,
315 const TInt length=aLineProps.iLength*iScalingFactorX;
316 TInt firstErr=length;
318 for(TInt jj=0;jj<length;++jj)
320 //TEST(data[jj]!=aClearColorValue);
321 if (data[jj]==aClearColorValue)
331 _LIT(KLog,"Line %d (of %d) of length %d has %d errors first one at %d, ClearCol=0x%x");
332 INFO_PRINTF7(KLog,ii,iScalingFactorY,length,numErrs,firstErr,aClearColorValue);
335 TInt changedPixelsCnt = iScalingFactorY * aLineProps.iLength * iScalingFactorX;
336 CheckChangedPixels(changedPixelsCnt, aDrawModeProps.iClearColorVal);
339 //Checks the rectangle filled using CFbsScreenDevice::WriteRgbMulti.
340 //The screen lines pixel values are tested against aClearColorValue value.
341 //Then the screen is testsed pixel by pixel that nothing is written outside the tested rectangle.
342 template <class TPixelType>
343 void CTScaling<TPixelType>::CheckWriteRgbMulti(const TRect& aRcProps,
345 const TDrawModeProps& aDrawModeProps,
346 TPixelType aClearColorValue)
348 TPixelType data[KLegacyAppSizeWidth * KMaxScalingFactor];
350 TInt xx = aOrg.iX + aRcProps.iTl.iX * iScalingFactorX;
351 TInt yy = aOrg.iY + aRcProps.iTl.iY * iScalingFactorY;
352 for(ii=0;ii<(iScalingFactorY * aRcProps.Height());++ii)
354 Mem::Fill(data, sizeof(data), 0x00);
355 iDrawDevice->ReadLine(xx, yy+ii, aRcProps.Width()*iScalingFactorX, data, iDisplayMode);
356 const TInt width=aRcProps.Width()*iScalingFactorX;
359 for(TInt jj=0;jj<width;++jj)
361 //TEST(data[jj]!=aClearColorValue);
362 if (data[jj]==aClearColorValue)
372 _LIT(KLog,"Line %d of width %d has %d errors first one at %d, ClearCol=0x%x");
373 INFO_PRINTF6(KLog,ii,width,numErrs,firstErr,aClearColorValue);
376 TInt changedPixelsCnt = iScalingFactorY * aRcProps.Width() * aRcProps.Height() * iScalingFactorX;
377 CheckChangedPixels(changedPixelsCnt, aDrawModeProps.iClearColorVal);
380 //Checks a set of horisontal lines , which starting point is
381 //[aOrg.iX + aLineProps.iX * iScalingFactorX, aOrg.iY + aLineProps.iY * iScalingFactorY]
382 //and length is aLineProps.iLength * iScalingFactorX. For each nexh line y-coordinate
383 //is incremented by 1.
384 //The screen lines pixel values are tested against aClearColorValue value.
385 //Then the screen is testsed pixel by pixel that nothing is written outside the tested lines.
386 template <class TPixelType>
387 void CTScaling<TPixelType>::CheckRgbAlphaLine(const TLineProps& aLineProps,
389 TPixelType aClearColorValue)
391 TPixelType data[KLegacyAppSizeWidth * KMaxScalingFactor];
392 for(TInt ii=0;ii<iScalingFactorY;++ii)
394 Mem::Fill(data, sizeof(data), 0x00);
395 iDrawDevice->ReadLine(aOrg.iX + aLineProps.iX * iScalingFactorX,
396 aOrg.iY + aLineProps.iY * iScalingFactorY + ii,
397 aLineProps.iLength * iScalingFactorX,
400 const TInt length=aLineProps.iLength*iScalingFactorX;
401 TInt firstErr=length;
403 for(TInt jj=0;jj<(aLineProps.iLength * iScalingFactorX);++jj)
405 //TEST(data[jj]!=aClearColorValue);
406 if (data[jj]==aClearColorValue)
416 _LIT(KLog,"Line %d of length %d has %d errors first one at %d, ClearCol=0x%x");
417 INFO_PRINTF6(KLog,ii,length,numErrs,firstErr,aClearColorValue);
420 TInt changedPixelsCnt = iScalingFactorY * aLineProps.iLength * iScalingFactorX;
421 CheckChangedPixels(changedPixelsCnt, aClearColorValue);
424 //Checks the rectangle filled using CFbsScreenDevice::WriteBinary.
425 //The screen lines pixel values are tested against aClearColorValue value.
426 //Then the screen is testsed pixel by pixel that nothing is written outside the tested rectangle.
427 template <class TPixelType>
428 void CTScaling<TPixelType>::CheckWriteBinary(const TPoint& aPt,
430 TPixelType aClearColorValue,
431 TInt aLength, TInt aHeight)
433 TPixelType data[KLegacyAppSizeWidth * KMaxScalingFactor];
435 TInt xx = aOrg.iX + aPt.iX * iScalingFactorX;
436 TInt yy = aOrg.iY + aPt.iY * iScalingFactorY;
437 for(ii=0;ii<(iScalingFactorY * aHeight);++ii)
439 Mem::Fill(data, sizeof(data), 0x00);
440 iDrawDevice->ReadLine(xx, yy + ii, aLength * iScalingFactorX, data, iDisplayMode);
441 const TInt length=aLength*iScalingFactorX;
442 TInt firstErr=length;
444 for(TInt jj=0;jj<length;++jj)
446 //TEST(data[jj] != aClearColorValue);
447 if (data[jj]==aClearColorValue)
457 _LIT(KLog,"Line %d of length %d has %d errors first one at %d, ClearCol=0x%x");
458 INFO_PRINTF6(KLog,ii,length,numErrs,firstErr,aClearColorValue);
461 TInt changedPixelsCnt = iScalingFactorY * aLength * aHeight * iScalingFactorX;
462 CheckChangedPixels(changedPixelsCnt, aClearColorValue);
465 //Checks a set of vertical lines , which starting point is
466 //[aOrg.iX + aLineProps.iX * iScalingFactorX, aOrg.iY + aLineProps.iY * iScalingFactorY]
467 //and length is aLineProps.iLength * iScalingFactorX. For each nexh line y-coordinate
468 //is incremented by 1.
469 //The screen lines pixel values are tested against aClearColorValue value.
470 //Then the screen is testsed pixel by pixel that nothing is written outside the tested lines.
471 template <class TPixelType>
472 void CTScaling<TPixelType>::CheckVertLine(const TLineProps& aLineProps, const TPoint& aOrg, TPixelType aClearColorValue)
474 TInt x = aOrg.iX + aLineProps.iX * iScalingFactorX;
475 TInt y = aOrg.iY + aLineProps.iY * iScalingFactorY;
476 for(TInt i=0;i<iScalingFactorX;++i)
478 for(TInt j=0;j<(aLineProps.iLength * iScalingFactorY);++j)
480 TRgb val = iDrawDevice->ReadPixel(x + i, y + j);
481 switch (iDisplayMode)
484 TEST(val.Color64K() != aClearColorValue);
488 TEST(val.Color256() != aClearColorValue);
496 TInt changedPixelsCnt = iScalingFactorX * aLineProps.iLength * iScalingFactorY;
497 CheckChangedPixels(changedPixelsCnt, aClearColorValue);
500 //Checks the rectangle filled using CFbsScreenDevice::ShadowArea
501 //The screen lines pixel values are tested against aClearColorValue value.
502 //Then the screen is testsed pixel by pixel that nothing is written outside the tested rectangle.
503 template <class TPixelType>
504 void CTScaling<TPixelType>::CheckRect(const TRect& aRc, const TPoint& aOrg, TPixelType aClearColorValue)
506 TPixelType data[KLegacyAppSizeWidth * KMaxScalingFactor];
508 TInt x = aOrg.iX + aRc.iTl.iX * iScalingFactorX;
509 TInt y = aOrg.iY + aRc.iTl.iY * iScalingFactorY;
510 for(i=0;i<(iScalingFactorY * aRc.Height());++i)
512 Mem::Fill(data, sizeof(data), 0x00);
513 iDrawDevice->ReadLine(x, y + i, aRc.Width() * iScalingFactorX, data, iDisplayMode);
514 for(TInt j=0;j<(aRc.Width() * iScalingFactorX);++j)
516 TEST(data[j] != aClearColorValue);
519 TInt changedPixelsCnt = iScalingFactorY * aRc.Width() * aRc.Height() * iScalingFactorX;
520 CheckChangedPixels(changedPixelsCnt, aClearColorValue);
523 //CFbsScreenDevice::WriteLine() and CFbsScreenDevice::ReadLine() test.
524 //(Set of test lines) X (Set of origins) X (Set of drawing modes) number of test cases.
525 template <class TPixelType>
526 void CTScaling<TPixelType>::WriteLine()
528 INFO_PRINTF1(_L("CFbsDrawDevice::WriteLine"));
530 TLineProps lineProps[] =
532 {0, 0, KLegacyAppSizeWidth - 1},
533 {0, KLegacyAppSizeHeight - 1, KLegacyAppSizeWidth - 1},
534 {10, 20, KLegacyAppSizeWidth / 2},
541 const TInt KLinesCnt = sizeof(lineProps) / sizeof(lineProps[0]);
547 const TInt KOriginsCnt = sizeof(ptOrg) / sizeof(ptOrg[0]);
548 for(TInt ll=0;ll<KOriginsCnt;++ll)
550 for(TInt line=0;line<KLinesCnt;++line)
552 for(TInt kk=0;kk<KDrawModesCnt;++kk)
554 ClearScreen(KDrawMode[kk]);
556 SetScalingSettings(ptOrg[ll], KScalingFactorX, KScalingFactorY, 1, 1);
557 iDrawDevice->WriteLine(lineProps[line].iX, lineProps[line].iY,
558 lineProps[line].iLength,
559 reinterpret_cast <TUint32*> (iTestData),
560 KDrawMode[kk].iDrawMode);
561 if(KDrawMode[kk].iDrawMode == CGraphicsContext::EDrawModePEN)
563 TPixelType writtenData[KLegacyAppSizeWidth];
564 Mem::FillZ(writtenData, sizeof(writtenData));
565 iDrawDevice->ReadLine(lineProps[line].iX, lineProps[line].iY,
566 lineProps[line].iLength,
567 writtenData, iDisplayMode);
568 for(TInt ii=0;ii<lineProps[line].iLength;++ii)
570 TEST(writtenData[ii] == iTestData[ii]);
573 SetScalingSettings(TPoint(), 1, 1, 1, 1);
574 CheckLine(lineProps[line], ptOrg[ll], KDrawMode[kk], KDrawMode[kk].iClearColorVal);
580 //CFbsScreenDevice::WriteRgb() and CFbsScreenDevice::ReadPixel() test.
581 //(Set of test points) X (Set of origins) X (Set of drawing modes) number of test cases.
582 template <class TPixelType>
583 void CTScaling<TPixelType>::WriteRgb()
585 INFO_PRINTF1(_L("CFbsDrawDevice::WriteRgb"));
590 TPoint(KLegacyAppSizeWidth - 1, 0),
591 TPoint(0, KLegacyAppSizeHeight - 1),
592 TPoint(KLegacyAppSizeWidth - 1, KLegacyAppSizeHeight - 1),
593 TPoint(KLegacyAppSizeWidth / 2, KLegacyAppSizeHeight / 2),
598 const TInt KPointsCnt = sizeof(pt) / sizeof(pt[0]);
604 const TInt KOriginsCnt = sizeof(ptOrg) / sizeof(ptOrg[0]);
605 for(TInt l=0;l<KOriginsCnt;++l)
607 for(TInt i=0;i<KPointsCnt;++i)
609 for(TInt k=0;k<KDrawModesCnt;++k)
611 ClearScreen(KDrawMode[k]);
612 SetScalingSettings(ptOrg[l], KScalingFactorX, KScalingFactorY, 1, 1);
613 TRgb val(KTestColorVal);
614 iDrawDevice->WriteRgb(pt[i].iX, pt[i].iY, val, KDrawMode[k].iDrawMode);
615 if(KDrawMode[k].iDrawMode == CGraphicsContext::EDrawModePEN)
617 TRgb writtenVal = iDrawDevice->ReadPixel(pt[i].iX, pt[i].iY);
618 switch (iDisplayMode)
621 TEST(writtenVal == TRgb::Color64K(val.Color64K()));
625 TEST(writtenVal == val);
632 SetScalingSettings(TPoint(0, 0), 1, 1, 1, 1);
637 CheckLine(props, ptOrg[l], KDrawMode[k], KDrawMode[k].iClearColorVal);
643 //CFbsScreenDevice::WriteRgbMulti() test.
644 template <class TPixelType>
645 void CTScaling<TPixelType>::WriteRgbMulti()
647 INFO_PRINTF1(_L("CFbsDrawDevice::WriteRgbMulti"));
651 TRect(TPoint(0, 0), TSize(KLegacyAppSizeWidth - 1, KLegacyAppSizeHeight - 1)),
652 TRect(TPoint(17, 11), TSize(KLegacyAppSizeWidth / 2, KLegacyAppSizeHeight / 2)),
653 TRect(TPoint(-1, -4), TSize(31, 12)),
654 TRect(TPoint(-3, -1), TSize(11, 11)),
655 TRect(TPoint(0, -2), TSize(6, 17))
657 const TInt KRcCnt = sizeof(rcProps) / sizeof(rcProps[0]);
663 const TInt KOriginsCnt = sizeof(ptOrg) / sizeof(ptOrg[0]);
664 for(TInt l=0;l<KOriginsCnt;++l)
666 for(TInt i=0;i<KRcCnt;++i)
668 for(TInt k=0;k<KDrawModesCnt;++k)
670 ClearScreen(KDrawMode[k]);
672 SetScalingSettings(ptOrg[l], KScalingFactorX, KScalingFactorY, 1, 1);
673 TRgb val(KTestColorVal);
674 iDrawDevice->WriteRgbMulti(rcProps[i].iTl.iX, rcProps[i].iTl.iY,
675 rcProps[i].Width(), rcProps[i].Height(),
677 KDrawMode[k].iDrawMode);
678 SetScalingSettings(TPoint(0, 0), 1, 1, 1, 1);
679 CheckWriteRgbMulti(rcProps[i], ptOrg[l], KDrawMode[k], KDrawMode[k].iClearColorVal);
685 //CFbsScreenDevice::WriteRgbAlphaLine() test.
686 //(Set of test lines) X (Set of origins) X (Set of drawing modes) number of test cases.
687 template <class TPixelType>
688 void CTScaling<TPixelType>::WriteRgbAlphaLine()
690 INFO_PRINTF1(_L("CFbsDrawDevice::WriteRgbAlphaLine"));
692 TLineProps lineProps[] =
694 {0, 0, KLegacyAppSizeWidth - 1},
695 {0, KLegacyAppSizeHeight - 1, KLegacyAppSizeWidth - 1},
696 {17, 3, KLegacyAppSizeWidth / 2},
702 const TInt KLinesCnt = sizeof(lineProps) / sizeof(lineProps[0]);
708 const TInt KOriginsCnt = sizeof(ptOrg) / sizeof(ptOrg[0]);
709 for(TInt l=0;l<KOriginsCnt;++l)
711 for(TInt i=0;i<KLinesCnt;++i)
713 for(TInt k=0;k<KDrawModesCnt;++k)
715 ClearScreen(KDrawMode[k]);
716 SetScalingSettings(ptOrg[l], KScalingFactorX, KScalingFactorY, 1, 1);
717 TUint8 rgbBuff[KLegacyAppSizeWidth * 3];
718 Mem::Fill(rgbBuff, sizeof(rgbBuff), KTestColorVal);
719 TUint8 maskBuff[KLegacyAppSizeWidth];
720 TUint8 maskChar = 0xF1;
721 Mem::Fill(maskBuff, sizeof(maskBuff), maskChar);
722 iDrawDevice->WriteRgbAlphaLine(lineProps[i].iX, lineProps[i].iY,
723 lineProps[i].iLength, rgbBuff, maskBuff, CGraphicsContext::EDrawModePEN);
724 SetScalingSettings(TPoint(0, 0), 1, 1, 1, 1);
725 CheckRgbAlphaLine(lineProps[i], ptOrg[l], KDrawMode[k].iClearColorVal);
731 //CFbsScreenDevice::WriteBinary() test.
732 template <class TPixelType>
733 void CTScaling<TPixelType>::WriteBinary()
735 INFO_PRINTF1(_L("CFbsDrawDevice::WriteBinary"));
747 const TInt KPtCnt = sizeof(pt) / sizeof(pt[0]);
753 const TInt KOriginsCnt = sizeof(ptOrg) / sizeof(ptOrg[0]);
754 for(TInt l=0;l<KOriginsCnt;++l)
756 for(TInt i=0;i<KPtCnt;++i)
758 for(TInt k=0;k<KDrawModesCnt;++k)
760 ClearScreen(KDrawMode[k]);
762 SetScalingSettings(ptOrg[l], KScalingFactorX, KScalingFactorY, 1, 1);
763 const TInt KHeight = 5;
764 const TInt KLength = 11;
765 TUint32 buff[KHeight];
766 TUint32 buffChar = 0xFFFFFFFF;
767 for(TInt ooo=0;ooo<KHeight;++ooo)
769 buff[ooo] = buffChar;
771 TRgb val(KTestColorVal);
772 iDrawDevice->WriteBinary(pt[i].iX, pt[i].iY, buff, KLength, KHeight,
773 val, KDrawMode[k].iDrawMode);
774 SetScalingSettings(TPoint(0, 0), 1, 1, 1, 1);
775 CheckWriteBinary(pt[i], ptOrg[l], KDrawMode[k].iClearColorVal, KLength, KHeight);
781 //CFbsScreenDevice::WriteBinaryLineVertical() test.
782 template <class TPixelType>
783 void CTScaling<TPixelType>::WriteBinaryLineVertical()
785 INFO_PRINTF1(_L("CFbsDrawDevice::WriteBinaryLineVertical"));
787 TLineProps lineProps[] =
789 {0, 0, KLegacyAppSizeHeight - 1},
790 {KLegacyAppSizeWidth - 1, 0, KLegacyAppSizeHeight - 1},
798 const TInt KLinesCnt = sizeof(lineProps) / sizeof(lineProps[0]);
804 const TInt KOriginsCnt = sizeof(ptOrg) / sizeof(ptOrg[0]);
805 for(TInt l=0;l<KOriginsCnt;++l)
807 for(TInt i=0;i<KLinesCnt;++i)
809 for(TInt k=0;k<KDrawModesCnt;++k)
811 ClearScreen(KDrawMode[k]);
813 SetScalingSettings(ptOrg[l], KScalingFactorX, KScalingFactorY, 1, 1);
814 const TInt KLength = 30;
815 TUint32 buff[KLength];
816 TUint32 buffChar = 0xFFFFFFFF;
817 for(TInt ooo=0;ooo<KLength;++ooo)
819 buff[ooo] = buffChar;
821 TRgb val(KTestColorVal);
822 iDrawDevice->WriteBinaryLineVertical(lineProps[i].iX, lineProps[i].iY,
823 buff, lineProps[i].iLength, val,
824 KDrawMode[k].iDrawMode, EFalse);
825 SetScalingSettings(TPoint(0, 0), 1, 1, 1, 1);
826 CheckVertLine(lineProps[i], ptOrg[l], KDrawMode[k].iClearColorVal);
832 //CFbsScreenDevice::WriteBinaryLine() test.
833 template <class TPixelType>
834 void CTScaling<TPixelType>::WriteBinaryLine()
836 INFO_PRINTF1(_L("CFbsDrawDevice::WriteBinaryLiine"));
849 const TInt KPtCnt = sizeof(pt) / sizeof(pt[0]);
855 const TInt KOriginsCnt = sizeof(ptOrg) / sizeof(ptOrg[0]);
856 for(TInt l=0;l<KOriginsCnt;++l)
858 for(TInt i=0;i<KPtCnt;++i)
860 for(TInt k=0;k<KDrawModesCnt;++k)
862 ClearScreen(KDrawMode[k]);
864 SetScalingSettings(ptOrg[l], KScalingFactorX, KScalingFactorY, 1, 1);
865 const TInt KHeight = 1;
866 const TInt KLength = 11;
867 TUint32 buff[KHeight];
868 TUint32 buffChar = 0xFFFFFFFF;
869 for(TInt ooo=0;ooo<KHeight;++ooo)
871 buff[ooo] = buffChar;
873 TRgb val(KTestColorVal);
874 iDrawDevice->WriteBinaryLine(pt[i].iX, pt[i].iY, buff, KLength,
875 val, KDrawMode[k].iDrawMode);
876 SetScalingSettings(TPoint(0, 0), 1, 1, 1, 1);
877 CheckWriteBinary(pt[i], ptOrg[l], KDrawMode[k].iClearColorVal, KLength, KHeight);
883 //CFbsScreenDevice::WriteRgbAlphaMulti() test.
884 template <class TPixelType>
885 void CTScaling<TPixelType>::WriteRgbAlphaMulti()
887 INFO_PRINTF1(_L("CFbsDrawDevice::WriteRgbAlphaMulti"));
889 TLineProps lineProps[] =
891 {0, 0, KLegacyAppSizeWidth - 1},
892 {0, KLegacyAppSizeHeight - 1, KLegacyAppSizeWidth - 1},
893 {17, 3, KLegacyAppSizeWidth / 2},
900 const TInt KLinesCnt = sizeof(lineProps) / sizeof(lineProps[0]);
906 const TInt KOriginsCnt = sizeof(ptOrg) / sizeof(ptOrg[0]);
907 for(TInt l=0;l<KOriginsCnt;++l)
909 for(TInt i=0;i<KLinesCnt;++i)
911 for(TInt k=0;k<KDrawModesCnt;++k)
913 ClearScreen(KDrawMode[k]);
915 SetScalingSettings(ptOrg[l], KScalingFactorX, KScalingFactorY, 1, 1);
916 TUint8 maskBuff[KLegacyAppSizeWidth];
917 TUint8 maskChar = 0xF1;
918 Mem::Fill(maskBuff, sizeof(maskBuff), maskChar);
919 TRgb val(KTestColorVal);
920 iDrawDevice->WriteRgbAlphaMulti(lineProps[i].iX, lineProps[i].iY,
921 lineProps[i].iLength, val, maskBuff);
922 SetScalingSettings(TPoint(0, 0), 1, 1, 1, 1);
923 CheckRgbAlphaLine(lineProps[i], ptOrg[l], KDrawMode[k].iClearColorVal);
929 //CFbsScreenDevice::ShadowArea() test.
930 template <class TPixelType>
931 void CTScaling<TPixelType>::ShadowArea()
933 INFO_PRINTF1(_L("CFbsDrawDevice::ShadowArea"));
937 TRect(TPoint(0, 0), TSize(KLegacyAppSizeWidth - 1, KLegacyAppSizeHeight - 1)),
938 TRect(TPoint(17, 11), TSize(KLegacyAppSizeWidth / 2, KLegacyAppSizeHeight / 2)),
939 TRect(TPoint(-1, -1), TSize(1, 1)),
940 TRect(TPoint(-4, -5), TSize(11, 8)),
941 TRect(TPoint(0, -6), TSize(3, 23)),
942 TRect(TPoint(-7, 0), TSize(24, 2)),
943 TRect(TPoint(5, -2), TSize(8, 9)),
944 TRect(TPoint(-4, 16), TSize(11, 8))
946 const TInt KRcCnt = sizeof(rcProps) / sizeof(rcProps[0]);
952 const TInt KOriginsCnt = sizeof(ptOrg) / sizeof(ptOrg[0]);
953 for(TInt l=0;l<KOriginsCnt;++l)
955 for(TInt i=0;i<KRcCnt;++i)
957 for(TInt k=0;k<KDrawModesCnt;++k)
959 TDrawModeProps drawModeProps(KDrawMode[k]);
960 --drawModeProps.iClearColorVal;//I want to avoid "255" clear color value.
961 for(TInt m=0;m<KShadowModesCnt;++m)
963 iDrawDevice->SetShadowMode(KShadowMode[m]);
964 ClearScreen(drawModeProps);
966 SetScalingSettings(ptOrg[l], KScalingFactorX, KScalingFactorY, 1, 1);
967 iDrawDevice->ShadowArea(rcProps[i]);
968 SetScalingSettings(TPoint(0, 0), 1, 1, 1, 1);
969 CheckRect(rcProps[i], ptOrg[l], drawModeProps.iClearColorVal);
974 iDrawDevice->SetShadowMode(CFbsDrawDevice::ENoShadow);
977 //CFbsScreenDevice::WriteRgbAlphaLine() test.
978 template <class TPixelType>
979 void CTScaling<TPixelType>::WriteRgbAlphaLine2()
981 INFO_PRINTF1(_L("CFbsDrawDevice::WriteRgbAlphaLine-2"));
983 TLineProps lineProps[] =
985 {0, 0, KLegacyAppSizeWidth - 1},
986 {0, KLegacyAppSizeHeight - 1, KLegacyAppSizeWidth - 1},
987 {17, 3, KLegacyAppSizeWidth / 2},
995 const TInt KLinesCnt = sizeof(lineProps) / sizeof(lineProps[0]);
1001 const TInt KOriginsCnt = sizeof(ptOrg) / sizeof(ptOrg[0]);
1002 for(TInt l=0;l<KOriginsCnt;++l)
1004 for(TInt i=0;i<KLinesCnt;++i)
1006 for(TInt k=0;k<KDrawModesCnt;++k)
1008 ClearScreen(KDrawMode[k]);
1010 SetScalingSettings(ptOrg[l], KScalingFactorX, KScalingFactorY, 1, 1);
1011 TUint8 rgbBuff1[KLegacyAppSizeWidth * 3];
1012 TUint8 rgbBuff2[KLegacyAppSizeWidth * 3];
1013 Mem::Fill(rgbBuff1, sizeof(rgbBuff1), KTestColorVal - 15);
1014 Mem::Fill(rgbBuff2, sizeof(rgbBuff2), KTestColorVal + 22);
1015 TUint8 maskBuff[KLegacyAppSizeWidth];
1016 TUint8 maskChar = 0xF1;
1017 Mem::Fill(maskBuff, sizeof(maskBuff), maskChar);
1018 iDrawDevice->WriteRgbAlphaLine(lineProps[i].iX, lineProps[i].iY,
1019 lineProps[i].iLength, rgbBuff1, rgbBuff2, maskBuff,
1020 KDrawMode[k].iDrawMode);
1021 SetScalingSettings(TPoint(0, 0), 1, 1, 1, 1);
1022 CheckRgbAlphaLine(lineProps[i], ptOrg[l], KDrawMode[k].iClearColorVal);
1028 template <class TPixelType>
1029 void CTScaling<TPixelType>::TestScalingSettingsInterface()
1031 INFO_PRINTF1(_L("MScalingSettings functionality test"));
1032 TEST(iDrawDevice != NULL);
1034 MScalingSettings* scalingSettings = NULL;
1035 TInt err = iDrawDevice->GetInterface(KScalingSettingsInterfaceID,
1036 reinterpret_cast <TAny*&> (scalingSettings));
1037 TEST2(err, KErrNone);
1038 TEST(scalingSettings != NULL);
1040 TEST(scalingSettings->IsScalingOff());
1042 const TInt factorXIn = 10, factorYIn = 13, divisorXIn = 1, divisorYIn = 1;
1043 TInt factorXOut = -1, factorYOut = -1, divisorXOut = -1, divisorYOut = -1;
1045 err = scalingSettings->Set(factorXIn, factorYIn, divisorXIn, divisorYIn);
1046 TEST2(err, KErrNone);
1047 TEST(!scalingSettings->IsScalingOff());
1048 scalingSettings->Get(factorXOut, factorYOut, divisorXOut, divisorYOut);
1050 TEST(factorXOut == factorXOut);
1051 TEST(factorYIn == factorYOut);
1052 TEST(divisorXIn == divisorXOut);
1053 TEST(divisorYIn == divisorYOut);
1055 MDrawDeviceOrigin* originInterface = NULL;
1056 err = iDrawDevice->GetInterface(KDrawDeviceOriginInterfaceID,
1057 reinterpret_cast <TAny*&> (originInterface));
1058 TEST2(err, KErrNone);
1059 TEST(originInterface != NULL);
1061 const TPoint ptOriginIn(20, 45);
1063 err = originInterface->Set(ptOriginIn);
1064 TEST2(err, KErrNone);
1065 originInterface->Get(ptOriginOut);
1066 TEST(ptOriginIn == ptOriginOut);
1068 SetScalingSettings(TPoint(0, 0), 1, 1, 1, 1);
1071 //Creates screen device and initializes ::DrawDevice global variable.
1072 template <class TPixelType>
1073 void CTScaling<TPixelType>::CreateScreenDeviceL()
1075 if (iDisplayMode == ENone)
1078 TInt address = NULL;
1079 User::LeaveIfError(HAL::Get(KDefaultScreenNo, HALData::EDisplayMemoryAddress,address));
1080 User::LeaveIfError(HAL::Get(KDefaultScreenNo, HALData::EDisplayXPixels, iPhysSize.iWidth));
1081 User::LeaveIfError(HAL::Get(KDefaultScreenNo, HALData::EDisplayYPixels, iPhysSize.iHeight));
1082 __ASSERT_DEBUG(iPhysSize.iWidth > 0 && iPhysSize.iHeight > 0 && address != NULL, User::Invariant());
1084 TPckgBuf<TScreenInfoV01> info;
1085 info().iScreenAddressValid = ETrue;
1086 info().iScreenAddress = reinterpret_cast <void*> (address);
1087 info().iScreenSize = iPhysSize;
1089 iDrawDevice = CFbsDrawDevice::NewScreenDeviceL(info(), iDisplayMode);
1090 TestScalingSettingsInterface();
1091 iBits = new (ELeave) TPixelType[::ByteSize(EColor256, iPhysSize)];
1092 iDrawDevice->SetUserDisplayMode(iDisplayMode);
1093 iDrawDevice->SetAutoUpdate(EFalse);
1094 iDrawDevice->SetBits(iBits);
1099 template <class TPixelType>
1100 void CTScaling<TPixelType>::PerformanceTest()
1102 INFO_PRINTF1(_L("CFbsDrawDevice, scaling - WriteRgb() performance test"));
1104 const TInt KDrawingsCnt = 1000000;
1107 TUint time1 = User::TickCount();
1109 for(i=0;i<KDrawingsCnt;i++)
1119 TRgb val(0x11, 0x12, i);
1120 iDrawDevice->WriteRgb(x, y, val, CGraphicsContext::EDrawModePEN);
1122 time1 = User::TickCount() - time1;
1124 TPoint ptOrigin(5, 3);
1125 SetScalingSettings(ptOrigin, KScalingFactorX, KScalingFactorY, 1, 1);
1127 TUint time2 = User::TickCount();
1129 for(i=0;i<KDrawingsCnt;i++)
1139 TRgb val(0x11, 0x12, i);
1140 iDrawDevice->WriteRgb(x, y, val, CGraphicsContext::EDrawModePEN);
1142 time2 = User::TickCount() - time2;
1144 SetScalingSettings(TPoint(0, 0), 1, 1, 1, 1);
1146 RDebug::Print(_L("Non-scaled device, time=%d\r\n"), time1);
1147 RDebug::Print(_L("Scaled device, time=%d\r\n"), time2);
1150 template <class TPixelType>
1151 void CTScaling<TPixelType>::RunTestCaseL(TInt aCurTestCase)
1153 // EColor64K and EColor256 is not supported, stop the test
1154 if (iDisplayMode == ENone)
1156 INFO_PRINTF1(_L("EColor64K and EColor256 are not supported, The test is not run"));
1162 ((CTScalingStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
1163 switch(aCurTestCase)
1167 if(iCurOrientation >= KOrientationsCnt)
1169 ((CTScalingStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
1174 ((CTScalingStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
1175 if (iCurOrientation==CFbsDrawDevice::EOrientationRotated90 || iCurOrientation==CFbsDrawDevice::EOrientationRotated270)
1177 iScalingFactorX=KScalingFactorY;
1178 iScalingFactorY=KScalingFactorX;
1182 iScalingFactorX=KScalingFactorX;
1183 iScalingFactorY=KScalingFactorY;
1185 INFO_PRINTF3(_L("Set scalling %d,%d"),iScalingFactorX,iScalingFactorY);
1186 if(iDrawDevice->SetOrientation(KOrientation[iCurOrientation]))
1188 INFO_PRINTF2(_L("Set orientation: ===EOrientation%S==="),&RotationName(iCurOrientation));
1192 INFO_PRINTF2(_L("Failed to set orientation: ===EOrientation%S==="),&RotationName(iCurOrientation));
1201 @SYMTestCaseID GRAPHICS-SCREENDRIVER-0022
1203 ((CTScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0022"));
1208 @SYMTestCaseID GRAPHICS-SCREENDRIVER-0023
1210 ((CTScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0023"));
1215 @SYMTestCaseID GRAPHICS-SCREENDRIVER-0024
1217 ((CTScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0024"));
1222 @SYMTestCaseID GRAPHICS-SCREENDRIVER-0025
1224 ((CTScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0025"));
1225 WriteRgbAlphaLine();
1229 @SYMTestCaseID GRAPHICS-SCREENDRIVER-0026
1231 ((CTScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0026"));
1236 @SYMTestCaseID GRAPHICS-SCREENDRIVER-0027
1238 ((CTScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0027"));
1239 WriteBinaryLineVertical();
1243 @SYMTestCaseID GRAPHICS-SCREENDRIVER-0028
1245 ((CTScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0028"));
1250 @SYMTestCaseID GRAPHICS-SCREENDRIVER-0029
1252 ((CTScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0029"));
1253 WriteRgbAlphaMulti();
1257 @SYMTestCaseID GRAPHICS-SCREENDRIVER-0030
1259 ((CTScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0030"));
1264 @SYMTestCaseID GRAPHICS-SCREENDRIVER-0031
1266 ((CTScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0031"));
1267 WriteRgbAlphaLine2();
1271 @SYMTestCaseID GRAPHICS-SCREENDRIVER-0032
1273 ((CTScalingStep*)iStep)->SetTestStepID(_L("GRAPHICS-SCREENDRIVER-0032"));
1277 ((CTScalingStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
1281 ((CTScalingStep*)iStep)->RecordTestResultL();
1285 static TDisplayMode GetDisplayModeL()
1287 TDisplayMode mode = EColor64K;
1288 CFbsDrawDevice* device = NULL;
1289 TRAPD(err, device = CFbsDrawDevice::NewScreenDeviceL(KDefaultScreenNo, mode));
1293 TRAPD(err, device = CFbsDrawDevice::NewScreenDeviceL(KDefaultScreenNo, mode));
1295 if (err == KErrNotSupported)
1305 CTScalingStep::CTScalingStep()
1307 SetTestStepName(KTScalingStep);
1310 CTGraphicsBase* CTScalingStep::CreateTestL()
1312 CTGraphicsBase* theTest = NULL;
1313 switch (GetDisplayModeL())
1317 INFO_PRINTF1(_L("Scaling - EColor64K"));
1318 theTest = new (ELeave) CTestColor64K(this, EColor64K);
1324 INFO_PRINTF1(_L("Scaling - EColor256"));
1325 theTest = new (ELeave) CTestColor256(this, EColor256);
1330 INFO_PRINTF1(_L("EColor64K and EColor256 are not supported"));
1331 theTest = new (ELeave) CTestNone(this, ENone);
1336 void CTScalingStep::TestSetupL()
1339 HAL::Get(KDefaultScreenNo, HALData::EDisplayColors, temp);//force HAL memory allocation