First public contribution.
1 // Copyright (c) 2003-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.
21 #include "TGraphicsHarness.h"
23 #define KRgbFadedBlack TRgb(0x808080)
24 const TInt KNumDispModes = 13;
25 const TInt KNumDrawModes = 6;
26 const TInt KNumTestRects = 10;
27 const TInt KNumTestColors = 12;
28 const TInt KNumTestBackgrounds = 6;
29 const TInt KNumShadowModes = 4;
30 const TInt KCheckBinaryPixelBufferSize = 64;
31 const TInt KNumBlendingColors = 3;
32 const TInt KNumColorsToBlend = 4;
34 //this is to allow EColor16MAP to be tested with extra colours
35 const TUint32 KMaxNon16Colours = 9;
37 //this is to allow EColor16MAP to be tested with extra background colours
38 const TUint32 KMaxNon16BackColours = 3;
40 const TDisplayMode TestDisplayMode[KNumDispModes] =
57 const TPtrC DisplayModeNames[KNumDispModes] =
74 const TDisplayMode TestDisplayMode1[] =
90 const TPtrC DisplayModeNames1[] =
106 const CGraphicsContext::TDrawMode TestDrawMode[KNumDrawModes] =
108 CGraphicsContext::EDrawModePEN,
109 CGraphicsContext::EDrawModeAND,
110 CGraphicsContext::EDrawModeXOR,
111 CGraphicsContext::EDrawModeOR,
112 CGraphicsContext::EDrawModeNOTSCREEN,
113 CGraphicsContext::EDrawModeNOTPEN
116 const TRect TestRect[KNumTestRects] =
126 TRect(0,0,30,34), //needs a height >32
127 TRect(1,1,7,7) // for DEF123772
130 const TRgb TestColor[KNumTestColors] =
141 TRgb((TUint32)0xff2665A3),
142 TRgb((TUint32)0x002766A4),
143 TRgb((TUint32)0x57339A4E),
146 const TRgb TestBackground[KNumTestBackgrounds] =
156 const TUint8 ditherlutab[16][4]=
157 {{ 0x0, 0x0, 0x0, 0x0, },
158 { 0x5, 0x0, 0x0, 0x0, },
159 { 0x5, 0x0, 0x0, 0x5, },
160 { 0x5, 0x0, 0x0, 0x5, },
161 { 0x5, 0x0, 0x5, 0x5, },
162 { 0x5, 0x5, 0x5, 0x5, },
163 { 0xa, 0x5, 0x5, 0x5, },
164 { 0xa, 0x5, 0x5, 0xa, },
165 { 0xa, 0x5, 0x5, 0xa, },
166 { 0xa, 0x5, 0xa, 0xa, },
167 { 0xa, 0xa, 0xa, 0xa, },
168 { 0xf, 0xa, 0xa, 0xa, },
169 { 0xf, 0xa, 0xa, 0xf, },
170 { 0xf, 0xa, 0xa, 0xf, },
171 { 0xf, 0xa, 0xf, 0xf, },
172 { 0xf, 0xf, 0xf, 0xf }};
175 This array has three colours, It would be used to blend the four colours using WriteRgbOutlineAndShadow ().
176 Four colours which needs blending are
177 O - Outline colour, first entry of this table
178 S - Shadow colour, second entry in this table
179 F - Foreground colour i.e. third entry and,
180 B - Background colur, It will be set inside the test function.
182 const TRgb TestOSFBColorsForBlending[KNumBlendingColors][KNumColorsToBlend] =
184 { KRgbBlack, TRgb(220,150,164,138), KRgbMagenta, KRgbWhite},
185 { KRgbDarkMagenta, KRgbBlue, KRgbDarkYellow, TRgb(20,250,160, 128)},
186 { TRgb(230,180,70,10), KRgbGreen, TRgb(20,250,160,168), KRgbBlack}
190 This lookup table is used for outline and shadow fonts. Four entries of this table represents
191 % of Outline, Shadow, Fill and Background color to be used to get the final color to be
194 While doing the blending of four colors it would use the following formula,
196 blendedXXXColor = (XXXOutlinePenColor * FourColorBlendLookup[index][KOutlineColorIndex] +
197 XXXShadowColor * FourColorBlendLookup[index][KShadowColorIndex] +
198 XXXFillColor * FourColorBlendLookup[index][KFillColorIndex] +
199 backgroundColor.XXX() * FourColorBlendLookup[index][KBackgroundColorIndex]) >> 8;
200 where XXX can be Red, Green or Blue
201 and index is the 8-bit value which will be provided by the rasterizer to decide which
202 entry of lookup table should be used. Right shift by eight will divide the calculated value in % with
203 256 to get the actual colour.
205 This table is provided by Monotype and MUST NOT be changed.
207 const TInt FourColorBlendLookup[256][4] = {
466 class TColorConvertor
469 virtual TInt Index(TRgb aColor) = 0;
470 virtual TRgb Color(TInt aIndex) = 0;
473 class TNullColorConvertor : public TColorConvertor
476 virtual TInt Index(TRgb /*aColor*/) { return 0; }
477 virtual TRgb Color(TInt /*aIndex*/) { return KRgbBlack; }
480 class TGray2ColorConvertor : public TColorConvertor
483 virtual TInt Index(TRgb aColor) { return aColor.Gray2(); }
484 virtual TRgb Color(TInt aIndex) { return TRgb::Gray2(aIndex); }
487 class TGray4ColorConvertor : public TColorConvertor
490 virtual TInt Index(TRgb aColor) { return aColor.Gray4(); }
491 virtual TRgb Color(TInt aIndex) { return TRgb::Gray4(aIndex); }
494 class TGray16ColorConvertor : public TColorConvertor
497 virtual TInt Index(TRgb aColor) { return aColor.Gray16(); }
498 virtual TRgb Color(TInt aIndex) { return TRgb::Gray16(aIndex); }
501 class TGray256ColorConvertor : public TColorConvertor
504 virtual TInt Index(TRgb aColor) { return aColor.Gray256(); }
505 virtual TRgb Color(TInt aIndex) { return TRgb::Gray256(aIndex); }
508 class TColor16ColorConvertor : public TColorConvertor
511 virtual TInt Index(TRgb aColor) { return aColor.Color16(); }
512 virtual TRgb Color(TInt aIndex) { return TRgb::Color16(aIndex); }
515 class TColor256ColorConvertor : public TColorConvertor
518 virtual TInt Index(TRgb aColor) { return aColor.Color256(); }
519 virtual TRgb Color(TInt aIndex) { return TRgb::Color256(aIndex); }
522 class TColor4KColorConvertor : public TColorConvertor
525 virtual TInt Index(TRgb aColor) { return aColor.Color4K(); }
526 virtual TRgb Color(TInt aIndex) { return TRgb::Color4K(aIndex); }
529 class TColor64KColorConvertor : public TColorConvertor
532 virtual TInt Index(TRgb aColor) { return aColor.Color64K(); }
533 virtual TRgb Color(TInt aIndex) { return TRgb::Color64K(aIndex); }
536 class TColor16MColorConvertor : public TColorConvertor
539 virtual TInt Index(TRgb aColor) { return aColor.Color16M(); }
540 virtual TRgb Color(TInt aIndex) { return TRgb::Color16M(aIndex); }
543 class TColor16MUColorConvertor : public TColorConvertor
546 virtual TInt Index(TRgb aColor) { return aColor.Color16MU(); }
547 virtual TRgb Color(TInt aIndex) { return TRgb::Color16MU(aIndex); }
550 class TColor16MAColorConvertor : public TColorConvertor
553 virtual TInt Index(TRgb aColor) { return aColor.Color16MA(); }
554 virtual TRgb Color(TInt aIndex) { return TRgb::Color16MA(aIndex); }
557 class TColor16MAPColorConvertor : public TColorConvertor
560 virtual TInt Index(TRgb aColor) { return aColor.Color16MAP(); }
561 virtual TRgb Color(TInt aIndex) { return TRgb::Color16MAP(aIndex); }
564 class CTLowLevel : public CTGraphicsBase
574 CTLowLevel(CTestStep* aStep);
577 //from CTGraphicsStep
578 virtual void RunTestCaseL(TInt aCurTestCase);
579 void TestScreenDrawL(TDisplayMode aDisplayMode);
583 void TestBitmapDraw(TDisplayMode aDisplayMode,const TSize& aSize);
588 void TestWriteLine();
589 void TestWriteBinary();
590 void TestWriteRGBAlpha();
591 void TestWriteAlphaLineEx();
592 void TestWriteAlphaLineNoShadowEx();
593 void TestWriteMaskLineNoShadowEx();
594 void ClosePanicDialogs();
595 void TestFastBlendBitmapMasked(const TInt aRetry = 0);
597 void TestWriteRgbOutlineAndShadow();
598 inline TInt ByteSize();
599 inline TBool Check(TBool aValue);
600 void CheckBuffer(TUint8* aWriteBuffer,TDisplayMode aWriteDispMode,TUint8* aReadBuffer,TDisplayMode aReadDispMode,TInt aPixelLength);
601 void CheckBinary(const TRect& aRect,TUint32* aBuffer,TRgb aForeColor,TRgb aBackColor,CGraphicsContext::TDrawMode aDrawMode,TInt aShadowMode,TBool aWrapDataWords,TBool aUp);
602 void CheckRgb(const TPoint& aPoint,TRgb aColor,TRgb aBackgroundColor,CGraphicsContext::TDrawMode aDrawMode,TInt aShadowMode);
603 void CheckRgb(const TRect& aRect,TRgb aColor,TRgb aBackgroundColor,CGraphicsContext::TDrawMode aDrawMode,TInt aShadowMode);
604 void CheckShadowRgb(const TRect& aRect,TRgb aColor,TInt aShadowMode);
605 void CheckScanline(TInt aX,TInt aY,TInt aLength,TRgb aFore1,TRgb aFore2,TRgb aBack1,TRgb aBack2,CGraphicsContext::TDrawMode aDrawMode);
606 void CheckLine(TUint8* aWriteBuffer,TUint8* aReadBuffer,TUint8* aBackBuffer,TInt aPixelLength,CGraphicsContext::TDrawMode aDrawMode,TDisplayMode aDispMode);
607 void CheckPixel(TUint8* aWriteBuffer,TDisplayMode aWriteDispMode,TUint8* aReadBuffer,TDisplayMode aReadDispMode,TInt aPixelLength,TDisplayMode aCompareDispMode);
608 void CheckBackground(const TRect& aRect,TRgb aBackgroundColor);
609 TBool CheckBlendedOutlineAndShadow(TRgb aOutlinePenColor, TRgb aShadowColor, TRgb aFillColor, TRgb aBackgroundColor, TInt aLookupIndex, TInt aLength, TUint8* aReadBuffer);
610 void Clear(TRgb aColor);
611 void CheckMatch(TUint32 aFirst, TUint32 aSecond);
612 TRgb ExtractRgbValue(TInt aX,TUint8* aBuffer,TDisplayMode aDispMode);
613 TUint32 ExtractBinaryValue(TInt aX,TUint32* aBuffer,TDisplayMode aDispMode);
614 void FillArray(TRgb aColor,TRgb aArray[4]);
615 void FillBuffer(TUint8* aBuffer, TInt aByteSize, TDisplayMode aDispMode, TBool aNoAlpha16MU = EFalse);
616 TInt LongWidth(TInt aWidth,TDisplayMode aDispMode);
617 void Normalize(TRgb& aColor);
618 void Normalize(TRgb& aColor, TDisplayMode aDispMode);
619 void Normalize(TRgb& aColor,TRgb aDitherColors[4]);
620 TRgb RgbValue(TRgb aFore,TRgb aBack,CGraphicsContext::TDrawMode aDrawMode);
621 TUint32 BinaryValue(TRgb aFore,TRgb aBack,CGraphicsContext::TDrawMode aDrawMode);
622 void Shadow(TRgb& aColor,TInt aShadowMode);
623 void Shadow(TUint8* aBuffer,TInt aByteLength,TInt aShadowMode);
624 TUint8 FadeGray(TInt aGray256);
625 TRgb FadeRgb(TRgb aColor, TBool aFastFade = EFalse);
626 TColorConvertor& ColorConvertor(TDisplayMode aDisplayMode);
627 void Blend(TUint8* aBuffer,TUint8* aBufferDest,TDisplayMode aDispMode);
628 void PostBlendShadow(TUint32 &aPmaColor);
629 void TestUserDisplayModeMapping();
630 void PrepareDestPixel(TDisplayMode aDevDisplayMode, TRgb& aRgb, TInt aDstAlpha);
631 void CheckMappedRgb(TDisplayMode aDevDisplayMode, TDisplayMode aUserDisplayMode, TRgb aRgb);
632 void CheckNormalizedRgb(TRgb aReadRgb, TRgb aCheckRgb, TDisplayMode aDevDisplayMode, TDisplayMode aUserDisplayMode, TBool aWriteRgbAlphaLine);
633 void WriteBinaryValue(TUint32 aX, TAny* const aPtr, TDisplayMode aMode, TUint32 aValue) const;
634 void MaskedBlendBuffer(TAny* aSrc, TDisplayMode aSrcMode, TAny* aDst,
635 TDisplayMode aDstMode, TUint32* aMsk, TInt aWidth, TBool aInvert);
636 TUint32 BytesForPixels(TUint32 aPixels, TDisplayMode aMode);
637 TBool CompareBlendMaskResults(TAny* aActual, TAny* aExpected,
638 TUint32 aWidth, TDisplayMode aMode, TBool aBlended, TDisplayMode aSrcMode = ENone);
640 CFbsDrawDevice* iDrawDevice;
643 TDisplayMode iDispMode;
644 TDisplayMode iUserDispMode;
650 TInt iReportIteration;
651 TInt iTotalReportIterations;
652 TNullColorConvertor iNullConvertor;
653 TGray2ColorConvertor iGray2Convertor;
654 TGray4ColorConvertor iGray4Convertor;
655 TGray16ColorConvertor iGray16Convertor;
656 TGray256ColorConvertor iGray256Convertor;
657 TColor16ColorConvertor iColor16Convertor;
658 TColor256ColorConvertor iColor256Convertor;
659 TColor4KColorConvertor iColor4KConvertor;
660 TColor64KColorConvertor iColor64KConvertor;
661 TColor16MColorConvertor iColor16MConvertor;
662 TColor16MUColorConvertor iColor16MUConvertor;
663 TColor16MAColorConvertor iColor16MAConvertor;
664 TColor16MAPColorConvertor iColor16MAPConvertor;
665 TColorConvertor* iColorConvertor[15];
666 TInt iOrientationEnd;
667 TInt iCurScreenDeviceModeIndex;
669 TBool iBlendTestColors;
670 TPostShadowMode iPostBlendShadow;
671 TBool i16MAUserDispMode;
672 TBool iUseFastFade; //used to check whether fast fading method is required or not
673 // while calling FadeRgb from CTLowLevel::Shadow(TRgb& aColor,TInt aShadowMode)
674 TBool iLastFailTestNo;
675 };//end of - class TestLowLevel
677 class CTLowLevel1 : public CTLowLevel
680 CTLowLevel1(CTestStep* aStep);
682 //from CTGraphicsStep
683 virtual void RunTestCaseL(TInt aCurTestCase);
686 class CTLowLevelStep : public CTGraphicsStep
691 //from CTGraphicsStep
692 virtual CTGraphicsBase* CreateTestL();
695 _LIT(KTLowLevelStep,"TLowLevel");
697 class CTLowLevel1Step : public CTGraphicsStep
702 //from CTGraphicsStep
703 virtual CTGraphicsBase* CreateTestL();
706 _LIT(KTLowLevel1Step,"TLowLevel1");